forked from milo2012/carbonator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch_burp.py
232 lines (217 loc) · 6.29 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
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
#http://winappdbg.sourceforge.net/blog/google-1.06.tar.gz
bingAPIKey = ''
burpPath = '/pentest/burp/burpsuite_pro_v1.6.04.jar'
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 "Running Google Searches: "+str(domain).replace("save","")
urls = []
print "Found the below URLs in Google"
for url in search('site:'+domain, stop=50):
print url
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 "\n[*] Bing Reverse IP Lookup: "+str(ip)
print "\n[*] Found the below domains: "
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)
res = urllib2.urlopen(request)
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]
tmpDomain = domain
if ":" in domain:
domain = domain.split(":")[0]
if tmpDomain not in sites:
siteIP = getIP(domain)
if ip not in sites:
sites.append(ip)
if ip==siteIP:
sites.append(tmpDomain)
print tmpDomain
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()
tmpHost = args.host
print tmpHost
if "http" in tmpHost 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(args.host)
else:
if args.enableBing==True:
ip = getIP(tmpHost)
sites = reverseBing(ip)
for site in sites:
print site
tmpSite = site
ipSite = site
if ":" in tmpSite:
site = site.split(":")[0]
ipSite = getIP(site)
else:
ipSite = getIP(tmpSite)
if ip==ipSite:
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(tmpSite)
else:
site = tmpHost
if args.saveState:
site+=' save'
if args.enableGoogle:
getGoogleResults(site)
else:
removeFile()
runBurp(site)