1
+ #!/usr/bin/env python
2
+ #coding:gbk
3
+ from burp import IBurpExtender
4
+ from burp import IIntruderPayloadGeneratorFactory
5
+ from burp import IIntruderPayloadGenerator
6
+ import base64
7
+ import json
8
+ import re
9
+ import urllib2
10
+ import ssl
11
+
12
+ host = ('127.0.0.1' , 8899 )
13
+
14
+ class BurpExtender (IBurpExtender , IIntruderPayloadGeneratorFactory ):
15
+ def registerExtenderCallbacks (self , callbacks ):
16
+ #注册payload生成器
17
+ callbacks .registerIntruderPayloadGeneratorFactory (self )
18
+ #插件里面显示的名字
19
+ callbacks .setExtensionName ("xp_CAPTCHA" )
20
+ print 'xp_CAPTCHA 中文名:瞎跑验证码\n blog:http://www.nmd5.com/\n T00ls:https://www.t00ls.net/ \n The loner安全团队 author:算命縖子\n \n 用法:\n 在head头部添加xiapao:验证码的URL\n \n 如:\n \n POST /login HTTP/1.1\n Host: www.baidu.com\n User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0\n Accept: text/plain, */*; q=0.01\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Content-Type: application/x-www-form-urlencoded; charset=UTF-8\n X-Requested-With: XMLHttpRequest\n xiapao:http://www.baidu.com/get-validate-code\n Content-Length: 84\n Connection: close\n Cookie: JSESSIONID=24D59677C5EDF0ED7AFAB8566DC366F0\n \n username=admin&password=admin&vcode=8888\n \n '
21
+
22
+ def getGeneratorName (self ):
23
+ return "xp_CAPTCHA"
24
+
25
+ def createNewInstance (self , attack ):
26
+ return xp_CAPTCHA (attack )
27
+
28
+ class xp_CAPTCHA (IIntruderPayloadGenerator ):
29
+ def __init__ (self , attack ):
30
+ tem = "" .join (chr (abs (x )) for x in attack .getRequestTemplate ()) #request内容
31
+ cookie = re .findall ("Cookie: (.+?)\r \n " , tem )[0 ] #获取cookie
32
+ xp_CAPTCHA = re .findall ("xiapao:(.+?)\r \n " , tem )[0 ]
33
+ ssl ._create_default_https_context = ssl ._create_unverified_context #忽略证书,防止证书报错
34
+ print xp_CAPTCHA + '\n '
35
+ print 'cookie:' + cookie + '\n '
36
+ self .xp_CAPTCHA = xp_CAPTCHA
37
+ self .cookie = cookie
38
+ self .max = 1 #payload最大使用次数
39
+ self .num = 0 #标记payload的使用次数
40
+ self .attack = attack
41
+
42
+ def hasMorePayloads (self ):
43
+ #如果payload使用到了最大次数reset就清0
44
+ if self .num == self .max :
45
+ return False # 当达到最大次数的时候就调用reset
46
+ else :
47
+ return True
48
+
49
+ def getNextPayload (self , payload ): # 这个函数请看下文解释
50
+ xp_CAPTCHA_url = self .xp_CAPTCHA #验证码url
51
+
52
+ print xp_CAPTCHA_url
53
+ headers = {"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" ,"Cookie" :self .cookie }
54
+ request = urllib2 .Request (xp_CAPTCHA_url ,headers = headers )
55
+ CAPTCHA = urllib2 .urlopen (request ) #获取图片
56
+ CAPTCHA_base64 = base64 .b64encode (CAPTCHA .read ()) #把图片base64编码
57
+
58
+ request = urllib2 .Request ('http://%s:%s/base64' % host , 'base64=' + CAPTCHA_base64 )
59
+ response = urllib2 .urlopen (request ).read ()
60
+ print (response )
61
+ return response
62
+
63
+ def reset (self ):
64
+ self .num = 0 # 清零
65
+ return
0 commit comments