forked from hackertarget/maltego_transforms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GetReverseIP.py
43 lines (34 loc) · 1.25 KB
/
GetReverseIP.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
#!/usr/bin/env python
# Maltego Transform to get hosts from HackerTarget.com (Reverse IP Search)
# 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 = ''
ipaddress = sys.argv[1]
hosts = []
m = MaltegoTransform()
try:
if len(APIKEY) == 80:
r = requests.get('https://api.hackertarget.com/reverseiplookup/?q=' + ipaddress + '&apikey=' + APIKEY)
else:
r = requests.get('https://api.hackertarget.com/reverseiplookup/?q=' + ipaddress)
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 A records" 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)
else:
m.addUIMessage("No results found from Reverse IP Search")
except Exception as e:
m.addUIMessage(str(e))
m.returnOutput()