-
Notifications
You must be signed in to change notification settings - Fork 23
/
blinder.py
144 lines (112 loc) · 4.89 KB
/
blinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from burp import IBurpExtender
from burp import IHttpListener
from burp import ITab
from lib.utils import URL
from lib.ui import GUI
from random import randint
import datetime
import sys
OP_INJECTION_PARAMS = [
URL.PARAM_URL,
URL.PARAM_BODY
]
OP_DEBUG_MODE = 0
OP_DEBUG_SERVER = "127.0.0.1"
OP_DEBUG_PORT = 80
OP_DEBUG_USE_HTTPS = 0
OP_SHOW_OUT_OF_SCOPE = 0
class BurpExtender(IBurpExtender, IHttpListener, ITab):
def getTabCaption(self):
# Setting extenstion tab name
return "Bit Blinder"
def getUiComponent(self):
# Returning instance of the panel as in burp's docs
return self.ui.panel
def registerExtenderCallbacks(self, callbacks):
gui = GUI() # Local instance of the GUI class
self.ui = gui.gui()
# Registering callbacks from burp api
self.callbacks = callbacks
self.callbacks.setExtensionName("BIT/Blinder")
self.callbacks.registerHttpListener(self)
# Redirect the stdout to burp stdout
sys.stdout = self.callbacks.getStdout()
# Saving IExtensionHelpers to use later
self.helpers = self.callbacks.getHelpers()
# Settings up the main gui
self.callbacks.customizeUiComponent(self.ui.panel)
self.callbacks.addSuiteTab(self)
print("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
print("- Developer: Ahmed Ezzat (BitTheByte) -")
print("- Github: https://github.com/BitTheByte -")
print("- Version: 0.05b -")
print("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
print("[WARNING] MAKE SURE TO EDIT THE SETTINGS BEFORE USE")
print("[WARNING] THIS TOOL WILL WORK FOR IN-SCOPE ITEMS ONLY")
print("[WARNING] THIS TOOL WILL CONSUME TOO MUCH BANDWIDTH")
return
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
# Check if tool is enabled from the gui panel
if not self.ui.enable.isSelected(): return
# Check if it's not a request from burp
if not messageIsRequest: return
request = messageInfo.getRequest()
requestInfo = self.helpers.analyzeRequest(messageInfo)
url = requestInfo.getUrl()
# Check if the url in the scope
if not self.callbacks.isInScope(url):
if OP_SHOW_OUT_OF_SCOPE:
print(f"[-] {url} is out of scope")
return
https = 1 if 'https' in requestInfo.url.getProtocol() else 0
payloads = self.ui.get_payloads()
body = request[requestInfo.getBodyOffset():]
path = requestInfo.url.getPath()
host = requestInfo.url.getHost()
port = requestInfo.url.port
method = requestInfo.getMethod()
headers = requestInfo.getHeaders()
paramters = requestInfo.getParameters()
vparams = [p for p in paramters if p.getType() in OP_INJECTION_PARAMS]
req_time = datetime.datetime.now().strftime('%m/%d|%H:%M:%S')
print("====================================================")
print(f"[{req_time}] Host: %s" % host)
print(f"[{req_time}] Path: %s" % path)
print(f"[{req_time}] Port: %i" % port)
print(f"[{req_time}] Method: %s" % method)
print(f"[{req_time}] Using http: %i" % (not https))
print(f"[{req_time}] Injection points: %s" % len(vparams))
print("====================================================")
new_paramters_value = []
for paramter in vparams:
name = paramter.getName()
value = paramter.getValue()
ptype = paramter.getType()
# To prevent self scanning
if name == "blinder_ignore_request" and value == "yes": return
if self.ui.randomize.isSelected():
payload = payloads[randint(0, len(payloads) - 1)]
else:
payload = payloads[0]
# Adding the new paramters to array to use it for later
new_paramters_value.append(
self.helpers.buildParameter(name, payload, ptype)
)
for paramter in new_paramters_value:
name = paramter.getName()
value = paramter.getValue()
ptype = paramter.getType()
updated_request = self.helpers.addParameter(
self.helpers.updateParameter(request, paramter),
self.helpers.buildParameter("blinder_ignore_request", "yes", 0)
)
if OP_DEBUG_MODE:
self.callbacks.makeHttpRequest(
OP_DEBUG_SERVER, OP_DEBUG_PORT,
OP_DEBUG_USE_HTTPS, updated_request
)
else:
self.callbacks.makeHttpRequest(
host, port, https, updated_request
)
return