WEBVTT

00:00.000 --> 00:10.380
We're going to get started this morning with what looks to be a very exciting talk with a couple of recorded demos, because these guys are smart and they don't do live demos at DEF CON.

00:10.440 --> 00:16.080
Well, you're allowed, but it's just a really, really terrible idea.

00:17.040 --> 00:29.060
So if this is your first time in track four, which we are calling fancy track, here in fancy track, you cannot vape, you cannot smoke anything of any kind.

00:29.520 --> 00:33.380
You are not supposed to be having any kind of outside beverages other than water.

00:33.740 --> 00:34.700
There you go.

00:35.180 --> 00:44.240
Like I said, if you want to kind of move towards the center so that people can get in and out, that will help because we're going to have a lot of people coming to a lot of really good talks today.

00:44.580 --> 00:48.680
With that said, let's get Topher and Michael up here.

00:48.700 --> 00:50.800
How many people use antivirus at work?

00:51.260 --> 00:53.080
How many people believe it does anything?

00:53.380 --> 00:54.720
There we go.

00:54.720 --> 00:56.520
How many people use EDR at work?

00:56.980 --> 00:57.240
Yeah?

00:57.240 --> 00:59.520
How many people believe it does something?

01:00.220 --> 01:01.260
Aha!

01:02.940 --> 01:04.020
Suckers!

01:05.040 --> 01:08.040
Let's give Michael and Topher a big round of applause.

01:10.420 --> 01:21.310
Thank you for coming on an early Saturday morning.

01:21.750 --> 01:23.910
EDR is coming, hide your shit.

01:24.510 --> 01:27.170
I'm really happy to be here this year.

01:27.170 --> 01:32.510
This sort of came about as a hallway conversation at DEF CON last year.

01:32.510 --> 01:37.810
We had some ideas, we talked it over, it turned into some research and here we are.

01:37.810 --> 01:39.670
And that's pretty exciting.

01:39.670 --> 01:45.170
So go out there and talk to all the people and have all the ideas and submit something next year.

01:46.470 --> 01:49.790
Alright, so who are we?

01:49.790 --> 01:52.410
Well, first of all, we don't speak for our employer.

01:52.410 --> 02:00.510
These are speaking all on behalf of ourselves and nothing that we are saying is to be construed as, you know, from our employer.

02:01.330 --> 02:02.710
I'm Michael Liebowitz.

02:02.710 --> 02:12.570
I like to, in my free time, write or make hardware implants, re-implementing NSA hardware implants and I'm a principal troublemaker.

02:13.390 --> 02:14.050
Anne?

02:14.510 --> 02:16.290
And I'm Topher Timson.

02:16.290 --> 02:18.330
I like doing like C sharp malware stuff.

02:18.330 --> 02:24.090
So hilariously enough, some of the things you are going to see in this talk, I've talked about previously at DEF CON 23.

02:24.090 --> 02:25.930
So it's kind of like the old is still new.

02:26.070 --> 02:28.070
I'm a principal vulnerability enthusiast.

02:28.070 --> 02:34.050
We both work on red teams and as you can see by our matching attire, we just want to drink coffee and write malware.

02:36.730 --> 02:42.850
Alright, so here's what we're going to go through and we have a lot to cover.

02:42.850 --> 02:44.830
So we're going to go through it pretty fast.

02:44.830 --> 02:47.530
Basically, what EDR is, why we care.

02:48.830 --> 02:57.950
UEFI and the thing to note about UEFI is UEFI is cross-platform which is why we're doing a Windows and a Linux demo and why we have a Windows and Linux payload.

02:58.230 --> 03:01.470
Of course, you know, what everyone's wondering, what does this all mean ?

03:01.710 --> 03:05.570
And then, you know, some mitigation or whatever and then future work and then conclusions .

03:08.430 --> 03:11.050
So we're going to kind of start off with talking about EDR.

03:11.050 --> 03:13.990
So a lot of you raised your hands that you use this and think it works.

03:13.990 --> 03:16.190
So we're about to, you know, kind of ruin that for you.

03:17.210 --> 03:22.230
So kind of a, so it's 10 o'clock, the slides are a little bit hung over.

03:22.230 --> 03:25.570
So EDR is end point detection and response, not enterprise.

03:25.570 --> 03:27.730
Thanks slides for being up early with us.

03:28.150 --> 03:37.470
The biggest thing about EDR is that it's really just defensive tooling that focuses on like detecting, investigating and mitigating suspicious activities going on within an environment.

03:37.770 --> 03:41.790
The big thing that it really provides blue teams is a hunt capability.

03:41.790 --> 03:49.610
So this is how and a lot of organizations, they're making like large scale like correlations for hunt stages.

03:49.610 --> 03:52.730
So like, oh, this machine over here is doing these sorts of things.

03:52.730 --> 03:53.790
That's not really typical.

03:53.790 --> 03:55.310
This alert fired on our scene.

03:55.310 --> 03:56.550
Let's go investigate.

03:57.090 --> 04:03.610
Typically, it really just means that like for us on red teams that blue team is going to find you and we don't want to be found.

04:03.790 --> 04:07.050
Uh, so we're going to sort of look at how we avoid that.

04:07.490 --> 04:14.670
Um, and then like the one big thing with EDR is that typically everything is mapped to uh, like MITRE attack.

04:14.670 --> 04:23.690
And if you're not familiar with MITRE attack, that's essentially just like this huge knowledge, knowledge base of uh, of things that attackers tend to do based off of real world observation.

04:23.850 --> 04:27.190
So like you probably hear the term like TTPs thrown around everywhere.

04:27.510 --> 04:32.790
Um, in essence, it's really just this huge table that lists things that attackers like to do.

04:32.870 --> 04:40.830
So you kind of like think back to previous life when you were in kindergarten and you get like a gold star for like turning in your homework on time and like being polite.

04:40.950 --> 04:43.590
It's essentially like that but for like us as bad guys.

04:43.590 --> 04:45.830
So we get gold stars when we do like persistence.

04:45.830 --> 04:47.970
We get a gold star for privilege escalation.

04:48.290 --> 04:52.950
Uh, so like we want to fill out all the things but not have anybody know so we don't actually get the gold stars.

04:52.950 --> 04:54.350
Uh, we just want to do it.

04:56.030 --> 05:03.250
Um, so like I'm saying like EDR is really just tuned like in actuality for like processes, commands and API calls.

05:03.250 --> 05:10.290
So if you're like running say like uh, CMD.XE or PowerShell or doing like some registry stuff or trying to set up persistence.

05:10.350 --> 05:19.330
Because those are like TTPs in the MITRE attack framework, those tend to be flagged and mapped and then alerted on for the, the blue team.

05:19.330 --> 05:22.350
Um, and we want to make sure that none of that actually happens.

05:24.670 --> 05:33.150
So, uh, a lot of people talk about, you know, the risk curve and um, you know, this is the other side of the risk curve.

05:33.190 --> 05:37.370
Basically, you know, no, no attack, no breach lasts forever, right?

05:37.370 --> 05:41.230
You can see from the right side of the graph that eventually you're going to get busted.

05:41.670 --> 05:46.090
And you, you land your shell, you know, that's kind of the highest risk time.

05:46.090 --> 05:49.510
You move around a little bit and eventually you sort of settle into persistence.

05:49.890 --> 05:53.910
And like the longer you hold on, the more chance it is that someone's going to roll you up.

05:53.970 --> 06:00.750
And really what we want to do is, you know, make this curve flatten a little bit.

06:01.850 --> 06:05.670
And, you know, what, what does it mean when, you know, the breach gets detected?

06:05.670 --> 06:07.550
Like no one's sleeping well tonight.

06:07.550 --> 06:09.090
This is, this is terrible.

06:09.730 --> 06:14.110
You know, your lovingly crafted payload becomes the analyst's sample.

06:14.110 --> 06:21.370
You're like very upset because all these months of work and crafting that super awesome payload are just down the drain.

06:21.370 --> 06:25.130
And the analyst is like, oh shit, there goes my Friday night.

06:26.670 --> 06:27.790
Nobody's happy.

06:28.910 --> 06:33.810
So what we want to do is we want to modify this risk curve.

06:33.810 --> 06:41.730
We want to make it such that, you know, we're not going to flatten that initial shell pop kind of, kind of part, like that's kind of the same.

06:41.730 --> 06:45.570
But we just want to, we just want to hang on to the good stuff for longer.

06:45.570 --> 06:47.650
Eventually, eventually you're going to get rolled up.

06:47.650 --> 06:51.610
But we just, just hang out and chill out for a little bit longer.

06:54.070 --> 07:06.890
So as we were investigating ways that we can hide from a UEF or from a EDR, Mike and I had some pre-existing platform experience, a particular UEFI platform experience, so like platform firmware.

07:07.190 --> 07:18.830
So in sort of this research, it's like, we were thinking that we can utilize this sort of functionality to evade all of these detections and make that risk curve and the dwell time for us last a little bit longer.

07:19.270 --> 07:28.690
So if you're not familiar with UEFI, I have to include this awesome diagram of it because John Lucchetti has told everybody ever talking about UEFI that they have to.

07:29.310 --> 07:34.430
Essentially, if you're not familiar with UEFI, it's essentially what modern BIOS is now.

07:34.430 --> 07:43.430
So it does all of the things that you don't really care about, like CPU in it, trains your memory, it loads a bunch of option ROMs from like your PCI devices.

07:44.130 --> 07:47.310
There's other talks that go over what this actually means.

07:47.310 --> 07:57.410
Uh, but what we're concerned about is if you look at the bottom, there's this notion of runtime services and after the OS boots, those are exposed at the operating system level.

07:57.450 --> 08:04.150
Some of the things that get exposed within the runtime services stage of UEFI are, uh, UEFI firmware variables.

08:04.150 --> 08:17.610
So these are persistent variables that actually live within your NVRAM on your, on, on your platform, uh, that are accessible both to UEFI applications, like, if you're familiar with secure boot, all of your secure boot like variables and stuff live there.

08:17.610 --> 08:24.410
So like boot order, like your, uh, the keys that secure boot utilizes, things of that, uh, nature.

08:24.510 --> 08:32.350
So we're going to take advantage of the fact that we can persist within NVRAM, within the UEFI platform that we can then access at operating system runtime.

08:32.830 --> 08:38.610
Um, so, sort of like, you're probably thinking at this point, well, why UEFI firmware variables?

08:38.890 --> 08:46.430
Well, like I was saying, it, it's a way that you can hide your payloads from all of these detective capabilities because it's, it's a blind spot for all of them.

08:46.430 --> 08:51.470
Nobody looks here, like really at all, especially within AV and EDR platforms.

08:51.730 --> 08:59.730
Um, if you're not familiar really with what UEFI firmware variables are either, it essentially consists of like a name and a GWID, so it's like this tuple.

08:59.730 --> 09:06.430
And if you are able to set or get that, uh, that tuple, you can pull the contents of what that variable is out of NVRAM.

09:06.430 --> 09:15.330
And we're going to kind of showcase that we can execute those live on the system to both stash our stuff and to sort of have like this persistence, uh, mechanism.

09:17.570 --> 09:22.790
So, really quickly, uh, like UEFI firmware variables have a couple of types.

09:22.790 --> 09:25.130
There's authenticated and unauthenticated.

09:25.210 --> 09:32.770
This isn't so much important, but we kind of just wanted to briefly touch on it, uh, just in case you're concerned at all with the specification or what we're doing.

09:32.770 --> 09:40.090
Like, um, if you've heard of like authenticated variables, these are signed like X509 certs that, uh, perform like a certificate check when writing.

09:40.210 --> 09:41.870
Uh, we're not going to worry about those.

09:41.870 --> 09:47.110
There are unauthenticated variables that are also, um, present, uh, at that runtime stage.

09:47.110 --> 09:49.230
These have no verification on write.

09:49.230 --> 09:53.750
The majority of variables on a platform, as we'll show you in a demo, are unauthenticated.

09:53.750 --> 10:00.330
Uh, so it's not really abnormal for these to be there and it's not atypical for things to necessarily be writing or reading from there.

10:00.370 --> 10:04.050
Um, if you're like a platform researcher or something, you know about this.

10:04.910 --> 10:09.950
Uh, there's a couple of attributes as well to UEFI firmware variables, uh, within the specification.

10:10.170 --> 10:27.150
We're going to really just focus on 3 out of the 6 because as I'll showcase in the Windows 10 API, uh, you have to have non-volatile boot service access and runtime access in order to have, uh, UEFI variables that persist within the Windows runtime after boot on your NVRAM.

10:27.170 --> 10:31.910
Um, so just note that those 3 are going to be utilized and that'll be shown in the demo as well.

10:32.070 --> 10:49.650
Sort of the hilarious little thing here too with, uh, why we sort of started thinking about UEFI as a way to hide from EDR is, uh, in an old, old life, we're walking, you know, with some blue team, uh, folks and we're talking about ways that we've been being tricky on engagements and sharing some techniques.

10:50.570 --> 10:55.990
And we're kind of talking about, like, uh, IOT devices and how it'd be cool to hide, like, an IOT firmware.

10:55.990 --> 10:59.990
And they're like, yeah, that'd be cool, but, like, please don't ever hide, like, in platform firmware.

10:59.990 --> 11:02.930
And, you know, Mike and I kind of stopped and we're like, oh, shit.

11:06.190 --> 11:08.790
Uh, so we're going to do Windows and Linux, uh, and we're going to do, uh, Windows and Linux.

11:08.790 --> 11:12.730
Like Mike said, uh, UEFI is platform agnostic, so it doesn't matter what it's running on.

11:12.730 --> 11:14.090
It's, it's part of your platform.

11:14.090 --> 11:16.550
It helps boot Intel, like, processors.

11:16.550 --> 11:18.550
It also works, like, on AMD.

11:18.630 --> 11:19.770
Uh, it's kind of different there.

11:19.770 --> 11:22.290
It's, it's a specification , whatever.

11:22.610 --> 11:39.890
Um, so UEFI and Windows, basically, um, I was re-looking at the MSDN articles for Windows 10 and I recognized, so they had taken this off and then they re-introduced the ability to do UEFI platform stuff within 1803.

11:40.430 --> 11:43.470
Um, so I was kind of, like, reading the documents.

11:43.470 --> 11:50.790
They, they listed all of these requirements for actually being able to use this, these API function, this API functionality within Windows now.

11:50.830 --> 11:55.610
So it was kind of concerning because there, there's a lot there that they say you need this, otherwise it won't work.

11:55.610 --> 11:59.570
Such as, you need to declare firmware read and write in your application manifest.

11:59.770 --> 12:04.230
You need to have it be a protected app, so, like, a signed app that the Microsoft store signs.

12:04.230 --> 12:05.330
Needs to be signed.

12:05.330 --> 12:13.350
You need to be an admin that has access to this special privilege SE system environment name, uh, like privilege token in your process space.

12:13.490 --> 12:21.370
So looking at it, it was kind of daunting because it's, it's such a long list of requirements, but, you know, we're hackers, that doesn't mean anything.

12:21.710 --> 12:36.210
Uh, so we started looking at ways to bypass this, like Specter Ops puts out a lot of, like, WDAC bypasses, which is a way to execute signed Windows binaries with that, well, unsigned Windows binaries, so, like, unsigned Windows binaries you can still execute.

12:36.270 --> 12:53.850
Um, obviously on red teams we sometimes jump to conclusions or we make, uh, some leaps forward to speed up engagement time with, like, assume breach type, um, scenarios or sort of the methodology and thinking that we're gonna wind up being admin, why don't we just become admin now.

12:53.950 --> 13:07.130
Um, so, like, that sort of stuff for our purposes of doing this sort of thing on red team engagements wasn't necessarily impactful, so we just kind of went with it with the assumption that we're gonna be, we can be an admin on a box and we're not gonna need it to be a signed,

13:07.130 --> 13:08.470
uh, Windows application.

13:09.890 --> 13:25.650
So, like, uh, just to showcase what the read and white firmware variable API looks like from the MSDN articles, you can do set and get firmware variables from NVRAM, uh, really the key thing here is you just have, like, the name and GWT tuple that I was mentioning earlier,

13:25.650 --> 13:37.030
um, and for set, all you do is you point, uh, the buffer you want to write into the variable, you give it the size and the attributes that you want to have it be declared as, and it just sets it in NVRAM for you.

13:37.030 --> 13:52.310
And then for get, it's the same sort of idea, you give it a name and a GWT tuple and then you give it the buffer you want to read into and then it reads the NVRAM out into some memory buffer that you control as the attacker and, of course, you'll wind up executing that once you get the variable out of NVRAM.

13:53.190 --> 14:07.510
Uh, these are the attributes, not really important, it's on the slide more for reference, but this is from the MSDN article, note that for variable, uh, attribute runtime services, it says if you want this to be accessible during RT, it needs to also be accessible to boot services,

14:07.510 --> 14:12.650
so that's kind of why we're going to have to set all three in Windows, so NVBS and RT variables.

14:14.170 --> 14:30.430
So when I was initially implementing this, uh, it was sort of the decision between if I wanted it to be in C++ or in C sharp, so I initially implemented all of this in C++ just because it was, it was easy, because the MSDN articles basically just give you the code you need,

14:30.430 --> 14:45.330
but as I was kind of doing the research, it occurred to me that C++ wasn't a viable option because AV flags it very easily, um, like one thing that you have to do obviously if we're getting a firmware variable is you need RWX memory, so doing a lot of calls to like virtual alloc,

14:45.330 --> 14:58.710
virtual protect, uh, it's kind of a red flag right now, especially for EDR products as they start querying all these APIs, um, like most applications aren't like making an RWX memory buffer and then executing it like it was shellcode, so we're not going to do that.

14:59.130 --> 15:08.510
Um, C sharp can basically do everything C++ can either with P invoke or reflection, and having C sharp malware experience in the past was like, yeah, let's just do it in C sharp.

15:08.670 --> 15:16.850
Furthermore, most of the C sharp bypasses, or some of the, most of the WDAC bypasses are in C sharp anyway, so that kind of like checked that flag off for us.

15:17.030 --> 15:31.210
And then in order to make things kind of easier for all of our red team friends to use, particularly on Windows environments, we wanted to make sure that they could, that they could use it in C sharp as like kind of the direction that, uh, malware authors in Windows are kind of going for red team engagements these days,

15:31.210 --> 15:32.390
or, or going.

15:33.190 --> 15:37.150
Um, but there's reference code for both on the repo which we'll showcase later after the talk.

15:38.030 --> 15:44.370
So essentially the steps for writing a UEFI variable in Windows is really easy once you have that admin privilege.

15:44.370 --> 15:48.490
Uh, you essentially just need to obtain the SE system environment name with set priv.

15:48.610 --> 15:51.950
Uh, this is the only case of like P invoke that we're going to be using.

15:52.070 --> 16:01.530
Um, furthermore, like I was saying, like in the manifest where you needed read and write capabilities, the MSDN article is weird in that it lists all of those things for C plus plus applications.

16:01.530 --> 16:10.390
It makes no notion of ever doing this stuff in C sharp, so I've never had to declare those things and I don't really know what Microsoft is stating in that, so just ignore that completely.

16:10.390 --> 16:11.910
You don't need it for C sharp.

16:12.390 --> 16:19.850
Uh, you can then get the address of your pin buffer, so that's our payload, and then we just write the UEFI variable to NVRAM and now it's persistent storage.

16:21.110 --> 16:24.210
So here's some code really quickly to set the privilege.

16:24.410 --> 16:31.670
Um, it's just P invokes, you get process, you say that you want the new, the new token privilege, you set it, boom, we're good.

16:31.910 --> 16:36.750
Then you can get the address of your, uh, pin buffer in C sharp, like I said, this was your payload.

16:36.790 --> 16:44.970
So you initialize an end pointer, you call, uh, interop services to get a pinned array of your, of your buffer that you want to write.

16:45.190 --> 16:50.070
You pin it so the garbage collector and nothing can, can touch it as you're working with it.

16:50.070 --> 16:58.150
And then you just simply write that UEFI variable with the set firmware variable call with, uh, the tuple, and in this case it's going to be C sharp UEFI.

16:58.190 --> 17:08.590
And then I have a super secret, uh, super secret GWT, uh, super secret GWT, say that five times fast, um, that you can Google and figure out what it is.

17:09.550 --> 17:13.030
Uh, so the steps for executing UEFI variable are pretty much similar.

17:13.030 --> 17:14.430
You still need that token.

17:14.550 --> 17:21.430
And the first thing I did in C sharp was I did P invoke with virtual alloc to obtain an RWX memory pointer that I can execute.

17:21.430 --> 17:26.030
And then I was just obtaining that UEFI variable back into that buffer so I can execute it.

17:26.250 --> 17:29.670
Uh, so the first step, same idea, you need that privilege.

17:30.190 --> 17:34.310
The second step is I start P invoking some memory so I have RWX.

17:34.970 --> 17:43.970
Uh, but you can't actually really do that in C sharp because it's abnormal to bring things into your import address table that aren't actually C sharp specific.

17:44.370 --> 17:49.230
Um, so like all of the virtual calls are more suspicious than getting a new process token.

17:49.290 --> 17:52.850
Cause, uh , within like C sharp there's no real way to do like process token stuff.

17:52.850 --> 17:55.990
You have to pretty much P invoke so it's not suspicious.

17:56.350 --> 18:03.310
It is suspicious for EDR products that you're doing virtual alloc, virtual free and virtual protect within C sharp.

18:03.310 --> 18:05.210
It's like, whoa, stop right there.

18:05.210 --> 18:07.970
We're going to tell the blue team about this and they're going to hunt you down.

18:08.050 --> 18:10.090
So we can't do that.

18:10.750 --> 18:23.550
Hilariously enough as we were going through this research, um, OJ is working on like a, a C sharp C alarm interpreter and he was dealing with some stuff and he also says the same thing like don't P invoke your dot net apps.

18:23.550 --> 18:25.250
Like EDR is going to find you.

18:25.250 --> 18:28.710
Like as he says, it's the proverbial solution for them hunting you down.

18:29.050 --> 18:34.510
Uh, so we're, we're not going to have, we're going to lose the ability to P invoke to get RWX memory.

18:34.630 --> 18:36.610
Uh, which is kind of a problem.

18:37.610 --> 18:44.170
So we can't do step 2 anymore, but fear not, uh, the CLR and C sharp is fantastic for malware.

18:44.170 --> 18:59.910
So we're going to actually just now instead of doing any virtual calls, we're going to use reflection within C sharp to obtain RWX JIT memory, which just in time compilation leaves RWX memory pages if you're not familiar with it, to read the UEFI variable into that.

18:59.910 --> 19:07.570
Then we're going to write the UEFI variable into a method table pointer and then we're going to execute the method as if nothing actually ever happened.

19:08.290 --> 19:10.090
Uh, so those are the steps.

19:10.090 --> 19:13.410
I'm going to actually go through that in detail because that was probably a little bit jarring.

19:13.970 --> 19:28.330
Basically, in C sharp, if you're not familiar with it, because it's an intermediate level, uh, language representation of code, it has to get just in time compiled to assembly code before it gets executed by the processor.

19:28.470 --> 19:38.430
So within C sharp there's this huge method table that contains all of the methods that the C sharp application knows about and all of those contain a JIT stub for those classes methods.

19:38.650 --> 19:52.850
So essentially what that means is at the time of just in time compilation, the method table gets referenced, you then get a function pointer to the executable assembly code that the processor will run, which is RWX due to the notion of JIT.

19:52.930 --> 20:02.470
You can grab that method pointer, dereference the function pointer that the assembly code lives to, which is, uh, just the location of the method that you're clobbering and overwrite it.

20:02.470 --> 20:10.630
So this essentially means we can declare a method that we don't care about, force it to just in time compile, get the pointer to it and then overwrite it.

20:11.110 --> 20:16.250
Uh, so it's basically like red tulip C but in C sharp and it's like more fucky.

20:18.530 --> 20:20.250
So the steps for that look like this.

20:20.250 --> 20:24.810
We're essentially going to now obtain an RWX JIT memory page to read the variable into.

20:24.810 --> 20:33.890
That's going to consist of defining a method, uh, to overwrite, JITing the method, obtaining the pointer to the method and then overwriting it and calling it.

20:34.230 --> 20:36.050
So we'll define a method to overwrite.

20:36.050 --> 20:38.430
This is in the code that I'm going to be releasing.

20:38.430 --> 20:39.910
It's just called overwrite me.

20:39.910 --> 20:41.050
It does nothing.

20:41.950 --> 20:43.470
We'll JIT the method.

20:43.490 --> 20:47.710
So here you can see in reflection I'm doing a type of the program I'm in.

20:47.710 --> 20:49.310
Get method overwrite me.

20:49.370 --> 20:55.310
I call compile service run time helpers prepare method which is essentially just going to JIT that with the method handle.

20:55.310 --> 20:56.890
So I have my method dot method handle.

20:56.890 --> 20:58.790
That's dereferencing one of the pointers.

20:59.030 --> 21:03.430
And then I obtain the pointer to the method which is just get function pointer once I've JITed it.

21:03.430 --> 21:09.270
So now I have the location of the raw assembly code after JIT and that RWX memory location.

21:10.110 --> 21:16.530
So now I write the UEFI variable payload that's stored in NVRAM into the pointer to method.

21:16.530 --> 21:18.850
So I just call get firmware variable EX.

21:19.090 --> 21:25.350
Uh, you can see the third argument there after the tuple is pointer to method with then the fourth argument being buffer length.

21:25.350 --> 21:33.790
That's going to take the NVRAM out, plop it in and then I can just execute the method called overwrite me as if it was actual C sharp code and I hadn't done anything malice.

21:34.770 --> 21:40.090
So we're going to do a quick demo of what that looks like to kind of tie it all together in Windows.

21:40.390 --> 21:43.910
Um, step one, you obtain your, you obtain your shell on target.

21:43.910 --> 21:46.490
Uh, we've already done that so step one's kind of skipped.

21:46.570 --> 21:49.390
We're then going to run write UEFI C sharp.

21:49.390 --> 21:52.450
You'll see this with a, with a writer binary that I've written.

21:52.510 --> 21:57.990
Uh, in an actual like red team engagement or in a campaign you'd probably do this with like whatever C2 framework you were using.

21:57.990 --> 22:03.050
So you can use the C sharp code say like in cobalt strike with some of the functionality there and do it on Windows boxes.

22:03.250 --> 22:10.970
Um, you'll then do some sort of persistence mechanism for the reader binary which is going to go through and do the steps I just demonstrated with reflection.

22:11.230 --> 22:14.390
Um, it's like a 4 kilobyte binary you'll use for persistence.

22:14.390 --> 22:16.770
You can, you know, we're not giving you a persistent mechanism.

22:16.770 --> 22:18.590
I'm sure all of you have lots in your bag.

22:18.610 --> 22:21.910
Uh, you just need to throw this binary somewhere and, and run it.

22:22.190 --> 22:25.270
And then we'll uh, we'll run it to showcase what it looks like.

22:25.690 --> 22:33.550
So, the Windows demo is this one.

22:34.210 --> 22:35.570
Computers are hard.

22:35.850 --> 22:38.050
So here I am on Windows.

22:38.130 --> 22:42.310
Um, I'm going to first go through and run a really quick chipsec module.

22:42.310 --> 22:49.530
Uh, if you're not familiar with chipsec, it's a UEFI platform security tool that helps security researchers analyze platform firmware.

22:49.590 --> 22:53.450
Uh, it does a lot of cool things for UEFI, particularly variables.

22:53.450 --> 22:59.330
So what I did here is I just ran a module to dump and list what all the UEFI variables currently on my system are.

22:59.330 --> 23:01.070
You can see that there's a lot of them.

23:01.070 --> 23:04.270
Do note that most of these are NVBS plus RT.

23:04.530 --> 23:09.030
Uh, so most of them are accessible, uh, at run time services to the operating system.

23:09.030 --> 23:12.890
And they're, of course, because they're persistent, they're persistent in NVRAM.

23:13.970 --> 23:14.970
So there they are.

23:14.970 --> 23:16.190
You didn't see mine.

23:16.210 --> 23:21.490
Here I'm going to dump really quickly the variable list to show you that there's contents of all of these variables.

23:21.490 --> 23:24.830
Like this one is kind of funny, like test zero, this is a test.

23:25.670 --> 23:27.850
Um, so there's lots of variables here.

23:27.870 --> 23:29.550
Nobody really ever audits them.

23:29.550 --> 23:31.790
Like I said, AV and EDR doesn't look here.

23:31.930 --> 23:36.350
So now what I'm going to do is I'm going to run write UEFI or UEFI write C sharp.

23:36.350 --> 23:39.070
That's going to write a UEFI variable to NVRAM.

23:39.130 --> 23:41.790
I ran chipsec again to show you that it's now there.

23:41.830 --> 23:42.550
There it is.

23:42.550 --> 23:44.490
Uh, C sharp dash UEFI.

23:46.550 --> 23:50.790
So now that that's there on box, I can execute what the payload is.

23:50.990 --> 23:55.970
Um, but first I'm going to show you what that, uh, there's actual like, uh, shellcode there.

23:55.970 --> 23:59.090
So I'll go into the UEFI variables directory with chipsec.

23:59.090 --> 24:00.130
I'll dump it out.

24:00.130 --> 24:06.450
And there you can see that I have some shellcode there that I'm going to execute out of NVRAM with a, with a, the, the reader binary.

24:06.610 --> 24:11.510
Uh, that payload for demo purposes is going to be our, our favorite demo, uh, Metasploit.

24:11.570 --> 24:14.230
So it's just a meterpreter shell that I'm going to spin up.

24:14.230 --> 24:17.070
I'm going to go through, run UEFI read C sharp.

24:17.210 --> 24:24.930
And then as you can see from that, uh, I successfully just executed a payload out of NVRAM with like a four kilobyte binary using reflection.

24:28.310 --> 24:29.350
Thank you.

24:30.650 --> 24:32.550
So the fun doesn't actually end there.

24:32.550 --> 24:39.250
So because this is a persistence mechanism and it's persistent, uh, in NVRAM, this means it's going to survive reboots.

24:39.250 --> 24:42.270
It's going to survive reinstalling your operating system.

24:42.270 --> 24:52.490
The only way to clear this out is to like clobber over that variable or, uh, pull NVRAM with like a deady prog and re, uh, like rewrite your UEFI, um, variable space.

24:52.610 --> 24:59.350
So I'm going to shut down the box, reboot it, go back to my Metasploit shell, uh, rerun the console.

24:59.710 --> 25:01.070
And then it's a cooking show.

25:01.070 --> 25:02.810
It takes a long time for Windows to boot.

25:02.810 --> 25:03.990
So speed it up.

25:03.990 --> 25:06.010
Uh, you know, I just put the payload in the oven.

25:06.130 --> 25:07.770
It's going to be done pretty quickly.

25:07.890 --> 25:09.310
The machine's booting.

25:11.590 --> 25:12.810
Still booting.

25:12.810 --> 25:13.850
It's a cooking show.

25:13.850 --> 25:14.710
Wait a minute.

25:15.210 --> 25:16.290
There it is.

25:16.310 --> 25:17.250
Let's see.

25:17.290 --> 25:17.950
And there we go.

25:17.950 --> 25:23.910
I just executed my payload out of NVRAM again, uh, with a persistence mechanism out of a UEFI variable.

25:27.800 --> 25:29.140
Yay, cookies.

25:29.880 --> 25:30.840
And shells.

25:30.840 --> 25:32.300
It, uh, it baked some shells.

25:32.300 --> 25:32.880
Awesome.

25:34.060 --> 25:36.840
Um, so we kind of like have hand-waved the persistence thing.

25:36.840 --> 25:38.940
We're going to leave that as an exercise up to the reader.

25:38.940 --> 25:41.940
Like I said, WDAC bypasses are a great way to do this.

25:42.000 --> 25:45.080
Uh, in actuality, uh, your payload's a UEFI variable.

25:45.080 --> 25:46.180
Like, good luck, have fun.

25:46.500 --> 25:48.060
Analysts, uh, we love you still though.

25:48.060 --> 25:50.120
Like, we're going to help you, but this is fun.

25:51.040 --> 25:53.240
Um, so like what about Windows EDR products?

25:53.240 --> 25:54.620
We haven't necessarily touched on that.

25:54.620 --> 25:57.620
Like, obviously this is a way to, to mitigate detection.

25:57.680 --> 26:09.080
Um, so we looked at a couple of, uh, EDR vendors and we found no relevant information pertaining to the usage of either these API calls, executing out of UEFI variable or anything of that nature.

26:09.160 --> 26:12.820
The only thing they're really going to see is that you're executing this binary.

26:12.980 --> 26:15.920
Uh, but like there's binaries executed on systems all the time.

26:15.920 --> 26:19.920
That's not really something too relevant, too relevant that's going to trigger hunt.

26:20.940 --> 26:27.260
Um, furthermore, uh, there's a lot of ways currently to sinkhole or to tamper with EDR products.

26:27.260 --> 26:31.600
So here's like a five line PowerShell script that you can use to like sinkhole EDR products.

26:31.600 --> 26:33.300
This works on a lot of them.

26:33.300 --> 26:37.420
Uh, like EDR products are things of software running on a box.

26:37.420 --> 26:39.500
Software have configs.

26:39.500 --> 26:40.980
Configs can be tampered with.

26:40.980 --> 26:45.120
So just tamper with configs a lot of the times and you can get away with anything on a box on Windows.

26:45.400 --> 26:47.500
Um, there's a lot of other ways to go about it.

26:47.500 --> 26:49.480
We can chat like after the talk about it.

26:49.480 --> 26:50.980
Uh, this isn't really a talk about this.

26:50.980 --> 26:54.280
So it's a talk about hiding your shit and that's how you hide your shit in Windows.

26:54.920 --> 26:57.460
Um, some WDAC bypasses just for references.

26:57.640 --> 27:02.280
Uh, now that I've talked about hiding your shit in Windows, uh, Mike's going to talk about some Linux stuff.

27:03.920 --> 27:05.320
Boy, Windows is silly.

27:07.260 --> 27:08.940
Let's, let's, let's talk about Linux.

27:08.940 --> 27:11.860
Linux is, you know, everyone knows that's where the real loot is.

27:13.960 --> 27:16.740
So, let's talk about the problem space.

27:16.740 --> 27:19.380
Uh, basically, let's introduce our players here.

27:19.380 --> 27:20.900
We have, you know, the kernel.

27:21.220 --> 27:22.360
We have the EDR.

27:22.420 --> 27:24.860
And we have, on the right, we have your sample.

27:25.000 --> 27:29.780
And, you know, EDR is looking at your sample and that's, that's bad.

27:29.780 --> 27:32.340
That's what makes it your sample and not your payload.

27:32.860 --> 27:37.320
Um, and, you know, the EDR and your sample are actually kind of peers, right?

27:37.320 --> 27:45.580
We're both running as privileged processes and the EDR has some hooks into kernel space to help it do, help it do its job.

27:45.580 --> 27:49.840
And so that's what that sort of rectangle just above the eyeballs is.

27:50.140 --> 27:52.080
Eyeballs are obviously EDR.

27:53.780 --> 27:57.160
And so, like, what does our solution space look like?

27:57.160 --> 28:08.200
Well, you know, what we really want is just to make, you know, just to sucker punch the EDR a little bit, you know, while it's not looking and make sure that it just doesn't look at us at all.

28:08.200 --> 28:10.800
And then, then it's back to being our payload.

28:11.160 --> 28:14.220
So, you know, how are we going to do that?

28:14.980 --> 28:19.560
We, we need to, like, we need to show up early to the fight, right?

28:19.660 --> 28:21.800
So that it never sees us coming.

28:22.140 --> 28:24.020
So we need to infect something.

28:24.520 --> 28:28.020
So, you know, how does your computer, how does your computer boot?

28:28.280 --> 28:29.560
And what can we infect?

28:29.900 --> 28:32.580
Well, the first thing that boots is platform firmware.

28:32.760 --> 28:34.720
And that's signed by the OEM.

28:34.720 --> 28:36.580
You can't really infect that easily.

28:36.580 --> 28:37.140
Boo.

28:37.340 --> 28:43.480
The next thing, that's signed by Microsoft, the shim, that's signed by Microsoft and it pivots the key over to the distro.

28:43.980 --> 28:46.140
That's a little bit harder to infect.

28:46.780 --> 28:51.180
Uh, grub, you know, signed by the distro, no good.

28:51.180 --> 28:53.620
Kernel signed by the distro, no good.

28:54.040 --> 28:58.020
But the RAM disk is generated on system and not signed.

28:58.080 --> 28:59.680
This sounds like a good time.

29:00.800 --> 29:05.340
And then sometime later, some shit happens and the EDR is, is started.

29:05.460 --> 29:08.040
So obviously what we need to infect is the RAM disk.

29:08.040 --> 29:16.920
So how are we gonna, what capabilities do we have, what, what, what, what tools do we have at our disposal in the Linux environment to, to make things happen and, and, and make the EDR not look at us.

29:16.920 --> 29:23.240
So, uh, the first sort of, uh, wonderful syscall to, uh, introduce is ptrace, right?

29:23.320 --> 29:25.760
And this is, you know, why we say the 90s are back again.

29:25.760 --> 29:31.520
Like ptrace, uh, exploitation of processes has been like, uh, as, as old as time itself.

29:31.520 --> 29:38.860
But, you know, and, and it's, it's tapered off in the, in the modern era because we have policies that prevent you from doing it.

29:39.040 --> 29:44.560
We have like Yama and SE Linux and AppArmor and silly stuff like Smack and Tomoyo and whatever.

29:44.720 --> 29:50.020
But the best part about all this stuff is the policy is implied in, is applied in user space.

29:50.540 --> 29:51.500
Alrighty.

29:53.340 --> 30:01.020
So let's, let's, let's go through this, um, let's go through this in flow chart sort of land.

30:01.020 --> 30:05.800
So we have, um, the RAM disk is actually the original PID 1.

30:05.800 --> 30:10.500
That's actually where, uh, init starts from.

30:10.880 --> 30:17.980
And then it finds your file system, you know, draws some pretty stuff on screen, like make sure you have the right fonts, whatever.

30:18.480 --> 30:26.860
And then it does, it actually deletes everything out of the, out of the root file system except for target directory.

30:26.860 --> 30:31.920
And then it moves the mount from the target to root.

30:32.020 --> 30:34.740
And then it execs systemd.

30:35.800 --> 30:39.060
And that will come up again, this sort of deleting everything.

30:39.060 --> 30:45.460
And then like systemd starts and like, you know, the thumbs down is the policy being loaded that prevents you from attacking the EDR.

30:45.460 --> 30:47.460
And then of course our eyeballs here are the EDR.

30:47.740 --> 30:49.760
So let's, let's talk about some other things.

30:49.760 --> 30:50.820
We have FANotify.

30:50.840 --> 30:55.660
FANotify is kind of a obscure API, but like it's designed for AV.

30:55.780 --> 30:59.620
I don't think any AV actually uses it, but, you know, who cares?

31:00.120 --> 31:05.520
Exploiting, or using security APIs for unintended things is like one of my favorite things.

31:06.760 --> 31:13.380
So basically what this lets you do is this lets you, you know, do the AV thing, right?

31:13.380 --> 31:28.660
Like a file is accessed, you get to stop that process from accessing that file, decide whether it's okay, and then you can say, if it is, to go ahead, which effectively allows us to inhibit startup of other processes.

31:30.400 --> 31:34.120
Another fantastic utility is memfd create.

31:34.940 --> 31:57.660
This has been talked about a lot in, in, in the hacker scene, but essentially, like, you can create an anonymous file, and this works like a file, get a file descriptor, and then you can actually access it through, you know, PROC PID, FD, even from other processes.

31:57.660 --> 31:58.960
This is fantastic.

31:59.120 --> 32:03.840
And, you know, the best part is, like everyone says, never touch disk, kids.

32:05.220 --> 32:15.500
And then another API that we can use is and this is also somewhat obscure and not really security relevant, is a PRCTL, PR set timer.

32:15.500 --> 32:25.540
So we need some marker for our process to say to the EDR, don't look at this.

32:25.640 --> 32:28.460
And so we need something that's inheritable, right?

32:28.460 --> 32:36.160
So, you know, you can, you can have your malicious shell, you can catch shadow, and when cat does, cat also inherits the marker.

32:36.320 --> 32:45.800
So we do the set timer slack, this basically controls how often you wake up the CPU, it's designed to save power, but I don't care about that.

32:47.140 --> 33:00.560
And then lastly, like, config EFI virus, this is the kernel config to make the EFI virus file system, you saw what a pain in the ass it was to do stuff with UEFI on Windows, Windows is dumb, it's just a file system, you just read and write files, it's super easy,

33:00.560 --> 33:01.760
you can do it from a shell script.

33:04.280 --> 33:13.200
And then I talked previously about MS move, like, basically, this, if you look in the code, this is labeled as black magic fuckery.

33:14.580 --> 33:40.920
I can go through these steps, but it's really convoluted, but essentially, if you want to have a malicious process that survives pivoting the root file system out from under you, there's a whole lot of really weird stuff involving containers and cheroots and namespaces and weird stuff to do so that your malicious process sees the real root file system as opposed to seeing the init root file system,

33:40.920 --> 33:42.400
which has nothing in it.

33:43.380 --> 33:56.900
Funny story, like, even though you can never have two root file systems in Linux, if you don't do this, you have two root file systems in that process, and the real one and the init one, and nothing is there, it's, like, really messed up.

33:57.980 --> 34:01.900
So, anyway, let's go through how this works in practice.

34:02.140 --> 34:08.320
So, our little devil emoji here, I like emojis, is our malicious demon.

34:08.320 --> 34:10.800
This is effectively stage one.

34:11.680 --> 34:17.880
We, in the init script, in the ramfs, forks and execs that.

34:18.020 --> 34:25.700
We open the EFI vars, we actually mount the EFI vars file system and mount proc and all that.

34:25.760 --> 34:31.840
And we fetch it out of the, we fetch stage 2 and 3 out of UEFI land.

34:32.760 --> 34:42.000
And then we just kind of stay there and we cross that boundary between init ramfs land and, you know, the real system land.

34:42.160 --> 34:47.700
And that execs, you know, our friend system D, which then spawns all kinds of other garbage.

34:48.100 --> 34:55.680
And when it spawns the policy load, which we detect through FA notify, we give a stop signal to sysctl.

34:55.800 --> 35:00.540
Sysctl is going to apply the policy that says you cannot p-trace.

35:00.780 --> 35:03.080
And there's our EDR over there.

35:03.760 --> 35:05.860
I think you can figure out the next step.

35:06.180 --> 35:11.240
We're going to p-trace the EDR and then, like, have our way with it.

35:13.180 --> 35:18.720
So, what p-trace allows us to do is, basically, we stop the process.

35:18.720 --> 35:26.680
You can see we probably end up stopping it right after or before a syscall.

35:26.680 --> 35:32.240
And we can just back up, we can just back up to the syscall.

35:32.240 --> 35:35.160
We can control the IP and back up to the syscall.

35:35.180 --> 35:39.640
And then we can just set EAX and set what syscalls we'd like to make.

35:39.640 --> 35:43.240
So, we're effectively coercing syscalls into the process.

35:43.540 --> 35:45.640
So, we can call memfd create.

35:46.000 --> 35:59.880
Then in our other process, because we can access proc FD, proc paid FD, we can shove stage 3 in there, which is embedded in stage 2, which, by the way, never touched disk.

36:00.420 --> 36:04.060
And then we can do an mmap.

36:04.060 --> 36:09.960
Fortunately, unlike in Windows, mmapping rewrite execute pages is like totally normal.

36:09.960 --> 36:11.480
Lib C does it all the time.

36:12.080 --> 36:14.740
And then we can just put our shellcode in there.

36:16.420 --> 36:18.920
And then we set, oop, I went too fast.

36:18.920 --> 36:22.100
Then we set our EIP to the slash of the slide there.

36:22.280 --> 36:24.300
And we actually just jump over.

36:25.320 --> 36:30.100
And then we effectively return to DL open as

36:33.820 --> 36:35.380
we learned yesterday.

36:35.380 --> 36:40.300
And as I kind of already knew, like, I'm sorry, I forgot the speaker's name.

36:40.300 --> 36:41.920
We talked about it yesterday.

36:42.560 --> 36:43.660
It's on my note card.

36:44.340 --> 36:45.740
I'm out of sync.

36:45.940 --> 36:46.640
Anyway.

36:49.160 --> 36:52.300
So, Lib C has an internal DL open.

36:52.300 --> 36:57.020
We can do the old school LD preload trick except for without LD preloading.

36:57.020 --> 37:01.880
We can call the internal DL open and then we can have our malicious SO.

37:02.060 --> 37:05.320
And that malicious SO can clobber whatever we need to clobber.

37:05.940 --> 37:07.080
And then we return.

37:07.080 --> 37:08.000
All right.

37:08.200 --> 37:17.500
So now, we can send the continue to our policy load and load the actual policy that prevents us for doing this.

37:17.960 --> 37:21.720
And our EDR is actually now looking the other way.

37:21.780 --> 37:38.000
So, basically, if you look at the code and you see our payload, and this is sort of a point that also touched on, that you don't want to, there's two options here about clobbering the EDR, either the input stage or the output stage.

37:38.000 --> 37:39.200
And the input stage is complicated.

37:39.200 --> 37:42.620
You have to understand how it processes information from the kernel.

37:42.620 --> 37:44.000
The output stage is super simple.

37:44.000 --> 37:45.320
You've already looked at the logs.

37:45.320 --> 37:46.360
You know what they say.

37:46.480 --> 37:53.360
You just want to, you know, compromise its ability to write things to the output log or things you don't want to the output log.

37:53.420 --> 37:56.420
And then there's our malicious process and everybody's happy.

37:56.420 --> 37:58.700
The EDR is looking away and we can plunder away.

37:59.280 --> 38:01.380
So, let's do a little demo.

38:02.660 --> 38:07.080
What I'm going to do is we're going to tune up AuditD.

38:07.080 --> 38:08.980
AuditD is our example EDR.

38:09.340 --> 38:15.740
You know, I know that AuditD is not a commercial EDR vendor and you're wondering, does this work on commercial EDR vendors?

38:15.740 --> 38:17.000
Yeah, probably.

38:19.620 --> 38:22.080
And we'll install our implant.

38:22.080 --> 38:22.760
We'll reboot.

38:22.760 --> 38:23.920
We'll set the marker.

38:24.440 --> 38:28.000
We'll do the exploit again and we'll show that we're invisible.

38:28.680 --> 38:30.100
All right, let's do the demo.

38:30.520 --> 38:31.160
Okay.

38:31.240 --> 38:32.980
Oh, God, how do you do this?

38:33.460 --> 38:34.580
Windows is hard.

38:40.320 --> 38:41.180
Oh, God.

38:43.420 --> 38:44.180
Do it.

38:44.180 --> 38:44.760
Okay.

38:45.200 --> 38:46.200
Oh, God, what did I do?

38:46.200 --> 38:47.060
Oh, God!

38:47.060 --> 38:47.060
Oh, God!

38:49.760 --> 38:51.400
I know how to use Windows.

38:53.300 --> 38:55.100
This Windows shit is complicated.

38:55.980 --> 38:57.240
All right, here we go.

38:57.500 --> 38:59.580
We got the analyst on the right.

38:59.580 --> 39:01.180
We got the hacker on the left.

39:02.140 --> 39:07.480
And what we're going to do is the analyst is going to turn on the audit rules.

39:07.480 --> 39:12.320
He's going to tune up audit so that it just has every exec.

39:12.620 --> 39:14.800
Then we're going to tailor the audit log.

39:14.800 --> 39:16.540
We're going to exploit the enterprise tool.

39:16.540 --> 39:17.300
You can see we're root.

39:17.300 --> 39:18.140
We're making all this noise.

39:18.140 --> 39:18.900
It's terrible.

39:19.460 --> 39:21.260
You know, they're going to roll this up.

39:23.180 --> 39:25.180
You can see it on the right, all that noise.

39:25.180 --> 39:26.800
Then we're going to run our infector binary.

39:26.800 --> 39:29.180
Our infector binary is going to make a whole lot of noise.

39:29.420 --> 39:35.560
But this noise is actually really normal because systems generate initram fs's all the time.

39:35.560 --> 39:36.740
So it's fine.

39:37.260 --> 39:45.780
So it's going to make basically all the noise that it makes on an initram fs update.

39:45.800 --> 39:51.900
This is kind of a lot of reused harness from my horse pill talk from a few years ago.

39:52.440 --> 39:54.640
But, you know, it's as true today as it was there.

39:55.260 --> 39:56.160
Everything's infected.

39:56.160 --> 39:57.220
Have a nice day.

39:58.620 --> 40:00.220
And then we're going to reboot.

40:01.480 --> 40:03.180
Let's do some cooking show time.

40:03.180 --> 40:06.700
Let's see if I edited this video well enough.

40:07.420 --> 40:08.560
Here we are.

40:08.620 --> 40:09.380
Okay.

40:11.700 --> 40:13.640
I'll edit it tighter next time.

40:14.940 --> 40:15.660
Okay.

40:15.660 --> 40:15.780
And we're going to reboot.

40:15.800 --> 40:17.220
Again, we've tuned up audit.

40:17.220 --> 40:21.540
And you can see we're displaying the audit log there.

40:24.020 --> 40:24.580
Let's see.

40:24.580 --> 40:26.820
Make a little space there.

40:28.440 --> 40:29.160
Okay.

40:30.080 --> 40:32.120
And then we're going to do the same thing.

40:32.840 --> 40:34.740
Actually, we're going to set our marker first.

40:34.740 --> 40:36.460
And that's going to make a little bit of noise.

40:36.640 --> 40:39.960
But once you set the timer slack, that's what the PRCTL call is.

40:39.960 --> 40:42.940
You can see the marker is set.

40:42.940 --> 40:46.440
And you can also see that there's no noise in the audit log.

40:47.160 --> 40:49.260
And then I game root again.

40:49.680 --> 40:51.900
And you can see, again, no noise.

40:52.460 --> 40:53.760
We're invisible.

40:54.360 --> 40:57.480
We can do all those nasty things we did before.

40:58.140 --> 40:59.040
Invisible.

40:59.360 --> 41:00.080
It's awesome.

41:00.080 --> 41:00.860
Ta-da!

41:02.880 --> 41:09.280
And then we can show the policy as applied.

41:09.280 --> 41:13.440
You can see YAML mode 3 means P trace is completely disabled in the system.

41:13.440 --> 41:14.260
And that is true.

41:14.260 --> 41:16.700
P trace is now completely disabled in the system.

41:16.700 --> 41:20.280
But we inhibited the policy load that prevented us from doing that.

41:21.360 --> 41:24.860
And then, like I said, everything is a file system.

41:24.860 --> 41:26.420
Or everything is a file in Linux.

41:26.440 --> 41:32.020
If you look somewhere in there, there should be a lol key.

41:32.020 --> 41:33.060
Yeah, there it is.

41:33.300 --> 41:34.500
Yeah, right around there.

41:35.640 --> 41:36.980
Because hacking is funny.

41:37.380 --> 41:38.240
And then, ta-da!

41:38.240 --> 41:39.140
We did it.

41:39.260 --> 41:40.900
How do we get back to the slides?

41:41.740 --> 41:42.520
Okay.

41:47.040 --> 41:48.240
Thank you.

41:48.640 --> 41:55.180
And, you know, everyone on a Saturday morning at DEF CON is always thinking to themselves, what does this all mean?

41:56.960 --> 42:00.700
You know, we just want to bring happiness to everyone.

42:02.420 --> 42:04.480
Everyone is going to sleep well tonight.

42:04.480 --> 42:06.440
This is the net happiness increase.

42:06.440 --> 42:07.540
You're happy.

42:07.840 --> 42:09.180
The analyst is happy.

42:09.180 --> 42:13.940
That payload that you spent months working on is still your payload and not their sample.

42:14.240 --> 42:15.560
Everything is good.

42:15.700 --> 42:16.600
That's what we're all about.

42:16.600 --> 42:18.280
Bringing happiness to the world.

42:20.440 --> 42:21.200
All right.

42:21.200 --> 42:23.880
I don't really care about mitigation, so I'm going to have Topher talk about that.

42:23.980 --> 42:26.820
I mean, I don't really care either, but we felt it necessary.

42:27.300 --> 42:29.960
There's a couple of things that you can do to mitigate this.

42:29.960 --> 42:37.220
Like, the one biggest thing is, because we're utilizing UEFI variables, is to actually monitor and audit those against your organization's fleet.

42:37.220 --> 42:41.200
That would be like the first step to sort of mitigating these risks that we've presented.

42:41.460 --> 42:51.340
Um, furthermore, EDR vendors, if any of you are out there, you should be detecting UEFI APIs and this functionality in Windows and in Linux spaces if you happen to be doing, like, Linux EDR.

42:51.460 --> 42:55.900
Um, it's not really common for applications to set and get firmware variables.

42:55.940 --> 43:03.440
Um, and furthermore, like, after the installation of a platform, uh, NVBS and RT variables being set is pretty weird.

43:03.440 --> 43:05.640
Uh, I've never actually seen that in practice.

43:05.640 --> 43:10.820
If you have seen that in practice, come talk to me about it, because I'd like to know where, because I want to abuse it.

43:12.060 --> 43:16.940
Um, furthermore, as we kind of showcase, EDR tamper resistance is not at all effective.

43:17.120 --> 43:21.300
Uh, it's very easy to, like, sinkhole, uh, the sensor, kill the sensor.

43:21.400 --> 43:24.700
As Mike showed, it's very easy to p-trace the sensor.

43:24.900 --> 43:30.440
Um, so vendors really just need to work on securing their, uh, agents and their processes a little bit better.

43:30.460 --> 43:37.160
Um, furthermore, uh, Mike kind of said this in his horse talk at Black Hat a few years ago, but assembling RAM disks on systems is just silly.

43:37.600 --> 43:39.600
Stop doing that if you're a Linux distro.

43:41.440 --> 43:45.100
Um, so, like, as far as closing the rest goes, we have some future work.

43:46.220 --> 43:55.940
So, you know, the system firmware is, uh, a great, a great place to hide and there's all kinds of goodies in there and we are just touching the surface of it.

43:56.080 --> 44:07.240
And it's interesting, like, as we were doing this research, a lot of companies started announcing that they are going to start looking at the firmware space as a place to hunt.

44:07.980 --> 44:14.080
But, you know, this is a cat and mouse game and, uh, as far as I can tell, the, uh, are we the mouse or are we the cat?

44:14.840 --> 44:17.260
Anyway, one of us is already ahead.

44:19.920 --> 44:21.040
And I think it's us.

44:21.040 --> 44:22.800
I'm not sure if we're the cat or the mouse.

44:23.960 --> 44:24.680
Alright.

44:25.200 --> 44:28.420
So, like, in closing, we're bringing net happiness to everybody.

44:28.420 --> 44:30.720
We're going to have ourselves a UEFI dot party.

44:30.720 --> 44:31.980
We're plundering away our loot.

44:31.980 --> 44:34.040
We're sucker punching that pesky EDR.

44:34.340 --> 44:41.540
Um, and all of our code is located on this GitHub link, uh, perturbed platypus or, you know, as we like to call ourselves, APTPP.

44:43.640 --> 44:45.480
Uh, we, we just pushed the code.

44:45.480 --> 44:46.260
We just confirmed it.

44:46.260 --> 44:50.680
We had a, we had a timer on a box that pushed it exactly 1045.

44:50.680 --> 44:51.680
Uh, it's live.

44:51.680 --> 44:53.420
So, go, go have at it.

44:53.420 --> 44:54.440
Plunder away.

44:54.460 --> 44:56.560
Uh, here's some references that you can look at.

44:56.560 --> 44:58.480
Uh, that, that's all we got for you.

