All Projects → codepr → aiotunnel

codepr / aiotunnel

Licence: BSD-3-Clause license
HTTP tunnel on top of aiohttp and asyncio

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to aiotunnel

Mole
CLI application to create ssh tunnels focused on resiliency and user experience.
Stars: ✭ 1,520 (+5141.38%)
Mutual labels:  tunnel, port-forwarding, port-forward
Nps
一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
Stars: ✭ 19,537 (+67268.97%)
Mutual labels:  tunnel, https
client
Remote access and tunnels to your localhost from everywhere in the world.
Stars: ✭ 25 (-13.79%)
Mutual labels:  tunnel, https
Python Proxy
HTTP/HTTP2/HTTP3/Socks4/Socks5/Shadowsocks/ShadowsocksR/SSH/Redirect/Pf TCP/UDP asynchronous tunnel proxy implemented in Python 3 asyncio.
Stars: ✭ 692 (+2286.21%)
Mutual labels:  tunnel, asyncio
Halive
A fast http and https prober, to check which URLs are alive
Stars: ✭ 47 (+62.07%)
Mutual labels:  https, asyncio
Python Mocket
a socket mock framework - for all kinds of socket animals, web-clients included
Stars: ✭ 209 (+620.69%)
Mutual labels:  https, asyncio
LightTunnel
LightTunnel-内网穿透映射工具,支持TCP、HTTP、HTTPS穿透映射,支持Windows、Linux、Mac、Android系统
Stars: ✭ 40 (+37.93%)
Mutual labels:  tunnel, https
nat-tunnel
NAT Tunnel: to effortlessly serve from behind NAT
Stars: ✭ 75 (+158.62%)
Mutual labels:  tunnel, port-forwarding
Frpc Android
Android,安卓版frpc,一个快速反向代理,可帮助您将NAT或防火墙后面的本地服务器暴露给Internet。
Stars: ✭ 205 (+606.9%)
Mutual labels:  tunnel, https
Fq Book
📖《这本书能让你连接互联网》详细阐述代理、隧道、VPN运作过程,并对GFW策略如:地址端口封锁、服务器缓存投毒、数字验证攻击、SSL连接阻断做相关的原理说明
Stars: ✭ 2,393 (+8151.72%)
Mutual labels:  tunnel, https
hypercorn-fastapi-docker
Docker image with Hypercorn for FastAPI apps in Python 3.7, 3.8, 3.9. Ready for HTTP2 and HTTPS
Stars: ✭ 18 (-37.93%)
Mutual labels:  https, asyncio
webhook-tunnel
A little HTTP proxy suitable to create tunnels for webhook endpoints protected behind a firewall or a VPN
Stars: ✭ 63 (+117.24%)
Mutual labels:  tunnel, https
Kubefwd
Bulk port forwarding Kubernetes services for local development.
Stars: ✭ 2,713 (+9255.17%)
Mutual labels:  port-forwarding, port-forward
gost
GO Simple Tunnel - a simple tunnel written in golang
Stars: ✭ 154 (+431.03%)
Mutual labels:  tunnel, https
rconn
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.
Stars: ✭ 231 (+696.55%)
Mutual labels:  port-forwarding, port-forward
Sish
HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.
Stars: ✭ 2,087 (+7096.55%)
Mutual labels:  tunnel, https
gohide
tunnel port to port traffic over an obfuscated channel with AES-GCM encryption.
Stars: ✭ 62 (+113.79%)
Mutual labels:  tunnel, port-forwarding
tunman
Comprehensive solution for SSH tunnels - respawning, healthchecking/monitoring
Stars: ✭ 43 (+48.28%)
Mutual labels:  tunnel, port-forwarding
httpit
A rapid http(s) benchmark tool written in Go
Stars: ✭ 156 (+437.93%)
Mutual labels:  https
glacier
❄️ Building Python CLI using docstrings and typehints 🐍
Stars: ✭ 84 (+189.66%)
Mutual labels:  asyncio

Aiotunnel

Python 3.7

Yet another HTTP tunnel, supports two modes; a direct one which open a local port on the host machine and redirect all TCP data to the remote side of the tunnel, which actually connect to the desired URL. A second one which require the client part to run on the target system we want to expose, the server side on a (arguably) public machine (e.g. an AWS EC2) which expose a port to communicate to our target system through HTTP.

Quickstart

Let's suppose we have a machine located at 10.5.0.240 that we want to expose SSH access and a server on which we have free access located at 10.5.0.10; we really don't know if port 22 on 10.5.0.240 is already exposed or if the IP address will change, we actually don't care because once set the server address, it will retrieve all incoming commands via HTTP GET requests to our known server.

    10.0.50.15 <----> (TCP) 8888:10.5.0.10:8080 (HTTP) <----> 10.5.0.240:22

So just run the tunneld on the server at 10.5.0.10 (you probably want to daemonize it through NOHUP or by creating a systemd service) in reverse mode:

[email protected]:~$ aiotunnel server -r
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)

On the target machine at 10.5.0.240 run the client bound to the service we want to expose (SSH in this case but could be anything):

[email protected]:~$ aiotunnel client --server-addr 10.5.0.10 --server-port 8080 -A localhost -P 22 -r
[2018-10-14 22:20:45,806] Opening a connection with 127.0.0.1:22 and 0.0.0.0:8888 over HTTP
[2018-10-14 22:20:45,831] 0.0.0.0:8888 over HTTP to http://10.5.0.10:8080/aiotunnel
[2018-10-14 22:20:45,832] Obtained a client id: aeb7cfc6-3de3-4bc1-b769-b81641d496eb

Now we're ready to open an SSH session to 10.5.0.10 even in the case of a closed 22 port or a different IP address.

[email protected]:~$ ssh [email protected] -p 8888

Welcome to Linux 4.19.0-1-MANJARO
Last login: Thu Feb 11 17:28:20 2016
[email protected]:~$

A more common approach is to use the tunnel without -r/--reverse flag. In this case we actually have the port 22 exposed on the target system, but our network do not permit traffic over SSH. In this case we use a known server as a proxy to demand the actual SSH connection to him, while we communicate with him by using HTTP requests:

  • POST to establish the connection
  • PUT to send data
  • GET to read responses
  • DELETE to close the connection

So on our known server located at 10.5.0.10 we start a tunneld process

[email protected]:~$ aiotunnel server
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)

On the network-constrainted machine we start a tunnel instance

[email protected]:~$ aiotunnel -A 10.0.5.240 -P 22
[2018-10-15 00:58:41,744] Opening local port 8888 and 10.0.5.240:22 over HTTP

And we're good to go.

It's possible to use the Dockerfile to build an image and run it in a container, default start with a command aiotunnel server -r, easily overridable.

[email protected]:~$ docker build -t aiotunnel /path/to/aiotunnel
[email protected]:~$ docker run --rm --network host aiotunnel aiotunnel client --server-addr 10.5.0.10 --server-port 8080 -A localhost -p 22 -r

Security

SSL/TLS is supported, just set certificates cain and ca in the configuration or by the CLI process to encrypt the communication and use HTTPS (defaulting on port 8443 instead of 8080)

[email protected]:~$ aiotunnel server -r --ca /path/to/ca.crt --cert /path/to/cert.crt --key
/path/to/keyfile.key
======== Running on https://0.0.0.0:8443 ========

And client side

[email protected]:~$ aiotunnel client -A 127.0.0.1 -P 22 --ca /path/to/ca.crt --cert
/path/to/cert.crt --key /path/to/keyfile.key
[2018-10-18 22:20:45,806] Opening a connection with 127.0.0.1:22 and 0.0.0.0:8888 over HTTPS
[2018-10-18 22:20:45,831] 0.0.0.0:8888 over HTTPS to https://10.5.0.10:8443/aiotunnel
[2018-10-18 22:20:45,832] Obtained a client id: aeb7dfc4-3da3-4wc1-b769-n81621db96eb

Installation

Clone the repository and install it locally or play with it using python -i or ipython.

$ git clone https://github.com/codepr/aiotunnel.git
$ cd aiotunnel
$ pip install .

or, to skip cloning part

$ pip install git+https://github.com/codepr/aiotunnel.git@master#egg=aiotunnel

Changelog

See the CHANGES file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].