WEBVTT

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


00:00:03.416 --> 00:00:06.344 align:middle line:90%
[THEME MUSIC]

00:00:06.344 --> 00:00:10.260 align:middle line:90%


00:00:10.260 --> 00:00:14.850 align:middle line:84%
Exploiting WinRM, or the Windows
Remote Management protocol.

00:00:14.850 --> 00:00:17.760 align:middle line:84%
Now that we've taken a look at
how to exploit various Windows

00:00:17.760 --> 00:00:20.850 align:middle line:84%
services and protocols
like SMB and RDP,

00:00:20.850 --> 00:00:23.760 align:middle line:84%
let's turn our attention
to the final protocol

00:00:23.760 --> 00:00:27.150 align:middle line:84%
that we will be exploiting,
and that, of course, is WinRM.

00:00:27.150 --> 00:00:30.030 align:middle line:84%
Now, you may not have
heard about WinRM,

00:00:30.030 --> 00:00:32.880 align:middle line:84%
or if this is your first
time hearing about it,

00:00:32.880 --> 00:00:34.680 align:middle line:84%
I'll be explaining
that before we actually

00:00:34.680 --> 00:00:36.990 align:middle line:90%
get to the exploitation phase.

00:00:36.990 --> 00:00:39.900 align:middle line:84%
So before we get started
with exploitation,

00:00:39.900 --> 00:00:43.710 align:middle line:84%
let's get an idea of what
WinRM is, why it's used,

00:00:43.710 --> 00:00:47.550 align:middle line:84%
and the environments
you'll likely find it in

00:00:47.550 --> 00:00:49.780 align:middle line:84%
or you'll likely find
it configured in.

00:00:49.780 --> 00:00:54.840 align:middle line:84%
And the reason for that is
because WinRM is a feature that

00:00:54.840 --> 00:00:56.820 align:middle line:90%
exists within Windows.

00:00:56.820 --> 00:01:00.330 align:middle line:84%
However, it is not
configured to run by default

00:01:00.330 --> 00:01:03.390 align:middle line:84%
and needs to be explicitly
configured and enabled

00:01:03.390 --> 00:01:08.130 align:middle line:84%
in order for it to work and in
order for you to utilize it.

00:01:08.130 --> 00:01:09.960 align:middle line:90%
So first things first.

00:01:09.960 --> 00:01:11.220 align:middle line:90%
What is WinRM?

00:01:11.220 --> 00:01:14.640 align:middle line:84%
WinRM stands for the Windows
Remote Management protocol.

00:01:14.640 --> 00:01:17.130 align:middle line:84%
It is a Windows Remote
Management protocol

00:01:17.130 --> 00:01:19.830 align:middle line:84%
that can be used to facilitate
remote access with Windows

00:01:19.830 --> 00:01:23.700 align:middle line:90%
systems over HTTP or HTTPS.

00:01:23.700 --> 00:01:26.220 align:middle line:84%
So the reason Microsoft
implemented this feature

00:01:26.220 --> 00:01:29.070 align:middle line:84%
into Windows is primarily
to make life easier

00:01:29.070 --> 00:01:30.850 align:middle line:90%
for system administrators.

00:01:30.850 --> 00:01:33.360 align:middle line:90%
So let's take a simple example.

00:01:33.360 --> 00:01:37.560 align:middle line:84%
In a standard company
network, you'll

00:01:37.560 --> 00:01:40.410 align:middle line:84%
typically find a network
of Windows systems,

00:01:40.410 --> 00:01:41.820 align:middle line:90%
and they could number--

00:01:41.820 --> 00:01:46.350 align:middle line:84%
or range from anything from
5 computers to 50 computers.

00:01:46.350 --> 00:01:48.510 align:middle line:84%
And, of course, this
is a huge number

00:01:48.510 --> 00:01:52.140 align:middle line:84%
of computers to remotely
manage and maintain.

00:01:52.140 --> 00:01:54.180 align:middle line:84%
And within that
environment, you will

00:01:54.180 --> 00:01:56.220 align:middle line:90%
have a system administrator.

00:01:56.220 --> 00:02:00.450 align:middle line:84%
So a system administrator
can utilize WinRM in order

00:02:00.450 --> 00:02:03.690 align:middle line:84%
to essentially access and
interact with the Windows

00:02:03.690 --> 00:02:07.230 align:middle line:84%
systems on the local
network, and WinRM can also

00:02:07.230 --> 00:02:09.630 align:middle line:84%
be configured to run
across the internet.

00:02:09.630 --> 00:02:14.700 align:middle line:84%
So you can also configure WinRM
to run on a Windows Server,

00:02:14.700 --> 00:02:17.190 align:middle line:84%
and then remotely access
the Windows Server

00:02:17.190 --> 00:02:20.790 align:middle line:84%
and perform any types of
commands or functionality

00:02:20.790 --> 00:02:22.080 align:middle line:90%
that you'd like to perform.

00:02:22.080 --> 00:02:24.390 align:middle line:84%
But that's really not the
typical deployment case.

00:02:24.390 --> 00:02:27.960 align:middle line:84%
Well, in the shoes of
a system administrator,

00:02:27.960 --> 00:02:31.020 align:middle line:84%
this is a fantastic protocol
because, when they're

00:02:31.020 --> 00:02:33.720 align:middle line:84%
configuring the network, they
can configure every Windows

00:02:33.720 --> 00:02:38.590 align:middle line:84%
host on that network to run
WinRM or enable it-- or enable

00:02:38.590 --> 00:02:40.140 align:middle line:90%
WinRM on those hosts.

00:02:40.140 --> 00:02:43.170 align:middle line:84%
And they can then create
a user account already,

00:02:43.170 --> 00:02:45.780 align:middle line:84%
or if they already have
an administrator account

00:02:45.780 --> 00:02:47.850 align:middle line:84%
configured on those
Windows hosts,

00:02:47.850 --> 00:02:51.390 align:middle line:84%
they can utilize those
credentials to remotely access

00:02:51.390 --> 00:02:52.800 align:middle line:90%
these Windows systems.

00:02:52.800 --> 00:02:55.650 align:middle line:84%
And all they need to do is
provide the user account

00:02:55.650 --> 00:02:58.050 align:middle line:84%
username and the
password, and they

00:02:58.050 --> 00:03:00.060 align:middle line:84%
will be able to
essentially execute

00:03:00.060 --> 00:03:02.340 align:middle line:84%
Windows commands,
remotely interact

00:03:02.340 --> 00:03:06.460 align:middle line:84%
with them through a command
shell, so on and so forth.

00:03:06.460 --> 00:03:08.850 align:middle line:84%
Now, in terms of the
ports that WinRM runs on,

00:03:08.850 --> 00:03:14.370 align:middle line:84%
you'll typically find that it
runs on TCP port 5985 or 5986

00:03:14.370 --> 00:03:17.190 align:middle line:84%
if an SSL certificate
has been configured.

00:03:17.190 --> 00:03:24.162 align:middle line:84%
So always keep in mind that
WinRM runs on 5985 and 5986--

00:03:24.162 --> 00:03:26.470 align:middle line:90%
or 5986, for that matter.

00:03:26.470 --> 00:03:30.540 align:middle line:84%
So now that you're aware
of this protocol, let's

00:03:30.540 --> 00:03:33.810 align:middle line:84%
take a look at how
authentication is facilitated.

00:03:33.810 --> 00:03:36.720 align:middle line:84%
So WinRM implements access
control and security

00:03:36.720 --> 00:03:39.360 align:middle line:84%
for communication between
systems through various forms

00:03:39.360 --> 00:03:43.680 align:middle line:84%
of authentication, one of them
being just a simple username

00:03:43.680 --> 00:03:48.270 align:middle line:84%
and password authentication,
whereby the administrator--

00:03:48.270 --> 00:03:49.590 align:middle line:90%
going back to our example--

00:03:49.590 --> 00:03:54.510 align:middle line:84%
can essentially just provide the
target IP of the Windows system

00:03:54.510 --> 00:03:56.700 align:middle line:84%
that they're trying to
access or interact with.

00:03:56.700 --> 00:03:59.850 align:middle line:84%
They then provide the
user account username

00:03:59.850 --> 00:04:02.980 align:middle line:84%
and the password, and they'll
be able to do what they want.

00:04:02.980 --> 00:04:06.900 align:middle line:84%
Alternatively, you can also
provide a user account--

00:04:06.900 --> 00:04:10.440 align:middle line:84%
or, rather, the user account
username and a password hash,

00:04:10.440 --> 00:04:13.080 align:middle line:84%
and authenticate with
the password hash.

00:04:13.080 --> 00:04:15.570 align:middle line:84%
Now, in terms of
exploitation, we

00:04:15.570 --> 00:04:19.050 align:middle line:84%
will be utilizing a utility
called crackmapexec.

00:04:19.050 --> 00:04:21.329 align:middle line:84%
This is a penetration
testing utility

00:04:21.329 --> 00:04:24.300 align:middle line:84%
that you'll typically find
installed or pre-packaged

00:04:24.300 --> 00:04:26.610 align:middle line:84%
with penetration
testing distributions.

00:04:26.610 --> 00:04:29.880 align:middle line:84%
And we can utilize this utility
to perform a brute force

00:04:29.880 --> 00:04:33.690 align:middle line:84%
attack on WinRM in order
to identify legitimate user

00:04:33.690 --> 00:04:36.810 align:middle line:84%
accounts and their passwords,
as well as execute commands

00:04:36.810 --> 00:04:37.900 align:middle line:90%
on the target system.

00:04:37.900 --> 00:04:40.290 align:middle line:84%
So we can utilize it to
find legitimate credentials

00:04:40.290 --> 00:04:43.440 align:middle line:84%
that we can then use
to authenticate and run

00:04:43.440 --> 00:04:46.750 align:middle line:84%
arbitrary commands--
arbitrary Windows commands.

00:04:46.750 --> 00:04:48.480 align:middle line:84%
So, for example I
can execute commands

00:04:48.480 --> 00:04:51.840 align:middle line:84%
like ipconfig, Who
Am I, et cetera.

00:04:51.840 --> 00:04:53.640 align:middle line:84%
If we want to get
a command shell,

00:04:53.640 --> 00:04:58.170 align:middle line:84%
however, we can utilize a
Ruby script called evil-winrm.

00:04:58.170 --> 00:05:01.200 align:middle line:84%
And this utility-- again,
we'll be taking a look

00:05:01.200 --> 00:05:03.060 align:middle line:84%
at how to use both of
them, but this utility

00:05:03.060 --> 00:05:04.860 align:middle line:84%
is extremely helpful
because once we've

00:05:04.860 --> 00:05:08.030 align:middle line:84%
obtained credentials, we can
utilize it to get a command

00:05:08.030 --> 00:05:10.130 align:middle line:90%
shell session on the target.

00:05:10.130 --> 00:05:11.930 align:middle line:84%
We'll also be
exploring the process

00:05:11.930 --> 00:05:15.010 align:middle line:84%
of obtaining a Meterpreter
session through WinRM.

00:05:15.010 --> 00:05:16.760 align:middle line:84%
And, of course, that
will be facilitated

00:05:16.760 --> 00:05:18.390 align:middle line:84%
through the
Metasploit framework.

00:05:18.390 --> 00:05:20.900 align:middle line:84%
So we're going to be covering
a lot of these techniques

00:05:20.900 --> 00:05:23.210 align:middle line:84%
and a lot of tools,
and hopefully,

00:05:23.210 --> 00:05:26.840 align:middle line:84%
by the end of this video, you'll
be comfortable with WinRM,

00:05:26.840 --> 00:05:28.340 align:middle line:84%
and you'll have a
good understanding

00:05:28.340 --> 00:05:32.600 align:middle line:84%
of how you can perform an
attack on it or on the protocol.

00:05:32.600 --> 00:05:36.020 align:middle line:84%
So the lab environment
for this particular video

00:05:36.020 --> 00:05:39.140 align:middle line:84%
already has all of these tools
prepackaged and configured,

00:05:39.140 --> 00:05:41.630 align:middle line:84%
so you don't need to download
any additional tools.

00:05:41.630 --> 00:05:44.750 align:middle line:84%
So fire up the lab
environment, as will I,

00:05:44.750 --> 00:05:49.030 align:middle line:84%
and I'll see you within
the lab environment.

00:05:49.030 --> 00:05:51.290 align:middle line:84%
So I'm back within
the lab environment,

00:05:51.290 --> 00:05:53.503 align:middle line:84%
and you will be provided
with the target IP.

00:05:53.503 --> 00:05:55.670 align:middle line:84%
Of course, in your case,
it's going to be different.

00:05:55.670 --> 00:05:58.620 align:middle line:90%
So I'm just going to copy that.

00:05:58.620 --> 00:05:59.440 align:middle line:90%
There we go.

00:05:59.440 --> 00:06:01.380 align:middle line:84%
And the first step,
of course, will

00:06:01.380 --> 00:06:03.870 align:middle line:84%
involve performing an
Nmap scan on the target

00:06:03.870 --> 00:06:07.050 align:middle line:84%
in order to identify whether
WinRM is actually enabled

00:06:07.050 --> 00:06:08.280 align:middle line:90%
and running.

00:06:08.280 --> 00:06:09.960 align:middle line:84%
So I'll just zoom in
a little bit here,

00:06:09.960 --> 00:06:12.870 align:middle line:90%
and we'll say nmap -sV.

00:06:12.870 --> 00:06:15.360 align:middle line:84%
And we can also
specify the entire port

00:06:15.360 --> 00:06:17.860 align:middle line:84%
range or the specific ports
that we're interested in.

00:06:17.860 --> 00:06:21.030 align:middle line:84%
But for the purpose of
being time efficient,

00:06:21.030 --> 00:06:24.023 align:middle line:84%
I'll just provide the target
IP, and I'll hit Enter.

00:06:24.023 --> 00:06:26.190 align:middle line:84%
And, of course, I'll give
this a couple of seconds--

00:06:26.190 --> 00:06:29.230 align:middle line:84%
or, a couple of
minutes to complete.

00:06:29.230 --> 00:06:33.190 align:middle line:84%
The scan completes, but we see
that we cannot identify port

00:06:33.190 --> 00:06:34.630 align:middle line:90%
5985.

00:06:34.630 --> 00:06:37.960 align:middle line:84%
And the reason for that is
because the default Nmap scan,

00:06:37.960 --> 00:06:40.240 align:middle line:84%
or the default
ports with an Nmap--

00:06:40.240 --> 00:06:42.250 align:middle line:84%
the default ports
that have been scanned

00:06:42.250 --> 00:06:44.770 align:middle line:84%
with this particular
scan here are only

00:06:44.770 --> 00:06:47.780 align:middle line:84%
limited to 1,000 of
the most common--

00:06:47.780 --> 00:06:49.780 align:middle line:84%
1,000 of the most
commonly used ports.

00:06:49.780 --> 00:06:52.630 align:middle line:84%
So what we can do is
we can perform an Nmap

00:06:52.630 --> 00:06:54.190 align:middle line:90%
scan on that exact port.

00:06:54.190 --> 00:06:57.964 align:middle line:84%
So we are going to
say port is 5985.

00:06:57.964 --> 00:07:00.310 align:middle line:84%
And, of course, we can
change that to 5986

00:07:00.310 --> 00:07:03.700 align:middle line:84%
or just specify the range of
ports that you'd like to scan.

00:07:03.700 --> 00:07:08.140 align:middle line:84%
In this case, we'll just say
5985, and I'll then hit Enter.

00:07:08.140 --> 00:07:10.570 align:middle line:84%
And, of course, this
will take much less time

00:07:10.570 --> 00:07:12.340 align:middle line:84%
because we're only
scanning one port.

00:07:12.340 --> 00:07:14.560 align:middle line:84%
So I'm just going to wait
for this to complete.

00:07:14.560 --> 00:07:15.340 align:middle line:90%
There we are.

00:07:15.340 --> 00:07:18.100 align:middle line:84%
You can see 5985
is currently open.

00:07:18.100 --> 00:07:21.520 align:middle line:84%
Now, don't really pay
attention to the actual banner

00:07:21.520 --> 00:07:25.000 align:middle line:84%
or the service version that's
displayed here, primarily

00:07:25.000 --> 00:07:26.290 align:middle line:90%
because Nmap--

00:07:26.290 --> 00:07:30.260 align:middle line:84%
or, rather, Windows
systems don't explicitly

00:07:30.260 --> 00:07:33.880 align:middle line:84%
have a banner telling
you that this is WinRM.

00:07:33.880 --> 00:07:35.510 align:middle line:90%
So do keep that in mind.

00:07:35.510 --> 00:07:37.720 align:middle line:84%
But we do know that
WinRM is running

00:07:37.720 --> 00:07:39.100 align:middle line:90%
on this particular port.

00:07:39.100 --> 00:07:40.810 align:middle line:84%
And, of course, we
can confirm that this

00:07:40.810 --> 00:07:45.230 align:middle line:84%
is the case through the use
of the crackmapexec utility.

00:07:45.230 --> 00:07:47.830 align:middle line:84%
So, for example, I'll
just clear up my terminal.

00:07:47.830 --> 00:07:51.280 align:middle line:84%
We can launch the tool
by saying crackmapexec.

00:07:51.280 --> 00:07:53.410 align:middle line:90%
There we are, and we hit Enter.

00:07:53.410 --> 00:07:56.470 align:middle line:84%
So give that a couple
of seconds to start up.

00:07:56.470 --> 00:07:59.390 align:middle line:84%
And taking a look at
the documentation,

00:07:59.390 --> 00:08:01.210 align:middle line:84%
you can see that
this is a Swiss army

00:08:01.210 --> 00:08:03.070 align:middle line:90%
knife for pen testing networks.

00:08:03.070 --> 00:08:05.080 align:middle line:84%
And it's very important
that I take you

00:08:05.080 --> 00:08:08.890 align:middle line:84%
through how to utilize this tool
because you will be using it

00:08:08.890 --> 00:08:12.050 align:middle line:90%
a lot during a penetration test.

00:08:12.050 --> 00:08:15.010 align:middle line:84%
So the key area I want
you to focus on here

00:08:15.010 --> 00:08:16.450 align:middle line:90%
is the supported protocol.

00:08:16.450 --> 00:08:21.130 align:middle line:84%
So not only can you use
crackmapexec to attack WinRM.

00:08:21.130 --> 00:08:25.990 align:middle line:84%
You can also use it to
attack SSH, SMB, and MSSQL.

00:08:25.990 --> 00:08:30.580 align:middle line:84%
However, in this case, we will
be primarily focusing on WinRM.

00:08:30.580 --> 00:08:34.240 align:middle line:84%
So to perform the brute-force
attack, we can say--

00:08:34.240 --> 00:08:39.260 align:middle line:84%
or, we can essentially just type
in crackmapexec exec, and then

00:08:39.260 --> 00:08:41.360 align:middle line:84%
we specify the protocol
that we are attacking.

00:08:41.360 --> 00:08:42.860 align:middle line:90%
In this case, it's WinRM.

00:08:42.860 --> 00:08:45.140 align:middle line:90%
We then specify the target IP.

00:08:45.140 --> 00:08:45.920 align:middle line:90%
There we are.

00:08:45.920 --> 00:08:47.490 align:middle line:90%
I've just pasted it in there.

00:08:47.490 --> 00:08:52.130 align:middle line:84%
We can then specify the actual
list or the word list that

00:08:52.130 --> 00:08:55.100 align:middle line:84%
contains the usernames that
we would like to perform

00:08:55.100 --> 00:08:56.720 align:middle line:90%
the brute force with.

00:08:56.720 --> 00:08:59.210 align:middle line:84%
In this case, we will--
because we're only

00:08:59.210 --> 00:09:02.420 align:middle line:84%
looking for specific types of
accounts like the administrator

00:09:02.420 --> 00:09:04.790 align:middle line:84%
account, we will
explicitly say we

00:09:04.790 --> 00:09:06.500 align:middle line:84%
want to perform
an administer-- we

00:09:06.500 --> 00:09:08.990 align:middle line:84%
want to perform the brute force
attack on the administrator

00:09:08.990 --> 00:09:12.020 align:middle line:84%
account in order to identify
the administrator's account

00:09:12.020 --> 00:09:13.160 align:middle line:90%
password.

00:09:13.160 --> 00:09:16.040 align:middle line:84%
So we'll say administrator,
and we can then

00:09:16.040 --> 00:09:18.343 align:middle line:84%
specify the actual
word list that

00:09:18.343 --> 00:09:20.510 align:middle line:84%
contains the passwords that
we would like to perform

00:09:20.510 --> 00:09:21.500 align:middle line:90%
the brute force with.

00:09:21.500 --> 00:09:23.167 align:middle line:84%
And the one that we're
going to be using

00:09:23.167 --> 00:09:28.430 align:middle line:84%
is under usr/share/metasploit
framework/data/wordlists,

00:09:28.430 --> 00:09:31.280 align:middle line:84%
and we are going to
use unix_passwords.

00:09:31.280 --> 00:09:33.800 align:middle line:84%
And, of course, in your case,
feel free to change around

00:09:33.800 --> 00:09:37.820 align:middle line:84%
or to utilize any
different word lists

00:09:37.820 --> 00:09:39.140 align:middle line:90%
that you would like to use.

00:09:39.140 --> 00:09:40.640 align:middle line:84%
And, of course, you
have the ability

00:09:40.640 --> 00:09:43.100 align:middle line:84%
to generate your
own word lists when

00:09:43.100 --> 00:09:44.480 align:middle line:90%
performing password cracking.

00:09:44.480 --> 00:09:46.880 align:middle line:84%
So, again, in this
case, this is just

00:09:46.880 --> 00:09:48.980 align:middle line:84%
for the purpose
of demonstration.

00:09:48.980 --> 00:09:51.480 align:middle line:84%
Now, as I said, you might be
thinking to yourself, well,

00:09:51.480 --> 00:09:53.930 align:middle line:84%
why are we only targeting
the administrator account?

00:09:53.930 --> 00:09:56.630 align:middle line:84%
Well, let's take a few
things into consideration.

00:09:56.630 --> 00:09:58.400 align:middle line:84%
We know that on
a Windows system,

00:09:58.400 --> 00:10:01.520 align:middle line:84%
the administrator account
is definitely there

00:10:01.520 --> 00:10:03.770 align:middle line:84%
because it's the first
account that's created

00:10:03.770 --> 00:10:05.930 align:middle line:90%
when you install Windows.

00:10:05.930 --> 00:10:08.750 align:middle line:84%
And secondly, the
administrator account

00:10:08.750 --> 00:10:10.280 align:middle line:84%
is typically the
user account that's

00:10:10.280 --> 00:10:13.910 align:middle line:84%
going to be used or accessed
by system administrators

00:10:13.910 --> 00:10:15.380 align:middle line:90%
for obvious reasons.

00:10:15.380 --> 00:10:17.840 align:middle line:84%
And, of course, thirdly,
if we gain access

00:10:17.840 --> 00:10:19.370 align:middle line:84%
to the administrator
account, that

00:10:19.370 --> 00:10:21.300 align:middle line:84%
means we'll have
elevated privileges,

00:10:21.300 --> 00:10:23.330 align:middle line:84%
and we will not have to
go through the process

00:10:23.330 --> 00:10:26.630 align:middle line:84%
of elevating our
privileges manually.

00:10:26.630 --> 00:10:30.600 align:middle line:84%
So we have specified
all the options there,

00:10:30.600 --> 00:10:31.940 align:middle line:90%
and we can just hit Enter.

00:10:31.940 --> 00:10:33.950 align:middle line:84%
That's going to perform
the brute force.

00:10:33.950 --> 00:10:36.020 align:middle line:84%
So give this a
couple of seconds.

00:10:36.020 --> 00:10:36.590 align:middle line:90%
There we are.

00:10:36.590 --> 00:10:38.540 align:middle line:84%
At the end, you can
see tells us that we

00:10:38.540 --> 00:10:42.440 align:middle line:84%
have a successful brute force
or authentication attempt,

00:10:42.440 --> 00:10:46.340 align:middle line:84%
and it tells us that for the
username or the user account

00:10:46.340 --> 00:10:48.680 align:middle line:84%
administrator, the
password is Tinkerbell,

00:10:48.680 --> 00:10:50.930 align:middle line:84%
and it'll tell you,
right over here, Pwn3d.

00:10:50.930 --> 00:10:53.310 align:middle line:84%
If we take a look at the
output at the beginning here--

00:10:53.310 --> 00:10:55.820 align:middle line:84%
I just want to cover
that right now--

00:10:55.820 --> 00:10:58.550 align:middle line:84%
you can see that it
actually connects to--

00:10:58.550 --> 00:10:59.888 align:middle line:90%
it actually connects to WinRM.

00:10:59.888 --> 00:11:01.430 align:middle line:84%
Don't worry if it
tells you that it's

00:11:01.430 --> 00:11:05.840 align:middle line:84%
using the wsman or
the wsman service

00:11:05.840 --> 00:11:09.860 align:middle line:84%
because WinRM is essentially
an implementation of wsman

00:11:09.860 --> 00:11:13.550 align:middle line:84%
or Windows Management, or
the Windows Management API.

00:11:13.550 --> 00:11:17.090 align:middle line:84%
So now that we've
identified the credentials,

00:11:17.090 --> 00:11:20.810 align:middle line:84%
we can utilize crackmapexec
to execute arbitrary

00:11:20.810 --> 00:11:22.200 align:middle line:90%
Windows commands on the target.

00:11:22.200 --> 00:11:26.630 align:middle line:84%
So, for example, we
can say crackmapexec.

00:11:26.630 --> 00:11:30.440 align:middle line:84%
We then specify WinRM
and then the target IP.

00:11:30.440 --> 00:11:32.030 align:middle line:90%
So I'll paste that in there.

00:11:32.030 --> 00:11:37.290 align:middle line:84%
And we can specify the username,
which is administrator.

00:11:37.290 --> 00:11:37.890 align:middle line:90%
Here we are.

00:11:37.890 --> 00:11:41.070 align:middle line:84%
And the password in this
case is Tinkerbell not.

00:11:41.070 --> 00:11:44.370 align:middle line:84%
A very strong password, but
there you go, Tinkerbell.

00:11:44.370 --> 00:11:48.640 align:middle line:84%
And we can then use the X option
to execute a specific command.

00:11:48.640 --> 00:11:54.170 align:middle line:84%
So, for example, I can say
whoami, and I'll hit Enter.

00:11:54.170 --> 00:11:56.270 align:middle line:84%
You can see that it
connects to WinRM.

00:11:56.270 --> 00:11:59.330 align:middle line:84%
It authenticates successfully,
and it tells us--

00:11:59.330 --> 00:12:02.030 align:middle line:84%
it provides us with the
output of our command, whoami.

00:12:02.030 --> 00:12:04.850 align:middle line:84%
So we currently
server administrator.

00:12:04.850 --> 00:12:08.330 align:middle line:84%
And we can also
execute other commands

00:12:08.330 --> 00:12:11.840 align:middle line:84%
that are vital during
a penetration test,

00:12:11.840 --> 00:12:13.700 align:middle line:84%
like system info,
which will enumerate

00:12:13.700 --> 00:12:17.160 align:middle line:84%
all the information pertinent
to this particular system.

00:12:17.160 --> 00:12:18.200 align:middle line:90%
So I'll hit Enter.

00:12:18.200 --> 00:12:19.910 align:middle line:84%
This command usually
takes a while,

00:12:19.910 --> 00:12:22.800 align:middle line:84%
so we're just going to give
it a couple of seconds here.

00:12:22.800 --> 00:12:23.480 align:middle line:90%
There we are.

00:12:23.480 --> 00:12:24.950 align:middle line:84%
So if we take a
look at the output,

00:12:24.950 --> 00:12:27.620 align:middle line:84%
this command will tell us that
it's running Windows Server

00:12:27.620 --> 00:12:31.190 align:middle line:84%
2019, and it provides us
with the build number right

00:12:31.190 --> 00:12:31.920 align:middle line:90%
over there.

00:12:31.920 --> 00:12:33.620 align:middle line:84%
And, of course, what
we've done here--

00:12:33.620 --> 00:12:35.660 align:middle line:84%
we've not utilized
any exploit code

00:12:35.660 --> 00:12:40.760 align:middle line:84%
or exploited a
vulnerability within WinRM.

00:12:40.760 --> 00:12:42.950 align:middle line:84%
We've simply performed
a brute-force attack,

00:12:42.950 --> 00:12:45.770 align:middle line:84%
and we're now utilizing
the WinRM protocol

00:12:45.770 --> 00:12:49.880 align:middle line:84%
to legitimately execute
commands on the target system.

00:12:49.880 --> 00:12:53.000 align:middle line:84%
And, of course, executing
commands on a target system

00:12:53.000 --> 00:12:55.590 align:middle line:84%
will have its own number
of logs, which you can,

00:12:55.590 --> 00:12:58.190 align:middle line:90%
of course, clear very easily.

00:12:58.190 --> 00:13:01.490 align:middle line:84%
But this is relatively
safe because, again,

00:13:01.490 --> 00:13:06.530 align:middle line:84%
if WinRM is enabled on a target,
a firewall rule or exception

00:13:06.530 --> 00:13:08.510 align:middle line:84%
will be added so
you can communicate

00:13:08.510 --> 00:13:12.950 align:middle line:84%
with the system via WinRM,
without any restriction.

00:13:12.950 --> 00:13:17.120 align:middle line:84%
So that's cool, but can we
obtain a command shell session?

00:13:17.120 --> 00:13:20.600 align:middle line:84%
Well, we can, and the tool
we'll be using-- or, rather,

00:13:20.600 --> 00:13:25.490 align:middle line:84%
the Ruby script that we'll be
using is called evil-winrm.

00:13:25.490 --> 00:13:26.390 align:middle line:90%
So there we are.

00:13:26.390 --> 00:13:28.580 align:middle line:84%
It's already configured
on this system.

00:13:28.580 --> 00:13:32.420 align:middle line:84%
And in order to use it, we can
essentially say evil-winrm,

00:13:32.420 --> 00:13:34.910 align:middle line:84%
and then we specify the
username, which, in this case,

00:13:34.910 --> 00:13:36.290 align:middle line:90%
is administrator.

00:13:36.290 --> 00:13:39.500 align:middle line:84%
And we can then specify
the password, which I will

00:13:39.500 --> 00:13:42.520 align:middle line:90%
encapsulate in single quotes.

00:13:42.520 --> 00:13:43.300 align:middle line:90%
Tinkerbell.

00:13:43.300 --> 00:13:44.270 align:middle line:90%
There we are.

00:13:44.270 --> 00:13:47.470 align:middle line:84%
And then the IP is specified
using the i option,

00:13:47.470 --> 00:13:49.250 align:middle line:90%
and we can paste that in there.

00:13:49.250 --> 00:13:51.070 align:middle line:84%
This will automatically
provide us

00:13:51.070 --> 00:13:52.420 align:middle line:90%
with a command shell session.

00:13:52.420 --> 00:13:55.278 align:middle line:90%
So I'll hit Enter.

00:13:55.278 --> 00:13:55.820 align:middle line:90%
There we are.

00:13:55.820 --> 00:14:00.140 align:middle line:84%
You can evil-winrm shell version
2.3, establishing connection

00:14:00.140 --> 00:14:03.950 align:middle line:84%
to the remote endpoint, and
we get a command shell session

00:14:03.950 --> 00:14:06.470 align:middle line:90%
facilitated through PowerShell.

00:14:06.470 --> 00:14:09.930 align:middle line:84%
So we currently have access
to the target system,

00:14:09.930 --> 00:14:11.640 align:middle line:90%
and we can do whatever we want.

00:14:11.640 --> 00:14:19.030 align:middle line:84%
So, for example, I can say
whoami, ipconfig, net user,

00:14:19.030 --> 00:14:21.730 align:middle line:84%
and you can see we have other
user accounts on the system

00:14:21.730 --> 00:14:24.520 align:middle line:84%
like sysadmin, auditor,
et cetera, et cetera.

00:14:24.520 --> 00:14:25.770 align:middle line:90%
So this is great.

00:14:25.770 --> 00:14:28.120 align:middle line:84%
We've established access
with the target system,

00:14:28.120 --> 00:14:30.430 align:middle line:84%
and we can always
establish access

00:14:30.430 --> 00:14:33.100 align:middle line:84%
with the target system
via WinRM as long

00:14:33.100 --> 00:14:37.090 align:middle line:84%
as we have the credentials
that we were able to identify.

00:14:37.090 --> 00:14:39.520 align:middle line:84%
We can also obtain a
Meterpreter session

00:14:39.520 --> 00:14:41.470 align:middle line:84%
through the use of the
Metasploit framework.

00:14:41.470 --> 00:14:44.050 align:middle line:84%
So I'll open up a new
tab here, and I'll

00:14:44.050 --> 00:14:46.270 align:middle line:84%
start up the PostgreSQL
Database Service.

00:14:46.270 --> 00:14:49.610 align:middle line:90%


00:14:49.610 --> 00:14:53.090 align:middle line:84%
And we'll also start
up msfconsole here.

00:14:53.090 --> 00:14:55.940 align:middle line:84%
And we'll just wait
for this to start up.

00:14:55.940 --> 00:14:57.320 align:middle line:90%
So that is started up.

00:14:57.320 --> 00:14:59.720 align:middle line:84%
So the module that we're
going to be utilizing

00:14:59.720 --> 00:15:03.620 align:middle line:84%
is a module called
WinRM Script Exec.

00:15:03.620 --> 00:15:06.930 align:middle line:90%
So winrm_script.

00:15:06.930 --> 00:15:07.930 align:middle line:90%
That should bring it up.

00:15:07.930 --> 00:15:08.450 align:middle line:90%
There we are.

00:15:08.450 --> 00:15:09.408 align:middle line:90%
That's the module here.

00:15:09.408 --> 00:15:12.580 align:middle line:84%
So this is an exploit module
for Windows and WinRM,

00:15:12.580 --> 00:15:15.760 align:middle line:84%
and it essentially allows us to
perform remote code execution.

00:15:15.760 --> 00:15:18.070 align:middle line:84%
But more specifically,
it will allow

00:15:18.070 --> 00:15:22.330 align:middle line:84%
us to essentially establish or
obtain a Meterpreter session.

00:15:22.330 --> 00:15:25.857 align:middle line:84%
So I'll say use,
paste that in there,

00:15:25.857 --> 00:15:27.690 align:middle line:84%
and it's going to say
no payload configured.

00:15:27.690 --> 00:15:30.520 align:middle line:84%
It'll use the default
32-bit interpreter payload,

00:15:30.520 --> 00:15:31.560 align:middle line:90%
which is perfectly fine.

00:15:31.560 --> 00:15:34.350 align:middle line:84%
Of course, you can change
that to a 64-bit payload

00:15:34.350 --> 00:15:35.430 align:middle line:90%
if you want.

00:15:35.430 --> 00:15:37.380 align:middle line:84%
We then need to set
up the target IP,

00:15:37.380 --> 00:15:39.180 align:middle line:84%
so I'm just going
to copy that here.

00:15:39.180 --> 00:15:42.570 align:middle line:84%
If we show the options for
this particular module,

00:15:42.570 --> 00:15:47.400 align:middle line:84%
we can see that we need to
specify the actual target,

00:15:47.400 --> 00:15:48.360 align:middle line:90%
the target IP.

00:15:48.360 --> 00:15:52.260 align:middle line:84%
The rport has been
configured to 5985,

00:15:52.260 --> 00:15:53.830 align:middle line:90%
which is fine in this case.

00:15:53.830 --> 00:15:55.110 align:middle line:90%
So we'll say set RHOSTS.

00:15:55.110 --> 00:16:00.200 align:middle line:90%


00:16:00.200 --> 00:16:00.860 align:middle line:90%
There we are.

00:16:00.860 --> 00:16:02.420 align:middle line:90%
Paste in the target IP.

00:16:02.420 --> 00:16:03.920 align:middle line:84%
And, of course, you
have the ability

00:16:03.920 --> 00:16:06.920 align:middle line:84%
to configure the payload options
for the Meterpreter session.

00:16:06.920 --> 00:16:11.720 align:middle line:84%
So your LHOST value here is your
IP, your Kali Linux IP address.

00:16:11.720 --> 00:16:15.140 align:middle line:84%
And the LPORT option is the
port you will be listening on

00:16:15.140 --> 00:16:18.080 align:middle line:84%
for the connection from
the Meterpreter payload,

00:16:18.080 --> 00:16:21.330 align:middle line:84%
once the second
stage is executed.

00:16:21.330 --> 00:16:26.390 align:middle line:84%
In this case, we want to set
the force VBS option to true.

00:16:26.390 --> 00:16:28.010 align:middle line:84%
This will essentially
force the module

00:16:28.010 --> 00:16:30.650 align:middle line:84%
to use a Visual
Basic command stager.

00:16:30.650 --> 00:16:36.080 align:middle line:90%
So we'll set FORCE_VBS to true.

00:16:36.080 --> 00:16:39.950 align:middle line:84%
And we then need to specify
the username and the password.

00:16:39.950 --> 00:16:42.290 align:middle line:84%
So in this case, the
username is administrator,

00:16:42.290 --> 00:16:43.910 align:middle line:90%
and the password is Tinkerbell.

00:16:43.910 --> 00:16:55.740 align:middle line:84%
So I'll say set USERNAME and
set the password to Tinkerbell.

00:16:55.740 --> 00:16:57.070 align:middle line:90%
There we are.

00:16:57.070 --> 00:16:58.335 align:middle line:90%
And we can then hit exploit.

00:16:58.335 --> 00:17:04.109 align:middle line:90%


00:17:04.109 --> 00:17:06.720 align:middle line:84%
So it's going to begin
sending the command stager.

00:17:06.720 --> 00:17:09.150 align:middle line:84%
So we'll give this a couple
of seconds to complete.

00:17:09.150 --> 00:17:12.359 align:middle line:84%
This particular exploit
module might not work,

00:17:12.359 --> 00:17:13.787 align:middle line:84%
and you have to
keep retrying it.

00:17:13.787 --> 00:17:15.329 align:middle line:84%
In this case, let's
see whether we'll

00:17:15.329 --> 00:17:17.040 align:middle line:84%
be able to obtain a
Meterpreter session.

00:17:17.040 --> 00:17:20.230 align:middle line:90%


00:17:20.230 --> 00:17:23.109 align:middle line:84%
So it completes
sending the stage,

00:17:23.109 --> 00:17:25.810 align:middle line:84%
and you can see that
it tells us right away,

00:17:25.810 --> 00:17:27.819 align:middle line:84%
a Meterpreter
session one opened.

00:17:27.819 --> 00:17:31.960 align:middle line:84%
And the current session is
under the process xyjhd.exe

00:17:31.960 --> 00:17:33.910 align:middle line:90%
as server administrator.

00:17:33.910 --> 00:17:38.260 align:middle line:84%
It'll successfully migrate
to SVC host for stability

00:17:38.260 --> 00:17:40.120 align:middle line:90%
as anti-authority system.

00:17:40.120 --> 00:17:43.078 align:middle line:90%
So we can say sysinfo.

00:17:43.078 --> 00:17:43.620 align:middle line:90%
There we are.

00:17:43.620 --> 00:17:45.900 align:middle line:84%
We now have a 64-bit
Meterpreter possession

00:17:45.900 --> 00:17:48.600 align:middle line:84%
because it migrates
to a 64-bit process.

00:17:48.600 --> 00:17:51.085 align:middle line:84%
And we then get the
privileges associated

00:17:51.085 --> 00:17:52.710 align:middle line:84%
with that process,
which, in this case,

00:17:52.710 --> 00:17:54.630 align:middle line:90%
is NT AUTHORITY/SYSTEM.

00:17:54.630 --> 00:17:57.750 align:middle line:84%
And we have successfully been
able to obtain an Meterpreter

00:17:57.750 --> 00:18:01.200 align:middle line:84%
session on the target
system via WinRM.

00:18:01.200 --> 00:18:03.180 align:middle line:84%
And, of course, this
particular exploit module

00:18:03.180 --> 00:18:04.410 align:middle line:90%
requires credentials.

00:18:04.410 --> 00:18:07.900 align:middle line:84%
So you will need to perform the
brute-force attack beforehand.

00:18:07.900 --> 00:18:09.660 align:middle line:84%
And as I said,
there's multiple tools

00:18:09.660 --> 00:18:11.430 align:middle line:84%
that you can use
to attack WinRM.

00:18:11.430 --> 00:18:16.090 align:middle line:84%
One of them is crackmapexec
and, of course, evil-winrm.

00:18:16.090 --> 00:18:18.090 align:middle line:84%
Of course, if you want
to utilize the Metasploit

00:18:18.090 --> 00:18:21.870 align:middle line:84%
framework for exploitation,
you can also do that as well.

00:18:21.870 --> 00:18:24.690 align:middle line:84%
So that is going to conclude
the practical demonstration

00:18:24.690 --> 00:18:27.680 align:middle line:90%
side of this video.

00:18:27.680 --> 00:18:31.160 align:middle line:84%
So that is going to conclude
the Windows exploitation

00:18:31.160 --> 00:18:32.810 align:middle line:90%
section of this course.

00:18:32.810 --> 00:18:35.060 align:middle line:84%
In the next section,
we'll begin taking a look

00:18:35.060 --> 00:18:36.710 align:middle line:84%
at the various
privilege escalation

00:18:36.710 --> 00:18:40.370 align:middle line:84%
techniques we can use to elevate
our privileges on Windows

00:18:40.370 --> 00:18:44.300 align:middle line:84%
systems after we've gained
initial access on them.

00:18:44.300 --> 00:18:47.590 align:middle line:84%
So I'll see you in
the next section.

00:18:47.590 --> 00:18:49.000 align:middle line:90%