Local Windows Password Attacks

SAM database

circle-exclamation
circle-info

TL;DR

The idea is making a copy of three registry hives. Then transfer those copies to our attacking machine, dump the creds and then crack the NT hash.

Here are our target registry hives:

  • hklm\sam : Contains the hashes associated with local account passwords. We will need the hashes so we can crack them and get the user account passwords in cleartext.

  • hklm\system : Contains the system bootkey, which is used to encrypt the SAM database. We will need the bootkey to decrypt the SAM database.

  • hklm\security : Contains cached credentials for domain accounts. We may benefit from having this on a domain-joined Windows target.

Create backup of the hives (cmd launched as admin):

circle-info

Technically we will only need hklm\sam & hklm\system, but hklm\security can also be helpful to save as it can contain hashes associated with cached domain user account credentials present on domain-joined hosts.

C:\WINDOWS\system32 > reg.exe save hklm\sam C:\sam.save

The operation completed successfully.

C:\WINDOWS\system32 > reg.exe save hklm\system C:\system.save

The operation completed successfully.

C:\WINDOWS\system32 > reg.exe save hklm\security C:\security.save

The operation completed successfully.

Transfer the backup files to our attacking machine

Creating an SMB share (smbserver.py)

Moving the copies:

Dumping the hashes from hives (secretsdump.py)

Cracking the dumped hashes

circle-check

Remote Dumping and LSA secrets

triangle-exclamation

LSASS service

LSASS is a critical service that plays a central role in credential management and the authentication processes in all Windows operating systems.

Upon initial logon, LSASS will:

Dumping LSASS Process Memory

circle-info

TL;DR

We will dump LSASS process memory, as the name describes it, with two methods, one that replies on GUI interface and the other doesnt. Then upon transferring it to out attacking host, we will proceed to dump the creds from that file and crack the NT hash.

Task Manager Method

This will create a file at :

And then we can transfer it with whatever method we choose.

Rundll32.exe & Comsvcsdll Method

Before issuing the command to create the dump file, we must determine what process ID (PID) is assigned to lsass.exe.

This file will then be transferred to our machine and we then proceed to dump creds and crack them. For that we will use Pypykatz, a python-version of Mimikatz which runs only on Windows.

Dumping the creds

Some interesting parts in the findings are:

  • MSV : MSVarrow-up-right is an authentication package in Windows that LSA calls on to validate logon attempts against the SAM database. Pypykatz extracted the SID, Username, Domain, and even the NT & SHA1 password hashes associated with the bob user account's logon session stored in LSASS process memory. This will prove helpful in the final stage of our attack covered at the end of this section.

  • WDIGEST is an older authentication protocol enabled by default in Windows XP - Windows 8 and Windows Server 2003 - Windows Server 2012. LSASS caches credentials used by WDIGEST in clear-text. This means if we find ourselves targeting a Windows system with WDIGEST enabled, we will most likely see a password in clear-text. Modern Windows operating systems have WDIGEST disabled by default. Additionally, it is essential to note that Microsoft released a security update for systems affected by this issue with WDIGEST. We can study the details of that security update herearrow-up-right.

  • Kerberos : Kerberosarrow-up-right is a network authentication protocol used by Active Directory in Windows Domain environments. Domain user accounts are granted tickets upon authentication with Active Directory. This ticket is used to allow the user to access shared resources on the network that they have been granted access to without needing to type their credentials each time. LSASS caches passwords, ekeys, tickets, and pins associated with Kerberos. It is possible to extract these from LSASS process memory and use them to access other systems joined to the same domain.

  • DPAPI : The Data Protection Application Programming Interface or DPAPIarrow-up-right is a set of APIs in Windows operating systems used to encrypt and decrypt DPAPI data blobs on a per-user basis for Windows OS features and various third-party applications. Mimikatz and Pypykatz can extract the DPAPI masterkey for the logged-on user whose data is present in LSASS process memory. This masterkey can then be used to decrypt the secrets associated with each of the applications using DPAPI and result in the capturing of credentials for various accounts.


AD & NTDS.dit dictionary

circle-exclamation
circle-info

After gaining some valid creds, whether from some google dorks, OSINT, social engineering or custom wordlists (with username-anarchy for example), we can then try to bruteforce our way in with crackmapexec with smb using :

Connecting to the target

circle-info

To make a copy of the NTDS.dit file, we need local admin (Administrators group) or Domain Admin (Domain Admins group) (or equivalent) rights. We also will want to check what domain privileges we have.

Shadow Copy of C

We can use vssadmin to create a Volume Shadow Copyarrow-up-right (VSS) of the C: drive or whatever volume the admin chose when initially installing AD. It is very likely that NTDS will be stored on C: as that is the default location selected at install, but it is possible to change the location. We use VSS for this because it is designed to make copies of volumes that may be read & written to actively without needing to bring a particular application or system down. VSS is used by many different backup & disaster recovery software to perform operations.

circle-exclamation

Moving the copy

Look in here for the first method.

Using crackmapexec

Another faster method is using cme, which does all of the above with just one command.

Cracking the hash

circle-info

Of course the cracking may be unsuccessful, one consideration is using Pass-the-Hash method which takes advantage of the NTLM authentication protocolarrow-up-right.

Instead of username:clear-text password as the format for login, we can instead use username:password hash.

This could be done using :

Creds Hunting In Windows

circle-info

Coming 😄

Last updated