Without further ado, this is Elvis Cayado. He's going to be presenting on some really cool research that he manipulated. Yeah, sure. All right. Awesome. Thank you so much for joining us. And here we go. Test. Is that good? All right. Thank you everyone and welcome for coming. This is my talk called green waves and ham. All right. Let's get started. So this device up here that you see is called the green wave G1100. It was distributed by Verizon Fios and Frontier. They're an ISP up in the northeast. And we have Verizon for the file service. It was not available in my area, but this is what they gave you. So if we look a little there, we got our FCC ID. So what do we do with our FCC ID? We go online and we find the internal photos and then we find the processor and we look it up. There's no data sheet for that, unfortunately, but we see the shield is on cover. We see two memory modules. And if you see something like over here, you may be going, hey, what's going on over here? Well, you have every reason right to be, because this over here is JTAG. Awesome. So I just grabbed my, I think it was like JTAGulator or my Arduino. It's 3-3 logic, so it doesn't really matter. Got the pin outs. So this in the middle, open up the device, this thing right here. In the middle we have four pins. And what do you think it is? You are right. So we have ground, receive, transmit, 3-3. Unfortunately, when we turn on the device, standard in is blocked. So all we get is standard out. So receive is, you know, we can't type anything. Crap. We cannot do anything whatsoever. We just see standard out. We just see print logs, whatever. We're not seeing it. We can't do anything. That's boring. So after some thinking, because I want to keep everything software based. I don't want to touch hardware. Like, yeah, there's a NAND flash. We can remove it. That's the last thing I want to do. Like, I'd rather go the software route because it's ripping crap out and I mess up. I got to buy a new one. Forget all that. So I just solder some, so it takes like a hot glue gun. You know, find an area on the board that has no copper exposed. Put a little bit of hot glue on there. Take some header pins. Just stick it on there. Wait for it to dry. And then I take some wires and I just, you know, solder it on. And it's not the prettiest thing in the world. But, you know, and then I just attach some wires. Put it on my FTDI base breakout board over here. Turn on OpenOCD with my configuration on my FTDI board. And we see automatically, boom, we do have a JTAG interface. We have the ID. We see the manufacturer ID is ARM base. Woohoo. So then we open up our own target configuration. So we set the reset config. We have test reset. We have system reset. It's a push-pull situation. We have a new, like, tab with the ID at the very end of it. And then we create a cortex A target that's little Indian. And then after that, we run it again with our two configurations, the board and the target. And look, oh, also we have six break points, four watch points. 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. 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. So I'm dumping memory addresses. If something is not, you know, unaccessible, I just write that out. So I'm dumping, dumping, dumping, halting the boot-up process at different stages. I'm trying to find the kernel boot arguments. 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. 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. 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, you know, do a second retry and get into it, but, again, I don't want to touch hardware. 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. We actually, can actually do something, and you actually probably saw me typing up some commands to load everything up. So great. So this gives us access to rip the firmware off and get debug capabilities, right? 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. I don't care if it's WAN-based, LAN-based, everything's open scope in my eyes. So I'm looking at anything that's listed on all interfaces 0 to 0, or, uh, inner, you know, an internal interface. Uh, IP tables can maybe come into play later, but we'll get into that later. So very first thing, I'm looking for low-hanging fruit, and someone please scrim it out. UDP 1900 is? Low-hanging fruit! Yes! Awesome! It is known as SSDP. It is a piece of crap, and everyone talks about it. But anyways, we have three binaries here, we have three different SSDB servers, WPS monitor. Frontier 4 is about a 32 megabyte C++ file. Have fun with that. It's kind of fun to look at. Fun. Uh, we have mini UPNPD, which probably is vulnerable to the read out of bounds volume that I posted earlier this year. So anyways, today we're going to be talking about WPS monitor. So before I even start ripping things out, I need to know my environment. Um, because I need to know like, you know, do I need an info leak? Uh, do we have an executable stack? Do we have an executable heap? Well, what the hell am I looking at, right? So the very first things I do is I look at all, you know, there's a libupnp library. You can see like, oh, a libupnp. It's not the Intel one, so remove all like assumptions out of your head. Uh, and also we have ASLR on the imported libraries. Surprise. We look at a stack in the heap. We have depth. Awesome. 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. Cool. 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. We have a gadget. 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. 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, like always, and we extract the file system. So now we're going to get more into the nitty-gritty, happier stuff. Vuln hunting. 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? It's like, oh, I looked at a string, found a vuln, and that's exactly what I do first. 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? We have a buffer, or some sort of file descriptor in Linux, right? 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? So I see this very first response, HP11, okay, blah, blah, blah. I see %s here, I see %s there, %s here, over here is a %s, and over there is a %s as well, ha. And that's very interesting to me, because I'm like, alright, what is this response, right? Like, what function is using this? So I see this immediately, looked at xrefs, and I'm like, oh, that's nice, sprintf. But, you know, remember, sprintf, assert copy, and all those, like, vulnerable C functions can be used in a non-vulnerable way, right? So just because it's sprintf doesn't mean it's vulnerable. So we look at where's r0, the destination buffer coming from. 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. 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. So we're accessing something. This could be, like, a pointer that, you know, maybe Malik is saved, you know, Malik is being saved to or whatever. Like, you know, we get an address from Malik, we save it there. Maybe it's calculating the length beforehand and, you know, maybe it's not vulnerable, like I said. Who knows? Or maybe this is just a character buffer inside this structure that has a fixed size. Who knows? So we need to do more research. So next thing I do is I'm looking at the UPnP specifications, going, what is this message for? 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. Something in our, we probably have second dash and some integer, right? So I'm like, well, what's causing this response? And we see this. It's called a subscribe. Subscribe publisher path, and I'll show you that, what's that, afterwards. We have something called a callback. Host and user agent are optional, so that's why they're not bold. Callback is mandatory. It is wrapped around angle brackets or less than, greater than, whatever. We have NT set to UPnP event, which is static, has to be that. And then we have timeout second dash, and then a request is duration. Second dash, again, probably an integer, second dash 20, second dash 900, whatever. So what is this for? Like, what part is this? What is the publisher path? 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. But everyone talks about the control URL, the SOAP actions, and that's not what we're talking about today. We're talking about this, the event URL, which is called the Gina stat. I forgot what it stands for off the top of my head, but just trust me, it's called Gina. 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. So we use, you know, requests. We're going to send a request that, come on, we do second dash and then a string instead of, like, an integer. Because I just want to see firsthand if this percent S that I'm seeing in the response is even worth looking at. This is, you know, maybe pass it to a toy first and, you know, I get zero back and I get second zero. Like, that's not exploitable or anything worth looking at. So I need to dig deeper. So we just send it and awesome, I sent a string, I get a string back. That's awesome. So okay, this seems kind of interesting now. So that percent S is what we control. So okay, so next things we can do is we have two things we can do. We can be super C, super, like, awesome CSI, double-hacking keyboard, lead dudes that were, you know, like, all the clubbers and crap. Or, fuck it, we can just black box it, right? 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. 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. 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. But this is supposed to be confidential. So I didn't have all this at the time, so screw it, we'll just black box it. Kobe. So, next thing. So I set up a for loop. That same exact code, just in a for loop. I'm incrementing now by one byte at a time, that second dash. And I have GDB attached. It's going to keep going and going and going and going and going and going. Any kind of reset sets to me, just try again, keep going. Right, just keep going. And I get a segmentation fault. I'm like, oh my god, there's probably static sizes, this is awesome. Oh my god, I got to call my dad. But hold on, let's not call my dad. Because this is just loading compare. We're not writing anything, we're just loading and comparing. That's not anything useful. 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. But you know, we have this compare, it's looking at zero, it's going to branch out and return. 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? What kind of requests can I send to this thing? We have an HP stack, we have a SOAP stack, SSP stack, we have this Gina stack. So, I start thinking, I'm like, well what kind of other states can I do this in? And I find this. And I'm not going to read this wallet text to you. Basically what this says is that once you subscribe, you get a SID, your unique identifier ID, right? So from there, let's say you subscribe for 20 seconds. And then you change your mind. No, no, no, no, I meant to subscribe for like 100 seconds. Well, you send a second subscription with your SID and with a new timeout value. I was like, oh, maybe we can like hit some new code with this type of thing. So, we subscribe first, save the SID, and then we cause the overflow and see what happens, right? So, I do the thing again. And we get a different site fault. I'm like, oh, better be something good, right? So, I start looking, I'm like, oh, we see this load, you know, offset 24 to R3. We do a compare, a branch on zero. So, if it's null, we don't call it. You're not going to call null. And then it jumps to it with the exchange. So, we can jump modes like thumb mode, R mode, whatever, right? And I'm looking at this, I'm like, what's R3? I'm like, oh, that's the value I control. That's my name. That's awesome. So, okay. So, we have, so I got lucky, right? I got super lucky. But I don't care. That's my luck. So, going on, I kind of have a way to obtain PC control. We're one pointer away, right? We're almost there. Still can't use WPS monitor as a gadget because we're still bounded by the limitations of a string. Can't have a null byte because that's the terminator. Uh, ASLR and import libraries that don't have an infleek. So, whatever, right? So, now to the exploit development of this. 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. Holy crap, you know what, this reminds me of actually, so back in the day, who's ever done internet explorer exploitation? IE8, 7, 4, 1, I don't care. Anyone? Yes, awesome, cool. So, that's exactly what it reminds me of. I'm like, okay, new tactic. Screw the infleek. 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? And speaking of which, oh, whoops. I need to start this. So, you're about to witness the world's slowest exploit. My exploit takes about 20, 28 minutes and 30 seconds to run. So, we're going to start it. Just want to make sure it's running before I go back to my slides. All right. All right. One second, please. This is slow. All right. There we go. All right, cool. So, let's go back. All right. So, it says spray the heap, do some magic, trigger overflow, get code exec. So, we look at the heap. So, I need information now. What is the base address of this heap like loaded at every single time? So, I need a target address to maybe grow this heap torch, right? 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. That's okay. You know, we can do that later, right? We can do more off screen. That's boring. So, also I need to know how much memory do I have? Like Internet Explorer, everyone had like, you know, maybe back in the day like 512 megs. Yeah, my age is showing, right? Or, you know, at least a gig. 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. But we have 117 megabytes free. Or, you know, I don't want to be, you know, taking up everything. So, let's just call it 100. 100 megs. So, theoretically, if the heap always loads at zero, just think about that. The maximum size I can grow the heap to is 06060606 or whatever, right? So, awesome. I can grow the heap to a very large size potentially if I find a printer to allow me to. 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? Like, what's the, you know, like, what's the highest address the heap actually loads onto and stuff like that? So, actually you saw that it loads under 0303 all the time. We see like an 0210, but it always loads under 03, 03, 03. So, I'm like, alright, cool. So, I start looking at the description functionality. Like, how does this work? I need to find primitives. I need to fill the heap. I need to do memory leak. Not info leak, memory leak. I need to fill up the heap. So, I start looking at this. So, I start looking at Stirling and it goes to a Calic. And I find out that that pointer there is the starting, it's the URL portion of the callback. So, after the IP colon port slash and then the end of it, that's, that's where we're at. So, that's where that pointer's to. That's slash and then like ABCD, right? The, the closing bracket is null terminated at this point. So, we're just slash. And then after that, we add some sort of size to it. So, it's going to be the size of some structure, right? So, we have some structure. And where the last element is some character buffer array. And then we call Calic. If you're not sure what Calic does, it takes the values of R1 and R0, multiplies them, checks for overflow condition. This is a very high level. And then it calls Malik, gets a pointer back, memsets it, and returns it back to you. So, everything's going to be initialized to zero. There's some other crap that goes on in there, but it's not relevant to this. So, we go into GDB. We set some break points. And, you know, we get the length and we get the return address. Because I need to learn how to, you know, I need to start spraying this stuff. So, I set up a for loop to subscribe over and over and over and over and over again. And crap. All right. I'm getting the same pointer over and over again. So, in my head, I'm like, all right, so, it's being freed, alecked again. Freed, alecked again. Freed, alecked again. What, what, like, what the hell is going on? So, step back. 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. Right? 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. So, I go, well, let's change something in my subscription. We can change IP address maybe, change the port number, change the URL. 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. 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. Awesome. I have a way to fill the heap. So, in theory, this is what I'm doing. Subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe. So, we're just filling up the heap with a bunch of subscriptions with Different port numbers. Okay, cool, that's cool. You can fill the heap. We can spray the heap. But we still need to do some dope David Blaine magic, all right? Then we go to street magic, you know, some crazy shit. So I start reading the manual some more. We go back to the architect, you know, the specifications. And I see this request now. Unsubscribe with the publisher path with your SID. I'm like, all right, let's go back to the code. And I find this function called delete subscriber. I wonder what it does. And I see this little wrapper of free here, which literally just takes the pointer and passes the free. So I set a break point there. I go, well, what is this pointer, right? We have run time capabilities. I don't feel like spending all the time reversing all the things. Don't limit yourself to just one way. Use the easiest ways. 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. These are my blocks. I'm using the, oh, awesome. 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? So back to monkeying around. Because this is the heap spray portion, but I'm like, okay, I'm still bounded by the limitations of a string. I can't do anything yet. I can fill up the heap. That's fun. But, you know, I can't use WPS monitor as a gadget yet. So I start talking to a colleague who works on different products but also has experiences with heap stuff. I'm just bouncing ideas back and forth with my colleague. It's kind of like rubber ducking. So I send him my IDB. I'm like, hey, man, I'm looking at this. You know, this is my limitations. This is what I can do so far. You know, you can look at all the references to malloc, calloc. If you're super hardcore, xmalloc. If you turn null, kill the application. Super hardcore. But we start going back forth and he asks me a question. He goes, hey, this function here about base64 decoding uses malloc. What is that all about? Like a UPnP, base64. I'm like, oh, shit. Awesome. So we go back to SOAP, the thing I did not want to talk about whatsoever. And I start looking for an action with one argument. Because I don't want to deal with multiple arguments and it just gets kind of messy. And I find this. This delete AP settings. Sure. Whatever. What kind of type is this new AP settings argument? Go all the way down to the bottom of XML. We see it's a base64 type. So we can send a SOAP request to this action and inside the XML, inside the text, we just, you know, base64 encoded string. I can base64 encode nulls. Okay. So what I do next is like, alright. So when I send this, when I send the SOAP action, I set a breakpoint, I look at the heap block. And it's actually the decoded data that I sent to it. It's not the base64 string. Awesome. 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. So, I try this out. So we do it. We unsubscribe. We call the SOAP action. We unsubscribe. We call the SOAP action. Unsubscribe. And then I look at this. This is early development of my structure. That's why you see like 02, 02, 03, 03. Just lining everything up. The very first one is my first gadget. So whatever. But I'm trying to set things up. So I'm doing everything by hand at first and I'll, you know, I'll make it nice and pretty later. So, okay. We can spray the heap now. We're kind of almost there doing some magic. But wait. Roadblock. Alright. I do my spray. I'm doing my technique and I'm like, alright, let's look at this address and it's not there anymore. Shit. Alright. Well, what's going on? So, to think about it in layman's terms, like super simplistic, you can't build a house without a roof. Right? That seems silly. So my technique right now, I'm like, you know, I got all these descriptions. I unsubscribe. Do a SOAP action. I unsubscribe. Do a SOAP action. Unsubscribe. SOAP action. You know, blah, blah, blah, blah. And we're going down the line and, you know, and, and then the rest. Right? 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. So it eats it all away and revokes it from me and gives it to another application or anything else that needs the memory. Right? So, that's what's going on. So I'm like thinking, I'm like, well, instead of freeing everything, what if I leave the last allocation there? Because in the seconds, there's actually an option to do infinite, where it will never, ever run out of time for your description. It's forever until the, no, until it like reboots or something. 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. Right? So, this is awesome. So this is working fine until, come on, until this happens. So my, my way to do the base 64 thing is writing to the same block over and over again. 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. It's not, it's something else is racing to it. Something else is causing some issues. So now I've got to figure out what the hell is being freed. So I'm going to set just a simple break point on free. If it's null, just keep going, I don't care about null being passed or freed. Um, so we just keep going, and we're just going to wait. 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, and it's not really worth going for anymore. So I look at it, and I'm like, alright, let me send an msearch request. 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, 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. But anyways, we send an msearch request, we see that there's pointers being freed, okay? We find the sizes by looking at the heap header manual and stuff like that. Um, so every 60 seconds, this device sends out a notify request on multicast. 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. 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. 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. So that now I have two arenas. So I have one arena where I have spaces for these objects to fit into perfectly. And they can jump in there all they want, because I'm making holes. It'll never get, like, condensed or whatever. It may get trimmed, doesn't matter. Then I have my other arena where I have that last allocation being set and I do the whole thing. So now we shift gears. So now what I'm doing is a free, replace, free, replace, free, replace, blah, blah, blah. And then we do an allocation back up. So we resubscribe and we come back down. And also what we're doing is between every single iteration is that we have a UDP socket listening on multicast. 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. So, next, we can spray the heap. We can do some magic now. We can now use WPS monitor. We can write nulls to the heap and stuff like that, I guess, basics for decoding. That's awesome. Uh, but we don't have an exploit chain yet. So I'm thinking, I'm like, alright, let's cause a crash and we look at what do we control, right? 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. But anyways, the only register that we have control of really is R4. R4 points to our overflow string. 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. So I have a pointer that points to my data. That's all I have. So I start looking online, I'm like, alright, let's look, think back about Internet Explorer days. Uh, you know, what did we do? Oh, we did a stack pivot, right? Uh, we have, like, one shot, so we do a stack pivot. So if this heap was executable, we have a bunch of, like, NOPs and then shellcode, NOPs, shellcode, we jump to NOPs. Wee! Uh, if we have depth, we have a bunch of returns. 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. So I start looking online and I see this. 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. And what, what does it do really? 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. I'm like, oh, man, god. 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. Well, what the hell? Like, what? Why? So we look at the ARM manual and we see this restriction on the second line, the register destination list cannot contain SP. The destination list that I had before has SP, the second to last one. This is now an illegal instruction. I can't use this technique on this device. So, alright, back to the drawing board. So what I do next is I develop a regex for IDA. 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. That's all, that's what I want. 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. And it says like dereff R4 and R3 and we add all these offsets and we get R2 and we have R1 and R0. I'm spraying 4K blocks here, hex 1000 is 4K. So we're just going to jump into another block that I, I'm in control of with my data. So this right here gives me the primitive of calling a function with two arguments. Okay, cool. 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. So I only have a one shot situation. So I'm thinking, I'm like, what can I do? 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. So I started looking at mem copies. This thing has tons of them. 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. I know it's probably hard in the back and I apologize. I'll sum it up. So this right here, if you look at the second to last instruction, R0, the destination, is a stack based buffer. 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. And R0 and R1 are in our control now because that was the last gadget that gave us control. And R1's in R4, R0's in R5, we look in, R4 is N, R5 is the source. So instead of bringing the stack pointer to the heap, like fuck it, let's just bring the heap to the stack. Just clobber the shit out of the stack. I control N. I can clobber the shit out of the stack. So that's what I do. And we look at the bottom of this thing so we adjust the stack frame so we have to be careful now. This is a large adjustment, 2K. So we're not going to jump back and do stuff. We're now just incrementing the stack. 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. So now we have control of R4 to R7 because now we brought the heap to the stack. So now, next gadget. 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. But with the pointer of minus 4. And this next slide you'll see why. So then after that we pop from the stack R3 to R7 PC. Next thing. 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. Now we're inside libc at str2 unsigned long. We don't need to leak it anymore. Pop from the stack. Next one. We add R3 because look, we have R3 to R7. R3, uh, it's going to be an offset now. We're going to add it, well R3 and R0 are going to be added together and we're going to save into R0. 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. 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, 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. So then from there, gadget six, this looks really large, but we can pick another allocation that's like maybe a megabyte away. We don't care. We're going to write to the heap now. We have a pointer to P open and all these gadgets I found by hand. If I try to use some wrapper thing and try to automate it, I would not have found these gadgets. Wrapper and everything. 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. It's not going to tell me that. So anyways, this right here, I'm going to write to the heap. I'm going to write the P open pointer that I just calculated into the heap now. Keep going. We're almost kind of towards the end of the stack limitations here. So now I invoke gadget one again, which is our last gadget, gadget seven. So this one, remember, I can call something with two arguments. So R2 is going to be P open. R0 is going to be a string. R1 is going to be R because you have to provide something for P open. And then, okay, cool. So let's put it all together. So we spray the heap. We save all the subscription IDs. We don't free the last subscription ID, that's our roof. 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. Everything is aligned to 256, or actually, yeah, so everything is 256 by the line, whatever. So we free five, reoccupy five, free them again, go to the next five. If anything comes in multicast, fix up the heap if needed by doing resubscriptions and freeze again. Trigger volume, maybe we win. So we sue everything and we see this, right? So let's check out this guy. Why is it at 11%? No! It is at 11%. Why is it 11%? All right. So I guess I'm not doing the exploit live anymore. That sucks. Oh, that sucks. Oh, no. Why? It's on. All right. I'm sorry. I guess I'm not doing this live. It is reliable. I can demo it later if you guys want to see it. But it's all right. We're stuck at 11%. What we were doing, though, was the free and replace of everything that we were doing. We create two arenas and we're going all the way down. It should have been around 60% by now or so. So that's all right. Man, let's see down here. 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. But the funny part about this as well, just to look up, is that there's actually one process. Let's see here. One process ran by nobody. It's another UPnP server. So whoever actually made the process, you know, the process run under nobody, like, that guy deserves a high five. So anyways, let's go back to everything. Man, I really wanted to show that shell. Oh, well, it's actually still going. It's just going really slow. Anyways, so we do have a shell. And I wanted to show you guys some bonus stuff as well. 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. And I found one 5916 that was being filtered by IP tables. So I started thinking, I'm like, huh, what if we use that genus stack to pivot, like a server-side request forgery, right? So we set the callback address to 120 localhost 5916 with this URL. And so we attach strace to that daemon to see if anything's coming in. We send the request, and yes, we do get that. 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, you can use this to maybe hit that part of the code, maybe change configuration or something like that. So it's a way to pivot. 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. But I mean, after all this, so finding the vuln and all that stuff taught me something valuable. So I was doing this by hand, and I was like, you know what? I've been finding a lot of the same kind of programming issues with this protocol and stuff like that. I have a background in network engineering, I also have a background in QA, so I was like, let me start making a fuzzer. And I encourage everyone else to do this as well, because what do we have? We just have HP, we have XML. 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. You'll save so much time. So instead of a few days, like it took me by hand to find this vuln, it would have taken me 30 seconds. So actually, let's see. Now it's going. It's going now. 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. So anyways, man, everything going wrong is. That's awesome. So anyways, so if an ISP asks you, and this is going to be super cheesy, but whatever, I'm going to do it. If an ISP asks you, could you, would you install this router in your house? You must say, no, I do not, would not install this in my house. I do not want it here or there. I do not want it anywhere. I wouldn't want it for free. I wouldn't want it if it could download up to 10 GB. But anyways, that's enough of that stuff. This is who I am. So I go by Black Owl Online. Someone had the real name Black Owl, so I changed the L21020. Cool. Elite sauce. What up? I'm a zero-day researcher at Exodus Intelligence. I do embedded devices, both SOHO, I do enterprise network solutions, firewalls, virtual appliances, whatever. I don't care. If I can get it, I'm going to audit it. Smart devices or anything else that catches my eye. We're also hiring at Exodus Intelligence. We're looking for another zero-day researcher if you're interested for getting paid for finding no-days. I get a bonus on top of that for selling your phones to us. Like, you know, hit me up. But that's about it. So again, that's who I am. Thank you for coming to my talk labeled Green Waves in Ham. Take care.