1 00:00:00,000 --> 00:00:03,640 Without further ado, this is Elvis Cayado. 2 00:00:03,740 --> 00:00:09,260 He's going to be presenting on some really cool research that he manipulated. 3 00:00:10,080 --> 00:00:10,900 Yeah, sure. 4 00:00:10,900 --> 00:00:11,220 All right. 5 00:00:11,220 --> 00:00:11,680 Awesome. 6 00:00:11,680 --> 00:00:12,860 Thank you so much for joining us. 7 00:00:12,860 --> 00:00:14,000 And here we go. 8 00:00:17,720 --> 00:00:18,460 Test. 9 00:00:18,460 --> 00:00:19,120 Is that good? 10 00:00:19,120 --> 00:00:19,500 All right. 11 00:00:20,640 --> 00:00:22,740 Thank you everyone and welcome for coming. 12 00:00:22,740 --> 00:00:25,860 This is my talk called green waves and ham. 13 00:00:26,820 --> 00:00:27,460 All right. 14 00:00:27,460 --> 00:00:28,080 Let's get started. 15 00:00:28,080 --> 00:00:31,760 So this device up here that you see is called the green wave G1100. 16 00:00:31,840 --> 00:00:34,660 It was distributed by Verizon Fios and Frontier. 17 00:00:34,660 --> 00:00:36,620 They're an ISP up in the northeast. 18 00:00:36,720 --> 00:00:38,920 And we have Verizon for the file service. 19 00:00:38,920 --> 00:00:42,120 It was not available in my area, but this is what they gave you. 20 00:00:42,940 --> 00:00:45,460 So if we look a little there, we got our FCC ID. 21 00:00:45,460 --> 00:00:47,860 So what do we do with our FCC ID? 22 00:00:47,940 --> 00:00:54,040 We go online and we find the internal photos and then we find the processor and we look it up. 23 00:00:54,040 --> 00:00:57,900 There's no data sheet for that, unfortunately, but we see the shield is on cover. 24 00:00:57,900 --> 00:00:59,200 We see two memory modules. 25 00:00:59,400 --> 00:01:03,340 And if you see something like over here, you may be going, hey, what's going on over here? 26 00:01:03,940 --> 00:01:07,540 Well, you have every reason right to be, because this over here is JTAG. 27 00:01:07,580 --> 00:01:08,220 Awesome. 28 00:01:08,380 --> 00:01:11,620 So I just grabbed my, I think it was like JTAGulator or my Arduino. 29 00:01:11,620 --> 00:01:13,400 It's 3-3 logic, so it doesn't really matter. 30 00:01:13,660 --> 00:01:14,740 Got the pin outs. 31 00:01:14,920 --> 00:01:17,660 So this in the middle, open up the device, this thing right here. 32 00:01:17,660 --> 00:01:19,180 In the middle we have four pins. 33 00:01:19,180 --> 00:01:20,340 And what do you think it is? 34 00:01:20,500 --> 00:01:21,900 You are right. 35 00:01:21,900 --> 00:01:24,400 So we have ground, receive, transmit, 3-3. 36 00:01:24,680 --> 00:01:28,160 Unfortunately, when we turn on the device, standard in is blocked. 37 00:01:28,300 --> 00:01:29,500 So all we get is standard out. 38 00:01:29,500 --> 00:01:31,980 So receive is, you know, we can't type anything. 39 00:01:32,540 --> 00:01:33,180 Crap. 40 00:01:33,240 --> 00:01:34,440 We cannot do anything whatsoever. 41 00:01:34,440 --> 00:01:35,360 We just see standard out. 42 00:01:35,360 --> 00:01:36,380 We just see print logs, whatever. 43 00:01:36,380 --> 00:01:37,180 We're not seeing it. 44 00:01:37,180 --> 00:01:38,340 We can't do anything. 45 00:01:38,480 --> 00:01:39,480 That's boring. 46 00:01:39,780 --> 00:01:42,600 So after some thinking, because I want to keep everything software based. 47 00:01:42,600 --> 00:01:43,800 I don't want to touch hardware. 48 00:01:43,800 --> 00:01:44,860 Like, yeah, there's a NAND flash. 49 00:01:44,860 --> 00:01:45,800 We can remove it. 50 00:01:45,800 --> 00:01:47,380 That's the last thing I want to do. 51 00:01:47,380 --> 00:01:51,720 Like, I'd rather go the software route because it's ripping crap out and I mess up. 52 00:01:51,720 --> 00:01:52,920 I got to buy a new one. 53 00:01:53,140 --> 00:01:54,260 Forget all that. 54 00:01:54,360 --> 00:01:57,380 So I just solder some, so it takes like a hot glue gun. 55 00:01:58,120 --> 00:02:01,360 You know, find an area on the board that has no copper exposed. 56 00:02:01,360 --> 00:02:03,020 Put a little bit of hot glue on there. 57 00:02:03,040 --> 00:02:04,120 Take some header pins. 58 00:02:04,120 --> 00:02:05,180 Just stick it on there. 59 00:02:05,180 --> 00:02:06,280 Wait for it to dry. 60 00:02:06,360 --> 00:02:09,020 And then I take some wires and I just, you know, solder it on. 61 00:02:09,120 --> 00:02:11,160 And it's not the prettiest thing in the world. 62 00:02:11,540 --> 00:02:13,580 But, you know, and then I just attach some wires. 63 00:02:13,580 --> 00:02:16,620 Put it on my FTDI base breakout board over here. 64 00:02:17,400 --> 00:02:20,360 Turn on OpenOCD with my configuration on my FTDI board. 65 00:02:20,360 --> 00:02:23,460 And we see automatically, boom, we do have a JTAG interface. 66 00:02:23,460 --> 00:02:24,700 We have the ID. 67 00:02:24,700 --> 00:02:26,680 We see the manufacturer ID is ARM base. 68 00:02:26,680 --> 00:02:27,480 Woohoo. 69 00:02:28,100 --> 00:02:31,500 So then we open up our own target configuration. 70 00:02:31,540 --> 00:02:32,980 So we set the reset config. 71 00:02:33,000 --> 00:02:34,040 We have test reset. 72 00:02:34,040 --> 00:02:35,000 We have system reset. 73 00:02:35,000 --> 00:02:36,600 It's a push-pull situation. 74 00:02:36,680 --> 00:02:40,020 We have a new, like, tab with the ID at the very end of it. 75 00:02:40,020 --> 00:02:43,920 And then we create a cortex A target that's little Indian. 76 00:02:44,020 --> 00:02:48,640 And then after that, we run it again with our two configurations, the board and the target. 77 00:02:48,640 --> 00:02:52,020 And look, oh, also we have six break points, four watch points. 78 00:02:52,080 --> 00: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. 79 00:02:59,710 --> 00: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. 80 00:03:06,650 --> 00:03:08,330 So I'm dumping memory addresses . 81 00:03:08,330 --> 00:03:11,630 If something is not, you know, unaccessible, I just write that out. 82 00:03:11,630 --> 00:03:15,570 So I'm dumping, dumping, dumping, halting the boot-up process at different stages. 83 00:03:15,570 --> 00:03:17,610 I'm trying to find the kernel boot arguments. 84 00:03:17,770 --> 00: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. 85 00:03:27,570 --> 00: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. 86 00:03:34,490 --> 00: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, 87 00:03:47,310 --> 00:03:50,790 you know, do a second retry and get into it, but, again, I don't want to touch hardware. 88 00:03:50,990 --> 00: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. 89 00:04:01,830 --> 00:04:06,790 We actually, can actually do something, and you actually probably saw me typing up some commands to load everything up. 90 00:04:07,370 --> 00:04:08,210 So great. 91 00:04:08,210 --> 00:04:12,950 So this gives us access to rip the firmware off and get debug capabilities, right? 92 00:04:12,950 --> 00: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. 93 00:04:19,930 --> 00:04:23,570 I don't care if it's WAN-based, LAN-based, everything's open scope in my eyes. 94 00:04:23,570 --> 00: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. 95 00:04:30,550 --> 00:04:34,510 Uh, IP tables can maybe come into play later, but we'll get into that later. 96 00:04:34,530 --> 00:04:38,890 So very first thing, I'm looking for low-hanging fruit, and someone please scrim it out. 97 00:04:38,890 --> 00:04:40,850 UDP 1900 is? 98 00:04:41,010 --> 00:04:42,190 Low-hanging fruit! 99 00:04:42,190 --> 00:04:42,730 Yes! 100 00:04:42,730 --> 00:04:43,250 Awesome! 101 00:04:43,250 --> 00:04:45,030 It is known as SSDP. 102 00:04:45,030 --> 00:04:47,610 It is a piece of crap, and everyone talks about it. 103 00:04:47,610 --> 00:04:51,970 But anyways, we have three binaries here, we have three different SSDB servers, WPS monitor. 104 00:04:51,970 --> 00:04:55,230 Frontier 4 is about a 32 megabyte C++ file. 105 00:04:55,230 --> 00:04:56,170 Have fun with that. 106 00:04:56,170 --> 00:04:57,410 It's kind of fun to look at. 107 00:04:57,410 --> 00:04:58,010 Fun. 108 00:04:58,110 --> 00: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. 109 00:05:03,330 --> 00:05:06,470 So anyways, today we're going to be talking about WPS monitor. 110 00:05:07,490 --> 00:05:11,090 So before I even start ripping things out, I need to know my environment. 111 00:05:11,330 --> 00:05:14,130 Um, because I need to know like, you know, do I need an info leak? 112 00:05:14,130 --> 00:05:15,730 Uh, do we have an executable stack? 113 00:05:15,730 --> 00:05:16,450 Do we have an executable heap? 114 00:05:16,450 --> 00:05:17,790 Well, what the hell am I looking at, right? 115 00:05:17,790 --> 00:05:22,630 So the very first things I do is I look at all, you know, there's a libupnp library. 116 00:05:22,650 --> 00:05:24,670 You can see like, oh, a libupnp. 117 00:05:24,670 --> 00:05:28,130 It's not the Intel one, so remove all like assumptions out of your head. 118 00:05:28,250 --> 00:05:30,910 Uh, and also we have ASLR on the imported libraries. 119 00:05:30,910 --> 00:05:31,490 Surprise. 120 00:05:31,670 --> 00:05:32,930 We look at a stack in the heap. 121 00:05:32,930 --> 00:05:33,710 We have depth. 122 00:05:33,710 --> 00:05:34,310 Awesome. 123 00:05:34,510 --> 00: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. 124 00:05:40,650 --> 00:05:41,230 Cool . 125 00:05:41,290 --> 00: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. 126 00:05:48,750 --> 00:05:49,610 We have a gadget. 127 00:05:49,610 --> 00: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. 128 00:05:58,650 --> 00: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, 129 00:06:13,650 --> 00:06:16,050 like always, and we extract the file system. 130 00:06:17,030 --> 00:06:19,930 So now we're going to get more into the nitty-gritty, happier stuff. 131 00:06:20,010 --> 00:06:20,850 Vuln hunting. 132 00:06:21,090 --> 00: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? 133 00:06:32,150 --> 00:06:35,430 It's like, oh, I looked at a string , found a vuln, and that's exactly what I do first. 134 00:06:35,430 --> 00: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? 135 00:06:41,870 --> 00:06:44,810 We have a buffer, or some sort of file descriptor in Linux, right? 136 00:06:44,810 --> 00: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? 137 00:06:51,110 --> 00:06:54,950 So I see this very first response, HP11, okay, blah, blah, blah. 138 00:06:54,950 --> 00: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. 139 00:07:02,210 --> 00:07:06,770 And that's very interesting to me, because I'm like, alright, what is this response, right? 140 00:07:06,770 --> 00:07:08,730 Like, what function is using this? 141 00:07:08,930 --> 00:07:13,150 So I see this immediately, looked at xrefs, and I'm like, oh, that's nice, sprintf. 142 00:07:13,170 --> 00: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? 143 00:07:19,050 --> 00:07:21,250 So just because it's sprintf doesn't mean it's vulnerable. 144 00:07:21,390 --> 00:07:24,570 So we look at where's r0, the destination buffer coming from. 145 00:07:24,610 --> 00: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. 146 00:07:30,370 --> 00: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. 147 00:07:37,530 --> 00:07:39,370 So we're accessing something. 148 00:07:39,370 --> 00: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. 149 00:07:44,530 --> 00:07:46,510 Like, you know, we get an address from Malik, we save it there. 150 00:07:46,510 --> 00:07:49,890 Maybe it's calculating the length beforehand and, you know, maybe it's not vulnerable, like I said. 151 00:07:49,890 --> 00:07:50,410 Who knows? 152 00:07:50,410 --> 00:07:54,470 Or maybe this is just a character buffer inside this structure that has a fixed size. 153 00:07:54,470 --> 00:07:55,250 Who knows? 154 00:07:55,250 --> 00:07:56,710 So we need to do more research. 155 00:07:56,870 --> 00:08:04,810 So next thing I do is I'm looking at the UPnP specifications, going , what is this message for? 156 00:08:04,830 --> 00: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. 157 00:08:14,330 --> 00:08:17,250 Something in our, we probably have second dash and some integer, right? 158 00:08:17,450 --> 00:08:19,470 So I'm like, well, what's causing this response? 159 00:08:19,470 --> 00:08:20,150 And we see this. 160 00:08:20,150 --> 00:08:21,050 It's called a subscribe. 161 00:08:21,470 --> 00:08:24,510 Subscribe publisher path, and I'll show you that, what's that, afterwards. 162 00:08:24,510 --> 00:08:25,770 We have something called a callback. 163 00:08:25,770 --> 00:08:28,530 Host and user agent are optional, so that's why they're not bold. 164 00:08:28,530 --> 00:08:30,150 Callback is mandatory. 165 00:08:30,210 --> 00:08:33,490 It is wrapped around angle brackets or less than, greater than, whatever. 166 00:08:33,690 --> 00:08:37,010 We have NT set to UPnP event, which is static, has to be that. 167 00:08:37,050 --> 00:08:40,470 And then we have timeout second dash, and then a request is duration. 168 00:08:40,470 --> 00:08:44,790 Second dash, again, probably an integer, second dash 20, second dash 900, whatever. 169 00:08:46,110 --> 00:08:47,710 So what is this for? 170 00:08:47,710 --> 00:08:48,570 Like, what part is this? 171 00:08:48,570 --> 00:08:49,870 What is the publisher path? 172 00:08:49,970 --> 00: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. 173 00:08:56,910 --> 00:09:01,050 But everyone talks about the control URL, the SOAP actions, and that's not what we're talking about today. 174 00:09:01,050 --> 00:09:04,310 We're talking about this, the event URL, which is called the Gina stat. 175 00:09:04,310 --> 00:09:07,490 I forgot what it stands for off the top of my head, but just trust me, it's called Gina. 176 00:09:08,870 --> 00: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. 177 00:09:16,590 --> 00:09:18,650 So we use, you know, requests. 178 00:09:18,650 --> 00: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. 179 00:09:25,890 --> 00: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. 180 00:09:31,170 --> 00: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. 181 00:09:35,310 --> 00:09:37,170 Like, that's not exploitable or anything worth looking at. 182 00:09:37,170 --> 00:09:38,470 So I need to dig deeper. 183 00:09:38,470 --> 00:09:42,790 So we just send it and awesome, I sent a string , I get a string back. 184 00:09:43,250 --> 00:09:44,450 That's awesome. 185 00:09:44,450 --> 00:09:47,190 So okay, this seems kind of interesting now. 186 00:09:47,190 --> 00:09:49,610 So that percent S is what we control . 187 00:09:49,630 --> 00:09:54,830 So okay, so next things we can do is we have two things we can do. 188 00:09:54,830 --> 00: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. 189 00:10:02,730 --> 00:10:04,610 Or, fuck it, we can just black box it, right? 190 00:10:05,490 --> 00: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. 191 00:10:12,810 --> 00: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. 192 00:10:19,470 --> 00: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. 193 00:10:31,970 --> 00:10:34,030 But this is supposed to be confidential. 194 00:10:34,430 --> 00:10:38,850 So I didn't have all this at the time, so screw it, we'll just black box it. 195 00:10:38,930 --> 00:10:39,570 Kobe. 196 00:10:39,670 --> 00:10:41,470 So, next thing. 197 00:10:42,170 --> 00:10:43,890 So I set up a for loop. 198 00:10:43,890 --> 00:10:45,930 That same exact code, just in a for loop. 199 00:10:45,930 --> 00:10:49,490 I'm incrementing now by one byte at a time, that second dash. 200 00:10:49,530 --> 00:10:51,130 And I have GDB attached. 201 00:10:51,130 --> 00:10:53,490 It's going to keep going and going and going and going and going and going. 202 00:10:53,490 --> 00:10:55,790 Any kind of reset sets to me, just try again, keep going. 203 00:10:55,790 --> 00:10:56,830 Right, just keep going. 204 00:10:56,830 --> 00:10:58,310 And I get a segmentation fault. 205 00:10:58,510 --> 00:11:02,030 I'm like, oh my god, there's probably static sizes, this is awesome. 206 00:11:02,030 --> 00:11:03,690 Oh my god, I got to call my dad. 207 00:11:03,770 --> 00:11:05,950 But hold on, let's not call my dad. 208 00:11:05,950 --> 00:11:08,250 Because this is just loading compare. 209 00:11:08,630 --> 00:11:10,790 We're not writing anything, we're just loading and comparing. 210 00:11:10,790 --> 00:11:12,610 That's not anything useful. 211 00:11:12,730 --> 00: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. 212 00:11:20,590 --> 00:11:24,150 But you know, we have this compare, it's looking at zero, it's going to branch out and return. 213 00:11:25,370 --> 00: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? 214 00:11:31,670 --> 00:11:33,310 What kind of requests can I send to this thing? 215 00:11:33,310 --> 00:11:37,210 We have an HP stack, we have a SOAP stack, SSP stack, we have this Gina stack. 216 00:11:37,370 --> 00:11:42,190 So, I start thinking, I'm like, well what kind of other states can I do this in? 217 00:11:42,210 --> 00:11:43,870 And I find this. 218 00:11:44,350 --> 00:11:47,490 And I'm not going to read this wallet text to you. 219 00:11:47,510 --> 00:11:54,370 Basically what this says is that once you subscribe, you get a SID , your unique identifier ID, right? 220 00:11:54,410 --> 00:11:57,290 So from there, let's say you subscribe for 20 seconds. 221 00:11:57,290 --> 00:11:58,310 And then you change your mind. 222 00:11:58,310 --> 00:12:01,310 No, no, no, no, I meant to subscribe for like 100 seconds. 223 00:12:01,530 --> 00:12:05,890 Well, you send a second subscription with your SID and with a new timeout value. 224 00:12:05,950 --> 00:12:09,710 I was like, oh, maybe we can like hit some new code with this type of thing. 225 00:12:09,710 --> 00:12:14,270 So, we subscribe first, save the SID, and then we cause the overflow and see what happens, right? 226 00:12:14,270 --> 00:12:15,710 So, I do the thing again. 227 00:12:15,870 --> 00:12:17,310 And we get a different site fault. 228 00:12:17,310 --> 00:12:20,990 I'm like, oh, better be something good, right ? 229 00:12:20,990 --> 00:12:26,390 So, I start looking, I'm like, oh, we see this load, you know, offset 24 to R3. 230 00:12:26,470 --> 00:12:28,950 We do a compare, a branch on zero. 231 00:12:28,950 --> 00:12:30,490 So, if it's null, we don't call it. 232 00:12:30,490 --> 00:12:31,530 You're not going to call null. 233 00:12:31,590 --> 00:12:34,310 And then it jumps to it with the exchange. 234 00:12:34,310 --> 00:12:37,350 So, we can jump modes like thumb mode, R mode, whatever, right? 235 00:12:37,630 --> 00:12:39,490 And I'm looking at this, I'm like, what's R3? 236 00:12:39,510 --> 00:12:40,870 I'm like, oh, that's the value I control. 237 00:12:40,870 --> 00:12:41,390 That's my name. 238 00:12:41,390 --> 00:12:42,170 That's awesome. 239 00:12:42,730 --> 00:12:43,850 So, okay. 240 00:12:44,230 --> 00:12:45,970 So, we have, so I got lucky, right? 241 00:12:45,970 --> 00:12:46,930 I got super lucky. 242 00:12:46,930 --> 00:12:47,610 But I don't care. 243 00:12:47,610 --> 00:12:48,610 That's my luck. 244 00:12:49,050 --> 00:12:52,410 So, going on, I kind of have a way to obtain PC control. 245 00:12:52,410 --> 00:12:54,790 We're one pointer away, right? 246 00:12:54,790 --> 00:12:56,210 We're almost there. 247 00:12:56,690 --> 00:13:01,270 Still can't use WPS monitor as a gadget because we're still bounded by the limitations of a string. 248 00:13:01,270 --> 00:13:03,510 Can't have a null byte because that's the terminator. 249 00:13:04,010 --> 00:13:06,470 Uh, ASLR and import libraries that don't have an infleek. 250 00:13:06,470 --> 00:13:07,610 So, whatever, right? 251 00:13:07,890 --> 00:13:10,530 So, now to the exploit development of this. 252 00:13:10,670 --> 00: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. 253 00:13:20,010 --> 00: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? 254 00:13:25,590 --> 00:13:28,290 IE8, 7, 4, 1, I don't care. 255 00:13:28,290 --> 00:13:29,030 Anyone? 256 00:13:29,830 --> 00:13:31,430 Yes, awesome, cool. 257 00:13:31,430 --> 00:13:33,510 So, that's exactly what it reminds me of. 258 00:13:33,630 --> 00:13:35,870 I'm like, okay, new tactic. 259 00:13:35,890 --> 00:13:37,270 Screw the infleek. 260 00:13:37,270 --> 00: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? 261 00:13:48,330 --> 00:13:52,390 And speaking of which, oh, whoops. 262 00:13:53,490 --> 00:13:55,510 I need to start this. 263 00:13:57,780 --> 00:14:01,800 So, you're about to witness the world's slowest exploit. 264 00:14:01,800 --> 00:14:05,740 My exploit takes about 20, 28 minutes and 30 seconds to run. 265 00:14:06,780 --> 00:14:08,880 So, we're going to start it. 266 00:14:09,080 --> 00:14:12,360 Just want to make sure it's running before I go back to my slides. 267 00:14:15,410 --> 00:14:16,550 All right. 268 00:14:16,550 --> 00:14:19,730 All right. 269 00:14:19,830 --> 00:14:21,770 One second, please. 270 00:14:23,990 --> 00:14:25,470 This is slow. 271 00:14:26,690 --> 00:14:27,310 All right. 272 00:14:27,310 --> 00:14:27,790 There we go. 273 00:14:27,790 --> 00:14:28,510 All right, cool. 274 00:14:29,470 --> 00:14:31,350 So, let's go back. 275 00:14:32,250 --> 00:14:32,890 All right. 276 00:14:32,930 --> 00:14:35,930 So, it says spray the heap, do some magic, trigger overflow, get code exec. 277 00:14:36,430 --> 00:14:37,790 So, we look at the heap. 278 00:14:37,790 --> 00:14:39,530 So, I need information now. 279 00:14:39,530 --> 00:14:42,470 What is the base address of this heap like loaded at every single time? 280 00:14:42,470 --> 00:14:45,590 So, I need a target address to maybe grow this heap torch, right? 281 00:14:47,350 --> 00: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. 282 00:14:58,630 --> 00:14:59,330 That's okay. 283 00:14:59,330 --> 00:15:00,850 You know, we can do that later, right? 284 00:15:00,850 --> 00:15:02,370 We can do more off screen. 285 00:15:02,370 --> 00:15:03,310 That's boring. 286 00:15:03,550 --> 00:15:09,190 So, also I need to know how much memory do I have? 287 00:15:09,190 --> 00:15:13,350 Like Internet Explorer, everyone had like, you know, maybe back in the day like 512 megs. 288 00:15:13,350 --> 00:15:14,710 Yeah, my age is showing, right? 289 00:15:14,710 --> 00:15:15,910 Or, you know, at least a gig. 290 00:15:15,910 --> 00: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. 291 00:15:21,470 --> 00:15:23,290 But we have 117 megabytes free. 292 00:15:23,470 --> 00:15:26,590 Or, you know, I don't want to be, you know, taking up everything. 293 00:15:26,590 --> 00:15:28,150 So, let's just call it 100. 294 00:15:28,230 --> 00:15:29,290 100 megs. 295 00:15:29,290 --> 00:15:33,410 So, theoretically, if the heap always loads at zero, just think about that. 296 00:15:33,490 --> 00:15:38,830 The maximum size I can grow the heap to is 06060606 or whatever, right? 297 00:15:39,010 --> 00:15:39,870 So, awesome. 298 00:15:39,870 --> 00:15:44,650 I can grow the heap to a very large size potentially if I find a printer to allow me to. 299 00:15:44,650 --> 00: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? 300 00:15:53,270 --> 00:15:58,430 Like, what's the, you know, like, what's the highest address the heap actually loads onto and stuff like that? 301 00:15:58,430 --> 00:16:01,530 So, actually you saw that it loads under 0303 all the time. 302 00:16:01,530 --> 00:16:05,290 We see like an 0210, but it always loads under 03, 03, 03. 303 00:16:05,290 --> 00:16:06,230 So, I'm like, alright, cool. 304 00:16:06,590 --> 00:16:09,650 So, I start looking at the description functionality. 305 00:16:09,650 --> 00:16:10,690 Like, how does this work? 306 00:16:10,690 --> 00:16:11,770 I need to find primitives. 307 00:16:11,770 --> 00:16:12,670 I need to fill the heap. 308 00:16:12,670 --> 00:16:14,070 I need to do memory leak. 309 00:16:14,070 --> 00:16:15,590 Not info leak, memory leak. 310 00:16:15,590 --> 00:16:16,830 I need to fill up the heap. 311 00:16:16,990 --> 00:16:18,470 So, I start looking at this. 312 00:16:19,110 --> 00:16:22,330 So, I start looking at Stirling and it goes to a Calic. 313 00:16:22,450 --> 00:16:27,730 And I find out that that pointer there is the starting, it's the URL portion of the callback. 314 00:16:27,730 --> 00:16:32,550 So, after the IP colon port slash and then the end of it, that's, that's where we're at. 315 00:16:32,550 --> 00:16:33,570 So, that's where that pointer's to. 316 00:16:33,570 --> 00:16:35,970 That's slash and then like ABCD, right? 317 00:16:36,370 --> 00:16:40,250 The, the closing bracket is null terminated at this point. 318 00:16:40,250 --> 00:16:41,350 So, we're just slash. 319 00:16:41,690 --> 00:16:44,150 And then after that, we add some sort of size to it. 320 00:16:44,150 --> 00:16:45,890 So, it's going to be the size of some structure, right? 321 00:16:45,890 --> 00:16:46,790 So, we have some structure. 322 00:16:47,130 --> 00:16:50,050 And where the last element is some character buffer array. 323 00:16:50,090 --> 00:16:51,390 And then we call Calic. 324 00:16:51,390 --> 00: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. 325 00:16:57,450 --> 00:16:58,550 This is a very high level. 326 00:16:58,590 --> 00:17:03,630 And then it calls Malik, gets a pointer back , memsets it, and returns it back to you. 327 00:17:03,630 --> 00:17:05,190 So, everything's going to be initialized to zero. 328 00:17:05,190 --> 00:17:08,190 There's some other crap that goes on in there, but it's not relevant to this. 329 00:17:08,290 --> 00:17:09,530 So, we go into GDB. 330 00:17:09,650 --> 00:17:10,810 We set some break points. 331 00:17:11,650 --> 00:17:14,470 And, you know, we get the length and we get the return address. 332 00:17:14,470 --> 00:17:17,090 Because I need to learn how to, you know, I need to start spraying this stuff. 333 00:17:17,170 --> 00:17:20,970 So, I set up a for loop to subscribe over and over and over and over and over again. 334 00:17:21,330 --> 00:17:23,630 And crap. 335 00:17:24,310 --> 00:17:24,750 All right. 336 00:17:24,750 --> 00:17:26,970 I'm getting the same pointer over and over again. 337 00:17:26,970 --> 00:17:30,890 So, in my head, I'm like, all right, so, it's being freed, alecked again. 338 00:17:30,990 --> 00:17:31,930 Freed, alecked again. 339 00:17:31,930 --> 00:17:32,990 Freed, alecked again. 340 00:17:33,150 --> 00:17:35,370 What, what, like, what the hell is going on? 341 00:17:35,750 --> 00:17:37,390 So, step back. 342 00:17:37,390 --> 00: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. 343 00:17:48,970 --> 00:17:49,470 Right? 344 00:17:49,470 --> 00: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. 345 00:17:57,570 --> 00:18:00,770 So, I go, well, let's change something in my subscription. 346 00:18:00,770 --> 00:18:04,170 We can change IP address maybe, change the port number, change the URL. 347 00:18:04,270 --> 00: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. 348 00:18:11,310 --> 00: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. 349 00:18:19,590 --> 00:18:20,330 Awesome. 350 00:18:20,330 --> 00:18:22,210 I have a way to fill the heap. 351 00:18:22,210 --> 00:18:24,690 So, in theory, this is what I'm doing. 352 00:18:24,690 --> 00:18:30,910 Subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe. 353 00:18:31,530 --> 00:18:35,450 So, we're just filling up the heap with a bunch of subscriptions with Different port numbers. 354 00:18:36,290 --> 00:18:37,470 Okay, cool, that's cool. 355 00:18:37,470 --> 00:18:38,610 You can fill the heap. 356 00:18:38,910 --> 00:18:40,010 We can spray the heap. 357 00:18:40,170 --> 00:18:43,050 But we still need to do some dope David Blaine magic, all right? 358 00:18:43,050 --> 00:18:46,030 Then we go to street magic, you know, some crazy shit. 359 00:18:46,230 --> 00:18:48,050 So I start reading the manual some more. 360 00:18:48,050 --> 00:18:50,590 We go back to the architect, you know, the specifications. 361 00:18:50,810 --> 00:18:52,590 And I see this request now. 362 00:18:52,730 --> 00:18:55,350 Unsubscribe with the publisher path with your SID. 363 00:18:55,750 --> 00:18:57,430 I'm like, all right, let's go back to the code. 364 00:18:57,430 --> 00:18:59,550 And I find this function called delete subscriber. 365 00:18:59,550 --> 00:19:01,270 I wonder what it does. 366 00:19:01,510 --> 00:19:05,990 And I see this little wrapper of free here, which literally just takes the pointer and passes the free. 367 00:19:06,190 --> 00:19:07,530 So I set a break point there. 368 00:19:07,530 --> 00:19:09,110 I go, well, what is this pointer, right? 369 00:19:09,110 --> 00:19:10,790 We have run time capabilities. 370 00:19:10,790 --> 00:19:13,270 I don't feel like spending all the time reversing all the things. 371 00:19:13,270 --> 00:19:15,230 Don't limit yourself to just one way. 372 00:19:15,230 --> 00:19:16,570 Use the easiest ways. 373 00:19:16,610 --> 00: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. 374 00:19:24,670 --> 00:19:25,710 These are my blocks. 375 00:19:25,710 --> 00:19:27,210 I'm using the, oh, awesome. 376 00:19:27,210 --> 00: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? 377 00:19:34,490 --> 00:19:36,470 So back to monkeying around. 378 00:19:38,090 --> 00: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. 379 00:19:44,970 --> 00:19:46,090 I can't do anything yet. 380 00:19:46,090 --> 00:19:46,950 I can fill up the heap. 381 00:19:46,950 --> 00:19:48,030 That's fun. 382 00:19:48,150 --> 00:19:51,170 But, you know, I can't use WPS monitor as a gadget yet. 383 00:19:51,290 --> 00:19:56,030 So I start talking to a colleague who works on different products but also has experiences with heap stuff. 384 00:19:56,030 --> 00:19:58,230 I'm just bouncing ideas back and forth with my colleague. 385 00:19:58,310 --> 00:19:59,510 It's kind of like rubber ducking. 386 00:19:59,530 --> 00:20:00,850 So I send him my IDB. 387 00:20:00,850 --> 00:20:02,570 I'm like, hey, man, I'm looking at this. 388 00:20:02,810 --> 00:20:04,290 You know, this is my limitations. 389 00:20:04,290 --> 00:20:05,470 This is what I can do so far. 390 00:20:05,550 --> 00:20:08,990 You know, you can look at all the references to malloc, calloc. 391 00:20:09,090 --> 00:20:11,270 If you're super hardcore, xmalloc. 392 00:20:11,270 --> 00:20:13,250 If you turn null, kill the application. 393 00:20:13,250 --> 00:20:14,030 Super hardcore. 394 00:20:14,230 --> 00:20:16,790 But we start going back forth and he asks me a question. 395 00:20:16,790 --> 00:20:20,510 He goes, hey, this function here about base64 decoding uses malloc. 396 00:20:20,510 --> 00:20:21,690 What is that all about? 397 00:20:21,710 --> 00:20:23,310 Like a UPnP, base64. 398 00:20:23,330 --> 00:20:24,490 I'm like, oh, shit. 399 00:20:24,510 --> 00:20:25,070 Awesome. 400 00:20:25,070 --> 00:20:28,610 So we go back to SOAP, the thing I did not want to talk about whatsoever. 401 00:20:28,610 --> 00:20:31,670 And I start looking for an action with one argument. 402 00:20:31,830 --> 00:20:35,310 Because I don't want to deal with multiple arguments and it just gets kind of messy. 403 00:20:35,310 --> 00:20:35,970 And I find this. 404 00:20:35,970 --> 00:20:37,290 This delete AP settings. 405 00:20:37,290 --> 00:20:37,730 Sure. 406 00:20:37,730 --> 00:20:38,310 Whatever. 407 00:20:38,410 --> 00:20:41,810 What kind of type is this new AP settings argument? 408 00:20:41,810 --> 00:20:43,410 Go all the way down to the bottom of XML. 409 00:20:43,410 --> 00:20:44,990 We see it's a base64 type. 410 00:20:45,110 --> 00: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. 411 00:20:51,690 --> 00:20:53,910 I can base64 encode nulls. 412 00:20:53,910 --> 00:20:54,630 Okay. 413 00:20:54,910 --> 00:20:56,810 So what I do next is like, alright. 414 00:20:56,990 --> 00:21:01,390 So when I send this, when I send the SOAP action, I set a breakpoint, I look at the heap block. 415 00:21:01,430 --> 00:21:04,370 And it's actually the decoded data that I sent to it. 416 00:21:04,370 --> 00:21:06,250 It's not the base64 string. 417 00:21:06,410 --> 00:21:06,910 Awesome. 418 00:21:06,910 --> 00: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. 419 00:21:14,390 --> 00:21:16,350 So, I try this out. 420 00:21:16,550 --> 00:21:17,390 So we do it. 421 00:21:17,390 --> 00:21:18,630 We unsubscribe. 422 00:21:18,790 --> 00:21:20,390 We call the SOAP action. 423 00:21:20,550 --> 00:21:21,630 We unsubscribe. 424 00:21:21,730 --> 00:21:23,090 We call the SOAP action. 425 00:21:23,210 --> 00:21:23,850 Unsubscribe. 426 00:21:23,850 --> 00:21:24,830 And then I look at this. 427 00:21:24,830 --> 00:21:26,710 This is early development of my structure. 428 00:21:26,770 --> 00:21:28,530 That's why you see like 02, 02, 03, 03. 429 00:21:28,530 --> 00:21:29,870 Just lining everything up. 430 00:21:29,870 --> 00:21:31,730 The very first one is my first gadget. 431 00:21:31,730 --> 00:21:32,610 So whatever. 432 00:21:32,690 --> 00:21:34,730 But I'm trying to set things up. 433 00:21:34,730 --> 00: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. 434 00:21:38,510 --> 00:21:39,290 So, okay. 435 00:21:39,290 --> 00:21:40,750 We can spray the heap now. 436 00:21:40,830 --> 00:21:43,130 We're kind of almost there doing some magic. 437 00:21:43,310 --> 00:21:44,290 But wait. 438 00:21:44,410 --> 00:21:45,090 Roadblock. 439 00:21:45,090 --> 00:21:45,350 Alright. 440 00:21:45,350 --> 00:21:46,070 I do my spray. 441 00:21:46,070 --> 00: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. 442 00:21:50,370 --> 00:21:51,170 Shit. 443 00:21:51,230 --> 00:21:51,590 Alright. 444 00:21:51,910 --> 00:21:53,350 Well, what's going on? 445 00:21:53,430 --> 00:21:59,450 So, to think about it in layman's terms, like super simplistic, you can't build a house without a roof. 446 00:21:59,450 --> 00:21:59,990 Right? 447 00:21:59,990 --> 00:22:01,270 That seems silly. 448 00:22:01,350 --> 00:22:04,290 So my technique right now, I'm like, you know, I got all these descriptions. 449 00:22:04,350 --> 00:22:05,350 I unsubscribe. 450 00:22:05,470 --> 00:22:06,550 Do a SOAP action. 451 00:22:06,550 --> 00:22:07,450 I unsubscribe. 452 00:22:07,450 --> 00:22:08,690 Do a SOAP action. 453 00:22:08,750 --> 00:22:09,310 Unsubscribe . 454 00:22:09,310 --> 00:22:09,790 SOAP action. 455 00:22:09,790 --> 00:22:11,490 You know, blah, blah, blah, blah. 456 00:22:11,490 --> 00:22:15,410 And we're going down the line and, you know, and, and then the rest. 457 00:22:15,410 --> 00:22:15,890 Right? 458 00:22:16,190 --> 00: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. 459 00:22:24,730 --> 00: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. 460 00:22:29,490 --> 00:22:29,970 Right? 461 00:22:30,150 --> 00:22:31,390 So, that's what's going on. 462 00:22:31,390 --> 00:22:37,770 So I'm like thinking, I'm like, well, instead of freeing everything, what if I leave the last allocation there? 463 00:22:37,770 --> 00: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. 464 00:22:43,970 --> 00:22:47,230 It's forever until the, no, until it like reboots or something. 465 00:22:47,310 --> 00: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. 466 00:22:59,070 --> 00:22:59,750 Right? 467 00:23:00,170 --> 00:23:01,830 So, this is awesome. 468 00:23:01,830 --> 00:23:09,330 So this is working fine until, come on, until this happens. 469 00:23:09,330 --> 00:23:15,810 So my, my way to do the base 64 thing is writing to the same block over and over again. 470 00:23:15,810 --> 00: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. 471 00:23:22,050 --> 00:23:23,850 It's not, it's something else is racing to it. 472 00:23:23,850 --> 00:23:25,490 Something else is causing some issues. 473 00:23:25,510 --> 00:23:28,570 So now I've got to figure out what the hell is being freed. 474 00:23:28,570 --> 00:23:31,010 So I'm going to set just a simple break point on free. 475 00:23:31,010 --> 00:23:35,610 If it's null, just keep going, I don't care about null being passed or freed. 476 00:23:35,890 --> 00:23:38,810 Um, so we just keep going, and we're just going to wait. 477 00:23:39,010 --> 00: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, 478 00:23:52,230 --> 00:23:54,170 and it's not really worth going for anymore. 479 00:23:54,330 --> 00:23:57,290 So I look at it, and I'm like, alright, let me send an msearch request. 480 00:23:57,290 --> 00: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, 481 00:24:11,630 --> 00: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. 482 00:24:18,530 --> 00:24:22,690 But anyways, we send an msearch request, we see that there's pointers being freed, okay? 483 00:24:22,810 --> 00:24:25,970 We find the sizes by looking at the heap header manual and stuff like that. 484 00:24:25,970 --> 00:24:30,950 Um, so every 60 seconds, this device sends out a notify request on multicast. 485 00:24:30,950 --> 00: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. 486 00:24:37,650 --> 00: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. 487 00:24:46,890 --> 00: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. 488 00:24:55,050 --> 00:24:57,050 So that now I have two arenas. 489 00:24:57,050 --> 00:25:01,230 So I have one arena where I have spaces for these objects to fit into perfectly. 490 00:25:01,230 --> 00:25:03,570 And they can jump in there all they want, because I'm making holes. 491 00:25:03,570 --> 00:25:05,430 It'll never get, like, condensed or whatever. 492 00:25:05,430 --> 00:25:06,730 It may get trimmed, doesn't matter. 493 00:25:06,730 --> 00:25:11,210 Then I have my other arena where I have that last allocation being set and I do the whole thing. 494 00:25:11,210 --> 00:25:12,810 So now we shift gears. 495 00:25:12,910 --> 00:25:18,850 So now what I'm doing is a free, replace, free, replace, free, replace, blah, blah, blah. 496 00:25:18,850 --> 00:25:21,330 And then we do an allocation back up. 497 00:25:21,330 --> 00:25:24,570 So we resubscribe and we come back down. 498 00:25:24,570 --> 00:25:29,950 And also what we're doing is between every single iteration is that we have a UDP socket listening on multicast. 499 00:25:29,950 --> 00: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. 500 00:25:42,070 --> 00:25:45,330 So, next, we can spray the heap. 501 00:25:45,330 --> 00:25:46,330 We can do some magic now. 502 00:25:46,330 --> 00:25:47,950 We can now use WPS monitor. 503 00:25:47,950 --> 00:25:51,030 We can write nulls to the heap and stuff like that, I guess, basics for decoding. 504 00:25:51,030 --> 00:25:51,870 That's awesome. 505 00:25:51,990 --> 00:25:53,850 Uh, but we don't have an exploit chain yet. 506 00:25:54,150 --> 00: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? 507 00:25:59,110 --> 00: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. 508 00:26:09,830 --> 00:26:13,210 But anyways, the only register that we have control of really is R4. 509 00:26:13,290 --> 00:26:15,250 R4 points to our overflow string. 510 00:26:15,270 --> 00: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. 511 00:26:23,570 --> 00:26:25,970 So I have a pointer that points to my data. 512 00:26:26,350 --> 00:26:27,710 That's all I have. 513 00:26:27,790 --> 00:26:31,130 So I start looking online, I'm like, alright, let's look, think back about Internet Explorer days. 514 00:26:31,290 --> 00:26:32,390 Uh, you know, what did we do? 515 00:26:32,390 --> 00:26:34,110 Oh, we did a stack pivot, right? 516 00:26:34,250 --> 00:26:36,530 Uh, we have, like, one shot, so we do a stack pivot. 517 00:26:36,530 --> 00: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. 518 00:26:41,870 --> 00:26:42,270 Wee! 519 00:26:42,310 --> 00:26:44,670 Uh, if we have depth, we have a bunch of returns. 520 00:26:44,710 --> 00: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. 521 00:26:52,970 --> 00:26:54,890 So I start looking online and I see this. 522 00:26:55,170 --> 00: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. 523 00:27:02,770 --> 00:27:04,010 And what, what does it do really? 524 00:27:04,010 --> 00: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. 525 00:27:10,670 --> 00:27:11,710 I'm like, oh, man, god. 526 00:27:11,710 --> 00: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. 527 00:27:24,090 --> 00:27:25,350 Well, what the hell? 528 00:27:25,590 --> 00:27:26,530 Like, what? 529 00:27:26,530 --> 00:27:27,250 Why? 530 00:27:27,250 --> 00: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. 531 00:27:34,110 --> 00:27:38,490 The destination list that I had before has SP, the second to last one. 532 00:27:38,490 --> 00:27:40,090 This is now an illegal instruction. 533 00:27:40,090 --> 00:27:42,530 I can't use this technique on this device. 534 00:27:42,550 --> 00:27:44,130 So, alright, back to the drawing board. 535 00:27:44,130 --> 00:27:47,590 So what I do next is I develop a regex for IDA. 536 00:27:47,790 --> 00: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. 537 00:27:55,390 --> 00:27:56,690 That's all, that's what I want. 538 00:27:56,690 --> 00: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. 539 00:28:01,770 --> 00: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. 540 00:28:08,130 --> 00:28:11,710 I'm spraying 4K blocks here, hex 1000 is 4K. 541 00:28:11,710 --> 00:28:16,150 So we're just going to jump into another block that I, I'm in control of with my data. 542 00:28:16,150 --> 00:28:20,150 So this right here gives me the primitive of calling a function with two arguments. 543 00:28:20,410 --> 00:28:21,610 Okay, cool. 544 00:28:21,650 --> 00: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. 545 00:28:31,130 --> 00:28:33,250 So I only have a one shot situation. 546 00:28:33,270 --> 00:28:35,630 So I'm thinking, I'm like, what can I do? 547 00:28:35,770 --> 00: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. 548 00:28:42,950 --> 00:28:44,330 So I started looking at mem copies. 549 00:28:44,330 --> 00:28:45,610 This thing has tons of them. 550 00:28:45,610 --> 00: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. 551 00:28:55,850 --> 00:28:57,670 I know it's probably hard in the back and I apologize. 552 00:28:57,670 --> 00:28:58,750 I'll sum it up. 553 00:28:58,750 --> 00:29:05,590 So this right here, if you look at the second to last instruction, R0, the destination, is a stack based buffer. 554 00:29:05,590 --> 00: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. 555 00:29:13,630 --> 00:29:18,790 And R0 and R1 are in our control now because that was the last gadget that gave us control. 556 00:29:18,790 --> 00:29:25,130 And R1's in R4, R0's in R5, we look in, R4 is N, R5 is the source. 557 00:29:25,170 --> 00: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. 558 00:29:30,310 --> 00:29:31,790 Just clobber the shit out of the stack. 559 00:29:31,790 --> 00:29:32,770 I control N. 560 00:29:32,770 --> 00:29:34,390 I can clobber the shit out of the stack. 561 00:29:34,390 --> 00:29:35,450 So that's what I do. 562 00:29:35,630 --> 00: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. 563 00:29:39,810 --> 00:29:41,530 This is a large adjustment, 2K. 564 00:29:41,710 --> 00:29:43,930 So we're not going to jump back and do stuff. 565 00:29:43,930 --> 00:29:45,810 We're now just incrementing the stack. 566 00:29:45,810 --> 00: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. 567 00:29:52,150 --> 00:29:57,330 So now we have control of R4 to R7 because now we brought the heap to the stack. 568 00:29:57,650 --> 00:29:59,330 So now, next gadget. 569 00:29:59,470 --> 00: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. 570 00:30:08,950 --> 00:30:10,970 But with the pointer of minus 4. 571 00:30:10,970 --> 00:30:13,030 And this next slide you'll see why. 572 00:30:13,650 --> 00:30:16,790 So then after that we pop from the stack R3 to R7 PC. 573 00:30:16,790 --> 00:30:17,750 Next thing. 574 00:30:17,770 --> 00: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. 575 00:30:29,670 --> 00:30:32,450 Now we're inside libc at str2 unsigned long. 576 00:30:32,450 --> 00:30:34,170 We don't need to leak it anymore . 577 00:30:34,170 --> 00:30:35,470 Pop from the stack. 578 00:30:35,490 --> 00:30:36,250 Next one. 579 00:30:36,250 --> 00:30:39,490 We add R3 because look, we have R3 to R7. 580 00:30:39,750 --> 00:30:42,190 R3, uh, it's going to be an offset now. 581 00:30:42,190 --> 00: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. 582 00:30:46,690 --> 00: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. 583 00:30:55,090 --> 00: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, 584 00:31:09,990 --> 00: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. 585 00:31:18,070 --> 00: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. 586 00:31:24,670 --> 00:31:25,470 We don't care. 587 00:31:25,470 --> 00:31:26,770 We're going to write to the heap now. 588 00:31:26,770 --> 00:31:30,430 We have a pointer to P open and all these gadgets I found by hand. 589 00:31:30,430 --> 00:31:34,250 If I try to use some wrapper thing and try to automate it , I would not have found these gadgets. 590 00:31:34,430 --> 00:31:35,130 Wrapper and everything. 591 00:31:35,130 --> 00: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. 592 00:31:40,490 --> 00:31:41,630 It's not going to tell me that. 593 00:31:41,630 --> 00:31:44,090 So anyways, this right here, I'm going to write to the heap. 594 00:31:44,090 --> 00:31:49,010 I'm going to write the P open pointer that I just calculated into the heap now. 595 00:31:49,070 --> 00:31:49,850 Keep going. 596 00:31:49,850 --> 00:31:53,090 We're almost kind of towards the end of the stack limitations here. 597 00:31:53,090 --> 00:31:57,590 So now I invoke gadget one again, which is our last gadget, gadget seven. 598 00:31:57,690 --> 00:32:00,810 So this one, remember, I can call something with two arguments. 599 00:32:00,810 --> 00:32:02,570 So R2 is going to be P open. 600 00:32:02,630 --> 00:32:04,130 R0 is going to be a string. 601 00:32:04,130 --> 00:32:07,930 R1 is going to be R because you have to provide something for P open. 602 00:32:08,070 --> 00:32:09,990 And then, okay, cool. 603 00:32:09,990 --> 00:32:11,030 So let's put it all together. 604 00:32:11,090 --> 00:32:12,310 So we spray the heap. 605 00:32:12,310 --> 00:32:14,190 We save all the subscription IDs. 606 00:32:14,270 --> 00:32:17,290 We don't free the last subscription ID, that's our roof. 607 00:32:17,910 --> 00: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. 608 00:32:26,790 --> 00:32:31,930 Everything is aligned to 256, or actually, yeah, so everything is 256 by the line, whatever. 609 00:32:32,030 --> 00:32:36,010 So we free five, reoccupy five, free them again, go to the next five. 610 00:32:36,010 --> 00:32:40,590 If anything comes in multicast, fix up the heap if needed by doing resubscriptions and freeze again. 611 00:32:41,370 --> 00:32:43,850 Trigger volume, maybe we win. 612 00:32:43,850 --> 00:32:46,930 So we sue everything and we see this, right? 613 00:32:46,990 --> 00:32:49,310 So let's check out this guy. 614 00:32:49,910 --> 00:32:51,730 Why is it at 11%? 615 00:32:54,130 --> 00:32:55,090 No! 616 00:32:55,710 --> 00:32:57,250 It is at 11%. 617 00:32:57,250 --> 00:33:00,930 Why is it 11%? 618 00:33:00,930 --> 00:33:01,390 All right. 619 00:33:01,390 --> 00:33:03,910 So I guess I'm not doing the exploit live anymore. 620 00:33:03,910 --> 00:33:05,190 That sucks. 621 00:33:05,490 --> 00:33:07,070 Oh, that sucks. 622 00:33:08,370 --> 00:33:09,630 Oh, no. 623 00:33:09,630 --> 00:33:10,530 Why? 624 00:33:11,450 --> 00:33:12,770 It's on. 625 00:33:12,810 --> 00:33:13,310 All right. 626 00:33:13,310 --> 00:33:13,970 I'm sorry. 627 00:33:13,970 --> 00:33:15,590 I guess I'm not doing this live. 628 00:33:15,590 --> 00:33:16,650 It is reliable. 629 00:33:16,650 --> 00:33:19,150 I can demo it later if you guys want to see it. 630 00:33:19,490 --> 00:33:20,610 But it's all right. 631 00:33:20,910 --> 00:33:22,630 We're stuck at 11%. 632 00:33:22,630 --> 00:33:30,190 What we were doing, though, was the free and replace of everything that we were doing. 633 00:33:30,190 --> 00:33:32,970 We create two arenas and we're going all the way down. 634 00:33:32,970 --> 00:33:35,610 It should have been around 60% by now or so. 635 00:33:35,690 --> 00:33:37,110 So that's all right. 636 00:33:37,930 --> 00:33:40,210 Man, let's see down here. 637 00:33:41,270 --> 00: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. 638 00:33:49,550 --> 00:33:54,830 But the funny part about this as well, just to look up, is that there's actually one process. 639 00:33:55,530 --> 00:33:56,570 Let's see here. 640 00:33:56,570 --> 00:33:59,210 One process ran by nobody. 641 00:33:59,390 --> 00:34:00,930 It's another UPnP server. 642 00:34:00,930 --> 00:34:07,510 So whoever actually made the process, you know, the process run under nobody, like, that guy deserves a high five. 643 00:34:07,630 --> 00:34:09,810 So anyways, let's go back to everything. 644 00:34:12,090 --> 00:34:13,950 Man, I really wanted to show that shell. 645 00:34:13,950 --> 00:34:15,090 Oh, well, it's actually still going. 646 00:34:15,090 --> 00:34:16,290 It's just going really slow. 647 00:34:16,710 --> 00:34:19,090 Anyways, so we do have a shell. 648 00:34:19,090 --> 00:34:22,030 And I wanted to show you guys some bonus stuff as well. 649 00:34:22,030 --> 00: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. 650 00:34:31,530 --> 00:34:35,090 And I found one 5916 that was being filtered by IP tables. 651 00:34:35,490 --> 00: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? 652 00:34:42,150 --> 00:34:48,150 So we set the callback address to 120 localhost 5916 with this URL. 653 00:34:48,350 --> 00:34:52,130 And so we attach strace to that daemon to see if anything's coming in. 654 00:34:52,130 --> 00:34:55,290 We send the request, and yes, we do get that. 655 00:34:55,290 --> 00: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, 656 00:35:06,830 --> 00:35:10,650 you can use this to maybe hit that part of the code, maybe change configuration or something like that. 657 00:35:10,650 --> 00:35:11,970 So it's a way to pivot. 658 00:35:12,290 --> 00: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. 659 00:35:20,730 --> 00:35:26,470 But I mean, after all this, so finding the vuln and all that stuff taught me something valuable. 660 00:35:26,470 --> 00:35:29,830 So I was doing this by hand, and I was like, you know what? 661 00:35:29,830 --> 00:35:33,930 I've been finding a lot of the same kind of programming issues with this protocol and stuff like that. 662 00:35:33,930 --> 00: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. 663 00:35:40,130 --> 00:35:43,350 And I encourage everyone else to do this as well, because what do we have ? 664 00:35:43,350 --> 00:35:45,330 We just have HP, we have XML. 665 00:35:45,570 --> 00: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. 666 00:35:56,850 --> 00:35:58,350 You'll save so much time. 667 00:35:58,350 --> 00: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. 668 00:36:02,490 --> 00:36:04,070 So actually, let's see. 669 00:36:04,750 --> 00:36:05,830 Now it's going. 670 00:36:05,830 --> 00:36:06,750 It's going now. 671 00:36:06,750 --> 00: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. 672 00:36:15,110 --> 00:36:19,610 So anyways, man, everything going wrong is. 673 00:36:19,610 --> 00:36:20,030 That's awesome. 674 00:36:20,030 --> 00: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. 675 00:36:27,190 --> 00:36:31,270 If an ISP asks you, could you, would you install this router in your house? 676 00:36:31,370 --> 00:36:34,470 You must say, no, I do not, would not install this in my house. 677 00:36:34,470 --> 00:36:35,550 I do not want it here or there. 678 00:36:35,550 --> 00:36:36,710 I do not want it anywhere. 679 00:36:36,710 --> 00:36:37,590 I wouldn't want it for free. 680 00:36:37,590 --> 00:36:39,670 I wouldn't want it if it could download up to 10 GB. 681 00:36:39,670 --> 00:36:42,990 But anyways, that's enough of that stuff. 682 00:36:42,990 --> 00:36:44,430 This is who I am. 683 00:36:44,450 --> 00:36:46,250 So I go by Black Owl Online. 684 00:36:46,730 --> 00:36:50,350 Someone had the real name Black Owl, so I changed the L21020. 685 00:36:50,410 --> 00:36:50,850 Cool. 686 00:36:50,850 --> 00:36:51,430 Elite sauce. 687 00:36:51,430 --> 00:36:52,150 What up? 688 00:36:52,390 --> 00:36:55,050 I'm a zero-day researcher at Exodus Intelligence. 689 00:36:55,130 --> 00:37:01,870 I do embedded devices, both SOHO, I do enterprise network solutions, firewalls, virtual appliances, whatever. 690 00:37:01,870 --> 00:37:02,410 I don't care. 691 00:37:02,410 --> 00:37:04,570 If I can get it, I'm going to audit it. 692 00:37:04,570 --> 00:37:07,690 Smart devices or anything else that catches my eye. 693 00:37:07,770 --> 00:37:09,970 We're also hiring at Exodus Intelligence. 694 00:37:09,970 --> 00:37:14,010 We're looking for another zero-day researcher if you're interested for getting paid for finding no-days. 695 00:37:14,010 --> 00:37:16,490 I get a bonus on top of that for selling your phones to us. 696 00:37:16,550 --> 00:37:17,530 Like, you know, hit me up. 697 00:37:17,690 --> 00:37:18,790 But that's about it. 698 00:37:18,790 --> 00:37:20,250 So again, that's who I am. 699 00:37:20,250 --> 00:37:23,150 Thank you for coming to my talk labeled Green Waves in Ham. 700 00:37:23,250 --> 00:37:24,050 Take care.