WEBVTT

00:00:00.000 --> 00:00:06.442
So I've seen some talks on using WMI for some pretty cool attacks.

00:00:06.442 --> 00:00:09.734
There was a Black Hat talk in 2015 about it where a guy

00:00:09.734 --> 00:00:11.325
had used it for blue team and red team,

00:00:11.325 --> 00:00:15.983
but established persistence and then monitored that box for WMI commands.

00:00:15.984 --> 00:00:17.357
We had talked before,

00:00:17.357 --> 00:00:20.434
WMI can also be used for these kind of fileless attacks

00:00:20.434 --> 00:00:21.939
that push stuff straight into memory.

00:00:21.939 --> 00:00:22.729
Can you speak to that a little bit?

00:00:22.730 --> 00:00:23.101
Yeah.

00:00:23.101 --> 00:00:28.512
So WMI, or Windows Management Instrumentation, has been around forever.

00:00:28.512 --> 00:00:32.468
I remember using it when I had, when I just got my Windows XP box way,

00:00:32.468 --> 00:00:35.234
way too long ago that we won't talk about,

00:00:35.234 --> 00:00:38.098
and I think it's even been around since like Windows 2000.

00:00:38.098 --> 00:00:42.970
So it's essentially another management interface for administrators.

00:00:42.970 --> 00:00:46.983
WMI is extremely powerful just like PowerShell is.

00:00:46.983 --> 00:00:49.015
You can do a lot.

00:00:49.016 --> 00:00:53.553
And one of the ways that attackers use WMI is,

00:00:53.553 --> 00:00:55.631
well, they use it to execute commands.

00:00:55.632 --> 00:00:58.269
You can execute commands directly through WMI.

00:00:58.269 --> 00:01:00.855
You can even execute commands if they're hidden essentially.

00:01:00.855 --> 00:01:05.974
You can use it to read the registry, to modify the registry.

00:01:05.974 --> 00:01:08.400
You can use it to interact with services,

00:01:08.400 --> 00:01:10.946
with the networking infrastructure within Windows.

00:01:10.946 --> 00:01:12.834
I mean, there's just so much you can do with it.

00:01:12.834 --> 00:01:15.600
Yeah, I've even used it to modify BIOS settings.

00:01:15.601 --> 00:01:16.574
Yes, exactly.

00:01:16.574 --> 00:01:21.161
And WMI is not just limited to the system it's on.

00:01:21.161 --> 00:01:22.852
Just like PowerShell has remoting,

00:01:22.852 --> 00:01:27.916
there's also WMI remoting so that you can actually execute commands,

00:01:27.916 --> 00:01:31.315
WMI commands, on other systems as long as you have the right credentials,

00:01:31.315 --> 00:01:36.097
and that's how attackers sometimes laterally move within an organization.

00:01:36.097 --> 00:01:36.450
So yeah.

00:01:36.450 --> 00:01:42.307
Like if when RM has been configured on the box, you now have remote capability.

00:01:42.307 --> 00:01:46.540
Yeah, a user, or I'm sorry, an attacker if they get on the box,

00:01:46.540 --> 00:01:48.628
probably what they're going to do is their going to load something

00:01:48.628 --> 00:01:54.006
like Mimikatz on it to grab the credentials out of memory and then use

00:01:54.006 --> 00:01:57.169
WMI to pivot throughout the environment.

00:01:57.169 --> 00:02:01.812
I, in my current job, I work with pen testers.

00:02:01.813 --> 00:02:04.635
With the company that I work for, we do a lot of pen testing,

00:02:04.635 --> 00:02:09.536
and so I get to see all the backend conversations that are happening.

00:02:09.536 --> 00:02:13.610
And the pen testers are absolutely using this.

00:02:13.610 --> 00:02:15.360
The first thing when they do when they get on there is

00:02:15.360 --> 00:02:18.909
they dump passwords if they can, and then they use WMI,

00:02:18.909 --> 00:02:23.997
or PowerShell, or something along those lines to pivot through the environment,

00:02:23.997 --> 00:02:27.624
and they're using the exact same techniques that the attackers are doing.

00:02:27.625 --> 00:02:30.917
So it's not just the people coming into your network

00:02:30.917 --> 00:02:32.919
to test it that they're using this.

00:02:32.920 --> 00:02:36.538
They're emulating the attackers, and so this is real-life stuff.

00:02:36.538 --> 00:02:38.720
This is stuff that's happening every day.

00:02:38.720 --> 00:02:38.934
Yeah,

00:02:38.934 --> 00:02:41.460
so that's kind of a unique work environment too and

00:02:41.460 --> 00:02:44.217
hopefully something that we're towards, kind of purple team.

00:02:44.218 --> 00:02:50.680
It is, and that's exactly what's going on here is the red teamers are coming in,

00:02:50.680 --> 00:02:53.543
they're doing the pen testing, they're using these fileless techniques,

00:02:53.544 --> 00:02:55.967
and then they sit down with the defense,

00:02:55.967 --> 00:02:58.692
and they go through and they show them alright well,

00:02:58.692 --> 00:03:00.257
here is how you could have detected it.

00:03:00.257 --> 00:03:03.672
This is what you need to turn on in order to detect it and so on,

00:03:03.672 --> 00:03:08.121
and that helps us as defenders protect ourselves and our organizations.

00:03:08.121 --> 00:03:08.301
Yeah.

00:03:08.301 --> 00:03:09.747
That's kind of an awesome cycle of upgrade.

00:03:09.748 --> 00:03:12.311
Like Cyber threat emulation, and then you're like hey,

00:03:12.311 --> 00:03:14.499
here's where you didn't catch it, and here's how you could.

00:03:14.500 --> 00:03:16.681
And then you come in as the blue team and figure out hey,

00:03:16.681 --> 00:03:19.954
let's help you set up to be able to detect this next time.

00:03:19.954 --> 00:03:20.755
Yeah, exactly.

00:03:20.755 --> 00:03:22.185
Very cool.

00:03:22.185 --> 00:03:26.640
With WMI still though, there is still so much more you can do.

00:03:26.640 --> 00:03:29.386
With PowerShell, when we talked about that,

00:03:29.386 --> 00:03:33.772
it's very powerful, but there's no way for you to set up persistence,

00:03:33.772 --> 00:03:36.493
for the attacker to set up persistence on the network,

00:03:36.494 --> 00:03:38.126
within PowerShell itself.

00:03:38.127 --> 00:03:41.115
I mean, there are a couple of ways, but they're not very easy.

00:03:41.115 --> 00:03:45.558
And typically, what attackers will do is they'll go to the registry,

00:03:45.558 --> 00:03:48.614
and in the persistence keys within the registry,

00:03:48.614 --> 00:03:52.106
like the Windows current version or Microsoft

00:03:52.106 --> 00:03:54.329
Windows--- The control set of the run key.

00:03:54.330 --> 00:03:55.808
---yeah, yeah, the run key.

00:03:55.808 --> 00:03:57.831
They'll set up a PowerShell command in there.

00:03:57.832 --> 00:03:59.673
Well, that's easily detectable.

00:03:59.674 --> 00:04:00.873
Everybody knows that.

00:04:00.873 --> 00:04:03.309
You can download Autoruns from Microsoft,

00:04:03.309 --> 00:04:05.979
and that's the first thing that everybody learns to check.

00:04:05.979 --> 00:04:08.973
WMI itself can set up its own persistence,

00:04:08.973 --> 00:04:11.816
and it becomes a little bit more difficult to check

00:04:11.816 --> 00:04:15.083
because not everybody thinks to check WMI.

00:04:15.083 --> 00:04:18.379
And so, within MI, you can set up things called event subscriptions,

00:04:18.379 --> 00:04:23.827
and these are essentially, they're composed of three parts.

00:04:23.827 --> 00:04:27.316
There is the consumer, which is the action that's going to perform,

00:04:27.316 --> 00:04:28.567
that's going to be performed,

00:04:28.567 --> 00:04:30.128
when you know what the script that's going to be run,

00:04:30.128 --> 00:04:32.047
the WMI commands that are going to be run,

00:04:32.047 --> 00:04:32.716
and so on.

00:04:32.716 --> 00:04:36.295
There's the filter, which is when is it going to do this?

00:04:36.295 --> 00:04:40.524
Is it going to run the consumer when somebody logs on,

00:04:40.524 --> 00:04:45.888
or every 5 minutes, or when the system gets shutdown.

00:04:45.889 --> 00:04:46.658
The timing of it.

00:04:46.658 --> 00:04:49.720
There are lots of different times when the filter can go off.

00:04:49.720 --> 00:04:53.761
And then the binding, which really just what takes the consumer,

00:04:53.762 --> 00:04:56.372
the filter, and kind of connects them together.

00:04:56.373 --> 00:05:02.108
And well, the advantage to this is whenever you set up an event subscription,

00:05:02.109 --> 00:05:05.473
you have to have administrative privileges on the system first off to do this,

00:05:05.473 --> 00:05:08.177
or elevated privileges, which for attackers,

00:05:08.177 --> 00:05:10.966
is not always that difficult to get.

00:05:10.966 --> 00:05:13.517
So you're in Mimikatz, and now you're on--- Exactly.

00:05:13.517 --> 00:05:15.874
You run Mimikatz, you've elevated your privileges,

00:05:15.875 --> 00:05:17.980
and you've set up this WMI subscription.

00:05:17.981 --> 00:05:22.826
Well, when the subscriptions are executed,

00:05:22.826 --> 00:05:26.715
they're often executed either as system or as a local service,

00:05:26.715 --> 00:05:28.815
the elevated user accounts already,

00:05:28.815 --> 00:05:31.535
depending on what operating system you're using.

00:05:31.535 --> 00:05:37.055
And so if an attacker can set up one of these event subscriptions,

00:05:37.055 --> 00:05:40.428
then they will, as soon as that get off,

00:05:40.428 --> 00:05:43.447
they're already at a higher level of privilege on the system,

00:05:43.447 --> 00:05:46.040
perhaps even the highest level of privilege that they can get to.

00:05:46.041 --> 00:05:49.154
And so you can just imagine when attacker gets that,

00:05:49.154 --> 00:05:51.612
that's like the ultimate for them.

00:05:51.612 --> 00:05:53.848
They can do anything on the system.

00:05:53.849 --> 00:05:55.486
That's why they call it owning the system.

00:05:55.486 --> 00:05:57.844
They can do anything they want.

00:05:57.844 --> 00:05:59.566
It's not your system anymore.

00:05:59.566 --> 00:06:03.115
So that's pretty neat too because that's kind of a legacy like WMI is legacy.

00:06:03.116 --> 00:06:05.763
I know SIEMs come in, SIEM objects are being phased in,

00:06:05.763 --> 00:06:07.416
but it's essentially the same functionality.

00:06:07.416 --> 00:06:11.493
But being able to use this legacy tool that no one really thinks to

00:06:11.493 --> 00:06:14.671
check with a lot of the same capabilities sounds like as Task

00:06:14.671 --> 00:06:18.046
Scheduler and as like normal persistence methods,

00:06:18.047 --> 00:06:19.793
but kind of go in undetected.

00:06:19.793 --> 00:06:22.148
And the same thing as this can also be ran

00:06:22.149 --> 00:06:23.919
in-memory is what we're talking about.

00:06:23.920 --> 00:06:29.510
Yeah, when you run a WMI, it does put some things in files.

00:06:29.510 --> 00:06:33.429
There are certain directories, especially for, with event subscriptions.

00:06:33.429 --> 00:06:34.949
It's going store--- It has to be somewhere.

00:06:34.950 --> 00:06:35.856
---yeah, it has to be somewhere.

00:06:35.856 --> 00:06:39.533
It's going to store those as a file under Windows.

00:06:39.533 --> 00:06:43.885
But when the attackers are using WMI commands themselves to pivot

00:06:43.885 --> 00:06:47.915
around the environment or run other programs,

00:06:47.915 --> 00:06:50.770
they will do that, and it's all in-memory.

00:06:50.770 --> 00:06:56.067
And honestly, there's very little logging that occurs with WMI by default.

00:06:56.068 --> 00:06:56.366
Yeah.

00:06:56.366 --> 00:06:58.758
I mean, I don't recall even seeing any.

00:06:58.759 --> 00:07:00.536
No, it's usually, by default,

00:07:00.536 --> 00:07:05.390
you only see any error messages that occur when WMI occurs,

00:07:05.390 --> 00:07:07.824
when WMI commands go off.

00:07:07.825 --> 00:07:10.442
Now there are other tools that we're going talk about that you can

00:07:10.442 --> 00:07:15.697
use to kind of enhance the WMI logging that go on.

00:07:15.697 --> 00:07:18.181
So it is possible, but again, it's not by default.

00:07:18.182 --> 00:07:21.323
You have to go in and purposely set this stuff up.

00:07:21.323 --> 00:07:28.073
So this is intentional security monitoring.

00:07:28.073 --> 00:07:30.323
Right exactly.
