/dibber

用于自动搜索 Python 沙箱逃逸、SSTI 攻击链的小工具

Primary LanguagePythonMIT LicenseMIT

dibber

用于搜索 Python 特定的对象/函数/模块,产出的 payload 的可用于 Python 沙箱逃逸、SSTI 等等。

help

usage: dibber.py [-h] --check CHECK [--depth DEPTH] [--disable-cache] [--verbose VERBOSE] [--dir DIR] [--eval EVAL] [--debug] [--mini] input

Version: 1.0; Supported all python versions

positional arguments:
  input              input the initial searching instance

optional arguments:
  -h, --help         show this help message and exit
  --check CHECK      how to check the payload?
  --depth DEPTH      max searching depth
  --disable-cache    disable cache
  --verbose VERBOSE  verbose level
  --dir DIR          how to get the attributes?
  --eval EVAL        how to turn the payload from string-format to instance?
  --debug            run in debug mode
  --mini             find the shortest payload

cookbook

理论上支持所有版本的 Python

示例

  1. 搜索 python code "".__class__.__mro__[-1].__subclasses__() 的利用链:

python dibber.py --check run_script_os --depth 6 '"".__class__.__mro__[-1].__subclasses__()'

  1. 搜索 jinja2 self 的利用链:

python dibber.py --check keyword_check --eval jinja2_template 'self' --depth 4

  1. 搜索 mako context 的利用链:

python dibber.py --check keyword_check --eval mako_template 'context' --depth 4

编写插件

有两个文件夹:

  1. check_func: 这里面的函数用于检查是否成功找到一条利用链
  2. eval_func: 这里面的函数执行字符串形式的代码,返回执行的结果

如果有特殊的需要(例如需要特殊的检查逻辑或者遇到特殊的模板无法直接 eval 等),直接按照已有插件,新增即可。

supported

  • raw python code
  • flask
  • mako

Others

Stargazers over time