Password hashes can be stolen in many ways,
for example via SQL injection attacks on a website
that extracts the hashes from the data base.
A SQL injection attack happens when a website
does not validate the input of the data it receives,
and because of that,
you can send direct queries
to the data base and ask it,
“Would you mind very much
just to give me your password hashes?”,
in the worst case scenario.
And here, what you can see here is a website
that has a collection of hashdumps from compromised websites.
You can see LinkedIn, EHarmony, the dating website.
These are the hashing algorithms they use,
MD5, not very good, should not have used it;
SHA1, also not acceptable.
So you can see, even big sites doing it wrong.
And then you’ve got an analysis here,
so we can check that out.
I’m going to go down here
and you can see here,
based on this analysis,
you feed into your cracking process.
You can see here
there’s a significant amount that uses the word LinkedIn,
so you would feed that into your rules.
And the rest of this sort of information,
like the Length, the Character sets used,
Character set frequency, etc.,
that all goes back into your recracking of the hashes.
Hashes can also be extracted from operating systems.
If you have local access to the drive,
you can do that by mounting the hard drive
in another operating system,
or using a live CD,
as long as it can mount the file system.
And here we have the example of Windows.
We’ve got LM hashes, we’ve got NT hash,
NTLM hashes for the passwords of these users here.
And in Windows, these are stored
in something called the Security Account Manager
or SAM, which is essentially just a file.
And those hashes
can be extracted with various tools.
Here’s an example of one, PWDUMP7,
and you can see it here
literally dumping the usernames and hashes,
and the hashes are then put into cracking tools,
which I’m going to show you in a second.
Because offline attacks are not interacting with the cryptosystem,
they can't defend themselves, hashes can't defend themselves,
they’re just a bunch of characters in a file.
So the attack can be many,
many, many times faster than online attacks.
So think about
in the region of one hundred billion guesses per second
or maybe one hundred trillion guesses per second
with super multi GPU crackers
like the one you can see here.
And it’s this speed which enables
brute force hybrid and custom attacks
that we have gone through to work
with moderately complex passwords.
In Kali you’ll see that there are actually lots of cracking tools.
We go down to here, Password Attacks;
got Hashcat, John the Ripper,
Ophcrack, there’s wordlists or dictionaries there,
and there’s other tools beside these as well.
Let me introduce you to Hashcat.
So we need some hashes in order to crack first,
so I’ve downloaded some public hashes
from one of the old crack sites
that I’ve just chosen at random.
And this is the file here, hashes.txt,
so I will just (00:03:15 – inaudible) that so you can see it.
So there you go,
you can see all of the hashes there.
Stop that for a minute.
So we’re going to crack these
and work out what the password is
for each of these hashes.
Sometimes you won't know
what sort of hash or key derivation,
combination that you have,
so you can try using hashid with a hash
and see what sort of results you get.
And we can see here
that this is possibly a number of different hashes,
but I actually know that this is MD5.
We’re going to use a wordlist or dictionary attack
as part of a kind of hybrid attack,
so here’s our dictionary,
this is what this looks like.
See, lots of common words that people use for passwords,
you can see, it’s not actually that big.
And here’s a command,
we’re going to use “hashcat” with “-m”
is to tell it that it’s MD5.
Those are the hashes, that's the wordlist,
and that’s just simply the output file.
Let's give it a go, see what we get.
So the wordlist has successfully cracked
22,000 out of five hundred odd thousand hashes,
that’s about 4%,
and that was literally in a few seconds
with a dictionary attack.
And here we are,
same command, but with “-a 1”,
1 for Hashcat is a combination attack.
Press "S” for status,
we can see it there cracking more files.
So click there.
Remember this file here,
this is how we can potentially add rules,
so we can take our dictionary without input words
and then change them to other words.
So here, this would do nothing, if we had that as a rule,
that’d be lowercase; we can append characters,
we can duplicate the word; password, password.
So I’ve got a rules file here,
so I’ve just added these,
so we’ve got some appending of characters at the end,
we’ve got "f” a duplicate word reverse,
and “;” for “do nothing”.
So let's save that,
and we append to the end here,
our “- - rules”,
and then our rules file.
Let's give that a go.
And you can see,
in literally just a few seconds,
went from 22,000 to 23,000.
So that gives you a flavor
of the sort of process that you go through
when you’re doing password cracking.
And because these were MD5,
these are much, much faster to crack,
and they would be if they’d use
a key stretching function.
You can even try decrypting online,
and there are a number of sites
that can enable you to do that.
Check out this link,
it provides a bunch of sites who enable you to do that.
The big one is actually crackstation.net.
An online cracking is actually very viable
because it’s fast and easy to hire
for short periods of time,
massively powerful servers.
For example, with AWS Amazon you can rent
these for short periods of time to crack passwords,
which is what people do.
It’s a time cost exercise.
But if the right hash key derivation function,
key length and password is being chosen,
then it’s unlikely to be cracked even with all the power.
But sometimes you don't always have to crack the hash.
You can capture it and relay it in a relay attack.
If you’re a man in the middle, instead of cracking it,
you just forward it on,
after you have captured it,
enabling your access to the destination.
Famously, Windows LM or NTLM hashes
can be relayed due to an authentication flaw,
which can be done with Metasploit in Kali.