All Projects → LiamHaworth → Go Tproxy

LiamHaworth / Go Tproxy

Licence: mit
Linux Transparent Proxy library for Golang

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Tproxy

torbox
Container-based Tor access point (Anonymizing Middlebox).
Stars: ✭ 52 (-64.86%)
Mutual labels:  transparent-proxy
Citadelcore
Cross platform filtering HTTP/S proxy based on .NET Standard 2.0.
Stars: ✭ 28 (-81.08%)
Mutual labels:  transparent-proxy
Ss Tproxy
搭建 SS/SSR/V2Ray/Socks5 透明代理环境的简易脚本
Stars: ✭ 1,561 (+954.73%)
Mutual labels:  transparent-proxy
zorp
Zorp GPL
Stars: ✭ 102 (-31.08%)
Mutual labels:  transparent-proxy
Gsnova
Private proxy solution & network troubleshooting tool.
Stars: ✭ 509 (+243.92%)
Mutual labels:  transparent-proxy
Shadow
A transparent proxy for Windows, Linux, macOS
Stars: ✭ 85 (-42.57%)
Mutual labels:  transparent-proxy
hev-socks5-tproxy
A simple, lightweight socks5 transparent proxy for Linux. (IPv4/IPv6/TCP/UDP over TCP)
Stars: ✭ 209 (+41.22%)
Mutual labels:  transparent-proxy
Linux Router
Set Linux as router in one command. Support Internet sharing, redsocks, Wifi hotspot, IPv6. Can also be used for routing VM/containers
Stars: ✭ 129 (-12.84%)
Mutual labels:  transparent-proxy
Kalitorify
Transparent proxy through Tor for Kali Linux OS
Stars: ✭ 513 (+246.62%)
Mutual labels:  transparent-proxy
Archtorify
Transparent proxy through Tor for Arch Linux OS
Stars: ✭ 100 (-32.43%)
Mutual labels:  transparent-proxy
Trojan Go
Go实现的Trojan代理,支持多路复用/路由功能/CDN中转/Shadowsocks混淆插件,多平台,无依赖。A Trojan proxy written in Go. An unidentifiable mechanism that helps you bypass GFW. https://p4gefau1t.github.io/trojan-go/
Stars: ✭ 4,049 (+2635.81%)
Mutual labels:  transparent-proxy
Asuswrt Merlin Transparent Proxy
transparent proxy base on ss, v2ray, ipset, iptables, chinadns on asuswrt merlin.
Stars: ✭ 367 (+147.97%)
Mutual labels:  transparent-proxy
Vrouter
一个基于 VirtualBox 和 openwrt 构建的项目, 旨在实现 macOS / Windows 平台的透明代理.
Stars: ✭ 1,307 (+783.11%)
Mutual labels:  transparent-proxy
darknet.py
darknet.py is a network application with no dependencies other than Python and Tor, useful to anonymize the traffic of linux servers and workstations.
Stars: ✭ 71 (-52.03%)
Mutual labels:  transparent-proxy
Glider
glider is a forward proxy with multiple protocols support, and also a dns/dhcp server with ipset management features(like dnsmasq).
Stars: ✭ 1,710 (+1055.41%)
Mutual labels:  transparent-proxy
HttpFilteringEngine
Transparent filtering TLS proxy.
Stars: ✭ 48 (-67.57%)
Mutual labels:  transparent-proxy
Go Dispatch Proxy
SOCKS5/Transparent load balancing proxy developed in Go, combines multiple internet connections
Stars: ✭ 43 (-70.95%)
Mutual labels:  transparent-proxy
Sslproxy
Transparent SSL/TLS proxy for decrypting and diverting network traffic to other programs, such as UTM services, for deep SSL inspection
Stars: ✭ 134 (-9.46%)
Mutual labels:  transparent-proxy
Goproxy
🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
Stars: ✭ 11,334 (+7558.11%)
Mutual labels:  transparent-proxy
Sslsplit
Transparent SSL/TLS interception
Stars: ✭ 1,371 (+826.35%)
Mutual labels:  transparent-proxy

Golang TProxy GoDoc Go Report Card

Golang TProxy provides an easy to use wrapper for the Linux Transparent Proxy functionality.

Transparent Proxy (TProxy for short) provides the ability to transparently proxy traffic through a userland program without the need for conntrack overhead caused by using NAT to force the traffic into the proxy.

Another feature of TProxy is the ability to connect to remote hosts using the same client information as the original client making the connection. For example, if the connection 10.0.0.1:50073 -> 8.8.8.8:80 was intercepted, the service could make a connection to 8.8.8.8:80 pretending to come from 10.0.0.1:50073.

The linux kernel and IPTables handle diverting the packets back into the proxy for those remote connections by matching incoming packets to any locally bound sockets with the same details.

This is done in three steps. (Please note, this is from my understanding of how it works, which may be wrong in some places, so please correct me if I have described something wrong)

Step 1 - Binding a listener socket with the IP_TRANSPARENT socket option

Preparing a socket to receive connections with TProxy is really no different than what is normally done when setting up a socket to listen for connections. The only difference in the process is before the socket is bound, the IP_TRANSPARENT socket option.

syscall.SetsockoptInt(fileDescriptor, syscall.SOL_IP, syscall.IP_TRANSPARENT, 1)

Step 2 - Setting the IP_TRANSPARENT socket option on outbound connections

Same goes for making connections to a remote host pretending to be the client, the IP_TRANSPARENT socket option is set and the Linux kernel will allow the bind so along as a connection was intercepted with those details being used for the bind

Step 3 - Adding IPTables and routing rules to redirect traffic in both directions

Finally IPTables and routing rules need to be setup to tell Linux to redirect the desired traffic to the proxy application.

First make a new chain in the mangle table called DIVERT and add a rule to direct any TCP traffic with a matching local socket to the DIVERT chain

iptables -t mangle -N DIVERT
iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT

Then in the DIVERT chain add rules to add routing mark of 1 to packets in the DIVERT chain and accept the packets

iptables -t mangle -A DIVERT -j MARK --set-mark 1
iptables -t mangle -A DIVERT -j ACCEPT

And add routing rules to direct traffic with mark 1 to the local loopback device so the Linux kernal can pipe the traffic into the existing socket.

ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100

Finally add a IPTables rule to catch new traffic on any desired port and send it to the TProxy server

iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 8080

To test this out and see it work, try running the example in example/tproxy_example.go on a virtual machine and route some traffic through it.

Contributing

To contribute to this project, please follow this guide:

  1. Create an issue detailing your planned contribution
  2. Fork this repository and implement your contribution
  3. Create a pull request linking back to the issue
  4. Await approval and merging

TODOs

[x] Add support for proxying UDP connections

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].