Skip to content

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

sfp_blocklistde: Report blocked hosts as blacklisted (#1528)

bcolesac4a58af88f8
diff --git a/modules/sfp_blocklistde.py b/modules/sfp_blocklistde.py
index 4c0e7e49..fae8cea3 100644
--- a/modules/sfp_blocklistde.py
+++ b/modules/sfp_blocklistde.py
@@ -42,7 +42,6 @@ class sfp_blocklistde(SpiderFootPlugin):
}
}
- # Default options
opts = {
'checkaffiliates': True,
'cacheperiod': 18,
@@ -50,7 +49,6 @@ class sfp_blocklistde(SpiderFootPlugin):
'checksubnets': True
}
- # Option descriptions
optdescs = {
'checkaffiliates': "Apply checks to affiliates?",
'cacheperiod': "Hours to cache list data before re-fetching.",
@@ -58,9 +56,6 @@ class sfp_blocklistde(SpiderFootPlugin):
'checksubnets': "Check if any malicious IPs are found within the same subnet of the target?"
}
- # Be sure to completely clear any class variables in setup()
- # or you run the risk of data persisting between scan runs.
-
results = None
errorState = False
@@ -72,7 +67,6 @@ class sfp_blocklistde(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",
@@ -85,13 +79,16 @@ class sfp_blocklistde(SpiderFootPlugin):
"NETBLOCKV6_OWNER",
]
- # What events this module produces
def producedEvents(self):
return [
+ "BLACKLISTED_IPADDR",
+ "BLACKLISTED_AFFILIATE_IPADDR",
+ "BLACKLISTED_SUBNET",
+ "BLACKLISTED_NETBLOCK",
"MALICIOUS_IPADDR",
"MALICIOUS_AFFILIATE_IPADDR",
+ "MALICIOUS_NETBLOCK",
"MALICIOUS_SUBNET",
- "MALICIOUS_NETBLOCK"
]
def queryBlacklist(self, target, targetType):
@@ -163,13 +160,11 @@ class sfp_blocklistde(SpiderFootPlugin):
return ips
- # 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.")
@@ -182,31 +177,41 @@ class sfp_blocklistde(SpiderFootPlugin):
if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:
targetType = 'ip'
- 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
targetType = 'ip'
- evtType = 'MALICIOUS_AFFILIATE_IPADDR'
+ malicious_type = 'MALICIOUS_AFFILIATE_IPADDR'
+ blacklist_type = 'BLACKLISTED_AFFILIATE_IPADDR'
elif eventName in ['NETBLOCK_OWNER', 'NETBLOCKV6_OWNER']:
if not self.opts.get('checknetblocks', False):
return
targetType = 'netblock'
- evtType = 'MALICIOUS_NETBLOCK'
+ malicious_type = 'MALICIOUS_NETBLOCK'
+ blacklist_type = 'BLACKLISTED_NETBLOCK'
elif eventName in ['NETBLOCK_MEMBER', 'NETBLOCKV6_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} ({eventName}) with blocklist.de")
if self.queryBlacklist(eventData, targetType):
+ # https://www.blocklist.de/en/search.html?ip=<ip>
url = "https://lists.blocklist.de/lists/all.txt"
text = f"blocklist.de [{eventData}]\n<SFURL>{url}</SFURL>"
- evt = SpiderFootEvent(evtType, text, self.__name__, event)
+
+ 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_blocklistde class