Module 6.5: Brute force attacks: Hydra
Migration
Brute inforce progressdictionary attacks: hashing, hashcat and hydra
Install hydra and hashcat: home brew example
brew install hydra hashcat
On linux machines:
sudo apt install hydra hashcat -y
Hashcat:
- decodes hashes by comparing them with a wordlist of known hashes
- you must have a local copy of the hashes to do this
- if you have a modern gaming GPU, this can be very fast
- you don't have to maintain a connection to do this once you have the hashed file
- can use huge dictionary to decode hash
Hydra: - does the same using ssh to attack a remote computer
- must have a constant connection to the computer to attack (e.g. can be detected)
- can attack computers inside a network, but not through firewalls
- can make millions of attacks per second using a large dictionary stored locally
Hashing:
Example:use the online utility to create a SHA512 hash for Toomanysecrets77:
da355c585ad36b98017d11ed3fd05199acbb2855345dc463f61fc42fdf6656c9
is a SHA256 hash of Toomanysecrets77 (a secret password)
try this out, make sure you get the same result
Local password attack demo: hashcat
create your own word list of passwords:
sudo nano wordlist.txt
insert these, one on each line:
papaya77
Toomanysecrets77
hashcat
pal82
ctrl-o, save and then ctrl-x
next: create another file on your machine:
sudo nano hashes.txt
Generate SHA512 hashes for each password and copy the hashes into this file, ctrl-o, save, ctrl-x
Run hashcat to decode the hashes:
hashcat -m 1400 -a 0 hashes.txt wordlist.txt
or this
sudo hashcat -m 1400 -a 0 hashes.txt wordlist.txt --outfile=cracked.txt --outfile-format=2
show results:
sudo hashcat --show -m 1400 hashes.txt
what does this do?
- opens hashcat
- decodes format 1400 (SHA512 encryption) (mode)
- attack mode, dictionary attack (-a)
- use these two files
what do you see?
try again using this password file:
Unmigrated media: common-passwords.txt.zip (text/plain, 2.2 KB)
Unmigrated media: crackedpasswords.txt (text/plain, 82 B)
sudo hydra -l "pi" -P wordlist.txt \
10.14.88.83 ssh
enter the password for YOUR machine to connect by ssh
This is an external attack...
1 of 1 target completed, 0 valid password found
What did you find?
Why does it fail?
Salting: adding random characters to confuse hashcat
ssh into the machine at 10.14.88.83 (pi/papaya77)
cd /etc
cat shadow
find the hashed entry for the user pi
$y$j9T$bl0cC/JggW3QeHa3UyiNc0$23oSBAPMIvOng71RwU4qZGLChAcwWCjJYm/jAaHavOB
This is a salted hash, meaning random characters have been inserted between the hash to make it more secure.
Download this massive list of passwords:
https://weakpass.com/wordlists/rockyou.txt
expand the file:
sudo gzip -d rockyou.txt.gz
Look at the file:
cat rockyou.txt
crazy!
Migrated from Apple WikiServer Wiki. Original page 64m6w3W5k7.ID: 64m6w3W5k7