Password Attacks
Introduction
Passwords are still the most common way people prove who they are online. Simply put, a password or passphrase is a mix of letters, numbers, and symbols that confirms your identity. Every app or system that uses authentication checks your credentials against a database, either on your device or somewhere remote.
Systems store these credentials in databases:
Linux: Encrypted passwords reside in the
/etc/shadow
file.Windows: A more complex process involves multiple components, with encrypted passwords stored in the SAM file at
%SystemRoot%\system32\config\SAM
.
Attacking Methods
There are a few main ways attackers try to crack passwords:
Dictionary Attacks: This method uses a pre-made list of words and phrases, called a dictionary, to guess passwords.
Brute Force Attacks: Here, attackers try every possible combination of characters until they find the right one.
Rainbow Table Attacks: These use pre-calculated tables of password hashes and their matching plaintext versions to speed up cracking.
People often pick simple passwords they can remember, so companies set rules to make passwords stronger. But humans are clever at bending these rules. If a special character is needed, they might just tack one on at the end. If an uppercase letter is required, they’ll capitalize the first one.
Attackers can use personal info, like a pet’s name or birthday, to make brute-forcing smarter. Tools like Hashcat help with this, while CeWL can scan a company’s website for words that might be passwords. People also tend to keep default passwords or reuse them across services. That’s where password spraying shines, once you get valid credentials, you try them everywhere.
Remote Password Attacks
In a network, many protocols, like WinRM, SMB, SSH, and RDP, require login details. Most of these rely on passwords and can often be brute-forced. Tools such as Hydra, CrackMapExec, and Metasploit make these attacks possible.
Windows Local Password Attacks
The Security Account Manager (SAM) is a database in Windows that holds credentials. If you’re on a Windows machine and have local admin access, you can copy the SAM database to your own system and crack its hashes offline. There are three key registry hives to grab:
HKLM\SAM: Stores hashes for local account passwords.
HKLM\SYSTEM: Holds the system bootkey, which encrypts the SAM database. You’ll need this to unlock it.
HKLM\SECURITY: Contains cached credentials for domain accounts.
You can back up these hives with the
reg.exe
utility. Once you’ve got them, tools likesecretdumps
can pull out the hashes, and Hashcat can crack them. For domain passwords, CrackMapExec can help extract and crack LSA secrets.
Then there’s LSASS, a vital Windows service that manages credentials and authentication. When you log in, LSASS does things like:
Storing credentials in memory.
Creating access tokens.
Enforcing security rules.
Logging events to the Windows security log.
To attack LSASS, you can dump its memory and extract credentials offline. One way is through Task Manager:
Open Task Manager.
Go to the Processes tab.
Find and right-click “Local Security Authority Process.”
Choose “Create dump file.”
This creates an
lsass.DMP
file inC:\Users\<Your-Username>\AppData\Local\Temp
. Or, from the command line, find the LSASS process ID (PID) withtasklist /svc
in cmd orGet-Process lsass
in PowerShell. Then, in an elevated PowerShell session, run:
Note that modern antivirus might block this as suspicious. Bypassing it is a whole other topic! Once you’ve got the dump file, use
pypykatz
to pull credentials:
Then crack the NT hash with Hashcat:
Linux Local Password Attacks
In Linux, the
/etc/passwd
file lists all users and is readable by everyone. Its password field usually shows an "x", meaning passwords are in/etc/shadow
, which only admins can read. Its format is$<type>$<salt>$<hashed>
, with types like:$1$
– MD5$5$
– SHA-256$6$
– SHA-512
To crack
/etc/shadow
:
Attacking Active Directory & NTDS.dit
Password Spraying/Brute-Forcing
When a Windows system joins a domain, it stops using the local SAM database for logins. Instead, it asks the domain controller to verify credentials. In Active Directory, brute-forcing can create lots of logs and lock accounts, so attackers need to be sneaky. One trick is using Open-Source Intelligence (OSINT) to figure out username patterns, like "firstname.lastinitial" or "firstinitial.lastname", by checking company emails or online employee info. Tools like
username-anarchy
generate username lists, and CrackMapExec runs the attacks.
Capturing NTDS.dit
NTDS (NT Directory Services) helps Active Directory organize network resources. The
NTDS.dit
file, found at%systemroot%\ntds
on domain controllers, is its main database. It holds all domain usernames, password hashes, and more. If you grab this file, you could compromise every account in the domain.You’ll need local admin or Domain Admin rights to copy it. One method uses
vssadmin
to make a Volume Shadow Copy (VSS) of the C: drive (or wherever NTDS lives):
Or automate it with CrackMapExec:
Extract the NT hashes and crack them with Hashcat
If cracking fails, try a Pass-the-Hash attack with Evil-WinRM:
Credential Hunting
Once you’re inside a system, hunting for credentials is a top priority. They can hide in files, logs, command histories, memory, browser data, databases, scripts, and more. You can search manually or use tools like LaZagne to automate it.
On Windows, try:
Or run:
On Linux, we can check for:
Configuration files:
Passwords in config files:
Database files:
SSH Keys:
Check bash history:
Run Mimipenguin:
Pass The Hash Attack
In a Pass-the-Hash (PtH) attack, you use a password hash instead of the actual password. Windows’ NTLM protocol doesn’t salt hashes, so if you have one, you can authenticate without knowing the password. Once the hash is obtained, attackers can use it to authenticate to remote systems via various protocols such as SMB, WinRM, or RDP. Below are common methods and tools for executing PtH attacks:
Get hashes with Mimikatz:
Then use Mimikatz for PtH:
This opens a new command prompt authenticated as the specified user.
Invoke-TheHash is an another PowerShell toolkit for performing PtH attacks over SMB or WMI. It does not require local administrator privileges on the attacking machine, but the user whose hash is used must have administrative rights on the target.
On Linux, we can use other tools like, Impacket, crackmapexec, or even rdp tools.
For graphical access, we can use PtH over RDP with tools like xfreerdp. This requires that Restricted Admin Mode is enabled on the target system.
Pass the Ticket (PtT)
Pass the Ticket (PtT) is an attack technique where we steal and reuse Kerberos tickets to gain unauthorized access to network resources in an Active Directory environment. Kerberos uses two types of tickets:
TGT (Ticket Granting Ticket): Allows requesting service tickets from the Key Distribution Center (KDC).
TGS (Ticket Granting Service): Authenticates the user to a specific service.
Unlike Pass the Hash (PtH), which relies on NTLM hashes, PtT exploits Kerberos tickets for authentication.
Extracting Tickets
Attackers extract tickets from a compromised system using tools like Mimikatz or Rubeus:
With Mimikatz:
This exports tickets as .kirbi files.
With Rubeus:
This outputs tickets in base64 format for easy copying.
Importing Tickets
Once extracted, tickets are imported into a session to authenticate as the ticket’s user:
With Mimikatz:
With Rubeus:
Pass the Key or OverPass the Hash
Pass the Key, also called OverPass the Hash, uses a user’s password hash (e.g., NTLM or AES keys) to request a TGT from the KDC, creating a new Kerberos ticket without the plaintext password. Unlike traditional PtH, which avoids Kerberos, this method integrates with it.
Obtaining Hashes
First, extract the user’s hash or Kerberos keys:
With Mimikatz:
This lists all Kerberos encryption keys (e.g., NTLM, AES256) for logged-on users.
Requesting a TGT
Use the hash to forge a TGT:
With Mimikatz:
This opens a new session with the user’s security context.
With Rubeus:
The /ptt flag imports the ticket into the current session. Alternatively, use an AES256 key:
Using PtT with PowerShell Remoting
Stolen Kerberos tickets can enable PowerShell Remoting for lateral movement. For this we need to be an admin, a member of the Remote Management Users group, or have explicit PowerShell Remoting permissions.
With Mimikatz, Import the ticket:
Launch PowerShell and connect:
With Rubeus, Create a sacrificial logon session:
Import the ticket in the new session:
Use PowerShell Remoting from that session.
Pass the Ticket on Linux
Linux systems integrated with Active Directory use Kerberos for authentication, storing tickets differently than Windows. We can exploit these tickets for access.
Identifying Domain Integration
Check if the system is domain-joined:
With realm:
Look for services like sssd or winbind running on the system.
Abusing ccache Files
Kerberos tickets are stored as credential cache (ccache) files, typically in /tmp, with their location set in the KRB5CCNAME environment variable.
Locate the ccache file:
Abusing Keytab Files
Keytab files store Kerberos keys for authentication without passwords.
Find keytab files:
Tool Support
Impacket: Use
-k
for Kerberos authentication:
Ensure KRB5CCNAME contains only the file path if FILE: prefix is present.
Evil-WinRM: Requires krb5-user package and /etc/krb5.conf setup:
Linikatz: Extracts credentials from AD-integrated Linux systems (requires root): Outputs tickets in linikatz.* folders as ccache or keytab files.
Ticket Conversion: Convert ccache to .kirbi or vice versa:
Cracking Encrypted Files
Sensitive files may be password-protected. Use John the Ripper to crack them. Examples:
SSH Keys:
Office Documents:
Last updated