HackTheBox - Blackfield - Retired
Recon
I've been using threader3000 to do my initial scan lately. It's a threaded python scanner that scans all tcp ports and then suggests a nmap scan based on live ports.
Threader3000 also drops the output to xml which I then convert to HTML using xsltproc
So we have ports
53 DNS
88 Kerberos
135 RPC
389 LDAP
445
593 RPC
3268 LDAP
So just starting out here it looks like this is definitely a windows box, and possible a Domain Controller. The fact that LDAP, Kerberos and DNS are present is usually an indicator of a domain controller.
We also get a little more info from the nmap scan that doesn't show up in the xml HTML
Looks like the domain is blackfield.local and the name of this machine is DC01
Well there is no web server here. So what to look at first?
How about smb, let's see if there are any open smb shares with anonymous access
To list out shares will try using smbclient
The -L switch will list any shares we might beagle to connect to
We will get prompted for a password but will just hit enter to use no authentication.
We'll there are a lot of shares we might have access to so we will try to connect to them now to see if we can really get in them or if they need authentication.
We'll use smbclient again to connect
The syntax would be
Here are the results of me trying several shares.
Looks like we can anonymously connect to some but aren't allowed to get the files by using dir.
Let's try a little recon on the DNS service.
Like we saw earlier dc01.blackfield.local
Let's check if it's the global catalog
Yup it is.
I tried enum4linux here to see if we could anonymously get some info out of the domain controller and it didn't return any results.
I can connect using rpcclient
But get access denied when trying to manually enumerate
I eventually circled back around to smb. I found that when connected to profiles we could run dir
We get a metric crapton of usernames
I copied the usernames out to a file on my kali box called users.txt
Exploit
Now that we have this list we can see if any of them are open for ASREPROASTING
https://blog.stealthbits.com/cracking-active-directory-passwords-with-as-rep-roasting/
So by default when a user authenticates to a domain there is a step called preauthentication which they are challenged for their password. This is the default when setting up a new account in AD, its purpose is to protect against brute forcing a user's password. But you can opt out of preauthentication by checking one simple checkbox on the users account in AD.
To see if any of these users have preauthentication turned off we will use an impacket tool called GetNPUsers.py
The basic syntax is this
Python3 GetNPUsers.py domainame/ - usersfile *list of users* -format *how you want the output formatted you can choose hashcat or john* -outputfile *where you want the file written to.
So for our example here we know the domain is blackfield.local. So first lets add that to our /etc/hosts file
Then add 10.10.10.192 blackfield.local
And save the file
Now for our command it will end up looking like this.
Then we let the tool eat.
Here in the output you can see a lot of failures… Session errors.
It can be a little confusing the first time you run this tool because it doesn't just highlight that it worked on "x" account but if you check the output file. You can see we were able to get a ticket
.
So since we formatted this to hashcat, now we need to feed this to hashcat to get the password back.
So we need to figure out the mode to set haschcat to
If we do
Hashcat --help we can get a list of the modes
Looks like we need 18200 for an AS-REP
So our command will end up looking like this
We give it the mode -m 18200
The type of attack -a 0 ( straight attack)
The location of our saved hashes /home/circusmonkey404/Desktop/HTB/blackfield/hahses.asrepraost
The location of the wordlist to use
/usr/share/wordlists/rockyou.txt
-- force ( this is because my kali is VM and it yells about resources)
--outfile where we want it to output the cracked password to
/home/circusmonkey404/Desktop/HTB/blackfield/cracked.txt
Hashcat says it was able to get the password for us, so let's check our output file.
Looks like the password is #00^BlackKnight
Let's try to connect up to the smb with that password and see if it works
Let's see if we can get more access to any of these shares now that we are an authenticated user.
Cool lets try some of the shares now.
Looks like we can still get into profiles but not the admin shares and still can't DIR on any of them except profiles……
Well let's try enum4linux - sometimes admins are lazy and put the passwords for services accounts in the description field of AD. I know when I was starting out this was common at a place I worked.
No such luck here.
So now that we are authenticated we can dump out the entirety of the ldap to see if we can learn anything from it.
This dumps all of the ldap info and puts in a file called ldap.txt
We can now grep against that to look for info, I like to see who is in the IT department
This will grep for IT and select the previous 7 lines before IT and the 15 lines after stick it in a file name ITDept.txt
So some of the interesting things we can look at here is the last logon and logoff
For example here the administrator account is the only one who has IT set as their department who has ever logged into the domain.
Using a similar search I grep'd for LogonCount: and looked for accounts that had actually be logged into
These were the only accounts that have ever actually been logged into, this might not be helpful in a real pentest but here on hackthebox, we can assume these means that these accounts are going to be important
Especially
Administrator
Svc_backup
I grepped for svc_backup
And found they are members of Backup Operators and Remote Management Users
Googling around for escalation techniques using RPC client. I found this https://malicious.link/post/2017/reset-ad-user-password-with-linux/
If the user is privileged to reset passwords in a domain then they can do this via rpclient also.
The account we have access to know is called support. I would assume a big part of the support role in an IT department is resetting users passwords.
I find some users to test on. I find it interesting the UPN's for the users in this ad environment are almost exclusively
BLACKFIELD**RADNOMNUMBERS*****@BLACKFIELD.local
I picked on a person in the IT department to try first, since they are usually more privileged than other users.
When I tired
I got an access denied, I got this for all the the AD users I tried with UPNs of Blackfield*somenumber*@blackfield.local
I double checked the password requirements incase this password didn't meet requirements
Minimum length 7 and complexity is on.. My test password should work. Maybe this support just has access to reset passwords on specific accounts or OUs…. what about the users that have different UPNS
I used grep to filter out all account that that started with blackfield
I'm sure there is a more elegant way to do this but it worked. :)
I broke this list down further to be real user accounts and not builtin AD accounts and got these out. I did this just using my knowledge of Active Directory and what the builtin account names are.
This is the result of pruning some more.
We already have the password for support.
So that really leaves
Let's start with the first one, There was a smb share called forensics I imagine they would have access to.
Let's see if we can reset audit2020's password.
No error, let's try to connect up to that smb again as this user.
We were able to connect up to forensic share.
Let's poke around.
Well we found some outputs of commands from what looks like a pentest done against the company in the commands_output folder.
But under the memory_analysis folder we find what looks like a dump of the lsass process. Named lsass.zip.
I tried transferring this via smbclient but it would eventually timeout
So I mounted it in kali directly to xfer it to my box.
If you are unfamiliar with lsass…… well you should get to know it.
From Wikipedia
"Local Security Authority Subsystem Service is a process in Microsoft Windows operating systems that is responsible for enforcing the security policy on the system. It verifies users logging on to a Windows computer or server, handles password changes, and creates access tokens"
But for our purpose here it basically holds the plaintext passwords for the machine. We just need to dump the process using a program like procdump. Then we can load it up in mimikatz to get our plaintext passwords out.
Here is a blog post showing the steps needed to get to these passwords.
Well I've run mimkatz plenty of times on windows machines… but never on kali.
I found pypykatz is a sort of port of mimikatz. So Let's try it out.
I found this blog which gave me the syntax
https://en.hackndo.com/remote-lsass-dump-passwords/
Ok let's see what we get…
We see that svc_backup account
We can see hashes but not the actual password…
Same thing for the Administrator account.
So we got a hash but now password. I think this is ok. We can try to just pass the hash to get in.
Since WinRM is available to use, we can try to pass the hash with it.
Of course I tried the Administrator account first, but no dice. Maybe they changed the Administrator password since that lsass dump was made
But we had better luck with svc_backup
And from here we can get to the user.txt in C:\Users\svc_backup\Desktop
Now we need to figure out a path to root.
https://roberthosborne.com/privesc
I found this blog that talks about using our backup privileges to export out a copy of ntds.dit
The basic Idea is since the svc_backup is part of backup operators and has the SeBackupPrivliege. We can leverage this to make a backup of the ntds.dit file for the domain, if we can get that and also dump out some of the registry we can get some other hashes or passwords to use to get into the administrator account.
SO we need to start by making a shadow copy of the C: drive using diskshadow so we can have access to the normally protected ntds.dit file.
So it took me a while to get this going and I just want to point this out, for some reason diskshadow needs another character at the end of each of these commands in order for them to properly execute. Also I couldn't get powershell to enter diskshadow so I setup another reverse shell for cmd.exe which could enter diskshadow correctly.
So to get to cmd.exe
I started a nc listener on my kali box
Then from blackfield I used the same NC64.exe I used earlier to get my shell
Now we just enter our diskshadow commands with a ; at the end for some reason :)
Now we need to import a couple of powershell modules to access the exposed shadow copy which is now Z:
https://github.com/giuliano108/SeBackupPrivilege/tree/master/SeBackupPrivilegeCmdLets/bin/Debug
We can use the built in upload feature of winrm to do this for us. Since I have the two dlls in the same folder I launched winRM from I just do
Now we need to import those modules into powershell with our evil-winRM connection.
Now we will check to see if they imported correctly
Now we just need to copy out the ntds.dit file from our backup exposed.
Now we need the system registry hive
Now we can use impacket's secret dump to get the hashes out of these files
Now lets try and pass this hash in evil-winrm
Well that is not what I wanted to see.
Access denied reading root.txt
But there is this note.
In the Documents folder there is this PS1 script called watcher.ps1
So We can guess this is running on a schedule to re-encrypt this file every 30 seconds.
But since we know the way they are encrypting we can just reverse this to decrypt the file
Comments
Post a Comment