-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathlaunch_burp.py
256 lines (233 loc) · 6.95 KB
/
launch_burp.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import argparse
import urllib2, socket,sys,base64,os
from xml.dom.minidom import parse, parseString
import socket
from google import search
from urlparse import urlparse
import os.path
# Initially written by milo2010 @ https://github.com/milo2012/carbonator/
# To install the google api library execute the following commandi as root
# wget http://winappdbg.sourceforge.net/blog/google-1.06.tar.gz && tar -xf google-1.06.tar.gz && cd google-1.06 && python setup.py install
bingAPIKey = ''
#lets find the latest version of burp.
burp_paths = ['/usr/bin/',
'/pentest/burp/',
'./',
'../burp_suite/',
'../burp/',
'../']
burp_filenames = [
'burp',
'burpsuite',
'burpsuite_pro_v1.6.',
'burpsuite_pro_v1.7.']
burpPath = ''
for test_path in reversed(burp_paths):
for test_filename in reversed(burp_filenames): #run through path hunt list in reverse from newest version to oldest
for version_guess in range(0,100):
#print test_path + test_filename + str(version_guess) + ".jar"
if os.path.isfile(test_path + test_filename + str(version_guess) + ".jar"):
burpPath = test_path + test_filename + str(version_guess) + ".jar"
print "Found Burp Suite Pro JAR file."
break
if len(burpPath) > 0: #double break out of nested for loops
break
if len(burpPath) > 0: #double break out of nested for loops
break
if not os.path.isfile(burpPath):
print "Could not find the Burp Suite Pro JAR file. Please update source."
sys.exit(1)
runHeadless = False
def isOpen(ip,port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
return True
except:
return False
def removeFile():
try:
os.remove('links.txt')
except OSError:
pass
def getIP(domain):
return socket.gethostbyname(domain)
def getGoogleResults(domain):
print "Google: "+str(domain)
urls = []
for url in search('site:'+domain, stop=50):
urls.append(url)
f = open('links.txt', 'w')
for item in urls:
f.write("%s\n" % item)
f.close()
return urls
def reverseBing(ip):
print "Bing: "+str(ip)
sites = []
skip = 0
top = 50
while skip < 200:
url = "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Web?Query='ip:%s'&$top=%s&$skip=%s&$format=Atom"%(ip,top,skip)
request = urllib2.Request(url)
auth = base64.encodestring("%s:%s" % (bingAPIKey, bingAPIKey)).replace("\n", "")
request.add_header("Authorization", "Basic %s" % auth)
try:
res = urllib2.urlopen(request)
except urllib2.HTTPError as e:
print "Bing authentication failed. Please check your API key: "+str(e)
sys.exit(1)
data = res.read()
xmldoc = parseString(data)
site_list = xmldoc.getElementsByTagName('d:Url')
for site in site_list:
domain = site.childNodes[0].nodeValue
domain = domain.split("/")[2]
if domain not in sites:
sites.append(domain)
skip += 50
print "Total domains found: %s \n" %(len(sites))
for site in sites:
print site
return sites
def runBurp(url):
print url
if "http" not in url and "https" not in url:
if isOpen(url,80):
url = "http://"+url
else:
url = "https://"+url
if runHeadless==True:
cmd = 'java -jar -Xmx2048m -Djava.awt.headless=true '+burpPath+' '+url
else:
cmd = 'java -jar -Xmx2048m '+burpPath+' '+url
print cmd
os.system(cmd)
parser = argparse.ArgumentParser(description='Burp automator')
parser.add_argument('-host', help='Enter an IP address or Domain name')
parser.add_argument('-saveState', action='store_true', help='Save Burpsuite State')
parser.add_argument('-enableBing', action='store_true', help='Enable Bing Reverse IP')
parser.add_argument('-enableGoogle', action='store_true', help='Enable Google Search')
parser.add_argument('-file', help='File containing Domain names or IP addresses')
parser.add_argument('-headless', action='store_true', help='Run Burp headless')
args = parser.parse_args()
if args.host==None and args.file==None:
print "\n[!] Please run 'python2.7 launch_burp.py -h'\n"
sys.exit()
else:
if args.headless:
#global runHeadless
runHeadless=True
if args.file:
if os.path.exists(args.file):
try:
with open(args.file) as f:
for line in f:
host = line.strip("\n")
tmpHost = host
if "http" in host or "https" in tmpHost:
parse_object = urlparse(tmpHost)
fqdn = str(parse_object.hostname)
tmpHost = fqdn
if any(c.isalpha() for c in tmpHost)==False:
if args.enableBing==True:
if len(bingAPIKey)<1:
sys.exit("[!] Please check your bingAPIKey !")
sites = reverseBing(tmpHost)
for site in sites:
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)
else:
site = tmpHost
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(host)
else:
if args.enableBing==True:
ip = getIP(tmpHost)
sites = reverseBing(ip)
for site in sites:
ipSite = getIP(site)
if ip==ipSite:
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)
else:
site = host
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)
except:
pass
else:
print "\n[!] Please check your input filename.\n"
sys.exit()
host = args.host
print "Setting Target: " + host
if "http" in host or "https" in host:
parse_object = urlparse(host)
fqdn = str(parse_object.hostname)
host = fqdn
if any(c.isalpha() for c in host)==False:
if args.enableBing==True:
if len(bingAPIKey)<1:
sys.exit("[!] Please check your bingAPIKey !")
sites = reverseBing(host)
for site in sites:
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)
else:
site = host
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(args.host)
else:
if args.enableBing==True:
ip = getIP(host)
sites = reverseBing(ip)
for site in sites:
ipSite = getIP(site)
if ip==ipSite:
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)
else:
site = host
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)