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


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

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 07:53 +0000
Organization BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID <10agdp4$ngs$1@nnrp.usenet.blueworldhosting.com> (permalink)
References <10agcdq$2e02$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.

The companion blocks psiphon.bat uses are listed below:
1. proxy.cmd
   registry sync helper that reads and writes WinINet & WinHTTP settings
2. pac.cmd
   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 
   Launches a lightweight HTTP server that serves proxy.pac to localhost
4. psiphon.bat
   The main proxy client which elevates to admin, starts mongoose, 
   launches Psiphon, applies PAC logic, syncs to WinHTTP & logs activity

Bearing in mind everything you do on WIndows more than once is to be made 
into a single click, each of these commands runs standalone when needed.
 Win+R > proxy
 Win+R > pac
 Win+R > mongoose
 Win+R > psiphon 
These single-point activators are made possible by the App Paths key:
 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\<name>.exe

For reference, here is the general flow so you can see where each is run.
 ::START: Win+R -> psiphon (uses App Paths registry key)
 ::    |
 ::    v
 ::psiphon.bat 
 ::    - Check if running as admin
 ::        - If not, request UAC elevation and restart
 ::    - Launch launchmongoose.vbs to start Mongoose HTTP server
 ::        - Serve proxy.pac at http://127.0.0.1/proxy.pac
 ::        - Wait 2 seconds for Mongoose to initialize
 ::        - Verify PAC file is available using curl
 ::        - If PAC file is not available, abort
 ::    - 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
 ::        - 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

Here is my working Win_R > proxy (proxy.cmd) source file:
 @echo off
 REM C:\data\sys\batch\proxy.cmd 20250902
 REM This is version 2.2
 REM Proxy diagnostic & config tool for WinINET, WinHTTP, PAC
 REM C:\data\sys\batch\proxy.cmd v2.1 - 20250916
 REM Changes in v2.1 (20250916):
 REM  Added conditional check before importing WinINET into WinHTTP 
 REM  to avoid overwriting existing settings unnecessarily
 REM  Added PAC file existence check before setting PAC URL
 REM  Updated pause prompts to clarify Enter, Spacebar, or any key works
 REM C:\data\sys\batch\proxy.cmd v2.2 - 20250916 (224 lines)
 REM  Changed final exit to exit /b to avoid closing parent cmd window
 
 REM Usage:
 REM   Win+R > proxy
 REM   Win+R > proxy /help
 REM   Win+R > proxy /sync
 REM   Win+R > proxy http://url.pac
 REM   Win+R > proxy /nopac
 REM   Win+R > proxy /status
 REM   Win+R > proxy /reset
 REM   Win+R > proxy /silent
 REM   Win+R > proxy /silent /sync
 
 REM Proxy types:
 REM   Type 1: WinINET - IE, Edge, MS Office, most apps
 REM   Type 2: WinHTTP - system services like Windows Update
 REM   Type 3: PAC/AutoDetect - Chrome, Edge, Firefox (if set to use system proxy)
 
 REM Show usage
 if /i "%~1"=="/help" (
     echo Usage:
     echo   proxy
     echo   proxy /sync
     echo   proxy http://...
     echo   proxy /nopac
     echo   proxy /status
     echo   proxy /reset
     echo   proxy /silent ...
     exit /b
 )
 
 REM Log command
 set LOG=C:\data\sys\log\proxy.log
 echo [%DATE% %TIME%] %cmdcmdline% >> %LOG%
 
 REM Begin scoped env
 setlocal
 
 set KEY="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
 
 REM Detect /silent flag
 if /i "%~1"=="/silent" (
     set SILENT=1
     shift
 )
 
 REM /reset flag
 if /i "%~1"=="/reset" (
     echo Reset proxy settings...
     reg delete %KEY% /v ProxyEnable /f >nul 2>&1
     reg delete %KEY% /v ProxyServer /f >nul 2>&1
     reg delete %KEY% /v AutoConfigURL /f >nul
     reg add %KEY% /v AutoDetect /t REG_DWORD /d 0 /f >nul
     netsh winhttp reset proxy >nul 2>&1
     echo Proxy settings cleared.
     goto SHOWCONFIG
 )
 
 REM /status flag
 if /i "%~1"=="/status" (
     echo Show proxy config...
     goto SHOWCONFIG
 )
 
 REM /sync flag
 if /i "%~1"=="/sync" (
     echo Sync WinINET into WinHTTP...
     REM Check if WinHTTP proxy is already set before importing
     for /f "tokens=1,* delims=:" %%A in ('netsh winhttp show proxy ^| findstr /R /C:"Proxy Server(s)"') do set curWinHTTP=%%B
     set curWinHTTP=%curWinHTTP:~1%
     if "%curWinHTTP%"=="" (
         netsh winhttp import proxy source=ie
         if errorlevel 1 (
             echo ERROR: Access denied. Run as admin.
         )
         echo Done.
     ) else (
         echo WinHTTP proxy already set, skipping import.
     )
     goto SHOWCONFIG
 )
 
 REM /nopac flag
 if /i "%~1"=="/nopac" (
     echo Disable PAC & Auto-Detect...
     reg delete %KEY% /v AutoConfigURL /f >nul 2>&1
     reg add %KEY% /v AutoDetect /t REG_DWORD /d 0 /f >nul
     echo PAC & Auto-Detect disabled.
     goto SHOWCONFIG
 )
 
 REM Set PAC URL
 if not "%~1"=="" (
     echo Set PAC URL: %~1
     REM PAC file existence check if URL is local file or localhost
     for /f "tokens=1 delims=:" %%P in ("%~1") do set PACPROTO=%%P
     if /i "%PACPROTO%"=="http" (
         REM If localhost PAC, check file existence
         echo %~1 | findstr /I "127.0.0.1" >nul
         if not errorlevel 1 (
             for /f "tokens=2 delims=:" %%H in ("%~1") do set PACPORTPATH=%%H
             REM Remove leading slashes
             set PACPORTPATH=%PACPORTPATH:/=%
             REM Adjust path if needed (user must ensure correct mapping)
             if not exist "C:\data\sys\pac\proxy.pac" (
                 echo WARNING: PAC file not found at C:\data\sys\pac\proxy.pac
             )
         )
     )
     reg add %KEY% /v AutoConfigURL /t REG_SZ /d %~1 /f >nul
     reg add %KEY% /v AutoDetect /t REG_DWORD /d 1 /f >nul
 )
 
 REM Diagnostic output
 :SHOWCONFIG
 echo ============================================
 echo   WINDOWS PROXY CONFIG CHECK
 REM Avoid slash to prevent parsing bug
 echo ============================================
 
 REM WinINET status
 echo.
 echo [1] WinINET
 for /f "tokens=2,* skip=2" %%A in ('reg query %KEY% /v ProxyEnable 2^>nul') do set ProxyEnable=%%B
 for /f "tokens=2,* skip=2" %%A in ('reg query %KEY% /v ProxyServer 2^>nul') do set ProxyServer=%%B
 if "%ProxyEnable%"=="0x1" (
     echo Proxy ENABLED
     echo Server: %ProxyServer%
 ) else (
     echo Proxy DISABLED
 )
 
 REM WinHTTP status
 echo.
 echo [2] WinHTTP
 for /f "tokens=1,* delims=:" %%A in ('netsh winhttp show proxy ^| findstr /R /C:"Proxy Server(s)"') do set curWinHTTP=%%B
 set curWinHTTP=%curWinHTTP:~1%
 if "%curWinHTTP%"=="" (
     echo No WinHTTP proxy - import from WinINET...
     netsh winhttp import proxy source=ie >nul 2>&1
 ) else (
     echo WinHTTP proxy already set
 )
 netsh winhttp show proxy
 
 REM PAC status
 echo.
 echo [3] PAC / AutoDetect
 for /f "tokens=2,* skip=2" %%A in ('reg query %KEY% /v AutoConfigURL 2^>nul') do set PACurl=%%B
 for /f "tokens=2,* skip=2" %%A in ('reg query %KEY% /v AutoDetect 2^>nul') do set AutoDetect=%%B
 if defined PACurl (
     echo PAC URL: %PACurl%
 ) else (
     echo No PAC URL
 )
 
 REM PAC logic summary
 if /i "%PACurl%"=="http://127.0.0.1/proxy.pac" (
     echo PAC logic: Bypass Gmail, Amazon, Copilot
     echo Other traffic via SOCKS proxy 127.0.0.1:1080
 )
 
 if "%AutoDetect%"=="0x1" (
     echo Auto-Detect ENABLED
 ) else (
     echo Auto-Detect DISABLED
 )
 
 echo.
 echo ============================================
 echo Proxy check complete
 echo ============================================
 
 endlocal
 
 REM Final pause unless /silent
 if not defined SILENT (
     echo.
     echo Press Enter, Spacebar, or any key to close...
     pause >nul
 )
 
 exit /b
 
-- 
Some people are kind hearted enough to ensure others always benefit.

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