Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
added CLI app, and nsis installer script,
Sourav Kalal45a8f7a84a31
diff --git a/.gitignore b/.gitignoreindex 38e5b06..59976a2 100644--- a/.gitignore+++ b/.gitignore@@ -6,4 +6,6 @@build/***.pycgui/bin/**-gui/obj/**\ No newline at end of file+gui/obj/**+cli/bin/**+cli/obj/**diff --git a/cli/Program.cs b/cli/Program.csnew file mode 100644index 0000000..377a899--- /dev/null+++ b/cli/Program.cs@@ -0,0 +1,261 @@+using System.Text.RegularExpressions;+using System.Security.Principal;+using System.Runtime.Versioning;++namespace ProxyBridge.CLI;++class Program+{+ private static ProxyBridgeNative.LogCallback? _logCallback;+ private static ProxyBridgeNative.ConnectionCallback? _connectionCallback;+ private static bool _isRunning = false;++ static int Main(string[] args)+ {+ if (args.Length == 0 || args.Contains("--help") || args.Contains("-h"))+ {+ ShowHelp();+ return 0;+ }++ if (!IsRunningAsAdministrator())+ {+ Console.ForegroundColor = ConsoleColor.Red;+ Console.WriteLine("\nERROR: ProxyBridge requires Administrator privileges!");+ Console.ResetColor();+ Console.WriteLine("Please run this application as Administrator.\n");+ return 1;+ }++ try+ {+ ShowBanner();++ var proxyConfig = ParseProxyConfig(args);+ var rules = ParseRules(args);++ _logCallback = OnLog;+ _connectionCallback = OnConnection;++ ProxyBridgeNative.ProxyBridge_SetLogCallback(_logCallback);+ ProxyBridgeNative.ProxyBridge_SetConnectionCallback(_connectionCallback);++ Console.WriteLine($"Proxy: {proxyConfig.Type}://{proxyConfig.Ip}:{proxyConfig.Port}");++ if (!ProxyBridgeNative.ProxyBridge_SetProxyConfig(proxyConfig.Type, proxyConfig.Ip, proxyConfig.Port))+ {+ Console.WriteLine("ERROR: Failed to set proxy configuration");+ return 1;+ }++ if (rules.Count > 0)+ {+ Console.WriteLine($"Rules: {rules.Count}");+ foreach (var rule in rules)+ {+ var ruleId = ProxyBridgeNative.ProxyBridge_AddRule(rule.ProcessName, rule.Action);+ if (ruleId > 0)+ {+ Console.WriteLine($" [{ruleId}] {rule.ProcessName} -> {rule.Action}");+ }+ else+ {+ Console.WriteLine($" ERROR: Failed to add rule for {rule.ProcessName}");+ }+ }+ }++ if (!ProxyBridgeNative.ProxyBridge_Start())+ {+ Console.WriteLine("ERROR: Failed to start ProxyBridge");+ return 1;+ }++ _isRunning = true;+ Console.WriteLine("\nProxyBridge started. Press Ctrl+C to stop...\n");++ Console.CancelKeyPress += (sender, e) =>+ {+ e.Cancel = true;+ Console.WriteLine("\n\nStopping ProxyBridge...");+ if (_isRunning)+ {+ ProxyBridgeNative.ProxyBridge_Stop();+ _isRunning = false;+ }+ Console.WriteLine("ProxyBridge stopped.");+ };++ while (_isRunning)+ {+ Thread.Sleep(100);+ }++ return 0;+ }+ catch (Exception ex)+ {+ Console.WriteLine($"ERROR: {ex.Message}");+ return 1;+ }+ }++ private static void OnLog(string message)+ {+ Console.WriteLine($"[LOG] {message}");+ }++ private static void OnConnection(string processName, uint pid, string destIp, ushort destPort, string proxyInfo)+ {+ Console.WriteLine($"[CONN] {processName} (PID:{pid}) -> {destIp}:{destPort} via {proxyInfo}");+ }++ private static (ProxyBridgeNative.ProxyType Type, string Ip, ushort Port) ParseProxyConfig(string[] args)+ {+ var proxyArg = GetArgValue(args, "--proxy");++ if (string.IsNullOrEmpty(proxyArg))+ {+ return (ProxyBridgeNative.ProxyType.SOCKS5, "127.0.0.1", 4444);+ }++ var socks5Match = Regex.Match(proxyArg, @"^socks5://([^:]+):(\d+)$", RegexOptions.IgnoreCase);+ if (socks5Match.Success)+ {+ return (+ ProxyBridgeNative.ProxyType.SOCKS5,+ socks5Match.Groups[1].Value,+ ushort.Parse(socks5Match.Groups[2].Value)+ );+ }++ var httpMatch = Regex.Match(proxyArg, @"^http://([^:]+):(\d+)$", RegexOptions.IgnoreCase);+ if (httpMatch.Success)+ {+ return (+ ProxyBridgeNative.ProxyType.HTTP,+ httpMatch.Groups[1].Value,+ ushort.Parse(httpMatch.Groups[2].Value)+ );+ }++ throw new ArgumentException($"Invalid proxy format: {proxyArg}. Use socks5://ip:port or http://ip:port");+ }++ private static List<(string ProcessName, ProxyBridgeNative.RuleAction Action)> ParseRules(string[] args)+ {+ var rules = new List<(string, ProxyBridgeNative.RuleAction)>();+ var ruleArg = GetArgValue(args, "--rule");++ if (string.IsNullOrEmpty(ruleArg))+ {+ return rules;+ }++ var rulePairs = ruleArg.Split(';', StringSplitOptions.RemoveEmptyEntries);+ foreach (var pair in rulePairs)+ {+ var parts = pair.Split('=', 2);+ if (parts.Length != 2)+ {+ throw new ArgumentException($"Invalid rule format: {pair}. Use process=action");+ }++ var processName = parts[0].Trim();+ var actionStr = parts[1].Trim().ToUpper();++ var action = actionStr switch+ {+ "PROXY" => ProxyBridgeNative.RuleAction.PROXY,+ "DIRECT" => ProxyBridgeNative.RuleAction.DIRECT,+ "BLOCK" => ProxyBridgeNative.RuleAction.BLOCK,+ _ => throw new ArgumentException($"Invalid action: {actionStr}. Use PROXY, DIRECT, or BLOCK")+ };++ rules.Add((processName, action));+ }++ return rules;+ }++ private static string? GetArgValue(string[] args, string argName)+ {+ for (int i = 0; i < args.Length - 1; i++)+ {+ if (args[i].Equals(argName, StringComparison.OrdinalIgnoreCase))+ {+ return args[i + 1];+ }+ }+ return null;+ }++ [SupportedOSPlatform("windows")]+ private static bool IsRunningAsAdministrator()+ {+ try+ {+ using var identity = WindowsIdentity.GetCurrent();+ var principal = new WindowsPrincipal(identity);+ return principal.IsInRole(WindowsBuiltInRole.Administrator);+ }+ catch+ {+ return false;+ }+ }++ private static void ShowBanner()+ {+ Console.WriteLine();+ Console.WriteLine(" ____ ____ _ _ ");+ Console.WriteLine(" | _ \\ _ __ _____ ___ _ | __ ) _ __(_) __| | __ _ ___ ");+ Console.WriteLine(" | |_) | '__/ _ \\ \\/ / | | | | _ \\| '__| |/ _` |/ _` |/ _ \\");+ Console.WriteLine(" | __/| | | (_) > <| |_| | | |_) | | | | (_| | (_| | __/");+ Console.WriteLine(" |_| |_| \\___/_/\\_\\\\__, | |____/|_| |_|\\__,_|\\__, |\\___|");+ Console.WriteLine(" |___/ |___/ V1.1");+ Console.WriteLine("\tAuthor: Sourav Kalal/InterceptSuite");+ Console.WriteLine("\tGitHub: https://github.com/InterceptSuite/ProxyBridge");+ Console.WriteLine();+ }++ private static void ShowHelp()+ {+ ShowBanner();+ Console.WriteLine(@"A lightweight proxy bridge for process-based traffic routing++USAGE:+ ProxyBridge_CLI [OPTIONS]++OPTIONS:+ --proxy <url> Proxy server URL+ Format: socks5://ip:port or http://ip:port+ Default: socks5://127.0.0.1:4444++ --rule <rules> Traffic routing rules (semicolon-separated)+ Format: process=action;process=action+ Actions: PROXY, DIRECT, BLOCK+ Example: --rule ""chrome.exe=proxy;firefox.exe=direct;*=block""++ --help, -h Show this help message++EXAMPLES:+ Start with default SOCKS5 proxy:+ ProxyBridge_CLI++ Use custom HTTP proxy:+ ProxyBridge_CLI --proxy http://192.168.1.100:8080++ Route specific processes:+ ProxyBridge_CLI --proxy socks5://127.0.0.1:1080 --rule ""chrome.exe=proxy;*=direct""++ Block all traffic except specific apps:+ ProxyBridge_CLI --rule ""chrome.exe=proxy;firefox.exe=proxy;*=block""++NOTES:+ - Press Ctrl+C to stop ProxyBridge+ - Use * as process name to match all traffic+ - Process names are case-insensitive+");+ }+}diff --git a/cli/ProxyBridge.CLI.csproj b/cli/ProxyBridge.CLI.csprojnew file mode 100644index 0000000..7ecfba5--- /dev/null+++ b/cli/ProxyBridge.CLI.csproj@@ -0,0 +1,15 @@+<Project Sdk="Microsoft.NET.Sdk">++ <PropertyGroup>+ <OutputType>Exe</OutputType>+ <TargetFramework>net9.0-windows</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <AssemblyName>ProxyBridge_CLI</AssemblyName>+ <Version>1.1.0</Version>+ <PublishAot>true</PublishAot>+ <InvariantGlobalization>false</InvariantGlobalization>+ <SelfContained>true</SelfContained>+ </PropertyGroup>++</Project>diff --git a/cli/ProxyBridgeNative.cs b/cli/ProxyBridgeNative.csnew file mode 100644index 0000000..2d39a89--- /dev/null+++ b/cli/ProxyBridgeNative.cs@@ -0,0 +1,83 @@+using System.Runtime.InteropServices;++namespace ProxyBridge.CLI;++public static class ProxyBridgeNative+{+ private const string DllName = "ProxyBridgeCore.dll";++ static ProxyBridgeNative()+ {+ var assemblyPath = AppContext.BaseDirectory;+ if (!string.IsNullOrEmpty(assemblyPath))+ {+ var dllPath = Path.Combine(assemblyPath, DllName);+ if (File.Exists(dllPath))+ {+ NativeLibrary.Load(dllPath);+ }+ }+ }++ public enum ProxyType+ {+ HTTP = 0,+ SOCKS5 = 1+ }++ public enum RuleAction+ {+ PROXY = 0,+ DIRECT = 1,+ BLOCK = 2+ }++ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]+ public delegate void LogCallback([MarshalAs(UnmanagedType.LPStr)] string message);++ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]+ public delegate void ConnectionCallback(+ [MarshalAs(UnmanagedType.LPStr)] string processName,+ uint pid,+ [MarshalAs(UnmanagedType.LPStr)] string destIp,+ ushort destPort,+ [MarshalAs(UnmanagedType.LPStr)] string proxyInfo);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ public static extern uint ProxyBridge_AddRule(+ [MarshalAs(UnmanagedType.LPStr)] string processName,+ RuleAction action);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_ClearRules();++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_EnableRule(uint ruleId);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_DisableRule(uint ruleId);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_SetProxyConfig(+ ProxyType type,+ [MarshalAs(UnmanagedType.LPStr)] string proxyIp,+ ushort proxyPort);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ public static extern void ProxyBridge_SetLogCallback(LogCallback callback);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ public static extern void ProxyBridge_SetConnectionCallback(ConnectionCallback callback);++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_Start();++ [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]+ [return: MarshalAs(UnmanagedType.Bool)]+ public static extern bool ProxyBridge_Stop();+}diff --git a/compile.ps1 b/compile.ps1index fa6a4d9..f272cb6 100644--- a/compile.ps1+++ b/compile.ps1@@ -5,12 +5,25 @@ param()$WinDivertPath = "C:\WinDivert-2.2.2-A"+$SourcePath = "src"$SourceFile = "ProxyBridge.c"-$OutputFile = "ProxyBridge.exe"+$OutputDLL = "ProxyBridgeCore.dll"+$OutputDir = "output"++$SignTool = "signtool.exe"+$CertThumbprint = ""+$TimestampServer = "http://timestamp.digicert.com"$Arch = if ([Environment]::Is64BitProcess) { "x64" } else { "x86" }Write-Host "Architecture: $Arch" -ForegroundColor Cyan+if (Test-Path $OutputDir) {+ Write-Host "Removing existing output directory..." -ForegroundColor Yellow+ Remove-Item $OutputDir -Recurse -Force+}+Write-Host "Creating output directory: $OutputDir" -ForegroundColor Cyan+New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null+if (-not (Test-Path $WinDivertPath)) {Write-Host "ERROR: WinDivert not found at: $WinDivertPath" -ForegroundColor RedWrite-Host "Please update the path in this script or install WinDivert" -ForegroundColor Yellow@@ -18,7 +31,7 @@ if (-not (Test-Path $WinDivertPath)) {}function Compile-MSVC {- Write-Host "`nCompiling with MSVC..." -ForegroundColor Green+ Write-Host "`nCompiling DLL with MSVC..." -ForegroundColor Green$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"@@ -32,12 +45,13 @@ function Compile-MSVC {}}- $cmd = "cl.exe /nologo /O2 /W3 /D_CRT_SECURE_NO_WARNINGS " ++ $cmd = "cl.exe /nologo /O2 /W3 /D_CRT_SECURE_NO_WARNINGS /DPROXYBRIDGE_EXPORTS " +"/I`"$WinDivertPath\include`" " +- "$SourceFile " ++ "$SourcePath\$SourceFile " ++ "/LD " +"/link /LIBPATH:`"$WinDivertPath\$Arch`" " +"WinDivert.lib ws2_32.lib iphlpapi.lib " +- "/OUT:$OutputFile"+ "/OUT:$OutputDLL"Write-Host "Command: $cmd" -ForegroundColor Gray@@ -50,7 +64,7 @@ function Compile-MSVC {}function Compile-GCC {- Write-Host "`nCompiling with GCC..." -ForegroundColor Green+ Write-Host "`nCompiling DLL with GCC..." -ForegroundColor Green$gccVersion = cmd /c gcc --version 2>&1if ($LASTEXITCODE -ne 0) {@@ -60,12 +74,12 @@ function Compile-GCC {Write-Host "GCC found: $($gccVersion[0])" -ForegroundColor Cyan- $cmd = "gcc -O2 -Wall -D_WIN32_WINNT=0x0601 " ++ $cmd = "gcc -shared -O2 -Wall -D_WIN32_WINNT=0x0601 -DPROXYBRIDGE_EXPORTS " +"-I`"$WinDivertPath\include`" " +- "$SourceFile " ++ "$SourcePath\$SourceFile " +"-L`"$WinDivertPath\$Arch`" " +"-lWinDivert -lws2_32 -liphlpapi " +- "-o $OutputFile"+ "-o $OutputDLL"Write-Host "Command: $cmd" -ForegroundColor Gray@@ -77,24 +91,46 @@ function Compile-GCC {return $exitCode -eq 0}-function Copy-WinDivertFiles {- Write-Host "`nCopying WinDivert runtime files..." -ForegroundColor Green-- $files = @(- "$WinDivertPath\$Arch\WinDivert.dll",- "$WinDivertPath\$Arch\WinDivert64.sys",- "$WinDivertPath\$Arch\WinDivert32.sys"+function Sign-Binary {+ param(+ [string]$FilePath)- foreach ($file in $files) {- if (Test-Path $file) {- Copy-Item $file -Destination . -Force- Write-Host " Copied: $(Split-Path $file -Leaf)" -ForegroundColor Gray- }+ if (-not (Test-Path $FilePath)) {+ Write-Host " File not found: $FilePath" -ForegroundColor Red+ return $false+ }++ $fileName = Split-Path $FilePath -Leaf++ if ($fileName -like "WinDivert*") {+ Write-Host " Skipped: $fileName (WinDivert is already EV signed)" -ForegroundColor Yellow+ return $true+ }++ Write-Host " Signing: $fileName" -ForegroundColor Cyan++ if ([string]::IsNullOrEmpty($CertThumbprint)) {+ $cmd = "signtool.exe sign /a /fd SHA256 /tr `"$TimestampServer`" /td SHA256 `"$FilePath`""+ } else {+ $cmd = "signtool.exe sign /sha1 $CertThumbprint /fd SHA256 /tr `"$TimestampServer`" /td SHA256 `"$FilePath`""+ }++ $result = cmd /c $cmd '2>&1'+ $exitCode = $LASTEXITCODE++ if ($exitCode -eq 0) {+ Write-Host " ✓ Signed successfully" -ForegroundColor Green+ return $true+ } else {+ Write-Host " ✗ Signing failed: $result" -ForegroundColor Red+ return $false}}++$success = $falseif ($Compiler -eq 'auto') {@@ -115,9 +151,112 @@ if ($Compiler -eq 'auto') {if ($success) {Write-Host "`nCompilation SUCCESSFUL!" -ForegroundColor Green- Copy-WinDivertFiles- Write-Host "`nUsage: .\$OutputFile chrome.exe -pid 27876" -ForegroundColor Cyan- Write-Host "Note: Run as Administrator!" -ForegroundColor Yellow++ Write-Host "`nMoving files to output directory..." -ForegroundColor Green+ Move-Item $OutputDLL -Destination $OutputDir -Force+ Write-Host " Moved: $OutputDLL -> $OutputDir\" -ForegroundColor Gray++ $files = @(+ "$WinDivertPath\$Arch\WinDivert.dll",+ "$WinDivertPath\$Arch\WinDivert64.sys",+ "$WinDivertPath\$Arch\WinDivert32.sys"+ )+ foreach ($file in $files) {+ if (Test-Path $file) {+ Copy-Item $file -Destination $OutputDir -Force+ Write-Host " Copied: $(Split-Path $file -Leaf)" -ForegroundColor Gray+ }+ }++ Write-Host "`nPublishing GUI..." -ForegroundColor Green+ $publishResult = dotnet publish gui/ProxyBridge.GUI.csproj -c Release -r win-x64 --self-contained -o gui/bin/Release/net9.0-windows/win-x64/publish 2>&1+ if ($LASTEXITCODE -eq 0) {+ Write-Host " GUI published successfully" -ForegroundColor Gray++ Write-Host "`nCopying GUI files to output..." -ForegroundColor Green+ $guiPublishPath = "gui\bin\Release\net9.0-windows\win-x64\publish"++ Copy-Item "$guiPublishPath\ProxyBridge.exe" -Destination $OutputDir -Force+ Write-Host " Copied: ProxyBridge.exe" -ForegroundColor Gray++ Get-ChildItem "$guiPublishPath\*.dll" | ForEach-Object {+ Copy-Item $_.FullName -Destination $OutputDir -Force+ Write-Host " Copied: $($_.Name)" -ForegroundColor Gray+ }+ } else {+ Write-Host " GUI publish failed!" -ForegroundColor Red+ Write-Host $publishResult+ }++ Write-Host "`nPublishing CLI..." -ForegroundColor Green+ $publishResult = dotnet publish cli/ProxyBridge.CLI.csproj -c Release -r win-x64 --self-contained -o cli/bin/Release/net9.0-windows/win-x64/publish 2>&1+ if ($LASTEXITCODE -eq 0) {+ Write-Host " CLI published successfully" -ForegroundColor Gray++ Write-Host "`nCopying CLI files to output..." -ForegroundColor Green+ $cliPublishPath = "cli\bin\Release\net9.0-windows\win-x64\publish"++ Copy-Item "$cliPublishPath\ProxyBridge_CLI.exe" -Destination $OutputDir -Force+ Write-Host " Copied: ProxyBridge_CLI.exe" -ForegroundColor Gray+ } else {+ Write-Host " CLI publish failed!" -ForegroundColor Red+ Write-Host $publishResult+ }++ Write-Host "`nSigning binaries..." -ForegroundColor Green+ $filesToSign = Get-ChildItem $OutputDir -Include *.exe,*.dll -Recurse+ $signedCount = 0+ $skippedCount = 0++ foreach ($file in $filesToSign) {+ if ($file.Name -like "WinDivert*") {+ Write-Host " Skipped: $($file.Name) (WinDivert is already EV signed)" -ForegroundColor Yellow+ $skippedCount+++ } else {+ if (Sign-Binary -FilePath $file.FullName) {+ $signedCount+++ }+ }+ }++ Write-Host "`nSigning Summary:" -ForegroundColor Cyan+ Write-Host " Signed: $signedCount files" -ForegroundColor Green+ Write-Host " Skipped: $skippedCount files (WinDivert)" -ForegroundColor Yellow++ Write-Host "`nAll files ready in: $OutputDir\" -ForegroundColor Cyan+ Write-Host "Contents:" -ForegroundColor Yellow+ Get-ChildItem $OutputDir | ForEach-Object {+ $size = [math]::Round($_.Length/1MB, 2)+ Write-Host " - $($_.Name) ($size MB)" -ForegroundColor Gray+ }++ Write-Host "`nBuilding installer..." -ForegroundColor Green+ $nsisPath = "C:\Program Files (x86)\NSIS\Bin\makensis.exe"+ if (Test-Path $nsisPath) {+ Push-Location installer+ $result = & $nsisPath "ProxyBridge.nsi" 2>&1+ Pop-Location+ if ($LASTEXITCODE -eq 0) {+ Write-Host " Installer created successfully" -ForegroundColor Green+ $installerName = "ProxyBridge-Setup-1.1.0.exe"+ if (Test-Path "installer\$installerName") {+ Move-Item "installer\$installerName" -Destination $OutputDir -Force+ Write-Host " Moved: $installerName -> $OutputDir\" -ForegroundColor Gray++ Write-Host "`nSigning installer..." -ForegroundColor Green+ if (Sign-Binary -FilePath "$OutputDir\$installerName") {+ $installerSize = [math]::Round((Get-Item "$OutputDir\$installerName").Length/1MB, 2)+ Write-Host " Installer ready: $OutputDir\$installerName ($installerSize MB)" -ForegroundColor Cyan+ }+ }+ } else {+ Write-Host " Installer build failed!" -ForegroundColor Red+ Write-Host $result+ }+ } else {+ Write-Host " NSIS not found at: $nsisPath" -ForegroundColor Yellow+ Write-Host " Skipping installer creation" -ForegroundColor Yellow+ }} else {Write-Host "`nCompilation FAILED!" -ForegroundColor RedWrite-Host "Need: Visual Studio with C++ or MinGW-w64" -ForegroundColor Yellowdiff --git a/installer/ProxyBridge.nsi b/installer/ProxyBridge.nsinew file mode 100644index 0000000..506b905--- /dev/null+++ b/installer/ProxyBridge.nsi@@ -0,0 +1,91 @@+!define PRODUCT_NAME "ProxyBridge"+!define PRODUCT_VERSION "1.1.0"+!define PRODUCT_PUBLISHER "InterceptSuite"+!define PRODUCT_WEB_SITE "https://github.com/InterceptSuite/ProxyBridge"+!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"+!define PRODUCT_UNINST_ROOT_KEY "HKLM"++!include "MUI2.nsh"+!include "WordFunc.nsh"++Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"+OutFile "ProxyBridge-Setup-${PRODUCT_VERSION}.exe"+InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}"+InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation"+RequestExecutionLevel admin++!define MUI_ABORTWARNING+!define MUI_ICON "..\gui\Assets\logo.ico"+!define MUI_UNICON "..\gui\Assets\logo.ico"++!insertmacro MUI_PAGE_WELCOME+!insertmacro MUI_PAGE_LICENSE "..\LICENSE"+!insertmacro MUI_PAGE_DIRECTORY+!insertmacro MUI_PAGE_INSTFILES+!insertmacro MUI_PAGE_FINISH++!insertmacro MUI_UNPAGE_CONFIRM+!insertmacro MUI_UNPAGE_INSTFILES++!insertmacro MUI_LANGUAGE "English"++Section "MainSection" SEC01+ SetOutPath "$INSTDIR"+ SetOverwrite on++ File "..\output\ProxyBridge.exe"+ File "..\output\ProxyBridge_CLI.exe"+ File "..\output\ProxyBridgeCore.dll"+ File "..\output\WinDivert.dll"+ File "..\output\WinDivert64.sys"+ File "..\output\av_libglesv2.dll"+ File "..\output\libHarfBuzzSharp.dll"+ File "..\output\libSkiaSharp.dll"++ CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"+ CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\ProxyBridge.exe"+ CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\ProxyBridge.exe"++ ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"+ StrCpy $0 "$0;$INSTDIR"+ WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$0"+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000+SectionEnd++Section -Post+ WriteUninstaller "$INSTDIR\uninst.exe"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\ProxyBridge.exe"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"+ WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"+SectionEnd++Section Uninstall+ Delete "$INSTDIR\ProxyBridge.exe"+ Delete "$INSTDIR\ProxyBridge_CLI.exe"+ Delete "$INSTDIR\ProxyBridgeCore.dll"+ Delete "$INSTDIR\WinDivert.dll"+ Delete "$INSTDIR\WinDivert64.sys"+ Delete "$INSTDIR\av_libglesv2.dll"+ Delete "$INSTDIR\libHarfBuzzSharp.dll"+ Delete "$INSTDIR\libSkiaSharp.dll"+ Delete "$INSTDIR\uninst.exe"++ Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"+ Delete "$DESKTOP\${PRODUCT_NAME}.lnk"+ RMDir "$SMPROGRAMS\${PRODUCT_NAME}"+ RMDir "$INSTDIR"++ ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"+ ${WordReplace} "$0" ";$INSTDIR" "" "+" $0+ ${WordReplace} "$0" "$INSTDIR;" "" "+" $0+ ${WordReplace} "$0" "$INSTDIR" "" "+" $0+ WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$0"+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000++ DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"+ SetAutoClose true+SectionEnd