Skip to content

Instantly share code, notes, and snippets.

@ssrlive
Created August 1, 2021 19:24
Show Gist options
  • Save ssrlive/bc1738dd86bd01cf29611ae5a7a45fdf to your computer and use it in GitHub Desktop.
Save ssrlive/bc1738dd86bd01cf29611ae5a7a45fdf to your computer and use it in GitHub Desktop.
@echo off
@setlocal EnableDelayedExpansion
cd /d "%~dp0"
::--- need config ---
:: to check interface index run> netsh int ipv4 show interfaces "Wi-Fi"
:: or change Wi-Fi to your interface name
set gwIP=XXX.XXX.XXX.XXX
set gwIndex=X
set proxyIp=XXX.XXX.XXX.XXX
set tapName=tap4socks
::--- set ip to text ---
(
echo 0.0.0.0/1
echo 128.0.0.0/1
)>"4-subnet.txt"
::--- TAP setup ---
netsh interface ip set address %tapName% static 10.0.0.2 255.255.255.0
netsh int ipv4 set dns name=%tapName% static 127.0.0.1 primary validate=no
set tapIp=10.0.0.1
::--- run tun2sock ---
:: if use old driver > --tundev "tap0901:tap4socks:..."
start /min cmd /c "tun2socks --tundev "root\tap0901:tap4socks:10.0.0.2:10.0.0.0:255.255.255.0" --netif-ipaddr 10.0.0.1 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:1080 --socks5-udp --udp-relay-addr 127.0.0.1:1080 --loglevel none"
timeout /t 2 > nul
::--- run config ---
for /F "tokens=*" %%a in ('type 4-subnet.txt') do ( netsh interface ipv4 add route %%a nexthop=%tapIp% interface=%tapName% metric=0 store=active )
netsh interface ipv4 add route %proxyIp%/32 nexthop=%gwIp% interface="%gwIndex%" metric=0 store=active
cls
echo [--running--]
echo Press any key to stop and remove config
pause
:::--- stop tun2sock ---
taskkill /IM "tun2socks.exe" /F
::--- del config ---
for /F "tokens=*" %%a in ('type 4-subnet.txt') do ( netsh interface ipv4 delete route %%a interface=%tapName% )
route delete %proxyIp%
::pause
@ssrlive
Copy link
Author

ssrlive commented Aug 1, 2021

tun2socks-cmd

cmd script to use tun2socks with shadowsocks.

this script for use with dnscrypt-proxy in tcp mode.

  • install TAP driver by Device Manager > Add legacy hardware.
  • remane TAP interface to tap4socks or what you want.
  • edit gateway data and proxy ip in script.
  • paste *.bat same directory as tun2socks.exe.
  • run Shadowsocks.exe
  • run *.bat as admin.

other resource

tun2socks

https://github.com/ambrop72/badvpn

or *.exe from other folk.

tap-windows

https://github.com/OpenVPN/tap-windows6

or

https://build.openvpn.net/downloads/releases/

Shadowsocks

https://github.com/shadowsocks/shadowsocks-windows

Outline Client

Client software running like my script.

but they send back telemetry data by sentry.io

and always connect to s3.amazonaws.com now sure why

it's always connection fail for me, no luck.

https://github.com/Jigsaw-Code/outline-client

Why TAP not wintun driver ?

Please read > https://github.com/lessload/wireguard-windows--------------Big-Problem

@ssrlive
Copy link
Author

ssrlive commented Aug 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment