SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_cleanbrowsing: code cleanup
Brendan Coles0205b80f8708
diff --git a/modules/sfp_cleanbrowsing.py b/modules/sfp_cleanbrowsing.pyindex b252b355..0e46d923 100644--- a/modules/sfp_cleanbrowsing.py+++ b/modules/sfp_cleanbrowsing.py@@ -1,8 +1,8 @@# -*- coding: utf-8 -*-# --------------------------------------------------------------------------------# Name: sfp_cleanbrowsing-# Purpose: SpiderFoot plug-in for looking up whether hosts are blocked by-# Cleanbrowsing.org DNS (185.228.168.168 and 185.228.168.169)+# Name: sfp_cleanbrowsing+# Purpose: SpiderFoot plug-in for looking up whether hosts are blocked by+# CleanBrowsing.org DNS (185.228.168.168 and 185.228.168.169)## Author: Steve Micallef <[email protected]>#@@ -19,8 +19,8 @@ from spiderfoot import SpiderFootEvent, SpiderFootPluginclass sfp_cleanbrowsing(SpiderFootPlugin):meta = {- 'name': "Cleanbrowsing.org",- 'summary': "Check if a host would be blocked by Cleanbrowsing.org DNS",+ 'name': "CleanBrowsing.org",+ 'summary': "Check if a host would be blocked by CleanBrowsing.org DNS",'flags': [""],'useCases': ["Investigate", "Passive"],'categories': ["Reputation Systems"],@@ -46,11 +46,9 @@ class sfp_cleanbrowsing(SpiderFootPlugin):}}- # Default optionsopts = {}- # Option descriptionsoptdescs = {}@@ -63,16 +61,19 @@ class sfp_cleanbrowsing(SpiderFootPlugin):for opt in list(userOpts.keys()):self.opts[opt] = userOpts[opt]- # What events is this module interested in for inputdef watchedEvents(self):- return ["INTERNET_NAME", "AFFILIATE_INTERNET_NAME", "CO_HOSTED_SITE"]+ return [+ "INTERNET_NAME",+ "AFFILIATE_INTERNET_NAME",+ "CO_HOSTED_SITE"+ ]- # What events this module produces- # This is to support the end user in selecting modules based on events- # produced.def producedEvents(self):- return ["MALICIOUS_INTERNET_NAME", "MALICIOUS_AFFILIATE_INTERNET_NAME",- "MALICIOUS_COHOST"]+ return [+ "MALICIOUS_INTERNET_NAME",+ "MALICIOUS_AFFILIATE_INTERNET_NAME",+ "MALICIOUS_COHOST"+ ]def queryAddr(self, qaddr):res = dns.resolver.Resolver()@@ -80,7 +81,7 @@ class sfp_cleanbrowsing(SpiderFootPlugin):try:addrs = res.query(qaddr)- self.sf.debug("Addresses returned: " + str(addrs))+ self.sf.debug(f"Addresses returned: {addrs}")except BaseException:self.sf.debug(f"Unable to resolve {qaddr}")return False@@ -89,36 +90,41 @@ class sfp_cleanbrowsing(SpiderFootPlugin):return Truereturn False- # Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventTypesrcModuleName = event.moduleeventData = event.dataparentEvent = event- resolved = Falseself.sf.debug(f"Received event, {eventName}, from {srcModuleName}")if eventData in self.results:return None+self.results[eventData] = True# Check that it resolves first, as it becomes a valid- # malicious host only if NOT resolved by Cleanbrowsing.org.- try:- if self.sf.resolveHost(eventData):- resolved = True- except BaseException:+ # malicious host only if NOT resolved by CleanBrowsing.org.+ if not self.sf.resolveHost(eventData):+ return None++ found = self.queryAddr(eventData)++ # Host was found, not blocked+ if found:return None- if resolved:- found = self.queryAddr(eventData)- typ = "MALICIOUS_" + eventName- if eventName == "CO_HOSTED_SITE":- typ = "MALICIOUS_COHOST"- if not found:- evt = SpiderFootEvent(typ, "Blocked by Cleanbrowsing.org [" + eventData + "]",- self.__name__, parentEvent)- self.notifyListeners(evt)+ typ = "MALICIOUS_" + eventName++ if eventName == "CO_HOSTED_SITE":+ typ = "MALICIOUS_COHOST"++ evt = SpiderFootEvent(+ typ,+ f"Blocked by CleanBrowsing.org [{eventData}]",+ self.__name__,+ parentEvent+ )+ self.notifyListeners(evt)# End of sfp_cleanbrowsing class