Skip to content

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

Various improvements/tweaks to improve data quality.

Steve Micallef4017b4d12d88
diff --git a/modules/sfp_bingsharedip.py b/modules/sfp_bingsharedip.py
index 9224d549..7dae4044 100644
--- a/modules/sfp_bingsharedip.py
+++ b/modules/sfp_bingsharedip.py
@@ -56,7 +56,7 @@ class sfp_bingsharedip(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return ["CO_HOSTED_SITE", "SEARCH_ENGINE_WEB_CONTENT"]
+ return ["CO_HOSTED_SITE", "IP_ADDRESS", "SEARCH_ENGINE_WEB_CONTENT"]
def validateIP(self, host, ip):
try:
@@ -88,6 +88,11 @@ class sfp_bingsharedip(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + " as already mapped.")
return None
+ # Ignore IP addresses from myself as they are just for creating
+ # a link from the netblock to the co-host.
+ if eventName == "IP_ADDRESS" and srcModuleName == "sfp_bingsharedip":
+ return None
+
if self.cohostcount > self.opts['maxcohost']:
return None
@@ -129,8 +134,16 @@ class sfp_bingsharedip(SpiderFootPlugin):
if self.opts['verify'] and not self.validateIP(site, ip):
self.sf.debug("Host " + site + " no longer resolves to " + ip)
continue
- evt = SpiderFootEvent("CO_HOSTED_SITE", site, self.__name__, event)
- self.notifyListeners(evt)
+ # Create an IP Address event stemming from the netblock as the
+ # link to the co-host.
+ if eventName == "NETBLOCK_OWNER":
+ ipe = SpiderFootEvent("IP_ADDRESS", ip, self.__name__, event)
+ self.notifyListeners(ipe)
+ evt = SpiderFootEvent("CO_HOSTED_SITE", site, self.__name__, ipe)
+ self.notifyListeners(evt)
+ else:
+ evt = SpiderFootEvent("CO_HOSTED_SITE", site, self.__name__, event)
+ self.notifyListeners(evt)
self.cohostcount += 1
myres.append(site)
diff --git a/modules/sfp_dnsbrute.py b/modules/sfp_dnsbrute.py
index 431aa1eb..811a9d53 100644
--- a/modules/sfp_dnsbrute.py
+++ b/modules/sfp_dnsbrute.py
@@ -88,7 +88,7 @@ class sfp_dnsbrute(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return ["IP_ADDRESS", "INTERNET_NAME", "IPV6_ADDRESS"]
+ return ["INTERNET_NAME"]
def tryHost(self, name):
resolver = dns.resolver.Resolver()
diff --git a/modules/sfp_dnsneighbor.py b/modules/sfp_dnsneighbor.py
index 40d208ba..9d11414a 100644
--- a/modules/sfp_dnsneighbor.py
+++ b/modules/sfp_dnsneighbor.py
@@ -59,7 +59,7 @@ class sfp_dnsneighbor(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return ["INTERNET_NAME"]
+ return ["IP_ADDRESS", "AFFILIATE_IPADDR"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -183,28 +183,6 @@ class sfp_dnsneighbor(SpiderFootPlugin):
self.sf.debug("Unable to resolve " + hostname + " (" + str(e) + ")")
return list()
- # Resolve a host to IPv6
- def resolveHost6(self, hostname):
- if hostname in self.resolveCache6:
- self.sf.debug("Returning IPv6 cached result for " + hostname + " (" +
- str(self.resolveCache6[hostname]) + ")")
- return self.resolveCache6[hostname]
-
- try:
- addrs = list()
- res = socket.getaddrinfo(hostname, None, socket.AF_INET6)
- for addr in res:
- if addr[4][0] not in addrs:
- addrs.append(addr[4][0])
- if len(addrs) < 1:
- return None
- self.resolveCache6[hostname] = addrs
- self.sf.debug("Resolved " + hostname + " to IPv6: " + str(addrs))
- return addrs
- except BaseException as e:
- self.sf.debug("Unable to IPv6 resolve " + hostname + " (" + str(e) + ")")
- return list()
-
# Process a host/IP, parentEvent is the event that represents this entity
def processHost(self, host, parentEvent, affiliate=None):
parentHash = self.sf.hashstring(parentEvent.data)
@@ -233,16 +211,16 @@ class sfp_dnsneighbor(SpiderFootPlugin):
else:
affil = affiliate
+ htype = None
if affil:
if self.sf.validIP(host):
htype = "AFFILIATE_IPADDR"
- else:
- htype = "AFFILIATE_INTERNET_NAME"
else:
if self.sf.validIP(host):
htype = "IP_ADDRESS"
- else:
- htype = "INTERNET_NAME"
+
+ if not htype:
+ return None
# Report the host
evt = SpiderFootEvent(htype, host, self.__name__, parentEvent)
diff --git a/modules/sfp_dnsresolve.py b/modules/sfp_dnsresolve.py
index 1c97555c..35e0430d 100644
--- a/modules/sfp_dnsresolve.py
+++ b/modules/sfp_dnsresolve.py
@@ -357,9 +357,12 @@ class sfp_dnsresolve(SpiderFootPlugin):
if not resolved:
return None
- # Report the host
- evt = SpiderFootEvent(htype, host, self.__name__, parentEvent)
- self.notifyListeners(evt)
+ if host != parentEvent.data and htype != parentEvent.eventType:
+ evt = SpiderFootEvent(htype, host, self.__name__, parentEvent)
+ self.notifyListeners(evt)
+ else:
+ evt = parentEvent
+
# Report the domain for that host
if htype == "INTERNET_NAME":
dom = self.sf.hostDomain(host, self.opts['_internettlds'])
@@ -370,15 +373,25 @@ class sfp_dnsresolve(SpiderFootPlugin):
evt6 = SpiderFootEvent("IPV6_ADDRESS", ip6, self.__name__, evt)
self.notifyListeners(evt6)
+ if htype == "AFFILIATE_INTERNET_NAME":
+ dom = self.sf.hostDomain(host, self.opts['_internettlds'])
+ self.processDomain(dom, evt, True)
+
return evt
- def processDomain(self, domainName, parentEvent):
+ def processDomain(self, domainName, parentEvent, affil=False):
if domainName not in self.domresults:
self.domresults[domainName] = True
else:
self.sf.debug("Skipping domain, " + domainName + ", already processed.")
return None
+ if affil:
+ domevt = SpiderFootEvent("AFFILIATE_DOMAIN", domainName,
+ self.__name__, parentEvent)
+ self.notifyListeners(domevt)
+ return None
+
if self.getTarget().matches(domainName):
domevt = SpiderFootEvent("DOMAIN_NAME", domainName,
self.__name__, parentEvent)
diff --git a/modules/sfp_hackertarget.py b/modules/sfp_hackertarget.py
index 59e29842..cc30e305 100644
--- a/modules/sfp_hackertarget.py
+++ b/modules/sfp_hackertarget.py
@@ -63,7 +63,7 @@ class sfp_hackertarget(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return ["CO_HOSTED_SITE", "UDP_PORT_OPEN", "TCP_PORT_OPEN"]
+ return ["CO_HOSTED_SITE", "UDP_PORT_OPEN", "TCP_PORT_OPEN", "IP_ADDRESS"]
def validateIP(self, host, ip):
try:
@@ -159,6 +159,9 @@ class sfp_hackertarget(SpiderFootPlugin):
self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)
+ if srcModuleName == "sfp_hackertarget" and eventName == "IP_ADDRESS":
+ return None
+
# Don't look up stuff twice
if eventData in self.results:
self.sf.debug("Skipping " + eventData + " as already mapped.")
@@ -208,8 +211,17 @@ class sfp_hackertarget(SpiderFootPlugin):
self.sf.debug("Host " + h + " no longer resolves to " + ip)
continue
if self.cohostcount < self.opts['maxcohost']:
- evt = SpiderFootEvent("CO_HOSTED_SITE", h.lower(), self.__name__, event)
- self.notifyListeners(evt)
+ # Create an IP Address event stemming from the netblock as the
+ # link to the co-host.
+ if eventName == "NETBLOCK_OWNER":
+ ipe = SpiderFootEvent("IP_ADDRESS", ip, self.__name__, event)
+ self.notifyListeners(ipe)
+ evt = SpiderFootEvent("CO_HOSTED_SITE", h.lower(), self.__name__, ipe)
+ self.notifyListeners(evt)
+ else:
+ evt = SpiderFootEvent("CO_HOSTED_SITE", h.lower(), self.__name__, event)
+ self.notifyListeners(evt)
+
myres.append(h.lower())
self.cohostcount += 1
diff --git a/modules/sfp_robtex.py b/modules/sfp_robtex.py
index a1d0d98b..fa51021d 100644
--- a/modules/sfp_robtex.py
+++ b/modules/sfp_robtex.py
@@ -27,8 +27,6 @@ class sfp_robtex(SpiderFootPlugin):
'verify': True,
'netblocklookup': True,
'maxnetblock': 24,
- 'subnetlookup': True,
- 'maxsubnet': 24,
'cohostsamedomain': False,
'maxcohost': 100
}
@@ -38,8 +36,6 @@ class sfp_robtex(SpiderFootPlugin):
'verify': "Verify co-hosts are valid by checking if they still resolve to the shared IP.",
'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.)",
'cohostsamedomain': "Treat co-hosted sites on the same target domain as co-hosting?",
'maxcohost': "Stop reporting co-hosted sites after this many are found, as it would likely indicate web hosting."
}
@@ -63,7 +59,7 @@ class sfp_robtex(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return ["CO_HOSTED_SITE"]
+ return ["CO_HOSTED_SITE", "IP_ADDRESS"]
def validateIP(self, host, ip):
try:
@@ -94,6 +90,9 @@ class sfp_robtex(SpiderFootPlugin):
if self.cohostcount > self.opts['maxcohost']:
return None
+ if srcModuleName == "sfp_robtex" and eventName == "IP_ADDRESS":
+ return None
+
# Don't look up stuff twice
if eventData in self.results:
self.sf.debug("Skipping " + eventData + " as already mapped.")
@@ -109,16 +108,6 @@ class sfp_robtex(SpiderFootPlugin):
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):
@@ -157,7 +146,7 @@ class sfp_robtex(SpiderFootPlugin):
except BaseException as e:
self.sf.error("Error parsing JSON from robtex API.", False)
return None
-
+
pas = data.get('pas')
if not pas:
return None
@@ -174,8 +163,14 @@ class sfp_robtex(SpiderFootPlugin):
if self.opts['verify'] and not self.validateIP(r['o'], ip):
self.sf.debug("Host " + r['o'] + " no longer resolves to " + ip)
continue
- evt = SpiderFootEvent("CO_HOSTED_SITE", r['o'], self.__name__, event)
- self.notifyListeners(evt)
+ if eventName == "NETBLOCK_OWNER":
+ ipe = SpiderFootEvent("IP_ADDRESS", ip, self.__name__, event)
+ self.notifyListeners(ipe)
+ evt = SpiderFootEvent("CO_HOSTED_SITE", r['o'], self.__name__, ipe)
+ self.notifyListeners(evt)
+ else:
+ evt = SpiderFootEvent("CO_HOSTED_SITE", r['o'], self.__name__, event)
+ self.notifyListeners(evt)
self.cohostcount += 1
# End of sfp_robtex class
diff --git a/sf.py b/sf.py
index e492b1bb..b43de4b7 100755
--- a/sf.py
+++ b/sf.py
@@ -142,7 +142,7 @@ if __name__ == '__main__':
p.add_argument("-D", metavar='DELIMITER', type=str, help="Delimiter to use for CSV output. Default is ,.")
p.add_argument("-f", action='store_true', help="Filter out other event types that weren't requested with -t.")
p.add_argument("-F", metavar="FILTER", type=str, help="Filter out a set of event types.")
- p.add_argument("-x", action='store_true', help="STRICT MODE. Means that only modules consuming your target type will be enabled and if -t was specified, only those events will be consumed by modules. This overrides -t and -m options.")
+ p.add_argument("-x", action='store_true', help="STRICT MODE. Will only enable modules that can directly consume your target, and if -t was specified only those events will be consumed by modules. This overrides -t and -m options.")
p.add_argument("-q", action='store_true', help="Disable logging.")
args = p.parse_args()