- Notifications
You must be signed in to change notification settings - Fork1
A fast TCP tunnel over HTTP
cicavey/chisel
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Chisel is a fast TCP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (Golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network. Chisel is very similar tocrowbar though achievesmuch higherperformance.
Binaries
Seethe latest release or download and install it now withcurl https://i.jpillora.com/chisel! | bash
Docker
docker run --rm -it jpillora/chisel --help
Source
$ go get -v github.com/jpillora/chisel
- Easy to use
- Performant*
- Encrypted connections using
crypto/ssh
- Authenticated connections; authenticated client connections with a users config file, authenticated server connections with fingerprint matching.
- Client auto-reconnects withexponential backoff
- Client can create multiple tunnel endpoints over one TCP connection
- Server optionally doubles as areverse proxy
Ademo app on Heroku is running thischisel server
:
$ chisel server --port$PORT --proxy http://example.com# listens on $PORT, proxy web requests to 'http://example.com'
This demo app is also running asimple file server on:3000
, which is normally inaccessible due to Heroku's firewall. However, if we tunnel in with:
$ chisel client https://chisel-demo.herokuapp.com 3000# connects to 'https://chisel-demo.herokuapp.com',# tunnels your localhost:3000 to the server's localhost:3000
and then visitlocalhost:3000, we should see a directory listing of the demo app's root. Also, if we visit thedemo app in the browser we should hit the server's default proxy and see a copy ofexample.com.
$ chisel --help Usage: chisel [command] [--help] Version: 0.0.0-src Commands: server - runs chisel in server mode client - runs chisel in client mode Read more: https://github.com/jpillora/chisel
$ chisel server --help Usage: chisel server [options] Options: --host, Defines the HTTP listening host – the network interface (defaults the environment variable HOST and falls back to 0.0.0.0). --port, -p, Defines the HTTP listening port (defaults to the environment variable PORT and fallsback to port 8080). --key, An optional string to seed the generation of a ECDSA public and private key pair. All commications will be secured using this key pair. Share the subsequent fingerprint with clients to enable detection of man-in-the-middle attacks (defaults to the CHISEL_KEY environmentvariable, otherwise a new key is generate each run). --auth, An optional string representing a single user with fullaccess, in the form of <user:pass>. This is equivalent to creating anauthfile with {"<user:pass>": [""]}. --authfile, An optional path to a users.json file. This file should be an object with users defined like: "<user:pass>": ["<addr-regex>","<addr-regex>"] when <user> connects, their <pass> will be verified and then each of the remote addresses will be compared against the list of address regular expressions for a match. Addresses will always come in the form "<host/ip>:<port>". --proxy, Specifies another HTTP server to proxy requests to whenchisel receives a normal HTTP request. Useful for hiding chisel inplain sight. --socks5, Allows client to access the internal SOCKS5 proxy. See chisel client --help for more information. --pid Generate pid file in current directory -v, Enable verbose logging --help, This help text Version: 0.0.0-src Read more: https://github.com/jpillora/chisel
$ chisel client --help Usage: chisel client [options] <server> <remote> [remote] [remote] ... <server> is the URL to the chisel server. <remote>s are remote connections tunnelled through the server, each of which come in the form: <local-host>:<local-port>:<remote-host>:<remote-port> ■ local-host defaults to 0.0.0.0 (all interfaces). ■ local-port defaults to remote-port. ■ remote-port is required*. ■ remote-host defaults to 0.0.0.0 (server localhost). example remotes 3000 example.com:3000 3000:google.com:80 192.168.0.5:3000:google.com:80 socks 5000:socks *When the chisel server enables --socks5, remotes can specify "socks" in place of remote-host and remote-port. The default local host and port for a "socks" remote is 127.0.0.1:1080. Connections to this remote will terminate at the server's internal SOCKS5 proxy. Options: --fingerprint, A *strongly recommended* fingerprint string to perform host-key validation against the server's public key. You may provide just a prefix of the key or the entire string. Fingerprint mismatches will close the connection. --auth, An optional username and password (client authentication) in the form: "<user>:<pass>". These credentials are compared to the credentials inside the server's --authfile. defaults to theAUTH environment variable. --keepalive, An optional keepalive interval. Since the underlying transport is HTTP, in many instances we'll be traversing through proxies, often these proxies will close idle connections. You must specify a time with a unit, for example '30s' or '2m'. Defaults to '0s' (disabled). --proxy, An optional HTTP CONNECT proxy which will be used reach the chisel server. Authentication can be specified inside the URL.For example, http://admin:password@my-server.com:8081 --pid Generate pid file in current directory -v, Enable verbose logging --help, This help text Version: 0.0.0-src Read more: https://github.com/jpillora/chisel
See alsoprogrammatic usage.
Encryption is always enabled. When you start up a chisel server, it will generate an in-memory ECDSA public/private key pair. The public key fingerprint will be displayed as the server starts. Instead of generating a random key, the server may optionally specify a key seed, using the--key
option, which will be used to seed the key generation. When clients connect, they will also display the server's public key fingerprint. The client can force a particular fingerprint using the--fingerprint
option. See the--help
above for more information.
Using the--authfile
option, the server may optionally provide auser.json
configuration file to create a list of accepted users. The client then authenticates using the--auth
option. Seeusers.json for an example authentication configuration file. See the--help
above for more information.
Internally, this is done using thePassword authentication method provided by SSH. Learn more aboutcrypto/ssh
herehttp://blog.gopheracademy.com/go-and-ssh/.
Withcrowbar, a connection is tunnelled by repeatedly querying the server with updates. This results in a large amount of HTTP and TCP connection overhead. Chisel overcomes this using WebSockets combined withcrypto/ssh to create hundreds of logical connections, resulting inone TCP connection per client.
In this simple benchmark, we have:
(direct) .--------------->----------------. / chisel chisel \request--->client:2001--->server:2002---->fileserver:3000 \ / '--> crowbar:4001--->crowbar:4002' client server
Note, we're using an in-memory "file" server on localhost for these tests
direct
:3000 => 1 bytes in 1.291417ms:3000 => 10 bytes in 713.525µs:3000 => 100 bytes in 562.48µs:3000 => 1000 bytes in 595.445µs:3000 => 10000 bytes in 1.053298ms:3000 => 100000 bytes in 741.351µs:3000 => 1000000 bytes in 1.367143ms:3000 => 10000000 bytes in 8.601549ms:3000 => 100000000 bytes in 76.3939ms
chisel
:2001 => 1 bytes in 1.556521ms:2001 => 10 bytes in 1.310739ms:2001 => 100 bytes in 1.26706ms:2001 => 1000 bytes in 1.189441ms:2001 => 10000 bytes in 1.509267ms:2001 => 100000 bytes in 2.98981ms:2001 => 1000000 bytes in 14.737928ms:2001 => 10000000 bytes in 141.936428ms:2001 => 100000000 bytes in 1.208960105s
~100MB in~1 second
crowbar
:4001 => 1 bytes in 3.335797ms:4001 => 10 bytes in 1.453007ms:4001 => 100 bytes in 1.811727ms:4001 => 1000 bytes in 1.621525ms:4001 => 10000 bytes in 5.20729ms:4001 => 100000 bytes in 38.461926ms:4001 => 1000000 bytes in 358.784864ms:4001 => 10000000 bytes in 3.603206487s:4001 => 100000000 bytes in 36.332395213s
~100MB in36 seconds
See moretest/
- WebSockets support is required
- IaaS providers all will support WebSockets
- Unless an unsupporting HTTP proxy has been forced in front of you, in which case I'd argue that you've been downgraded to PaaS.
- PaaS providers vary in their support for WebSockets
- Heroku has full support
- Openshift has full support though connections are only accepted on ports 8443 and 8080
- Google App Engine hasno support (Track this ontheir repo)
- IaaS providers all will support WebSockets
- http://golang.org/doc/code.html
- http://golang.org/doc/effective_go.html
github.com/jpillora/chisel/share
contains the shared packagegithub.com/jpillora/chisel/server
contains the server packagegithub.com/jpillora/chisel/client
contains the client package
1.0.0
- Initial release1.1.0
- Swapped out simple symmetric encryption for ECDSA SSH1.2.0
- Added SOCKS5 (server) and HTTP CONNECT (client) support
- Allow clients to act as an indirect tunnel endpoint for other clients
- Better, faster tests
- Expose a stats page for proxy throughput
- Treat client stdin/stdout as a socket
Copyright © 2017 Jaime Pillora <dev@jpillora.com>
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the'Software'), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.