Practical Password Cracking
Practical Password Cracking
Practical Password Cracking
Jamie Riden
Email: [email protected]
Twitter: @pedantic_hacker
Password Cracking
Bad hashes and why they’re bad
That means, we can check it’s correct but if an attacker breaches the
system, they can’t just recover the password.
We can make lots of guesses and see whether the answer is the same.
Quick function => quick guesses.
Recovers the original. A bit slower but not really very useful in terms of
protection.
md5(sha1(password))
md5(md5(salt) + md5(password))
sha1(sha1(password))
sha1(str_rot13(password + salt))
echo password_hash("rasmuslerdorf",
PASSWORD_DEFAULT);
$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq
7KnEd1rVAGv3Fykk1a
Requirements
Salt should be from CSPRNG (java SecureRandom, etc)
$6$9sirPrQg$keedQFIOyFrljxxxxiA2l7eksg1:toor
Actual Solutions – Better Hashing
bcrypt and other algorithms use number of rounds or cost
factor so you can make a hash computation take longer.
<?php
$options = [
'cost' => 12,
];
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $opti
ons);
?>
$2y$12$QjSH496pcT5CEbzjD/vtVeH03tfHKFy36d4J0Ltp3lRtee9HDxY
3Ks
Helping Your Users
Number
of users
Complexity of password
Helping Your Users
Try to enforce length/complexity.
But be aware, “Password123!” meets most length/complexity
guidelines.
Check for dictionary words ?
Check for password stuffing (someone replaying passwords found in
another breach) – e.g. rate limit, CAPTCHAs, account lockout etc.
Crack your own passwords and expire the compromised ones.
Check for breached passwords at set time – see below:
Checking for Breached Passwords
$ curl
"https://haveibeenpwned.com/api/v2/pwnedpassword/"`echo
-n password | sha1sum | cut -f 1 -d' '` -D
HTTP/2 200 [ found in a breach ]
$ curl
"https://haveibeenpwned.com/api/v2/pwnedpassword/"`echo
-n psdfasdfasdgasdfgasdgasdgassword | sha1sum | cut -f
1 -d' '` -D -
HTTP/2 404 [ not found in breach ]
Tools - Hashcat
Very good GPU cracker, but also does CPU / FPGA.
Get the binaries from the net, install the latest NVIDIA drivers
and it should be ready.
Incremental:
Hashcat64.exe –m <hash type> -a3 hashlist.txt [ <mask> ]
Where ?l lower case ?u upper case ?d digit ?s special
XAUTHORITY=/run/user/131/gdm/Xauthority nvidia-settings \
-a [gpu:0]/GpuPowerMizerMode=1 \
-a [gpu:0]/GPUMemoryTransferRateOffset[3]=$MEMCLOCK \
-a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=$FAN \
-a [gpu:0]/GPUGraphicsClockOffset[3]=$GFXCLOCK
nvidia-smi -pl $POWER
Tools – Hashcat overclocking
Tools – John the Ripper
JTR with all the bits and bobs, including UTF-8 support and GPUs.
$ git clone
https://github.com/magnumripper/JohnTheRipper.git
$ cd JohnTheRipper/src
$ ./configure
# on mine – vi Makefile and delete –DJOHN_AVX – for some reason
$ make install
user:43191e523ba88fba40a6744b67b8f546
43191e523ba88fba40a6744b67b8f546:$HEX[6dc3b674]
(depends on hashing scheme and pre-processing of input data)
root:$6$lZd0wvLZ$zb4lOouYxxx:::
$6$lZd0wvLZ$zb4lOouYxxx0pgJ90:$HEX[6dc3b6746f7268656164]
motordict.txt : 6d c3 b6 74 6f 72 68 65 61 64
Careful with non 7-bit ASCII
C:\> net user /add mot möt
9e8ad77244a880f7f1f10d0b46693fce:$HEX[6df674]
It seems ö is coded as \xf6 and not the two-byte UTF-8 encoding. (NTLM)
Careful with non 7-bit ASCII
Compare LM/NTLM for the same account:
LM 759c0a91bxxx8728d99f4:xxxxxxx$HEX[454250509c]
NTLM 7b0ee41fxxx6376a6aee3c:xxxxxxx$HEX[65627070a3]
xxxxxxxebpp£
$ perl -e '$i=32; while ($i<127) { print chr($i); $i++ }; $i=192; while ($i<255) { print
chr($i); $i++ };' > win-ext.hcchr
9883fd245e9aee55ad39d31752eb4a4d:$HEX[62f674]
Oracle
Connect as a DBA to Oracle 11g with sqlplus
set heading off
set feedback off
set pagesize 1000
set linesize 100
SELECT name || ':' || SUBSTR(spare4,3) FROM sys.user$ WHERE spare4 IS NOT NULL ORDER
BY name;
DBSNMP:A092440872DEAA491B0F8C16F4A2C9304928238617DA4741CBF3683A469C
Oracle
DBSNMP:A092440872DEAA491B0F8C16F4A2C9304928238617DA
4741CBF3683A469C
a092440872deaa491b0f8c16f4a2c93049282386:17da4741cb
f3683a469c:dbsnmp
Postgresql
select passwd, usename from pg_shadow
Run with -m 12
Targetted Attacks - hashcat
# swap char - leetify ( word -> w0rd )
so0
# append ‘!’
$!
# Toggle case of first letter
T0
# Enclose in quotes
^”$”
#prepend 123
^3^2^1
https://hashcat.net/wiki/doku.php?id=rule_based_attack
Targetted Attacks - wordlists
Troy Hunt’s list – unpublished ?
Breach compilation list
https://gist.github.com/scottlinux/9a3b11257ac575e4f71de811322ce6b3
Crackstation https://crackstation.net/
Probabilistic password lists https://github.com/berzerk0/Probable-Wordlists
SecLists Passwords
https://github.com/danielmiessler/SecLists/tree/master/Passwords
Your found passwords / --loopback option
SHA1, so it’s very quick. These, and 275 million others, were recovered on a Dell Precision
7510 / Quadro M2000M
tres metros sobre el cielo [ tr: three meters above the sky ]
[email protected] [ data issues? ]
S0metimearoundmidnight [leetified phrase]
qwertyuiopasdfghjklzxcvbnm12332 [ keyboard pattern ]
danthemanfrombristolland
ironwhoironfuckingmaiden [ personal favourite ]
Greyarea – 1 x 1080 Ti
Hash.Type........: SHA1
Hash.Target......: ../uncracked-sha1.txt
Guess.Mask.......: ?1?2?2?2?2?2?2?3?3?3?3?d [12]
Guess.Charset....: -1 ?l?d?u, -2 ?l?d, -3 ?l?d*!$@_, -4 Undefined
Speed.Dev.#2.....: 9675.8 MH/s (11.57ms) [ ~ 10 bn/s ]
07bbb269b7f9b7bf2a649dc5d2472ad9058f5889:hpkhhp999999
Targetted Attacks - hashcat
Search a specific set of characters [a-z]{4-6}
hashcat64.exe -m 1800 -a 3
password.hcmask $6$mZVuffPMxxxFF0
Pp,@a4,s5$,o0,?1?2?3?3w?4rd?d?d?d?s
Tries [Pp][@a4][s5$][s5$][oO]rd?d?d?d?s
e.g. P455w0rd123!
Hcmask files
Pp,@a4,s5$,o0,?1?2?3?3w?4rd?a?a
Pp,@a4,s5$,o0,?1?2?3?3W?4rd?a?a?a
Pp,@a4,s5$,o0,?1?2?3?3w?4rd?a?a?a
Pp,@a4,s5$,o0,?1?2?3?3W?4rd?a?a?a?a
Pp,@a4,s5$,o0,?1?2?3?3w?4rd?a?a?a?a
Pp,@a4,s5$,o0,?a?1?2?3?3W?4rd?a
…
$ hashcat-4.0.1\hashcat64.exe -m 1000 users.ntlm -a3
password.hccmask
Tools
Hate_crack ( trusted sec ) https://github.com/trustedsec/hate_crack
(couldn’t get this one to go on Windows – can’t map NVIDIA cards
through to Vmware workstation?)
Autohashcat https://gitlab.com/pentest/autohashcat
(saves some keystrokes by running common / sensible params, and
tries to identify hash type for you)