From 86b5cd501ae726265f137f35041831e93d7f58f0 Mon Sep 17 00:00:00 2001 From: msarg44 Date: Sat, 22 Aug 2026 01:07:08 +0000 Subject: [PATCH 1/2] Escape file paths when interpolated into PowerShell commands All five Set-/Get-ProcessMitigation file-path call sites embed a user-chosen (or user-influenced) path inside a single-quoted PowerShell string without escaping. A path containing an apostrophe (common on Windows, e.g. a folder named "User's Documents") breaks the command, and a crafted '; ; ' segment is a PowerShell command-injection primitive. Wrap every interpolated path in ps_quote(), which doubles literal single quotes -- the PowerShell escape for single-quoted strings -- so install, import, and backup paths are safe regardless of their contents. --- ExploitProtection.PY | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) mode change 100644 => 100755 ExploitProtection.PY diff --git a/ExploitProtection.PY b/ExploitProtection.PY old mode 100644 new mode 100755 index 4354ab5..6444927 --- a/ExploitProtection.PY +++ b/ExploitProtection.PY @@ -53,6 +53,17 @@ def run_powershell(command): print(f"PS Error: {e}") return None +def ps_quote(value): + """Escape a path for safe use inside a single-quoted PowerShell string. + + In PowerShell a literal single quote inside a single-quoted string is + escaped by doubling it (''). Paths containing an apostrophe otherwise + break the command or enable command injection via a crafted '; ; ' + sequence. + """ + return value.replace("'", "''") + + def update_online_xml(): # Changed from ProgramFiles to Downloads to avoid strict permission issues dl_folder = os.path.join(os.path.expanduser("~"), "Downloads") @@ -69,7 +80,7 @@ def update_online_xml(): if os.path.exists(file_path): # 1. Try PowerShell Validation - cmd = f"Set-ProcessMitigation -PolicyFilePath '{file_path}' -IsValid" + cmd = f"Set-ProcessMitigation -PolicyFilePath '{ps_quote(file_path)}' -IsValid" res = run_powershell(cmd) is_valid = False @@ -89,7 +100,7 @@ def update_online_xml(): pass if is_valid: - run_powershell(f"Set-ProcessMitigation -PolicyFilePath '{file_path}'") + run_powershell(f"Set-ProcessMitigation -PolicyFilePath '{ps_quote(file_path)}'") messagebox.showinfo("Update completed", "Reboot to finalize protection") else: # Include debug info in error @@ -112,7 +123,7 @@ def backup_current_settings(): full_path = os.path.join(directory_name, f"{name}.xml") # Run Backup - cmd = f"Get-ProcessMitigation -RegistryConfigFilePath '{full_path}'" + cmd = f"Get-ProcessMitigation -RegistryConfigFilePath '{ps_quote(full_path)}'" run_powershell(cmd) if os.path.exists(full_path): @@ -195,7 +206,7 @@ def remove_all_protection(): def import_local_xml(): file_path = filedialog.askopenfilename(title="Select XML File", filetypes=[("XML files", "*.xml")]) if file_path: - cmd = f"Set-ProcessMitigation -PolicyFilePath '{file_path}'" + cmd = f"Set-ProcessMitigation -PolicyFilePath '{ps_quote(file_path)}'" run_powershell(cmd) messagebox.showinfo("Reboot to update.", f"Import completed from {file_path}") From 7e27ab495c3443dae0988dcbca4e203fb46497d9 Mon Sep 17 00:00:00 2001 From: msarg44 Date: Sat, 22 Aug 2026 01:07:18 +0000 Subject: [PATCH 2/2] Restore non-executable file mode (no functional change) --- ExploitProtection.PY | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 ExploitProtection.PY diff --git a/ExploitProtection.PY b/ExploitProtection.PY old mode 100755 new mode 100644