Skip to content

d2jvkpn/socks5-proxy

Repository files navigation

socks5-proxy


socks5 proxying through ssh tunnel and vpn

C01. Solved Problems

  1. Creating a SOCKS5 Proxy Server via SSH Tunnel with Optional Authentication
  • language: Golang
  • packages:
    • github.com/armon/go-socks5
    • golang.org/x/crypto/ssh
  1. DNS Resolver (socksh://)
  • uses the SSH remote command(crypto/ssh.Client.NewSession): dig +short
  1. Containers
  • docker, docker-compose
  • make
  1. Autoheal

C02. Usage

  1. configuration(configs/local.yaml)
ssh:
  ssh_host: remote_host
  ssh_port: 22
  ssh_user: account
  ssh_password: password
  ssh_private_key: /home/account/.ssh/id_rsa
  ssh_known_hosts: /home/account/.ssh/known_hosts
  socks5_user: hello
  socks5_password: world

noauth:
  ssh_host: remote_host
  ssh_port: 22
  ssh_user: account
  ssh_password: password
  ssh_private_key: /home/account/.ssh/id_rsa
  ssh_known_hosts: /home/account/.ssh/known_hosts
  1. compile
make build
  1. run
./target/main ssh -config=configs/local.yaml -addr=127.0.0.1:1081
  1. release
make release
  1. deployment(docker-compose)
  • build image socks5-proxy:dev:
make image-dev
  • create compose.yaml see containers/compose.sh and containers/compose.template.yaml

C03. Applications

  1. commandlines with socks5 proxying
# proxy=socks5://hello:world@127.0.0.1:1081
proxy=socks5h://hello:world@127.0.0.1:1081

https_proxy=$proxy git pull
https_proxy=$proxy git push

https_proxy=$proxy curl -4 https://icanhazip.com
curl -x "$proxy" https://icanhazip.com
  1. web browser with sock5 proxying (Neither Firefox nor Chromium supports SOCKS5 with authentication)
proxy=socks5h://127.0.0.1:1081

chromium --disable-extensions --incognito --proxy-server="$proxy"

# mannual config proxy in settings of firefox
firefox -p proxy

C04. Run an openvpn client in container and expose a sock5 proxy

  1. config and debug
  • _openvpn.sh
  1. deployment
  • containers/supervisord.compose.yaml
  1. openvpn server in container

C05. TODO

  1. block target ips and domains
  2. socks5 through ssh
  3. vpn
  4. wireguard: apk add wireguard-tools, --cap-add=NET_ADMIN, --cap-add=SYS_MODULE
  5. stunnel