SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_base64: resolve pep8 violations
Brendan Colese90682cb6295
diff --git a/modules/sfp_base64.py b/modules/sfp_base64.pyindex 1c063cb2..6f7574e9 100644--- a/modules/sfp_base64.py+++ b/modules/sfp_base64.py@@ -12,7 +12,7 @@import base64import re-from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent+from sflib import SpiderFootPlugin, SpiderFootEventclass sfp_base64(SpiderFootPlugin):@@ -21,9 +21,9 @@ class sfp_base64(SpiderFootPlugin):meta = {'name': "Base64 Decoder",'summary': "Identify Base64-encoded strings in any content and URLs, often revealing interesting hidden information.",- 'flags': [ "" ],- 'useCases': [ "Investigate", "Passive" ],- 'categories': [ "Content Analysis" ]+ 'flags': [""],+ 'useCases': ["Investigate", "Passive"],+ 'categories': ["Content Analysis"]}# Default options@@ -48,8 +48,6 @@ class sfp_base64(SpiderFootPlugin):return ["LINKED_URL_INTERNAL", "TARGET_WEB_CONTENT"]# What events this module produces- # This is to support the end user in selecting modules based on events- # produced.def producedEvents(self):return ["BASE64_DATA"]@@ -59,30 +57,38 @@ class sfp_base64(SpiderFootPlugin):srcModuleName = event.moduleeventData = event.data- self.sf.debug("Received event, %s, from %s" % (eventName, srcModuleName))+ self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")- pat = re.compile(r"([A-Za-z0-9+\/]+\=\=|[A-Za-z0-9+\/]+\=)")+ # Note: this will miss base64 encoded strings with no padding+ # (strings which do not end with '=' or '==')+ pat = re.compile(r"([A-Za-z0-9+\/]+={1,2})")m = re.findall(pat, eventData)for match in m:if self.checkForStop():return Noneminlen = int(self.opts['minlength'])- if len(match) >= minlen:- caps = sum(1 for c in match if c.isupper())- # Base64-encoded strings don't look like normal strings- if caps < (minlen/4):- return None- self.sf.info("Found Base64 string: " + match)- if type(match) != str:- string = str(match)-- try:- string += " (" + base64.b64decode(match) + ")"- evt = SpiderFootEvent("BASE64_DATA", string, self.__name__, event)- self.notifyListeners(evt)- except BaseException as e:- self.sf.debug("Unable to base64-decode a string.")+ if len(match) < minlen:+ continue++ # Base64-encoded strings don't look like normal strings+ caps = sum(1 for c in match if c.isupper())+ if caps < (minlen/4):+ continue++ if type(match) != str:+ string = str(match)++ self.sf.info(f"Found Base64 string: {match}")++ try:+ string += " (" + base64.b64decode(match) + ")"+ except BaseException:+ self.sf.debug("Unable to base64-decode string.")+ continue++ evt = SpiderFootEvent("BASE64_DATA", string, self.__name__, event)+ self.notifyListeners(evt)return None