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

imagearrow-up-right

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:

imagearrow-up-right

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 

imagearrow-up-right

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

imagearrow-up-right

Content of "employees.ods":

imagearrow-up-right

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.

imagearrow-up-right

imagearrow-up-right

There is a valid username [email protected]envelope. 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]envelope.

imagearrow-up-right

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

imagearrow-up-right

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

imagearrow-up-right

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

imagearrow-up-right

Now we are going to query the user jmurphy with β€œrpcclient” service:

imagearrow-up-right

imagearrow-up-right

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:

imagearrow-up-right

Found Second flag:

imagearrow-up-right

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

imagearrow-up-right

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.

imagearrow-up-right

This usefull githubarrow-up-right 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:

imagearrow-up-right

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

imagearrow-up-right

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”:

imagearrow-up-right

Now read the last flag!!

imagearrow-up-right

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:

imagearrow-up-right

Now just download the files to your attacker machine:

imagearrow-up-right

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

imagearrow-up-right

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.

imagearrow-up-right

After reading more on how to privesc this machine through "SeBackupPrivilege" i found a very usefull article in hackingarticlesarrow-up-right 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:

imagearrow-up-right

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

imagearrow-up-right

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

imagearrow-up-right

To ran the commands inside β€œhashdump.dsh” we will "diskshadow":

imagearrow-up-right

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:

imagearrow-up-right

To get the β€œsystem” file is easier we just need to use:

imagearrow-up-right

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

imagearrow-up-right

imagearrow-up-right

imagearrow-up-right

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

imagearrow-up-right

We have a valid β€œAdministrator” hash to use with β€œevil-winrm”:

imagearrow-up-right

Success!

Last updated