-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathacamar.py
More file actions
267 lines (187 loc) · 6.51 KB
/
acamar.py
File metadata and controls
267 lines (187 loc) · 6.51 KB
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
257
258
259
260
261
262
263
264
265
266
267
#!/usr/bin/env python
import sys, requests, json, os, threading
from bs4 import BeautifulSoup as bs
def enterRes(e):
e = e.split('/', 1)[0]
if e not in result:
result.append(e)
def enumHackertarget():
print('[!] Enumerating hackertarget.com')
r = requests.get('https://api.hackertarget.com/hostsearch/?q=' + domain).text
e = r.split('\n')
print('\t - proceeding JSON output')
for i in e:
enterRes(i.split(',')[0])
def enumPtrarchive():
print('[!] Enumerating ptrarchive.com')
c = requests.Session()
h = {
'Referer': 'http://www.ptrarchive.com',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5'
}
t = {'pa_id': '1337'}
print('\t - hooking up page via fake-cookie "pa_id: 1337"')
r = c.get('http://www.ptrarchive.com/tools/search4.htm?label=' + domain + '&date=ALL', headers=h, cookies=t).text
s = bs(r, 'html.parser')
e = s.find('pre').text.split('\n')
print('\t - proceeding HTML for filtering out the result')
for i in e:
e = i[i.find(']'):].split(' ')
try:
if e[1].endswith('.' + domain) and not e[1].startswith('*'):
enterRes(e[1])
except IndexError:
pass
def enumCertspotter():
print('[!] Enumerating certspotter.com')
r = requests.get('https://certspotter.com/api/v0/certs?domain=' + domain).text
j = json.loads(r)
print('\t - proceeding JSON output')
for i in j:
for e in i['dns_names']:
if e.endswith('.' + domain) and not e.startswith('*'):
enterRes(e)
def enumRiddler():
print('[!] Enumerating riddler.io')
r = requests.get('https://riddler.io/search?q=pld:' + domain).text
s = bs(r, 'html.parser')
e = s.findAll('td', class_='col-lg-5 col-md-5 col-sm-5')
print('\t - proceeding HTML for filtering out the result')
for i in e:
enterRes(i.text.strip())
def enumCrt():
print('[-] Enumerating crt.sh')
r = requests.get('https://crt.sh/?q=%25' + domain).text
s = bs(r, 'html.parser')
try:
e = s.findAll('table')[1].findAll('tr')
except IndexError:
print('\t - crt.sh did not respond, continueing')
else:
print('\t - proceeding HTML for filtering out the result')
for i in e:
e = i.findAll('td')
try:
e = e[4].text
if e.endswith('.' + domain) and not e.startswith('*'):
enterRes(e)
except IndexError:
pass
def enumSecuritytrails():
print('[!] Enumerating securitytrails.com')
r = requests.get('https://securitytrails.com/list/apex_domain/' + domain).text
s = bs(r, 'html.parser')
e = s.findAll('td')
print('\t - proceeding HTML for filtering out the result')
for i in e:
e = i.find('a')
if e:
enterRes(e.text)
def enumThreatminer():
print('[!] Enumerating threatminer.org')
try:
r = requests.get('https://api.threatminer.org/v2/domain.php?q=' + domain + '&rt=5', timeout=6).text
j = json.loads(r)
print('\t - proceeding JSON output')
for i in j['results']:
enterRes(i)
except requests.exceptions.Timeout:
print('\t - API "api.threatminer.org/v2" looks down from here!')
pass
def enumVirustotal():
print('[!] Enumerating virustotal.com')
r = requests.get('https://www.virustotal.com/ui/domains/' + domain + '/subdomains?limit=40').text
j = json.loads(r)
try:
n = str(j['links']['next'])
c = 1
for i in j['data']:
enterRes(i['id'])
while type(n) is str:
print('\t proceeding result set: ' + str(c))
r = requests.get(n).text
j = json.loads(r)
for i in j['data']:
enterRes(i['id'])
try:
n = str(j['links']['next'])
c = c + 1
except KeyError:
break
except KeyError:
print('\t - result-set consists of < 40 entries')
for i in j['data']:
enterRes(i['id'])
def enumThreatcrowd():
print('[!] Enumerating threadcrowd.com')
r = requests.get('https://threatcrowd.org/searchApi/v2/domain/report/?domain=' + domain).text
j = json.loads(r)
print('\t - proceeding JSON output')
if "subdomains" not in j:
print('\t - JSON output seems to be empty!')
return
for e in j['subdomains']:
enterRes(e)
def enumFindsubdomains():
print('[!] Enumerating findsubdomains.com')
r = requests.get('https://findsubdomains.com/subdomains-of/' + domain).text
s = bs(r, 'html.parser')
e = s.findAll('td', {'data-field': 'Domain'})
print('\t - proceeding HTML for filtering out the result')
for i in e:
if i.get('title'):
enterRes(i.get('title'))
def enumDNSDumpster():
print('[!] Enumerating dnsdumpster.com')
print('\t - requesting valid session')
c = requests.Session()
r = c.get('https://dnsdumpster.com').text
h = {'Referer': 'https://dnsdumpster.com'}
t = c.cookies.get_dict()['csrftoken']
print('\t - got valid session: ' + t + ', proceeding output')
r = c.post('https://dnsdumpster.com', data={'csrfmiddlewaretoken': t, 'targetip': domain}, headers=h).text
s = bs(r, 'html.parser')
t = s.findAll('table')[-1].findAll('td', class_='col-md-4')
for i in t:
t = i.text.split()[0]
enterRes(t)
try:
domain = sys.argv[1]
except IndexError:
print('[X] No domain passed')
sys.exit()
result = []
output = open('results/' + domain + '.txt', 'w')
print('[~] Acamar.py v.0.1 written by @SI9INT | Target set to: ' + domain)
functions = [
enumDNSDumpster,
enumFindsubdomains,
enumThreatcrowd,
enumThreatminer,
enumVirustotal,
enumSecuritytrails,
enumHackertarget,
enumCrt,
enumCertspotter,
enumRiddler,
enumPtrarchive
]
threads = []
if __name__ == '__main__':
for f in functions:
t = threading.Thread(target=f)
t.start()
threads.append(t)
for t in threads:
t.join()
filtered = list(filter(None, result))
try:
for i in filtered:
output.write(i + '\n')
finally:
output.close()
print('[!] Finished, printing result:')
os.system('cat results/' + domain + '.txt')
print('[!] Counting ' + str(len(result)) + ' unique subdomains')