-
Notifications
You must be signed in to change notification settings - Fork 23
/
threatcrowd_domain.py
59 lines (53 loc) · 2.72 KB
/
threatcrowd_domain.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
from recon.core.module import BaseModule
import time
class Module(BaseModule):
meta = {
'name': 'ThreatCrowd API Reverse Whois',
'author': 'ScumSec 0x1414',
'description': 'Harvests email address of domain registrant and then crawls all domains registered by this registrant. Updates the \'domains\' table with the results.',
'query': 'SELECT DISTINCT domain FROM domains WHERE domain IS NOT NULL',
'comments': (
'One request \ 10 seconds'
),
}
def module_run(self, domains):
for domain in domains:
self.heading(domain, level=0)
base_url = 'https://www.threatcrowd.org/searchApi/v2/domain/report/'
payload = {'domain': domain}
resp = self.request(base_url, payload=payload)
registrant_emails = []
if resp.status_code == 200:
if resp.json['response_code'] == '1':
if resp.json['emails']:
for email in resp.json['emails']:
if email.endswith(domain):
self.output('%s => Registrant email found!' % email)
registrant_emails.append(email)
else:
self.alert('%s => No registrant emails found!' % domain)
else:
self.alert('%s => No data about this domain!' % domain)
else:
self.alert('%s => Bad request!' % domain)
# "Please limit all requests to no more than one request every ten seconds."
# https://github.com/threatcrowd/ApiV2#limits
time.sleep(10)
for registrant_email in registrant_emails:
self.heading(registrant_email, level=0)
base_url = 'https://www.threatcrowd.org/searchApi/v2/email/report/'
payload = {'email': registrant_email}
resp = self.request(base_url, payload=payload)
if resp.status_code == 200:
if resp.json['response_code'] == '1':
if resp.json['domains']:
for new_domain in resp.json['domains']:
if new_domain:
self.add_domains(new_domain)
else:
self.alert('%s => No new domains by registrant email!' % registrant_email)
else:
self.alert('%s => No data about this registrant email!' % registrant_email)
else:
self.alert('%s => Bad request!' % registrant_email)
time.sleep(10)