SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_malwarepatrol: Report blocked hosts as blacklisted (#1559)
bcolesc6fb1b3d6c77
diff --git a/modules/sfp_malwarepatrol.py b/modules/sfp_malwarepatrol.pyindex 1d2affa1..023085d6 100644--- a/modules/sfp_malwarepatrol.py+++ b/modules/sfp_malwarepatrol.py@@ -46,13 +46,18 @@ class sfp_malwarepatrol(SpiderFootPlugin):}}- # Default optionsopts = {- "api_key": ""+ "api_key": "",+ 'checkaffiliates': True,+ 'checkcohosts': True,}+optdescs = {- "api_key": "Malwarepatrol.com 'receipt' ID, provided once signing up for their open-source feed. Without this you cannot obtain their feed."+ "api_key": "Malwarepatrol.com 'receipt' ID, provided once signing up for their open-source feed. Without this you cannot obtain their feed.",+ 'checkaffiliates': "Apply checks to affiliates?",+ 'checkcohosts': "Apply checks to sites found to be co-hosted on the target's IP?",}+results = NoneerrorState = False@@ -63,19 +68,28 @@ class sfp_malwarepatrol(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", "IP_ADDRESS",- "AFFILIATE_INTERNET_NAME", "AFFILIATE_IPADDR",- "CO_HOSTED_SITE"]+ return [+ "INTERNET_NAME",+ "AFFILIATE_INTERNET_NAME",+ "IP_ADDRESS",+ "AFFILIATE_IPADDR",+ "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_IPADDR", "MALICIOUS_INTERNET_NAME",- "MALICIOUS_AFFILIATE_IPADDR", "MALICIOUS_AFFILIATE_INTERNET_NAME",- "MALICIOUS_COHOST"]+ return [+ "BLACKLISTED_IPADDR",+ "BLACKLISTED_AFFILIATE_IPADDR",+ "BLACKLISTED_INTERNET_NAME",+ "BLACKLISTED_AFFILIATE_INTERNET_NAME",+ "BLACKLISTED_COHOST",+ "MALICIOUS_IPADDR",+ "MALICIOUS_AFFILIATE_IPADDR",+ "MALICIOUS_INTERNET_NAME",+ "MALICIOUS_AFFILIATE_INTERNET_NAME",+ "MALICIOUS_COHOST",+ ]def queryAddr(self, qaddr):data = dict()@@ -88,8 +102,7 @@ class sfp_malwarepatrol(SpiderFootPlugin):if data['content'] is None:self.error("Unable to fetch " + url)return None- else:- self.sf.cachePut("sfmalwarepatrol", data['content'])+ self.sf.cachePut("sfmalwarepatrol", data['content'])for line in data['content'].split('\n'):if len(line) < 2 or line.startswith('#'):@@ -100,46 +113,60 @@ class sfp_malwarepatrol(SpiderFootPlugin):return False- # Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventType- srcModuleName = event.moduleeventData = event.dataif self.errorState:return- self.debug(f"Received event, {eventName}, from {srcModuleName}")+ self.debug(f"Received event, {eventName}, from {event.module}")if not self.opts['api_key']:- self.error("You enabled sfp_malwarepatrol but did not provide an receipt ID!")+ self.error("You enabled sfp_malwarepatrol but did not provide a receipt ID!")self.errorState = Truereturnif eventData in self.results:- self.debug("Skipping " + eventData + " as already searched.")+ self.debug(f"Skipping {eventData} as already searched.")returnself.results[eventData] = True- evtType = ""- if eventName in ['IP_ADDRESS', 'AFFILIATE_IPADDR']:- if eventName == 'IP_ADDRESS':- evtType = 'MALICIOUS_IPADDR'- else:- evtType = 'MALICIOUS_AFFILIATE_IPADDR'-- if eventName in ['INTERNET_NAME', 'CO_HOSTED_SITE',- 'AFFILIATE_INTERNET_NAME']:- if eventName == "INTERNET_NAME":- evtType = "MALICIOUS_INTERNET_NAME"- if eventName == 'AFFILIATE_INTERNET_NAME':- evtType = 'MALICIOUS_AFFILIATE_INTERNET_NAME'- if eventName == 'CO_HOSTED_SITE':- evtType = 'MALICIOUS_COHOST'-- if self.queryAddr(eventData):- evt = SpiderFootEvent(evtType, "MalwarePatrol [" + eventData + "]", self.__name__, event)- self.notifyListeners(evt)+ if eventName == 'IP_ADDRESS':+ malicious_type = "MALICIOUS_IPADDR"+ blacklist_type = "BLACKLISTED_IPADDR"+ elif eventName == 'AFFILIATE_IPADDR':+ if not self.opts.get('checkaffiliates', False):+ return+ malicious_type = "MALICIOUS_AFFILIATE_IPADDR"+ blacklist_type = "BLACKLISTED_AFFILIATE_IPADDR"+ elif eventName == "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+ 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+ malicious_type = "MALICIOUS_COHOST"+ blacklist_type = "BLACKLISTED_COHOST"+ else:+ self.debug(f"Unexpected event type {eventName}, skipping")+ return++ if not self.queryAddr(eventData):+ return++ text = f"MalwarePatrol [{eventData}]"++ 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_malwarepatrol class