From f62df1aac210674f61e3a31de6189a735d55a939 Mon Sep 17 00:00:00 2001 From: vlkumiloslearning Date: Wed, 3 Jun 2026 00:15:48 +0200 Subject: [PATCH 1/2] fix: Process.exists() returns True when tool is missing due to operator precedence bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `not stdout == stderr == ''` is evaluated as `not (stdout == stderr == '')` which returns True when stderr is non-empty (e.g. "service not found"), causing wifite to believe the tool exists and then crash with FileNotFoundError. Replace with `bool(stdout)` — which is non-empty only when `which` actually found the binary. Co-Authored-By: Claude Sonnet 4.6 --- wifite/util/process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wifite/util/process.py b/wifite/util/process.py index c2466894f..624f2bcc9 100755 --- a/wifite/util/process.py +++ b/wifite/util/process.py @@ -204,7 +204,7 @@ def exists(program): stdout = p2.stdout().strip() stderr = p2.stderr().strip() - exist = not stdout == stderr == '' + exist = bool(stdout) if Configuration.initialized: Configuration.existing_commands.update({program: exist}) return exist From 077b8e18bf88772a9868ed0978e2c0cdc5e2fb24 Mon Sep 17 00:00:00 2001 From: vlkumiloslearning Date: Wed, 3 Jun 2026 00:24:55 +0200 Subject: [PATCH 2/2] fix: replace subprocess which with shutil.which() in Process.exists() The previous approach shelled out to the `which` binary via Popen, which has three problems: - `which` is not present on all systems (Alpine, minimal Docker images), causing an unhandled FileNotFoundError on every exists() call - any non-path text on stdout (e.g. zsh built-in printing "foo not found" to stdout) produced a false positive - spawning a subprocess for a PATH lookup is unnecessary overhead shutil is already imported and shutil.which() is already used by _resolve_tool() in the same class, as well as system_check.py and dependency.py. Using it here is consistent and correct on all platforms. --- wifite/util/process.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wifite/util/process.py b/wifite/util/process.py index 624f2bcc9..ce3f30da8 100755 --- a/wifite/util/process.py +++ b/wifite/util/process.py @@ -200,11 +200,7 @@ def exists(program): if Configuration.initialized and program in Configuration.existing_commands: return Configuration.existing_commands[program] - p2 = Process(['which', program]) - stdout = p2.stdout().strip() - stderr = p2.stderr().strip() - - exist = bool(stdout) + exist = shutil.which(program) is not None if Configuration.initialized: Configuration.existing_commands.update({program: exist}) return exist