WEBVTT

00:00:00.866 --> 00:00:05.100
Introduction to Encryption,
Hashes and Cracking

00:00:06.500 --> 00:00:11.000
We can perform basic password
cracking with a simple example.

00:00:11.733 --> 00:00:17.200
Let’s assume that we gained
access to a SHA-256 password hash.

00:00:18.933 --> 00:00:22.800
There are various ways we could
have gained access to this hash,

00:00:22.800 --> 00:00:26.566
but either way we can use sha256sum

00:00:26.566 --> 00:00:30.266
to hash various passwords
and examine the results.

00:00:33.233 --> 00:00:36.900
In this case, we will
hash the string “secret”.

00:00:37.400 --> 00:00:42.000
We’ll use echo -n to strip the 
newline from our string

00:00:42.000 --> 00:00:45.700
(which would have been added
to our string, modifying the hash).

00:00:47.233 --> 00:00:49.633
then hash “secret” again,

00:00:52.033 --> 00:00:55.666
and finally hash the string “secret1”.

00:00:58.133 --> 00:01:01.566
In this example, we hashed “secret” twice

00:01:01.566 --> 00:01:05.333
to show that the resulting
output hash is always the same.

00:01:06.366 --> 00:01:10.300
Notice that the hashes for
the “secret” and “secret1”

00:01:10.300 --> 00:01:14.433
are completely different even
though the input strings are similar.

00:01:15.500 --> 00:01:20.566
Also note that the hash for “secret1”
matches our captured hash.

00:01:22.533 --> 00:01:27.266
This means that we have determined
the plaintext password, secret1,

00:01:27.266 --> 00:01:29.466
associated with that hash.

00:01:29.900 --> 00:01:31.266
Very cool.

00:01:33.600 --> 00:01:39.233
However, this is a very simple and
awkward way to crack password hashes.

00:01:39.666 --> 00:01:43.033
Fortunately there are
much better tools available.

00:01:43.500 --> 00:01:49.266
Hashcat and John the Ripper are two of
the most popular password cracking tools.

00:01:51.433 --> 00:01:56.633
In general, JtR is more of
a CPU-based cracking tool,

00:01:56.633 --> 00:01:59.266
which also supports GPUs,

00:01:59.266 --> 00:02:05.966
while Hashcat is mainly a GPU-based
cracking tool that also supports CPUs.

00:02:06.366 --> 00:02:10.066
JtR can be run without
any additional drivers

00:02:10.066 --> 00:02:13.500
using only CPUs for password cracking.

00:02:13.966 --> 00:02:19.900
Hashcat requires OpenCL or
CUDA for the GPU cracking process.

00:02:21.800 --> 00:02:26.733
For most algorithms, a GPU
is much faster than a CPU 

00:02:26.733 --> 00:02:30.300
since modern GPUs
contain thousands of cores,

00:02:30.300 --> 00:02:33.100
each of which can share
part of the workload.

00:02:33.500 --> 00:02:40.333
However, some slow hashing algorithms
(like bcrypt) work better on CPUs.

00:02:42.333 --> 00:02:45.400
It’s important to become
familiar with different tools

00:02:45.400 --> 00:02:48.200
since they don’t support
the same algorithms.

00:02:48.600 --> 00:02:52.166
We’ll examine both tools in this Topic.

00:02:52.600 --> 00:02:55.133
Before we begin cracking passwords,

00:02:55.133 --> 00:02:59.766
let’s calculate the cracking time
of various hash representations.

00:03:00.200 --> 00:03:05.733
The cracking time can be calculated by
dividing the keyspace with the hash rate.

00:03:06.200 --> 00:03:11.733
The keyspace consists of the character set
to the power of the amount of characters 

00:03:11.733 --> 00:03:15.566
or length of the original
information (password).

00:03:18.033 --> 00:03:22.100
For example, if we use the
lower-case Latin alphabet,

00:03:22.100 --> 00:03:23.933
upper case alphabet,

00:03:23.933 --> 00:03:26.400
and the numbers from 0 to 9,

00:03:26.400 --> 00:03:31.800
we have a character set of 62 possible
variations for every character.

00:03:32.233 --> 00:03:35.400
If we are faced with a
five-character password,

00:03:35.400 --> 00:03:39.833
we are facing 62 to the power
of five possible passwords

00:03:39.833 --> 00:03:42.233
containing these five characters.

00:03:44.233 --> 00:03:47.166
Since it’s important to
be able to calculate this,

00:03:47.166 --> 00:03:52.200
let’s use a terminal to calculate the
keyspace for a five-character password.

00:03:55.866 --> 00:04:01.900
We’ll echo our character set to
wc with -c to count every character.

00:04:03.066 --> 00:04:09.066
We will again specify -n for the echo
command to strip the newline character.

00:04:12.733 --> 00:04:16.233
We can then use python3
for the calculation,

00:04:16.233 --> 00:04:21.800
with -c to execute the calculation
and print to display the result.

00:04:23.100 --> 00:04:27.333
For a five-character password
and the specified character set,

00:04:27.333 --> 00:04:31.000
we have a keyspace of
over 900 million.

00:04:32.133 --> 00:04:35.400
This number determines
how many unique variations

00:04:35.400 --> 00:04:40.066
can be generated for a five-character
password with this character set.

00:04:42.566 --> 00:04:46.566
Now that we have the keyspace
in the context of this example,

00:04:46.566 --> 00:04:50.700
we also need the hash rate to
calculate the cracking time.

00:04:51.133 --> 00:04:54.366
The hash rate is a measure
of how many hash calculations

00:04:54.366 --> 00:04:56.600
can be performed in a second.

00:04:57.033 --> 00:05:01.300
To find the hash rate, we can
use Hashcat’s benchmark mode

00:05:01.300 --> 00:05:04.900
to determine the hash rates
for various hash algorithms

00:05:04.900 --> 00:05:06.966
 on our particular hardware.

00:05:07.400 --> 00:05:13.866
We’ll benchmark a CPU by running it in
a Kali VM without any GPUs attached.

00:05:15.233 --> 00:05:20.333
We’ll use hashcat with -b
to initiate benchmark mode.

00:05:20.733 --> 00:05:25.933
On a local Kali system and with
different hardware, the results will vary.

00:05:31.366 --> 00:05:36.266
The benchmark displays hash rates
for all supported modes of Hashcat.

00:05:38.666 --> 00:05:42.566
For now, we are only interested in MD5,

00:05:42.566 --> 00:05:43.933
 SHA1,

00:05:43.933 --> 00:05:46.133
and SHA-256.

00:05:47.233 --> 00:05:51.600
The values of the hash rates
are in Mega Hashes per second

00:05:51.600 --> 00:05:56.033
in which 1 equals 1 million
hashes per second.

00:06:01.933 --> 00:06:08.166
A comparison of our CPU with typical
GPU hashrates is shown in this table.

00:06:11.266 --> 00:06:14.666
We’ll calculate the
cracking time for SHA256

00:06:14.666 --> 00:06:17.500
with our previously determined keyspace.

00:06:20.700 --> 00:06:26.400
Therefore, we can again use Python to
calculate CPU cracking times in seconds.

00:06:28.800 --> 00:06:31.666
And GPU cracking times.

00:06:33.733 --> 00:06:37.666
The output shows that we can
calculate all possible hashes

00:06:37.666 --> 00:06:41.366
for this keyspace in under
one second with a GPU,

00:06:41.366 --> 00:06:45.333
and in approximately
eight seconds on a CPU.

00:06:46.000 --> 00:06:48.466
Let’s use the same character set

00:06:48.466 --> 00:06:51.866
but with an increased
password length of 8 and 10

00:06:51.866 --> 00:06:55.566
to get a better understanding
for how cracking time scales

00:06:55.566 --> 00:06:57.533
versus password length.

00:06:57.833 --> 00:07:04.800
For this, we’ll use the GPU hash rate
for SHA-256 for our calculations.

00:07:13.233 --> 00:07:16.833
The output shows that
when converted from seconds,

00:07:16.833 --> 00:07:23.533
it will take a GPU approximately 6.5 hours
to attempt all possible combinations

00:07:23.533 --> 00:07:25.766
for an eight-character password,

00:07:25.766 --> 00:07:30.266
and approximately 2.8 years
for a ten-character password.

00:07:30.600 --> 00:07:33.133
Note that increasing password length

00:07:33.133 --> 00:07:36.666
increases cracking duration
by exponential time,

00:07:36.666 --> 00:07:41.500
while increasing password complexity
only increases cracking duration

00:07:41.500 --> 00:07:43.633
by polynomial time.

00:07:44.000 --> 00:07:48.366
This implies that a password policy
encouraging longer passwords

00:07:48.366 --> 00:07:50.733
is more robust against cracking,

00:07:50.733 --> 00:07:55.800
compared to a password policy that 
encourages more-complex passwords.

00:07:58.033 --> 00:08:02.000
In this section, we discussed
encryption and hashing,

00:08:02.000 --> 00:08:07.500
and we benchmarked various hash
algorithms on a CPU and a GPU.

00:08:07.866 --> 00:08:13.700
Finally, we familiarized ourselves with
the process of calculating cracking time.
