
PyJFuzz - Python JSON Fuzzer
PyJFuzz is a small, extensible and ready-to-use framework used to fuzz JSON inputs, such as mobile endpoint REST API, JSON implementation, Browsers, cli executable and much more.
| Version | 1.1.0 |
|---|---|
| Homepage | http://www.mseclab.com/ |
| Github | https://github.com/mseclab/PyJFuzz |
| Author | Daniele Linguaglossa (@dzonerzy) |
| License | MIT - (see LICENSE file) |
Dependencies
In order to work PyJFuzz need some dependency, bottle,netifaces,GitPython and gramfuzz, you can install them from automatic setup.py installation.
Installation
You can install PyJFuzz with the following command
git clone https://github.com/mseclab/PyJFuzz.git && cd PyJFuzz && sudo python setup.py install
CLI tool
Once installed PyJFuzz will create both a python library and a command-line utility called pjf (screenshot below)
Library
PyJFuzz could also work as a library, you can import in your project like following
from pyjfuzz.lib import *
Classes
The available object/class are the following:
Examples
Below some trivial example of how-to implement PyJFuzz powered program
simple_fuzzer.py
from argparse import Namespace
from pyjfuzz.lib import *
config = PJFConfiguration(Namespace(json={"test": ["1", 2, True]}, nologo=True, level=6))
fuzzer = PJFFactory(config)
while True:
print fuzzer.fuzzed
custom_techniques.py
from argparse import Namespace
from pyjfuzz.lib import *
# Techniques may be defined by group , or by technique number
# groups are CHTPRSX , to understand what they are , please run pyjfuzz with -h switch or look at the command line screenshot
# This below will initalizate a config object which use only the P group attacks where P stay for Path Traversal
config = PJFConfiguration(Namespace(json={"test": ["1", 2, True]}, nologo=True, level=6, techniques="P"))
# once a config object is defined you can access to config.techniques to view the selected techniques for your group
print("Techniques IDs: {0}".format(str(config.techniques)))
# you can eventually modify them!
config.techniques = [2]
# This way only attack number 2 (LFI Attack) will be performed!
fuzzer = PJFFactory(config)
while True:
print fuzzer.fuzzed
simple_server.py
from argparse import Namespace
from pyjfuzz.lib import *
config = PJFConfiguration(Namespace(json={"test": ["1", 2, True]}, nologo=True, level=6, debug=True, indent=True))
PJFServer(config).run()
Sometimes you may need to modify standard non customizable settings such as HTTPS or HTTP server port, this can be done in the following way
from argparse import Namespace
from pyjfuzz.lib import *
config = PJFConfiguration(Namespace(json={"test": ["1", 2, True]}, nologo=True, level=6, indent=True))
print config.ports["servers"]["HTTP_PORT"] # 8080
print config.ports["servers"]["HTTPS_PORT"] # 8443
print config.ports["servers"]["TCASE_PORT"] # 8888
config.ports["servers"]["HTTPS_PORT"] = 443 # Change HTTPS port to 443
Remember: When changing default ports, you should always handle exception due to needed privileges!
Below a comprehensive list of all available settings / customization of PJFConfiguration object:
Configuration table
| Name | Type | Description |
|---|---|---|
| json | dict | JSON object to fuzz |
| json_file | str | Path to a JSON file |
| parameters | list<str> | List of parameters to fuzz (taken from JSON object) |
| techniques | str<int> | String of enable attacks, used to generate fuzzed JSON, such as XSS, LFI etc. ie "CHPTRSX" (Look techniques table) |
| level | int | Fuzzing level in the range 0-6 |
| utf8 | bool | If true switch from unicode encode to pure byte representation |
| indent | bool | Set whenever to indent the result object |
| url_encode | bool | Set whenever to URLEncode the result object |
| strong_fuzz | bool | Set whenever to use strong fuzzing (strong fuzzing will not maintain JSON structure, usefull for parser fuzzing) |
| debug | bool | Set whenever to enable debug prints |
| exclude | bool | Exclude from fuzzing parameters selected by parameters option |
| notify | bool | Set whenever to notify process monitor when a crash occurs only used with PJFServer |
| html | str | Path to an HTML directory to serve within PJFServer |
| ext_fuzz | bool | Set whenever to use binary from "command" as an externale fuzzer |
| cmd_fuzz | bool | Set whenever to use binary from "command" as fuzzer target |
| content_type | str | Set the content type result of PJFServer (default application/json) |
| command | list<str> | Command to execute each paramester is a list element, you could use shlex.split from python |
Techniques table