forked from hackertarget/maltego_transforms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetSharedDNS.py
45 lines (32 loc) · 1.17 KB
/
GetSharedDNS.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
#!/usr/bin/env python
# Maltego Transform to get hosts from HackerTarget.com (Shared DNS Server)
# with a HackerTarget.com Membership get an API key for additional quota (Free has 200 / day limit)
from MaltegoTransform import *
import sys
import os
import requests
APIKEY = ''
dnsserver = sys.argv[1]
hosts = []
m = MaltegoTransform()
try:
if len(APIKEY) == 80:
r = requests.get('https://api.hackertarget.com/findshareddns/?q=' + dnsserver + '&apikey=' + APIKEY)
else:
r = requests.get('https://api.hackertarget.com/findshareddns/?q=' + dnsserver)
if r.status_code != 200 or 'error check' in r.text:
m.addUIMessage("Error getting results - check input")
elif "Error invalid key" in r.text:
m.addUIMessage("Error invalid key")
elif "No DNS server" in r.text:
m.addUIMessage("No results found from HackerTarget.com")
elif "API count exceeded" in r.text:
m.addUIMessage("API count exceeded")
else:
hosts = str(r.text).split('\n')
hosts = filter(None, hosts)
for i in hosts:
m.addEntity('maltego.DNSName', i)
except Exception as e:
m.addUIMessage(str(e))
m.returnOutput()