WEBVTT

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


00:00:05.324 --> 00:00:08.712 align:middle line:90%
[MUSIC PLAYING]

00:00:08.712 --> 00:00:10.170 align:middle line:90%


00:00:10.170 --> 00:00:13.680 align:middle line:84%
Exploiting SSH-- now that
we have taken a look at how

00:00:13.680 --> 00:00:17.760 align:middle line:84%
to exploit the Shellshock
vulnerability as well as FTP,

00:00:17.760 --> 00:00:20.520 align:middle line:90%
let's turn our attention to SSH.

00:00:20.520 --> 00:00:22.260 align:middle line:90%
All right, so what is SSH?

00:00:22.260 --> 00:00:24.480 align:middle line:90%
SSH stands for Secure Shell.

00:00:24.480 --> 00:00:26.760 align:middle line:84%
It is a remote
administration protocol

00:00:26.760 --> 00:00:29.430 align:middle line:84%
that offers encryption and
is the natural successor

00:00:29.430 --> 00:00:30.360 align:middle line:90%
to Telnet.

00:00:30.360 --> 00:00:32.790 align:middle line:84%
So whenever you
have a Linux system,

00:00:32.790 --> 00:00:37.170 align:middle line:84%
or more specifically a Linux
server set up primarily

00:00:37.170 --> 00:00:40.900 align:middle line:84%
in a server farm maybe
halfway across the world,

00:00:40.900 --> 00:00:42.820 align:middle line:90%
how do you access that system?

00:00:42.820 --> 00:00:45.990 align:middle line:84%
Well, that access is
facilitated through the use

00:00:45.990 --> 00:00:48.000 align:middle line:90%
of a protocol called SSH.

00:00:48.000 --> 00:00:51.240 align:middle line:84%
So this is something that
you will find pretty much

00:00:51.240 --> 00:00:54.510 align:middle line:84%
on I would say 90% of Linux
systems or Linux servers,

00:00:54.510 --> 00:00:56.760 align:middle line:84%
for that matter,
and it is typically

00:00:56.760 --> 00:01:00.000 align:middle line:84%
used for remote access
to servers and systems.

00:01:00.000 --> 00:01:02.860 align:middle line:84%
And it's frequently
used for that matter.

00:01:02.860 --> 00:01:06.520 align:middle line:84%
Now, SSH utilizes TCP
port 22 by default.

00:01:06.520 --> 00:01:09.180 align:middle line:84%
However, like other services,
it can be configured

00:01:09.180 --> 00:01:11.700 align:middle line:90%
to use any other open TCP port.

00:01:11.700 --> 00:01:13.440 align:middle line:84%
So many administrators
have actually

00:01:13.440 --> 00:01:15.480 align:middle line:84%
been changing the
default TCP port

00:01:15.480 --> 00:01:18.870 align:middle line:84%
and have been running SSH
on different ports in a bid

00:01:18.870 --> 00:01:21.870 align:middle line:84%
to actually prevent attackers
from exploiting the service

00:01:21.870 --> 00:01:24.690 align:middle line:84%
or from performing a
brute-force attack.

00:01:24.690 --> 00:01:28.350 align:middle line:84%
Now, in order to understand
the types of attack vectors

00:01:28.350 --> 00:01:31.470 align:middle line:84%
in regards to SSH that
we can utilize in order

00:01:31.470 --> 00:01:34.230 align:middle line:84%
to gain access, we
need to understand

00:01:34.230 --> 00:01:37.680 align:middle line:84%
the actual forms of
authentication in terms of SSH.

00:01:37.680 --> 00:01:42.220 align:middle line:84%
All right, so SSH authentication
can be configured in two ways.

00:01:42.220 --> 00:01:44.730 align:middle line:84%
Number one is the standard
username and password

00:01:44.730 --> 00:01:48.600 align:middle line:84%
authentication, whereby you
can authenticate to the system

00:01:48.600 --> 00:01:52.530 align:middle line:84%
by providing legitimate
user account credentials, so

00:01:52.530 --> 00:01:54.180 align:middle line:90%
the username and password.

00:01:54.180 --> 00:01:56.350 align:middle line:84%
And then, you have
key-based authentication,

00:01:56.350 --> 00:01:59.670 align:middle line:84%
which essentially requires
you to have a private key.

00:01:59.670 --> 00:02:01.590 align:middle line:84%
And, of course,
key-based authentication

00:02:01.590 --> 00:02:03.810 align:middle line:84%
involves the use
of two key pairs

00:02:03.810 --> 00:02:07.320 align:middle line:84%
or rather a key pair of a
public key and a private key,

00:02:07.320 --> 00:02:09.990 align:middle line:84%
whereby the public
key is on the server

00:02:09.990 --> 00:02:12.750 align:middle line:84%
and the private key is
given to the person who

00:02:12.750 --> 00:02:16.680 align:middle line:84%
is going to essentially remotely
access the system via SSH.

00:02:16.680 --> 00:02:19.320 align:middle line:84%
And within key-based
authentication,

00:02:19.320 --> 00:02:21.630 align:middle line:84%
there is no username
and password.

00:02:21.630 --> 00:02:26.670 align:middle line:84%
You essentially log in
to the target system

00:02:26.670 --> 00:02:28.890 align:middle line:84%
by providing the
actual private key,

00:02:28.890 --> 00:02:31.120 align:middle line:84%
and only one person
has the private key.

00:02:31.120 --> 00:02:33.120 align:middle line:84%
So this is something
that really isn't

00:02:33.120 --> 00:02:35.400 align:middle line:84%
feasible to attack
unless you get

00:02:35.400 --> 00:02:37.830 align:middle line:84%
your hands on a
private key, so we

00:02:37.830 --> 00:02:40.680 align:middle line:84%
are going to be focusing on
the process of performing

00:02:40.680 --> 00:02:41.580 align:middle line:90%
a brute-force.

00:02:41.580 --> 00:02:43.380 align:middle line:84%
Now, the great
thing about SSH is

00:02:43.380 --> 00:02:45.360 align:middle line:84%
because it is a
remote administration

00:02:45.360 --> 00:02:47.790 align:middle line:84%
protocol or a remote
access protocol,

00:02:47.790 --> 00:02:50.610 align:middle line:84%
it means that if we get
legitimate credentials

00:02:50.610 --> 00:02:53.430 align:middle line:84%
through a brute-force,
we can essentially

00:02:53.430 --> 00:02:57.330 align:middle line:84%
gain access to the target system
and obtain a full blown shell.

00:02:57.330 --> 00:03:00.480 align:middle line:84%
So we don't really need to
get a Meterpreter session.

00:03:00.480 --> 00:03:02.490 align:middle line:84%
You can if you want to,
but this will actually

00:03:02.490 --> 00:03:04.860 align:middle line:84%
give us access to
the target system,

00:03:04.860 --> 00:03:07.410 align:middle line:84%
of course, with the privileges
associated with the user

00:03:07.410 --> 00:03:10.800 align:middle line:84%
account that we are able to
obtain through the brute-force.

00:03:10.800 --> 00:03:14.490 align:middle line:84%
All right, now, as
I said, SSH really

00:03:14.490 --> 00:03:16.890 align:middle line:84%
can be configured to be
really, really secure,

00:03:16.890 --> 00:03:19.980 align:middle line:84%
and that typically will involve
key-based authentication.

00:03:19.980 --> 00:03:24.060 align:middle line:84%
But in most cases, many
individuals and small companies

00:03:24.060 --> 00:03:27.310 align:middle line:84%
still utilize username and
password authentication,

00:03:27.310 --> 00:03:29.790 align:middle line:84%
so this attack is
very, very feasible.

00:03:29.790 --> 00:03:32.160 align:middle line:84%
Now, I have covered the
process of exploiting

00:03:32.160 --> 00:03:35.490 align:middle line:84%
inherent vulnerabilities within
the specific version of SSH

00:03:35.490 --> 00:03:38.430 align:middle line:84%
that's running on a target
in my Metasploit course,

00:03:38.430 --> 00:03:40.600 align:middle line:84%
so you can actually check
that out for yourself.

00:03:40.600 --> 00:03:43.560 align:middle line:84%
In this case, we are going
to be focusing on performing

00:03:43.560 --> 00:03:45.030 align:middle line:90%
a brute-force attack.

00:03:45.030 --> 00:03:47.790 align:middle line:84%
All right, so let's get
started with the practical side

00:03:47.790 --> 00:03:48.630 align:middle line:90%
of this video.

00:03:48.630 --> 00:03:51.960 align:middle line:84%
This lab or this video already
has a lab environment attached

00:03:51.960 --> 00:03:53.790 align:middle line:84%
to it, so all you need
to do is fire it up,

00:03:53.790 --> 00:03:56.190 align:middle line:84%
and you can follow along
with the techniques

00:03:56.190 --> 00:03:57.510 align:middle line:90%
that I'm about to highlight.

00:03:57.510 --> 00:04:02.170 align:middle line:84%
So I'll see you within
the lab environment.

00:04:02.170 --> 00:04:04.730 align:middle line:84%
All right, so I'm back
within the lab environment.

00:04:04.730 --> 00:04:06.550 align:middle line:84%
And within this lab
environment, you

00:04:06.550 --> 00:04:09.590 align:middle line:84%
will not be provided with
a graphical user interface.

00:04:09.590 --> 00:04:12.100 align:middle line:84%
You will just be provided
with the terminal.

00:04:12.100 --> 00:04:15.820 align:middle line:84%
So the first step will involve
identifying the target IP

00:04:15.820 --> 00:04:17.680 align:middle line:84%
address, which, of
course, you can identify

00:04:17.680 --> 00:04:20.980 align:middle line:84%
by typing in ifconfig and
taking a look at the IP

00:04:20.980 --> 00:04:24.400 align:middle line:84%
or the subnet attached to
the interface ethernet1.

00:04:24.400 --> 00:04:27.730 align:middle line:84%
And, of course, in your case,
this subnet will be different.

00:04:27.730 --> 00:04:29.980 align:middle line:84%
The target IP is
always on the third IP

00:04:29.980 --> 00:04:32.380 align:middle line:84%
address within the subnet,
so all you need to do

00:04:32.380 --> 00:04:34.420 align:middle line:90%
is just change the 2 into a 3.

00:04:34.420 --> 00:04:38.000 align:middle line:84%
So I'm just going to copy
this here, and there we are.

00:04:38.000 --> 00:04:39.820 align:middle line:84%
And we can then clear
that out, and we

00:04:39.820 --> 00:04:41.500 align:middle line:84%
can perform an
Nmap scan in order

00:04:41.500 --> 00:04:44.920 align:middle line:84%
to identify or to
confirm whether or not we

00:04:44.920 --> 00:04:46.780 align:middle line:90%
have SSH running on the target.

00:04:46.780 --> 00:04:49.390 align:middle line:84%
So I'll paste in the
target IP, and remember

00:04:49.390 --> 00:04:51.460 align:middle line:90%
to change the 2 into a 3.

00:04:51.460 --> 00:04:53.230 align:middle line:90%
And I'll hit Enter.

00:04:53.230 --> 00:04:53.930 align:middle line:90%
There we are.

00:04:53.930 --> 00:04:56.830 align:middle line:84%
We can see the scan is complete
in a relatively short amount

00:04:56.830 --> 00:04:57.620 align:middle line:90%
of time.

00:04:57.620 --> 00:05:00.080 align:middle line:84%
And we can see that we have
SSH running on port 22.

00:05:00.080 --> 00:05:02.080 align:middle line:84%
That's very important,
so it has been configured

00:05:02.080 --> 00:05:03.640 align:middle line:90%
to run on the default port.

00:05:03.640 --> 00:05:08.290 align:middle line:84%
And the service version
is OpenSSH 7.9p1 Ubuntu,

00:05:08.290 --> 00:05:12.130 align:middle line:84%
so we have gotten a basic
or generic idea as to what

00:05:12.130 --> 00:05:14.140 align:middle line:84%
distribution is
running on the target.

00:05:14.140 --> 00:05:17.950 align:middle line:84%
And this specific version of
OpenSSH really isn't vulnerable

00:05:17.950 --> 00:05:21.980 align:middle line:84%
to any inherent vulnerability
or rather cannot be exploited

00:05:21.980 --> 00:05:25.550 align:middle line:84%
directly, so we will have to
perform a brute-force attack.

00:05:25.550 --> 00:05:27.940 align:middle line:84%
So in order to perform
the brute-force attack,

00:05:27.940 --> 00:05:30.070 align:middle line:84%
we are again just
going to utilize Hydra,

00:05:30.070 --> 00:05:32.520 align:middle line:90%
so I'm going to say hydra.

00:05:32.520 --> 00:05:35.340 align:middle line:84%
And, of course, as we did
with the FTP brute-force,

00:05:35.340 --> 00:05:37.260 align:middle line:90%
I'm just going to zoom in here.

00:05:37.260 --> 00:05:40.327 align:middle line:84%
And we can specify
the actual word

00:05:40.327 --> 00:05:42.660 align:middle line:84%
list that contains the usernames
that we want to perform

00:05:42.660 --> 00:05:43.980 align:middle line:90%
the brute-force with.

00:05:43.980 --> 00:05:47.550 align:middle line:84%
In this case, the word list is
under user, share, Metasploit

00:05:47.550 --> 00:05:48.360 align:middle line:90%
framework.

00:05:48.360 --> 00:05:50.580 align:middle line:84%
And, of course, in
your case or whenever

00:05:50.580 --> 00:05:53.340 align:middle line:84%
you're performing a penetration
test, feel free to change this

00:05:53.340 --> 00:05:56.730 align:middle line:84%
or to use whichever
ones are actually

00:05:56.730 --> 00:05:59.034 align:middle line:84%
applicable to your
particular case.

00:05:59.034 --> 00:06:02.010 align:middle line:84%
So user share Metasploit
framework data

00:06:02.010 --> 00:06:05.970 align:middle line:84%
wordlists and common
underscore users dot txt.

00:06:05.970 --> 00:06:09.240 align:middle line:84%
And then, for the password
or the password list,

00:06:09.240 --> 00:06:13.260 align:middle line:84%
that is again going to be under
user share Metasploit framework

00:06:13.260 --> 00:06:16.350 align:middle line:84%
data wordlists, and
we are going to say

00:06:16.350 --> 00:06:19.230 align:middle line:90%
common passwords dot txt.

00:06:19.230 --> 00:06:22.320 align:middle line:84%
And we will set the
threads to four, maybe.

00:06:22.320 --> 00:06:26.910 align:middle line:84%
And we can then specify the
target IP, which, again,

00:06:26.910 --> 00:06:28.410 align:middle line:90%
you should have copied by now.

00:06:28.410 --> 00:06:30.990 align:middle line:84%
So we'll just say
threads of four.

00:06:30.990 --> 00:06:33.990 align:middle line:84%
And we can then specify
the target IP right

00:06:33.990 --> 00:06:35.580 align:middle line:84%
over there, which
I need to copy,

00:06:35.580 --> 00:06:41.638 align:middle line:84%
so let me actually
obtain the target IP.

00:06:41.638 --> 00:06:43.180 align:middle line:84%
All right, so I've
got the target IP,

00:06:43.180 --> 00:06:44.560 align:middle line:90%
and I'll just paste it in there.

00:06:44.560 --> 00:06:48.250 align:middle line:84%
And then, we can set the
threads to maybe four threads.

00:06:48.250 --> 00:06:50.470 align:middle line:84%
Again, be very careful
when performing

00:06:50.470 --> 00:06:53.980 align:middle line:84%
a brute-force attack, as it
may actually cause the service

00:06:53.980 --> 00:06:57.070 align:middle line:84%
to go down or to be overwhelmed
with the number of requests

00:06:57.070 --> 00:06:57.880 align:middle line:90%
you're sending.

00:06:57.880 --> 00:06:59.350 align:middle line:84%
So we'll limit it
to four threads.

00:06:59.350 --> 00:07:00.820 align:middle line:84%
And then, we specify
the protocol.

00:07:00.820 --> 00:07:02.710 align:middle line:90%
In this case, it is SSH.

00:07:02.710 --> 00:07:04.060 align:middle line:90%
And we can then hit Enter.

00:07:04.060 --> 00:07:05.710 align:middle line:84%
That's going to begin
the brute-force.

00:07:05.710 --> 00:07:07.585 align:middle line:84%
So I'm going to give
this a couple of seconds

00:07:07.585 --> 00:07:10.180 align:middle line:84%
to a couple of minutes, and
let's see what credentials we

00:07:10.180 --> 00:07:11.620 align:middle line:90%
are able to identify.

00:07:11.620 --> 00:07:16.570 align:middle line:90%


00:07:16.570 --> 00:07:18.052 align:middle line:84%
All right, so the
brute-force has

00:07:18.052 --> 00:07:19.510 align:middle line:84%
been going for a
couple of minutes,

00:07:19.510 --> 00:07:22.420 align:middle line:84%
and I've been able to identify
a few interesting accounts

00:07:22.420 --> 00:07:25.180 align:middle line:84%
that we can use to gain
access to the target.

00:07:25.180 --> 00:07:28.318 align:middle line:84%
The most interesting of all
is the sysadmin account,

00:07:28.318 --> 00:07:30.610 align:middle line:84%
and we, of course, get the
password, which in this case

00:07:30.610 --> 00:07:31.960 align:middle line:90%
is "hailey."

00:07:31.960 --> 00:07:34.750 align:middle line:84%
So what we can do is-- let
me just stop the brute force

00:07:34.750 --> 00:07:35.500 align:middle line:90%
here--

00:07:35.500 --> 00:07:38.440 align:middle line:84%
and, again, Hydra
will automatically

00:07:38.440 --> 00:07:41.440 align:middle line:84%
save a file called
hydra dot restore,

00:07:41.440 --> 00:07:44.350 align:middle line:84%
which means you can always
resume your brute force using

00:07:44.350 --> 00:07:47.080 align:middle line:84%
the hydra -R command
to resume the session.

00:07:47.080 --> 00:07:49.795 align:middle line:84%
In this case, we are just going
to use the credentials that we

00:07:49.795 --> 00:07:51.700 align:middle line:84%
have been able to
gather so far, and we

00:07:51.700 --> 00:07:56.170 align:middle line:84%
can log in to the target
system via SSH by saying SSH.

00:07:56.170 --> 00:08:00.950 align:middle line:84%
And then, we say sysadmin
at the target IP,

00:08:00.950 --> 00:08:04.340 align:middle line:84%
so we can actually just copy
and paste in the target IP.

00:08:04.340 --> 00:08:04.970 align:middle line:90%
There we are.

00:08:04.970 --> 00:08:06.860 align:middle line:90%
Just going to copy that there.

00:08:06.860 --> 00:08:10.208 align:middle line:84%
And we can say
sysadmin at, and it's

00:08:10.208 --> 00:08:12.500 align:middle line:84%
going to ask us whether we
want to continue connecting.

00:08:12.500 --> 00:08:13.610 align:middle line:90%
I'm going hit yes.

00:08:13.610 --> 00:08:16.150 align:middle line:90%
The password is "hailey."

00:08:16.150 --> 00:08:16.750 align:middle line:90%
There we go.

00:08:16.750 --> 00:08:20.140 align:middle line:84%
And we've logged into the target
system as the user sysadmin.

00:08:20.140 --> 00:08:23.470 align:middle line:84%
We can perform some basic
enumeration like whoami.

00:08:23.470 --> 00:08:24.160 align:middle line:90%
There we are.

00:08:24.160 --> 00:08:27.070 align:middle line:84%
And, of course, we
can display the groups

00:08:27.070 --> 00:08:30.934 align:middle line:84%
that the sysadmin is a part
of, so groups sysadmin.

00:08:30.934 --> 00:08:33.309 align:middle line:84%
You can see that it's not part
of the pseudo group, which

00:08:33.309 --> 00:08:35.950 align:middle line:84%
means we don't have any
elevated privileges.

00:08:35.950 --> 00:08:38.277 align:middle line:84%
And, of course, you can
try out the other accounts

00:08:38.277 --> 00:08:40.360 align:middle line:84%
right over here to see
whether they'll provide you

00:08:40.360 --> 00:08:43.090 align:middle line:84%
with root access or whether
they are accounts that

00:08:43.090 --> 00:08:44.680 align:middle line:90%
are part of the pseudo group.

00:08:44.680 --> 00:08:48.400 align:middle line:84%
And, of course, we can enumerate
the actual distribution release

00:08:48.400 --> 00:08:51.610 align:middle line:84%
version, so we can say cat
etc issue or cat etc release.

00:08:51.610 --> 00:08:54.940 align:middle line:84%
In this case, it's
running Ubuntu 19.04.

00:08:54.940 --> 00:08:57.940 align:middle line:84%
And we can get the kernel
version by saying uname -r.

00:08:57.940 --> 00:09:01.540 align:middle line:84%
There we are, so it's running
the kernel version 5.4.0.

00:09:01.540 --> 00:09:03.880 align:middle line:84%
And, of course, you
can enumerate the users

00:09:03.880 --> 00:09:07.900 align:middle line:84%
on the system by getting the
contents of the password file.

00:09:07.900 --> 00:09:10.430 align:middle line:84%
And you can see we have a
few other accounts here.

00:09:10.430 --> 00:09:12.920 align:middle line:84%
So we have the root user,
and then, of course,

00:09:12.920 --> 00:09:16.150 align:middle line:84%
we have demo, auditor, anon,
administrator, et cetera; all

00:09:16.150 --> 00:09:18.370 align:middle line:84%
of the accounts that we
were able to identify

00:09:18.370 --> 00:09:19.600 align:middle line:90%
through the brute-force.

00:09:19.600 --> 00:09:22.210 align:middle line:84%
So there are a few flags
that you can actually

00:09:22.210 --> 00:09:25.030 align:middle line:84%
gather with file list of the
contents of my current working

00:09:25.030 --> 00:09:25.540 align:middle line:90%
directory.

00:09:25.540 --> 00:09:27.400 align:middle line:84%
I don't have any
flags in there, so I'm

00:09:27.400 --> 00:09:30.460 align:middle line:84%
going to let you find the
flags that are on the system,

00:09:30.460 --> 00:09:33.250 align:middle line:84%
and you can complete
the challenge associated

00:09:33.250 --> 00:09:34.960 align:middle line:90%
with this particular lab.

00:09:34.960 --> 00:09:36.910 align:middle line:84%
All right, so that
is going to conclude

00:09:36.910 --> 00:09:40.972 align:middle line:84%
the practical demonstration
side of this video.

00:09:40.972 --> 00:09:42.680 align:middle line:84%
All right, so now that
we've taken a look

00:09:42.680 --> 00:09:46.460 align:middle line:84%
at how to exploit SSH
through a brute force attack,

00:09:46.460 --> 00:09:50.480 align:middle line:84%
we can now turn our attention to
the open source implementation

00:09:50.480 --> 00:09:53.030 align:middle line:84%
of SMB for Linux,
which is Samba.

00:09:53.030 --> 00:09:56.590 align:middle line:84%
So I'll see you
in the next video.

00:09:56.590 --> 00:09:58.000 align:middle line:90%