Skip to content

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

sfp_fortinet: Report blocked hosts as blacklisted (#1538)

bcoles2afb81bbbf3f
diff --git a/modules/sfp_fortinet.py b/modules/sfp_fortinet.py
index cfc54204..e3e49489 100644
--- a/modules/sfp_fortinet.py
+++ b/modules/sfp_fortinet.py
@@ -33,12 +33,10 @@ class sfp_fortinet(SpiderFootPlugin):
}
}
- # Default options
opts = {
'checkaffiliates': True
}
- # Option descriptions
optdescs = {
'checkaffiliates': "Apply checks to affiliates?"
}
@@ -54,13 +52,21 @@ class sfp_fortinet(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 ["IP_ADDRESS", "IPV6_ADDRESS", "AFFILIATE_IPADDR", "AFFILIATE_IPV6_ADDRESS"]
+ return [
+ "IP_ADDRESS",
+ "IPV6_ADDRESS",
+ "AFFILIATE_IPADDR",
+ "AFFILIATE_IPV6_ADDRESS",
+ ]
- # What events this module produces
def producedEvents(self):
- return ["MALICIOUS_IPADDR", "MALICIOUS_AFFILIATE_IPADDR"]
+ return [
+ "BLACKLISTED_IPADDR",
+ "BLACKLISTED_AFFILIATE_IPADDR",
+ "MALICIOUS_IPADDR",
+ "MALICIOUS_AFFILIATE_IPADDR",
+ ]
def query(self, ip):
if not ip:
@@ -84,13 +90,11 @@ class sfp_fortinet(SpiderFootPlugin):
return res['content']
- # 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.")
@@ -102,12 +106,15 @@ class sfp_fortinet(SpiderFootPlugin):
self.results[eventData] = True
if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:
- evtType = 'MALICIOUS_IPADDR'
+ malicious_type = 'MALICIOUS_IPADDR'
+ blacklist_type = 'BLACKLISTED_IPADDR'
elif eventName in ['AFFILIATE_IPADDR', 'AFFILIATE_IPV6_ADDRESS']:
if not self.opts.get('checkaffiliates', False):
return
- evtType = 'MALICIOUS_AFFILIATE_IPADDR'
+ malicious_type = 'MALICIOUS_AFFILIATE_IPADDR'
+ blacklist_type = 'BLACKLISTED_AFFILIATE_IPADDR'
else:
+ self.debug(f"Unexpected event type {eventName}, skipping")
return
data = self.query(eventData)
@@ -115,10 +122,16 @@ class sfp_fortinet(SpiderFootPlugin):
if not data:
return
- if "Your signature is on the blocklist" in data:
- url = f"https://www.fortiguard.com/search?q={eventData}&engine=8"
- text = f"FortiGuard Antispam [{eventData}]\n<SFURL>{url}</SFURL>"
- evt = SpiderFootEvent(evtType, text, self.__name__, event)
- self.notifyListeners(evt)
+ if "Your signature is on the blocklist" not in data:
+ return
+
+ url = f"https://www.fortiguard.com/search?q={eventData}&engine=8"
+ text = f"FortiGuard Antispam [{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_fortinet class