The internet here is very restricted and I want to...
Created on: June 23, 2025
Created on: June 23, 2025
The internet here is very restricted and I want to make something like a VPN. I want to use Telegram proxies to access blocked site. Telegram has some proxies that actually work very well, but it’s only used for Telegram itself. I want to know if it’s possible to make a python script that tunnel everything through Telegram and from there, I can use telegram proxies to use as a VPN for my entire computer.
SOCKS5
, you can use it system-wide – the proxy is just an ordinary SOCKS5 server and any program (or a TUN-to-SOCKS bridge) can talk to it.MTProto
proxy, you cannot use it like a VPN. MTProto proxies only understand Telegram’s own MTProto transport and will forward traffic only to Telegram’s data-centres. They drop any other packets, so the rest of the Internet never sees them. core.telegram.orgBelow are the practical options and a minimal Python example.
Works only with proxies that Telegram labels “SOCKS5”.
What you need | Quick how-to |
---|---|
A SOCKS5 proxy endpoint (host:port & optional user/pass). Public lists such as the GitHub repo hookzof/socks5_list often include many endpoints that Telegram clients use. | Pick one that is actually reachable from your network. |
A way to push all OS traffic into SOCKS5 | Linux / macOS: tun2socks (from go-tun2socks or clash ) + a dummy TUN interface.<br>Windows: tools like ProxyCap, Proxifier or WinTun2Socks. |
DNS leaks | Set system DNS to something that also goes through the proxy (e.g. dnscrypt-proxy in “DNS-over-HTTPS via SOCKS5” mode). |
python#!/usr/bin/env python3 """ Very small TCP forwarder that listens on 127.0.0.1:1081 and forwards every connection through a chosen Telegram SOCKS5 proxy. Point proxy-aware programs (or tun2socks) at 127.0.0.1:1081. """ import socket, threading, select, socks, sys LOCAL = ('127.0.0.1', 1081) TG_PROXY = ('203.0.113.77', 1080) # <- put your SOCKS5 host,port here def pump(src, dst): while True: data = src.recv(4096) if not data: break dst.sendall(data) def handle(client): remote = socks.socksocket() remote.set_proxy(socks.SOCKS5, *TG_PROXY) try: # first byte read from client tells us the target addr family etc. # we clone that connect via SOCKS5 BIND – omitted for brevity ↓ # see pySocks documentation for full implementation pass finally: client.close() remote.close() lsock = socket.socket() lsock.bind(LOCAL) lsock.listen(128) print(f'Local SOCKS bridge on {LOCAL}') while True: c, _ = lsock.accept() threading.Thread(target=handle, args=(c,), daemon=True).start()
This is only a skeleton (real code must parse the SOCKS handshake coming from the client), but it shows the idea: your programs speak to a local port; the script relays everything to the upstream Telegram SOCKS5. Combine it with tun2socks
to capture the whole system’s traffic.
✅ Pros | ❌ Cons |
---|---|
No server of your own required. | SOCKS5 lists fluctuate; many hosts die quickly. |
Easy to automate with Python or existing tools. | No additional encryption – the proxy sees plain TLS/HTTP headers. |
Works on any OS once the proxy address is set. | Quality and speed are usually worse than paid VPNs. |
Telegram’s MTProto proxy is not a generic forwarder: it speaks the MTProto handshake, then tunnels encrypted Telegram messages to Telegram IPs only. The proxy never sees or forwards arbitrary TCP/UDP packets, so browsers, Steam, etc. just fail. core.telegram.org core.telegram.org
To bend MTProto to your will you’d need:
iptables + NFQUEUE
, others patch mtproxy
directly).The architecture above (WireGuard hidden behind MTProto) is described in community write-ups such as “Build your own VPN node with Traefik v2, MTProto proxy, WireGuard…” freefd.github.io. It does work, but it is a weekend-to-week-long DIY project, not a 20-line Python script, and public MTProto proxies cannot be used for step 2 because you must control the other end.
Goal | Easiest route |
---|---|
Quick access to blocked websites | Try Telegram SOCKS5 proxies + tun2socks , or simply use Outline / V2Ray if you can rent a cheap VPS. |
Stealth (“look like Telegram”) | Rent a VPS and follow the MTProto + WireGuard approach; reuse existing open-source scripts instead of starting from scratch. |
No server budget | Public SOCKS5 lists are the only Telegram-based option, but expect instability. |
Remember legality & ethics
Bypassing censorship can be illegal where you live; proxies and VPNs do not magically hide all fingerprints (DNS leaks, traffic patterns). Use trusted endpoints, add TLS/HTTPS where possible, and keep in mind that the proxy operator sees your IP and timing information even if they cannot read the encrypted payload.