WEBVTT

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


00:00:03.472 --> 00:00:06.448 align:middle line:90%
[LOGO EFFECT]

00:00:06.448 --> 00:00:09.930 align:middle line:90%


00:00:09.930 --> 00:00:11.755 align:middle line:90%
Targeting SMB.

00:00:11.755 --> 00:00:13.380 align:middle line:84%
In this video, we're
going to be taking

00:00:13.380 --> 00:00:15.180 align:middle line:84%
a look at the various
tools and techniques

00:00:15.180 --> 00:00:19.590 align:middle line:84%
that we can use to exploit
SMB to consequently provide us

00:00:19.590 --> 00:00:22.030 align:middle line:84%
with remote access
to the target system.

00:00:22.030 --> 00:00:25.073 align:middle line:84%
So we're going to be exploring
various tools and techniques.

00:00:25.073 --> 00:00:26.490 align:middle line:84%
So it's going to
be quite lengthy,

00:00:26.490 --> 00:00:30.630 align:middle line:84%
and I'll be covering some
very important techniques

00:00:30.630 --> 00:00:34.110 align:middle line:84%
that you should be performing
whenever you're targeting SMB

00:00:34.110 --> 00:00:35.950 align:middle line:90%
running on a Windows system.

00:00:35.950 --> 00:00:39.150 align:middle line:84%
Now, I've already
explained SMB quite a bit

00:00:39.150 --> 00:00:41.880 align:middle line:84%
or gone through how
it works in the system

00:00:41.880 --> 00:00:43.810 align:middle line:90%
and host-based attacks course.

00:00:43.810 --> 00:00:46.560 align:middle line:84%
So if you want to learn more
about SMB and how it works in

00:00:46.560 --> 00:00:50.242 align:middle line:84%
regards to authentication,
you can check out that video.

00:00:50.242 --> 00:00:52.200 align:middle line:84%
So again, we're using
the same lab environment.

00:00:52.200 --> 00:00:55.260 align:middle line:84%
If you have terminated it
and you start up a new lab

00:00:55.260 --> 00:00:58.080 align:middle line:84%
environment, remember to get
the new target IP address

00:00:58.080 --> 00:00:59.340 align:middle line:90%
as it changes.

00:00:59.340 --> 00:01:02.318 align:middle line:84%
And of course, also
take note of the fact

00:01:02.318 --> 00:01:04.110 align:middle line:84%
that whatever information
you're gathering,

00:01:04.110 --> 00:01:06.780 align:middle line:84%
like user credentials
and passwords,

00:01:06.780 --> 00:01:10.320 align:middle line:84%
should be saved within your
own note-taking application,

00:01:10.320 --> 00:01:13.500 align:middle line:84%
as any data that's stored
within the lab environment

00:01:13.500 --> 00:01:16.860 align:middle line:84%
will be deleted or wiped
once that lab is terminated.

00:01:16.860 --> 00:01:18.360 align:middle line:84%
With that being
said, I'm just going

00:01:18.360 --> 00:01:20.130 align:middle line:84%
to switch over to
my lab environment,

00:01:20.130 --> 00:01:23.490 align:middle line:84%
and we'll take a look at how
we can target SMB in order

00:01:23.490 --> 00:01:25.960 align:middle line:84%
to gain access to
the target system.

00:01:25.960 --> 00:01:27.420 align:middle line:90%
So I'll see you there.

00:01:27.420 --> 00:01:30.050 align:middle line:90%


00:01:30.050 --> 00:01:30.550 align:middle line:90%
All right.

00:01:30.550 --> 00:01:32.930 align:middle line:84%
So I'm back in the
lab environment.

00:01:32.930 --> 00:01:36.550 align:middle line:84%
And I've just performed an
Nmap scan on the target system

00:01:36.550 --> 00:01:39.910 align:middle line:84%
on port 445, which is
the default SMB port.

00:01:39.910 --> 00:01:43.450 align:middle line:84%
And I've performed a service
version detection scan, as well

00:01:43.450 --> 00:01:46.240 align:middle line:90%
as the default Nmap script scan.

00:01:46.240 --> 00:01:50.240 align:middle line:84%
And again, this information
we've already gone through.

00:01:50.240 --> 00:01:53.110 align:middle line:84%
We've been able to identify
the target operating system.

00:01:53.110 --> 00:01:59.260 align:middle line:84%
We know it's Windows Server 2008
R2, build 7601, service pack 1.

00:01:59.260 --> 00:02:03.520 align:middle line:84%
And we do know that from the
actual host script results

00:02:03.520 --> 00:02:06.460 align:middle line:84%
right over here, we do know
the host name of the system,

00:02:06.460 --> 00:02:11.580 align:middle line:84%
as well as the various
SMB security configuration

00:02:11.580 --> 00:02:15.550 align:middle line:90%
for both SMB and SMB version 2.

00:02:15.550 --> 00:02:17.620 align:middle line:84%
With that being
said, we also need

00:02:17.620 --> 00:02:20.320 align:middle line:84%
to take into consideration
the information that we've

00:02:20.320 --> 00:02:22.120 align:middle line:90%
been able to gather so far.

00:02:22.120 --> 00:02:25.600 align:middle line:84%
And one of the most important
pieces of information

00:02:25.600 --> 00:02:28.510 align:middle line:84%
we were able to obtain
within the previous videos

00:02:28.510 --> 00:02:32.860 align:middle line:84%
was the two user accounts, as
well as their passwords, right?

00:02:32.860 --> 00:02:35.920 align:middle line:84%
So we were able to
obtain two user accounts.

00:02:35.920 --> 00:02:37.370 align:middle line:90%
One of them was administrator.

00:02:37.370 --> 00:02:38.980 align:middle line:90%
The other one was Vagrant.

00:02:38.980 --> 00:02:43.150 align:middle line:84%
And we obtained the credentials
for FTP, as well SSH.

00:02:43.150 --> 00:02:46.930 align:middle line:84%
And as I mentioned, with
regards to those services,

00:02:46.930 --> 00:02:48.340 align:middle line:90%
those are your--

00:02:48.340 --> 00:02:51.670 align:middle line:84%
those services utilize
already existing user accounts

00:02:51.670 --> 00:02:53.030 align:middle line:90%
on the Windows system.

00:02:53.030 --> 00:02:57.130 align:middle line:84%
So we do know that
we have a Windows

00:02:57.130 --> 00:03:00.460 align:middle line:84%
user called Administrator
and another Windows user

00:03:00.460 --> 00:03:01.330 align:middle line:90%
called Vagrant.

00:03:01.330 --> 00:03:04.120 align:middle line:84%
And via-- through
the SSH video, we

00:03:04.120 --> 00:03:08.170 align:middle line:84%
were also able to identify
that the credentials

00:03:08.170 --> 00:03:12.730 align:middle line:84%
or access to the system via SSH
with the administrator account

00:03:12.730 --> 00:03:15.400 align:middle line:84%
has been blocked, even
though the actual password

00:03:15.400 --> 00:03:16.210 align:middle line:90%
would have worked.

00:03:16.210 --> 00:03:20.120 align:middle line:84%
But we were able to gain
access via the Vagrant user.

00:03:20.120 --> 00:03:23.020 align:middle line:84%
So we'll be using all of that
information to essentially

00:03:23.020 --> 00:03:25.000 align:middle line:90%
perform our SMB attacks.

00:03:25.000 --> 00:03:28.570 align:middle line:84%
Now, if you have not been able
to identify any user accounts,

00:03:28.570 --> 00:03:31.150 align:middle line:84%
and of course, this is in
reference to other pen tests

00:03:31.150 --> 00:03:34.390 align:middle line:84%
that you will perform, then
you can perform a brute force

00:03:34.390 --> 00:03:36.940 align:middle line:84%
in order to identify
the usernames, as well

00:03:36.940 --> 00:03:38.800 align:middle line:90%
as the passwords.

00:03:38.800 --> 00:03:41.350 align:middle line:84%
But what I would recommend
doing is, firstly,

00:03:41.350 --> 00:03:44.380 align:middle line:84%
identifying usernames so
that you can narrow down

00:03:44.380 --> 00:03:45.740 align:middle line:90%
your brute force attack.

00:03:45.740 --> 00:03:48.160 align:middle line:84%
And of course, in the
context of Windows,

00:03:48.160 --> 00:03:50.660 align:middle line:84%
we know that there's always
an administrator user.

00:03:50.660 --> 00:03:52.570 align:middle line:84%
So what I would
typically recommend doing

00:03:52.570 --> 00:03:54.850 align:middle line:84%
is performing a brute
force attack with Hydra

00:03:54.850 --> 00:03:57.080 align:middle line:84%
for the administrator
user account

00:03:57.080 --> 00:04:00.350 align:middle line:84%
in order to try and identify
the password for that account.

00:04:00.350 --> 00:04:03.760 align:middle line:84%
So to perform a brute force
attack with Hydra on SMB,

00:04:03.760 --> 00:04:07.450 align:middle line:84%
we simply type in hydra and
the username we are testing

00:04:07.450 --> 00:04:09.310 align:middle line:84%
or we are performing
the brute force with

00:04:09.310 --> 00:04:11.840 align:middle line:84%
is the administrator
user account.

00:04:11.840 --> 00:04:14.148 align:middle line:84%
We can then specify the
password list or the word list

00:04:14.148 --> 00:04:15.940 align:middle line:84%
containing the passwords
that we would like

00:04:15.940 --> 00:04:17.709 align:middle line:90%
to use for the brute force.

00:04:17.709 --> 00:04:21.820 align:middle line:84%
In this case, we can use one
under the user share wordLists

00:04:21.820 --> 00:04:22.570 align:middle line:90%
directory.

00:04:22.570 --> 00:04:24.430 align:middle line:90%
So usr/share/wordLists.

00:04:24.430 --> 00:04:26.260 align:middle line:84%
And under the
Metasploit directory,

00:04:26.260 --> 00:04:29.330 align:middle line:84%
we can use the Unix,
users, wordLists.

00:04:29.330 --> 00:04:33.400 align:middle line:84%
So we can say unix_users.txt
or passwords.txt.

00:04:33.400 --> 00:04:35.080 align:middle line:90%
It's entirely up to you.

00:04:35.080 --> 00:04:38.740 align:middle line:84%
And we can then specify the
target IP address, which I've

00:04:38.740 --> 00:04:40.250 align:middle line:90%
already obtained in this case.

00:04:40.250 --> 00:04:42.790 align:middle line:84%
So I'll just copy it
again, make sure I have it,

00:04:42.790 --> 00:04:44.690 align:middle line:90%
and I'll paste that in there.

00:04:44.690 --> 00:04:46.210 align:middle line:84%
And then you
specify the protocol

00:04:46.210 --> 00:04:48.620 align:middle line:84%
that you are performing
the brute force attack on,

00:04:48.620 --> 00:04:50.560 align:middle line:90%
which is, in this case, is SMB.

00:04:50.560 --> 00:04:53.680 align:middle line:84%
Now, I've already covered SMB
brute forces in the system

00:04:53.680 --> 00:04:55.720 align:middle line:84%
and host-based attacks
course, and all

00:04:55.720 --> 00:04:57.850 align:middle line:84%
that can be done via the
Metasploit framework.

00:04:57.850 --> 00:05:00.070 align:middle line:84%
But again, if you want
to do it with Hydra,

00:05:00.070 --> 00:05:01.820 align:middle line:90%
that'll work out just fine.

00:05:01.820 --> 00:05:03.740 align:middle line:84%
So I'll perform the
brute force attack.

00:05:03.740 --> 00:05:06.460 align:middle line:84%
And you can see we're able
to authenticate successfully

00:05:06.460 --> 00:05:10.090 align:middle line:84%
with SMB with the
administrator user account,

00:05:10.090 --> 00:05:12.010 align:middle line:84%
and the password
is vagrant, as we

00:05:12.010 --> 00:05:17.300 align:middle line:84%
were able to obtain previously
during the FTP section.

00:05:17.300 --> 00:05:19.540 align:middle line:84%
So now that we've obtained
legitimate credentials,

00:05:19.540 --> 00:05:22.820 align:middle line:84%
we can, of course, also
test the Vagrant user,

00:05:22.820 --> 00:05:24.820 align:middle line:84%
and let's see whether
we're able to authenticate

00:05:24.820 --> 00:05:29.140 align:middle line:84%
as well, because both of these
are actually Windows accounts.

00:05:29.140 --> 00:05:32.030 align:middle line:90%
So we can say vagrant.

00:05:32.030 --> 00:05:33.350 align:middle line:90%
Let me type that in correctly.

00:05:33.350 --> 00:05:36.530 align:middle line:90%
So vagrant and I can hit Enter.

00:05:36.530 --> 00:05:38.538 align:middle line:84%
And the password should
indeed be vagrant.

00:05:38.538 --> 00:05:39.080 align:middle line:90%
There we are.

00:05:39.080 --> 00:05:41.690 align:middle line:84%
So what can we do with
these credentials?

00:05:41.690 --> 00:05:43.910 align:middle line:84%
Well, for one, we
can authenticate

00:05:43.910 --> 00:05:46.940 align:middle line:84%
with the target via RDP because
if you remember during the port

00:05:46.940 --> 00:05:49.100 align:middle line:84%
scanning and
enumeration video, we

00:05:49.100 --> 00:05:51.630 align:middle line:84%
identified that we have
RDP running on the target.

00:05:51.630 --> 00:05:53.090 align:middle line:84%
So we can immediately
authenticate

00:05:53.090 --> 00:05:54.890 align:middle line:90%
with the target via RDP.

00:05:54.890 --> 00:05:58.370 align:middle line:84%
However, we are focused on
SMB exploitation, right?

00:05:58.370 --> 00:06:00.900 align:middle line:84%
So again, we've
obtained credentials.

00:06:00.900 --> 00:06:04.190 align:middle line:84%
The next logical thing would
be to enumerate any shares,

00:06:04.190 --> 00:06:08.450 align:middle line:84%
and enumerating shares can
be done without credentials,

00:06:08.450 --> 00:06:10.205 align:middle line:90%
or in the case of--

00:06:10.205 --> 00:06:14.030 align:middle line:84%
if in the case you actually
have legitimate credentials,

00:06:14.030 --> 00:06:17.250 align:middle line:84%
then you'll be able to obtain
a lot more information.

00:06:17.250 --> 00:06:19.850 align:middle line:84%
So one of the tools that
we can use, for example,

00:06:19.850 --> 00:06:22.050 align:middle line:90%
is a tool called smbclient.

00:06:22.050 --> 00:06:22.550 align:middle line:90%
Right?

00:06:22.550 --> 00:06:25.130 align:middle line:84%
And we can list out
the actual shares,

00:06:25.130 --> 00:06:29.520 align:middle line:84%
and we can authenticate with
the use of Vagrant, for example.

00:06:29.520 --> 00:06:32.390 align:middle line:84%
So I can say vagrant,
and I can hit Enter,

00:06:32.390 --> 00:06:34.548 align:middle line:84%
and we'll type in the
password for vagrant.

00:06:34.548 --> 00:06:35.090 align:middle line:90%
There we are.

00:06:35.090 --> 00:06:36.620 align:middle line:90%
And we get the shares.

00:06:36.620 --> 00:06:39.170 align:middle line:84%
However, in the
case of SMB client,

00:06:39.170 --> 00:06:41.450 align:middle line:84%
it looks like the
connection failed,

00:06:41.450 --> 00:06:45.620 align:middle line:84%
and it is unable to
connect with SMB version 1.

00:06:45.620 --> 00:06:48.410 align:middle line:84%
So that's perfectly
fine, but primarily

00:06:48.410 --> 00:06:50.570 align:middle line:84%
because we're not really
interested in shares,

00:06:50.570 --> 00:06:54.230 align:middle line:84%
and there isn't any information
available within the shares.

00:06:54.230 --> 00:06:57.200 align:middle line:84%
But you can see we have admin
and C and your typical--

00:06:57.200 --> 00:07:00.680 align:middle line:90%
your standard IPC share.

00:07:00.680 --> 00:07:02.360 align:middle line:90%
We can also use SMB map.

00:07:02.360 --> 00:07:04.890 align:middle line:84%
That's another tool
that is quite useful.

00:07:04.890 --> 00:07:07.100 align:middle line:84%
So smbmap, and we
can authenticate

00:07:07.100 --> 00:07:08.450 align:middle line:90%
with the use of vagrant.

00:07:08.450 --> 00:07:10.970 align:middle line:84%
So we say username is
Vagrant, and the password

00:07:10.970 --> 00:07:13.500 align:middle line:90%
is vagrant as well.

00:07:13.500 --> 00:07:17.540 align:middle line:84%
We then specify the target
IP using the hyphen or minus

00:07:17.540 --> 00:07:19.670 align:middle line:90%
capital H and the target IP.

00:07:19.670 --> 00:07:21.260 align:middle line:90%
We hit Enter.

00:07:21.260 --> 00:07:23.180 align:middle line:84%
And again, that will
enumerate the shares

00:07:23.180 --> 00:07:27.230 align:middle line:84%
that we were able to identify
previously with SMB client.

00:07:27.230 --> 00:07:29.780 align:middle line:84%
Now, another important
thing that we can do

00:07:29.780 --> 00:07:32.930 align:middle line:84%
is enumerate other user
accounts on the system

00:07:32.930 --> 00:07:35.690 align:middle line:84%
with the credentials
that we already have,

00:07:35.690 --> 00:07:38.810 align:middle line:84%
and that can be done through
the enum4 Linux tool.

00:07:38.810 --> 00:07:41.250 align:middle line:90%
So we can say enum4linux.

00:07:41.250 --> 00:07:43.110 align:middle line:84%
And we can authenticate
with the target.

00:07:43.110 --> 00:07:46.040 align:middle line:84%
So we can say the password
or the username is vagrant,

00:07:46.040 --> 00:07:49.400 align:middle line:84%
and then the password is,
again, just going to be vagrant.

00:07:49.400 --> 00:07:54.140 align:middle line:84%
And we are connecting
to the following IP.

00:07:54.140 --> 00:07:56.595 align:middle line:84%
So that will allow us to
enumerate all the other user

00:07:56.595 --> 00:07:58.220 align:middle line:84%
accounts on the
system, and indeed, you

00:07:58.220 --> 00:08:00.610 align:middle line:84%
can see that these are
the other user accounts.

00:08:00.610 --> 00:08:01.880 align:middle line:90%
So we have the administrator.

00:08:01.880 --> 00:08:04.200 align:middle line:84%
And then the rest of the
user accounts were created,

00:08:04.200 --> 00:08:07.640 align:middle line:84%
and these are just
your Star Wars names

00:08:07.640 --> 00:08:09.590 align:middle line:84%
right over here
that we created just

00:08:09.590 --> 00:08:13.740 align:middle line:84%
to showcase this
particular technique.

00:08:13.740 --> 00:08:17.360 align:middle line:84%
So you can see, we have
vagrant, sshd_server, sshd.

00:08:17.360 --> 00:08:20.660 align:middle line:84%
And then, of course, Luke
Skywalker, Darth Vader,

00:08:20.660 --> 00:08:22.530 align:middle line:90%
and the administrator, user.

00:08:22.530 --> 00:08:26.690 align:middle line:84%
So once you've obtained
legitimate SMB credentials

00:08:26.690 --> 00:08:29.180 align:middle line:84%
or credentials for user
accounts on the system,

00:08:29.180 --> 00:08:32.010 align:middle line:84%
you can learn a lot
more about the system.

00:08:32.010 --> 00:08:33.980 align:middle line:84%
But this is just
basic enumeration.

00:08:33.980 --> 00:08:37.909 align:middle line:84%
And again, I recommend saving
all of these user accounts.

00:08:37.909 --> 00:08:41.450 align:middle line:84%
And of course, in the context
of a real penetration test,

00:08:41.450 --> 00:08:44.270 align:middle line:84%
then all of this information
should be logged.

00:08:44.270 --> 00:08:44.990 align:middle line:90%
All right.

00:08:44.990 --> 00:08:50.790 align:middle line:84%
We can also enumerate shares
with a Metasploit framework

00:08:50.790 --> 00:08:51.290 align:middle line:90%
module.

00:08:51.290 --> 00:08:54.200 align:middle line:84%
So I'll just open
up MSF console here,

00:08:54.200 --> 00:08:56.630 align:middle line:84%
and we'll take a
look at a few modules

00:08:56.630 --> 00:08:59.390 align:middle line:84%
that we can use in
the context of SMB.

00:08:59.390 --> 00:09:02.155 align:middle line:84%
One of which is the
SMB enum users module.

00:09:02.155 --> 00:09:03.280 align:middle line:90%
So I'll search for it here.

00:09:03.280 --> 00:09:06.530 align:middle line:90%
So smb_enumusers.

00:09:06.530 --> 00:09:09.540 align:middle line:84%
And we can also enumshares,
but we've already done that.

00:09:09.540 --> 00:09:12.320 align:middle line:84%
So let's take a look at
the enum users module.

00:09:12.320 --> 00:09:17.100 align:middle line:84%
So enumusers, and that's we're
going to use this module here.

00:09:17.100 --> 00:09:20.150 align:middle line:84%
So I'll just say
use and the ID of 1.

00:09:20.150 --> 00:09:21.890 align:middle line:90%
Well, that module there.

00:09:21.890 --> 00:09:24.680 align:middle line:84%
In terms of the options--
because this will typically

00:09:24.680 --> 00:09:27.470 align:middle line:84%
require legitimate
credentials, we

00:09:27.470 --> 00:09:29.120 align:middle line:90%
need to specify the target IP.

00:09:29.120 --> 00:09:35.960 align:middle line:84%
So I'll say set RHOSTS, target
IP, and then set SMBUser.

00:09:35.960 --> 00:09:38.240 align:middle line:84%
So we can do this with
either the Vagrant account

00:09:38.240 --> 00:09:39.960 align:middle line:90%
or the Administrator account.

00:09:39.960 --> 00:09:42.530 align:middle line:84%
So we can just use
vagrant in this case,

00:09:42.530 --> 00:09:46.060 align:middle line:84%
and the SMB password is
just vagrant as well.

00:09:46.060 --> 00:09:48.590 align:middle line:90%
So SMBPass vagrant.

00:09:48.590 --> 00:09:49.590 align:middle line:90%
There we are.

00:09:49.590 --> 00:09:53.810 align:middle line:84%
And we can then hit Run, and
that will enumerate the users

00:09:53.810 --> 00:09:57.380 align:middle line:84%
that we were able to
enumerate with enum4 Linux.

00:09:57.380 --> 00:09:59.480 align:middle line:84%
And of course, you can
also enumerate shares

00:09:59.480 --> 00:10:01.567 align:middle line:84%
if you want to, but
that's really not what

00:10:01.567 --> 00:10:02.400 align:middle line:90%
we're interested in.

00:10:02.400 --> 00:10:04.850 align:middle line:84%
So you might be asking
yourself, well, we've

00:10:04.850 --> 00:10:08.600 align:middle line:84%
already obtained legitimate
user account credentials.

00:10:08.600 --> 00:10:11.540 align:middle line:90%
We can log in via RDP.

00:10:11.540 --> 00:10:12.750 align:middle line:90%
But what else can we do?

00:10:12.750 --> 00:10:15.530 align:middle line:84%
Well, we can utilize
a tool called psexec

00:10:15.530 --> 00:10:20.450 align:middle line:84%
and more specifically the
Python implementation of psexec.

00:10:20.450 --> 00:10:23.910 align:middle line:84%
And again, in the case
of this lab environment,

00:10:23.910 --> 00:10:25.140 align:middle line:90%
we can locate the file.

00:10:25.140 --> 00:10:30.680 align:middle line:84%
So psexec.py and it should be
under the usr/share/doc/python3

00:10:30.680 --> 00:10:33.260 align:middle line:90%
impacket/examples directory.

00:10:33.260 --> 00:10:36.920 align:middle line:84%
So we can just copy this
file onto our desktop.

00:10:36.920 --> 00:10:41.640 align:middle line:84%
So I'll just navigate into
desktop, and I'll say copy.

00:10:41.640 --> 00:10:43.980 align:middle line:84%
And we'll copy it into our
current working directory

00:10:43.980 --> 00:10:45.370 align:middle line:90%
right over here.

00:10:45.370 --> 00:10:45.870 align:middle line:90%
OK.

00:10:45.870 --> 00:10:48.750 align:middle line:84%
So psexec is a tool
that allows you

00:10:48.750 --> 00:10:52.080 align:middle line:84%
to authenticate with a
system remotely via SMB

00:10:52.080 --> 00:10:53.958 align:middle line:90%
with legitimate credentials.

00:10:53.958 --> 00:10:55.500 align:middle line:84%
Now, in order to
use it, you're going

00:10:55.500 --> 00:10:57.600 align:middle line:84%
to require the target
IP address, as well

00:10:57.600 --> 00:10:58.860 align:middle line:90%
as the legitimate credentials.

00:10:58.860 --> 00:11:01.620 align:middle line:84%
So I'll just copy
the target IP there,

00:11:01.620 --> 00:11:04.800 align:middle line:84%
and I'm just going
to paste that in here

00:11:04.800 --> 00:11:07.080 align:middle line:84%
because it's quite
important in this case.

00:11:07.080 --> 00:11:13.140 align:middle line:84%
So to utilize psexec, we can
say chmod plus x to essentially

00:11:13.140 --> 00:11:14.250 align:middle line:90%
make it executable.

00:11:14.250 --> 00:11:16.920 align:middle line:90%
So chmod plus x psexec.py.

00:11:16.920 --> 00:11:19.230 align:middle line:84%
And then we can launch
it with Python 3.

00:11:19.230 --> 00:11:22.410 align:middle line:84%
So psexec.py, and
then specify the user

00:11:22.410 --> 00:11:24.400 align:middle line:84%
that we would like
to authenticate with.

00:11:24.400 --> 00:11:27.120 align:middle line:84%
So in this case, administrator
because we got the password

00:11:27.120 --> 00:11:28.800 align:middle line:90%
for the administrator account.

00:11:28.800 --> 00:11:30.930 align:middle line:84%
We can then paste
in the target IP.

00:11:30.930 --> 00:11:33.540 align:middle line:84%
So we're logging in
just like you would SSH.

00:11:33.540 --> 00:11:34.597 align:middle line:90%
We hit Enter.

00:11:34.597 --> 00:11:36.180 align:middle line:84%
It's going to ask
us for the password.

00:11:36.180 --> 00:11:38.340 align:middle line:84%
In this case, we
know it's vagrant.

00:11:38.340 --> 00:11:40.140 align:middle line:84%
And it's going to
request the shares.

00:11:40.140 --> 00:11:44.130 align:middle line:84%
Find a writable share, and it's
then going to upload a payload

00:11:44.130 --> 00:11:47.280 align:middle line:84%
and then provide us with an
elevated command prompt session

00:11:47.280 --> 00:11:50.050 align:middle line:84%
here because we logged in with
the administrator account.

00:11:50.050 --> 00:11:53.250 align:middle line:84%
So I can say who am I, for
example, and the authority

00:11:53.250 --> 00:11:55.830 align:middle line:84%
system, which is the
highest level of privileges

00:11:55.830 --> 00:11:57.760 align:middle line:90%
available on a Windows system.

00:11:57.760 --> 00:12:00.150 align:middle line:84%
So we've been able to
gain access via SMB,

00:12:00.150 --> 00:12:01.890 align:middle line:84%
and this is our
second attack vector

00:12:01.890 --> 00:12:05.040 align:middle line:84%
that has provided us
with access to the target

00:12:05.040 --> 00:12:07.152 align:middle line:90%
system, one of which was SSH.

00:12:07.152 --> 00:12:09.150 align:middle line:84%
And in this case,
in the case of SMB,

00:12:09.150 --> 00:12:11.910 align:middle line:84%
we've been able to authenticate
with the Administrator user

00:12:11.910 --> 00:12:15.150 align:middle line:84%
account, consequently giving
us elevated privileges

00:12:15.150 --> 00:12:16.780 align:middle line:90%
on the target system.

00:12:16.780 --> 00:12:18.918 align:middle line:84%
So the lead pen
tester should actually

00:12:18.918 --> 00:12:21.210 align:middle line:84%
be giving you a lot of credit
for this, if you actually

00:12:21.210 --> 00:12:24.550 align:middle line:84%
were able to do this
without watching this video.

00:12:24.550 --> 00:12:28.050 align:middle line:84%
So that's how to utilize
the psexec Python script.

00:12:28.050 --> 00:12:29.850 align:middle line:84%
Now, the Metasploit
framework module

00:12:29.850 --> 00:12:32.790 align:middle line:90%
also has a psexec module.

00:12:32.790 --> 00:12:35.910 align:middle line:84%
So I can just
terminate this here,

00:12:35.910 --> 00:12:38.130 align:middle line:90%
and we can open up MSF console.

00:12:38.130 --> 00:12:42.170 align:middle line:90%
And we can search for it.

00:12:42.170 --> 00:12:44.258 align:middle line:84%
So we'll give this
a couple of seconds.

00:12:44.258 --> 00:12:44.800 align:middle line:90%
There we are.

00:12:44.800 --> 00:12:47.110 align:middle line:90%
So I can say search psexec.

00:12:47.110 --> 00:12:49.270 align:middle line:84%
And this also
requires credentials.

00:12:49.270 --> 00:12:51.820 align:middle line:84%
And the one we're looking
for is this one right here,

00:12:51.820 --> 00:12:54.760 align:middle line:90%
exploit/windows/smb/psexec.

00:12:54.760 --> 00:12:57.610 align:middle line:84%
And that is the Microsoft
Windows authenticated user code

00:12:57.610 --> 00:12:59.620 align:middle line:90%
execution module.

00:12:59.620 --> 00:13:01.810 align:middle line:90%
So we'll say use 4--

00:13:01.810 --> 00:13:03.680 align:middle line:90%
or actually, let's go back here.

00:13:03.680 --> 00:13:07.762 align:middle line:84%
So search psexec, and
I want to use 4 not 3.

00:13:07.762 --> 00:13:08.470 align:middle line:90%
And there we are.

00:13:08.470 --> 00:13:12.130 align:middle line:84%
So the default payload is
windows/meterpreter/reverse_tcp.

00:13:12.130 --> 00:13:15.280 align:middle line:84%
We know that the target is
running a 64-bit version

00:13:15.280 --> 00:13:16.420 align:middle line:90%
of Windows Server.

00:13:16.420 --> 00:13:18.445 align:middle line:84%
So we can set the
payload to Windows.

00:13:18.445 --> 00:13:21.010 align:middle line:90%


00:13:21.010 --> 00:13:23.710 align:middle line:84%
windows/x64/meterpreter/reverse
tcp.

00:13:23.710 --> 00:13:27.510 align:middle line:90%


00:13:27.510 --> 00:13:31.360 align:middle line:84%
So that will provide us with
a 64-bit meterpreter session.

00:13:31.360 --> 00:13:33.330 align:middle line:84%
And if we show the
options, we again

00:13:33.330 --> 00:13:36.660 align:middle line:84%
need to set up the
username and the password,

00:13:36.660 --> 00:13:40.360 align:middle line:84%
as well as your LHOST option
and your LPORT option here.

00:13:40.360 --> 00:13:42.810 align:middle line:84%
So you need to set this
to your Kali Linux IP.

00:13:42.810 --> 00:13:44.620 align:middle line:84%
And for the port,
make sure you set that

00:13:44.620 --> 00:13:46.720 align:middle line:84%
to a port that's not
currently being used.

00:13:46.720 --> 00:13:48.330 align:middle line:90%
So we'll set the RHOSTS option.

00:13:48.330 --> 00:13:50.400 align:middle line:90%
So that's the target IP.

00:13:50.400 --> 00:13:51.210 align:middle line:90%
There we are.

00:13:51.210 --> 00:13:56.780 align:middle line:84%
And we'll set the SMB
user to administrator.

00:13:56.780 --> 00:13:59.000 align:middle line:84%
And I'll just change
that to a capital A

00:13:59.000 --> 00:14:01.520 align:middle line:84%
because this module
usually has a few issues.

00:14:01.520 --> 00:14:05.090 align:middle line:90%
And then we say set SMBPass.

00:14:05.090 --> 00:14:05.700 align:middle line:90%
There we are.

00:14:05.700 --> 00:14:08.960 align:middle line:84%
And we can set that to vagrant,
and we can then exploit.

00:14:08.960 --> 00:14:11.750 align:middle line:84%
And this should provide us
with an elevated meterpreter

00:14:11.750 --> 00:14:13.020 align:middle line:90%
session.

00:14:13.020 --> 00:14:13.520 align:middle line:90%
All right.

00:14:13.520 --> 00:14:15.730 align:middle line:90%
So it looks like it's working.

00:14:15.730 --> 00:14:18.430 align:middle line:84%
It sends the stage, and we
get a meterpreter session

00:14:18.430 --> 00:14:19.610 align:middle line:90%
on the target system.

00:14:19.610 --> 00:14:21.760 align:middle line:84%
So I can say
sysinfo, and you can

00:14:21.760 --> 00:14:27.160 align:middle line:84%
see it's running Windows Server
2008 R2, getuid, NT AUTHORITY

00:14:27.160 --> 00:14:28.480 align:middle line:90%
SYSTEM.

00:14:28.480 --> 00:14:31.900 align:middle line:84%
And we can enumerate our
privileges by saying getprivs.

00:14:31.900 --> 00:14:33.110 align:middle line:90%
And there we are.

00:14:33.110 --> 00:14:36.520 align:middle line:84%
So again, you can utilize
both-- you can gain access

00:14:36.520 --> 00:14:40.240 align:middle line:84%
to the target system via SMB
with psexec both manually

00:14:40.240 --> 00:14:41.553 align:middle line:90%
and automatically.

00:14:41.553 --> 00:14:42.970 align:middle line:84%
And that's something
that I really

00:14:42.970 --> 00:14:44.680 align:middle line:84%
wanted to highlight
because you don't

00:14:44.680 --> 00:14:49.000 align:middle line:84%
need to rely on the Metasploit
framework or the manual Python

00:14:49.000 --> 00:14:52.430 align:middle line:84%
scripts like the
psexec Python script.

00:14:52.430 --> 00:14:52.930 align:middle line:90%
All right.

00:14:52.930 --> 00:14:57.280 align:middle line:84%
So that is how to gain
access with the credentials

00:14:57.280 --> 00:14:59.530 align:middle line:90%
that we've been able to obtain.

00:14:59.530 --> 00:15:05.080 align:middle line:84%
Now, what if we did not
have any SMB credentials?

00:15:05.080 --> 00:15:07.960 align:middle line:84%
We were able to identify that
the target is running Windows

00:15:07.960 --> 00:15:14.020 align:middle line:84%
Server 2008, and Windows Server
2008 and Windows Server 2008 R2

00:15:14.020 --> 00:15:17.140 align:middle line:84%
are both vulnerable to the
EternalBlue vulnerability

00:15:17.140 --> 00:15:17.890 align:middle line:90%
or exploits.

00:15:17.890 --> 00:15:20.560 align:middle line:84%
So that means that we
can discount whatever

00:15:20.560 --> 00:15:24.580 align:middle line:84%
we've done so far in regards to
getting legitimate credentials,

00:15:24.580 --> 00:15:26.740 align:middle line:84%
and we can gain access
to the target system

00:15:26.740 --> 00:15:29.200 align:middle line:84%
without knowing anything
apart from the SMB port

00:15:29.200 --> 00:15:32.770 align:middle line:84%
and the target IP with
the EternalBlue Metasploit

00:15:32.770 --> 00:15:33.880 align:middle line:90%
exploit module.

00:15:33.880 --> 00:15:39.090 align:middle line:84%
So I'll do that right now by
saying search eternalblue.

00:15:39.090 --> 00:15:40.810 align:middle line:90%
And we can use the first one.

00:15:40.810 --> 00:15:43.270 align:middle line:84%
So that's
exploit/windows/smb/ms17 010

00:15:43.270 --> 00:15:45.660 align:middle line:90%
eternalblue.

00:15:45.660 --> 00:15:48.750 align:middle line:84%
And I'll say use
0, and the payload

00:15:48.750 --> 00:15:51.550 align:middle line:84%
is set to the default
64-bit meterpreter payload.

00:15:51.550 --> 00:15:53.520 align:middle line:90%
So I'll say show options.

00:15:53.520 --> 00:15:55.410 align:middle line:84%
And you can see, in
this case, we only

00:15:55.410 --> 00:15:57.990 align:middle line:84%
need to specify
the RHOST option.

00:15:57.990 --> 00:16:00.870 align:middle line:90%
So set RHOTSTS.

00:16:00.870 --> 00:16:03.000 align:middle line:90%
I'll specify the target IP.

00:16:03.000 --> 00:16:06.520 align:middle line:84%
And now, we also need to set
up the target information.

00:16:06.520 --> 00:16:08.820 align:middle line:84%
But in this case, we'll
leave it as automatic

00:16:08.820 --> 00:16:11.760 align:middle line:84%
because this module does
detect what version of Windows

00:16:11.760 --> 00:16:13.440 align:middle line:90%
is running very, very well.

00:16:13.440 --> 00:16:16.017 align:middle line:90%
So will it exploit?

00:16:16.017 --> 00:16:18.350 align:middle line:84%
You can see that it's going
to tell you right over here,

00:16:18.350 --> 00:16:23.360 align:middle line:84%
the host is likely vulnerable
to the ms17_010 vulnerability,

00:16:23.360 --> 00:16:26.510 align:middle line:84%
and it's then going
to essentially perform

00:16:26.510 --> 00:16:28.520 align:middle line:84%
the exploit, and it
should send the stage

00:16:28.520 --> 00:16:30.350 align:middle line:84%
and provide us
with a meterpreter

00:16:30.350 --> 00:16:32.870 align:middle line:90%
session on the target system.

00:16:32.870 --> 00:16:35.180 align:middle line:84%
The great thing about
the EternalBlue exploit

00:16:35.180 --> 00:16:38.360 align:middle line:84%
is that irregardless of whether
or not we have credentials,

00:16:38.360 --> 00:16:40.700 align:middle line:84%
it will provide you with
an elevated meterpreter

00:16:40.700 --> 00:16:42.750 align:middle line:90%
session right out of the box.

00:16:42.750 --> 00:16:43.250 align:middle line:90%
Right?

00:16:43.250 --> 00:16:47.660 align:middle line:84%
So if I say sysinfo and
getuid, NT AUTHORITY SYSTEM

00:16:47.660 --> 00:16:51.320 align:middle line:84%
without having done whatever
we have done previously in

00:16:51.320 --> 00:16:53.570 align:middle line:84%
regards to obtaining
legitimate credentials,

00:16:53.570 --> 00:16:55.910 align:middle line:84%
and then using those
credentials to perform

00:16:55.910 --> 00:16:59.330 align:middle line:84%
remote command execution or
authenticated remote code

00:16:59.330 --> 00:17:00.690 align:middle line:90%
execution.

00:17:00.690 --> 00:17:03.590 align:middle line:90%
So that is how to target SMB.

00:17:03.590 --> 00:17:06.859 align:middle line:84%
As I said, you don't also
have to rely on the Metasploit

00:17:06.859 --> 00:17:09.890 align:middle line:84%
framework in regards to
exploiting the EternalBlue

00:17:09.890 --> 00:17:11.300 align:middle line:90%
vulnerability.

00:17:11.300 --> 00:17:15.890 align:middle line:84%
You can also utilize the actual
exploit code from ExploitDB.

00:17:15.890 --> 00:17:17.630 align:middle line:84%
The only reason why
I haven't done that

00:17:17.630 --> 00:17:20.150 align:middle line:84%
is because this lab
environment doesn't have access

00:17:20.150 --> 00:17:21.140 align:middle line:90%
to the internet.

00:17:21.140 --> 00:17:25.609 align:middle line:84%
And one of the actual
ExploitDB EternalBlue exploits

00:17:25.609 --> 00:17:28.310 align:middle line:84%
requires you to download
shellcode and utilize

00:17:28.310 --> 00:17:31.280 align:middle line:84%
that in conjunction with
the actual Python script.

00:17:31.280 --> 00:17:33.590 align:middle line:84%
But that's something that
you can try out as well.

00:17:33.590 --> 00:17:35.180 align:middle line:84%
As I said, I don't
want you to rely

00:17:35.180 --> 00:17:38.690 align:middle line:84%
on either manual techniques
or automated techniques alone.

00:17:38.690 --> 00:17:43.190 align:middle line:84%
You must be able to essentially
perform or use them both

00:17:43.190 --> 00:17:45.620 align:middle line:84%
and synthesize
whatever you are doing

00:17:45.620 --> 00:17:48.890 align:middle line:84%
in regards to testing or
to using both manual tools

00:17:48.890 --> 00:17:50.480 align:middle line:90%
and automated tools.

00:17:50.480 --> 00:17:52.310 align:middle line:84%
With that being
said, that is going

00:17:52.310 --> 00:17:54.380 align:middle line:84%
to conclude the
practical demonstration

00:17:54.380 --> 00:17:57.730 align:middle line:90%
side of this video.

00:17:57.730 --> 00:17:58.230 align:middle line:90%
All right.

00:17:58.230 --> 00:17:59.940 align:middle line:84%
So now that we have
taken a look at how

00:17:59.940 --> 00:18:02.880 align:middle line:84%
to exploit SMB and
consequently gain

00:18:02.880 --> 00:18:05.160 align:middle line:84%
remote access to
the target system,

00:18:05.160 --> 00:18:08.880 align:middle line:84%
we can now move on to the next
attack vector or the service

00:18:08.880 --> 00:18:11.040 align:middle line:84%
that we will be targeting,
and that, of course,

00:18:11.040 --> 00:18:14.160 align:middle line:84%
is going to be the
MySQL database server.

00:18:14.160 --> 00:18:17.460 align:middle line:84%
And we're going to be taking
a look at how our access

00:18:17.460 --> 00:18:21.570 align:middle line:84%
or how we can gain access
to the MySQL database server

00:18:21.570 --> 00:18:25.080 align:middle line:84%
and what that means for all
the web applications that

00:18:25.080 --> 00:18:27.960 align:middle line:84%
are currently being hosted
on the target system

00:18:27.960 --> 00:18:33.810 align:middle line:84%
and how we can utilize our MySQL
access to essentially modify

00:18:33.810 --> 00:18:37.560 align:middle line:84%
web application data or web
application customer data

00:18:37.560 --> 00:18:41.680 align:middle line:84%
that's being stored within
the actual MySQL database.

00:18:41.680 --> 00:18:42.180 align:middle line:90%
All right?

00:18:42.180 --> 00:18:45.500 align:middle line:84%
So I'll be seeing you
in the next video.

00:18:45.500 --> 00:18:46.000 align:middle line:90%