Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Validate external tool paths

Brendan Coles2aaabdf9061c
diff --git a/modules/sfp_tool_cmseek.py b/modules/sfp_tool_cmseek.py
index 79874594..68d0d9d8 100644
--- a/modules/sfp_tool_cmseek.py
+++ b/modules/sfp_tool_cmseek.py
@@ -14,6 +14,7 @@
from subprocess import Popen, PIPE
import io
import json
+import os.path
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
class sfp_tool_cmseek(SpiderFootPlugin):
@@ -77,7 +78,7 @@ class sfp_tool_cmseek(SpiderFootPlugin):
self.errorState = True
return None
- # If tool is not found, abort
+ # Normalize path
if self.opts['cmseekpath'].endswith('cmseek.py'):
exe = self.opts['cmseekpath']
resultpath = self.opts['cmseekpath'].split("cmseek.py")[0] + "/Result"
@@ -88,6 +89,12 @@ class sfp_tool_cmseek(SpiderFootPlugin):
exe = self.opts['cmseekpath'] + "/cmseek.py"
resultpath = self.opts['cmseekpath'] + "/Result"
+ # If tool is not found, abort
+ if not os.path.isfile(exe):
+ self.sf.error("File does not exist: " + exe, False)
+ self.errorState = True
+ return None
+
# Sanitize domain name.
if not self.sf.sanitiseInput(eventData):
self.sf.error("Invalid input, refusing to run.", False)
diff --git a/modules/sfp_tool_dnstwist.py b/modules/sfp_tool_dnstwist.py
index ef3944cc..3601e91a 100644
--- a/modules/sfp_tool_dnstwist.py
+++ b/modules/sfp_tool_dnstwist.py
@@ -15,6 +15,7 @@ from subprocess import Popen, PIPE
import time
import re
import json
+import os.path
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
class sfp_tool_dnstwist(SpiderFootPlugin):
@@ -78,7 +79,7 @@ class sfp_tool_dnstwist(SpiderFootPlugin):
self.errorState = True
return None
- # If tool is not found, abort
+ # Normalize path
if self.opts['dnstwistpath'].endswith('dnstwist.py'):
exe = self.opts['dnstwistpath']
elif self.opts['dnstwistpath'].endswith('/'):
@@ -86,6 +87,12 @@ class sfp_tool_dnstwist(SpiderFootPlugin):
else:
exe = self.opts['dnstwistpath'] + "/dnstwist.py"
+ # If tool is not found, abort
+ if not os.path.isfile(exe):
+ self.sf.error("File does not exist: " + exe, False)
+ self.errorState = True
+ return None
+
# Sanitize domain name.
if not self.sf.sanitiseInput(eventData):
self.sf.error("Invalid input, refusing to run.", False)