WEBVTT

00:00:00.000 --> 00:00:04.800 align:middle line:90%


00:00:04.800 --> 00:00:07.200 align:middle line:90%
[MUSIC PLAYING]

00:00:07.200 --> 00:00:10.080 align:middle line:90%


00:00:10.080 --> 00:00:12.360 align:middle line:84%
Welcome to the
Linux Hash Cracking

00:00:12.360 --> 00:00:13.950 align:middle line:90%
section of this course.

00:00:13.950 --> 00:00:15.870 align:middle line:84%
In this section, we're
going to be covering

00:00:15.870 --> 00:00:18.930 align:middle line:84%
the process of dumping and
cracking Linux password

00:00:18.930 --> 00:00:23.830 align:middle line:84%
hashes on a Linux target system
that you have compromised.

00:00:23.830 --> 00:00:25.620 align:middle line:84%
So again, this section
will essentially

00:00:25.620 --> 00:00:28.150 align:middle line:84%
comprise of one video,
and this is the video.

00:00:28.150 --> 00:00:30.120 align:middle line:84%
So we'll essentially
cover the process

00:00:30.120 --> 00:00:33.443 align:middle line:84%
of how to dump the Linux
password hashes, and then,

00:00:33.443 --> 00:00:34.860 align:middle line:84%
of course, explore
how they can be

00:00:34.860 --> 00:00:39.810 align:middle line:84%
cracked through the use of both
John the Ripper and Hashcat.

00:00:39.810 --> 00:00:43.410 align:middle line:84%
Now, before we get started with
the actual cracking process,

00:00:43.410 --> 00:00:46.590 align:middle line:84%
let's get an understanding
of how Linux stores

00:00:46.590 --> 00:00:48.940 align:middle line:90%
passwords, or password hashes.

00:00:48.940 --> 00:00:49.440 align:middle line:90%
All right.

00:00:49.440 --> 00:00:53.140 align:middle line:84%
So Linux has multi-user
support, as you already know.

00:00:53.140 --> 00:00:56.490 align:middle line:84%
And as a result, multiple
users can access the system

00:00:56.490 --> 00:00:57.750 align:middle line:90%
simultaneously.

00:00:57.750 --> 00:01:01.380 align:middle line:84%
This can be seen as both an
advantage and disadvantage

00:01:01.380 --> 00:01:05.459 align:middle line:84%
from a security perspective,
in that multiple accounts offer

00:01:05.459 --> 00:01:07.890 align:middle line:84%
multiple access
vectors for attackers

00:01:07.890 --> 00:01:11.880 align:middle line:84%
and therefore increase the
overall risks of the server.

00:01:11.880 --> 00:01:16.020 align:middle line:84%
And this is not just limited to
Linux, but really any operating

00:01:16.020 --> 00:01:19.720 align:middle line:84%
system that allows you to
create multiple user accounts.

00:01:19.720 --> 00:01:23.640 align:middle line:84%
The issue here is that if you
create five user accounts those

00:01:23.640 --> 00:01:30.240 align:middle line:84%
are all potential access or
exploit vectors for attackers.

00:01:30.240 --> 00:01:33.750 align:middle line:84%
So you're essentially providing
attackers with five doors.

00:01:33.750 --> 00:01:38.340 align:middle line:84%
And that just increases the
overall risk, or the threat

00:01:38.340 --> 00:01:39.600 align:middle line:90%
surface.

00:01:39.600 --> 00:01:43.170 align:middle line:84%
Now, all of the information
for all accounts on Linux

00:01:43.170 --> 00:01:46.710 align:middle line:84%
is stored in the password
file, located etc password.

00:01:46.710 --> 00:01:48.690 align:middle line:84%
You should already
be familiar with.

00:01:48.690 --> 00:01:52.440 align:middle line:84%
We cannot view the passwords for
the users in the password file,

00:01:52.440 --> 00:01:56.100 align:middle line:84%
because they are encrypted and
the password file is readable

00:01:56.100 --> 00:01:58.030 align:middle line:90%
by any user on the system.

00:01:58.030 --> 00:02:01.410 align:middle line:84%
So if you wanted to view the
user accounts on the Linux

00:02:01.410 --> 00:02:04.350 align:middle line:84%
system as we did during
the Linux Local Enumeration

00:02:04.350 --> 00:02:07.570 align:middle line:84%
section, we can display the
contents of the etc password

00:02:07.570 --> 00:02:08.070 align:middle line:90%
file.

00:02:08.070 --> 00:02:11.550 align:middle line:84%
The etc password file does not
contain the encrypted hash,

00:02:11.550 --> 00:02:14.920 align:middle line:84%
or the encrypted password
of that user account.

00:02:14.920 --> 00:02:18.030 align:middle line:84%
It just contains the username
of the user, the user ID,

00:02:18.030 --> 00:02:21.420 align:middle line:84%
the group ID, the home
directory, and the default

00:02:21.420 --> 00:02:23.470 align:middle line:90%
shell for that user account.

00:02:23.470 --> 00:02:25.290 align:middle line:84%
And as a result,
because it doesn't

00:02:25.290 --> 00:02:28.260 align:middle line:84%
store anything that
is confidential,

00:02:28.260 --> 00:02:32.380 align:middle line:84%
that file is readable by any
user account on the system.

00:02:32.380 --> 00:02:34.800 align:middle line:84%
So where are the
passwords stored?

00:02:34.800 --> 00:02:37.200 align:middle line:84%
The encrypted passwords
for the user accounts

00:02:37.200 --> 00:02:40.320 align:middle line:84%
are stored in a file
called the shadow file.

00:02:40.320 --> 00:02:42.390 align:middle line:84%
It can be found in the
following directory.

00:02:42.390 --> 00:02:44.940 align:middle line:90%
So that etc shadow.

00:02:44.940 --> 00:02:48.030 align:middle line:84%
So user account details are
stored in the etc password

00:02:48.030 --> 00:02:48.630 align:middle line:90%
file.

00:02:48.630 --> 00:02:51.000 align:middle line:84%
The encrypted passwords
for the user account

00:02:51.000 --> 00:02:53.340 align:middle line:84%
are stored in the
etc shadow file.

00:02:53.340 --> 00:02:55.780 align:middle line:90%
Now, what's the caveat here?

00:02:55.780 --> 00:02:58.890 align:middle line:84%
The shadow file can only
be accessed and read

00:02:58.890 --> 00:03:00.630 align:middle line:90%
by the root account.

00:03:00.630 --> 00:03:03.240 align:middle line:84%
This is a very important
security feature,

00:03:03.240 --> 00:03:06.060 align:middle line:84%
as it prevents other
unprivileged user accounts

00:03:06.060 --> 00:03:10.470 align:middle line:84%
on the system from accessing the
hashed or encrypted passwords.

00:03:10.470 --> 00:03:15.840 align:middle line:84%
So just like Windows, if you
don't have elevated privileges,

00:03:15.840 --> 00:03:18.480 align:middle line:84%
you cannot view the
user account hashes,

00:03:18.480 --> 00:03:20.590 align:middle line:84%
and therefore you
cannot crack them.

00:03:20.590 --> 00:03:25.020 align:middle line:84%
So in order for you to
essentially dump Linux password

00:03:25.020 --> 00:03:27.600 align:middle line:84%
hashes, you need to
have administrative--

00:03:27.600 --> 00:03:30.510 align:middle line:84%
or in the case of Linux,
root privileges-- either

00:03:30.510 --> 00:03:33.060 align:middle line:84%
through the root account,
or through an account that

00:03:33.060 --> 00:03:36.300 align:middle line:84%
is part of the root
group, or the sudo group.

00:03:36.300 --> 00:03:38.340 align:middle line:84%
To put it simply,
you need access

00:03:38.340 --> 00:03:41.700 align:middle line:84%
to the target system
via the root account,

00:03:41.700 --> 00:03:45.870 align:middle line:84%
or an account that has sudo
or root privileges associated

00:03:45.870 --> 00:03:46.480 align:middle line:90%
to it.

00:03:46.480 --> 00:03:46.980 align:middle line:90%
All right.

00:03:46.980 --> 00:03:49.085 align:middle line:90%
So hopefully that makes sense.

00:03:49.085 --> 00:03:50.460 align:middle line:84%
Now that we have
an understanding

00:03:50.460 --> 00:03:54.270 align:middle line:84%
of how that works, let's talk
a little bit about the shadow

00:03:54.270 --> 00:03:59.130 align:middle line:84%
file and how the hashed or
encrypted passwords are stored.

00:03:59.130 --> 00:04:02.370 align:middle line:84%
So the shadow file gives
us information in regards

00:04:02.370 --> 00:04:05.070 align:middle line:84%
to the hashing algorithm
that is being used

00:04:05.070 --> 00:04:06.660 align:middle line:90%
and the password hash.

00:04:06.660 --> 00:04:09.900 align:middle line:84%
This is very helpful, as
we are able to determine

00:04:09.900 --> 00:04:12.420 align:middle line:84%
the type of hashing
algorithm that is being used

00:04:12.420 --> 00:04:13.740 align:middle line:90%
and its strength.

00:04:13.740 --> 00:04:16.260 align:middle line:84%
We can determine this
by looking at the number

00:04:16.260 --> 00:04:19.922 align:middle line:84%
after the username encapsulated
by the dollar symbol.

00:04:19.922 --> 00:04:21.339 align:middle line:84%
All right, so what
does this mean?

00:04:21.339 --> 00:04:25.110 align:middle line:84%
It means that Linux
systems and the way Linux

00:04:25.110 --> 00:04:29.100 align:middle line:84%
hashes or encrypts passwords
is very different than Windows.

00:04:29.100 --> 00:04:33.840 align:middle line:84%
Windows utilizes
NTLM, or LM hashing.

00:04:33.840 --> 00:04:35.940 align:middle line:84%
On Linux, you have
different types

00:04:35.940 --> 00:04:38.850 align:middle line:84%
of hashing algorithms
that are used based

00:04:38.850 --> 00:04:43.950 align:middle line:84%
on the actual release date
of that Linux distribution,

00:04:43.950 --> 00:04:46.210 align:middle line:84%
or that version of
the Linux kernel.

00:04:46.210 --> 00:04:51.900 align:middle line:84%
So Linux started off by
utilizing MD5 hashing, right?

00:04:51.900 --> 00:04:56.220 align:middle line:84%
And you would be able to
identify that this is the case.

00:04:56.220 --> 00:04:59.910 align:middle line:84%
If you opened up the etc shadow
file on a Linux target system

00:04:59.910 --> 00:05:03.660 align:middle line:84%
and you saw that after the
username for a specific user

00:05:03.660 --> 00:05:08.670 align:middle line:84%
account that the actual value
that's encapsulated by dollar

00:05:08.670 --> 00:05:14.730 align:middle line:84%
symbol is 1, that means
that the actual hash that

00:05:14.730 --> 00:05:17.460 align:middle line:84%
comes after that is going
to be encrypted, or is

00:05:17.460 --> 00:05:21.480 align:middle line:84%
encrypted or hashed using
the MD5 hashing algorithm.

00:05:21.480 --> 00:05:24.296 align:middle line:84%
And the same is repeated for
all the other algorithms.

00:05:24.296 --> 00:05:27.060 align:middle line:90%


00:05:27.060 --> 00:05:28.770 align:middle line:90%
So you have 1, 2, 5, and 6.

00:05:28.770 --> 00:05:31.290 align:middle line:84%
As the value
increases, the strength

00:05:31.290 --> 00:05:33.790 align:middle line:84%
of the hashing algorithm
also increases.

00:05:33.790 --> 00:05:36.120 align:middle line:84%
So you can see they
started off with MD5.

00:05:36.120 --> 00:05:37.590 align:middle line:90%
They then had Blowfish.

00:05:37.590 --> 00:05:42.300 align:middle line:84%
Then, of course, they
had SHA-256 and SHA-512.

00:05:42.300 --> 00:05:46.530 align:middle line:84%
So if we open up the shadow
file on a Linux system

00:05:46.530 --> 00:05:49.620 align:middle line:84%
that we have compromised,
and we identify

00:05:49.620 --> 00:05:57.240 align:middle line:84%
that the actual hash itself
is preceded by the value 6,

00:05:57.240 --> 00:06:00.540 align:middle line:84%
encapsulated by the
dollar symbol, then

00:06:00.540 --> 00:06:03.960 align:middle line:84%
that means that hash
is encrypted or hashed

00:06:03.960 --> 00:06:06.750 align:middle line:84%
in the SHA-512
hashing algorithm.

00:06:06.750 --> 00:06:11.070 align:middle line:84%
Now given the fact that this
is a very new course in regards

00:06:11.070 --> 00:06:17.700 align:middle line:84%
to cybersecurity
in general, we are

00:06:17.700 --> 00:06:21.150 align:middle line:84%
going to be exploring the
process of how to crack hashes,

00:06:21.150 --> 00:06:23.190 align:middle line:84%
or passwords that
have been hashed

00:06:23.190 --> 00:06:25.260 align:middle line:90%
using the SHA-512 algorithm.

00:06:25.260 --> 00:06:28.780 align:middle line:84%
So on most modern
Linux distributions,

00:06:28.780 --> 00:06:31.920 align:middle line:84%
the value 6, or the
hashing algorithm SHA-512

00:06:31.920 --> 00:06:34.410 align:middle line:84%
is going to be the one
that is used by default.

00:06:34.410 --> 00:06:36.990 align:middle line:84%
So it's actually quite
helpful to understand how

00:06:36.990 --> 00:06:42.220 align:middle line:90%
to crack the SHA-512 hashes.

00:06:42.220 --> 00:06:43.950 align:middle line:84%
Now of course,
just like Windows,

00:06:43.950 --> 00:06:45.750 align:middle line:84%
you need to take
into consideration

00:06:45.750 --> 00:06:48.990 align:middle line:84%
the strength of the password
that the user has created,

00:06:48.990 --> 00:06:51.210 align:middle line:84%
or the user
specified, because we

00:06:51.210 --> 00:06:53.880 align:middle line:84%
are going to be exploring how to
perform a brute force attack--

00:06:53.880 --> 00:06:56.340 align:middle line:84%
which really means
that we are going

00:06:56.340 --> 00:06:58.500 align:middle line:84%
to be using a word
list that contains

00:06:58.500 --> 00:07:01.710 align:middle line:84%
a list of commonly-used
passwords.

00:07:01.710 --> 00:07:04.590 align:middle line:84%
And all we're trying to
do is identify a match.

00:07:04.590 --> 00:07:06.600 align:middle line:84%
If there isn't a
match, then we have

00:07:06.600 --> 00:07:09.480 align:middle line:84%
to pretty much try
and find other ways

00:07:09.480 --> 00:07:11.460 align:middle line:84%
of generating a
word list that is

00:07:11.460 --> 00:07:15.780 align:middle line:84%
suitable or applicable to the
user account password hash

00:07:15.780 --> 00:07:17.100 align:middle line:90%
that we're trying to crack.

00:07:17.100 --> 00:07:20.430 align:middle line:84%
With that being said, this
video has a lab environment

00:07:20.430 --> 00:07:21.420 align:middle line:90%
attached to it.

00:07:21.420 --> 00:07:23.730 align:middle line:84%
And we're going to start
off by gaining access

00:07:23.730 --> 00:07:25.770 align:middle line:90%
to the target system.

00:07:25.770 --> 00:07:27.600 align:middle line:84%
After we do that,
I'll demonstrate

00:07:27.600 --> 00:07:30.510 align:middle line:84%
the process of dumping,
or essentially displaying

00:07:30.510 --> 00:07:34.110 align:middle line:84%
the contents of the etc
shadow file manually.

00:07:34.110 --> 00:07:38.010 align:middle line:84%
We'll then explore how we can
use a Metasploit framework post

00:07:38.010 --> 00:07:41.250 align:middle line:84%
exploitation module to
dump the hashes for us

00:07:41.250 --> 00:07:42.990 align:middle line:90%
and unshadow the files--

00:07:42.990 --> 00:07:44.580 align:middle line:90%
I'll explain what that is--

00:07:44.580 --> 00:07:47.137 align:middle line:84%
or on shadow the
hashes themselves.

00:07:47.137 --> 00:07:48.720 align:middle line:84%
Once that is done,
we can then explore

00:07:48.720 --> 00:07:51.000 align:middle line:90%
how we can crack the hash--

00:07:51.000 --> 00:07:54.630 align:middle line:84%
primarily, the root
user account hash--

00:07:54.630 --> 00:07:56.670 align:middle line:84%
with John the
Ripper and Hashcat.

00:07:56.670 --> 00:08:00.630 align:middle line:84%
So I'll be seeing you
in the lab environment.

00:08:00.630 --> 00:08:03.160 align:middle line:84%
All right, so I'm back
in the lab environment.

00:08:03.160 --> 00:08:06.080 align:middle line:84%
And the first step
is, of course, we're

00:08:06.080 --> 00:08:08.850 align:middle line:84%
going to involve identifying
the target IP address.

00:08:08.850 --> 00:08:11.370 align:middle line:84%
That can be done by
typing in ifconfig.

00:08:11.370 --> 00:08:13.470 align:middle line:84%
And if we take a look at
the interface ethernet 1,

00:08:13.470 --> 00:08:16.650 align:middle line:84%
we want to copy the value
here-- the inet value.

00:08:16.650 --> 00:08:19.150 align:middle line:84%
In your case, the subnet
is going to be different.

00:08:19.150 --> 00:08:22.770 align:middle line:84%
But your Kali Linux IP address,
or the Kali Linux system

00:08:22.770 --> 00:08:26.190 align:middle line:84%
should be on the second IP
address within this subnet.

00:08:26.190 --> 00:08:28.830 align:middle line:84%
The target IP address is
going to be on the third IP

00:08:28.830 --> 00:08:30.360 align:middle line:90%
address within the subnet.

00:08:30.360 --> 00:08:32.429 align:middle line:84%
All you need to do is
just copy this value

00:08:32.429 --> 00:08:34.559 align:middle line:84%
and change the 2
to a 3 at the end,

00:08:34.559 --> 00:08:36.730 align:middle line:84%
and that's the
target IP address.

00:08:36.730 --> 00:08:39.030 align:middle line:84%
So the next step,
of course, was going

00:08:39.030 --> 00:08:41.370 align:middle line:84%
to involve identifying the
vulnerable service that's

00:08:41.370 --> 00:08:42.700 align:middle line:90%
running on the target system.

00:08:42.700 --> 00:08:44.400 align:middle line:84%
So we'll perform a
quick service version

00:08:44.400 --> 00:08:48.690 align:middle line:84%
detection scan on 1,000 of
the most commonly used ports.

00:08:48.690 --> 00:08:52.110 align:middle line:84%
And we'll change the 2 to a
3 here, and I'll hit Enter.

00:08:52.110 --> 00:08:54.810 align:middle line:84%
And as you can see,
we have an FTP server

00:08:54.810 --> 00:08:57.990 align:middle line:84%
running on port 21, which
is the default FTP port.

00:08:57.990 --> 00:09:02.800 align:middle line:84%
And the service version
is ProFTPD version 1.3.3c.

00:09:02.800 --> 00:09:03.300 align:middle line:90%
All right.

00:09:03.300 --> 00:09:05.490 align:middle line:84%
So we can run a
searchsploit query here,

00:09:05.490 --> 00:09:07.080 align:middle line:84%
to try and identify
whether there

00:09:07.080 --> 00:09:10.470 align:middle line:84%
are any exploits pertinent
to this specific version

00:09:10.470 --> 00:09:12.130 align:middle line:90%
of ProFTPD.

00:09:12.130 --> 00:09:12.630 align:middle line:90%
All right.

00:09:12.630 --> 00:09:15.900 align:middle line:84%
So I'll just say,
searchsploit ProFTPD.

00:09:15.900 --> 00:09:19.560 align:middle line:84%
And we're looking
for version 1.3.3c.

00:09:19.560 --> 00:09:23.310 align:middle line:84%
And it looks like we have a
Metasploit framework exploit

00:09:23.310 --> 00:09:26.470 align:middle line:84%
module, so that is what
we're going to be using.

00:09:26.470 --> 00:09:29.910 align:middle line:84%
So before we do that, because
we're going to be making use

00:09:29.910 --> 00:09:32.070 align:middle line:90%
of a post-exploitation module--

00:09:32.070 --> 00:09:35.460 align:middle line:84%
and we are going to be saving
the credentials or hashes

00:09:35.460 --> 00:09:36.390 align:middle line:90%
that we dump--

00:09:36.390 --> 00:09:38.580 align:middle line:84%
we need to utilize,
or we need to start up

00:09:38.580 --> 00:09:42.120 align:middle line:84%
the PostgreSQL database
service, which will consequently

00:09:42.120 --> 00:09:44.940 align:middle line:84%
allow us to utilize the
Metasploit framework database.

00:09:44.940 --> 00:09:47.010 align:middle line:84%
So we'll say, service
PostgresSQL, start.

00:09:47.010 --> 00:09:50.640 align:middle line:90%


00:09:50.640 --> 00:09:54.358 align:middle line:84%
And then I'll say, MSF
console, once that is done.

00:09:54.358 --> 00:09:56.025 align:middle line:84%
And we'll give this
a couple of seconds.

00:09:56.025 --> 00:10:01.550 align:middle line:90%


00:10:01.550 --> 00:10:03.560 align:middle line:84%
I'm then going to set
up the global variable

00:10:03.560 --> 00:10:05.100 align:middle line:90%
for the rhost option.

00:10:05.100 --> 00:10:07.220 align:middle line:84%
So I'll set this
to the target IP.

00:10:07.220 --> 00:10:10.130 align:middle line:84%
It looks like I've copied
the actual module name there.

00:10:10.130 --> 00:10:12.110 align:middle line:84%
So I can just type
in, ifconfig, again,

00:10:12.110 --> 00:10:13.940 align:middle line:90%
from within MSF console--

00:10:13.940 --> 00:10:15.770 align:middle line:90%
and just copy the inet value.

00:10:15.770 --> 00:10:18.290 align:middle line:90%
And I'll say, setg rhosts.

00:10:18.290 --> 00:10:20.280 align:middle line:90%
And I'll specify the target IP.

00:10:20.280 --> 00:10:21.590 align:middle line:90%
I'll change the 2 to a 3.

00:10:21.590 --> 00:10:25.560 align:middle line:84%
So we're setting the rhosts
variable value globally

00:10:25.560 --> 00:10:27.740 align:middle line:84%
so that when we
load a module, we

00:10:27.740 --> 00:10:30.720 align:middle line:84%
don't need to set it every
time we load a new module.

00:10:30.720 --> 00:10:32.130 align:middle line:90%
So that is done.

00:10:32.130 --> 00:10:36.420 align:middle line:90%
We can then say search ProFTPD.

00:10:36.420 --> 00:10:38.140 align:middle line:90%
And this is the exploit here.

00:10:38.140 --> 00:10:43.800 align:middle line:84%
So it's ProFTPD version 1.3.3c,
backdoor command execution.

00:10:43.800 --> 00:10:45.420 align:middle line:84%
So I'll copy the
module name there.

00:10:45.420 --> 00:10:48.660 align:middle line:84%
I'll say, use--
paste that in there.

00:10:48.660 --> 00:10:51.010 align:middle line:84%
I'll show the options
for this module.

00:10:51.010 --> 00:10:53.940 align:middle line:84%
You can see that the target
IP, or the rhosts option

00:10:53.940 --> 00:10:56.250 align:middle line:90%
has already been set up for us.

00:10:56.250 --> 00:10:58.620 align:middle line:90%
And the target port is 21.

00:10:58.620 --> 00:10:59.640 align:middle line:90%
That's perfectly fine.

00:10:59.640 --> 00:11:01.170 align:middle line:90%
I can then type in, exploit.

00:11:01.170 --> 00:11:03.300 align:middle line:84%
This should provide me
with a command shell

00:11:03.300 --> 00:11:06.390 align:middle line:84%
session, which I will then
upgrade to a Meterpreter

00:11:06.390 --> 00:11:07.350 align:middle line:90%
session.

00:11:07.350 --> 00:11:09.570 align:middle line:84%
So it's going to send
the backdoor command,

00:11:09.570 --> 00:11:13.550 align:middle line:84%
and we should get a
command shell session.

00:11:13.550 --> 00:11:14.850 align:middle line:90%
All right, there we are.

00:11:14.850 --> 00:11:17.600 align:middle line:84%
Now, before we upgrade this
command shell session, which

00:11:17.600 --> 00:11:21.680 align:middle line:84%
is non-interactive, let us try
and dump or access the shadow

00:11:21.680 --> 00:11:22.380 align:middle line:90%
file.

00:11:22.380 --> 00:11:25.650 align:middle line:84%
So I'll say, bin bash
I. And you can see,

00:11:25.650 --> 00:11:27.540 align:middle line:84%
we currently have root
access on the target

00:11:27.540 --> 00:11:30.630 align:middle line:84%
system, which means we do not
need to elevate our privileges.

00:11:30.630 --> 00:11:36.500 align:middle line:84%
So if I say, get
etc shadow, you can

00:11:36.500 --> 00:11:38.660 align:middle line:84%
see they're the only user
account on the system

00:11:38.660 --> 00:11:40.560 align:middle line:90%
is the root user account.

00:11:40.560 --> 00:11:41.060 align:middle line:90%
All right.

00:11:41.060 --> 00:11:45.780 align:middle line:84%
So essentially what you need
to do is copy this value here.

00:11:45.780 --> 00:11:49.370 align:middle line:84%
Now as I mentioned
in the slides,

00:11:49.370 --> 00:11:52.250 align:middle line:84%
the shadow file contains
the username, and then

00:11:52.250 --> 00:11:54.780 align:middle line:84%
the value of the
hashing algorithm.

00:11:54.780 --> 00:11:59.270 align:middle line:84%
So you can see that the value
is encapsulated by the dollar

00:11:59.270 --> 00:12:00.090 align:middle line:90%
symbol.

00:12:00.090 --> 00:12:03.530 align:middle line:84%
So if it's 6, then that means
that the hashing algorithm

00:12:03.530 --> 00:12:05.120 align:middle line:90%
is SHA-512.

00:12:05.120 --> 00:12:07.910 align:middle line:84%
So that means that
the root user password

00:12:07.910 --> 00:12:12.060 align:middle line:84%
has been encrypted or hashed
using the SHA-512 algorithm.

00:12:12.060 --> 00:12:12.560 align:middle line:90%
All right.

00:12:12.560 --> 00:12:16.950 align:middle line:84%
So that's a very important thing
to take into consideration,

00:12:16.950 --> 00:12:20.180 align:middle line:84%
especially when you're cracking
Linux user account password

00:12:20.180 --> 00:12:21.260 align:middle line:90%
hashes.

00:12:21.260 --> 00:12:23.700 align:middle line:84%
All right, we'll get to
this in a few seconds.

00:12:23.700 --> 00:12:26.040 align:middle line:84%
So you can essentially
just copy this value.

00:12:26.040 --> 00:12:28.430 align:middle line:84%
Now, the way you copy
it is very important.

00:12:28.430 --> 00:12:31.640 align:middle line:84%
And as I said, there's a
Metasploit framework module

00:12:31.640 --> 00:12:37.220 align:middle line:84%
that can be used to unhash, or
unshadow this particular hash.

00:12:37.220 --> 00:12:41.100 align:middle line:84%
And it'll save that
for you in a text file.

00:12:41.100 --> 00:12:44.640 align:middle line:84%
So what I'll do is I'll just
put this in the background.

00:12:44.640 --> 00:12:46.560 align:middle line:84%
So I'll say, background
this session.

00:12:46.560 --> 00:12:48.050 align:middle line:84%
And if I list out
my sessions, you

00:12:48.050 --> 00:12:51.320 align:middle line:84%
can see I have the command shell
session, which I will upgrade

00:12:51.320 --> 00:12:52.730 align:middle line:90%
to a Meterpreter session.

00:12:52.730 --> 00:12:54.680 align:middle line:90%
So I'll say, sessions upgrade 1.

00:12:54.680 --> 00:12:57.380 align:middle line:90%


00:12:57.380 --> 00:12:58.880 align:middle line:84%
We'll give this a
couple of seconds.

00:12:58.880 --> 00:13:17.630 align:middle line:90%


00:13:17.630 --> 00:13:18.130 align:middle line:90%
All right.

00:13:18.130 --> 00:13:21.190 align:middle line:84%
So it looks like we've
obtained a Meterpreter session.

00:13:21.190 --> 00:13:24.430 align:middle line:84%
Don't worry if you get the
actual error here telling you

00:13:24.430 --> 00:13:27.340 align:middle line:84%
that it is unable to execute
the following command.

00:13:27.340 --> 00:13:29.290 align:middle line:84%
You can see we have
the Meterpreter

00:13:29.290 --> 00:13:31.240 align:middle line:90%
session with an ID of 2.

00:13:31.240 --> 00:13:32.930 align:middle line:90%
So keep that in mind.

00:13:32.930 --> 00:13:33.430 align:middle line:90%
All right.

00:13:33.430 --> 00:13:37.780 align:middle line:84%
So we can now utilize the
hash dump Metasploit framework

00:13:37.780 --> 00:13:39.910 align:middle line:90%
post-exploitation module.

00:13:39.910 --> 00:13:43.930 align:middle line:84%
And this is essentially
the same as the hash dump

00:13:43.930 --> 00:13:45.100 align:middle line:90%
Meterpreter command.

00:13:45.100 --> 00:13:47.690 align:middle line:84%
But this is pertinent
to Linux systems.

00:13:47.690 --> 00:13:50.490 align:middle line:90%
So I'll say, search hashdump.

00:13:50.490 --> 00:13:54.020 align:middle line:84%
And we are looking for the
post-Linux gather hashdump

00:13:54.020 --> 00:13:54.520 align:middle line:90%
module.

00:13:54.520 --> 00:13:56.320 align:middle line:90%
So I'll copy that there.

00:13:56.320 --> 00:13:57.840 align:middle line:90%
And I'll say, use--

00:13:57.840 --> 00:14:00.540 align:middle line:84%
paste that in there,
if I show the options.

00:14:00.540 --> 00:14:03.090 align:middle line:84%
Because this is a
post-exploitation module,

00:14:03.090 --> 00:14:05.470 align:middle line:84%
I only need to set
the session ID.

00:14:05.470 --> 00:14:10.030 align:middle line:84%
So we will set the session ID
for the Meterpreter session,

00:14:10.030 --> 00:14:11.130 align:middle line:90%
which is 2.

00:14:11.130 --> 00:14:12.570 align:middle line:90%
This will work best.

00:14:12.570 --> 00:14:15.060 align:middle line:90%
And we'll just hit Run.

00:14:15.060 --> 00:14:17.520 align:middle line:84%
I'll just zoom out, because
a lot of information

00:14:17.520 --> 00:14:19.150 align:middle line:90%
is going to be displayed here.

00:14:19.150 --> 00:14:20.610 align:middle line:90%
So I'll say, Run.

00:14:20.610 --> 00:14:23.460 align:middle line:84%
And you can see that it
dumps the actual root

00:14:23.460 --> 00:14:26.550 align:middle line:84%
user account password
hash from the shadow file.

00:14:26.550 --> 00:14:30.600 align:middle line:84%
And then it'll tell you that
there is an unshadowed password

00:14:30.600 --> 00:14:31.140 align:middle line:90%
file.

00:14:31.140 --> 00:14:33.930 align:middle line:84%
And it is stored
under the current user

00:14:33.930 --> 00:14:37.530 align:middle line:84%
directory, which is root,
under a directory called MS4,

00:14:37.530 --> 00:14:38.610 align:middle line:90%
under loot.

00:14:38.610 --> 00:14:42.210 align:middle line:84%
And this is the name of the
file that contains the hash.

00:14:42.210 --> 00:14:46.510 align:middle line:84%
So we can actually cat out the
contents of this text file.

00:14:46.510 --> 00:14:48.120 align:middle line:90%
So I'll say, cat--

00:14:48.120 --> 00:14:50.360 align:middle line:90%
paste that in there.

00:14:50.360 --> 00:14:53.830 align:middle line:84%
And you can see this is the
format that this module has

00:14:53.830 --> 00:14:55.370 align:middle line:90%
saved the hash in.

00:14:55.370 --> 00:14:57.550 align:middle line:84%
So in this case, there
are no major changes

00:14:57.550 --> 00:14:58.900 align:middle line:90%
made to the format.

00:14:58.900 --> 00:15:02.380 align:middle line:84%
And in this case,
this particular file

00:15:02.380 --> 00:15:04.510 align:middle line:84%
contains the hash
that we can use,

00:15:04.510 --> 00:15:06.940 align:middle line:90%
or that we can crack directly.

00:15:06.940 --> 00:15:09.640 align:middle line:84%
So now that is done,
what we want to do

00:15:09.640 --> 00:15:14.110 align:middle line:84%
is just take note of
this particular path

00:15:14.110 --> 00:15:16.810 align:middle line:84%
for the actual file
that contains the hash,

00:15:16.810 --> 00:15:18.850 align:middle line:84%
as this is what we're
going to be using.

00:15:18.850 --> 00:15:21.070 align:middle line:84%
Alternatively, you can
just copy this value

00:15:21.070 --> 00:15:25.040 align:middle line:84%
and save it on your desktop
in a file called hashes.txt.

00:15:25.040 --> 00:15:25.540 align:middle line:90%
All right.

00:15:25.540 --> 00:15:28.060 align:middle line:84%
So what we are
going to do now is

00:15:28.060 --> 00:15:31.360 align:middle line:84%
we are going to exit from the
Metasploit framework console.

00:15:31.360 --> 00:15:33.460 align:middle line:84%
And that's because
we are ready to begin

00:15:33.460 --> 00:15:37.460 align:middle line:84%
cracking this particular root
user account password hash.

00:15:37.460 --> 00:15:39.520 align:middle line:90%
So I'll say, Exit, Yes.

00:15:39.520 --> 00:15:43.270 align:middle line:84%
And that is going to
terminate all the sessions.

00:15:43.270 --> 00:15:46.480 align:middle line:84%
Now that is done, we are
going to be utilizing

00:15:46.480 --> 00:15:48.200 align:middle line:90%
the rockyou word list.

00:15:48.200 --> 00:15:50.630 align:middle line:84%
So I'm going to
just decompress it.

00:15:50.630 --> 00:15:55.030 align:middle line:84%
So user share, wordlist,
and rockyou.txt.

00:15:55.030 --> 00:15:57.340 align:middle line:84%
And you can see that
it is a G zip archive.

00:15:57.340 --> 00:15:59.050 align:middle line:84%
So we are essentially
decompressing it,

00:15:59.050 --> 00:16:00.970 align:middle line:90%
or unarchiving it first.

00:16:00.970 --> 00:16:02.020 align:middle line:90%
So I'll hit Enter.

00:16:02.020 --> 00:16:03.680 align:middle line:90%
That is going to decompress it.

00:16:03.680 --> 00:16:05.750 align:middle line:90%
And we should have the TXT file.

00:16:05.750 --> 00:16:06.250 align:middle line:90%
All right.

00:16:06.250 --> 00:16:09.640 align:middle line:90%
So let's get started with John.

00:16:09.640 --> 00:16:14.410 align:middle line:84%
So if you want to crack a Linux
password hashed with John,

00:16:14.410 --> 00:16:16.780 align:middle line:84%
the most important
piece of information

00:16:16.780 --> 00:16:18.670 align:middle line:90%
is the hashing algorithm used.

00:16:18.670 --> 00:16:22.180 align:middle line:84%
In this case, the hashing
algorithm is SHA-512.

00:16:22.180 --> 00:16:24.460 align:middle line:84%
So that means that
we need to specify

00:16:24.460 --> 00:16:31.050 align:middle line:90%
the format as SHA-512 crypt.

00:16:31.050 --> 00:16:32.940 align:middle line:90%
And I'll type that in correctly.

00:16:32.940 --> 00:16:35.310 align:middle line:90%
So format is SHA-512 crypt.

00:16:35.310 --> 00:16:40.470 align:middle line:84%
We then specify the
path to the actual file

00:16:40.470 --> 00:16:41.790 align:middle line:90%
that contains the hash.

00:16:41.790 --> 00:16:44.580 align:middle line:84%
So in this case, I'll
just paste the path

00:16:44.580 --> 00:16:46.690 align:middle line:90%
that we actually copied here.

00:16:46.690 --> 00:16:50.670 align:middle line:84%
So the hash file is stored
under the root MS4 loot.

00:16:50.670 --> 00:16:53.440 align:middle line:84%
And then, this is the
actual file name here.

00:16:53.440 --> 00:16:57.270 align:middle line:84%
So it has the target IP address
and it says, Linux hashes--

00:16:57.270 --> 00:17:01.710 align:middle line:84%
random piece of data
there-- and .txt.

00:17:01.710 --> 00:17:04.630 align:middle line:84%
We can then specify the word
list that we would like to use.

00:17:04.630 --> 00:17:09.679 align:middle line:84%
So we can say hyphen hyphen word
list is equal to user, share,

00:17:09.679 --> 00:17:13.420 align:middle line:90%
wordlist, rockyou.txt.

00:17:13.420 --> 00:17:13.920 align:middle line:90%
All right.

00:17:13.920 --> 00:17:16.079 align:middle line:90%
So we'll hit, Enter.

00:17:16.079 --> 00:17:18.329 align:middle line:84%
You can see that it
loaded one password hash.

00:17:18.329 --> 00:17:22.650 align:middle line:84%
And it correctly identifies
that this is a Linux password

00:17:22.650 --> 00:17:25.650 align:middle line:90%
hash encrypted in SHA-512.

00:17:25.650 --> 00:17:28.762 align:middle line:84%
It's then going to give you an
overview as to what it's doing.

00:17:28.762 --> 00:17:30.720 align:middle line:84%
So we're going to give
this a couple of seconds

00:17:30.720 --> 00:17:32.170 align:middle line:90%
to a couple of minutes.

00:17:32.170 --> 00:17:35.820 align:middle line:84%
Remember, this is the strongest
hashing algorithm out there

00:17:35.820 --> 00:17:38.910 align:middle line:84%
and implemented in
newer versions of Linux.

00:17:38.910 --> 00:17:42.070 align:middle line:84%
So we'll just give it
a couple of seconds.

00:17:42.070 --> 00:17:42.570 align:middle line:90%
All right.

00:17:42.570 --> 00:17:45.450 align:middle line:84%
So after about 30
seconds, it actually

00:17:45.450 --> 00:17:47.160 align:middle line:90%
is able to crack the hash.

00:17:47.160 --> 00:17:52.830 align:middle line:84%
And it tells us that the actual
hash for the root user password

00:17:52.830 --> 00:17:54.000 align:middle line:90%
is just password.

00:17:54.000 --> 00:17:55.380 align:middle line:90%
So it's a very simple password.

00:17:55.380 --> 00:17:58.470 align:middle line:84%
And the reason this
was done is, again,

00:17:58.470 --> 00:18:01.140 align:middle line:84%
we are primarily focused
on the techniques,

00:18:01.140 --> 00:18:03.780 align:middle line:84%
as opposed to the
actual process.

00:18:03.780 --> 00:18:05.550 align:middle line:84%
Now if the password
is more complex

00:18:05.550 --> 00:18:08.910 align:middle line:84%
and it essentially
includes numbers,

00:18:08.910 --> 00:18:10.530 align:middle line:84%
uppercase and
lowercase characters,

00:18:10.530 --> 00:18:12.210 align:middle line:84%
then it's going to
take a longer time.

00:18:12.210 --> 00:18:13.950 align:middle line:84%
But again, it's
important to remember

00:18:13.950 --> 00:18:18.750 align:middle line:84%
that this is a brute force
attack, where we are utilizing

00:18:18.750 --> 00:18:21.120 align:middle line:84%
a word list or a
dictionary that contains

00:18:21.120 --> 00:18:23.460 align:middle line:84%
a list of commonly-used
passwords.

00:18:23.460 --> 00:18:26.130 align:middle line:84%
So that is what we're
checking the hash against.

00:18:26.130 --> 00:18:29.000 align:middle line:84%
So it's important to take
that into consideration.

00:18:29.000 --> 00:18:29.500 align:middle line:90%
All right.

00:18:29.500 --> 00:18:33.540 align:middle line:84%
So that is how to crack
Linux user account password

00:18:33.540 --> 00:18:36.130 align:middle line:90%
hashes with John the Ripper.

00:18:36.130 --> 00:18:38.710 align:middle line:84%
Now let's take a look at how
this can be done with Hashcat.

00:18:38.710 --> 00:18:39.210 align:middle line:90%
All right.

00:18:39.210 --> 00:18:41.040 align:middle line:84%
So from the previous
section, where

00:18:41.040 --> 00:18:44.640 align:middle line:84%
we are cracking Windows
hashes, I essentially

00:18:44.640 --> 00:18:46.860 align:middle line:84%
went through how
to utilize Hashcat.

00:18:46.860 --> 00:18:50.740 align:middle line:84%
And the most important thing
to identify, as I mentioned,

00:18:50.740 --> 00:18:52.300 align:middle line:90%
is the actual hash mode.

00:18:52.300 --> 00:18:54.450 align:middle line:84%
So it can open up the
Hashcat help menu,

00:18:54.450 --> 00:18:56.160 align:middle line:90%
but we can grip this.

00:18:56.160 --> 00:18:57.660 align:middle line:84%
And I'm going to
limit it, or I'm

00:18:57.660 --> 00:19:01.050 align:middle line:84%
going to essentially
look for the hash mode

00:19:01.050 --> 00:19:07.170 align:middle line:84%
1800, which should essentially
correspond to SHA-512.

00:19:07.170 --> 00:19:10.680 align:middle line:84%
So you can see
1800 SHA-512 crypt.

00:19:10.680 --> 00:19:13.720 align:middle line:84%
And again, it tells
you how to identify it.

00:19:13.720 --> 00:19:17.110 align:middle line:84%
So this is for the Unix or
Linux operating systems.

00:19:17.110 --> 00:19:19.440 align:middle line:84%
So in order to perform
a brute force attack,

00:19:19.440 --> 00:19:23.420 align:middle line:90%
we can say hashcat a3.

00:19:23.420 --> 00:19:26.030 align:middle line:84%
And then we specify
the mode as 1800.

00:19:26.030 --> 00:19:27.240 align:middle line:90%
So that's the format--

00:19:27.240 --> 00:19:28.700 align:middle line:90%
SHA-512.

00:19:28.700 --> 00:19:32.240 align:middle line:84%
And then we specify or
paste in the actual path

00:19:32.240 --> 00:19:34.110 align:middle line:84%
to the file that
contains the hashes.

00:19:34.110 --> 00:19:37.080 align:middle line:84%
So in this case, I'll
just copy it from up here.

00:19:37.080 --> 00:19:39.350 align:middle line:90%
So it's on the root.

00:19:39.350 --> 00:19:41.420 align:middle line:84%
There we are So
I'll just say, copy,

00:19:41.420 --> 00:19:42.980 align:middle line:90%
and I'll paste that in there.

00:19:42.980 --> 00:19:44.880 align:middle line:84%
We then need to
specify the word list.

00:19:44.880 --> 00:19:51.500 align:middle line:84%
So I can say user, share,
wordlists, rockyou.txt.

00:19:51.500 --> 00:19:52.497 align:middle line:90%
Hit Enter.

00:19:52.497 --> 00:19:54.080 align:middle line:84%
It's going to take
a couple of seconds

00:19:54.080 --> 00:19:56.630 align:middle line:90%
to generate the bitmap tables.

00:19:56.630 --> 00:19:59.930 align:middle line:84%
After that it should
initialize, and it'll

00:19:59.930 --> 00:20:03.060 align:middle line:90%
begin the actual brute force.

00:20:03.060 --> 00:20:05.040 align:middle line:84%
All right, so give it
a few seconds here.

00:20:05.040 --> 00:20:08.390 align:middle line:90%


00:20:08.390 --> 00:20:08.890 align:middle line:90%
All right.

00:20:08.890 --> 00:20:10.960 align:middle line:90%
So it has begun cracking.

00:20:10.960 --> 00:20:13.450 align:middle line:84%
And you can see
that it successfully

00:20:13.450 --> 00:20:15.140 align:middle line:90%
cracked the hash here.

00:20:15.140 --> 00:20:17.320 align:middle line:84%
So it tells you the
actual hash value,

00:20:17.320 --> 00:20:20.080 align:middle line:84%
and it then provides you with
the password here-- the clear

00:20:20.080 --> 00:20:20.830 align:middle line:90%
text password.

00:20:20.830 --> 00:20:24.010 align:middle line:84%
So again, we've been able to
crack the Linux user account

00:20:24.010 --> 00:20:27.370 align:middle line:84%
password hash with John
the Ripper and, of course,

00:20:27.370 --> 00:20:28.360 align:middle line:90%
with Hashcat.

00:20:28.360 --> 00:20:31.780 align:middle line:84%
So that is going to conclude
the practical demonstration

00:20:31.780 --> 00:20:34.720 align:middle line:90%
side of this video.

00:20:34.720 --> 00:20:35.220 align:middle line:90%
All right.

00:20:35.220 --> 00:20:38.280 align:middle line:84%
So that concludes the
Linux Hash Cracking

00:20:38.280 --> 00:20:40.360 align:middle line:90%
section of this course.

00:20:40.360 --> 00:20:43.390 align:middle line:84%
By the end of this
section, or by this point,

00:20:43.390 --> 00:20:48.060 align:middle line:84%
you should be able to dump Linux
password hashes both manually

00:20:48.060 --> 00:20:49.530 align:middle line:84%
and automatically,
and you should

00:20:49.530 --> 00:20:51.540 align:middle line:84%
have a good
understanding of how you

00:20:51.540 --> 00:20:55.410 align:middle line:84%
can crack these hashes with
John the Ripper or Hashcat.

00:20:55.410 --> 00:20:57.570 align:middle line:84%
In the next section, we're
going to be exploring

00:20:57.570 --> 00:21:00.270 align:middle line:84%
the process of pivoting
from one system

00:21:00.270 --> 00:21:03.420 align:middle line:84%
that you have compromised
to other systems or hosts

00:21:03.420 --> 00:21:06.900 align:middle line:84%
on the internal network that
the system you've compromised

00:21:06.900 --> 00:21:07.660 align:middle line:90%
is on.

00:21:07.660 --> 00:21:11.480 align:middle line:84%
So I'll be seeing you
in the next video.