Skip to content

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

sfp_emergingthreats: Report blocked hosts as blacklisted (#1549)

bcoles2e32e0fa3527
diff --git a/modules/sfp_emergingthreats.py b/modules/sfp_emergingthreats.py
index 0d743f81..ced8daad 100644
--- a/modules/sfp_emergingthreats.py
+++ b/modules/sfp_emergingthreats.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_emergingthreats
-# Purpose: Checks if an IP address or netblock is malicious according to emergingthreats.net.
+# Purpose: Checks if an IP address or netblock is malicious according to
+# EmergingThreats.net.
#
#
@@ -19,7 +20,7 @@ class sfp_emergingthreats(SpiderFootPlugin):
meta = {
'name': "Emerging Threats",
- 'summary': "Check if a netblock or IP is malicious according to emergingthreats.net.",
+ 'summary': "Check if a netblock or IP address is malicious according to EmergingThreats.net.",
'flags': [],
'useCases': ["Investigate", "Passive"],
'categories': ["Reputation Systems"],
@@ -29,8 +30,8 @@ class sfp_emergingthreats(SpiderFootPlugin):
'references': [
"https://doc.emergingthreats.net/"
],
- 'favIcon': "",
- 'logo': "",
+ 'favIcon': "https://doc.emergingthreats.net/pub/Main/WebPreferences/favicon.ico",
+ 'logo': "https://doc.emergingthreats.net/logo.png",
'description': "Emerging Threats delivers the most timely and accurate threat intelligence.\n"
"Emerging Threat (ET) intelligence helps prevent attacks and reduce risk by "
"helping you understand the historical context of where these threats originated, "
@@ -40,7 +41,6 @@ class sfp_emergingthreats(SpiderFootPlugin):
}
}
- # Default options
opts = {
'checkaffiliates': True,
'cacheperiod': 18,
@@ -48,7 +48,6 @@ class sfp_emergingthreats(SpiderFootPlugin):
'checksubnets': True
}
- # Option descriptions
optdescs = {
'checkaffiliates': "Apply checks to affiliate IP addresses?",
'cacheperiod': "Hours to cache list data before re-fetching.",
@@ -67,15 +66,25 @@ class sfp_emergingthreats(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", "AFFILIATE_IPADDR",
- "NETBLOCK_MEMBER", "NETBLOCK_OWNER"]
+ return [
+ "IP_ADDRESS",
+ "AFFILIATE_IPADDR",
+ "NETBLOCK_MEMBER",
+ "NETBLOCK_OWNER",
+ ]
- # What events this module produces
def producedEvents(self):
- return ["MALICIOUS_IPADDR", "MALICIOUS_AFFILIATE_IPADDR",
- "MALICIOUS_SUBNET", "MALICIOUS_NETBLOCK"]
+ return [
+ "BLACKLISTED_IPADDR",
+ "BLACKLISTED_AFFILIATE_IPADDR",
+ "BLACKLISTED_SUBNET",
+ "BLACKLISTED_NETBLOCK",
+ "MALICIOUS_IPADDR",
+ "MALICIOUS_AFFILIATE_IPADDR",
+ "MALICIOUS_SUBNET",
+ "MALICIOUS_NETBLOCK",
+ ]
def query(self, qry, targetType):
cid = "_emergingthreats"
@@ -105,7 +114,7 @@ class sfp_emergingthreats(SpiderFootPlugin):
if targetType == "netblock":
try:
if IPAddress(ip) in IPNetwork(qry):
- self.debug(f"{ip} found within netblock/subnet {qry} in emergingthreats.net list.")
+ self.debug(f"{ip} found within netblock/subnet {qry} in EmergingThreats.net list.")
return url
except Exception as e:
self.debug(f"Error encountered parsing: {e}")
@@ -113,18 +122,16 @@ class sfp_emergingthreats(SpiderFootPlugin):
if targetType == "ip":
if qry.lower() == ip:
- self.debug(f"{qry} found in emergingthreats.net list.")
+ self.debug(f"{qry} found in EmergingThreats.net list.")
return url
return None
- # 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.")
@@ -137,34 +144,43 @@ class sfp_emergingthreats(SpiderFootPlugin):
if eventName == 'IP_ADDRESS':
targetType = 'ip'
- evtType = 'MALICIOUS_IPADDR'
+ malicious_type = "MALICIOUS_IPADDR"
+ blacklist_type = "BLACKLISTED_IPADDR"
elif eventName == 'AFFILIATE_IPADDR':
if not self.opts.get('checkaffiliates', False):
return
targetType = 'ip'
- evtType = 'MALICIOUS_AFFILIATE_IPADDR'
+ malicious_type = "MALICIOUS_AFFILIATE_IPADDR"
+ blacklist_type = "BLACKLISTED_AFFILIATE_IPADDR"
elif eventName == 'NETBLOCK_OWNER':
if not self.opts.get('checknetblocks', False):
return
targetType = 'netblock'
- evtType = 'MALICIOUS_NETBLOCK'
+ malicious_type = "MALICIOUS_NETBLOCK"
+ blacklist_type = "BLACKLISTED_NETBLOCK"
elif eventName == 'NETBLOCK_MEMBER':
if not self.opts.get('checksubnets', False):
return
targetType = 'netblock'
- evtType = 'MALICIOUS_SUBNET'
+ malicious_type = "MALICIOUS_SUBNET"
+ blacklist_type = "BLACKLISTED_SUBNET"
else:
+ self.debug(f"Unexpected event type {eventName}, skipping")
return
- self.debug(f"Checking maliciousness of {eventData} with emergingthreats.net")
+ self.debug(f"Checking maliciousness of {eventData} with EmergingThreats.net")
url = self.query(eventData, targetType)
if not url:
return
- text = f"emergingthreats.net [{eventData}]\n<SFURL>{url}</SFURL>"
- evt = SpiderFootEvent(evtType, text, self.__name__, event)
+ text = f"EmergingThreats.net [{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_emergingthreats class