Startec

Startec

Tunnel via Cloudflare to any TCP Service

Mai 19, às 22:01

·

3 min de leitura

·

0 leituras

Cloudflare's cloudflared tunnels are commonly used to 'publish' a web server that runs behind a firewall (e.g. making the webserver accessible from the Internet). Cloudflare restricts the traffic to HTTP-style traffic: It won't allow the publishing o...
Tunnel via Cloudflare to any TCP Service

Cloudflare's cloudflared tunnels are commonly used to 'publish' a web server that runs behind a firewall (e.g. making the webserver accessible from the Internet). Cloudflare restricts the traffic to HTTP-style traffic: It won't allow the publishing of SSHD for example.

This article explains how to 'publish' any other service (like SSHD) and make it accessible via the cloudflared tunnel. It does so by adding a WebSocket Proxy on either side of the tunnel.

You need websocat, cloudflared and gost.

Example 1:

Configure a tunnel to access SSHD on a server that is behind the firewall (via Cloudflare's cloudflared tunnel).

On the server behind the firewall:

### Start a WS <-> TCP forwarder
websocat -E -b ws-l:127.0.0.1:40008 tcp:127.0.0.1:22 &
### Create a free CF Tunnel:
cloudflared tunnel --url http://localhost:40008 --no-autoupdate

The CF tunnel will show you an URL similar to this one:

On your workstation:

### Start a TCP <-> WS forwarder to above URL
websocat -E -b tcp-l:127.0.0.1:2222 ws://<YourUrlFromAbove>.trycloudflare.com &
### Connect using SSH:
ssh -p 2222 [email protected]

Example 2:

A more advanced method is to add a Socks5 Proxy to the chain of tunnels. This will allow us to access ANYTHING from our workstation: That's any host within the LAN and any host on the Internet.

The Gost tool supports WS and Socks5 and is used instead of websocat and microsocks.

On the server behind the firewall:

gost -L mws://:40009 &
cloudflared tunnel --url http://localhost:40009 --no-autoupdate

On your workstation:

gost -L :1080 -F 'mwss://<YourUrlFromAbove>.trycloudflare.com:443'

Use some tools via the Socks Tunnel (via Cloudflare/Websocket):

### Access ipinfo.io via this tunnel
curl -x socks5h://0 ipinfo.io
### Create a ProxyChains configuration
echo -e "[ProxyList]\nsocks5 127.0.0.1 1080" >pc.conf
### SSH to 192.168.1.1 via the tunnel
proxychains -f pc.conf -q ssh [email protected]
### Use NMAP via our tunnel
proxychains -f pc.conf -q nmap -nF -Pn -sT --open scanme.nmap.org

Notes:

  1. Cloudflare's Free Service limits the number of connections. Consider upgrading.

  2. We use mwss and mws to enable TCP multiplexing (channelling) via a single TCP connection in Gost. All TCP connections will go via a single CF tunnel (and a single Websocket-request).

  3. We use wss (with TLS) on the workstation but just ws (without TLS) on the server. This is because Cloudflare is the Edge-Server and the TLS connection stops there. Cloudflare then re-encrypts the data to send it via Cloudflared to our server. A Cloudflare tunnel is never (!) End-2-End encrypted: Use SSH or other encrypted tools if you do not trust CloudFlare (as they can read your data).

All examples from this article were tested on Segfault's Disposable Root Servers.

Thank you to EMX for proofreading.

Like to publish an article? Send us what you got. We will review and help you improve your article and then publish it here.

Join us on Telegram: https://t.me/thcorg


Continue lendo

DEV

Como por em prática suas habilidades com programação
Existem muitas maneiras de por em prática suas habilidades com programação, mas hoje trago aqui a plataforma codewars que oferece desafios de programação em diversas linguagens, tendo também acesso á uma...

Hoje, às 18:59

TabNews

Criando apps para Celulares que rodam Java ME em 2023 · Hawk2811
Criando apps para Celulares que rodam Java ME em 2023 criei este artigo contar minha experiencia de como foi criar apps para um Nokia C3-00 antigo que eu tenho aqui em casa eu achei bem i...

Hoje, às 18:55

AI | Techcrunch

Virgin Orbit’s launch business sold for parts to Vast, Stratolaunch, and Rocket Lab
Virgin Orbit, once valued at $3.7B, has been chopped up for parts. The company has concluded the auction for some of its assets, which were put up for sale as part of its Chapter 11 bankruptcy proceedings....

Hoje, às 18:50

DEV

What Is a Content Management System (CMS)?
CMS stands for Content Management System. It refers to a software application or a set of tools that allows users to create, manage, modify, and publish digital content on the internet. A CMS provides a...

Hoje, às 18:34

Tech Crunch

Episode Six raises $48M to streamline payment processes
Austin, Texas-based Episode Six, a payments and banking infrastructure provider, today announced that it raised $48 million in a Series C funding round led by Avenir with participation from Anthos Capital. In...

Hoje, às 18:25

Showmetech

Dell lança desktop gamer Alienware Aurora R15 no Brasil por R$ 9.999
Índice Alienware Aurora R15Especificações técnicas – Alienware Aurora R15Alienware M16Especificações técnicas – Dell Alienware M16 A Dell convidou jornalistas e influencers de tecnologia para comparecerem à...

Hoje, às 17:42

AI | Techcrunch

The other DWI: Driving while immersed
VR headsets have no place in moving automobiles Jeremy Bailenson is founding director of Stanford University’s Virtual Human Interaction Lab and author of “Experience on Demand: What...

Hoje, às 17:30

IT Forum

Neoleads anuncia Andrea Orsolon como líder para A. Latina - IT Forum
Andrea Orsolon foi anunciada nessa terça-feira (23) como nova líder para a América Latina da Neoleads, empresa especializada em geração de leads e marketing móvel no Brasil. A executiva tem como missão...

Hoje, às 17:23

DEV

Why Your Cloud Assets Need A Time Machine
Tracking the configuration of cloud resources is essential in the DevOps world. But what happens when you need to look back at past configurations? This is where resource history tracking comes in. By...

Hoje, às 17:21

Tech Crunch

Introducing the Disrupt Audience Choice breakout winners
We asked you, dear readers, to vote for the breakout sessions you want to see in September at TechCrunch Disrupt 2023, and your response was amazing! The 15 contenders did nothing to make your job easy, but...

Hoje, às 17:00