Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Use Robtex.com's new API.

Steve1deafa3390cb
diff --git a/modules/sfp_robtex.py b/modules/sfp_robtex.py
index 24c01080..5f977066 100644
--- a/modules/sfp_robtex.py
+++ b/modules/sfp_robtex.py
@@ -25,18 +25,23 @@ class sfp_robtex(SpiderFootPlugin):
opts = {
'cohostsamedomain': False,
'verify': True,
- 'api_key': ""
+ 'netblocklookup': True,
+ 'maxnetblock': 24,
+ 'subnetlookup': True,
+ 'maxsubnet': 24
}
# Option descriptions
optdescs = {
'cohostsamedomain': "Treat co-hosted sites on the same target domain as co-hosting?",
'verify': "Verify co-hosts are valid by checking if they still resolve to the shared IP.",
- 'api_key': "Robtex.com requires an API key, obtained from the Mashape.com marketplace."
+ 'netblocklookup': "Look up all IPs on netblocks deemed to be owned by your target for possible co-hosts on the same target subdomain/domain?",
+ 'maxnetblock': "If looking up owned netblocks, the maximum netblock size to look up all IPs within (CIDR value, 24 = /24, 16 = /16, etc.)",
+ 'subnetlookup': "Look up all IPs on subnets which your target is a part of for identifying co-hosts?",
+ 'maxsubnet': "If looking up subnets, the maximum subnet size to look up all the IPs within (CIDR value, 24 = /24, 16 = /16, etc.)"
}
results = list()
- errorState = False
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
@@ -47,7 +52,7 @@ class sfp_robtex(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return ["IP_ADDRESS", "NETBLOCK_OWNER"]
+ return ["IP_ADDRESS", "NETBLOCK_OWNER", "NETBLOCK_MEMBER"]
# What events this module produces
# This is to support the end user in selecting modules based on events
@@ -81,28 +86,38 @@ class sfp_robtex(SpiderFootPlugin):
self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)
- if self.errorState:
- return None
-
- if self.opts['api_key'] == "":
- self.sf.error("You enabled sfp_robtex but did not set an API key!", False)
- self.errorState = True
- return None
-
# Don't look up stuff twice
if eventData in self.results:
self.sf.debug("Skipping " + eventData + " as already mapped.")
return None
+ if eventName == 'NETBLOCK_OWNER':
+ if not self.opts['netblocklookup']:
+ return None
+ else:
+ if IPNetwork(eventData).prefixlen < self.opts['maxnetblock']:
+ self.sf.debug("Network size bigger than permitted: " +
+ str(IPNetwork(eventData).prefixlen) + " > " +
+ str(self.opts['maxnetblock']))
+ return None
+
+ if eventName == 'NETBLOCK_MEMBER':
+ if not self.opts['subnetlookup']:
+ return None
+ else:
+ if IPNetwork(eventData).prefixlen < self.opts['maxsubnet']:
+ self.sf.debug("Network size bigger than permitted: " +
+ str(IPNetwork(eventData).prefixlen) + " > " +
+ str(self.opts['maxsubnet']))
+ return None
+
qrylist = list()
if eventName.startswith("NETBLOCK_"):
for ipaddr in IPNetwork(eventData):
- if str(ipaddr) not in self.results:
- qrylist.append(str(ipaddr))
- self.results.append(str(ipaddr))
+ qrylist.append(str(ipaddr))
+ self.results[str(ipaddr)] = True
else:
qrylist.append(eventData)
- self.results.append(eventData)
myres = list()
@@ -110,28 +125,20 @@ class sfp_robtex(SpiderFootPlugin):
if self.checkForStop():
return None
- res = self.sf.fetchUrl("https://robtex.p.mashape.com/reverse/?q=" + ip + "&m=100",
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout'],
- headers={
- 'X-Mashape-Key': self.opts['api_key'],
- 'Accept': 'application/json'}
- )
+ res = self.sf.fetchUrl("https://freeapi.robtex.com/ipquery/" + ip,
+ timeout=self.opts['_fetchtimeout'])
if res['content'] is None:
- self.sf.error("Unable to fetch robtex content.", False)
+ self.sf.error("Unable to query robtex API.", False)
continue
try:
data = json.loads(res['content'])
except BaseException as e:
self.sf.error("Error parsing JSON from robtex API.", False)
- # Abort so that we don't use up API credits in case this is an error
- # on our side.
- self.errorState = True
return None
- if len(data.get('l')) > 0:
- for r in data.get('l'):
+ if len(data.get('pas')) > 0:
+ for r in data.get('pas'):
if self.opts['verify'] and not self.validateIP(r['o'], ip):
self.sf.debug("Host no longer resolves to our IP.")
continue