Git Product home page Git Product logo

shadowtunnel's Introduction

shadowtunnel

Introduce

shadowtunnel is a secure encryption tunnel between your local machine and remote service to protect your TCP flow,

which can efficiently compress transmission, and the flow has no characteristics.

local machine <----> shadowtunnel <----> service on remote.

Usage

Usage of ./shadowtunnel:
  -E    outbound connection is encrypted
  -U    outbound connection is udp
  -c    compress traffic
  -cache string
        dns query cache file path (default "cache.dat")
  -daemon
        daemon mode
  -debug
        show debug info
  -dns string
        local dns server listen on address
  -dns-hosts string
        path of dns hosts file
  -dns-proxy
        is dns endpoint or not
  -dns-server string
        remote dns server to resolve domain (default "8.8.8.8:53")
  -e    inbound connection is encrypted
  -f weight
        forward address,such as : 127.0.0.1:8080 or with @weight: 127.0.0.1:8080@1
  -forever
        forever mode
  -l string
        local listen address, such as : 0.0.0.0:33000 (default ":50000")
  -lb-activeafter int
        host going actived after this success count (default 1)
  -lb-hashtarget hash
        use target address to choose parent for LB, only worked for LB's hash
        method and using `-redir` (default true)
  -lb-inactiveafter int
        host going inactived after this fail count (default 2)
  -lb-method string
        load balance method when use multiple parent,can be
        <roundrobin|leastconn|leasttime|hash|weight> (default "leasttime")
  -lb-onlyha high availability mode
        use only high availability mode to choose parent for LB
  -lb-retrytime int
        sleep time milliseconds after checking (default 2000)
  -lb-timeout int
        tcp milliseconds timeout of connecting to parent (default 3000)
  -log string
        logging output to file
  -m string
        method of encrypt/decrypt, these below are supported :
        aes-128-cfb,aes-192-cfb,des-cfb,cast5-cfb,rc4-md5,chacha20,aes-256-cfb,
        aes-128-ctr,aes-192-ctr,aes-256-ctr,bf-cfb,rc4-md5-6,chacha20-ietf
        (default "aes-192-cfb")
  -nolog
        turn off logging
  -p string
        password of encrypt/decrypt (default "shadowtunnel")
  -profiling
        profiling mode, in this mode, you should stopping process
        by : Ctrl+C or 'kill -s SIGHUP $PID_OF_shadowtunnel'
  -redir
        read target from socket's redirect opts of iptables
  -t int
        connection timeout seconds (default 3)
  -ttl int
        cache seconds of dns query , if zero , default ttl used. (default 300)
  -u    inbound connection is udp
  -v    show version

for example

1.http proxy

if we have a vps, IP is 2.2.2.2

firstly, we start a http proxy on 2.2.2.2.
download http proxy program, execute below on line command on vps with root:

wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz && tar zxfv proxy-linux-amd64.tar.gz && rm proxy-linux-amd64.tar.gz && mv proxy /usr/bin/ && proxy http -p 127.0.0.1:38080 &

2.Start a tunnel on VPS

download shadowtunnel program, execute below on line command on vps with root:

wget https://github.com/snail007/shadowtunnel/releases/download/v1.1/shadowtunnel-linux-amd64.tar.gz && tar zxfv shadowtunnel-linux-amd64.tar.gz && rm shadowtunnel-linux-amd64.tar.gz && mv shadowtunnel /usr/bin/

start a tunnel on vps listening on :50000 and forward to 127.0.0.1:38080 :

shadowtunnel -e -f 127.0.0.1:38080 -l :50000

3.start a tunnel on local machine

start a tunnel on local machine listening on :50000 and forward to 2.2.2.2:50000 :

shadowtunnel -E -f 2.2.2.2:50000 -l :50000

4.set http proxy configuration in chrome

setting local chrome's http proxy configuration as below:

ip: 127.0.0.1 port: 50000

5.done

TCP over UDP

1.http proxy

if we have a vps, IP is 2.2.2.2.

firstly, we start a http proxy on 2.2.2.2.
download http proxy program, execute below on line command on vps with root:

wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz && tar zxfv proxy-linux-amd64.tar.gz && rm proxy-linux-amd64.tar.gz && mv proxy /usr/bin/ && proxy http -p 127.0.0.1:38080 &

2.start a tunnel on vps

download shadowtunnel program, execute below on line command on vps with root:

wget https://github.com/snail007/shadowtunnel/releases/download/v1.1/shadowtunnel-linux-amd64.tar.gz && tar zxfv shadowtunnel-linux-amd64.tar.gz && rm shadowtunnel-linux-amd64.tar.gz && mv shadowtunnel /usr/bin/

start a tunnel on vps listening on udp :50000 and forward to tcp 127.0.0.1:38080 :

shadowtunnel -u -e -f 127.0.0.1:38080 -l :50000 -p your-password

3.start a tunnel on local machine

start a tunnel on local machine listening on tcp :50000 and forward to udp 2.2.2.2:50000 :

shadowtunnel -U -E -f 2.2.2.2:50000 -l :50000 -p your-password

4.set http proxy configuration in chrome

setting local chrome's http proxy configuration as below:

ip: 127.0.0.1 port: 50000

5.Done

Deamon & Forever & Log

-daemon:

Using the parameter -daemon allows shadowtunnel to detached from the current command line and run in the background.

-forever:

Using parameter -forever allows shadowtunnel to run in the way of creating and monitoring child processes,

If an abnormal exit occurs, the child process will be restarted to ensure that the service is always online..

-log

Using parameter -log, you can set the log output to the file instead of the command line output.

-nolog

Using parameter -nolog can completely shut off log output and save CPU occupation.

Generally, the three parameters (-daemon -forever -log /tmp/st.log) are used together, so that we can find out the cause of the problem by looking at the log when we have a problem.

for example:

shadowtunnel -u -e -f 127.0.0.1:38080 -l :50000 -p your-password -daemon -forever -log /tmp/st.log

DNS SERVICE

Shadowtunnel can provide local DNS query service, and has caching function to improve resolution speed.

It is necessary to have a superior service to start a DNS service while launching the port forwarding locally.

The -dns parameter sets the IP and port which the local DNS service listen, for example:0.0.0.0:5353

The -dns-server Parameters can be set to DNS servers that are ultimately used to resolve domain names, requiring the server to support TCP-style DNS queries, default:8.8.8.8:53.

for example:

shadowtunnel -E -f 2.2.2.2:50000 -l :50000 -p your-password -dns :5353 -dns-server 8.8.8.8:53

superior example:

If the superior is chain-style, then the superior of the DNS proxy in the chain is required to add the -dns-proxy parameter.

shadowtunnel -e -f 127.0.0.1:38080 -l :50000 -p your-password -dns-proxy

DNS CACHE

The -ttl parameter can set the DNS query result cache time. unit is second. if it is 0, and use the TTL of the query result.

The -cache parameter sets DNS cache file location to prevent program restart and cache disappear, which will reduce performance.

LOAD BALANCE

Support superior load balancing, repeat -f parameters if exist multiple superiors.

shadowtunnel -E -f 2.2.2.2:50000 -f 3.3.3.3:50000 -l :50000

SET RETRY INTERVAL AND TIMEOUT TIME

shadowtunnel -E -f 2.2.2.2:50000 -f 3.3.3.3:50000 -l :50000 -lb-method leastconn -lb-retrytime 300 -lb-timeout 300

SETTING WEIGHT

shadowtunnel -E -f 2.2.2.2:50000@2 -f 3.3.3.3:50000@1 -l :50000 -lb-method weight -lb-retrytime 300 -lb-timeout 300

USE TARGET ADDRESS TO SELECT SUPERIOR

shadowtunnel -E -f 2.2.2.2:50000@2 -f 3.3.3.3:50000@1 -l :50000 -lb-method hash -lb-hashtarget -lb-retrytime 300 -lb-timeout 300

DNS HOSTS

The -dns- hosts parameter sets the hosts file to be used when DNS is parsed, with the same content format as the system's hosts file.

shadowtunnel -f 2.2.2.2:50000 -dns :5353 -dns-hosts /etc/hosts

shadowtunnel's People

Contributors

snail007 avatar yincongcyincong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shadowtunnel's Issues

server crash

Hello ,I had a server side shadowtunnel crash, client and server version is v1.1
server cmd:

setsid ./shadowtunnel -u -e -f 127.0.0.1:38080 -l :50000 -p 123456 >shadow.log 2>&1 &

client cmd:

./shadowtunnel -E -U -f x.x.x.x:50000 -l :50000 -p 123456

following is key log from server:

runtime/debug.Stack(0xc42004acc8, 0x6c6dc0, 0x8cd2a0)
/usr/local/go/src/runtime/debug/stack.go:24 +0xa7
github.com/snail007/goproxy/core/dst.NewMux.func2.1()
/home/pengmeng/go/src/github.com/snail007/goproxy/core/dst/mux.go:85 +0x48
panic(0x6c6dc0, 0x8cd2a0)
/usr/local/go/src/runtime/panic.go:502 +0x229
encoding/binary.binary.bigEndian.Uint32(...)
/usr/local/go/src/encoding/binary/binary.go:111
github.com/snail007/goproxy/core/dst.unmarshalHeader(0xc420136000, 0x4, 0x1f4, 0x0, 0x0)
/home/pengmeng/go/src/github.com/snail007/goproxy/core/dst/packets.go:86 +0xcd
github.com/snail007/goproxy/core/dst.(*Mux).readerLoop(0xc420054360)
/home/pengmeng/go/src/github.com/snail007/goproxy/core/dst/mux.go:269 +0x101
github.com/snail007/goproxy/core/dst.NewMux.func2(0xc420054360)
/home/pengmeng/go/src/github.com/snail007/goproxy/core/dst/mux.go:88 +0x47
created by github.com/snail007/goproxy/core/dst.NewMux
/home/pengmeng/go/src/github.com/snail007/goproxy/core/dst/mux.go:82 +0x28f
2018/09/07 02:50:36 14.30.175.184:40483 <--> 127.0.0.1:38080 released

server and client crash v1.6

Hello,snail!
I was runing shadowtunnel in debug mode.when I want to quit it, it occurs.
Both Server and Client have this problem,here is the output log:

2019/03/25 22:03:51.853881 st.go:705: clean handler crashed, err :
goroutine 8 [running]:
runtime/debug.Stack(0xc0420b7df0, 0x7d9860, 0xa81570)
/usr/local/go/src/runtime/debug/stack.go:24 +0xae
github.com/snail007/shadowtunnel/core.cleanup.func1.1()
/home/pengmeng/go/src/github.com/snail007/shadowtunnel/core/st.go:434 +0x4f
panic(0x7d9860, 0xa81570)
/usr/local/go/src/runtime/panic.go:502 +0x237
time.(*Ticker).Stop(0x0)
/usr/local/go/src/time/tick.go:46 +0x29
github.com/snail007/shadowtunnel/core.Stop()
/home/pengmeng/go/src/github.com/snail007/shadowtunnel/core/st.go:447 +0x6c
github.com/snail007/shadowtunnel/core.cleanup.func1(0xc04204c300, 0xc042055800)
/home/pengmeng/go/src/github.com/snail007/shadowtunnel/core/st.go:438 +0x5b
created by github.com/snail007/shadowtunnel/core.cleanup
/home/pengmeng/go/src/github.com/snail007/shadowtunnel/core/st.go:431 +0x154

建议增加访问认证设置

非常好,已经用起来了,配置也比SSR简单很多

为了方便家里和手机端使用,我把客户端配置到了一台国内的vps上,switchyOmega只要配置这个地址就能使用。

这样就有一个问题,如果别人知道了我的服务器地址或者客户端地址,就能随意的使用,这一点是非常不安全的,希望增加用户认证的功能。

建议增加多后端负载均衡功能

我现在有2个vps,都安装了goproxy 和shadowtunnel,我想要在本地局域网服务器上监听一个端口,然后能够通过隧道将流量转发到2台vps上。
我使用这个命令可以正常监听,但是日志显示只与其中一台建立了连接:

shadowtunnel -E -f 1.1.1.1:5000 -f 1.1.1.2:5000 -l :5000

当停掉建立连接的服务器上的服务时,流量并没有切换到另一台上。

WARNING: this tool is not safe to use

There probably aren't many people using to encrypt their traffic any more, but in case anyone was thinking about it, please don't.

Breaking the encryption of this tool was a challenge for Real World CTF 2020.

By defaul the tunnel uses AES-CFB with a static Initialisation Vector, so multiple connections are encrypted using the same keystream. Furthermore, the streams are malleable, so an adversary can capture your traffic and decrypt it by replaying it through your own proxy server.

Here is a full writeup

cannot find package "github.com/snail007/proxy/core/dst"

Hi,
I downloaded this project and I run it but I got this error in building:
cannot find package "github.com/snail007/proxy/core/dst"
Is exist this repository (github.com/snail007/proxy)? I cannot find this repo anywhere. Any help, please.

-c 参数怎么用呢

发现新版增加了 -c 参数,试着两边都加了 -c 参数用了一下,但是发现无法建立连接。

请问 -c 参数怎么用呢? 是不需要解压缩的参数吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.