WEBVTT

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


00:00:03.367 --> 00:00:08.658 align:middle line:90%
[LOGO WHOOSHING]

00:00:08.658 --> 00:00:10.110 align:middle line:90%


00:00:10.110 --> 00:00:13.500 align:middle line:84%
Windows Privilege Escalation:
Token Impersonation

00:00:13.500 --> 00:00:15.120 align:middle line:90%
With Incognito.

00:00:15.120 --> 00:00:17.340 align:middle line:84%
In this video, we are
going to be exploring

00:00:17.340 --> 00:00:21.600 align:middle line:84%
the process of elevating our
privileges on a Windows system

00:00:21.600 --> 00:00:22.950 align:middle line:90%
through the use--

00:00:22.950 --> 00:00:25.920 align:middle line:84%
through the technique of
impersonating access tokens,

00:00:25.920 --> 00:00:29.550 align:middle line:84%
and this will be facilitated
by an inbuilt meterpreter

00:00:29.550 --> 00:00:31.470 align:middle line:90%
module called incognito.

00:00:31.470 --> 00:00:33.630 align:middle line:84%
Now, before we can
actually get started

00:00:33.630 --> 00:00:35.580 align:middle line:84%
with token impersonation,
we actually

00:00:35.580 --> 00:00:39.360 align:middle line:84%
need to understand what
a Windows access token is

00:00:39.360 --> 00:00:41.880 align:middle line:84%
and how it's used,
why it's used,

00:00:41.880 --> 00:00:44.880 align:middle line:84%
and how we can abuse Windows
access tokens to elevate

00:00:44.880 --> 00:00:45.810 align:middle line:90%
our privileges.

00:00:45.810 --> 00:00:50.070 align:middle line:84%
So, first and foremost, what
is a Windows access token?

00:00:50.070 --> 00:00:52.290 align:middle line:84%
Well, a Windows access
token is essentially

00:00:52.290 --> 00:00:54.780 align:middle line:84%
a core element of the
authentication process

00:00:54.780 --> 00:00:57.840 align:middle line:84%
on Windows, and they
are created and managed

00:00:57.840 --> 00:01:01.890 align:middle line:84%
by the Local Security Authority
Subsystem Service, also known

00:01:01.890 --> 00:01:02.910 align:middle line:90%
as LSASS.

00:01:02.910 --> 00:01:05.880 align:middle line:84%
So if you've ever opened up
the Task Manager on a Windows

00:01:05.880 --> 00:01:10.110 align:middle line:84%
system and headed over
to the Services tab,

00:01:10.110 --> 00:01:12.270 align:middle line:84%
you might have noticed
a small service

00:01:12.270 --> 00:01:15.190 align:middle line:84%
or a service called
lsass.exe running.

00:01:15.190 --> 00:01:18.390 align:middle line:84%
So that is the Local Security
Authority Subsystem Service.

00:01:18.390 --> 00:01:21.840 align:middle line:84%
And that service is essentially
responsible for creating

00:01:21.840 --> 00:01:25.140 align:middle line:84%
and managing Windows
access tokens on Windows.

00:01:25.140 --> 00:01:28.560 align:middle line:84%
So our Windows access
token is essentially

00:01:28.560 --> 00:01:31.500 align:middle line:84%
responsible for
identifying and describing

00:01:31.500 --> 00:01:34.470 align:middle line:84%
the security context of the
process or thread running

00:01:34.470 --> 00:01:35.340 align:middle line:90%
on a system.

00:01:35.340 --> 00:01:37.440 align:middle line:84%
Simply put, an
access token can be

00:01:37.440 --> 00:01:41.610 align:middle line:84%
thought of as a temporary
key akin to a web cookie that

00:01:41.610 --> 00:01:45.150 align:middle line:84%
provides users with access to
a system or network resource

00:01:45.150 --> 00:01:47.130 align:middle line:84%
without having to
provide credentials

00:01:47.130 --> 00:01:50.250 align:middle line:84%
each time a process is
started, or a system resource

00:01:50.250 --> 00:01:51.490 align:middle line:90%
is accessed.

00:01:51.490 --> 00:01:54.420 align:middle line:84%
So the reason
Windows access tokens

00:01:54.420 --> 00:01:57.390 align:middle line:84%
are implemented into Windows
is to essentially eliminate

00:01:57.390 --> 00:02:02.490 align:middle line:84%
the process of having a
user to essentially enter

00:02:02.490 --> 00:02:04.470 align:middle line:84%
their password or
their credentials

00:02:04.470 --> 00:02:07.560 align:middle line:84%
whenever they want
to start a process

00:02:07.560 --> 00:02:09.720 align:middle line:84%
or whenever they want
to start a program.

00:02:09.720 --> 00:02:13.050 align:middle line:84%
Right now, the way this is done
is whenever you authenticate

00:02:13.050 --> 00:02:16.350 align:middle line:84%
successfully to
Windows, you will

00:02:16.350 --> 00:02:20.580 align:middle line:84%
have an access token generated
by the winlogon.exe process.

00:02:20.580 --> 00:02:22.740 align:middle line:84%
And the access token
will essentially

00:02:22.740 --> 00:02:25.890 align:middle line:84%
include the user identity
or the user account,

00:02:25.890 --> 00:02:29.610 align:middle line:84%
as well as the privileges
associated with that account.

00:02:29.610 --> 00:02:34.770 align:middle line:84%
So this token is then attached
to the userinit.exe process,

00:02:34.770 --> 00:02:38.040 align:middle line:84%
after which all child
processes started by a user

00:02:38.040 --> 00:02:41.940 align:middle line:84%
will inherit a copy of the
access token from their creator

00:02:41.940 --> 00:02:44.760 align:middle line:84%
and will run under the
privileges of the same access

00:02:44.760 --> 00:02:45.610 align:middle line:90%
token.

00:02:45.610 --> 00:02:48.450 align:middle line:84%
So let me just give you
a simple example here.

00:02:48.450 --> 00:02:52.800 align:middle line:84%
So if we didn't have Windows
access tokens implemented

00:02:52.800 --> 00:02:54.930 align:middle line:84%
within Windows,
what would happen

00:02:54.930 --> 00:02:58.180 align:middle line:84%
is, whenever you log on
to your Windows system,

00:02:58.180 --> 00:03:02.130 align:middle line:84%
you would essentially type in
your username and your password

00:03:02.130 --> 00:03:02.910 align:middle line:90%
and log in.

00:03:02.910 --> 00:03:04.680 align:middle line:84%
And then whenever you
wanted to start up

00:03:04.680 --> 00:03:08.190 align:middle line:84%
a program like a simple user
LAN program like your browser

00:03:08.190 --> 00:03:10.320 align:middle line:84%
Firefox, Google
Chrome, et cetera,

00:03:10.320 --> 00:03:13.830 align:middle line:84%
you'd also have to enter a
password or your username

00:03:13.830 --> 00:03:18.220 align:middle line:84%
and password combination to
start it up because again,

00:03:18.220 --> 00:03:21.750 align:middle line:84%
whenever you're working with
privileges and permissions

00:03:21.750 --> 00:03:24.870 align:middle line:84%
on an operating
system, you need a way

00:03:24.870 --> 00:03:27.750 align:middle line:84%
of essentially implementing
access control.

00:03:27.750 --> 00:03:29.850 align:middle line:84%
But this is really
not associated

00:03:29.850 --> 00:03:31.380 align:middle line:90%
to use access control.

00:03:31.380 --> 00:03:33.900 align:middle line:84%
In this case, what you're
trying to do is set up

00:03:33.900 --> 00:03:40.380 align:middle line:84%
the actual privileges and the
security context of a process.

00:03:40.380 --> 00:03:42.510 align:middle line:84%
So whenever you
start up a program,

00:03:42.510 --> 00:03:44.760 align:middle line:84%
you would essentially have
to enter your username

00:03:44.760 --> 00:03:45.400 align:middle line:90%
and password.

00:03:45.400 --> 00:03:50.460 align:middle line:84%
Now Windows access tokens, or
where they come into play here

00:03:50.460 --> 00:03:55.080 align:middle line:84%
in terms of authentication, is
whenever you log in to Windows,

00:03:55.080 --> 00:03:59.100 align:middle line:84%
the winlogon.exe process will
generate a Windows access

00:03:59.100 --> 00:04:00.120 align:middle line:90%
token for you.

00:04:00.120 --> 00:04:02.700 align:middle line:84%
And that Windows access
token will essentially

00:04:02.700 --> 00:04:04.590 align:middle line:90%
contain your user account.

00:04:04.590 --> 00:04:07.980 align:middle line:84%
So your user identity,
as well as the privileges

00:04:07.980 --> 00:04:13.470 align:middle line:84%
associated with that
particular user account.

00:04:13.470 --> 00:04:15.630 align:middle line:84%
That token is then
going to be attached

00:04:15.630 --> 00:04:17.910 align:middle line:84%
to the userinit.exe
process, which

00:04:17.910 --> 00:04:22.990 align:middle line:84%
is used to start up processes or
programs for a particular user.

00:04:22.990 --> 00:04:26.130 align:middle line:84%
So all child processes
started by the user

00:04:26.130 --> 00:04:29.130 align:middle line:84%
will then inherit a copy of the
access token from their creator

00:04:29.130 --> 00:04:31.470 align:middle line:84%
and will run under the
privileges of the same access

00:04:31.470 --> 00:04:32.040 align:middle line:90%
token.

00:04:32.040 --> 00:04:34.950 align:middle line:84%
So, that way, the
processes that are running

00:04:34.950 --> 00:04:38.190 align:middle line:84%
under the privileges
of a specific user

00:04:38.190 --> 00:04:40.590 align:middle line:84%
can be identified, and
they're kept separate.

00:04:40.590 --> 00:04:43.860 align:middle line:84%
So it's really,
really-- is a vital part

00:04:43.860 --> 00:04:47.820 align:middle line:84%
of the Windows operating
system and a core element

00:04:47.820 --> 00:04:50.520 align:middle line:84%
of the authentication
process on Windows.

00:04:50.520 --> 00:04:55.650 align:middle line:84%
Now, let's explore a little
bit about how Windows access

00:04:55.650 --> 00:04:57.090 align:middle line:90%
tokens are sorted.

00:04:57.090 --> 00:05:00.210 align:middle line:84%
Now Windows access
tokens are categorized

00:05:00.210 --> 00:05:03.850 align:middle line:84%
based on the varying security
levels assigned to them.

00:05:03.850 --> 00:05:06.390 align:middle line:84%
So these security
levels are used

00:05:06.390 --> 00:05:07.920 align:middle line:84%
to determine the
privileges that are

00:05:07.920 --> 00:05:09.580 align:middle line:90%
assigned to a specific token.

00:05:09.580 --> 00:05:11.700 align:middle line:84%
So an access token
will typically

00:05:11.700 --> 00:05:14.400 align:middle line:84%
be assigned one of the
following security levels.

00:05:14.400 --> 00:05:18.420 align:middle line:84%
You have the impersonate access
tokens as well as the delegate

00:05:18.420 --> 00:05:20.670 align:middle line:84%
access tokens and will
actually take a look at them

00:05:20.670 --> 00:05:23.410 align:middle line:84%
when we have access
to the target system.

00:05:23.410 --> 00:05:26.040 align:middle line:84%
So the impersonate-level
tokens are

00:05:26.040 --> 00:05:29.580 align:middle line:84%
created as a direct result
of a non-interactive login

00:05:29.580 --> 00:05:33.420 align:middle line:84%
on Windows, typically through
specific system services

00:05:33.420 --> 00:05:34.540 align:middle line:90%
or domain logon.

00:05:34.540 --> 00:05:37.200 align:middle line:84%
So whenever you see an
impersonate access token,

00:05:37.200 --> 00:05:39.600 align:middle line:84%
they have typically
been created as a direct

00:05:39.600 --> 00:05:41.580 align:middle line:90%
of a non-interactive login.

00:05:41.580 --> 00:05:44.250 align:middle line:84%
You then have your
delegate-level tokens,

00:05:44.250 --> 00:05:46.920 align:middle line:84%
which are created through an
interactive login on Windows

00:05:46.920 --> 00:05:51.390 align:middle line:84%
primarily through a traditional
login using the Winlogon

00:05:51.390 --> 00:05:55.300 align:middle line:84%
process or through remote
access protocols like RDP.

00:05:55.300 --> 00:05:59.778 align:middle line:84%
So whenever you see a
delegate access token,

00:05:59.778 --> 00:06:01.320 align:middle line:84%
again, you should
know that they were

00:06:01.320 --> 00:06:07.890 align:middle line:84%
created as a direct result of
an interactive login on Windows.

00:06:07.890 --> 00:06:10.380 align:middle line:84%
Now, in terms of how
we can abuse them,

00:06:10.380 --> 00:06:12.870 align:middle line:84%
impersonate access
tokens can be used

00:06:12.870 --> 00:06:15.720 align:middle line:84%
to impersonate a token on
the local system and not

00:06:15.720 --> 00:06:19.080 align:middle line:84%
any external systems
that utilize the token,

00:06:19.080 --> 00:06:21.870 align:middle line:84%
whereas delegate-level
tokens pose the largest

00:06:21.870 --> 00:06:24.510 align:middle line:84%
threat as they can be
used to impersonate tokens

00:06:24.510 --> 00:06:25.810 align:middle line:90%
on any system.

00:06:25.810 --> 00:06:28.080 align:middle line:84%
So this will all make
sense once we actually

00:06:28.080 --> 00:06:30.030 align:middle line:90%
get onto the target system.

00:06:30.030 --> 00:06:32.730 align:middle line:84%
Now, before we
actually get started

00:06:32.730 --> 00:06:37.080 align:middle line:84%
with the practical section,
we need to understand or get

00:06:37.080 --> 00:06:39.540 align:middle line:84%
an idea of the privileges
required in order

00:06:39.540 --> 00:06:42.300 align:middle line:90%
to impersonate an access token.

00:06:42.300 --> 00:06:45.180 align:middle line:84%
So the process of
impersonating access tokens

00:06:45.180 --> 00:06:47.190 align:middle line:84%
to elevate privileges
on a system

00:06:47.190 --> 00:06:50.010 align:middle line:84%
will primarily depend on
the privileges assigned

00:06:50.010 --> 00:06:51.750 align:middle line:84%
to the account that
has been exploited

00:06:51.750 --> 00:06:55.080 align:middle line:84%
to gain initial access, as
well as the impersonation

00:06:55.080 --> 00:06:56.730 align:middle line:90%
or delegation tokens available.

00:06:56.730 --> 00:06:58.680 align:middle line:84%
What this means
is that, in order

00:06:58.680 --> 00:07:03.780 align:middle line:84%
for us to elevate our privileges
through token impersonation,

00:07:03.780 --> 00:07:07.560 align:middle line:84%
we need to have the
following privileges assigned

00:07:07.560 --> 00:07:08.680 align:middle line:90%
to our account.

00:07:08.680 --> 00:07:10.620 align:middle line:84%
Furthermore, we
also need to have

00:07:10.620 --> 00:07:14.400 align:middle line:84%
impersonation or delegation
tokens available on the system

00:07:14.400 --> 00:07:16.980 align:middle line:90%
that we can use to impersonate.

00:07:16.980 --> 00:07:19.320 align:middle line:84%
So the following
are the privileges

00:07:19.320 --> 00:07:21.720 align:middle line:84%
that are required for a
successful impersonation

00:07:21.720 --> 00:07:22.980 align:middle line:90%
attack.

00:07:22.980 --> 00:07:26.160 align:middle line:84%
We primarily need the
SeImpersonatePrivilege.

00:07:26.160 --> 00:07:28.380 align:middle line:84%
So this privilege
essentially allows a user

00:07:28.380 --> 00:07:30.570 align:middle line:84%
to create a process
under the security

00:07:30.570 --> 00:07:32.580 align:middle line:84%
context of another
user, typically

00:07:32.580 --> 00:07:34.240 align:middle line:90%
with administrative privileges.

00:07:34.240 --> 00:07:37.200 align:middle line:84%
So the SeImpersonatePrivilege
will essentially

00:07:37.200 --> 00:07:40.470 align:middle line:84%
allow us to impersonate the
access token of another user

00:07:40.470 --> 00:07:41.370 align:middle line:90%
account.

00:07:41.370 --> 00:07:43.770 align:middle line:84%
And we already explored
how to enumerate

00:07:43.770 --> 00:07:46.830 align:middle line:84%
the privileges assigned
to our current account

00:07:46.830 --> 00:07:50.470 align:middle line:84%
and with meterpreter
as we did previously.

00:07:50.470 --> 00:07:53.160 align:middle line:84%
That can be done by typing
in the get privs command,

00:07:53.160 --> 00:07:55.230 align:middle line:84%
and that will essentially
list out whether or not

00:07:55.230 --> 00:07:57.930 align:middle line:84%
you have the
SeImpersonatePrivilege assigned

00:07:57.930 --> 00:07:59.560 align:middle line:90%
to that particular user account.

00:07:59.560 --> 00:08:01.810 align:middle line:84%
And of course, we'll
explore this as well.

00:08:01.810 --> 00:08:06.570 align:middle line:84%
Now, we I briefly mentioned the
incognito module because this

00:08:06.570 --> 00:08:09.840 align:middle line:84%
is the meterpreter module that
we are going to be utilizing

00:08:09.840 --> 00:08:14.730 align:middle line:84%
to essentially list out the
available access tokens that we

00:08:14.730 --> 00:08:16.710 align:middle line:84%
can impersonate,
and it will also

00:08:16.710 --> 00:08:19.210 align:middle line:84%
facilitate the actual
impersonation process.

00:08:19.210 --> 00:08:22.290 align:middle line:84%
So incognito is a built-in
meterpreter module

00:08:22.290 --> 00:08:25.110 align:middle line:84%
that was originally a
standalone application

00:08:25.110 --> 00:08:27.630 align:middle line:84%
and allows you to
impersonate user tokens

00:08:27.630 --> 00:08:30.660 align:middle line:84%
after successful exploitation
or once you've gained access

00:08:30.660 --> 00:08:32.110 align:middle line:90%
to a target system.

00:08:32.110 --> 00:08:35.429 align:middle line:84%
So we can use-- we can utilize
the incognito module to display

00:08:35.429 --> 00:08:38.100 align:middle line:84%
a list of available tokens
that we can impersonate

00:08:38.100 --> 00:08:43.950 align:middle line:84%
and consequently perform the
actual token impersonation.

00:08:43.950 --> 00:08:46.060 align:middle line:84%
So let's take a look at
how this can be done.

00:08:46.060 --> 00:08:48.300 align:middle line:84%
So just fire up the
lab environment,

00:08:48.300 --> 00:08:51.480 align:middle line:84%
and we can get started
with the actual process

00:08:51.480 --> 00:08:55.780 align:middle line:84%
of elevating our privileges
through token impersonation.

00:08:55.780 --> 00:08:58.690 align:middle line:84%
All right, so I'm back
within the lab environment,

00:08:58.690 --> 00:09:01.630 align:middle line:84%
and we already have
the target IP specified

00:09:01.630 --> 00:09:02.810 align:middle line:90%
for us, which is great.

00:09:02.810 --> 00:09:04.250 align:middle line:90%
So we can copy that.

00:09:04.250 --> 00:09:07.090 align:middle line:84%
And I'm going to open up
a terminal session here.

00:09:07.090 --> 00:09:09.040 align:middle line:84%
I'm going to maximize
that and increase

00:09:09.040 --> 00:09:11.470 align:middle line:84%
the font size so you can
actually see what's going on.

00:09:11.470 --> 00:09:15.340 align:middle line:84%
I'm then going to start up the
PostgreSQL database service

00:09:15.340 --> 00:09:18.220 align:middle line:84%
so that we can actually interact
with the Metasploit Framework

00:09:18.220 --> 00:09:19.000 align:middle line:90%
database.

00:09:19.000 --> 00:09:22.660 align:middle line:84%
And I'm going to also start up
msfconsole while we're at it,

00:09:22.660 --> 00:09:24.880 align:middle line:84%
and that will save us
a little bit of time.

00:09:24.880 --> 00:09:27.400 align:middle line:84%
So that's going to start
up the PostgreSQL database

00:09:27.400 --> 00:09:29.920 align:middle line:84%
server for us, and then
start up msfconsole.

00:09:29.920 --> 00:09:33.698 align:middle line:84%
So let's just wait
for this to start up.

00:09:33.698 --> 00:09:34.240 align:middle line:90%
There we are.

00:09:34.240 --> 00:09:36.670 align:middle line:84%
That starts up
relatively quickly.

00:09:36.670 --> 00:09:38.200 align:middle line:84%
What we're going
to do now is create

00:09:38.200 --> 00:09:40.540 align:middle line:84%
a workspace for
all our activity,

00:09:40.540 --> 00:09:42.580 align:middle line:84%
and I'm just going to
call it impersonate

00:09:42.580 --> 00:09:45.798 align:middle line:84%
because that's what we're
dealing with, in this case.

00:09:45.798 --> 00:09:47.590 align:middle line:84%
We can then, of course,
check the workspace

00:09:47.590 --> 00:09:48.757 align:middle line:90%
we are currently working in.

00:09:48.757 --> 00:09:50.780 align:middle line:84%
And it's impersonate,
which is great.

00:09:50.780 --> 00:09:53.590 align:middle line:84%
We then need to set up the
global variable for the RHOSTS

00:09:53.590 --> 00:09:55.630 align:middle line:90%
option to the target IP.

00:09:55.630 --> 00:09:57.520 align:middle line:84%
And the reason we
are doing this is

00:09:57.520 --> 00:10:00.490 align:middle line:84%
to essentially prevent
us or alleviate us

00:10:00.490 --> 00:10:03.340 align:middle line:84%
from having to type
in the target IP

00:10:03.340 --> 00:10:05.290 align:middle line:90%
whenever we load in a module.

00:10:05.290 --> 00:10:07.340 align:middle line:90%
So this is a great time saver.

00:10:07.340 --> 00:10:08.890 align:middle line:90%
So I'm going to hit Enter.

00:10:08.890 --> 00:10:12.040 align:middle line:84%
And we now want to perform an
Nmap scan on the target system

00:10:12.040 --> 00:10:15.070 align:middle line:84%
to identify what services are
running on the target system

00:10:15.070 --> 00:10:18.730 align:middle line:84%
that we can consequently exploit
to gain access, after which we

00:10:18.730 --> 00:10:22.340 align:middle line:84%
can then begin exploring the
privilege escalation process.

00:10:22.340 --> 00:10:25.000 align:middle line:84%
So I'm going to be
utilizing the db_nmap

00:10:25.000 --> 00:10:28.810 align:middle line:84%
command to perform the Nmap
scan from within msfconsole.

00:10:28.810 --> 00:10:30.550 align:middle line:84%
And this command
will consequently

00:10:30.550 --> 00:10:34.150 align:middle line:84%
save the Nmap results within the
Metasploit Framework database

00:10:34.150 --> 00:10:35.770 align:middle line:90%
in our current workspace.

00:10:35.770 --> 00:10:38.320 align:middle line:84%
So I'm going to perform some
service version detection

00:10:38.320 --> 00:10:41.230 align:middle line:84%
and will paste the
target IP and hit Enter.

00:10:41.230 --> 00:10:43.300 align:middle line:84%
So I'm going to give
this a couple of seconds

00:10:43.300 --> 00:10:46.260 align:middle line:84%
to a couple of
minutes to complete.

00:10:46.260 --> 00:10:47.970 align:middle line:84%
All right, once
the scan is done,

00:10:47.970 --> 00:10:51.620 align:middle line:84%
we can see that, on port
80, we have the Rejetto HFS

00:10:51.620 --> 00:10:54.890 align:middle line:84%
or HttpFileServer version
2.3 running, which

00:10:54.890 --> 00:10:56.640 align:middle line:90%
we have exploited previously.

00:10:56.640 --> 00:10:59.370 align:middle line:84%
So this is going to
be our attack vector.

00:10:59.370 --> 00:11:01.890 align:middle line:84%
So I'm going to just search
for the exploit module.

00:11:01.890 --> 00:11:04.700 align:middle line:84%
And in this case, we know
that it's called Rejetto,

00:11:04.700 --> 00:11:05.940 align:middle line:90%
and there we are.

00:11:05.940 --> 00:11:08.690 align:middle line:84%
That's the Rejetto
remote command execution

00:11:08.690 --> 00:11:09.492 align:middle line:90%
exploit module.

00:11:09.492 --> 00:11:11.700 align:middle line:84%
So I'm going to copy it,
and we're going to paste it.

00:11:11.700 --> 00:11:15.450 align:middle line:84%
And we're going to
say use and hit Enter.

00:11:15.450 --> 00:11:17.100 align:middle line:84%
As you can see,
the default payload

00:11:17.100 --> 00:11:20.040 align:middle line:84%
is the 32-bit
meterpreter payload.

00:11:20.040 --> 00:11:23.290 align:middle line:84%
We're going to set that to the
64-bit meterpreter payload.

00:11:23.290 --> 00:11:25.620 align:middle line:84%
So I'm going to say
set payload, and I'm

00:11:25.620 --> 00:11:31.980 align:middle line:84%
going to say Windows x64
meterpreter reverse TCP.

00:11:31.980 --> 00:11:34.050 align:middle line:84%
And of course, you can
use whatever protocol,

00:11:34.050 --> 00:11:37.750 align:middle line:84%
or you can use whatever
connection type that you want.

00:11:37.750 --> 00:11:40.700 align:middle line:84%
We are now going to
show the options.

00:11:40.700 --> 00:11:43.120 align:middle line:84%
And you can see that the
RHOSTS option is already

00:11:43.120 --> 00:11:47.530 align:middle line:84%
specified for us because we set
up the global variable value

00:11:47.530 --> 00:11:50.080 align:middle line:90%
for the RHOSTS option.

00:11:50.080 --> 00:11:53.680 align:middle line:84%
The target port where
Rejetto HFS is running

00:11:53.680 --> 00:11:56.120 align:middle line:90%
is port 80, which is correct.

00:11:56.120 --> 00:11:58.750 align:middle line:84%
We don't have SSL running,
and the target URI

00:11:58.750 --> 00:12:00.280 align:middle line:90%
is the root of the webserver.

00:12:00.280 --> 00:12:02.080 align:middle line:84%
And of course, we
can confirm that

00:12:02.080 --> 00:12:05.890 align:middle line:84%
by pasting in the target
IP, so within our browser

00:12:05.890 --> 00:12:08.000 align:middle line:90%
and navigating to port 80.

00:12:08.000 --> 00:12:09.610 align:middle line:90%
So we can just hit Enter.

00:12:09.610 --> 00:12:11.080 align:middle line:84%
And as you can
see, it's currently

00:12:11.080 --> 00:12:13.097 align:middle line:84%
running at the root
of the web server.

00:12:13.097 --> 00:12:14.680 align:middle line:84%
So we don't need to
configure anything

00:12:14.680 --> 00:12:19.000 align:middle line:84%
else apart from the LHOST
and LPORT options here.

00:12:19.000 --> 00:12:20.980 align:middle line:84%
And these, of course,
the payload options.

00:12:20.980 --> 00:12:23.540 align:middle line:84%
And in this case, I'm going
to leave them as the default.

00:12:23.540 --> 00:12:26.500 align:middle line:84%
So I'm just going to type
in exploit or run, whatever

00:12:26.500 --> 00:12:28.920 align:middle line:90%
you're comfortable with.

00:12:28.920 --> 00:12:31.340 align:middle line:84%
And in this case, we should
get a meterpreter session

00:12:31.340 --> 00:12:32.990 align:middle line:90%
on the target system.

00:12:32.990 --> 00:12:36.850 align:middle line:84%
There we are, meterpreter
session one opened.

00:12:36.850 --> 00:12:37.540 align:middle line:90%
Fantastic.

00:12:37.540 --> 00:12:39.460 align:middle line:84%
OK, so the first
thing we want to do

00:12:39.460 --> 00:12:42.880 align:middle line:84%
is we can perform some
local enumeration.

00:12:42.880 --> 00:12:45.760 align:middle line:84%
And in this case, we can see
that the target operating

00:12:45.760 --> 00:12:48.100 align:middle line:90%
system is Windows Server 2016.

00:12:48.100 --> 00:12:50.650 align:middle line:84%
It's a 64-bit version
of Windows Server,

00:12:50.650 --> 00:12:52.960 align:middle line:84%
and the payload type
or the meterpreter

00:12:52.960 --> 00:12:57.940 align:middle line:84%
payload architecture or session
is the 64-bit meterpreter

00:12:57.940 --> 00:12:58.600 align:middle line:90%
session.

00:12:58.600 --> 00:12:59.600 align:middle line:90%
So that's great.

00:12:59.600 --> 00:13:02.440 align:middle line:84%
So we don't actually need to
migrate to another process

00:13:02.440 --> 00:13:04.730 align:middle line:84%
in order to get a
64-bit meterpreter

00:13:04.730 --> 00:13:06.760 align:middle line:90%
session as we already have one.

00:13:06.760 --> 00:13:09.040 align:middle line:84%
The next thing we want
to do is enumerate

00:13:09.040 --> 00:13:11.240 align:middle line:84%
our current privileges
or the actual user

00:13:11.240 --> 00:13:13.190 align:middle line:90%
account that we have access to.

00:13:13.190 --> 00:13:15.910 align:middle line:84%
We can type in get user
ID, and this tells us

00:13:15.910 --> 00:13:19.240 align:middle line:84%
that we have the anti-authority
local service privileges.

00:13:19.240 --> 00:13:21.310 align:middle line:84%
So you need to make
the distinction

00:13:21.310 --> 00:13:24.400 align:middle line:84%
between anti-authority system
and anti-authority local

00:13:24.400 --> 00:13:25.120 align:middle line:90%
service.

00:13:25.120 --> 00:13:26.950 align:middle line:84%
Anti-authority
system means that we

00:13:26.950 --> 00:13:30.970 align:middle line:84%
have system privileges or the
highest privileges associated

00:13:30.970 --> 00:13:33.580 align:middle line:90%
with a user account on Windows.

00:13:33.580 --> 00:13:35.410 align:middle line:84%
And then local
service means that we

00:13:35.410 --> 00:13:38.870 align:middle line:84%
have the privileges associated
with a local service account.

00:13:38.870 --> 00:13:41.680 align:middle line:84%
The reason we have access
to a local service account

00:13:41.680 --> 00:13:45.020 align:middle line:84%
is because we exploited a
service, and in this case,

00:13:45.020 --> 00:13:49.450 align:middle line:84%
the service that we exploited
was the Rejetto HFS or Http

00:13:49.450 --> 00:13:50.650 align:middle line:90%
File Server service.

00:13:50.650 --> 00:13:53.960 align:middle line:84%
So we get the privileges
associated with that service.

00:13:53.960 --> 00:13:55.990 align:middle line:84%
We can also enumerate
our current privileges

00:13:55.990 --> 00:13:59.050 align:middle line:84%
to see whether we can perform
token impersonation by typing

00:13:59.050 --> 00:14:00.100 align:middle line:90%
in getprivs.

00:14:00.100 --> 00:14:02.470 align:middle line:84%
And as I mentioned
within the slides,

00:14:02.470 --> 00:14:05.350 align:middle line:84%
we require the
SeImpersonatePrivilege in order

00:14:05.350 --> 00:14:07.250 align:middle line:90%
to perform token impersonation.

00:14:07.250 --> 00:14:08.905 align:middle line:90%
So we can see that this--

00:14:08.905 --> 00:14:10.280 align:middle line:84%
we currently have
this privilege,

00:14:10.280 --> 00:14:12.910 align:middle line:84%
which means we can perform
token impersonation

00:14:12.910 --> 00:14:15.670 align:middle line:84%
and consequently
elevate our privileges.

00:14:15.670 --> 00:14:17.710 align:middle line:84%
So again, just to
verify that we don't

00:14:17.710 --> 00:14:20.320 align:middle line:84%
have any administrative
privileges beforehand,

00:14:20.320 --> 00:14:24.250 align:middle line:84%
I can try and perform a command
like hashdump, which requires

00:14:24.250 --> 00:14:25.512 align:middle line:90%
administrative privileges.

00:14:25.512 --> 00:14:27.220 align:middle line:84%
And as you can see,
it's going to tell us

00:14:27.220 --> 00:14:30.160 align:middle line:84%
priv_passwd_get_sam_hashes:
operation failed:

00:14:30.160 --> 00:14:32.530 align:middle line:84%
the parameter is
incorrect, which

00:14:32.530 --> 00:14:34.720 align:middle line:84%
essentially fails
because we don't

00:14:34.720 --> 00:14:36.280 align:middle line:90%
have sufficient privileges.

00:14:36.280 --> 00:14:40.390 align:middle line:84%
We can also try and navigate
to the administrator's user

00:14:40.390 --> 00:14:40.900 align:middle line:90%
directory.

00:14:40.900 --> 00:14:46.690 align:middle line:84%
So we can say cd Users and
under administrator, you

00:14:46.690 --> 00:14:48.940 align:middle line:84%
can see operation
failed, access is denied.

00:14:48.940 --> 00:14:51.820 align:middle line:84%
So we definitely need to
elevate our privileges,

00:14:51.820 --> 00:14:54.190 align:middle line:84%
and that's what we're
going to be doing now.

00:14:54.190 --> 00:14:56.800 align:middle line:84%
So now that we've done
or essentially verified

00:14:56.800 --> 00:14:58.810 align:middle line:84%
that we don't have
administrative privileges,

00:14:58.810 --> 00:15:02.050 align:middle line:84%
to begin with, we
can begin exploring

00:15:02.050 --> 00:15:04.040 align:middle line:84%
how to utilize the
incognito module.

00:15:04.040 --> 00:15:07.540 align:middle line:84%
So when I mentioned that the
incognito module is built

00:15:07.540 --> 00:15:10.090 align:middle line:84%
into meterpreter, what I
mean is that you can easily

00:15:10.090 --> 00:15:13.990 align:middle line:84%
load it by typing in load
incognito and hit Enter.

00:15:13.990 --> 00:15:16.840 align:middle line:84%
It's going to say loading
extension incognito,

00:15:16.840 --> 00:15:19.460 align:middle line:84%
and it's going to say success,
and that's pretty much it.

00:15:19.460 --> 00:15:22.990 align:middle line:84%
Now, we can utilize
incognito within meterpreter

00:15:22.990 --> 00:15:25.360 align:middle line:84%
to list out, first and
foremost, the access

00:15:25.360 --> 00:15:27.350 align:middle line:90%
tokens available on the system.

00:15:27.350 --> 00:15:30.100 align:middle line:84%
So we can say list
tokens and say

00:15:30.100 --> 00:15:32.290 align:middle line:84%
we want to list out
the user access tokens,

00:15:32.290 --> 00:15:33.640 align:middle line:90%
and we hit Enter.

00:15:33.640 --> 00:15:36.140 align:middle line:84%
And as you can see, it's
going to give you the output,

00:15:36.140 --> 00:15:38.710 align:middle line:84%
and it's going to be sorted
based on the various access

00:15:38.710 --> 00:15:41.110 align:middle line:84%
token categories
or security levels

00:15:41.110 --> 00:15:43.180 align:middle line:84%
that I highlighted
within the slides.

00:15:43.180 --> 00:15:45.790 align:middle line:84%
So you have your delegation
tokens as well as

00:15:45.790 --> 00:15:47.140 align:middle line:90%
your impersonation tokens.

00:15:47.140 --> 00:15:48.820 align:middle line:90%
Now, remember what I said.

00:15:48.820 --> 00:15:53.530 align:middle line:84%
Impersonation tokens are created
as a direct result of logging

00:15:53.530 --> 00:15:59.740 align:middle line:84%
in or authentication through
a non-interactive prompt

00:15:59.740 --> 00:16:01.360 align:middle line:90%
or a non-interactive session.

00:16:01.360 --> 00:16:05.440 align:middle line:84%
So you can see that we have no
impersonation tokens available,

00:16:05.440 --> 00:16:07.630 align:middle line:84%
and delegation
tokens are created

00:16:07.630 --> 00:16:11.620 align:middle line:84%
as a direct result of
an interactive logon,

00:16:11.620 --> 00:16:15.280 align:middle line:84%
like either through Winlogon
or through remote protocol

00:16:15.280 --> 00:16:16.270 align:middle line:90%
like RDP.

00:16:16.270 --> 00:16:17.950 align:middle line:84%
And in this case,
you can see that we

00:16:17.950 --> 00:16:20.170 align:middle line:84%
have two delegation
tokens available

00:16:20.170 --> 00:16:21.310 align:middle line:90%
that we can impersonate.

00:16:21.310 --> 00:16:24.280 align:middle line:84%
We have the administrator
delegation token,

00:16:24.280 --> 00:16:26.980 align:middle line:84%
which is essentially-- which
will essentially provide us

00:16:26.980 --> 00:16:30.310 align:middle line:84%
with the privileges associated
with the administrator account.

00:16:30.310 --> 00:16:33.220 align:middle line:84%
And then we have the
anti-authority local service

00:16:33.220 --> 00:16:35.060 align:middle line:90%
delegation token available.

00:16:35.060 --> 00:16:38.680 align:middle line:84%
So if we impersonate the
administrator delegation token,

00:16:38.680 --> 00:16:41.290 align:middle line:84%
we can essentially get
the privileges associated

00:16:41.290 --> 00:16:43.210 align:middle line:84%
with that user
account, and that's

00:16:43.210 --> 00:16:44.500 align:middle line:90%
exactly what we want to do.

00:16:44.500 --> 00:16:48.400 align:middle line:84%
So just copy the
delegation token name.

00:16:48.400 --> 00:16:49.100 align:middle line:90%
There we are.

00:16:49.100 --> 00:16:50.800 align:middle line:84%
And in order to
impersonate it, we

00:16:50.800 --> 00:16:53.710 align:middle line:84%
can type in impersonate
token, and we

00:16:53.710 --> 00:16:57.400 align:middle line:84%
can then place the actual token
name within quotation marks

00:16:57.400 --> 00:16:59.260 align:middle line:90%
and then hit Enter.

00:16:59.260 --> 00:17:01.900 align:middle line:84%
And it's going to say
delegation token available

00:17:01.900 --> 00:17:04.940 align:middle line:84%
successfully impersonated
the user administrator.

00:17:04.940 --> 00:17:07.720 align:middle line:84%
So if we type in
getuid now, you can

00:17:07.720 --> 00:17:10.329 align:middle line:84%
see that we now have the
privileges of the administrator

00:17:10.329 --> 00:17:11.980 align:middle line:84%
account and we have
successfully been

00:17:11.980 --> 00:17:14.030 align:middle line:90%
able to elevate our privileges.

00:17:14.030 --> 00:17:17.109 align:middle line:84%
And of course, we can verify
this by typing in hashdump,

00:17:17.109 --> 00:17:19.210 align:middle line:84%
and in this case, it's
going to fail primarily

00:17:19.210 --> 00:17:22.069 align:middle line:84%
because we need to migrate
to a different process.

00:17:22.069 --> 00:17:23.500 align:middle line:84%
And the reason we
need to do that

00:17:23.500 --> 00:17:25.510 align:middle line:84%
is because the
current process tree--

00:17:25.510 --> 00:17:28.990 align:middle line:84%
the current process that we're
currently operating in or under

00:17:28.990 --> 00:17:31.540 align:middle line:84%
is still has the
access token associated

00:17:31.540 --> 00:17:34.370 align:middle line:84%
with the anti-authority
local service account.

00:17:34.370 --> 00:17:37.730 align:middle line:84%
So we can list out
this is available here,

00:17:37.730 --> 00:17:40.480 align:middle line:84%
and we can migrate
to explorer.exe.

00:17:40.480 --> 00:17:42.890 align:middle line:84%
So I'm going to say
migrate, and we can then

00:17:42.890 --> 00:17:47.780 align:middle line:84%
specify the process ID of
explorer.exe, which is 3544.

00:17:47.780 --> 00:17:55.340 align:middle line:84%
So I'm going to
say migrate 3544.

00:17:55.340 --> 00:17:57.350 align:middle line:84%
And now, if we type
in hashdump, you

00:17:57.350 --> 00:18:01.100 align:middle line:84%
can see we get the actual
user count hashes here,

00:18:01.100 --> 00:18:03.780 align:middle line:84%
and we've successfully
elevated our privileges.

00:18:03.780 --> 00:18:06.380 align:middle line:84%
And of course, we can
now access the contents

00:18:06.380 --> 00:18:07.800 align:middle line:90%
of the administrative folder.

00:18:07.800 --> 00:18:10.160 align:middle line:84%
So we head over into
the root of the C drive.

00:18:10.160 --> 00:18:13.550 align:middle line:84%
And then, under, the
user's directory and under

00:18:13.550 --> 00:18:16.370 align:middle line:84%
the administrator directory,
you can see we now have access,

00:18:16.370 --> 00:18:18.440 align:middle line:84%
well, whereas
previously we didn't.

00:18:18.440 --> 00:18:22.280 align:middle line:84%
So that is how to elevate your
privileges on a Windows system

00:18:22.280 --> 00:18:23.905 align:middle line:90%
through token impersonation.

00:18:23.905 --> 00:18:25.280 align:middle line:84%
And of course,
we've taken a look

00:18:25.280 --> 00:18:28.310 align:middle line:84%
at how to do this through
the incognito module, which

00:18:28.310 --> 00:18:29.990 align:middle line:90%
is extremely helpful.

00:18:29.990 --> 00:18:31.700 align:middle line:84%
The reason I've
covered this technique

00:18:31.700 --> 00:18:35.210 align:middle line:84%
is because of its viability
and the fact that you will

00:18:35.210 --> 00:18:37.910 align:middle line:84%
be utilizing this technique
when you work within Windows

00:18:37.910 --> 00:18:40.250 align:middle line:84%
environments or whenever
you're conducting a penetration

00:18:40.250 --> 00:18:42.680 align:middle line:84%
test because it
works irregardless

00:18:42.680 --> 00:18:46.070 align:middle line:84%
of the version of Windows as
long as their impersonation

00:18:46.070 --> 00:18:48.590 align:middle line:84%
tokens or delegation
tokens available,

00:18:48.590 --> 00:18:50.240 align:middle line:90%
you can always impersonate them.

00:18:50.240 --> 00:18:51.930 align:middle line:84%
And of course, in
order to do that,

00:18:51.930 --> 00:18:53.990 align:middle line:84%
you need to make sure
that you currently have

00:18:53.990 --> 00:18:56.300 align:middle line:90%
the SeImpersonatePrivilege.

00:18:56.300 --> 00:18:59.000 align:middle line:84%
So this is the
first prerequisite,

00:18:59.000 --> 00:19:02.510 align:middle line:84%
after which if you have access
tokens on the target operating

00:19:02.510 --> 00:19:05.270 align:middle line:84%
system, you can essentially
impersonate them

00:19:05.270 --> 00:19:07.350 align:middle line:90%
using the incognito module.

00:19:07.350 --> 00:19:10.940 align:middle line:84%
So that is going to conclude
the practical demonstration

00:19:10.940 --> 00:19:14.150 align:middle line:90%
side of this video.

00:19:14.150 --> 00:19:16.840 align:middle line:84%
In the next video, we
are going to be exploring

00:19:16.840 --> 00:19:20.590 align:middle line:84%
the process of dumping hashes
as well as clear text passwords

00:19:20.590 --> 00:19:22.900 align:middle line:90%
from memory with Mimikatz.

00:19:22.900 --> 00:19:25.900 align:middle line:84%
And we'll also be exploring
the Kiwi module, which

00:19:25.900 --> 00:19:31.030 align:middle line:84%
is essentially a meterpreter
module for the four Mimikatz

00:19:31.030 --> 00:19:33.730 align:middle line:84%
that, again, can allow
us to essentially perform

00:19:33.730 --> 00:19:36.370 align:middle line:84%
all of the password
and hashdumping

00:19:36.370 --> 00:19:37.680 align:middle line:90%
from within the interpreter.

00:19:37.680 --> 00:19:39.701 align:middle line:90%
So I'll see you there.

00:19:39.701 --> 00:19:40.201 align:middle line:90%