
PyJFuzz 是一个小巧、可扩展且开箱即用的框架,用于模糊测试 JSON 输入,例如移动端 REST API、JSON 实现、浏览器、CLI 可执行文件等。
| 版本 | 1.1.0 |
|---|---|
| 主页 | http://www.mseclab.com/ |
| Github | https://github.com/mseclab/PyJFuzz |
| 作者 | Daniele Linguaglossa (@dzonerzy) |
| 许可证 | MIT - (参见 LICENSE 文件) |
依赖
PyJFuzz 需要一些依赖才能正常工作:bottle、netifaces、GitPython 和 gramfuzz。你可以通过自动安装的 setup.py 来安装它们。
安装
你可以使用以下命令安装 PyJFuzz:
git clone https://github.com/mseclab/PyJFuzz.git && cd PyJFuzz && sudo python setup.py install
CLI 工具
安装完成后,PyJFuzz 会同时创建一个 Python 库和一个名为 pjf 的命令行工具(见下方截图)
库
PyJFuzz 也可以作为库使用,你可以通过以下方式导入到你的项目中:
from pyjfuzz.lib import *
类
可用的对象/类如下:
示例
下面是一些实现基于 PyJFuzz 的程序的简单示例
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()
有时你可能需要修改标准的不可自定义设置,例如 HTTPS 或 HTTP 服务器端口,可以通过以下方式实现:
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 # 将 HTTPS 端口改为 443
请记住: 更改默认端口时,应始终处理因权限不足而引发的异常!
以下是 PJFConfiguration 对象所有可用设置/自定义的完整列表:
配置表
技术表
下面是一些截图,让你了解 PyJFuzz 的预期效果:
PyJFuzz 附带一个名为 PyJFuzz Web Fuzzer 的内置工具,该工具通过 HTTP 和 HTTPS 服务器提供一个自动化的模糊测试控制台,即使你无法控制进程状态,也可以轻松地对几乎任何 Web 浏览器进行模糊测试!
有两个用于启动该工具的开关(--browser-auto 和 --fuzz-web):前者在发生崩溃时自动重启浏览器,后者则尝试捕获浏览器不再发出请求的情况。两者都会保存测试用例,下面是截图:
如有问题请通过 GitHub 提交,我会尽快修复。
以下是 PyJFuzz 发现的一些已知问题,该列表将每周更新
感谢使用 PyJFuzz!
快乐 Fuzzing 来自 mseclab
| 名称 | 类型 | 描述 |
|---|---|---|
| json | dict | 要模糊测试的 JSON 对象 |
| json_file | str | JSON 文件的路径 |
| parameters | list<str> | 要模糊测试的参数列表(取自 JSON 对象) |
| techniques | str<int> | 启用的攻击字符串,用于生成模糊测试后的 JSON,例如 XSS、LFI 等,如 "CHPTRSX"(请查看 技术表) |
| level | int | 模糊测试等级,范围为 0-6 |
| utf8 | bool | 如果为 true,则从 Unicode 编码切换到纯字节表示 |
| indent | bool | 是否缩进结果对象 |
| url_encode | bool | 是否对结果对象进行 URL 编码 |
| strong_fuzz | bool | 是否使用 强模糊测试(强模糊测试不会保持 JSON 结构,适用于解析器的模糊测试) |
| debug | bool | 是否启用调试输出 |
| exclude | bool | 从模糊测试中排除通过 parameters 选项选择的参数 |
| notify | bool | 是否在发生崩溃时通知进程监视器(仅与 PJFServer 一起使用) |
| html | str | 要在 PJFServer 中提供的 HTML 目录路径 |
| ext_fuzz | bool | 是否使用 "command" 中的二进制文件作为外部模糊测试工具 |
| cmd_fuzz | bool | 是否使用 "command" 中的二进制文件作为模糊测试目标 |
| content_type | str | 设置 PJFServer 的结果内容类型(默认为 application/json) |
| command | list<str> | 要执行的命令,每个参数是一个列表元素,你可以使用 Python 的 shlex.split |
| 索引 | 描述 |
|---|---|
| 0 | XSS 注入(多语言) |
| 1 | SQL 注入(多语言) |
| 2 | LFI 攻击 |
| 3 | SQL 注入多语言(2) |
| 4 | XSS 注入多语言(2) |
| 5 | RCE 注入(多语言) |
| 6 | LFI 攻击(2) |
| 7 | 数据 URI 攻击 |
| 8 | LFI 和 HREF 攻击 |
| 9 | 头部注入 |
| 10 | RCE 注入(多语言)(2) |
| 11 | 通用模板注入 |
| 12 | Flask 模板注入 |
| 13 | 随机字符攻击 |