Skip to content

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

sfp_phishtank: Report blocked hosts as blacklisted (#1569)

bcoles1bf71b71c697
diff --git a/modules/sfp_phishtank.py b/modules/sfp_phishtank.py
index c7460569..7352cefc 100644
--- a/modules/sfp_phishtank.py
+++ b/modules/sfp_phishtank.py
@@ -33,14 +33,12 @@ class sfp_phishtank(SpiderFootPlugin):
}
}
- # Default options
opts = {
'checkaffiliates': True,
'checkcohosts': True,
'cacheperiod': 18
}
- # Option descriptions
optdescs = {
'checkaffiliates': "Apply checks to affiliates?",
'checkcohosts': "Apply checks to sites found to be co-hosted on the target's IP?",
@@ -58,20 +56,21 @@ class sfp_phishtank(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",
"AFFILIATE_INTERNET_NAME",
- "CO_HOSTED_SITE"
+ "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"
+ "MALICIOUS_COHOST",
]
def queryBlacklist(self, target):
@@ -148,13 +147,11 @@ class sfp_phishtank(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.")
@@ -166,25 +163,36 @@ class sfp_phishtank(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 = "BLACKLISTED_COHOST"
else:
+ self.debug(f"Unexpected event type {eventName}, skipping")
return
self.debug(f"Checking maliciousness of {eventData} ({eventName}) with phishtank.com")
phish_id = self.queryBlacklist(eventData)
- if phish_id:
- url = f"https://www.phishtank.com/phish_detail.php?phish_id={phish_id}"
- text = f"PhishTank [{eventData}]\n<SFURL>{url}</SFURL>"
- evt = SpiderFootEvent(evtType, text, self.__name__, event)
- self.notifyListeners(evt)
+
+ if not phish_id:
+ return
+
+ url = f"https://www.phishtank.com/phish_detail.php?phish_id={phish_id}"
+ text = f"PhishTank [{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_phishtank class