Page cover

Backfire

Synopsis

Backfire is a medium linux machine created by hyperrealityarrow-up-right and chebuyaarrow-up-right. The machine is using the havoc c2 framework which is vulnerable to CVE-2024-41570 SSRF and Auth RCE, by combining both the exploit we get the shell as ilya. The another c2 framework hardhat is running in port 7096 which is vulnerable to authentication bypass. By exploiting the hardhat authentication bypass we can access the hardhat. The hardhat has a built in terminal which can be used to gain shell as sergej. The sergej user has a privilege to run the iptables and iptables-save with sudo privileges which can be used to further privilege escalate as a root.

OS
Difficulty
Points
Release Date
Retired Date

Linux

Medium

30

18-01-2025

07-06-2025


Enumeration

Nmap

Started the nmap scan and found the ssh, https and http services running.

nmap -Pn -sC -sV --min-rate=500 10.10.11.49                         
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-18 17:47 EST
Nmap scan report for 10.10.11.49
Host is up (0.55s latency).
Not shown: 984 closed tcp ports (conn-refused)
PORT      STATE    SERVICE           VERSION
22/tcp    open     ssh               OpenSSH 9.2p1 Debian 2+deb12u4 (protocol 2.0)
| ssh-hostkey: 
|   256 7d:6b:ba:b6:25:48:77:ac:3a:a2:ef:ae:f5:1d:98:c4 (ECDSA)
|_  256 be:f3:27:9e:c6:d6:29:27:7b:98:18:91:4e:97:25:99 (ED25519)
443/tcp   open     ssl/http          nginx 1.22.1
| tls-alpn: 
|   http/1.1
|   http/1.0
|_  http/0.9
|_http-server-header: nginx/1.22.1
| ssl-cert: Subject: commonName=127.0.0.1/organizationName=corp/stateOrProvinceName=Arizona/countryName=US
| Subject Alternative Name: IP Address:127.0.0.1
| Not valid before: 2024-12-30T19:01:22
|_Not valid after:  2027-12-30T19:01:22
|_http-title: 400 The plain HTTP request was sent to HTTPS port
|_ssl-date: TLS randomness does not represent time
465/tcp   filtered smtps
625/tcp   filtered apple-xsrvr-admin
1077/tcp  filtered imgames
1236/tcp  filtered bvcontrol
1580/tcp  filtered tn-tl-r1
2021/tcp  filtered servexec
3889/tcp  filtered dandv-tester
6346/tcp  filtered gnutella
8000/tcp  open     http              nginx 1.22.1
|_http-open-proxy: Proxy might be redirecting requests
| http-ls: Volume /
| SIZE  TIME               FILENAME
| 1559  17-Dec-2024 11:31  disable_tls.patch
| 875   17-Dec-2024 11:34  havoc.yaotl
|_
|_http-server-header: nginx/1.22.1
|_http-title: Index of /
8088/tcp  filtered radan-http
8873/tcp  filtered dxspider
12345/tcp filtered netbus
16113/tcp filtered unknown
50003/tcp filtered unknown
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 65.07 seconds

https - 443

The 404 not found page is shown, while visiting the website.

The whatweb shows the uncommon x-havoc header.

http - 8000

The disable_tls.patch and havoc.yaotl files are present while visiting the website.

File - disable_tls.patch

The file shows us that the havoc is running and the tls for websocket has been disabled.

Changes

  1. The tls is disabled by changing wss:// into ws:// on port 40056. So we

  2. The setSslConfiguration( SslConf ) function is removed for ignoring SSL errors.

  3. The certPath and keyPath args are removed while starting the Teamserver.

File - havoc.yaotl

The .yaotl file is a profiles used for havoc C2 which contains all the configuration for havoc.

Information

  1. Teamserver Configuration

    1. Host: 127.0.0.1

    2. Port: 40056.

  2. The compiler used for build are:

    1. Compiler64: data/x86_64-w64-mingw32-cross/bin/x86_64-w64-mingw32-gcc

    2. Compiler86: data/i686-w64-mingw32-cross/bin/i686-w64-mingw32-gcc

    3. Nasm: /usr/bin/nasm

  3. Operators Account

    1. ilya: CobaltStr1keSuckz!

    2. sergej: 1w4nt2sw1tch2h4rdh4tc2

  4. Demon Configuration

    1. The Sleep of 2 seconds is used and Jitter of 15 seconds.

    2. The notepad.exe is set as default process for both x64 and x86.

  5. Listeners Configuration

    1. Host: backfire.htb

    2. HostBind: 127.0.0.1

    3. Listens on port 8443 using HTTPS.


Vulnerabilities

CVE-2024-41570 - Havoc-C2-SSRF

The machine creator Chebuyaarrow-up-right has created the PoC blogarrow-up-right post and exploitarrow-up-right about the CVE-2024-41570.

The vulnerability allows us to spoof demon agent registrations and check-ins to open a TCP socket to the teamserver, enabling attackers to read and write data. The PoC registers a fake agent, open a socket, write data and read responses.

Executing the PoC

Create the python virtual environment and install the required libraries, then execute the PoC.

circle-info

The connection received on nc confirms the vulnerability and we can interact with havoc.

Information Security - Havoc Auth RCE

The Include Security Team has released proof-of-concepts (PoCs) for remote code execution (RCE) vulnerabilities targeting open-source C2 servers. The details are published in their blogarrow-up-right post. They have also created the github repository which contains the python script for exploitation. The github repository can be found herearrow-up-right. The PoC requires credentials which is obtained through havoc.yaotl.

The PoC doesn't work from our local machine. We have to interact with the havoc through agents. The CVE-2024-41570 vulnerability can be used to interact with the havoc teamserver.

Foothold

By combining both the SSRF and RCE vulnerability we can interact with havoc teamserver and execute the command in host system.

Shell - ilya [ SSRF + Auth RCE Exploit ]

1

Combining both exploit's script with some modification for executing the command.

2

Create the file with reverse shell payload

3

Open python server and nc listener

4

Execute the havoc_exp.py

circle-info

The shell is not persistent after some seconds it will terminate.

Getting persistent shell - ilya

We can get the persistent shell through ssh by creating ssh keypair and adding the our public key in ilya's ssh authorized_keys.

1

Create the ssh keypair

Copy the content of id_rsa.pub

2

Creating the payload and storing it in file

3

Get the shell using the above method. Copy and paste the content of payload.txt file

4

Now ssh using the private key

circle-info

The user.txt file contains the user flag 👏


Privilege Escalation

Pillaging - ilya [ user ]

Listing the files and directories reveals the hardhat.txt file which contains message from Sergej.

The netstat reveals the two ports 5000 and 7096.

Using curl in both the ports reveals that the 7096 is running hardhat and 5000 is running harhat teamserver with self-signed certificate.

Port 7096

Port: 5000

Port forward both the ports.

Shell - sergej [ Hardhat Authentication Bypass ]

HardHat C2 is a cross-platform, collaborative Command & Control (C2) framework developed in C#. It is designed primarily for red-team engagements and penetration testing, aiming to improve the quality of life factors during engagements by providing an easy-to-use but still robust C2 framework.

The JWT token can be created with Administrator and TeamLead role which is used to authenticate into HardHat C2 without valid passowrd. The PoCarrow-up-right is posted in Medium, showing the HardHat Authentication Bypass. The PoC contains the python script which we are going to use.

1

Execute the above python script

We can simply login now inputting username and password as sth_pentest with JWT token.

2

Login into HardHat as user sth_pentest

3

The HardHat has built-in terminal which we will use to gain shell

Previously the technique used to gain persistent shell of ilya, we will be using same here to gain the shell as sergej.

4

SSH as a sergej using ssh public key

Shell - root [ iptables-save ]

The user sergej has a sudo privilages to run iptables and iptables-save to privilege escalated and gain a shell as a root.

1

Generate the SSH Keypair

2

Adding SSH via Firewall Comments

3

Save the Firewall rules and ssh into root

circle-info

The root.txt file contains the root flag 🎉

Last updated