Fusion Corp (Get-NPUsers + rcpclient + SeBackupPrivilege privesc)

Difficulty: Hard

Overview: In this room we will take advantage of different services on a windows machine, abusing Kerberos pre-authentication to enumerate users, dumping and cracking hashes with the help of impacket tools and John the ripper to finaly privesc exploiting SeBackupPrivilege permissions.


Like always we start our enumeration by running โ€œnmapโ€ to scan for all open ports on the target system:

nmap -sV -sC -p- fusioncorp.thm -oN nmap.txt

-sV    โ†’  Probe open ports to determine service
-sC    โ†’  Scan using the default set of scripts
-p-    โ†’  Scan all ports
-oN   โ†’  Save the ouput of the scan in a file

image

Normally Active Directory windows machines have alot of open ports, which at times can be scary. But , following the basics.

We will explorer the http webserver:

image

Since there was not any usefull information on the website we can search for hidden directories with โ€œgobusterโ€:

gobuster dir --wordlist /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt --url http://fusioncorp.thm -x .txt,.cgi,.php,.log,.bak,.xxx,.old

dir             โ†’ Uses directory/file enumeration mode
--wordlist  โ†’ Path to wordlist 
--url           โ†’ specifies the path of the target url we want to find any hidden directories
-x              โ†’ Search for all files with the specified extentions 

image

We have found an interesting file in the directory /backup which had a list of of employees and their usernames:

image

Content of "employees.ods":

image

With this information we can create a username wordlist and use โ€œkerbrute" which is a enumeration tool used to brute-force and enumerate valid users by abusing the Kerberos pre-authentication.

image

image

There is a valid username [email protected]. Now we will use an "impacket" tool called "GetNPUsers.py" to dump the kerberos hash for all kerberoastable accounts. In this case for the account [email protected].

image

We got the hash, since it is encrypted we need to crack it with โ€œJohn the Ripperโ€, โ€œhashcatโ€ or another tool of your choice.

image

Success we have โ€œlparkerโ€ credentials, connect with โ€œevil-winrmโ€ and we can start doing some reconnaissance of the machine:

image

We found โ€œjmurphy" and โ€œAdministrator" accounts. Also the first flag of the room.

image

Now we are going to query the user jmurphy with โ€œrpcclientโ€ service:

image

image

In the description in plaintext we found the password for โ€œjmurphyโ€.

Lets login again with โ€œevil-winrmโ€ but this time with the new user credentials:

image

Found Second flag:

image

Now to privesc in order to get the last flag we can check /privs for our user:

image

We have some privileges that we can exploit and one of them is โ€œSeBackupPrivilegeโ€.

Has we can see the contents of user โ€œAdministratorโ€ can be displayed but we cannot read or execute files like the last "flag.txt" file.

image

This usefull github repository from "giuliano108" shows us how to take advantage of the SeBackupPrivilege. It allows the user to access directories/files that he doesn't own or doesn't have permission to.

So with โ€œevil-winrmโ€ we can upload the two โ€œ.dllโ€ files that we got from the github repository to the target machine:

image

Like in "meterpreter" shell we can do commands โ€œdownload or uploadโ€ to transfer files between the target and the attacker machine.

image

Now after importing the two modules we have to user command โ€œCopy-FileSeBackupPrivilegeโ€, this command will make a copy of the โ€œflag.txtโ€ file to our directory abusing โ€œSeBackupPrivilegeโ€:

image

Now read the last flag!!

image

We have all the flags but let's explore and see if we can escalate our privileges further.

My first attempt to privesc to user โ€œAdministratorโ€ failed, because i got an invalid โ€œadministratorโ€ hash. Let me show:

With user โ€œjmurphyโ€ we can save โ€œsamโ€ and โ€œsystemโ€ files into a directory that we can access by doing:

image

Now just download the files to your attacker machine:

image

With the tool "pypykatz" we can extract the hashes from the "sam" file:

image

As we can see below we failed login with โ€œAdministratorโ€ hash for whatever reason. Maybe because the โ€œsamโ€ file was from the windows machine itself and not the Domain Controller.

image

After reading more on how to privesc this machine through "SeBackupPrivilege" i found a very usefull article in hackingarticles website.

To get all the hashes of the Domain Controller we need โ€œntds.ditโ€ and โ€œsystemโ€ files from the target machine.

For getting the โ€œntds.ditโ€ file we need to use "shadowdisk" functionalities because โ€œntds.ditโ€ file is always running on the system and doesn't let us make a copy of it.

So we can create a custom โ€œDistributed Shell File" with the commands necessary to make a copy of the Windows drive which then we can extract the โ€œntds.ditโ€ file:

image

Use โ€œunix2dosโ€ to convert the encoding and spacing of the dsh to be windows compatible.

image

Running โ€œevil-winrmโ€ with โ€œjmurphyโ€ user i created a /temp folder in his home directory and uploaded the โ€œhashdump.dshโ€:

image

To ran the commands inside โ€œhashdump.dshโ€ we will "diskshadow":

image

Now to make the actual copy of the โ€œntds.ditโ€ we have to use "robocopy" on the new driver letter that we created just now:

image

To get the โ€œsystemโ€ file is easier we just need to use:

image

We have all the files that we need to get hashes, we just need to download them to our attacker machine:

image

image

image

On our attacker machine we can use โ€œimpacket secretsdumpโ€ tool to extract all the hashes inside "ntds.dit":

image

We have a valid โ€œAdministratorโ€ hash to use with โ€œevil-winrmโ€:

image

Success!

Last updated