So, uh, welcome. Thank you for coming. Uh, this is, uh, a talk on reversing and exploiting embedded devices. You know, just in case that wasn't obvious. So, let's just get going. Let's just get started with this. But, actually, before I get started, I have one question. Who here has actually done exploitation on embedded devices, either MIPS or ARM? Awesome. Did you take that POC all the way to Code Exact? Awesome. Cool. So, that's what we'll be talking about here, too, as well. Like, uh, so, anyways, let's get started. So, this is the outline for my talk. It's a little hour, it's about an hour long or so, but I'm going to go through it a little bit quickly. Um, I've, I've done this talk before, but kind of, like, scaled it back on the technicalities, but since this is DEF CON, we're going to go full technical for a little bit. So, this is the outline. I'm not going to go through it, but let's just say we're going to get a little technical, and after this, we're going to go on an adventure to actually take the stuff that's in this talk and find our own ODays and products in today, and that's what we'll be doing tomorrow. But, who here has actually joined us? Who am I, right? Like, who's this kid up there wearing all black? So, my name's Elvis, real name, and I love how everyone's cell phones started going out and taking pictures when I, when I said that. I'm a senior security researcher at a local pen testing firm in Austin, Texas called Praetorian. I got into IoT research completely by accident, right? I started off in desktop space, and this whole IoT embedded device, device stuff got just completely by accident. The long, the long story that's short was that I had a coworker who found a vuln, a really nasty vuln. It took him three seconds to find it with a really dumb fuzzer, and I said, if you can do it, why can't I? And, now I'm in this trap. So, um, I'm also known as Black Owl on Twitter. That's cool. So, let's get started. So, like I said, I found some bugs, because I got competitive with a co, a former coworker of mine who found bugs really, really easily, high impact bugs that was affecting the entire SDK of the manufacturer. So, I just did the same thing. I was fuzzing, HP daemon, everything I think of, the method, the URI path, HP 1.0, 1.1, 0.9, host with long everything, maybe tons of new lines, no new lines. Everything I could think of. The UPnP interface was so, all the methods I could think of. Anything that takes a string. Let's put command injection. Let's put 3000 A's. Nothing was happening. My device was all happy dory going, no problem, man. We got this. So, then I started taking it further. I was like, well, what about, like, directory traversal, maybe pull some files. We do double percent encoding, next characters. So, we can do, like, percent 25, uh, 41 for, like, capital A. Or, let's just do all these crazy things, or command, let's just fuzz everything. But, nothing was working. So, what did work was, I had to, I had to, I had to, I had to sit down. I took the firmware completely apart with binwalk, which is fantastic. And, I found hidden APIs that you would never find on the front end by fuzzing, by disassembling this, that was inside the binary itself. You would not find it in the file system, it was inside the binary itself. And this particular one was, it would take the, the value from submit URL and pass it straight to system. Pretty dope. So, digging into firmware. So, like I said, fuzzing stuff on the outside. May just only get you on the surface. Some of the nasty stuff that you want to get into is going to be deep. You're going to have to dig for it. So, extracting firmware binaries. Who here has heard of binwalk? Yes! Awesome! Binwalk is an amazing tool. It's long, like, a very, very high level what binwalk is. It's a magic byte parser and extractor. That's all it does. If you look at the configuration files for binwalk, it is just using libmagic. Offset this, this is the byte, like, cafe bay for, like, Java, right? And it just goes through the entire structure. It's supposed to be matching the entire structure up before doing any kind of extraction. If there's any kind of false positives inside of that and when you see the word invalid for this kind of stuff, it's supposed to be reducing false positives. So, that's binwalk in a nutshell. Very, very simple, straightforward, but it's super powerful. But it can also be annoying if you're dealing with dumps that are not particularly organized properly and binwalk just goes crazy and just says everything's an LZMA block. So, great. So, we can extract, we can extract, we can extract, we can extract firmware that we can download off the internet that's not encoded or anything like that. Fun fact, a lot of encoding stuff is usually, like, single byte or multi-byte XORs, so don't worry there. Um, so, when I got into embedded devices, wow, that's a lot of people. What's up, guys? Um, the one thing I didn't know was the assembly for it. I started off in x86, 64 land. I didn't know MIPS assembly, like, what the hell's a branch, what the hell's all this stuff? But what I did know was C. And I was like, well, let me just do exactly what I did in x86. All right. So, I was like, well, let me just do exactly what I did in x86. All right. So, I was like, well, let me just do exactly what I did in x86. All right. So, I'll just create C, compile it, maybe with some different flags, see what else comes out, and then just step through it. So, this is exactly what I did. So, right here, I have a local, uh, integer called red, red val. And it is initialized to zero. And in MIPS, we have a dedicated register called zero. It's just always null. So, right here, I know that we have something called store word, zero to offset 24 of S8. 24 S8, S8 is also known as a frame pointer, also known as EBP, if you want to say. So, we are now, we, we know we're in the middle of something. So, we're in the middle of something. So, we're in the local, uh, local variable for this function. Great. So, I know S8, and I know the, the offset for that, uh, for that value. So, we go further. What about calling functions? How do arguments get passed in this, uh, in this, uh, in this architecture? So, the very first one, I pass hex 44, which in base 10, would be 68. And then second, uh, argument, which is A1, which is hex 65 or 101 in decimal, which is A1. Great. So, now we know when we're calling a function, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, those A1s, 0, A1, A2, 3, I'm going to be pointing to the arguments I'm going to pass to this function. Great. This is super simple. So, now we know, like we're, you know, initializing happens. I know where arguments get passed. What about return values, right? So, I have this function called test. And I do a ret sixty-six or whatever it is, right? Well, remember that same offset, 24, that we solved for the beginning. That's ret val. So, now we know v zero whenever a function returns. It's gonna contain a value return from the previous function. Cool. And then we do it again, printf. second argument is going to be an A1 because the first argument is the format string right? And then we just keep going and then it's the final one where we finally return from main and I put a D word in there 43 all capital C's right? So we have an LUI of 2 bytes and an ORI of 2 bytes and I was like alright that's kind of cool but what is actually ORI doing because I don't feel like reading the assembly manual right now and I just kind of want to see what's going on. So it's everything we've always done when we're trying to learn new assembly stuff, we just set the breakpoint, we make sure step mode is on, we step one to make sure that instruction was executed, we double check to make sure the execution happened, we check the value. So now we know when LUI 2 bytes happen the greatest significant 2 bytes of that register will be that value. And then the lowest significant bytes, this is an ORI so it's an OR integer but the lowest significant since it was null, 4343 gets populated and the whole D word gets populated into that register. Why did it have to do 2 instructions? Some people in there if you don't know I just want to say it, this is MIPS 32 bits MIPS 1 it's 4 byte instructions. So every single 4 bytes is going to be a different instruction so that's why you can put 4 bytes for your operands to the opcode. Cool. So this is kind of, you know, kind of like annoying you can say it takes time, you're going to sit down, make some coffee, not get distracted by Mr. Robot or whatever you're watching. So what about, making our lives easier? We want to find vulns, right? It's our jobs, it's what we want to do, we want to pop shells, we just, that's all we want to do. So I learned about something called GPL, the General Public License, right? So when I was reading from it at a high level I was like if you license your binary in your source everything on a GPL you have to publish it. The source has to be out there. If it's on a GPL and you're like no I'm not going to give you the source, that's a violation. So what if I take, I don't know, vendor A into Google and type in source code? Cool. So I'm going to take vendor A into Google and type in source code. Cool. So I'm going to take vendor A into Google and type in source code. Cool. This is all the tar balls for that device. If you download this tar ball and if you modify a little bit with the symbolic links inside it because sometimes they break, you can compile your own binary for that device. It will upload and all that good stuff which is what I did on this one. What about smart TVs? Complete source code is on there too. No need to take it apart and probe the flash chip on the SPI interface. Don't do that. Complete source code is in there. And you may find some old libraries, maybe web kit is old on there. I don't know. And last vendor. Again, GPL. It's vendor name. All there. Very, very straight forward and everything is documented beautifully. I love these guys. So it goes on and on, right? It goes on and on and on and you'll run into two different types of like GPL codes with this type of devices. You'll have your Linux boxes and then your RTOS boxes and they're completely different and I'll talk about that a little bit more on but yeah. So I talked a little bit about software, how to get into it, how I taught myself how to like you know, go over the hurdles of learning assembly so I can actually read this stuff and interpret what I'm reading. What about the hardware, right? It's like when I started getting into it, I exhausted the software stack completely at one point. I'm, I'm completely stuck. I have to start opening this stuff up. So the thing is though, you have different levels of like, I don't know, you can say uh, advancedness. You can build a super dream of your lab, you know, super lab of your dreams and you're dropping acid on chips and doing all this crazy stuff. You don't really need that. Majority of the things that I do use this, maybe some of these, and that's about it. Hold on, let me go back. Sorry. And maybe some of those. Yeah, cool. So, what I wanted to say is that the barebone stuff, it says $95 to $100 or whatever, but that's the biggest chunks from the multimeter and the soldering iron itself, right? If you have friends or just have them laying around, that's your biggest chunk that's going to go away. The JTAGulator, that's a controversial topic in my opinion because if you go under the JTAG Enum project for the Arduino Nanos, which is, in my bag, which I have, you can build yourself a JTAGulator basically for about five bucks. So, these things, right? Have you ever seen like an Arduino, these little five, three dollars, you can build yourself a JTAGulator basically for about five bucks. So, these things, all the cheapy things from eBay, right? Um, if you look at the JTAGulator source, you can see that there's a comment saying that the, the logic from it was actually pulled from the JTAG Enum project for the Arduino Nano. Cool. So, the same logic is in there too. What's the difference though? Like, why is that so expensive and you can do this whole thing? You can't do voltage control on this. I can't say, alright, give me 1.8 logic for your software. It's not going to work like that. This is 3.3. So, I would have to make my own like, like logic converter or like some sort of shield. So, that's where the other thing comes into play. So, that's where the JTAGulator comes more like friendly and stuff like that. So, that's where the other thing comes into play. So, that's where the other thing comes into play. So, that's where the other thing comes into play. So, I'll talk, I'll talk about that another time we're offline. And then the logic analyzer is fantastic because I've seen so many boards where I go, what the hell does this test point do? Where does it go? I can't figure it out. Hook up the logic analyzer, do a quick sample, analyze what you see and just go forward from there. So, guessing, probing stuff with a multimedia at a very low sample rate. You're going to go crazy because I did. So, finding UART. So, UART in a nutshell, right? Most people in here most know UART. You know, UART is basically, just think of it like telnet RSH. You got a command line or it's just a serial output from the device. So, what about finding this kind of stuff without opening the device? What if I bought some $300 device and I go, I don't want to open it up. So, what if I break it? Because I will, right? So, every single wireless device, at least in the states, has to go through something called FCC qualifications. Has to be tested. If it's wireless, does radio, has to be qualified. So, you take this number called the FCC ID. You go on FCC's website. Click a little button called internal photos, which is great. And you get the complete PCB, front and back, up and down, left, right, Konami code. Awesome. And right there, like this is, like not all the time, but this is a very good hunch. When you see a rows of pins like that, like those five pins I highlight right there, it looks like something that may be useful for development or testing. I don't know, it kind of looks like a shell interface and the one below that may be some sort of JTAG interface to test like the processor or anything that's in the JTAG chain. But it's efficient. So, I go, that's UART maybe, so let me go probe and test it out. Uh, and spoiler alert, it was. Cool. So, that was some easy ways. But, one thing I really want to stress. Don't make the same mistakes I did. Find your ground first. I have had too many smoke shows or too many, ugh, moments when I'm just like, uh, yeah, that should be fine. Shit. So, find your ground first. The one, the one thing that I like to do, uh, is like, I find common grounds. Like, this is like a, a shield, there was a shielding over it and I took it off. I found it to be a common ground. But, like, USB casings on the outside, they're usually grounded. Just find yourself a common ground point. Uh, if you'll flip on the back, you'll see also casing groundings for like, uh, anything, any kind of ports. Find a ground and then don't use continuity mode. I used to say that and I was dead wrong. And this is why. When you use continuity mode, you know, the one where you say, alright, is A connected to B and it makes a noise, right? That's pumping voltage through it. And I hooked up my logic analyzer and this was me moving the dial. So, we got some noise. And the multimeter in continuity mode pumps out 1.6 volts. Continuous. So, if we have any kind of fuses that are very, very sensitive or anything else that may blow that's over 1.6, I don't really see anything that's, you know, says I can't handle anything over 1.6. But, we just want to be careful. So, instead, we use resistance mode. Resistance doesn't do voltage, uh, resistance doesn't do, uh, resistance mode. It doesn't pump out 1.6 volts like we saw before. So, all we need to do is to say if A connects to B, we look through resistance. If it's absolute zero, they're connected. Awesome. Or have no resistance in the middle. So, yes, they're connected. Great. So, that's how I find ground now is by using resistance because I did, I was using the wrong way and, um, learned that I could blow stuff up. But you are in a nutshell, right? We got transmit to receive and a common ground. There's no clock. It's going to be like some sort of like, I think it's like asynchronous or something like that where you have to like tell it. Um, so, I'm going to show you how to do it. So, basically, think of it like a phone call. You talk to somebody and you hear it. The end. But now you have to figure out how tall, how fast it's talking. So, there's methods of finding the baud rate for these UART devices and it's annoying. I don't like brute forcing UART interfaces. Is it 9600? No. Do you attach 33, 400 or something like that? No. So, instead, we take a 20-second digital capture and if anyone's used a logic analyzer, you'll know that digital captures are very, very, very tiny. So, instead, we take a 20-second digital capture and if anyone's used a logic, you'll know that they're very small. So, if this was an analog capture, it'd probably be in the gigs. But this is like a 20K file, right? So, this is ambiguous so, uh, let's just use our CSI cyber skills and we enhance this photo really well. And what I'm looking for here is something called the shortest width bit. Doesn't have to be the exact one but I'm looking for when the falling edge and the rising edge happen again. What's the distance between that? So, this one is 8.8 microseconds. So, okay. Cool. You found that. What can we do with that? So, if we take that 8.8. Will that catch me? Well, looks like we used it the last time. Прек utilización point eight and we take one second over eight point eight divided by a million whatever the uh measurement for that is. We get eleven three six three six three six three six. We're gonna round it to our uh standards which is eleven five two hundred. But just for fun I'm like you know the logic uh the SLA logic analyzer comes with a uh different kind of analyzers that come in with it. This is called the serial one. So I said this is the baud rate. I want you to analyze this signal and see if anything comes out. And it comes back saying this particular segment is the word start and there's a space. Cool. So now I know the transmit pin on the device. I know the ground and I know the baud rate. The receive. Don't hate me but I brute force my way around. Until something clicks. Click here. Enter enter enter. Nope. Next one. Alright. Talked about UART. So how about JTAG? So what the hell is JTAG? What is it for? I've heard JTAG. I've heard people use JTAG blah blah. What can you do with it? It's literally a testing like it's a what was it? It's a test. It's a test. It's a testing suite. It's supposed to be made for quick easy ways to diagnose hardware problems without sitting down and probing everything. So this is great. But it has a lot of functionality. So what we have here is something called a tap interface. The tap interface connects to the insides of the actual logic of the chip. It's a little bit complex. I'm not 100% there so I'm not going to try to BS my way around. But I do understand this which is the state machine of JTAG. So basically when we have lines the lines here are going to represent our mode select TMS and then the TCK, the clock is going to indicate when we go from next step to next step to next step. Right? So let's say that I'm at run test idle. If TMS is high and the clock happens one more time the TMS will move over there. So now I'm at select DR scan or data register. So this is how the state machine works. And if I keep TMS high it will go all the way up to test logic reset and correct me if I'm wrong but based on what I've seen there's no TDI needed for this and you'll get the ID code. TDI stuff when you start doing bypass scans and you're filling every register up with I believe ones to put into a bypass state, that's a different thing. But we'll go into that, later sorry. So locating the flash chip. So what if you find UART and it's password protected and you can't brute brute force it because brute forcing the root password takes like 3 seconds for every attempt. That's slow right? So what if you also can't download the firmware when it's not public? It's some sort of like proprietary device right? So now this is where we start getting nitty gritty. So let's start comparing this to computers. This would be the hard drive. So we just find out what who makes this particular chip. We use Google cause you know I'm pretty smart like that. And then we pull up our chip. And the main things I'm looking for is basically where are the interfaces that I can talk to, the input and output and what commands can I send it in order to extract data. And also how can I put it in the right protect state so I don't erase something. Kind of like a floppy disk when you have that thing right? So the thing is though with this is that with chips, with these flash chips they are like a slave. When a master chip says I want to talk to you or mine I select you. That is it. You cannot have another probe into it and talk to your chip. It's 1 to 1. So what happens is when you're actually um pulling the chip off or you're actually trying to dump everything. So there's two ways right? Some people like to be non-instructive and want to keep the chip on the board. And that's a perfectly good way of doing it. And this is how you can do it. There's a, there's a thing called like a, it's an SOIC and then the number. Like this one's 8, there's 16. There's also like uh breakout boards that you can buy and put the chip in here and have a huge breakout you can put into a breadboard and do whatever you want. Um but this, also this way. But the problem with this one is that you have to provide power to the chip. Cause it's not going to turn on, on like the chip itself. It's not going to turn on like magic right? But you may turn on other devices around it and you may put the, the chip into a select mode. So that's not good. So what can we do without removing the chip? Find the reset pin on the, on the processor. Either ground it or put it high, whatever data set says. Then turn on the device fully. The device will not do anything at all. And you should be able to communicate with JTAG and everything else. Because if the dri- like there's been devices as well where you see JTAG for one second and then initialize everything goes away. This is because the driver's doing it. So if you put into reset state everything should be communicate, should communicate perfectly fine. So that's how you can do it without removing it. But I remove everything um just because I like to do that. So that was um a flash chip that's serial. I've been playing around with these things and I'm pretty sure these things were made by the devil. These, these are known as NAND flash chips and they do everything in parallel. And uh I have a dump here and I'll, it's offline, it's not on my, it's not on my slides. And I'll show you the, the hardships I've been having with this. With all the blocks, and organizing everything. And that arrow's not pointing anything. But this is basically how I hooked it up. This is a FT2232H and there's all these white papers, there's a black hat talk on it. You can look it up. It's super, super simple. And this is how it works. You hook it up, you turn it on and there's a tool out there called dump flash and you say give me the ID code and it gives you everything. Gives you the page count. And extracting this 2 gig thing took 12 hours. Super fast. So this is the thing as well, what I was talking about BIM walk earlier. This thing, the blocks are all over the place so I'm trying to figure out how the microcontroller wrote to the NAND flash so I can reorganize everything. Running BIM walk against it goes that for about 5 minutes. LZMA, LZMA, LZMA. Yeah, no. So that's the only thing about NAND flash. With SPI flash running BIM walk on it, done. It's serial. But once you have started having parallel uh flash memory it starts getting really complicated cause it's not all nice and laid out. So exploitation. So all this software hardware stuff, alright cool we've heard a million times. Let's actually break some stuff right? That's what we're here for. So one thing I've noticed a lot. So a lot of red teamers will probably know this as well. Developers love to keep debug code in production stuff. Why? There's no TV, there's no monitor hooked up so who cares right? So when I first found a vuln and I you know made the crash, this came out out of UART. And it said your return address is 43-43-43 and your program counter is at 2. Cool, so now I know my offsets all off the bat. So, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, just to verify I did it again. So look for uh debug code for signal catchers. It's probably in there. So you don't have to like cross compile GDB and attach and all that good stuff. So analyze the crash. So like you know it's the same thing over and over again just like x86. Analyze the crash, find your offsets and put everything into place and everything will work. So analyzing function returns. This is how I taught myself all this stuff like I said before. So we have the same program, two architectures. We have x86. All this is doing is just calling stir copy, taking argument value 1 and just throwing it into like a stack buffer of like I don't know it's really really small. And then uh and then it prints out some stuff and then it returns right? But then we have leave and ret. So leave, so EBP and ESP should be switched I believe. And then we have ret. So then we have whatever ESP is pointing to it's going to pop those 4 bytes into EIP and move over plus 4. Cool. So MIPS. Same thing. Load word RA from some offstat or some offset from the stack. RA is return address. In MIPS we have a dedicated register for return addresses. Load word frame pointer from this thing. Same thing. It's like leave. So we have the same thing. Restore the frame pointer, restore the stack and then jump RA or ret. So it's then having the instructions and one thing is broken out. Load it and then jump. Cool. So x86 and now ARM. So let's see what we've got here. So we've got an x86 and an ARM. So ARM is a very special architecture. That's all I'm going to say. So going from MIPS to ARM is a little bit different. Um but basically the same thing is going to be the same. The same thing. Function return and entry and yada yada yada. We just uh return everything it was when we called it right? So the one thing also with ARM is that you have different modes and some MIPS architectures also have this where you have something called a thumb mode and an arm mode. Very very easy nutshell. So ARM is a very special architecture. So ARM is a very special architecture. So thumb mode is a 16 bit interpreter. So we have two byte interpretations for instructions. The way that happens. You have something called uh I think it's jump and link exchange or branch and link exchange. Sorry. And if that the address that it's going to if the least significant bit is set minus one go back to that memory. Yeah minus one of that memory and then put everything into 16 bit mode. That's how it works. So if we jump into a odd memory and it's jump and exchange 16 bit. If not then it's uh ARM mode. Cool. So like I said before if we just analyze everything we kind of know where everything is going to be. So we're going to go back to our game. We're going to play. We can predict things now. So I know this is a little boring. I apologize guys. So just like before we're just crashing, analyzing, crashing. Alright now we're starting to see everything coming into play. Everything is starting to really look at the same as x86. Just different instructions. That's all it is. Instruction hunting ellipse though is a different story. Especially in MIPS. x86 you guys are spoiled. Spoiled with instructions. Stackable forward flow. No NX. Jump ESP. Right? You know basically. So we're going to go back to T9. I'm not going to say that's every single situation. But basically right? Win. Simple. No NX. That's all we care about. MIPS. Jump register stack. Nope. Move stack into T9. Maybe we can call T9. Nope. Go screw yourself. So this one is more complicated. We have to ROP in order to do a basic stack execution. We don't care about NX. We're not calling any kind of APIs to modify memory uh uh attributes. So this one was a little bit more interesting. So what I had to do was I had to chain gadgets together. And then I had to do the same thing over and over and over and over and over. And I completely skipped that by accident. So sorry about that. So basically what I had to do from the very beginning. I only had a limited set of registers. So all first gadget get more registers. And then I sleep because when I was doing this at the time I was hearing about instruction cache flushing. Not every single MIPS device has that. This is an R3000 MIPS 1. It doesn't use instruction caching at all. There was no reason to go into sleep. But I did it anyways. And then from there it's to adjust uh put the stack at 80% of the stack. And then I put an A18 offset into it and put into A1. Move A1 into T9. Jump T9. That is how I did jump ESP on MIPS. So one thing that was a little annoying and just like we all have with x86 that we've done before. Are null bytes. So when I first came into this it seemed like every single instruction had null bytes. And I said you know what forget this router stuff. I'm going back to desktop space. GG. I'm done. You guys can have fun with this. But then I relaxed. I said alright. Let's actually relax. Whatever. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. I'm done. What about X4? What if I just I don't know. X4 this and that. Dope. So we don't have null bytes. So we can just make an X4 encoder. So in a nutshell though the whole thing is still the same ideas and techniques that we've used with x86. It's just a different instruction set. That is it. So um before I go into this a little bit more the shellcode stuff that I done before and a little bit the ah the I don't know like the pre prelude or whatever to the ah shellcode. I did it. When I got to the program I got a new one. But that's all right. I did it. So I'm everything in RASM. I use uh, I use RASM2 to assemble all my opc- all my instructions into opcodes because I didn't feel like using an assembler and trying to get everything working correctly. No, screw it. I just want these instructions and I'm just going to copy these opcodes into my payload and that's going to be done with it. So this one, all I did there was I XORed S0 with S0 stored in S0. Why? In MIPS for nulls there's no op and when I was jumping back to the stack I had an address that was not resolving to an actual instruction. So I just overwrote it with nulls. It's a nop-slug. I know it's dirty but it worked. So, in a nutshell, grab your libc address, find your extraction offsets, crash your shellcode, test your exploit in QEMU or QMU, whatever you want to call it. I'm really bad with butchering these names. I test everything in emulation first and then from there all I had to do was replace the libc base address because a lot of these devices don't use ASLR even though uh, randomized VASpace is set to 2. Doesn't work. Crash the device, replace the libc base restart it many, many times. Libc and everything else, all the other libraries that it loads are going to be in the same place every time. So, this example is from something I've made. It's called the DVRF project or damn vulnerable router. Yeah, it's kind of funny but um, so this one, the, it's a, it's a very first level. It's just a stack buff overflow and I wanted to show that this is in QEMU and I took the same exact payload. The padding is different but still the same payload. Copied it to my device and it works beautifully. Great. So, going forward though, I'm talking about all this exploitation stuff and I was guilty of doing this. I was super guilty of doing this. I would find a vuln. I would say, yes, PC is 41, 41, 41. I am done. Drop mic. But that doesn't do anything. I was limiting myself and I was limiting my growth. So, we need to get away from this. We need no more dos pox. And I vote that we, we make pox great again. But don't worry, I'm not going to build a Faraday wall around these devices and may the vendors pay for it. I guarantee you that. So, this is my demo now. So, um, yeah, so let's get started. But before I, I do this, I like to get, kind of like get into character. Kind of have fun with this. You know, we're, we sit here all day, we see talks. We need to have some fun, right? So, have you, have you guys ever seen stock photos of hackers? Hello. Okay. Uh, so before we get started, I'm going to set up the environment first. So, the application, I'll be, I'm going to be using, I'm going to be using, I'm going to be exploiting in this demo. It's called socket BOF. Um, the application, all it does, it's listed on a socket. And whatever data it gets, it just stir copies it. These, uh, these levels and stuff, I'll talk about towards the end, are supposed to be educational levels to help you learn about this kind of stuff. But, let's, let's just set this up. What? Hold on. Hold on. Huh. Yeah. Hold on. There we go. Yep. All right. Sorry about that. All right. Um, before we get started, can we kill the lights? All right. Awesome. So, what I'm going to do here, um, I forgot my own arguments for my own script. So, that's why I had to print out the help. So, we're going to set this whole thing up. And I'm going to get my microphone because my computer is going to do the rest of the talking. Sorry. I'm a little slow. Huh? Thank you. Uh, let me make sure that it's actually... All right. Cool. Just want to make sure, you know, I don't want the demigods to get mad at me. So, we did this on 8080, right? So, now, so, over here, uh, let's make a new tab. NC-L-V-P. So, now, we have a Netcat listener waiting. And, uh, we're going to, uh, we're going to, uh, we're going to, uh, load up some stuff. And I'm now going to make sure that's right. 8080. All right. Cool. So, uh, without further ado, let's get this going. Oh, no. Hold on. The sound's not working. No I don't. Aw man. No! No. Oh, it works. Front, left. All right, cool. Hello, IoT Village. Before we begin, I want to say that this will be my last performance of this demo. With that out of the way, let's corrupt this application stack. But first, we need some sick hacking music. That's better. Now we need to cover our tracks for that offset. Thank you. Thanks, guys. So we can also verify. So this application is still in this stuck state. So if I go back to Netcat and just kill it to just verify, then it's, you know, it returns. So that was an actual exploit. So thank you for bearing with me with that. Like I said, I just want to have fun. You can bring back the lights. So like I said, I just want to have fun with that. But like I said, I went from not knowing myths assembly to doing that. So it just takes some time. You guys can do it too. It's pretty straightforward. The differences that I learned, X86, based stack buffer flow is pretty simple, straightforward. Like I said, a thousand times. Ropping, just know where ESP is and where the RET's going to happen and everything falls into place. MIPS, base stack buffer flow is a little bit less straightforward because of the less instructions that you have than X86. But it's a little bit more fun, but it does require roping. So if you've never roped before in X86, you should probably do that first before coming over here. And then roping in MIPS, same thing. You're just calling different APIs and feeding it different arguments, same thing as X86. I haven't finished this one yet because I'm still learning the many, many, many, many, many, many, many different instructions that ARM provides. So this one, so far I've seen is that the gadgets can be found in different modes. The same function can represent two different types of instruction sets all at once. You can analyze a function in ARM mode and have different instructions that we have in thumb mode, right? Kind of as expected versus 32 versus 16 bit instruction sets. So and then at the very end, you also have something called pop PC which can be used for your ROP. So you just pop PC, pop PC, pop PC. Or RET, right? So interfacing with JTAG or interacting with JTAG. So this is an Arduino Zero that I bought. Um, I used it more because I had a Cortex processor and I wanted to play more with real, more real time devices. So this is the JTAG layer like I said in the beginning where, you know, you can use the, you know, Arduino, blah, blah, blah. But I just wanted to learn actually like how does this work? So on this device, JTAG is listed up. I was like let's brute force this and see what happens. So that's what, this is JTAG layer. You just hook up as many pins as you want, before I even do that, who here has heard of JTAGulator? I am not going further with what I was going to say about JTAGulator. Very, very straight forward, right? So, next step though. Alright, so I find TDI, I find, you know, I find data in, I find data out, I find mode select, I find everything I need, I find the clock. Now what? Now you have to actually interact with that interface, right? You have to actually talk to it. Um, the state machine will still be the same, but the instruction registers and data registers, think of it as operand and opcode. Same thing, right? You have a opcode and an operand to go with it. Same thing, but it's in JTAG and they're very small registers. So, there's an open source project that I use called OpenOCD and in this one, um, it's funny because one of the devices that's in the other room, um, I actually used OpenOCD to talk to JTAG, so it's actually pretty cool to see that in here. But, once you have JTAG open and you actually can talk to it, you can't just say OpenOCD, my FTDI chip that's connected to JTAG. No, it has to actually know the profile. So, if you go online, these things have many, many, many profiles already for a lot of chips and different manufacturers, you know, like ARM, right? ARM is not a chip maker, right? It's just, it just does its, uh, instruction sets and all that shit. So, but different manufacturers will implement the same JTAG state machine and all the instructions and everything else the same. So, different type of manufacturers will use the same OpenOCD configuration. Also, newer versions of the chip may also work on older versions for that JTAG as well and vice versa. So, don't get stuck when you can't find the configuration file for your exact processor. Find something around it or with the same architecture and it may be the same. So, when you open it up though, just, this is just for people that have never used it before. You have GDB server that opens up locally and you can start dumping memory. You can do whatever you want. It's GDB, right? So, what's great about this, this was on a Cortex processor and Cortex has a very specific memory layout. And with this one, there's a specific memory address. If you look at the data sheet, you could dump AES keys and all that good stuff. So, this is very powerful when we want to kind of extract information from it that we can't get to it normally. Like, maybe SPI, the flash chip's encrypted or all this other crap. So, this is our last resort. I always like to say that start with the software stack first, exhaust all your resources, then go to hardware and start from easy to, you know, easy to hard. It's the same thing that we always do in our everyday lives. So, once we have the JTAG, uh, connected and it's connected to it, we can say how fast is the clock going, I want to measure this, I want to reset the entire processor and then halt. I want to set a break point when, uh, like, you know, say at this memory, not memory address, when, uh, when memory address is being written to here or like when the kernel's being loaded, we can do whatever we want. So, like, for example, if there's URI, if there's a smart password, you can use this at a watch point when the kernel, uh, arguments are being loaded, set it to single user mode, let it load, done. So, wrapping up. So, I, I want to say thank you guys a lot for sitting through this. I know I've been a little repetitive, a little fast, but thank you guys. This is wrapping up now. So, this is my project. This is the, uh, demo that I gave you guys. Uh, this is called my damn vulnerable write-up firmware. Where'd it just come from? This is the literal story. I was in my shower thinking about damn vulnerable web app, damn vulnerable web app. It's called Linux. I was like, that's so silly. That's so many of those. There's not one for routers. So, I'm going to make one. So, that's what happened. But how did I do this? Remember that tarball thing I told you from a while ago? This device was sitting in my closet, not doing anything. It's a $10 device now. It's an AO211N. And I just picked up my thing. I was like, oh, let's start writing firmware for this. Let's actually do it. So, that's what I did. I downloaded tarball and just started ripping everything out. I started learning how they did everything and just made my own custom, uh, tarball for it. And that's on GitHub. You can download it. You can fork it. You can do whatever the hell you want with it. But this is how this works. So, I'm working on another device. The device is actually, actually, they actually have it in there as well. It's a trend net. It's an ARM device as well. I'm just having issues compiling the kernel. Um, it keeps bombing out for some reason saying that, uh, processor dot H is not found. So, uh, once I figure that out and kind of fix that, then I'll have another DVRF build for ARM. And what's good about this is that there's two ways to do this. You can put the firmware on your device. It can always revert back to. There's not a whole lot. It's a one-way street. And when you do that, the device, the, the ponables that I have on there are only accessible through UART. You have to start them through UART. So, this forces you to open up the device, plug through UART, find the directory, find the executable, run it, right? Or you can emulate it. I prefer both ways. Just do everything that you can. As long as you get the point B, who cares, right? But this, this idea was to learn, to help people dig into this, get the hands-on experience with exploiting stuff outside the x86 space. And also help IOT developers. I say IOT like this, just, it's a key word that's very stuck in my brain. So, help people learn this stuff as well because I've seen 90s programming code in today's architecture. When I was doing example codes of start copy and just, you know, funny stuff, that's actually happening today. I will be demoing an exploit tomorrow that's an actual one that I found that does this kind of stuff. And I'll be chaining four vulns together in order to get complete compromise. But that'll be for tomorrow. It's in the IOT Village. Same with plug. So, this is where you can download the damn vulnerable router firmware stuff on GitHub. That's the, the link. It's on Praetorians GitHub. I am updating it. I, you know, if, if you want to update it as well, more people, the better. This is for the community. I just wanted to see if I can teach what I've learned. That's all I want to do with all this stuff. If I can learn it, you can learn it as well. I'm not some amazing guy. I'm just some little kid from Texas. My future plans is to keep working on this stuff. Do the ARM one. Get that finished. I have a blog post that I've done on introductory to, uh, hardware exploit, uh, software exploitation. And then getting started with this project as well. And that code for this exploit that I demoed is on the blog as well. Fully documented as well. You can copy and paste it and do whatever the hell you want. The shellcode is in there as well from Bowcaster. And, yeah, take a look at it. Do whatever you want. I'm also available on Twitter. And I'm always available to help you guys out. There's no such thing as a dumb answer or a dumb question. There may be a dumb answer from me. No such thing as a dumb question. If you are confused, lost, need some help, or going, hey, man, I've been probing this thing for hours. Can't find anything. Can you help me out? I'm always here to help you guys. That's what I want to do is teach and help people grow. That's what we're all doing here is to grow, right? That's why we go to conferences. So, uh, before we wrap up, I'll be holding a workshop tomorrow at the IoT Village at 10 a.m. Uh, basically it's a bring your own device type thing or maybe take one or borrow one from IoT Village. Or just share one from a researcher. We're doing a zero-day hunting workshop. But we're not just finding vulns. We're going to take it all the way to Code Exact 2. So, attendees will be, uh, encouraged to craft exploits for the vulns that they find. All the vulns that are found just because of, you know, disclosure policies and stuff like that will be safely disclosed over PGP or whatever, uh, communication the vendor prefers, uh, to the vendor first. And then we'll do the exploitation and get that underway. And then you can go, you know, claim your prizes or whatever. But I just want to help people actually find this stuff and get the hands-on experience. We sit here and watch and watch and watch and watch. Let's actually do stuff and actually commit it, right? So that's tomorrow at 10 a.m., IoT Village. Um, I can put this out online if anyone wants it. You guys take pictures too. The multimeter that I use and the USB microscope, literally Amazon came in, tried it out, worked great. Nothing more crazier than that. But the one thing I use a lot is the FT232, which by Adafruit is $15. Um, the equivalent is the Shikra, which is $50. Has a little bit more to it, but it's the same chip. Um, so depending on your budget, you may want to go through that route. But, that's the end of my talk. I appreciate you guys sitting through this. Are there any questions before we say, get out? Yes? So, um, for chips that, or excuse that, have block bits or if they have, like, JPEG to see if there's one or anything, would you be able to, like, ask, ask those questions? So, the question was, um, around, uh, was it the manipulation of, uh, chips if, like, JTAG is disabled and stuff like that. So, there's, there's one question around that, too. How is JTAG disabled? Is it software disabled or is it a fuse? If it's a hardware disabled, you're kind of screwed. Unless you can, you know, decap it and, like, fuse that fuse back together to bridge it. If it's software, find the reset pin, ground it or, you know, do what the data sheet says, but it's usually ground it. Power it on. Everything will turn on and no software will be loaded and the JTAG state machine will be accessible. So, but if it's the latter. You're kind of screwed. So, that's the only downfall, right? Yes? What if, uh, GDB is not enabled on the device? If GDB what? It's not enabled. So, I have cross-compiled GDB and I can teach you guys how to do this well. So, on my device as well, I had, uh, there's no GDB on it and I had to craft my exploit. So, that's why I was doing the emulation route. But I did cross-compile GDB for, uh, MIPS and I believe it was, like, MIPS Big Indian, Little Indian for, uh, for generic instruction of MIPS 1. So, that's on there. You can compile it yourself. It's a little bit of a pain in the ass. But it's doable. Um, so, you would have to cross-compile it yourself. Put it on the device. Or, if the device doesn't have enough space on it, you're going to have to go through the emulation route. So, that's the only two ways. Cross-compile it yourself. Put it onto the device. Because most devices usually have wget. Um, they usually have wget or you can just echo it through the serial interface and just put it into a file, right? So, uh, put GDB on it. Run it. Or just emulate yourself through QEMO or whatever you want to use. So, that's... If you put a GDB on it, do you have access? If what? Do you have access? If you have access to GDB? If you don't have access. If you don't have access to the device, how can you put GDB on it? Oh, you can put GDB server on it. GDB server. And then just attach it to the process. Have it listed on the socket. Connect over the socket. Over the network. And that's it. That's the way I've done it. Like, I've always either GDB and then I put GDB and I use it over a serial interface. Or GDB server. Connect it over a socket. And just do everything like that. Or just emulate it. That's pretty much it. Nothing too crazy there. Are there any more questions? Yes? What hardware did you use to talk to the flash chips? Yes. So the question was what is the hardware that I use to talk to the flash chips and stuff. That is the Adafruit FT232H breakout board. It is a FTDI chip. And it supports JTAG, SPI, I2C, UART. And I believe that's about it. But there may be more. But that's what I used. And in the open OCD, you just tell it the driver to use is FTDI. It will automatically attach to it. So, yeah. That's $15, man. So that's the one I use. Any more questions? Yes? Have you been working with Cortex M3 and M4? So basically the Archons? What did you take on, like, trusted platforms? I mean, MLTI. So this one is kind of a heavy question. So he was talking about the Cortex M3, M4s. You know, the real-time devices and the trusted model. Trusted models, right? Trusted platform. Yes. Trusted platform. I haven't looked into that. So I don't know at this time. So I would have to follow up later. So right now, I just don't know. I don't want to give you a bad answer. So, yeah. Let's sync up afterwards because I want to find you that answer because I'm curious now as well. Any more questions? No? Yeah, sure. So if you guys want to, you know, if you guys want to, you know, if you guys want to see what's going on in my not-so-interesting life, hold on one second. Yeah. So my Twitter is, it's BlackOwl, but someone already had that name. So I said no. So I replaced the L with a 1 and the O with a 0. That's about it. Nothing too crazy. The image is I was fuzzing libpng with an owl image and it looks pretty cool so I took a screenshot. So, yeah. That's about it. Any more questions before I just wrap up? No? Great. Again, thank you guys. Have a great conference.