Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.os.windows-10 > #187523

Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware

From Marion <marionf@fact.com>
Newsgroups alt.comp.os.windows-10, alt.comp.os.windows-11, alt.msdos.batch
Subject Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware
Date 2025-09-18 08:46 +0000
Organization BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID <10aggsa$p1e$1@nnrp.usenet.blueworldhosting.com> (permalink)
References <10agcdq$2e02$1@nnrp.usenet.blueworldhosting.com> <10agdp4$ngs$1@nnrp.usenet.blueworldhosting.com> <10agf37$15ok$1@nnrp.usenet.blueworldhosting.com>

Cross-posted to 3 groups.

Show all headers | View raw


Marion wrote:
> Tutorial: 
> Build a one-click Windows custom SOCKS5 proxy client using freeware
> Note that I will post working companion scripts following this overview.

While companion blocks are listed below, some are optional.
1. proxy.cmd (previously posted)
   HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\proxy.exe
   registry sync helper that reads and writes WinINet & WinHTTP settings

2. pac.cmd (posted below)
   HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pac.exe
   PAC file installer that calls proxy.cmd to enforce AutoConfigURL 
   and AutoDetect so that these three domains are bypassed 
   Amazon Vine (https://amazon.com/vine/about)
   Google Gmail (https://mail.google.com) 
   Microsoft (https://copilot.microsoft.com) 
   These are bypassed since they hate proxies like they hate VPN.

3. launchmongoose.vbs (previously posted)
   HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\mongoose.exe
   Launches a lightweight HTTP server that serves proxy.pac to localhost

4. psiphon.bat (previously posted in the original post of this thread)
   HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\psiphon.exe
   The main proxy client which elevates to admin, starts mongoose, 
   launches Psiphon, applies PAC logic, syncs to WinHTTP & logs activity

In contrast with the previous post where mongoose was added just yesterday 
as an OPTIONAL helper to serve PAC files over HTTP, probably the one script 
that I've spent the most time on in this month-long effort is this pac.cmd, 
which is a helper script that makes sure the system is using the correct 
PAC file, PAC URL and Auto-Detect settings after Psiphon starts. 

This pac.cmd script (which can be run from "Win+R > pac" if needed, is 
called by the main psiphon.bat custom proxy client in order to sync WinINet 
proxy settings into WinHTTP. What it does is it checks the current PAC 
configuration and applies changes if needed. It can also intelligently 
force the PAC URL and Auto-Detect registry keys so they stay set even if 
Windows fails to fetch the PAC file. That took a while to get timing right.

It then logs its actions even as it can run silently and it shows the final 
PAC status so we know when proxy logic is active across both stacks.

 @echo off
 REM C:\data\sys\batch\pac.cmd (This is version 3.0)
 REM Single command: Win+R > pac
 REM HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pac.exe
 REM C:\data\sys\batch\pac.cmd v1p6_20250902
 REM Sync WinHTTP proxy & apply PAC logic
 REM Used after Psiphon starts to align proxy layers
 REM C:\data\sys\batch\pac.cmd v1p7_20250916
 REM Changes in v1.7 (20250916):
 REM  After applying PAC, capture proxy.cmd /status to a temp file
 REM  Parse PAC URL & Auto-Detect status from proxy.cmd output
 REM  Display parsed results instead of static PAC summary
 REM C:\data\sys\batch\pac.cmd v1p8_20250916
 REM  Added PACURL variable at top for easy change
 REM  Improved /silent handling to work in any argument position
 REM C:\data\sys\batch\pac.cmd v1p9_20250916
 REM  Fixed capture logic so temp file is created before parsing
 REM C:\data\sys\batch\pac.cmd v2.0_20250916
 REM  Skips PAC apply step if PAC URL and Auto-Detect are already correct
 REM C:\data\sys\batch\pac.cmd v2.1_20250916
 REM  Added note this may be called automatically from psiphon.bat v1.2
 REM  Added detection/logging if called from psiphon.bat
 REM C:\data\sys\batch\pac.cmd v2.2_20250916
 REM  Added forced PAC set suggestion
 REM C:\data\sys\batch\pac.cmd v2.3_20250916
 REM  Now always forces PAC URL + Auto-Detect to ensure persistence
 REM C:\data\sys\batch\pac.cmd v2.4_20250916
 REM  Added re-capture of status after forcing PAC for accurate display
 REM C:\data\sys\batch\pac.cmd v2.5_20250916
 REM  Verified re-capture placement after reg add to fix stale display bug
 REM C:\data\sys\batch\pac.cmd v2.9_20250916
 REM  Hard-coded TEMPSTATUS to C:\tmp\pac_status.txt
 REM  Removed deletion of TEMPSTATUS at end
 REM  Section-aware parsing of PAC/AutoDetect block with /B matching
 REM C:\data\sys\batch\pac.cmd v3.0_20250917 (242 lines)
 REM  Moved PAC registry enforcement into apply block 
 REM  so proxy.cmd reflects correct status immediately
 REM  Added fallback enforcement even when PAC is already correct
 :: Normally the pac file is served by a web server.
 :: This script does not rely on Windows successfully fetching the PAC file 
 :: via HTTP. Instead, it Sets the registry key to point to the PAC URL
 :: It assumes the PAC logic is known & trusted.
 :: It uses proxy.cmd to apply proxy settings directly, 
 :: bypassing the need for Windows to interpret the PAC file
 :: So even if http://127.0.0.1/proxy.pac is not actually being served 
 :: by a web server, the system still behaves as if it is because the 
 :: tooling here enforces the logic manually.
 :: This is where Windows typically looks for the PAC script URL.
 :: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\
 :: AutoConfigURL = http://127.0.0.1/proxy.pac
 :: That tells Windows to fetch the PAC file from your own machine via HTTP
 :: http://127.0.0.1/proxy.pac
 :: C:\data\sys\batch\proxy.pac
 :: curl http://127.0.0.1/proxy.pac
 :: 
 :: You could point to the actual pac file but that is less universal
 :: AutoConfigURL = file:///C:/data/sys/batch/proxy.pac
 ::
 :: C:\app\network\psiphon\psiphon3.exe -mode=socks
 :: Win+R > control > Internet Options > Connections > LAN Settings
 :: Automatic configuration
 ::  [x]Automatically detect settings
 ::  [x]Use automatic configuration script
 ::     Address http://127.0.0.1/proxy.pac
 :: Proxy server
 ::  [x]Use a proxy server for your LAN
 ::  [x]Bypass proxy server for local addresses
 ::
 :: Win+I > Settings > Network & Internet > Proxy > Manual proxy setup = on
 ::  Automatic proxy setup
 ::   Automatically detect settings = on
 ::   Use setup script = on
 ::   Script address = http://127.0.0.1/proxy.pac
 ::  Manual proxy setup
 ::   Use a proxy server = on
 ::   Address http=127.0.0.1:3736;https=127.0.0.1:3736;socks=127.0.0.1:1080
 ::   Port = <blank>
 ::   Use the proxy server except for addresses that start with the following entries. Use semicolons (;) to separate entries.
 ::   10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*;169.254.*;[fc*];[fd*];[fe8*];[fe9*];[fea*];[feb*]
 ::  [x]Do not use the proxy server for local intranet addresses
 :: 
 :: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL
 :: AutoConfigURL = http://127.0.0.1/proxy.pac
 :: 
 :: C:\data\sys\batch\proxy.pac
 :: 
 
 REM PAC URL variable
 set "PACURL=http://127.0.0.1/proxy.pac"
 
 REM Detect /silent flag anywhere in args
 set SILENT=
 for %%A in (%*) do (
     if /i "%%A"=="/silent" set SILENT=1
 )
 
 REM Detect if called from psiphon.bat
 echo %CMDCMDLINE% | find /I "psiphon.bat" >nul
 if not errorlevel 1 (
     echo [%DATE% %TIME%] pac.cmd detected it was called from psiphon.bat >> C:\data\sys\log\proxy.log
 )
 
 REM Log start
 echo [%DATE% %TIME%] Run pac.cmd %* >> C:\data\sys\log\proxy.log
 
 REM /status flag
 for %%A in (%*) do (
     if /i "%%A"=="/status" (
         start "" "C:\data\sys\batch\proxy.cmd" /silent /status
         exit /b
     )
 )
 
 REM /nopac flag
 for %%A in (%*) do (
     if /i "%%A"=="/nopac" (
         echo Disable PAC & Auto-Detect...
         start "" "C:\data\sys\batch\proxy.cmd" /silent /nopac
         exit /b
     )
 )
 
 REM Sync WinINET into WinHTTP
 echo Run proxy sync...
 powershell -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c \"C:\data\sys\batch\proxy.cmd\" /sync' -NoNewWindow -Wait"
 
 REM Hard-coded temp file path
 set "TEMPSTATUS=C:\tmp\pac_status.txt"
 
 REM Capture current PAC status
 call "C:\data\sys\batch\proxy.cmd" /silent /status > "%TEMPSTATUS%"
 
 REM Parse PAC URL and Auto-Detect from [3] PAC / AutoDetect section only
 set "PACURL_FOUND="
 set "AUTODETECT="
 set "IN_PAC_SECTION="
 
 for /f "usebackq delims=" %%L in ("%TEMPSTATUS%") do (
     if defined IN_PAC_SECTION (
         if not defined PACURL_FOUND echo %%L | findstr /B /I "PAC URL:" >nul && set "PACURL_FOUND=%%L"
         if not defined AUTODETECT echo %%L | findstr /B /I "Auto-Detect" >nul && set "AUTODETECT=%%L"
         if "%%L"=="" set "IN_PAC_SECTION="
     )
     if "%%L"=="[3] PAC / AutoDetect" set "IN_PAC_SECTION=1"
 )
 
 set "PACURL_FOUND=%PACURL_FOUND:PAC URL: =%"
 set "AUTODETECT=%AUTODETECT:Auto-Detect =%"
 
 REM Decide whether to apply PAC
 set APPLY_PAC=0
 if /i not "%PACURL_FOUND%"=="%PACURL%" set APPLY_PAC=1
 if /i not "%AUTODETECT%"=="ENABLED" set APPLY_PAC=1
 
 if "%APPLY_PAC%"=="1" (
     echo Apply PAC logic...
     powershell -Command "Start-Process -FilePath 'cmd.exe' -ArgumentList '/c \"C:\data\sys\batch\proxy.cmd\" %PACURL%' -NoNewWindow -Wait"
 
     REM v2.10: Force PAC registry keys immediately after apply
     reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d %PACURL% /f >nul
     reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d 1 /f >nul
 
     REM Re-capture status after applying PAC
     call "C:\data\sys\batch\proxy.cmd" /silent /status > "%TEMPSTATUS%"
 ) else (
     echo PAC settings already correct - skipping apply step.
 
     REM v2.10: Still enforce PAC registry keys to guarantee consistency
     reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d %PACURL% /f >nul
     reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d 1 /f >nul
 )
 
 REM Re-capture status AFTER forcing PAC so display is accurate
 echo Re-capturing final status...
 call "C:\data\sys\batch\proxy.cmd" /silent /status > "%TEMPSTATUS%"
 REM Parse PAC URL and Auto-Detect again from [3] PAC / AutoDetect section
 set "PACURL_FOUND="
 set "AUTODETECT="
 set "IN_PAC_SECTION="
 
 for /f "usebackq delims=" %%L in ("%TEMPSTATUS%") do (
     if defined IN_PAC_SECTION (
         if not defined PACURL_FOUND echo %%L | findstr /B /I "PAC URL:" >nul && set "PACURL_FOUND=%%L"
         if not defined AUTODETECT echo %%L | findstr /B /I "Auto-Detect" >nul && set "AUTODETECT=%%L"
         if "%%L"=="" set "IN_PAC_SECTION="
     )
     if "%%L"=="[3] PAC / AutoDetect" set "IN_PAC_SECTION=1"
 )
 
 set "PACURL_FOUND=%PACURL_FOUND:PAC URL: =%"
 set "AUTODETECT=%AUTODETECT:Auto-Detect =%"
 
 if defined PACURL_FOUND (
     echo PAC URL: %PACURL_FOUND%
 ) else (
     echo PAC URL: Not set
 )
 
 if /i "%AUTODETECT%"=="ENABLED" (
     echo Auto-Detect ENABLED
 ) else (
     echo Auto-Detect DISABLED
 )
 
 REM Final pause unless /silent
 if not defined SILENT (
     echo.
     echo Press Enter, Spacebar, or any key to close...
     pause >nul
 )
 
 exit /b
 
 ::START: You type Win+R -> psiphon
 ::    |
 ::    v
 ::psiphon.bat 
 ::    - Check if running as admin
 ::        - If not, request UAC elevation and restart
 ::    - Launch mongoose.vbs to serve proxy.pac (moved earlier in v1.8)
 ::    - Wait 2 seconds for Mongoose to initialize (added in v1.8)
 ::    - Echo "waiting for mongoose..." during delay (added in v1.9)
 ::    - Verify PAC file is accessible via curl (added in v1.8)
 ::    - Launch psiphon3.exe in SOCKS mode
 ::    - Wait 5 seconds for Psiphon to initialize
 ::    - Log that pac.cmd is being run
 ::    - Call pac.cmd /silent
 ::        |
 ::        v
 ::    pac.cmd
 ::        - Log run
 ::        - Run proxy.cmd /sync to align WinINET -> WinHTTP
 ::        - Capture current PAC URL and Auto-Detect status
 ::        - If missing or wrong, call proxy.cmd with PAC URL
 ::        - Force set PAC URL and Auto-Detect in registry
 ::        - Re-capture status so final display is accurate
 ::        - Show final PAC and Auto-Detect status
 ::        - Return to psiphon.bat
 ::    - Force set PAC URL and Auto-Detect again (double guarantee)
 ::    - Pause for user to see output
 ::    - Exit without closing parent shell
 ::END
-- 
Note that this custom one-click socks5 proxy client is modular, 
where each component can be individually run & tested in one step.

Back to alt.comp.os.windows-10 | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 07:30 +0000
  Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 07:53 +0000
    Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 08:15 +0000
      Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 08:46 +0000
        Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 09:59 +0000
          Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 10:11 +0000
            Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 10:51 +0000
              Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 11:09 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-18 11:53 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware "R.Wieser" <address@is.invalid> - 2025-09-18 15:06 +0200
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-19 00:42 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-21 04:34 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-22 20:31 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-22 20:41 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-23 17:22 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-09-28 06:10 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-10-17 05:40 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <marionf@fact.com> - 2025-10-17 05:44 +0000
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-10-29 11:55 -0600
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-10-29 11:58 -0600
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-10-30 00:56 -0600
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-11-02 20:45 -0700
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-11-02 20:58 -0700
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marion <mariond@facts.com> - 2025-11-03 10:41 -0700
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marian <marianjones@helpfulpeople.com> - 2025-12-01 15:38 -0700
                Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marian <marianjones@helpfulpeople.com> - 2025-12-02 01:11 -0700
  Re: Tutorial: Build a one-click Windows custom SOCKS5 proxy client using freeware Marian <marianjones@helpfulpeople.com> - 2025-12-02 09:19 -0700

csiph-web