WEBVTT

00:00.000 --> 00:03.640
Without further ado, this is Elvis Cayado.

00:03.740 --> 00:09.260
He's going to be presenting on some really cool research that he manipulated.

00:10.080 --> 00:10.900
Yeah, sure.

00:10.900 --> 00:11.220
All right.

00:11.220 --> 00:11.680
Awesome.

00:11.680 --> 00:12.860
Thank you so much for joining us.

00:12.860 --> 00:14.000
And here we go.

00:17.720 --> 00:18.460
Test.

00:18.460 --> 00:19.120
Is that good?

00:19.120 --> 00:19.500
All right.

00:20.640 --> 00:22.740
Thank you everyone and welcome for coming.

00:22.740 --> 00:25.860
This is my talk called green waves and ham.

00:26.820 --> 00:27.460
All right.

00:27.460 --> 00:28.080
Let's get started.

00:28.080 --> 00:31.760
So this device up here that you see is called the green wave G1100.

00:31.840 --> 00:34.660
It was distributed by Verizon Fios and Frontier.

00:34.660 --> 00:36.620
They're an ISP up in the northeast.

00:36.720 --> 00:38.920
And we have Verizon for the file service.

00:38.920 --> 00:42.120
It was not available in my area, but this is what they gave you.

00:42.940 --> 00:45.460
So if we look a little there, we got our FCC ID.

00:45.460 --> 00:47.860
So what do we do with our FCC ID?

00:47.940 --> 00:54.040
We go online and we find the internal photos and then we find the processor and we look it up.

00:54.040 --> 00:57.900
There's no data sheet for that, unfortunately, but we see the shield is on cover.

00:57.900 --> 00:59.200
We see two memory modules.

00:59.400 --> 01:03.340
And if you see something like over here, you may be going, hey, what's going on over here?

01:03.940 --> 01:07.540
Well, you have every reason right to be, because this over here is JTAG.

01:07.580 --> 01:08.220
Awesome.

01:08.380 --> 01:11.620
So I just grabbed my, I think it was like JTAGulator or my Arduino.

01:11.620 --> 01:13.400
It's 3-3 logic, so it doesn't really matter.

01:13.660 --> 01:14.740
Got the pin outs.

01:14.920 --> 01:17.660
So this in the middle, open up the device, this thing right here.

01:17.660 --> 01:19.180
In the middle we have four pins.

01:19.180 --> 01:20.340
And what do you think it is?

01:20.500 --> 01:21.900
You are right.

01:21.900 --> 01:24.400
So we have ground, receive, transmit, 3-3.

01:24.680 --> 01:28.160
Unfortunately, when we turn on the device, standard in is blocked.

01:28.300 --> 01:29.500
So all we get is standard out.

01:29.500 --> 01:31.980
So receive is, you know, we can't type anything.

01:32.540 --> 01:33.180
Crap.

01:33.240 --> 01:34.440
We cannot do anything whatsoever.

01:34.440 --> 01:35.360
We just see standard out.

01:35.360 --> 01:36.380
We just see print logs, whatever.

01:36.380 --> 01:37.180
We're not seeing it.

01:37.180 --> 01:38.340
We can't do anything.

01:38.480 --> 01:39.480
That's boring.

01:39.780 --> 01:42.600
So after some thinking, because I want to keep everything software based.

01:42.600 --> 01:43.800
I don't want to touch hardware.

01:43.800 --> 01:44.860
Like, yeah, there's a NAND flash.

01:44.860 --> 01:45.800
We can remove it.

01:45.800 --> 01:47.380
That's the last thing I want to do.

01:47.380 --> 01:51.720
Like, I'd rather go the software route because it's ripping crap out and I mess up.

01:51.720 --> 01:52.920
I got to buy a new one.

01:53.140 --> 01:54.260
Forget all that.

01:54.360 --> 01:57.380
So I just solder some, so it takes like a hot glue gun.

01:58.120 --> 02:01.360
You know, find an area on the board that has no copper exposed.

02:01.360 --> 02:03.020
Put a little bit of hot glue on there.

02:03.040 --> 02:04.120
Take some header pins.

02:04.120 --> 02:05.180
Just stick it on there.

02:05.180 --> 02:06.280
Wait for it to dry.

02:06.360 --> 02:09.020
And then I take some wires and I just, you know, solder it on.

02:09.120 --> 02:11.160
And it's not the prettiest thing in the world.

02:11.540 --> 02:13.580
But, you know, and then I just attach some wires.

02:13.580 --> 02:16.620
Put it on my FTDI base breakout board over here.

02:17.400 --> 02:20.360
Turn on OpenOCD with my configuration on my FTDI board.

02:20.360 --> 02:23.460
And we see automatically, boom, we do have a JTAG interface.

02:23.460 --> 02:24.700
We have the ID.

02:24.700 --> 02:26.680
We see the manufacturer ID is ARM base.

02:26.680 --> 02:27.480
Woohoo.

02:28.100 --> 02:31.500
So then we open up our own target configuration.

02:31.540 --> 02:32.980
So we set the reset config.

02:33.000 --> 02:34.040
We have test reset.

02:34.040 --> 02:35.000
We have system reset.

02:35.000 --> 02:36.600
It's a push-pull situation.

02:36.680 --> 02:40.020
We have a new, like, tab with the ID at the very end of it.

02:40.020 --> 02:43.920
And then we create a cortex A target that's little Indian.

02:44.020 --> 02:48.640
And then after that, we run it again with our two configurations, the board and the target.

02:48.640 --> 02:52.020
And look, oh, also we have six break points, four watch points.

02:52.080 --> 02:59.310
And, you know , I can tell that into OpenOCD, like always, and give a command or attach GDB to it and start analyzing memory once I halt the processor.

02:59.710 --> 03:06.650
So before we get on to the next slide, so the first thing I started doing once I had JTAG was I don't have a data sheet for this chip whatsoever.

03:06.650 --> 03:08.330
So I'm dumping memory addresses .

03:08.330 --> 03:11.630
If something is not, you know, unaccessible, I just write that out.

03:11.630 --> 03:15.570
So I'm dumping, dumping, dumping, halting the boot-up process at different stages.

03:15.570 --> 03:17.610
I'm trying to find the kernel boot arguments.

03:17.770 --> 03:27.330
So after about an hour or two, I think about two or three hours, it was kind of a while, I finally found it, and I set a watch point to the very last character of that kernel argument, or kernel boot argument.

03:27.570 --> 03:34.490
So that when it's done writing for a watch point, I can set a break point, well, it'll, you know, break, and I can overwrite it.

03:34.490 --> 03:47.310
So instead of init calling slash init, I can set, no, instead of calling this upon initialization, because I don't have U-boot access, like, yeah, I could ground clock on the, on the NAND or so, or, you know, whatever, and make it fail, and maybe I can,

03:47.310 --> 03:50.790
you know, do a second retry and get into it, but, again, I don't want to touch hardware.

03:50.990 --> 04:01.830
So, um, I'm able to overwrite the kernel boot parameters, set a net to bin SH, alright, awesome, and then we continue execution, and, awesome, we get a root shell.

04:01.830 --> 04:06.790
We actually, can actually do something, and you actually probably saw me typing up some commands to load everything up.

04:07.370 --> 04:08.210
So great.

04:08.210 --> 04:12.950
So this gives us access to rip the firmware off and get debug capabilities, right?

04:12.950 --> 04:19.930
So the very first thing I do is I go through all the RCS initialization scripts, I get everything running, and I look for all the running daemons.

04:19.930 --> 04:23.570
I don't care if it's WAN-based, LAN-based, everything's open scope in my eyes.

04:23.570 --> 04:30.550
So I'm looking at anything that's listed on all interfaces 0 to 0, or, uh, inner, you know, an internal interface.

04:30.550 --> 04:34.510
Uh, IP tables can maybe come into play later, but we'll get into that later.

04:34.530 --> 04:38.890
So very first thing, I'm looking for low-hanging fruit, and someone please scrim it out.

04:38.890 --> 04:40.850
UDP 1900 is?

04:41.010 --> 04:42.190
Low-hanging fruit!

04:42.190 --> 04:42.730
Yes!

04:42.730 --> 04:43.250
Awesome!

04:43.250 --> 04:45.030
It is known as SSDP.

04:45.030 --> 04:47.610
It is a piece of crap, and everyone talks about it.

04:47.610 --> 04:51.970
But anyways, we have three binaries here, we have three different SSDB servers, WPS monitor.

04:51.970 --> 04:55.230
Frontier 4 is about a 32 megabyte C++ file.

04:55.230 --> 04:56.170
Have fun with that.

04:56.170 --> 04:57.410
It's kind of fun to look at.

04:57.410 --> 04:58.010
Fun.

04:58.110 --> 05:03.310
Uh, we have mini UPNPD, which probably is vulnerable to the read out of bounds volume that I posted earlier this year.

05:03.330 --> 05:06.470
So anyways, today we're going to be talking about WPS monitor.

05:07.490 --> 05:11.090
So before I even start ripping things out, I need to know my environment.

05:11.330 --> 05:14.130
Um, because I need to know like, you know, do I need an info leak?

05:14.130 --> 05:15.730
Uh, do we have an executable stack?

05:15.730 --> 05:16.450
Do we have an executable heap?

05:16.450 --> 05:17.790
Well, what the hell am I looking at, right?

05:17.790 --> 05:22.630
So the very first things I do is I look at all, you know, there's a libupnp library.

05:22.650 --> 05:24.670
You can see like, oh, a libupnp.

05:24.670 --> 05:28.130
It's not the Intel one, so remove all like assumptions out of your head.

05:28.250 --> 05:30.910
Uh, and also we have ASLR on the imported libraries.

05:30.910 --> 05:31.490
Surprise.

05:31.670 --> 05:32.930
We look at a stack in the heap.

05:32.930 --> 05:33.710
We have depth.

05:33.710 --> 05:34.310
Awesome.

05:34.510 --> 05:40.610
Uh, we also look at the heap over and over again, you know, and we see that ASLR does impact the heap base headers and the stack.

05:40.650 --> 05:41.230
Cool .

05:41.290 --> 05:48.750
Uh, the only thing that we see here is that this WPS monitor, the main binary itself is not ASLRed whatsoever, so we do have a static binary.

05:48.750 --> 05:49.610
We have a gadget.

05:49.610 --> 05:58.650
The problem is, we have null bytes in this 32-bit address, so if we have a string-based overflow or anything like that, we can't use this because of limitations of a string, you know.

05:58.650 --> 06:13.650
So, after that, this device does have USB devices, so I plugged in the FAT32 device in, and then just DD, uh, you know, look at mount, see where the file system will be mounted from, DD down to the USB drive, and then after that, 1, 2, 3, we use binwalk,

06:13.650 --> 06:16.050
like always, and we extract the file system.

06:17.030 --> 06:19.930
So now we're going to get more into the nitty-gritty, happier stuff.

06:20.010 --> 06:20.850
Vuln hunting.

06:21.090 --> 06:32.150
And so, like, you know, everyone has their own way of like, you know, going about vuln hunting, like some people have like, you know, super dope scripts, and some people get lucky, they're like, oh, man, I just looked at a string , and that sucks, right?

06:32.150 --> 06:35.430
It's like, oh, I looked at a string , found a vuln, and that's exactly what I do first.

06:35.430 --> 06:41.870
I'm looking for low-hanging fruit, least path-resistance, so I'm looking for %s, right, because what are the destinations for a format string?

06:41.870 --> 06:44.810
We have a buffer, or some sort of file descriptor in Linux, right?

06:44.810 --> 06:51.010
We have syslog, or we print the standard out, or we're going to, you know, save it something to a buffer and do whatever, right?

06:51.110 --> 06:54.950
So I see this very first response, HP11, okay, blah, blah, blah.

06:54.950 --> 07:02.070
I see %s here, I see %s there, %s here, over here is a %s, and over there is a %s as well, ha.

07:02.210 --> 07:06.770
And that's very interesting to me, because I'm like, alright, what is this response, right?

07:06.770 --> 07:08.730
Like, what function is using this?

07:08.930 --> 07:13.150
So I see this immediately, looked at xrefs, and I'm like, oh, that's nice, sprintf.

07:13.170 --> 07:19.050
But, you know, remember, sprintf, assert copy, and all those, like, vulnerable C functions can be used in a non -vulnerable way, right?

07:19.050 --> 07:21.250
So just because it's sprintf doesn't mean it's vulnerable.

07:21.390 --> 07:24.570
So we look at where's r0, the destination buffer coming from.

07:24.610 --> 07:30.350
So we look at, it's from r5 going to r7, going to, you know, then adding some more to r7 and putting it into r0.

07:30.370 --> 07:37.450
So this right here seems to me that we're accessing some sort of member in a structure, right, or, you know, an object, but it's still a struct, it's C.

07:37.530 --> 07:39.370
So we're accessing something.

07:39.370 --> 07:44.530
This could be, like, a pointer that, you know, maybe Malik is saved, you know, Malik is being saved to or whatever.

07:44.530 --> 07:46.510
Like, you know, we get an address from Malik, we save it there.

07:46.510 --> 07:49.890
Maybe it's calculating the length beforehand and, you know, maybe it's not vulnerable, like I said.

07:49.890 --> 07:50.410
Who knows?

07:50.410 --> 07:54.470
Or maybe this is just a character buffer inside this structure that has a fixed size.

07:54.470 --> 07:55.250
Who knows?

07:55.250 --> 07:56.710
So we need to do more research.

07:56.870 --> 08:04.810
So next thing I do is I'm looking at the UPnP specifications, going , what is this message for?

08:04.830 --> 08:14.090
And we see that we have something called a SID, which is a unique identifier, and we have this timeout second dash, and this is actual subscription time.

08:14.330 --> 08:17.250
Something in our, we probably have second dash and some integer, right?

08:17.450 --> 08:19.470
So I'm like, well, what's causing this response?

08:19.470 --> 08:20.150
And we see this.

08:20.150 --> 08:21.050
It's called a subscribe.

08:21.470 --> 08:24.510
Subscribe publisher path, and I'll show you that, what's that, afterwards.

08:24.510 --> 08:25.770
We have something called a callback.

08:25.770 --> 08:28.530
Host and user agent are optional, so that's why they're not bold.

08:28.530 --> 08:30.150
Callback is mandatory.

08:30.210 --> 08:33.490
It is wrapped around angle brackets or less than, greater than, whatever.

08:33.690 --> 08:37.010
We have NT set to UPnP event, which is static, has to be that.

08:37.050 --> 08:40.470
And then we have timeout second dash, and then a request is duration.

08:40.470 --> 08:44.790
Second dash, again, probably an integer, second dash 20, second dash 900, whatever.

08:46.110 --> 08:47.710
So what is this for?

08:47.710 --> 08:48.570
Like, what part is this?

08:48.570 --> 08:49.870
What is the publisher path?

08:49.970 --> 08:56.650
So you probably have done, like, I send an M search request on multicast, and then I get an XML, and then I get all this crap.

08:56.910 --> 09:01.050
But everyone talks about the control URL, the SOAP actions, and that's not what we're talking about today.

09:01.050 --> 09:04.310
We're talking about this, the event URL, which is called the Gina stat.

09:04.310 --> 09:07.490
I forgot what it stands for off the top of my head, but just trust me, it's called Gina.

09:08.870 --> 09:16.490
So the very first things we do is we launch up some notepad editor, Vim, whatever, but this is not Vim, I think it's Zed or something like that.

09:16.590 --> 09:18.650
So we use, you know, requests.

09:18.650 --> 09:25.890
We're going to send a request that, come on, we do second dash and then a string instead of, like, an integer.

09:25.890 --> 09:31.130
Because I just want to see firsthand if this percent S that I'm seeing in the response is even worth looking at.

09:31.170 --> 09:35.310
This is, you know, maybe pass it to a toy first and, you know, I get zero back and I get second zero.

09:35.310 --> 09:37.170
Like, that's not exploitable or anything worth looking at.

09:37.170 --> 09:38.470
So I need to dig deeper.

09:38.470 --> 09:42.790
So we just send it and awesome, I sent a string , I get a string back.

09:43.250 --> 09:44.450
That's awesome.

09:44.450 --> 09:47.190
So okay, this seems kind of interesting now.

09:47.190 --> 09:49.610
So that percent S is what we control .

09:49.630 --> 09:54.830
So okay, so next things we can do is we have two things we can do.

09:54.830 --> 10:02.410
We can be super C, super, like, awesome CSI, double -hacking keyboard, lead dudes that were, you know, like, all the clubbers and crap.

10:02.730 --> 10:04.610
Or, fuck it, we can just black box it, right?

10:05.490 --> 10:12.810
I mean, like, yeah, we can chase down the structure and, like, you know, we can find C functions and find where arguments, you know, is being passed to.

10:12.810 --> 10:19.370
We can be like, oh, we know that, you know, like, a start copy is a character buffer, character pointer, so this is a character pointer or whatever.

10:19.470 --> 10:31.870
Or maybe if we look up certain strings online, like on git duck duck go, Google, whatever, maybe we find the structure that we're clobbering, potentially, and we find everything.

10:31.970 --> 10:34.030
But this is supposed to be confidential.

10:34.430 --> 10:38.850
So I didn't have all this at the time, so screw it, we'll just black box it.

10:38.930 --> 10:39.570
Kobe.

10:39.670 --> 10:41.470
So, next thing.

10:42.170 --> 10:43.890
So I set up a for loop.

10:43.890 --> 10:45.930
That same exact code, just in a for loop.

10:45.930 --> 10:49.490
I'm incrementing now by one byte at a time, that second dash.

10:49.530 --> 10:51.130
And I have GDB attached.

10:51.130 --> 10:53.490
It's going to keep going and going and going and going and going and going.

10:53.490 --> 10:55.790
Any kind of reset sets to me, just try again, keep going.

10:55.790 --> 10:56.830
Right, just keep going.

10:56.830 --> 10:58.310
And I get a segmentation fault.

10:58.510 --> 11:02.030
I'm like, oh my god, there's probably static sizes, this is awesome.

11:02.030 --> 11:03.690
Oh my god, I got to call my dad.

11:03.770 --> 11:05.950
But hold on, let's not call my dad.

11:05.950 --> 11:08.250
Because this is just loading compare.

11:08.630 --> 11:10.790
We're not writing anything, we're just loading and comparing.

11:10.790 --> 11:12.610
That's not anything useful.

11:12.730 --> 11:20.510
And we go in IDA and we look around and yeah, all right, it's comparing to R1, which I don't know the value of, it's an unknown.

11:20.590 --> 11:24.150
But you know, we have this compare, it's looking at zero, it's going to branch out and return.

11:25.370 --> 11:31.670
So, all right, so I'm kind of messing around at this point because I'm thinking we have this UPnP server, what kind of states can we put this in?

11:31.670 --> 11:33.310
What kind of requests can I send to this thing?

11:33.310 --> 11:37.210
We have an HP stack, we have a SOAP stack, SSP stack, we have this Gina stack.

11:37.370 --> 11:42.190
So, I start thinking, I'm like, well what kind of other states can I do this in?

11:42.210 --> 11:43.870
And I find this.

11:44.350 --> 11:47.490
And I'm not going to read this wallet text to you.

11:47.510 --> 11:54.370
Basically what this says is that once you subscribe, you get a SID , your unique identifier ID, right?

11:54.410 --> 11:57.290
So from there, let's say you subscribe for 20 seconds.

11:57.290 --> 11:58.310
And then you change your mind.

11:58.310 --> 12:01.310
No, no, no, no, I meant to subscribe for like 100 seconds.

12:01.530 --> 12:05.890
Well, you send a second subscription with your SID and with a new timeout value.

12:05.950 --> 12:09.710
I was like, oh, maybe we can like hit some new code with this type of thing.

12:09.710 --> 12:14.270
So, we subscribe first, save the SID, and then we cause the overflow and see what happens, right?

12:14.270 --> 12:15.710
So, I do the thing again.

12:15.870 --> 12:17.310
And we get a different site fault.

12:17.310 --> 12:20.990
I'm like, oh, better be something good, right ?

12:20.990 --> 12:26.390
So, I start looking, I'm like, oh, we see this load, you know, offset 24 to R3.

12:26.470 --> 12:28.950
We do a compare, a branch on zero.

12:28.950 --> 12:30.490
So, if it's null, we don't call it.

12:30.490 --> 12:31.530
You're not going to call null.

12:31.590 --> 12:34.310
And then it jumps to it with the exchange.

12:34.310 --> 12:37.350
So, we can jump modes like thumb mode, R mode, whatever, right?

12:37.630 --> 12:39.490
And I'm looking at this, I'm like, what's R3?

12:39.510 --> 12:40.870
I'm like, oh, that's the value I control.

12:40.870 --> 12:41.390
That's my name.

12:41.390 --> 12:42.170
That's awesome.

12:42.730 --> 12:43.850
So, okay.

12:44.230 --> 12:45.970
So, we have, so I got lucky, right?

12:45.970 --> 12:46.930
I got super lucky.

12:46.930 --> 12:47.610
But I don't care.

12:47.610 --> 12:48.610
That's my luck.

12:49.050 --> 12:52.410
So, going on, I kind of have a way to obtain PC control.

12:52.410 --> 12:54.790
We're one pointer away, right?

12:54.790 --> 12:56.210
We're almost there.

12:56.690 --> 13:01.270
Still can't use WPS monitor as a gadget because we're still bounded by the limitations of a string.

13:01.270 --> 13:03.510
Can't have a null byte because that's the terminator.

13:04.010 --> 13:06.470
Uh, ASLR and import libraries that don't have an infleek.

13:06.470 --> 13:07.610
So, whatever, right?

13:07.890 --> 13:10.530
So, now to the exploit development of this.

13:10.670 --> 13:19.510
So, we're thinking, we're thinking, I have one pointer away, I have ASLR, I have depth on the heap and stack, one pointer away.

13:20.010 --> 13:25.490
Holy crap, you know what, this reminds me of actually, so back in the day, who's ever done internet explorer exploitation?

13:25.590 --> 13:28.290
IE8, 7, 4, 1, I don't care.

13:28.290 --> 13:29.030
Anyone?

13:29.830 --> 13:31.430
Yes, awesome, cool.

13:31.430 --> 13:33.510
So, that's exactly what it reminds me of.

13:33.630 --> 13:35.870
I'm like, okay, new tactic.

13:35.890 --> 13:37.270
Screw the infleek.

13:37.270 --> 13:47.650
Let's find a way to spray the heap, let's figure out to do some, you know, some David Blaine magic stuff and then, you know, maybe we can trigger the overflow and get code exec, right?

13:48.330 --> 13:52.390
And speaking of which, oh, whoops.

13:53.490 --> 13:55.510
I need to start this.

13:57.780 --> 14:01.800
So, you're about to witness the world's slowest exploit.

14:01.800 --> 14:05.740
My exploit takes about 20, 28 minutes and 30 seconds to run.

14:06.780 --> 14:08.880
So, we're going to start it.

14:09.080 --> 14:12.360
Just want to make sure it's running before I go back to my slides.

14:15.410 --> 14:16.550
All right.

14:16.550 --> 14:19.730
All right.

14:19.830 --> 14:21.770
One second, please.

14:23.990 --> 14:25.470
This is slow.

14:26.690 --> 14:27.310
All right.

14:27.310 --> 14:27.790
There we go.

14:27.790 --> 14:28.510
All right, cool.

14:29.470 --> 14:31.350
So, let's go back.

14:32.250 --> 14:32.890
All right.

14:32.930 --> 14:35.930
So, it says spray the heap, do some magic, trigger overflow, get code exec.

14:36.430 --> 14:37.790
So, we look at the heap.

14:37.790 --> 14:39.530
So, I need information now.

14:39.530 --> 14:42.470
What is the base address of this heap like loaded at every single time?

14:42.470 --> 14:45.590
So, I need a target address to maybe grow this heap torch, right?

14:47.350 --> 14:57.550
So, look at it once, maybe twice, look at it again, and again, and again, and again, and again, and again, and again, and again.

14:58.630 --> 14:59.330
That's okay.

14:59.330 --> 15:00.850
You know, we can do that later, right?

15:00.850 --> 15:02.370
We can do more off screen.

15:02.370 --> 15:03.310
That's boring.

15:03.550 --> 15:09.190
So, also I need to know how much memory do I have?

15:09.190 --> 15:13.350
Like Internet Explorer, everyone had like, you know, maybe back in the day like 512 megs.

15:13.350 --> 15:14.710
Yeah, my age is showing, right?

15:14.710 --> 15:15.910
Or, you know, at least a gig.

15:15.910 --> 15:21.470
So, spraying the heap is not really that much, you know, not much, you don't have to worry about it and running out of memory and stuff like that.

15:21.470 --> 15:23.290
But we have 117 megabytes free.

15:23.470 --> 15:26.590
Or, you know, I don't want to be, you know, taking up everything.

15:26.590 --> 15:28.150
So, let's just call it 100.

15:28.230 --> 15:29.290
100 megs.

15:29.290 --> 15:33.410
So, theoretically, if the heap always loads at zero, just think about that.

15:33.490 --> 15:38.830
The maximum size I can grow the heap to is 06060606 or whatever, right?

15:39.010 --> 15:39.870
So, awesome.

15:39.870 --> 15:44.650
I can grow the heap to a very large size potentially if I find a printer to allow me to.

15:44.650 --> 15:53.270
So, after doing all that stuff and putting everything to like an array, into an array, into a spreadsheet, and seeing like the top and bottom and see, like, what's, what's going on here?

15:53.270 --> 15:58.430
Like, what's the, you know, like, what's the highest address the heap actually loads onto and stuff like that?

15:58.430 --> 16:01.530
So, actually you saw that it loads under 0303 all the time.

16:01.530 --> 16:05.290
We see like an 0210, but it always loads under 03, 03, 03.

16:05.290 --> 16:06.230
So, I'm like, alright, cool.

16:06.590 --> 16:09.650
So, I start looking at the description functionality.

16:09.650 --> 16:10.690
Like, how does this work?

16:10.690 --> 16:11.770
I need to find primitives.

16:11.770 --> 16:12.670
I need to fill the heap.

16:12.670 --> 16:14.070
I need to do memory leak.

16:14.070 --> 16:15.590
Not info leak, memory leak.

16:15.590 --> 16:16.830
I need to fill up the heap.

16:16.990 --> 16:18.470
So, I start looking at this.

16:19.110 --> 16:22.330
So, I start looking at Stirling and it goes to a Calic.

16:22.450 --> 16:27.730
And I find out that that pointer there is the starting, it's the URL portion of the callback.

16:27.730 --> 16:32.550
So, after the IP colon port slash and then the end of it, that's, that's where we're at.

16:32.550 --> 16:33.570
So, that's where that pointer's to.

16:33.570 --> 16:35.970
That's slash and then like ABCD, right?

16:36.370 --> 16:40.250
The, the closing bracket is null terminated at this point.

16:40.250 --> 16:41.350
So, we're just slash.

16:41.690 --> 16:44.150
And then after that, we add some sort of size to it.

16:44.150 --> 16:45.890
So, it's going to be the size of some structure, right?

16:45.890 --> 16:46.790
So, we have some structure.

16:47.130 --> 16:50.050
And where the last element is some character buffer array.

16:50.090 --> 16:51.390
And then we call Calic.

16:51.390 --> 16:57.450
If you're not sure what Calic does, it takes the values of R1 and R0, multiplies them, checks for overflow condition.

16:57.450 --> 16:58.550
This is a very high level.

16:58.590 --> 17:03.630
And then it calls Malik, gets a pointer back , memsets it, and returns it back to you.

17:03.630 --> 17:05.190
So, everything's going to be initialized to zero.

17:05.190 --> 17:08.190
There's some other crap that goes on in there, but it's not relevant to this.

17:08.290 --> 17:09.530
So, we go into GDB.

17:09.650 --> 17:10.810
We set some break points.

17:11.650 --> 17:14.470
And, you know, we get the length and we get the return address.

17:14.470 --> 17:17.090
Because I need to learn how to, you know, I need to start spraying this stuff.

17:17.170 --> 17:20.970
So, I set up a for loop to subscribe over and over and over and over and over again.

17:21.330 --> 17:23.630
And crap.

17:24.310 --> 17:24.750
All right.

17:24.750 --> 17:26.970
I'm getting the same pointer over and over again.

17:26.970 --> 17:30.890
So, in my head, I'm like, all right, so, it's being freed, alecked again.

17:30.990 --> 17:31.930
Freed, alecked again.

17:31.930 --> 17:32.990
Freed, alecked again.

17:33.150 --> 17:35.370
What, what, like, what the hell is going on?

17:35.750 --> 17:37.390
So, step back.

17:37.390 --> 17:48.970
If I were to develop this, if I were, you know, on some team where I'm stressed out to get something delivered by the end of the week, I'm like, well, having one block for subscriptions for multiple devices makes no sense.

17:48.970 --> 17:49.470
Right?

17:49.470 --> 17:56.130
If I'm just using the same block, we're freeing one block with two devices, that's almost like you used out the free situation or only I support one device at a time.

17:57.570 --> 18:00.770
So, I go, well, let's change something in my subscription.

18:00.770 --> 18:04.170
We can change IP address maybe, change the port number, change the URL.

18:04.270 --> 18:11.310
So, for simplicity, I just do, like, a, a four I and range zero two whatever, and use the I to add it to my port range.

18:11.310 --> 18:19.530
So, we get a new, you know, port number upon every single iteration and ba-da-bing, ba-da-boom, I can now spray blocks of 4K.

18:19.590 --> 18:20.330
Awesome.

18:20.330 --> 18:22.210
I have a way to fill the heap.

18:22.210 --> 18:24.690
So, in theory, this is what I'm doing.

18:24.690 --> 18:30.910
Subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe.

18:31.530 --> 18:35.450
So, we're just filling up the heap with a bunch of subscriptions with Different port numbers.

18:36.290 --> 18:37.470
Okay, cool, that's cool.

18:37.470 --> 18:38.610
You can fill the heap.

18:38.910 --> 18:40.010
We can spray the heap.

18:40.170 --> 18:43.050
But we still need to do some dope David Blaine magic, all right?

18:43.050 --> 18:46.030
Then we go to street magic, you know, some crazy shit.

18:46.230 --> 18:48.050
So I start reading the manual some more.

18:48.050 --> 18:50.590
We go back to the architect, you know, the specifications.

18:50.810 --> 18:52.590
And I see this request now.

18:52.730 --> 18:55.350
Unsubscribe with the publisher path with your SID.

18:55.750 --> 18:57.430
I'm like, all right, let's go back to the code.

18:57.430 --> 18:59.550
And I find this function called delete subscriber.

18:59.550 --> 19:01.270
I wonder what it does.

19:01.510 --> 19:05.990
And I see this little wrapper of free here, which literally just takes the pointer and passes the free.

19:06.190 --> 19:07.530
So I set a break point there.

19:07.530 --> 19:09.110
I go, well, what is this pointer, right?

19:09.110 --> 19:10.790
We have run time capabilities.

19:10.790 --> 19:13.270
I don't feel like spending all the time reversing all the things.

19:13.270 --> 19:15.230
Don't limit yourself to just one way.

19:15.230 --> 19:16.570
Use the easiest ways.

19:16.610 --> 19:24.670
So I'm like, oh, so if I subscribe and I reverse the array of all the SIDs that I saved and I send them to unsubscribe, they're freed.

19:24.670 --> 19:25.710
These are my blocks.

19:25.710 --> 19:27.210
I'm using the, oh, awesome.

19:27.210 --> 19:34.390
So I have an ability to spray the heap and I have the ability to free blocks at will and I can make holes in the heap if I want to or whatever, right?

19:34.490 --> 19:36.470
So back to monkeying around.

19:38.090 --> 19:44.850
Because this is the heap spray portion, but I'm like, okay, I'm still bounded by the limitations of a string.

19:44.970 --> 19:46.090
I can't do anything yet.

19:46.090 --> 19:46.950
I can fill up the heap.

19:46.950 --> 19:48.030
That's fun.

19:48.150 --> 19:51.170
But, you know, I can't use WPS monitor as a gadget yet.

19:51.290 --> 19:56.030
So I start talking to a colleague who works on different products but also has experiences with heap stuff.

19:56.030 --> 19:58.230
I'm just bouncing ideas back and forth with my colleague.

19:58.310 --> 19:59.510
It's kind of like rubber ducking.

19:59.530 --> 20:00.850
So I send him my IDB.

20:00.850 --> 20:02.570
I'm like, hey, man, I'm looking at this.

20:02.810 --> 20:04.290
You know, this is my limitations.

20:04.290 --> 20:05.470
This is what I can do so far.

20:05.550 --> 20:08.990
You know, you can look at all the references to malloc, calloc.

20:09.090 --> 20:11.270
If you're super hardcore, xmalloc.

20:11.270 --> 20:13.250
If you turn null, kill the application.

20:13.250 --> 20:14.030
Super hardcore.

20:14.230 --> 20:16.790
But we start going back forth and he asks me a question.

20:16.790 --> 20:20.510
He goes, hey, this function here about base64 decoding uses malloc.

20:20.510 --> 20:21.690
What is that all about?

20:21.710 --> 20:23.310
Like a UPnP, base64.

20:23.330 --> 20:24.490
I'm like, oh, shit.

20:24.510 --> 20:25.070
Awesome.

20:25.070 --> 20:28.610
So we go back to SOAP, the thing I did not want to talk about whatsoever.

20:28.610 --> 20:31.670
And I start looking for an action with one argument.

20:31.830 --> 20:35.310
Because I don't want to deal with multiple arguments and it just gets kind of messy.

20:35.310 --> 20:35.970
And I find this.

20:35.970 --> 20:37.290
This delete AP settings.

20:37.290 --> 20:37.730
Sure.

20:37.730 --> 20:38.310
Whatever.

20:38.410 --> 20:41.810
What kind of type is this new AP settings argument?

20:41.810 --> 20:43.410
Go all the way down to the bottom of XML.

20:43.410 --> 20:44.990
We see it's a base64 type.

20:45.110 --> 20:51.570
So we can send a SOAP request to this action and inside the XML, inside the text, we just, you know, base64 encoded string.

20:51.690 --> 20:53.910
I can base64 encode nulls.

20:53.910 --> 20:54.630
Okay.

20:54.910 --> 20:56.810
So what I do next is like, alright.

20:56.990 --> 21:01.390
So when I send this, when I send the SOAP action, I set a breakpoint, I look at the heap block.

21:01.430 --> 21:04.370
And it's actually the decoded data that I sent to it.

21:04.370 --> 21:06.250
It's not the base64 string.

21:06.410 --> 21:06.910
Awesome.

21:06.910 --> 21:14.170
I can now write nulls and I can probably use WPS as some sort of gadget if I can figure out the way to spray my fake object into the heap.

21:14.390 --> 21:16.350
So, I try this out.

21:16.550 --> 21:17.390
So we do it.

21:17.390 --> 21:18.630
We unsubscribe.

21:18.790 --> 21:20.390
We call the SOAP action.

21:20.550 --> 21:21.630
We unsubscribe.

21:21.730 --> 21:23.090
We call the SOAP action.

21:23.210 --> 21:23.850
Unsubscribe.

21:23.850 --> 21:24.830
And then I look at this.

21:24.830 --> 21:26.710
This is early development of my structure.

21:26.770 --> 21:28.530
That's why you see like 02, 02, 03, 03.

21:28.530 --> 21:29.870
Just lining everything up.

21:29.870 --> 21:31.730
The very first one is my first gadget.

21:31.730 --> 21:32.610
So whatever.

21:32.690 --> 21:34.730
But I'm trying to set things up.

21:34.730 --> 21:38.230
So I'm doing everything by hand at first and I'll, you know, I'll make it nice and pretty later.

21:38.510 --> 21:39.290
So, okay.

21:39.290 --> 21:40.750
We can spray the heap now.

21:40.830 --> 21:43.130
We're kind of almost there doing some magic.

21:43.310 --> 21:44.290
But wait.

21:44.410 --> 21:45.090
Roadblock.

21:45.090 --> 21:45.350
Alright.

21:45.350 --> 21:46.070
I do my spray.

21:46.070 --> 21:49.810
I'm doing my technique and I'm like, alright, let's look at this address and it's not there anymore.

21:50.370 --> 21:51.170
Shit.

21:51.230 --> 21:51.590
Alright.

21:51.910 --> 21:53.350
Well, what's going on?

21:53.430 --> 21:59.450
So, to think about it in layman's terms, like super simplistic, you can't build a house without a roof.

21:59.450 --> 21:59.990
Right?

21:59.990 --> 22:01.270
That seems silly.

22:01.350 --> 22:04.290
So my technique right now, I'm like, you know, I got all these descriptions.

22:04.350 --> 22:05.350
I unsubscribe.

22:05.470 --> 22:06.550
Do a SOAP action.

22:06.550 --> 22:07.450
I unsubscribe.

22:07.450 --> 22:08.690
Do a SOAP action.

22:08.750 --> 22:09.310
Unsubscribe .

22:09.310 --> 22:09.790
SOAP action.

22:09.790 --> 22:11.490
You know, blah, blah, blah, blah.

22:11.490 --> 22:15.410
And we're going down the line and, you know, and, and then the rest.

22:15.410 --> 22:15.890
Right?

22:16.190 --> 22:23.370
But then, the Linux kernel's like, usually an application, you got all this free space in malloc, or you know, in your heap, you don't need this anymore.

22:24.730 --> 22:29.490
So it eats it all away and revokes it from me and gives it to another application or anything else that needs the memory.

22:29.490 --> 22:29.970
Right?

22:30.150 --> 22:31.390
So, that's what's going on.

22:31.390 --> 22:37.770
So I'm like thinking, I'm like, well, instead of freeing everything, what if I leave the last allocation there?

22:37.770 --> 22:43.970
Because in the seconds, there's actually an option to do infinite, where it will never, ever run out of time for your description.

22:43.970 --> 22:47.230
It's forever until the, no, until it like reboots or something.

22:47.310 --> 22:59.070
But either way, so now I fill up the heap, I pop the last allocation off of my array, reverse it, now I do a unsubscribe on the second to last, and I go from there.

22:59.070 --> 22:59.750
Right?

23:00.170 --> 23:01.830
So, this is awesome.

23:01.830 --> 23:09.330
So this is working fine until, come on, until this happens.

23:09.330 --> 23:15.810
So my, my way to do the base 64 thing is writing to the same block over and over again.

23:15.810 --> 23:22.050
I'm no longer putting something on top of the free list, occupying it, it's getting freed again, free something else, put it on top.

23:22.050 --> 23:23.850
It's not, it's something else is racing to it.

23:23.850 --> 23:25.490
Something else is causing some issues.

23:25.510 --> 23:28.570
So now I've got to figure out what the hell is being freed.

23:28.570 --> 23:31.010
So I'm going to set just a simple break point on free.

23:31.010 --> 23:35.610
If it's null, just keep going, I don't care about null being passed or freed.

23:35.890 --> 23:38.810
Um, so we just keep going, and we're just going to wait.

23:39.010 --> 23:52.230
And actually it does some stuff every 60 seconds, cause there's also other imported libraries, and you know, we gotta see if they're doing something, or the main binary's doing something, cause if there's a race condition, this makes the exploit that we're trying to do much less reliable,

23:52.230 --> 23:54.170
and it's not really worth going for anymore.

23:54.330 --> 23:57.290
So I look at it, and I'm like, alright, let me send an msearch request.

23:57.290 --> 24:11.630
Because if you use Google Chrome, for example, uh, when you open up your browser, go to YouTube, your browser sends an msearch request on multicast, uh, because it's looking for something called a dial server, which is a layer of UPnP, developed by Netflix,

24:11.630 --> 24:18.530
you can find the GitHub, find the code, uh, you can also look at the Chromium, uh, code branch and find the, uh, the dial code.

24:18.530 --> 24:22.690
But anyways, we send an msearch request, we see that there's pointers being freed, okay?

24:22.810 --> 24:25.970
We find the sizes by looking at the heap header manual and stuff like that.

24:25.970 --> 24:30.950
Um, so every 60 seconds, this device sends out a notify request on multicast.

24:30.950 --> 24:37.470
Sends it out and says to everyone, hey, you know, I'm here, here's my XML, go and chat, that's cool, if not, you know, no big deal.

24:37.650 --> 24:46.890
Um, and then last but not least, if someone sends it in, like a get request, like a device is, uh, getting the XML in order to send us a request or a subscription , this is what it looks like.

24:46.890 --> 24:55.050
So I'm going over all these different instances as to , like, what can get in there, what kind of requests, and the sizes, so that I, I set up my heap a little bit differently.

24:55.050 --> 24:57.050
So that now I have two arenas.

24:57.050 --> 25:01.230
So I have one arena where I have spaces for these objects to fit into perfectly.

25:01.230 --> 25:03.570
And they can jump in there all they want, because I'm making holes.

25:03.570 --> 25:05.430
It'll never get, like, condensed or whatever.

25:05.430 --> 25:06.730
It may get trimmed, doesn't matter.

25:06.730 --> 25:11.210
Then I have my other arena where I have that last allocation being set and I do the whole thing.

25:11.210 --> 25:12.810
So now we shift gears.

25:12.910 --> 25:18.850
So now what I'm doing is a free, replace, free, replace, free, replace, blah, blah, blah.

25:18.850 --> 25:21.330
And then we do an allocation back up.

25:21.330 --> 25:24.570
So we resubscribe and we come back down.

25:24.570 --> 25:29.950
And also what we're doing is between every single iteration is that we have a UDP socket listening on multicast.

25:29.950 --> 25:41.750
We select it upon every single iteration, there's something to read, we slurp it up, and then we also maybe do some more subscriptions and replacing just to unfubar anything at the top of the free list, because we don't want anything else to race there.

25:42.070 --> 25:45.330
So, next, we can spray the heap.

25:45.330 --> 25:46.330
We can do some magic now.

25:46.330 --> 25:47.950
We can now use WPS monitor.

25:47.950 --> 25:51.030
We can write nulls to the heap and stuff like that, I guess, basics for decoding.

25:51.030 --> 25:51.870
That's awesome.

25:51.990 --> 25:53.850
Uh, but we don't have an exploit chain yet.

25:54.150 --> 25:58.890
So I'm thinking, I'm like, alright, let's cause a crash and we look at what do we control, right?

25:59.110 --> 26:09.830
Um, I don't use, like, sometimes I use, uh, like, Pwn2Bug and stuff like that, but if you use an open OCD and you have Pwn2Bug running, you have a lot of issues that may occur, so I just haven't commented on my GDB init.

26:09.830 --> 26:13.210
But anyways, the only register that we have control of really is R4.

26:13.290 --> 26:15.250
R4 points to our overflow string.

26:15.270 --> 26:21.590
And yeah, the first pointer is going to point to something in the heap, blah, blah, blah, but let's just assume the very first one is just 41, 41, 41, 41.

26:23.570 --> 26:25.970
So I have a pointer that points to my data.

26:26.350 --> 26:27.710
That's all I have.

26:27.790 --> 26:31.130
So I start looking online, I'm like, alright, let's look, think back about Internet Explorer days.

26:31.290 --> 26:32.390
Uh, you know, what did we do?

26:32.390 --> 26:34.110
Oh, we did a stack pivot, right?

26:34.250 --> 26:36.530
Uh, we have, like, one shot, so we do a stack pivot.

26:36.530 --> 26:41.670
So if this heap was executable, we have a bunch of, like, NOPs and then shellcode, NOPs, shellcode, we jump to NOPs.

26:41.870 --> 26:42.270
Wee!

26:42.310 --> 26:44.670
Uh, if we have depth, we have a bunch of returns.

26:44.710 --> 26:52.810
So, you know, we shift the stack to the, the heap and then we do return, return, return, then we have our prop gadget and call virtual protect and we execute shellcode, ba-da-bing, ba-da-boom.

26:52.970 --> 26:54.890
So I start looking online and I see this.

26:55.170 --> 27:02.550
So this was from 2012, a Rockstown talk about exploiting stuff on R and blah, blah, blah, and it has this load multiple decrement before instruction.

27:02.770 --> 27:04.010
And what, what does it do really?

27:04.010 --> 27:10.650
And it's saying that, oh , you know, if you have a source register, you can populate the other registers and you can, you know, do a stack pivot because it writes to SP.

27:10.670 --> 27:11.710
I'm like, oh, man, god.

27:11.710 --> 27:23.590
So I, I open up Redere and I look for this load, uh, deduct multiple, uh, load multiple deduct before with R4 and I see some instructions, so I plug it in, very first thing, and illegal instruction.

27:24.090 --> 27:25.350
Well, what the hell?

27:25.590 --> 27:26.530
Like, what?

27:26.530 --> 27:27.250
Why?

27:27.250 --> 27:33.930
So we look at the ARM manual and we see this restriction on the second line, the register destination list cannot contain SP.

27:34.110 --> 27:38.490
The destination list that I had before has SP, the second to last one.

27:38.490 --> 27:40.090
This is now an illegal instruction.

27:40.090 --> 27:42.530
I can't use this technique on this device.

27:42.550 --> 27:44.130
So, alright, back to the drawing board.

27:44.130 --> 27:47.590
So what I do next is I develop a regex for IDA.

27:47.790 --> 27:55.370
I'm looking for load where the, the last, uh, last register, you know, second operand or whatever of that opcode is, uh, R4 being dereffed.

27:55.390 --> 27:56.690
That's all, that's what I want.

27:56.690 --> 28:01.670
So I set up a regex to do that and I find a bunch of them, I go through them by hand and I find this gadget here.

28:01.770 --> 28:08.050
And it says like dereff R4 and R3 and we add all these offsets and we get R2 and we have R1 and R0.

28:08.130 --> 28:11.710
I'm spraying 4K blocks here, hex 1000 is 4K.

28:11.710 --> 28:16.150
So we're just going to jump into another block that I, I'm in control of with my data.

28:16.150 --> 28:20.150
So this right here gives me the primitive of calling a function with two arguments.

28:20.410 --> 28:21.610
Okay, cool.

28:21.650 --> 28:31.130
But the problem is though, once, once this function , like once what I call returns, it's going to use the stack now and it's going to pop PC and I no longer have control.

28:31.130 --> 28:33.250
So I only have a one shot situation.

28:33.270 --> 28:35.630
So I'm thinking, I'm like, what can I do?

28:35.770 --> 28:42.950
I'm like, alright, so let's look at functions that write, like that write to memory that are not bounded by uh character limitations.

28:42.950 --> 28:44.330
So I started looking at mem copies.

28:44.330 --> 28:45.610
This thing has tons of them.

28:45.610 --> 28:55.850
So, you know, I'll put on my music or whatever and I start grinding through this and uh, I find this mem copy here and you don't have to read all this.

28:55.850 --> 28:57.670
I know it's probably hard in the back and I apologize.

28:57.670 --> 28:58.750
I'll sum it up.

28:58.750 --> 29:05.590
So this right here, if you look at the second to last instruction, R0, the destination, is a stack based buffer.

29:05.590 --> 29:13.590
Even though the stack frame is kind of large at like 2K, you know, hex 800, uh, we still have a destination buffer that's a stack.

29:13.630 --> 29:18.790
And R0 and R1 are in our control now because that was the last gadget that gave us control.

29:18.790 --> 29:25.130
And R1's in R4, R0's in R5, we look in, R4 is N, R5 is the source.

29:25.170 --> 29:30.310
So instead of bringing the stack pointer to the heap, like fuck it, let's just bring the heap to the stack.

29:30.310 --> 29:31.790
Just clobber the shit out of the stack.

29:31.790 --> 29:32.770
I control N.

29:32.770 --> 29:34.390
I can clobber the shit out of the stack.

29:34.390 --> 29:35.450
So that's what I do.

29:35.630 --> 29:39.810
And we look at the bottom of this thing so we adjust the stack frame so we have to be careful now.

29:39.810 --> 29:41.530
This is a large adjustment, 2K.

29:41.710 --> 29:43.930
So we're not going to jump back and do stuff.

29:43.930 --> 29:45.810
We're now just incrementing the stack.

29:45.810 --> 29:51.990
We have to be careful not to run out of stack space and cause, uh, you know, like an interrupt to happen or a signal to happen and kill the program.

29:52.150 --> 29:57.330
So now we have control of R4 to R7 because now we brought the heap to the stack.

29:57.650 --> 29:59.330
So now, next gadget.

29:59.470 --> 30:08.950
R7 is going to contain a pointer to the IAT table entry, uh, inside WPS marks where it's not ASLR'd, uh, of str2 unsigned long.

30:08.950 --> 30:10.970
But with the pointer of minus 4.

30:10.970 --> 30:13.030
And this next slide you'll see why.

30:13.650 --> 30:16.790
So then after that we pop from the stack R3 to R7 PC.

30:16.790 --> 30:17.750
Next thing.

30:17.770 --> 30:29.670
We deref R0 now, which is now going to take the IAT table plus 4 and it's going to, it's going to deref that pointer from the IAT table and now we have a libc function, uh, pointer.

30:29.670 --> 30:32.450
Now we're inside libc at str2 unsigned long.

30:32.450 --> 30:34.170
We don't need to leak it anymore .

30:34.170 --> 30:35.470
Pop from the stack.

30:35.490 --> 30:36.250
Next one.

30:36.250 --> 30:39.490
We add R3 because look, we have R3 to R7.

30:39.750 --> 30:42.190
R3, uh, it's going to be an offset now.

30:42.190 --> 30:46.690
We're going to add it, well R3 and R0 are going to be added together and we're going to save into R0.

30:46.690 --> 30:54.790
So now it takes str2 unsigned long, I take an offset and I add it and I get to, since system wasn't working and I didn't want to debug it, P open.

30:55.090 --> 31:09.990
So since the system, since the, uh, WPS monitor didn't use system, it didn't import P open or anything else I can use to execute shell commands, uh, since back in the day, like, you know, uh, with inter explorer exploitation, uh, if you had some way to get into kernel 32 DLL,

31:09.990 --> 31:17.770
you just add or minus an offset to get to virtual protect in order to make the, you know, allocation that you want executable or whatever the hell you wanted to do with the permissions.

31:18.070 --> 31:24.670
So then from there, gadget six, this looks really large, but we can pick another allocation that's like maybe a megabyte away.

31:24.670 --> 31:25.470
We don't care.

31:25.470 --> 31:26.770
We're going to write to the heap now.

31:26.770 --> 31:30.430
We have a pointer to P open and all these gadgets I found by hand.

31:30.430 --> 31:34.250
If I try to use some wrapper thing and try to automate it , I would not have found these gadgets.

31:34.430 --> 31:35.130
Wrapper and everything.

31:35.130 --> 31:40.490
So I'm going to say, hey man , there's a mem copy with R0 and R1 or R1 and R2 and R0 being stacked.

31:40.490 --> 31:41.630
It's not going to tell me that.

31:41.630 --> 31:44.090
So anyways, this right here, I'm going to write to the heap.

31:44.090 --> 31:49.010
I'm going to write the P open pointer that I just calculated into the heap now.

31:49.070 --> 31:49.850
Keep going.

31:49.850 --> 31:53.090
We're almost kind of towards the end of the stack limitations here.

31:53.090 --> 31:57.590
So now I invoke gadget one again, which is our last gadget, gadget seven.

31:57.690 --> 32:00.810
So this one, remember, I can call something with two arguments.

32:00.810 --> 32:02.570
So R2 is going to be P open.

32:02.630 --> 32:04.130
R0 is going to be a string.

32:04.130 --> 32:07.930
R1 is going to be R because you have to provide something for P open.

32:08.070 --> 32:09.990
And then, okay, cool.

32:09.990 --> 32:11.030
So let's put it all together.

32:11.090 --> 32:12.310
So we spray the heap.

32:12.310 --> 32:14.190
We save all the subscription IDs.

32:14.270 --> 32:17.290
We don't free the last subscription ID, that's our roof.

32:17.910 --> 32:26.790
We free and replace the blocks with unsubscribe and we replace everything with the soap action with base 64 encoded fake structure, our ROP chain, and ending with the command.

32:26.790 --> 32:31.930
Everything is aligned to 256, or actually, yeah, so everything is 256 by the line, whatever.

32:32.030 --> 32:36.010
So we free five, reoccupy five, free them again, go to the next five.

32:36.010 --> 32:40.590
If anything comes in multicast, fix up the heap if needed by doing resubscriptions and freeze again.

32:41.370 --> 32:43.850
Trigger volume, maybe we win.

32:43.850 --> 32:46.930
So we sue everything and we see this, right?

32:46.990 --> 32:49.310
So let's check out this guy.

32:49.910 --> 32:51.730
Why is it at 11%?

32:54.130 --> 32:55.090
No!

32:55.710 --> 32:57.250
It is at 11%.

32:57.250 --> 33:00.930
Why is it 11%?

33:00.930 --> 33:01.390
All right.

33:01.390 --> 33:03.910
So I guess I'm not doing the exploit live anymore.

33:03.910 --> 33:05.190
That sucks.

33:05.490 --> 33:07.070
Oh, that sucks.

33:08.370 --> 33:09.630
Oh, no.

33:09.630 --> 33:10.530
Why?

33:11.450 --> 33:12.770
It's on.

33:12.810 --> 33:13.310
All right.

33:13.310 --> 33:13.970
I'm sorry.

33:13.970 --> 33:15.590
I guess I'm not doing this live.

33:15.590 --> 33:16.650
It is reliable.

33:16.650 --> 33:19.150
I can demo it later if you guys want to see it.

33:19.490 --> 33:20.610
But it's all right.

33:20.910 --> 33:22.630
We're stuck at 11%.

33:22.630 --> 33:30.190
What we were doing, though, was the free and replace of everything that we were doing.

33:30.190 --> 33:32.970
We create two arenas and we're going all the way down.

33:32.970 --> 33:35.610
It should have been around 60% by now or so.

33:35.690 --> 33:37.110
So that's all right.

33:37.930 --> 33:40.210
Man, let's see down here.

33:41.270 --> 33:49.550
But anyways, if this was working properly and didn't want to just foobar out of nowhere, we would be in the context of doing all that stuff.

33:49.550 --> 33:54.830
But the funny part about this as well, just to look up, is that there's actually one process.

33:55.530 --> 33:56.570
Let's see here.

33:56.570 --> 33:59.210
One process ran by nobody.

33:59.390 --> 34:00.930
It's another UPnP server.

34:00.930 --> 34:07.510
So whoever actually made the process, you know, the process run under nobody, like, that guy deserves a high five.

34:07.630 --> 34:09.810
So anyways, let's go back to everything.

34:12.090 --> 34:13.950
Man, I really wanted to show that shell.

34:13.950 --> 34:15.090
Oh, well, it's actually still going.

34:15.090 --> 34:16.290
It's just going really slow.

34:16.710 --> 34:19.090
Anyways, so we do have a shell.

34:19.090 --> 34:22.030
And I wanted to show you guys some bonus stuff as well.

34:22.030 --> 34:31.530
So besides the shell and all that stuff, so before, remember I was saying that, you know, I was looking at daemons that were running on a particular, you know, all interfaces or just a LAN.

34:31.530 --> 34:35.090
And I found one 5916 that was being filtered by IP tables.

34:35.490 --> 34:42.150
So I started thinking, I'm like, huh, what if we use that genus stack to pivot, like a server -side request forgery, right?

34:42.150 --> 34:48.150
So we set the callback address to 120 localhost 5916 with this URL.

34:48.350 --> 34:52.130
And so we attach strace to that daemon to see if anything's coming in.

34:52.130 --> 34:55.290
We send the request, and yes, we do get that.

34:55.290 --> 35:06.830
So if you are trying to hit something that's maybe token based, so it's a TCP-based connection, and maybe it's like, oh, it's doing like structure, they start to be getting up something or stir, like a stir stir, like some sort of substring that's token based,

35:06.830 --> 35:10.650
you can use this to maybe hit that part of the code, maybe change configuration or something like that.

35:10.650 --> 35:11.970
So it's a way to pivot.

35:12.290 --> 35:20.730
So last but not least, I also wanted to give a fuzzing demo, but I'm not sure if it's, if it's going to cooperate with me.

35:20.730 --> 35:26.470
But I mean, after all this, so finding the vuln and all that stuff taught me something valuable.

35:26.470 --> 35:29.830
So I was doing this by hand, and I was like, you know what?

35:29.830 --> 35:33.930
I've been finding a lot of the same kind of programming issues with this protocol and stuff like that.

35:33.930 --> 35:39.830
I have a background in network engineering, I also have a background in QA, so I was like, let me start making a fuzzer.

35:40.130 --> 35:43.350
And I encourage everyone else to do this as well, because what do we have ?

35:43.350 --> 35:45.330
We just have HP, we have XML.

35:45.570 --> 35:56.850
If you could just make something to just send out an attempt search request, get the, you know, get the, the XML file back and just parse that, make an XML parser, go through everything, save everything, make your own fuzzer.

35:56.850 --> 35:58.350
You'll save so much time.

35:58.350 --> 36:02.250
So instead of a few days, like it took me by hand to find this vuln, it would have taken me 30 seconds.

36:02.490 --> 36:04.070
So actually, let's see.

36:04.750 --> 36:05.830
Now it's going.

36:05.830 --> 36:06.750
It's going now.

36:06.750 --> 36:14.110
Alright, so maybe if we have time towards the end, I'll, I'll check up on it and see if we're, if we're all good.

36:15.110 --> 36:19.610
So anyways, man, everything going wrong is.

36:19.610 --> 36:20.030
That's awesome.

36:20.030 --> 36:26.970
So anyways, so if an ISP asks you, and this is going to be super cheesy, but whatever, I'm going to do it.

36:27.190 --> 36:31.270
If an ISP asks you, could you, would you install this router in your house?

36:31.370 --> 36:34.470
You must say, no, I do not, would not install this in my house.

36:34.470 --> 36:35.550
I do not want it here or there.

36:35.550 --> 36:36.710
I do not want it anywhere.

36:36.710 --> 36:37.590
I wouldn't want it for free.

36:37.590 --> 36:39.670
I wouldn't want it if it could download up to 10 GB.

36:39.670 --> 36:42.990
But anyways, that's enough of that stuff.

36:42.990 --> 36:44.430
This is who I am.

36:44.450 --> 36:46.250
So I go by Black Owl Online.

36:46.730 --> 36:50.350
Someone had the real name Black Owl, so I changed the L21020.

36:50.410 --> 36:50.850
Cool.

36:50.850 --> 36:51.430
Elite sauce.

36:51.430 --> 36:52.150
What up?

36:52.390 --> 36:55.050
I'm a zero-day researcher at Exodus Intelligence.

36:55.130 --> 37:01.870
I do embedded devices, both SOHO, I do enterprise network solutions, firewalls, virtual appliances, whatever.

37:01.870 --> 37:02.410
I don't care.

37:02.410 --> 37:04.570
If I can get it, I'm going to audit it.

37:04.570 --> 37:07.690
Smart devices or anything else that catches my eye.

37:07.770 --> 37:09.970
We're also hiring at Exodus Intelligence.

37:09.970 --> 37:14.010
We're looking for another zero-day researcher if you're interested for getting paid for finding no-days.

37:14.010 --> 37:16.490
I get a bonus on top of that for selling your phones to us.

37:16.550 --> 37:17.530
Like, you know, hit me up.

37:17.690 --> 37:18.790
But that's about it.

37:18.790 --> 37:20.250
So again, that's who I am.

37:20.250 --> 37:23.150
Thank you for coming to my talk labeled Green Waves in Ham.

37:23.250 --> 37:24.050
Take care.

