Skip to content

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

sfp_stevenblack_hosts: Report blocked hosts as blacklisted (#1516)

bcolesf0e49e186fc5
diff --git a/modules/sfp_stevenblack_hosts.py b/modules/sfp_stevenblack_hosts.py
index e138b109..0c206879 100644
--- a/modules/sfp_stevenblack_hosts.py
+++ b/modules/sfp_stevenblack_hosts.py
@@ -53,7 +53,6 @@ class sfp_stevenblack_hosts(SpiderFootPlugin):
for opt in list(userOpts.keys()):
self.opts[opt] = userOpts[opt]
- # What events is this module interested in for input
def watchedEvents(self):
return [
"INTERNET_NAME",
@@ -61,9 +60,11 @@ class sfp_stevenblack_hosts(SpiderFootPlugin):
"CO_HOSTED_SITE"
]
- # What events this module produces
def producedEvents(self):
return [
+ "BLACKLISTED_INTERNET_NAME",
+ "BLACKLISTED_AFFILIATE_INTERNET_NAME",
+ "BLACKLISTED_COHOST",
"MALICIOUS_INTERNET_NAME",
"MALICIOUS_AFFILIATE_INTERNET_NAME",
"MALICIOUS_COHOST"
@@ -137,13 +138,11 @@ class sfp_stevenblack_hosts(SpiderFootPlugin):
return hosts
- # Handle events sent to this module
def handleEvent(self, event):
eventName = event.eventType
- srcModuleName = event.module
eventData = event.data
- self.debug(f"Received event, {eventName}, from {srcModuleName}")
+ self.debug(f"Received event, {eventName}, from {event.module}")
if eventData in self.results:
self.debug(f"Skipping {eventData}, already checked.")
@@ -155,24 +154,34 @@ class sfp_stevenblack_hosts(SpiderFootPlugin):
self.results[eventData] = True
if eventName == "INTERNET_NAME":
- evtType = "MALICIOUS_INTERNET_NAME"
- elif eventName == 'AFFILIATE_INTERNET_NAME':
+ malicious_type = "MALICIOUS_INTERNET_NAME"
+ blacklist_type = "BLACKLISTED_INTERNET_NAME"
+ elif eventName == "AFFILIATE_INTERNET_NAME":
if not self.opts.get('checkaffiliates', False):
return
- evtType = 'MALICIOUS_AFFILIATE_INTERNET_NAME'
- elif eventName == 'CO_HOSTED_SITE':
+ malicious_type = "MALICIOUS_AFFILIATE_INTERNET_NAME"
+ blacklist_type = "BLACKLISTED_AFFILIATE_INTERNET_NAME"
+ elif eventName == "CO_HOSTED_SITE":
if not self.opts.get('checkcohosts', False):
return
- evtType = 'MALICIOUS_COHOST'
+ malicious_type = "MALICIOUS_COHOST"
+ blacklist_type = "BACKLISTED_COHOST"
else:
+ self.debug(f"Unexpected event type {eventName}, skipping")
return
self.debug(f"Checking maliciousness of {eventData} ({eventName}) with Steven Black Hosts blocklist")
- if self.queryBlocklist(eventData):
- url = "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
- text = f"Steven Black Hosts Blocklist [{eventData}]\n<SFURL>{url}</SFURL>"
- evt = SpiderFootEvent(evtType, text, self.__name__, event)
- self.notifyListeners(evt)
+ if not self.queryBlocklist(eventData):
+ return
+
+ url = "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
+ text = f"Steven Black Hosts Blocklist [{eventData}]\n<SFURL>{url}</SFURL>"
+
+ evt = SpiderFootEvent(malicious_type, text, self.__name__, event)
+ self.notifyListeners(evt)
+
+ evt = SpiderFootEvent(blacklist_type, text, self.__name__, event)
+ self.notifyListeners(evt)
# End of sfp_stevenblack_hosts class