WEBVTT

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


00:00:03.000 --> 00:00:03.930 align:middle line:90%
Hi.

00:00:03.930 --> 00:00:05.700 align:middle line:84%
In this video
course, we're going

00:00:05.700 --> 00:00:08.520 align:middle line:84%
to talk about
Kerberos Delegation.

00:00:08.520 --> 00:00:12.210 align:middle line:84%
And Kerberos Delegation is
a massive topic on itself.

00:00:12.210 --> 00:00:15.160 align:middle line:84%
We'll need really days
to cover it completely.

00:00:15.160 --> 00:00:17.670 align:middle line:84%
So what we want to achieve
with this video lesson,

00:00:17.670 --> 00:00:20.940 align:middle line:84%
is to outline the reasons
why there is a security

00:00:20.940 --> 00:00:25.170 align:middle line:84%
problem with Kerberos Delegation
and how to really prevent it.

00:00:25.170 --> 00:00:29.550 align:middle line:84%
So let's begin by looking into
what is it that the requires

00:00:29.550 --> 00:00:30.810 align:middle line:90%
to have Kerberos Delegation.

00:00:30.810 --> 00:00:34.120 align:middle line:84%
Why does it exist
in the first place?

00:00:34.120 --> 00:00:36.240 align:middle line:84%
So by definition,
and I have taken it

00:00:36.240 --> 00:00:40.260 align:middle line:84%
from the link provided
on the slide currently,

00:00:40.260 --> 00:00:42.630 align:middle line:84%
Kerberos Delegation
enables an application

00:00:42.630 --> 00:00:46.890 align:middle line:84%
to access resources which
are hosted on another server.

00:00:46.890 --> 00:00:50.790 align:middle line:84%
And the most common
example, you may say

00:00:50.790 --> 00:00:55.230 align:middle line:84%
is when you have a web server,
which is internet facing

00:00:55.230 --> 00:00:59.980 align:middle line:84%
or user facing and there's a
SQL database in the backend.

00:00:59.980 --> 00:01:01.680 align:middle line:84%
So what we want
to achieve is, we

00:01:01.680 --> 00:01:05.850 align:middle line:84%
want the user who is accessing
the web server to only

00:01:05.850 --> 00:01:11.580 align:middle line:84%
be able to access data for
himself on the backend server.

00:01:11.580 --> 00:01:12.785 align:middle line:90%
So instead of giving--

00:01:12.785 --> 00:01:14.160 align:middle line:84%
with Kerberos
Delegation, instead

00:01:14.160 --> 00:01:17.310 align:middle line:84%
of giving access to the
service account that

00:01:17.310 --> 00:01:20.440 align:middle line:84%
is going to perform that
connection, and in this case,

00:01:20.440 --> 00:01:22.890 align:middle line:84%
it would be access to
the entire database, what

00:01:22.890 --> 00:01:26.550 align:middle line:84%
we can do is we can use this
service account to delegate

00:01:26.550 --> 00:01:30.150 align:middle line:84%
the currently logged in
user on the web server

00:01:30.150 --> 00:01:34.890 align:middle line:84%
and access only that account
data in the backend database.

00:01:34.890 --> 00:01:38.295 align:middle line:84%
And by doing so, since the
service account itself is not

00:01:38.295 --> 00:01:41.670 align:middle line:84%
going to have any access
to the backend database,

00:01:41.670 --> 00:01:44.220 align:middle line:84%
if that account gets
compromised there's

00:01:44.220 --> 00:01:50.700 align:middle line:84%
going to be no risks to
the database you may think.

00:01:50.700 --> 00:01:55.740 align:middle line:84%
But then we come into reality
and initially, Microsoft

00:01:55.740 --> 00:01:59.160 align:middle line:84%
started implementing Kerberos
Delegation with a type known

00:01:59.160 --> 00:02:01.470 align:middle line:90%
as unconstrained delegation.

00:02:01.470 --> 00:02:04.470 align:middle line:84%
And this was
introduced very early

00:02:04.470 --> 00:02:06.570 align:middle line:90%
when [INAUDIBLE] was created.

00:02:06.570 --> 00:02:09.660 align:middle line:84%
And with unconstrained
delegation,

00:02:09.660 --> 00:02:12.900 align:middle line:90%
you can delegate to any server.

00:02:12.900 --> 00:02:14.910 align:middle line:90%
There are no constraints at all.

00:02:14.910 --> 00:02:18.540 align:middle line:84%
As long as you're configured to
have unconstrained delegation

00:02:18.540 --> 00:02:21.570 align:middle line:84%
your account will
be able to delegate

00:02:21.570 --> 00:02:25.440 align:middle line:84%
another user to anywhere
else, any service, any device.

00:02:25.440 --> 00:02:28.020 align:middle line:84%
To configure
unconstrained delegation,

00:02:28.020 --> 00:02:33.330 align:middle line:84%
this is set by setting in the
delegation tab of an account,

00:02:33.330 --> 00:02:38.740 align:middle line:84%
trust this computer for
delegation to any Service.

00:02:38.740 --> 00:02:40.540 align:middle line:84%
Now unconstrained
delegation, since it

00:02:40.540 --> 00:02:44.137 align:middle line:84%
can delegate to anything,
is a massive issue

00:02:44.137 --> 00:02:45.720 align:middle line:84%
because if you
compromise this account

00:02:45.720 --> 00:02:49.240 align:middle line:84%
you have delegation
rights basically to enter

00:02:49.240 --> 00:02:50.810 align:middle line:90%
in your active directory.

00:02:50.810 --> 00:02:55.180 align:middle line:84%
And very early again, I believe
it was in 2003 released,

00:02:55.180 --> 00:02:58.030 align:middle line:84%
Microsoft realized that
unconstrained delegation

00:02:58.030 --> 00:03:01.960 align:middle line:84%
will have serious
security issues

00:03:01.960 --> 00:03:05.920 align:middle line:84%
so they released what was
called constrained delegation.

00:03:05.920 --> 00:03:08.290 align:middle line:84%
And with constrained
delegation, this

00:03:08.290 --> 00:03:10.660 align:middle line:84%
is a type of delegation which
you can configure, again,

00:03:10.660 --> 00:03:13.330 align:middle line:90%
on a computer or a user object.

00:03:13.330 --> 00:03:15.790 align:middle line:84%
And the constrained
part comes here

00:03:15.790 --> 00:03:19.990 align:middle line:84%
because you're specifying
which account, in which servers

00:03:19.990 --> 00:03:23.170 align:middle line:90%
you want to be delegated to.

00:03:23.170 --> 00:03:25.770 align:middle line:84%
So in this case, or in
the previous example

00:03:25.770 --> 00:03:28.450 align:middle line:84%
that we had with the web
server and the database,

00:03:28.450 --> 00:03:31.810 align:middle line:84%
you said that the user
account, the services account

00:03:31.810 --> 00:03:35.470 align:middle line:84%
will be delegating only to
let's go back in database server

00:03:35.470 --> 00:03:38.570 align:middle line:90%
and servers and nothing else.

00:03:38.570 --> 00:03:40.940 align:middle line:84%
But again, one
account in this case

00:03:40.940 --> 00:03:42.800 align:middle line:84%
can have multiple
delegations, and you

00:03:42.800 --> 00:03:45.800 align:middle line:84%
might end up with
one serious account

00:03:45.800 --> 00:03:48.710 align:middle line:84%
that an admin may
have created 20

00:03:48.710 --> 00:03:53.350 align:middle line:84%
different constrained
delegations,

00:03:53.350 --> 00:03:56.290 align:middle line:84%
and that might give that account
access to 20 different servers.

00:03:56.290 --> 00:03:59.200 align:middle line:84%
And that, again, can
grow really exponentially

00:03:59.200 --> 00:04:01.810 align:middle line:84%
if the same servers
account is being used

00:04:01.810 --> 00:04:04.650 align:middle line:90%
across the entire directory.

00:04:04.650 --> 00:04:06.400 align:middle line:84%
And the thing about
constrained delegation

00:04:06.400 --> 00:04:08.740 align:middle line:84%
is that it really
works like magic

00:04:08.740 --> 00:04:11.860 align:middle line:84%
and it completely blew my
mind the first time I saw it.

00:04:11.860 --> 00:04:15.280 align:middle line:84%
I even later on,
created a blog post.

00:04:15.280 --> 00:04:19.120 align:middle line:84%
That would be the last link
on the current slide, where

00:04:19.120 --> 00:04:23.230 align:middle line:84%
I'm showcasing how a
user with absolutely

00:04:23.230 --> 00:04:25.360 align:middle line:84%
no rights in active
directory, just

00:04:25.360 --> 00:04:28.420 align:middle line:84%
a single delegation towards
domain controller on the LDAP

00:04:28.420 --> 00:04:32.140 align:middle line:84%
servers allows the user
to request a Kerberos

00:04:32.140 --> 00:04:35.500 align:middle line:84%
ticket, a valid Kerberos
ticket for any user,

00:04:35.500 --> 00:04:37.630 align:middle line:90%
without knowing their password.

00:04:37.630 --> 00:04:40.780 align:middle line:84%
So imagine you have a
user code, test user,

00:04:40.780 --> 00:04:45.670 align:middle line:84%
and that test user is configured
for constrained delegation

00:04:45.670 --> 00:04:49.450 align:middle line:84%
towards the domain controller
on the LDAP servers.

00:04:49.450 --> 00:04:53.020 align:middle line:84%
That server, or that
account can just go and say,

00:04:53.020 --> 00:04:56.200 align:middle line:84%
hello domain controller,
I am test user.

00:04:56.200 --> 00:04:59.260 align:middle line:84%
I want to authenticate to
you or to another machine

00:04:59.260 --> 00:05:03.160 align:middle line:84%
in this active directory as
the account administrator,

00:05:03.160 --> 00:05:06.460 align:middle line:84%
and I'm just a delegate so just
giving me that Kerberos ticket.

00:05:06.460 --> 00:05:08.380 align:middle line:84%
And the domain
control will happily

00:05:08.380 --> 00:05:11.920 align:middle line:84%
provide that Kerberos ticket
of the account administrator

00:05:11.920 --> 00:05:15.970 align:middle line:84%
without ever validating that
test user knows the password

00:05:15.970 --> 00:05:20.170 align:middle line:84%
or has in any way connection
with the account administrator.

00:05:20.170 --> 00:05:23.322 align:middle line:84%
And again, this
can be really bad.

00:05:23.322 --> 00:05:25.780 align:middle line:84%
And it's really bad if it's
compared to domain controllers.

00:05:25.780 --> 00:05:27.850 align:middle line:84%
If it's configured
to a member server,

00:05:27.850 --> 00:05:30.460 align:middle line:84%
then the worst case scenario
is that we can authenticate

00:05:30.460 --> 00:05:33.440 align:middle line:84%
as a local administrator
or a privileged account

00:05:33.440 --> 00:05:36.310 align:middle line:90%
on that single machine.

00:05:36.310 --> 00:05:39.256 align:middle line:84%
And you can, of course,
login with domain admin.

00:05:39.256 --> 00:05:41.070 align:middle line:90%
We did as well.

00:05:41.070 --> 00:05:43.210 align:middle line:84%
You can delegate yourself
only as domain admin,

00:05:43.210 --> 00:05:45.550 align:middle line:84%
but only that one
specific machine

00:05:45.550 --> 00:05:47.140 align:middle line:84%
is going to trust
that you're actually

00:05:47.140 --> 00:05:49.090 align:middle line:84%
the domain admin
account since you never

00:05:49.090 --> 00:05:53.890 align:middle line:84%
provided the password, which
you're being delegated to.

00:05:53.890 --> 00:05:58.600 align:middle line:84%
And later on, again, Microsoft
realized or eventually came

00:05:58.600 --> 00:06:00.520 align:middle line:84%
to the conclusion that
constrained delegation

00:06:00.520 --> 00:06:03.560 align:middle line:90%
can again, pose an issue.

00:06:03.560 --> 00:06:06.100 align:middle line:84%
So finally they released
what is called resource

00:06:06.100 --> 00:06:08.810 align:middle line:84%
based delegation
where in this case,

00:06:08.810 --> 00:06:12.310 align:middle line:84%
instead of creating the
delegation on the user

00:06:12.310 --> 00:06:16.480 align:middle line:84%
account's properties or the
computer account's properties,

00:06:16.480 --> 00:06:20.080 align:middle line:84%
the resource based delegation
is defined on the resource

00:06:20.080 --> 00:06:21.800 align:middle line:90%
that you're accessing.

00:06:21.800 --> 00:06:24.490 align:middle line:84%
So in our initial
example, this delegation

00:06:24.490 --> 00:06:27.760 align:middle line:84%
would be created on the
computer object that

00:06:27.760 --> 00:06:30.270 align:middle line:90%
is hosting the SQL database.

00:06:30.270 --> 00:06:32.130 align:middle line:90%
So really at the very backend.

00:06:32.130 --> 00:06:37.650 align:middle line:84%
The computer itself will decide
who to trust for delegation.

00:06:37.650 --> 00:06:41.250 align:middle line:84%
And again, with recent
research security professionals

00:06:41.250 --> 00:06:44.250 align:middle line:84%
have created absolutely
amazing tools

00:06:44.250 --> 00:06:49.410 align:middle line:84%
that can go and abuse any of
these Kerberos Delegation types

00:06:49.410 --> 00:06:54.810 align:middle line:84%
and potentially escalate your
[INAUDIBLE] into the domain.

00:06:54.810 --> 00:06:56.620 align:middle line:84%
What I want to do
with these types--

00:06:56.620 --> 00:06:59.970 align:middle line:84%
so really what we want to
achieve with this presentation

00:06:59.970 --> 00:07:04.350 align:middle line:84%
is to understand that Kerberos
Delegation can be an issue

00:07:04.350 --> 00:07:08.130 align:middle line:84%
and we need to find ways
to protect against it.

00:07:08.130 --> 00:07:11.580 align:middle line:84%
Unfortunately, we might need
to use it in an environment

00:07:11.580 --> 00:07:13.830 align:middle line:84%
and there might be really
good reasons for that,

00:07:13.830 --> 00:07:16.150 align:middle line:84%
and that is fine as
long as you manage

00:07:16.150 --> 00:07:19.500 align:middle line:84%
to properly protect our
environment against delegation.

00:07:19.500 --> 00:07:22.170 align:middle line:84%
And we'll talk about
protection just in a bit.

00:07:22.170 --> 00:07:24.300 align:middle line:84%
But what I want to
showcase now, is

00:07:24.300 --> 00:07:27.480 align:middle line:84%
I want to show you a
demonstration of how we can

00:07:27.480 --> 00:07:31.040 align:middle line:90%
abuse unconstrained delegation.

00:07:31.040 --> 00:07:34.100 align:middle line:84%
And the reason why I chose
this specific demonstration

00:07:34.100 --> 00:07:36.770 align:middle line:84%
is because this can
be really, really

00:07:36.770 --> 00:07:38.390 align:middle line:90%
bad in your entire environment.

00:07:38.390 --> 00:07:41.480 align:middle line:84%
This can-- compromising
a machine which

00:07:41.480 --> 00:07:45.800 align:middle line:84%
is tested for delegation, can
result in complete compromising

00:07:45.800 --> 00:07:49.740 align:middle line:84%
your active directory, as
you'll see in the video.

00:07:49.740 --> 00:07:57.420 align:middle line:84%
And in this case, the compromise
comes because the printer

00:07:57.420 --> 00:07:58.740 align:middle line:90%
or the spooler--

00:07:58.740 --> 00:08:01.170 align:middle line:84%
spool server is running
on domain controller.

00:08:01.170 --> 00:08:03.240 align:middle line:84%
So combining
unconstrained delegation

00:08:03.240 --> 00:08:06.575 align:middle line:84%
on a server and the principle
of service on the domain

00:08:06.575 --> 00:08:10.650 align:middle line:84%
controller, can result in
complete forest compromise.

00:08:10.650 --> 00:08:16.590 align:middle line:84%
And there was some research
done where this can actually

00:08:16.590 --> 00:08:18.150 align:middle line:90%
work also across forests.

00:08:18.150 --> 00:08:21.450 align:middle line:84%
So if you have trust
configured between forests,

00:08:21.450 --> 00:08:22.890 align:middle line:84%
compromising one
forest-- and I'm

00:08:22.890 --> 00:08:26.220 align:middle line:84%
using exactly the same scenario
as I'm going to demonstrate,

00:08:26.220 --> 00:08:29.760 align:middle line:84%
can result in compromising
cross forests.

00:08:29.760 --> 00:08:32.640 align:middle line:84%
And that can be, again, really
bad, as you can imagine.

00:08:32.640 --> 00:08:36.799 align:middle line:84%
Let's go to the environment and
showcase this demonstration.

00:08:36.799 --> 00:08:40.760 align:middle line:84%
Now, my environment currently
consists of two servers.

00:08:40.760 --> 00:08:42.150 align:middle line:84%
We have a domain
controller code.

00:08:42.150 --> 00:08:43.100 align:middle line:90%
This is your one.

00:08:43.100 --> 00:08:45.980 align:middle line:90%
And we have the server zero one.

00:08:45.980 --> 00:08:50.030 align:middle line:84%
Server zero one is configured
for unconstrained delegation.

00:08:50.030 --> 00:08:52.920 align:middle line:90%
And currently, I am logged in.

00:08:52.920 --> 00:08:57.350 align:middle line:84%
Oh, I wanted to type
this [INAUDIBLE] Cindy.

00:08:57.350 --> 00:09:02.830 align:middle line:84%
I'm currently logged in as
the account prod slash slavi.

00:09:02.830 --> 00:09:06.090 align:middle line:84%
And this account is
low privileged user,

00:09:06.090 --> 00:09:09.390 align:middle line:84%
and it only has local
administrative rights

00:09:09.390 --> 00:09:12.770 align:middle line:84%
on this one sever
in my entire domain.

00:09:12.770 --> 00:09:15.210 align:middle line:84%
I have somehow managed
to compromise this user

00:09:15.210 --> 00:09:18.820 align:middle line:84%
and now I'm logged in in
that user on server zero one.

00:09:18.820 --> 00:09:21.690 align:middle line:84%
So I want to showcase
that my account doesn't

00:09:21.690 --> 00:09:23.400 align:middle line:90%
have any specific rights.

00:09:23.400 --> 00:09:28.620 align:middle line:84%
And the rights that I'm
really after at this time

00:09:28.620 --> 00:09:34.570 align:middle line:84%
are the ability to perform
domain controller replication.

00:09:34.570 --> 00:09:37.450 align:middle line:84%
And yes, I'm not a
domain controller,

00:09:37.450 --> 00:09:41.650 align:middle line:84%
I'm just a user account,
but under certain rights

00:09:41.650 --> 00:09:44.620 align:middle line:84%
that exist in active
directory, you

00:09:44.620 --> 00:09:47.890 align:middle line:84%
can configure this domain
control replication ability

00:09:47.890 --> 00:09:49.940 align:middle line:90%
also to user accounts.

00:09:49.940 --> 00:09:53.800 align:middle line:84%
So what I wanted to show here
is how we utilize mimikatz.

00:09:53.800 --> 00:09:57.880 align:middle line:84%
And mimikatz has
built-in ability

00:09:57.880 --> 00:10:00.500 align:middle line:84%
to perform this domain
controller replication.

00:10:00.500 --> 00:10:02.950 align:middle line:84%
And the attack itself
is called, dcsync.

00:10:02.950 --> 00:10:06.050 align:middle line:84%
So I will utilize mimikatz
to try to perform that.

00:10:06.050 --> 00:10:09.130 align:middle line:84%
And what I'm expecting to see
is that I'll get an error that I

00:10:09.130 --> 00:10:14.650 align:middle line:84%
cannot beat, since I'm not a
domain controller or I'm not

00:10:14.650 --> 00:10:17.660 align:middle line:90%
a user that has those rights.

00:10:17.660 --> 00:10:20.180 align:middle line:90%
So now this is interesting.

00:10:20.180 --> 00:10:22.700 align:middle line:84%
The command is lsadump
dcsync and then

00:10:22.700 --> 00:10:26.300 align:middle line:84%
I need to specify
user of which account

00:10:26.300 --> 00:10:30.990 align:middle line:84%
I want to obtain the NTLM hash
of once the replication is

00:10:30.990 --> 00:10:31.490 align:middle line:90%
done.

00:10:31.490 --> 00:10:32.907 align:middle line:84%
Because when the
domain controller

00:10:32.907 --> 00:10:35.570 align:middle line:84%
is replicating in
between, they're

00:10:35.570 --> 00:10:38.630 align:middle line:84%
also replicating
NTDS, which contains

00:10:38.630 --> 00:10:42.560 align:middle line:84%
the entire active directory,
including user password hashes.

00:10:42.560 --> 00:10:44.840 align:middle line:84%
So in this case, I can
perform the replication

00:10:44.840 --> 00:10:48.260 align:middle line:84%
and only extract the
password hash of the account

00:10:48.260 --> 00:10:50.630 align:middle line:84%
administrator, or
really the information

00:10:50.630 --> 00:10:52.440 align:middle line:84%
that is associated
with this account.

00:10:52.440 --> 00:10:54.080 align:middle line:84%
So if I run it, I
would get an error.

00:10:54.080 --> 00:10:56.330 align:middle line:84%
And this really
error comes because I

00:10:56.330 --> 00:11:00.500 align:middle line:84%
don't have the necessary
rights to perform this action.

00:11:00.500 --> 00:11:04.950 align:middle line:84%
So to perform the type
we'll use two tools, Rubeus

00:11:04.950 --> 00:11:07.010 align:middle line:90%
and SpoolSample.

00:11:07.010 --> 00:11:10.380 align:middle line:84%
These two are
absolutely amazing.

00:11:10.380 --> 00:11:13.320 align:middle line:84%
They're part of every pen-test
and red team engagements

00:11:13.320 --> 00:11:15.540 align:middle line:90%
that we do.

00:11:15.540 --> 00:11:17.290 align:middle line:84%
I think everyone in
the security community

00:11:17.290 --> 00:11:20.710 align:middle line:84%
is really grateful for the
developers of these tools.

00:11:20.710 --> 00:11:24.700 align:middle line:84%
They're so widely used,
literally everywhere,

00:11:24.700 --> 00:11:27.340 align:middle line:84%
and that's because
they're really great.

00:11:27.340 --> 00:11:30.550 align:middle line:84%
So in my partial compromise
that I have just started,

00:11:30.550 --> 00:11:34.370 align:middle line:84%
I will start Rubeus, and in the
other one I'll run SpoolSample.

00:11:34.370 --> 00:11:35.890 align:middle line:90%
So how the attack works.

00:11:35.890 --> 00:11:39.680 align:middle line:84%
Because we are talking about
unconstrained delegation, what

00:11:39.680 --> 00:11:43.520 align:middle line:84%
we're going to notice or
what we need to be aware of

00:11:43.520 --> 00:11:46.820 align:middle line:84%
is that the computer
account will

00:11:46.820 --> 00:11:51.470 align:middle line:84%
be storing the credentials
that connect to it,

00:11:51.470 --> 00:11:55.250 align:middle line:84%
or that are being delegated
to it for a very small amount

00:11:55.250 --> 00:11:56.810 align:middle line:90%
of time in memory.

00:11:56.810 --> 00:12:00.260 align:middle line:84%
But that time is
sufficient for an attacker

00:12:00.260 --> 00:12:03.410 align:middle line:84%
to extract the Kerberos tickets
that are stored in memory.

00:12:03.410 --> 00:12:06.740 align:middle line:84%
And what Rubeus
has is the ability

00:12:06.740 --> 00:12:09.110 align:middle line:90%
to monitor exactly for that.

00:12:09.110 --> 00:12:11.480 align:middle line:84%
The command is
monitor, and we need

00:12:11.480 --> 00:12:13.085 align:middle line:84%
to set an interval
of how often we

00:12:13.085 --> 00:12:14.870 align:middle line:90%
want this monitoring to happen.

00:12:14.870 --> 00:12:16.110 align:middle line:90%
And then we run the tool.

00:12:16.110 --> 00:12:19.790 align:middle line:84%
So now every second, since
we specified interval one,

00:12:19.790 --> 00:12:22.640 align:middle line:84%
every second Rubeus will
be checking if someone

00:12:22.640 --> 00:12:24.600 align:middle line:90%
has logged into the device.

00:12:24.600 --> 00:12:28.820 align:middle line:84%
And if someone did, it will
extract the Kerberos ticket

00:12:28.820 --> 00:12:31.610 align:middle line:90%
from memory of that user.

00:12:31.610 --> 00:12:34.520 align:middle line:84%
And this will be looking
for both user connections,

00:12:34.520 --> 00:12:37.310 align:middle line:84%
but also for
computer connections.

00:12:37.310 --> 00:12:41.300 align:middle line:84%
Then we'll move into the second
part of this exploitation,

00:12:41.300 --> 00:12:46.640 align:middle line:84%
which is the SpoolSample,
which is based on a printer

00:12:46.640 --> 00:12:49.430 align:middle line:84%
or on the service
printer spooler.

00:12:49.430 --> 00:12:53.570 align:middle line:84%
And what it's really based
on is a short or small bug

00:12:53.570 --> 00:12:57.860 align:middle line:84%
that was discovered
in that service, where

00:12:57.860 --> 00:13:00.170 align:middle line:84%
if you send a specifically
crafted request

00:13:00.170 --> 00:13:05.720 align:middle line:84%
to the spool Service or the
printer service on the machine,

00:13:05.720 --> 00:13:08.030 align:middle line:84%
the service would try to
attempt to get back to you.

00:13:08.030 --> 00:13:12.260 align:middle line:84%
And that authentication happens
with the computer account

00:13:12.260 --> 00:13:15.230 align:middle line:84%
where the service is running
on, since that service

00:13:15.230 --> 00:13:18.210 align:middle line:84%
is running a system on
that specific machine.

00:13:18.210 --> 00:13:20.060 align:middle line:84%
So what SpoolSample
dot exe can do

00:13:20.060 --> 00:13:24.380 align:middle line:84%
is, if it's pointed to the
domain controller which

00:13:24.380 --> 00:13:25.910 align:middle line:84%
is what we're
going to do now, it

00:13:25.910 --> 00:13:28.925 align:middle line:84%
will send a specific custom
request of the domain

00:13:28.925 --> 00:13:29.540 align:middle line:90%
controller.

00:13:29.540 --> 00:13:32.900 align:middle line:84%
And the domain controller
will connect back to us

00:13:32.900 --> 00:13:36.470 align:middle line:84%
where we'll be able to extract
that domain controllers

00:13:36.470 --> 00:13:39.620 align:middle line:90%
Kerberos ticket out of memory.

00:13:39.620 --> 00:13:42.110 align:middle line:84%
And it's really simple, because
these tools are developed

00:13:42.110 --> 00:13:43.910 align:middle line:84%
and they're just
working out of the box.

00:13:43.910 --> 00:13:45.380 align:middle line:84%
So all we have to
do really here,

00:13:45.380 --> 00:13:48.500 align:middle line:84%
is just run the executable,
specify the computer

00:13:48.500 --> 00:13:51.080 align:middle line:84%
that we want to connect back
to us, which in this case

00:13:51.080 --> 00:13:53.570 align:middle line:84%
is this is your one,
and specify ourselves.

00:13:53.570 --> 00:13:56.810 align:middle line:84%
And we are running
on server zero one.

00:13:56.810 --> 00:13:59.060 align:middle line:90%
Then we run it.

00:13:59.060 --> 00:14:03.310 align:middle line:84%
And what you saw immediately is
that Rubeus detected something.

00:14:03.310 --> 00:14:08.180 align:middle line:84%
I'll just scroll all the way up
and here we will see an event.

00:14:08.180 --> 00:14:11.080 align:middle line:90%
ID was detected 4624.

00:14:11.080 --> 00:14:15.070 align:middle line:84%
Login attempt from, this is
zero one, and the IP address

00:14:15.070 --> 00:14:17.360 align:middle line:90%
of the domain controller.

00:14:17.360 --> 00:14:22.130 align:middle line:84%
So further down we'll see
base64 encoded ticket,

00:14:22.130 --> 00:14:25.640 align:middle line:84%
which is the actual Kerberos--
it's a valid Kerberos ticket

00:14:25.640 --> 00:14:27.980 align:middle line:90%
of the domain controller.

00:14:27.980 --> 00:14:29.630 align:middle line:90%
So let's go forward.

00:14:29.630 --> 00:14:33.050 align:middle line:84%
And we'll actually get
to use this ticked now.

00:14:33.050 --> 00:14:35.520 align:middle line:84%
I need to reformat it
since it's multiple lines.

00:14:35.520 --> 00:14:37.730 align:middle line:90%
So I'll use Notepad for that.

00:14:37.730 --> 00:14:41.520 align:middle line:84%
I will replace the new line and
the empty spaces with nothing.

00:14:41.520 --> 00:14:42.280 align:middle line:90%
There we go.

00:14:42.280 --> 00:14:46.030 align:middle line:84%
Now we have only
one line ticket.

00:14:46.030 --> 00:14:47.440 align:middle line:90%
So I just copied the ticket.

00:14:47.440 --> 00:14:52.420 align:middle line:90%
It's base64 variation of it.

00:14:52.420 --> 00:14:55.750 align:middle line:90%
I'm trying to stop Rubeus.

00:14:55.750 --> 00:14:57.110 align:middle line:90%
There we go.

00:14:57.110 --> 00:14:59.090 align:middle line:90%
So now Rubeus is stopped.

00:14:59.090 --> 00:15:02.900 align:middle line:84%
And I have a Kerberos ticket
of the domain controller.

00:15:02.900 --> 00:15:05.390 align:middle line:84%
So I will again use
Rubeus, and this time I'll

00:15:05.390 --> 00:15:08.233 align:middle line:90%
specify as the ticket.

00:15:08.233 --> 00:15:09.650 align:middle line:84%
Actually, let's
first look at what

00:15:09.650 --> 00:15:11.330 align:middle line:90%
tickets I have in my session.

00:15:11.330 --> 00:15:13.640 align:middle line:84%
If I list my
tickets with K list,

00:15:13.640 --> 00:15:16.340 align:middle line:84%
I will see that I have tickets
for slavi, slavi, slavi,

00:15:16.340 --> 00:15:18.470 align:middle line:90%
which is [INAUDIBLE].

00:15:18.470 --> 00:15:21.830 align:middle line:84%
What I'm going to do is, I
will remove all those Kerberos

00:15:21.830 --> 00:15:22.850 align:middle line:90%
tickets.

00:15:22.850 --> 00:15:26.390 align:middle line:84%
And if I do K list
again, I have no tickets.

00:15:26.390 --> 00:15:29.960 align:middle line:84%
Then I'll use Rubeus with the
[INAUDIBLE] ticket command

00:15:29.960 --> 00:15:32.870 align:middle line:84%
and I'll specify the ticket
that I want Rubeus to inject

00:15:32.870 --> 00:15:35.323 align:middle line:90%
into memory on my session.

00:15:35.323 --> 00:15:37.560 align:middle line:90%
OK, the cover page did not work.

00:15:37.560 --> 00:15:38.500 align:middle line:90%
Need to copy it again.

00:15:38.500 --> 00:15:41.320 align:middle line:90%


00:15:41.320 --> 00:15:42.220 align:middle line:90%
There you go.

00:15:42.220 --> 00:15:46.420 align:middle line:84%
So Kerberos will take this
base64 ticket, on base648,

00:15:46.420 --> 00:15:50.040 align:middle line:84%
and encrypt it into
my PowerShell session.

00:15:50.040 --> 00:15:52.237 align:middle line:84%
And it gives us
information that the ticket

00:15:52.237 --> 00:15:53.320 align:middle line:90%
was successfully imported.

00:15:53.320 --> 00:15:56.730 align:middle line:84%
If I do K list now, I have
one ticket and that ticket

00:15:56.730 --> 00:15:59.010 align:middle line:84%
is for the domain
controller itself.

00:15:59.010 --> 00:16:01.080 align:middle line:84%
So even though I'm not
the domain controller,

00:16:01.080 --> 00:16:04.110 align:middle line:84%
I managed to obtain a ticket
and inject it into my session.

00:16:04.110 --> 00:16:05.940 align:middle line:84%
And since I'm at
domain controller now,

00:16:05.940 --> 00:16:09.360 align:middle line:84%
I can go forward and
perform that replication

00:16:09.360 --> 00:16:11.890 align:middle line:90%
that we tried to do earlier.

00:16:11.890 --> 00:16:14.910 align:middle line:84%
So I will execute
mimikatz again.

00:16:14.910 --> 00:16:16.430 align:middle line:90%
And the command was--

00:16:16.430 --> 00:16:23.190 align:middle line:84%
sorry, the command
was samdump dcsync

00:16:23.190 --> 00:16:26.730 align:middle line:84%
with the user being
administrator.

00:16:26.730 --> 00:16:30.850 align:middle line:90%
And it can be really any user.

00:16:30.850 --> 00:16:32.890 align:middle line:84%
OK, I think I got
the command wrong.

00:16:32.890 --> 00:16:36.760 align:middle line:90%


00:16:36.760 --> 00:16:38.800 align:middle line:84%
Of course, it is
lsadump not samdump.

00:16:38.800 --> 00:16:41.920 align:middle line:90%


00:16:41.920 --> 00:16:44.920 align:middle line:84%
So lsadump dcsync, the
user, administrator.

00:16:44.920 --> 00:16:47.680 align:middle line:84%
In this case, we
don't get an error.

00:16:47.680 --> 00:16:51.280 align:middle line:84%
We actually extract information
about the account administrator

00:16:51.280 --> 00:16:52.720 align:middle line:84%
and what you're
going to see here,

00:16:52.720 --> 00:16:55.760 align:middle line:84%
is that we have the password
hash of that account.

00:16:55.760 --> 00:16:59.710 align:middle line:84%
So we actually are going
to be able to perform

00:16:59.710 --> 00:17:02.470 align:middle line:84%
offline password tracking
against this special hash

00:17:02.470 --> 00:17:07.510 align:middle line:84%
or just use this password
hash to pass the hash with it.

00:17:07.510 --> 00:17:09.339 align:middle line:84%
Or finally, what
we can also do is

00:17:09.339 --> 00:17:11.829 align:middle line:84%
we can also pass the ticket
with the special hash

00:17:11.829 --> 00:17:13.810 align:middle line:90%
by again, using Rubeus.

00:17:13.810 --> 00:17:16.119 align:middle line:84%
But the point here,
is that we can

00:17:16.119 --> 00:17:21.980 align:middle line:84%
obtain the password hash of
any user in the entire domain.

00:17:21.980 --> 00:17:26.859 align:middle line:84%
So essentially, by abusing
this unconstrained delegation

00:17:26.859 --> 00:17:30.100 align:middle line:84%
and the printer bug, we managed
to escalate our privileges

00:17:30.100 --> 00:17:32.980 align:middle line:84%
from just having local
administrative rights or one

00:17:32.980 --> 00:17:36.220 align:middle line:84%
single server, which is tested
for unconstrained delegation

00:17:36.220 --> 00:17:39.640 align:middle line:84%
into the entire
domain, in this case.

00:17:39.640 --> 00:17:43.660 align:middle line:84%
And for those of you not aware,
we'll discuss it in later topic

00:17:43.660 --> 00:17:46.330 align:middle line:84%
again, there's something
called golden ticket which

00:17:46.330 --> 00:17:49.720 align:middle line:84%
we can abuse to escalate
to a forest domination

00:17:49.720 --> 00:17:51.610 align:middle line:84%
once we have
compromised our domain.

00:17:51.610 --> 00:17:53.260 align:middle line:90%
But we'll look into that later.

00:17:53.260 --> 00:17:55.360 align:middle line:84%
Point here again,
Kerberos Delegation

00:17:55.360 --> 00:17:57.400 align:middle line:90%
can be really, really bad.

00:17:57.400 --> 00:18:00.970 align:middle line:84%
So what can we do to
protect against it?

00:18:00.970 --> 00:18:04.120 align:middle line:84%
So each user account has
this attribute called,

00:18:04.120 --> 00:18:07.510 align:middle line:84%
this account is sensitive
and can be delegated.

00:18:07.510 --> 00:18:11.380 align:middle line:84%
If this attribute
is set, there will

00:18:11.380 --> 00:18:13.270 align:middle line:90%
be no tickets stored in memory.

00:18:13.270 --> 00:18:16.400 align:middle line:84%
And in the case of
constrained delegation,

00:18:16.400 --> 00:18:19.170 align:middle line:84%
you cannot just go and
say, hello I'm trusted

00:18:19.170 --> 00:18:22.180 align:middle line:84%
for delegation, I want a
ticket for this account.

00:18:22.180 --> 00:18:24.970 align:middle line:84%
As long as this is set,
you cannot request a ticket

00:18:24.970 --> 00:18:27.800 align:middle line:90%
on behalf of another user.

00:18:27.800 --> 00:18:31.310 align:middle line:84%
There's also the protected
users group, which special group

00:18:31.310 --> 00:18:32.540 align:middle line:90%
in active directory.

00:18:32.540 --> 00:18:36.620 align:middle line:84%
It provides a massive amount
of protections for users

00:18:36.620 --> 00:18:37.770 align:middle line:90%
who are a member of it.

00:18:37.770 --> 00:18:40.760 align:middle line:84%
And that's provided by default.
The only thing you have to do

00:18:40.760 --> 00:18:42.600 align:middle line:84%
is just be a member
of this group.

00:18:42.600 --> 00:18:45.710 align:middle line:84%
And one of the protections that
it provides is that the account

00:18:45.710 --> 00:18:48.833 align:middle line:84%
member of this group
cannot be delegated.

00:18:48.833 --> 00:18:50.750 align:middle line:84%
We'll talk about this
group in detail later on

00:18:50.750 --> 00:18:58.530 align:middle line:84%
and we'll list all the different
protections that it provides.

00:18:58.530 --> 00:19:04.010 align:middle line:84%
And then, when you have
users and computers that

00:19:04.010 --> 00:19:06.320 align:middle line:84%
are configured for
delegation, you really

00:19:06.320 --> 00:19:08.660 align:middle line:84%
need to go one step
forward or further

00:19:08.660 --> 00:19:12.350 align:middle line:84%
and ensure that those users and
computer accounts are really

00:19:12.350 --> 00:19:13.410 align:middle line:90%
protected.

00:19:13.410 --> 00:19:16.520 align:middle line:84%
So for computer accounts,
really limit the amount

00:19:16.520 --> 00:19:18.620 align:middle line:84%
of users who can log
into them, ensure

00:19:18.620 --> 00:19:21.290 align:middle line:84%
that you have proper
patching, and don't really

00:19:21.290 --> 00:19:24.710 align:middle line:84%
install any third party
tools or any software

00:19:24.710 --> 00:19:27.230 align:middle line:84%
that you're not patching,
because you might introduce

00:19:27.230 --> 00:19:30.470 align:middle line:84%
bugs or exploits, critical
exploits that might not

00:19:30.470 --> 00:19:32.240 align:middle line:90%
budge against that server.

00:19:32.240 --> 00:19:35.670 align:middle line:84%
And regardless of what you do
in the rest of your network,

00:19:35.670 --> 00:19:37.130 align:middle line:90%
this server will be exposed.

00:19:37.130 --> 00:19:39.500 align:middle line:84%
So really limit the attack
servers of your device.

00:19:39.500 --> 00:19:41.930 align:middle line:84%
Don't install software that
is not required in there

00:19:41.930 --> 00:19:45.500 align:middle line:84%
and limit the amount of people
who have access to that.

00:19:45.500 --> 00:19:50.270 align:middle line:84%
Even groups such as users,
who have access to all servers

00:19:50.270 --> 00:19:53.120 align:middle line:84%
should probably not have access
to these delegation servers.

00:19:53.120 --> 00:19:56.040 align:middle line:90%
They're very sensitive.

00:19:56.040 --> 00:19:57.180 align:middle line:90%
There's a final note.

00:19:57.180 --> 00:20:01.260 align:middle line:84%
What I wanted to state is that
Kerberos Delegation, which

00:20:01.260 --> 00:20:03.210 align:middle line:84%
I already stated
multiple times by now,

00:20:03.210 --> 00:20:05.250 align:middle line:84%
Kerberos Delegation
is a massive issue.

00:20:05.250 --> 00:20:08.230 align:middle line:84%
You should not
use it if you can.

00:20:08.230 --> 00:20:11.070 align:middle line:84%
But if you need to
use it, then ensure

00:20:11.070 --> 00:20:13.500 align:middle line:90%
that it's properly protected.

00:20:13.500 --> 00:20:14.000 align:middle line:90%