SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_tool_dnstwist: Sanitize domain name before processing (#1758)
bcoles27ac7a3884ff
diff --git a/modules/sfp_tool_dnstwist.py b/modules/sfp_tool_dnstwist.pyindex ec938c33..13438e69 100644--- a/modules/sfp_tool_dnstwist.py+++ b/modules/sfp_tool_dnstwist.py@@ -86,20 +86,28 @@ class sfp_tool_dnstwist(SpiderFootPlugin):returnif eventData in self.results:- self.debug("Skipping " + eventData + " as already scanned.")+ self.debug(f"Skipping {eventData} as already scanned.")returnself.results[eventData] = True+ # Sanitize domain name+ if not SpiderFootHelpers.sanitiseInput(eventData):+ self.error("Invalid input, refusing to run.")+ return+dom = self.sf.domainKeyword(eventData, self.opts['_internettlds'])if not dom:+ self.error(f"Could not extract keyword from domain: {eventData}")returntld = eventData.split(dom + ".")[-1]# Check if the TLD has wildcards before testingif self.opts['skipwildcards'] and self.sf.checkDnsWildcard(tld):+ self.debug(f"Wildcard DNS detected on {eventData} TLD: {tld}")return+ # TODO: check dnstwistpath option before trying which()dnstwistLocation = which('dnstwist')if dnstwistLocation and Path(dnstwistLocation).is_file():cmd = ['dnstwist']@@ -125,11 +133,6 @@ class sfp_tool_dnstwist(SpiderFootPlugin):cmd = [self.opts['pythonpath'], exe]- # Sanitize domain name.- if not SpiderFootHelpers.sanitiseInput(eventData):- self.error("Invalid input, refusing to run.")- return-try:p = Popen(cmd + ["-f", "json", "-r", eventData], stdout=PIPE, stderr=PIPE)stdout, stderr = p.communicate(input=None, timeout=300)diff --git a/test/unit/modules/test_sfp_tool_dnstwist.py b/test/unit/modules/test_sfp_tool_dnstwist.pyindex 6db66155..d0dbe31e 100644--- a/test/unit/modules/test_sfp_tool_dnstwist.py+++ b/test/unit/modules/test_sfp_tool_dnstwist.py@@ -3,7 +3,6 @@ import unittestfrom modules.sfp_tool_dnstwist import sfp_tool_dnstwistfrom sflib import SpiderFoot-from spiderfoot import SpiderFootEvent, SpiderFootTarget@pytest.mark.usefixtures@@ -25,25 +24,3 @@ class TestModuleToolDnstwist(unittest.TestCase):def test_producedEvents_should_return_list(self):module = sfp_tool_dnstwist()self.assertIsInstance(module.producedEvents(), list)-- def test_handleEvent_no_tool_path_configured_should_set_errorState(self):- sf = SpiderFoot(self.default_options)-- module = sfp_tool_dnstwist()- module.setup(sf, dict())-- target_value = 'example target value'- target_type = 'IP_ADDRESS'- target = SpiderFootTarget(target_value, target_type)- module.setTarget(target)-- event_type = 'ROOT'- event_data = 'example data'- event_module = ''- source_event = ''- evt = SpiderFootEvent(event_type, event_data, event_module, source_event)-- result = module.handleEvent(evt)-- self.assertIsNone(result)- self.assertTrue(module.errorState)