SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_base64: Fix event data URL decoding (#1094)
bcolesc417904cc651
diff --git a/modules/sfp_base64.py b/modules/sfp_base64.pyindex 825e6fd8..8f522d0d 100644--- a/modules/sfp_base64.py+++ b/modules/sfp_base64.py@@ -11,6 +11,7 @@import base64import re+import urllib.parsefrom spiderfoot import SpiderFootEvent, SpiderFootPlugin@@ -58,10 +59,12 @@ class sfp_base64(SpiderFootPlugin):self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")+ decoded_data = urllib.parse.unquote(eventData)+# 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)+ m = re.findall(pat, decoded_data)for match in m:if self.checkForStop():returndiff --git a/test/unit/modules/test_sfp_base64.py b/test/unit/modules/test_sfp_base64.pyindex 28f051d1..d2ca3d00 100644--- a/test/unit/modules/test_sfp_base64.py+++ b/test/unit/modules/test_sfp_base64.py@@ -74,17 +74,21 @@ class TestModuleBase64(unittest.TestCase):if str(event.data) != expected:raise Exception(f"{event.data} != {expected}")+ raise Exception("OK")+module.notifyListeners = new_notifyListeners.__get__(module, sfp_base64)event_type = 'ROOT'- event_data = 'https://someurl/?somevar=example%20data%20U3BpZGVyRm9vdA%3d%3d%20example%20data'+ event_data = 'https://spiderfoot.net/path?param=example%20data%20U3BpZGVyRm9vdA%3d%3d%20example%20data'event_module = ''source_event = ''evt = SpiderFootEvent(event_type, event_data, event_module, source_event)- result = module.handleEvent(evt)- self.assertIsNone(result)+ with self.assertRaises(Exception) as cm:+ module.handleEvent(evt)++ self.assertEqual("OK", str(cm.exception))def test_handleEvent_event_data_not_containing_base64_string_should_not_return_event(self):sf = SpiderFoot(self.default_options)