All right, so those of us in the hardware hacking village are looking at kind of covering more than just soldering. There's a lot of stuff that's kind of interesting in the hardware realm, and one of my real interests these days is looking at firmware, tearing it apart, figuring out reasons why things are insecure. The presentation will be up on my GitHub. I am Matt Duarte, also known as CryptoMonkey. You can find me around a lot of different places. Neg9, if you're up in Seattle, we hang around the Black Lodge quite a bit. Obviously, the standard disclaimers always apply to these things. This talk does not represent my employers, my dog. Pretty much anybody except my opinions. And what I want to talk about today are really some of the motivations of looking at firmware without actually running it. And that's kind of my point. If you take a hardware hacking course, they're going to say, oh, look, there's a series of hardware that's going to be running . Let's connect to it and do all that. But not all devices have serial ports. If you take, like, an infusion pump from inside a hospital, you won't find a lot of serial ports on it. So we're going to talk about that. We're going to look at the attack patterns. We're going to talk about some of the extraction protocols and technologies and then look at the firmware. So this is meant to be a bit of a beginner's talk. I'm going to cover everything from getting the stuff off the box to our basic analysis. Obviously, there's only so much you can talk to in an hour. But we should have a lot of fun on with this. So the question is, why do this talk now? Well, the thing is, this is really a lot simpler to do than most people think. You open the box up, you see all these chips, but it's not that bad. Once you get the little dongle, $40 little dongle, either a Shikra or a Bus Pirate, you can actually pull the firmware out and start pulling it apart, all using open source tools. Now, why is this important to us? Well, if one were to look at the NSA catalog, you will see some very interesting entries, such as persistence on laptops via the firmware. Providing security on by modifying the firmware. The whole point behind this is there's a lot of stuff going on here where people look at the firmware or they just run these systems without actually checking what's going on here. So even though we have a lot of stuff going on, we're really not really actually by the logic of even if you're not that concerned about the NSA spying on you, well, there's a lot of other problems here. Shadow IT and bring your own devices are bringing lots of these little embedded devices into our workplaces and we don't know what's running on them. We don't even know if that's the firmware that was shipped with them. We don't know if it's ever been audited. In fact, it probably hasn't. So maybe we should do some auditing ourselves. There's also some competitive analysis, too. There's also the problem of who's stealing your code. I have a case here, a pretty interesting one, American Superconductor versus Sonomial Wind Group. These guys make wind turbines, right? Well, the source code got stolen and quite bluntly, a city, I think it was in Michigan or something, bought a wind turbine from China and it had this American company's stolen firmware on it, they allege. It's still in the courts, but there's some links here when you get the presentation. You can follow up on it. So, again, if you pull the firmware, you might be able to compare it to yours and see how similar they are, if anybody's done it. So, definitely when you do this stuff, try to stay on the right side of the law. I'm not a lawyer, but I'm telling you, you can get into some real problems here if you suddenly say, hey, all of this device are vulnerable and you haven't contacted the people or gone through this stuff. So definitely keep an eye on that. Also, I see a day in which you got a question whether your cyber insurance policy will cover you. If you have a claim against you and they say, hey, are all of your devices updated, you may actually have to prove that you've really updated the firmware on all of your devices. The same thing, if a Tesla in auto drive mode crashes, they may actually question, are you up to date on the firmware before they pay the insurance policy? So, again, this is kind of important and we're really just getting started on it. But it's accessible to you now. I mean, in the past, we all had to have these $100, $200, $800 sniffers in order to talk to the chips, the memory chips that hold the firmware. Nowadays, it's a lot simpler. You can do it with these low-cost devices, lots of things you can do. The first were a little unreliable, but they're getting better. So when you grab a device, first thing you do, you look at the device. What kind of architecture? Are you doing this for somebody else? What architectures do they use? What kind of technologies are in there? Your customers should be able to tell you this. If not, little OS in, you know, Google the device, you can see what kinds of processors that are in there. If not, Google the device, you can see what kinds of things that have. But more importantly for us in extracting firmware, what type of chip does it have in it? Also, you have to also decide how much you want to spend. I'm talking about doing this on the cheap. Sure, if you have a big company and a lab, you can go buy your Deddy Prog and pull that stuff out. $1,200 for, you know, a hardware device is great. I'm talking more how to do it with a $40 device. You can spend lots and lots of money on it. You can have an insane pile of junk like my lab at home. But you can spend a lot of money on it. You can have an insane pile of junk but you don't need it. What you really need to get started on ripping open these embedded devices is a screwdriver, a couple jumper wires, I highly recommend a magnifying glass, and something like a shikra, this little $45 dongle that will speak I2C, JTAG, and SPI. In fact, the most valuable upgrade of all the equipment in there is by far the microscope. If you have any extra money, get a good microscope. If you want, we have one over in the hardware hacking village. You can take a look at the difference of what you can do with this. Also, if you're in business, make sure you buy a trinocular one. That's this extra tube right here that has a video camera on the top of it. It means I can make pictures and put them in the reports. Makes you look much more professional, less likely to get sued when you actually present this to the people. So you've done your information gathering. You've looked at the product lines they have out. Again, you'll often find similar parts in them. And there can be some odd parts that make it a little tougher. But today, I'm going to look at two devices. These things. Little cheap devices I bought at Fry's. Didn't even know what they were at first, but I looked them up. The first one, the lovely TP-Link TLPS310U is nothing but a, wow, that blue doesn't come through very well. It is a little print server. Okay? Ethernet connected to your printer. It's a print server. What I like about it, well, it has an Ethernet port. It has a USB port. And according to the documentation, it's got a TN I can have it on the computer. And again, it has a GUI. This will become important to me later because I like things with GUIs. The other one we'll look at is of course the lovely TLWR702 which is just an 802.11N router. Again, Ethernet port and a GUI. Terrific. So what are the threats to these things. Well, you're going to put them in your environment. You're going to do lots of interesting things with them. They're going to be on your Ethernet inside your protected environment. So if somebody Trojans it, I'm going to charge them. And I'm going to pull out a bug from my computer. There's a bug expression. So if somebody Trojans it, I'm going to do lots of might want to know that. If it has a vulnerability like a built-in password, I might want to know that. So I want to audit it. Also, you have to consider what you're going to do when you're done. Are you going to report it to the manufacturer? How do you think they're going to react to you tearing their stuff open and pulling the firmware out, analyzing it and screaming to the world, hey, this has a back door. Definitely be prepared for that. What's the public good of your research, that sort of thing. Also, if you're a company, make sure you have a good lawyer and you're doing everything right because I guarantee you the DCMA security analysis exemptions will not protect you from being an ass. So the other question, one of the things I like to do is how hard is it to open the case? You saw these little plastic cases. Did these guys use security screws? Did they use tri-lobes like on an Apple device, right? If you had to go and get a special tool like this set here that's a million different security bits to open the case, they have an argument that they did something to protect it. You can't just crack it open. But, of course, in these cases, these are just little plastic cases with plastic latches. A monkey and a screwdriver could pry these things open in a few minutes. In fact, that's what I did. I gave a monkey a screwdriver and he propped them open for me. What I found on the inside? A board. Okay? I found chips. I want the firmware, right? I don't care about what the chips are. I just, what is the firmware? Where is the operating system of this device? So I look up the chips. The ones at the top are power. The ones at the bottom are chips. The little black ones there are not really chips. They're voltage regulators. But I found a couple of big chips. I've labeled them off. And there's a clock chip over there. So get my magnifying glass out or my microscope. I look at the numbers. I Google the numbers. Okay. First one we find. The H1631CG. It is known as a base T surface mount magnetics. Anybody think the firmware is in there? Show of hands. Magnetics. They're transformers used to convert the electricity from the Ethernet jack to the power supply. They're transformers used to convert the electricity from the Ethernet jack to something that will work on the board. They are not firmware. Okay. Let's try the other one. The E2868M4. The system on a chip with built-in USB 2 and Ethernet. Anybody think that has the firmware? That's the system on the chip. That's your CPU. Okay. Third try. The 25L8006E. An 8-bit serial CMOS flash. How many people think that has the firmware? Yes. Excellent. All right. Let's go to the next one. Let's go to the next one. Let's go to the next one. Links at the bottom are to the spec sheets that I got my pin outs from. So, in this diagram where you looked at it, what was missing from this diagram that all the hardware hacking courses will teach you? Well, if you go look at, say, a TP link of some larger router, this isn't a, what is it, 841N, 300 megabits router. Much bigger circuit board. But the first thing they're going to say is, hey, see all these little empty pins here? I want to get rid of all this. Look at what they do. Those are things like serial ports, JTAG adapters. Unfortunately, our devices don't have those. And that's the challenge with embedded software. All these guys in the courses will teach you, hey, find the serial port, connect to it, look, I'm on a Linux prompt. Unfortunately, a lot of these devices simply don't have that. Your only choice, if you want to see the software they're running, is to go to the firmware and pull it out. Okay? Because without the serial port, it's really hard to look at the running software. What's in memory? What's going on? Now, on an embedded device, what's in memory is actually not as important because you don't see a lot of persistent malware sitting in a print server, sitting in a printer because they have more memory, but not in print servers so much. So by doing it the way I'm proposing, pulling it out of the firmware, you're not getting the live running data. You're just getting the data that will be loaded every time you boot up. So you lose access to exploits and things like that that are only in memory. You just get the loaded stuff. But that's not necessarily a bad thing. For the simple reason that for those of us who have lived with rootkits for years, we understand that running systems lie. You cannot trust anything a system tells you when you log into it. Because if it's been Trojan or a rootkit, they hide their activity. On a simple system like this, it's a little harder, but the storage that's mounted on it is actually a very reliable place to get what's going to be at least memory when you start. Plus, there's no way for the running software on the device to modify your view of it. You're pulling it straight out of memory. We're going to audit the entire system here, not just what is visible from a running system. The other device is, of course, the TP-Link 702. I looked at it. I found the chips. I find a big memory chip up at the top there. I find another SOC, an atheros system on a chip. Has built-in wireless. Great. And I find the magnetics again. Oddly enough, there's no storage here. Well, simple enough, if you flip the board over, there's my little 8-pin SPI flash. Exactly what I was looking for. So, in both these cases, I found an SPI flash that's going to have my operating system on it. So, I've opened it. I've got my chip. Let's pull the stuff off. All three of the routers I've showed you have an SPI-based flash. Now, that's going to be where it is, where I want to get my stuff. There's three big protocols that you deal with here. SPI is the one we're going to do with all of these. But the three protocols you kind of need to know to do this stuff. I, too, said I'm going to do it. I'm going to do it. I'm going to see JTAG and SPI. And really, my point is that you don't need to know a lot about these protocols. A little bit of protocol knowledge is all that's really required here. You need to find the type of chip. You need to find the pins, wire them up, and that's it. You don't care about thermal characteristics. You're going to find 20 pages of data sheets, and all you care about is what signals are on what pin. That's it. You wire them up to your tool, and the tool will tell you, hey, if you're going to do this, you're going to do this. If you're going to do this, you're going to do this. If you're using a bus pirate and you want to talk SPI, I need to find these four signals, connect them to those pins. That's it. Use a shikra, you'll find the same thing. If it's SPI, it's telling me find four signals, those are four leads coming out of the chip, and attach them to me, and I'll take care of the rest of it for you. So quick and dirty on these three protocols. I2C requires two wires. I've got to find two signals in order to talk to something that talks I2C. There are I2C flashes. They're not as common. They're not as common as the common. They can run on three volts or five volts. Again, power matters when I feed it into the chip. And each one will have an address. Sometimes I have to tweak that a little bit. But you'll see that if I find an I2C chip here, this is non-volatile I2C memory, it looks the same thing. It's, you know, eight things coming out. I look on the data sheet. Data sheet's available here. And all I care about is finding power in, power out, and the two wires I'm looking for. SDA, the clock, or SDA is data, and SCA is data. So I'm going to look at the data sheet, and I'm going to yell the clock. Those two wires connected to my little bus pirate or Shikra, I now have a connection. I can talk to this chip. You'll find I2C in things with low-speed applications. You'll find it where log files sometimes, things like that. It's not the fastest protocol. Also be aware that while I2C in the spec can get up to about 3.4 megabits a second, things like the bus pirate only talk at 1 megabit a second. That means you talk to it slowly and it takes longer to get the data out. Remember, I'm looking for two wires and some power. Second protocol, this is the big one. We'll go over this a little bit more later, but the JTAG. JTAG is actually a set of adapters. It's a way of talking. But the thing you need to know about it is there's up to five wires that can make up JTAG. Okay? TDI, TDO, the clock, TMS, and the test reset. Something like the bus pirate is able to talk to three of those wires and gather data off them. That's generally enough. If not, something like the Shikra. Shikra can handle the four-wire variation. Also understand that while SPI and I2C are protocols that chips use to talk to each other, JTAG is actually a separate circuit that's on the die that can do things like debug the chip, stop it running. There's a lot you can do with it. As well as reading and writing the firmwares. We see this a lot in FPGAs and CPLDs. That's how they get the firmware onto those things. Because of the added cost of it, it's really nice to be able to debug the chip. It's normally only on things that require you to add in debugging capability. So you'll notice that none of the devices we're looking at have that sort of capability. They don't need it. The system-on-a-chips are debugged a slightly different way for those. There's also a real variety of JTAG devices that can appear on a network. You'll find, like, a memory chip. I'll show you a picture later, but you'll see, like, here's a memory chip, here's a system-on-a-chip. All of those things can be on there, and you'll step through them deciding which one you actually want to talk to. That's different than I2C. I2C where everything has an address or SPI where everything is going to have either an enable or disable. But, again, what do I need to know? What do you need to know about JTAG? Find the wires, connect up to them. Last one you need to know, SPI. This is the one that all of our examples are going to look at. So four wires I need. A clock again. Master in, slave out. MAZI, master input, slave out. MISO and the slave select is just the one that says you're the active chip. So again, I'm going to find the four wires. Both the shicker and the bus pirate will support SPI. It's faster than I2C. It actually requires less power, which is why you often see it in these embedded devices, right? They're limited by the amount of power they can do. All the TP-Link devices that I've looked at here, and I'm not picking on TP-Link, they were just what was cheap at Fry's, use these SPI chips. So that's really all you need to know about them. I mean, you can go read Wikipedia. There's pages and pages. There's tons of specs. But from the point of view of pulling firmware, we don't care. It's already on the board. We're not an electrical engineer. All I need to do is connect to it and get the data off it. So if I can find those signals, that's all I need. I don't need anything else off of these things. You can dig into it deeper. But from an auditing point of view, I just need to know how to connect to it. And for that, I get a hardware adapter. So we're looking at two hardware adapters. We're looking at two hardware adapters. We're looking at the bus pirate and the shikra. They're the most common ones that are used at the entry level. There's the bus pirate. You have a V4 on the left and a V3. They both do basically the same thing. But what's key about this is there's a USB port on the bottom. You connect that to your computer. And all the pins at the top are what we're going to wire to the chip. Then I have the ability of my laptop to talk to these chips. These adapters have made it possible now for me to talk to any one of those protocols we've talked and even more. There have been multiple generations of these adapters. They've made it possible now for me to talk to any one of those protocols. There have been multiple generations of these adapters. They've made it possible now for The accommodations are designed. They've gotten a lot more stable. But that access via the serial port is what we really are after. You can use something like a bus pirate to send individual commands to the actual chip. Things like read this byte, write this byte, play around with it that way. So again, here's my cheat sheet on the bus pirate. I look for these pins labeled on the left, mozzy, clock, peso. And then to talk spy I just find the ones on the chip, I wire the two of them together. Once I've done that, I connect the Bus Pirate to the laptop. I literally just connect to it as a serial port. I plug the USB in and say, hey, you have a new serial port. Go with Minicom or Screen or something like that. You connect to it and it says, hey, what do you want to do? And it has just a little operating system. I say, tell me what modes you can be in. And it lists all the different languages those pins can speak. The one we care about is number five, Spy. And with this, you walk through a menu system and you set the parameters. How fast do you want it to run? Well, we go look on the spec sheet and say how fast it will talk. Although they auto set pretty well. And you can get Bus Pirates all over the place. So price point here, at the time, these are about 40 bucks a piece. Definitely within the hobbyist realm for you to go grab one of these. And I've given a few companies that I know sell them that are reliable. The Bus Pirate was a little slow at things. The next gen is this one called the Shikra. Most of us are using this these days. It doesn't handle quite as many protocols as the Bus Pirate, but it's a lot faster. It has a newer generation of chips. It's very stable. Documentation and examples, not quite as many of them out there because it hasn't been out as long. And also, you'll find that this one, you won't connect to it and interact with it as much. It's a little bit more of an... interface that you'll use other programs to connect to it and pull it through. But you'll see the same sort of thing. It's a USB port you plug in and then you pick what protocol you want and just match the pins up. So pin one for our spy connected to the clock. Find the SDI, put it on two, chip select, and the ground. Again, they're available online, about 45 bucks. So again, something in the hobbyist realm definitely you can get at. So now I've been talking about connecting to the chip. We've got our little dongle here. Now we just need to connect the two of them. So once we have that, this is actually the most painful part of this entire process I will talk about. Everything else is actually dead simple. You Google it, you open the thing up, really simple. Connecting to the chip, this is where all your headaches come from. And it's mainly because most people start off with a test clip lead. It's a little thing that when you push it back, little hooks come out. You can attach that to the leads. And oh, that's a pain. So I go back, I look at the chips, here are the two memory chips we've dealt with. I said they're both spy. They're both eight pins. What do I need to find? Well, there's my chip select, there's my SI, there's my SO, there's my clock. Those are the ones I need to connect to. The other chip, you'll see they have has a similar layout. So the two memory chips, both eight-pin spy. I need to get those signals into my bus pirate of my Shikra. Simple as that. So I take my little clips out, I begin connecting the clips, and that's what it looks like. Now, these are fairly large clips. You can buy smaller ones. They are more expensive. They still fall off all the time. This is a horrible way to do this, but it'll get you a connection. So at the end of each one of these clips, I then connect that to my adapter, and I've got what I need. So they also can do things like short out pins if you use too large a clip. These are actually, the chips that we're looking at in that picture, are actually physically have pretty large leads to connect to. When you get into finer chips, you can't really get the clips in there as well. So if you can invest about 30 bucks more, one of these is a godsend. This is just a clip that goes on top of the chip that allows you to get the wires out, and this one has a few leads soldered to it. It saves you an awful lot of time and trouble because you just take the chip, clip it right on there, and it touches all the leads, pulls all the signals out, and you're good to go. It makes it very easy to connect. It just gets on all the legs at once. But again, for the beginner, that's 30 bucks for a clip like this, and you have to buy a clip for each kind of chip size. The last thing we need before we actually start downloading the firmware is power. I've talked about wiring up all of these signals, but the other thing that you need is the chip has to have power. You have two ways of doing this. Either you turn the device on and let it power the device up. Or you're going to have to connect power from your, say, bus pirate, and what it needs is a power in and a ground. It's really important that both the device and your adapter share the same ground because what we're doing is we're reading the signals of all these pins. They need to have a common zero point. So it's very important to get that ground also connected. Basically, I just power the stuff on most of the time. It's easier. But if you want to make sure it never boots, then you need to have a power in and a ground. And then you need to come up with an external power. When you're all done, that's what it looks like. You've got a clip on the chip. I take my wires. I wire them in the right spot of the shikra. I'm all ready to plug the shikra into my laptop. And I hate to break it to you because it's pretty anticlimactic after this. Really, once the devices are in there, the two devices we have when used directly are good for doing one read, one write. Bit banging is what we call it. You access one byte of data at a time. Sure, you can loop it, but it can be a little messy. But since both these devices are easily accessible via this serial port, USB serial, but this serial port, other things can talk to it. So people have written tons of helper programs to help you out here. So this is where we are. We've got our device. It's powered up. We've got everything wired up. We're all connected. Let's use a helper program here. For pulling a spy, there's a really nice program called FlashROM. It's on most Linux distros, and there's the link to it if you need to install it. Once it's wired up, you literally just type a very simple command. FlashROM, you say the type of adapter you're using, and then R is what I want to dump out. So I've just told this FlashROM program to go use my adapter that's been wired up, and if it's wired up right, it'll actually go and say, Hey Chip, I want your config. Read it all out. What you end up with is an image. The same thing. If you had wired up JTAG, you're going to use a system called OpenOCD. Again, it's free. You can download it. There's the link. We'll talk about JTAG a little more later. But really, it takes a little bit more configuration because it's a slightly more complicated protocol. But if you want to use the Shikra, you see the blank there when you get the presentation, you can just Google it. There's a whole config of what you need to do to use OpenOCD here. You might have to specify a little info about the chip. What it is, how big it is, that sort of thing. Speeds. But again, once you have that, you literally just type OpenOCD-F, the config file, connect now telnet to 4444, and now you're in this little interactive prompt. And there's a command there literally just called dump image. Once you do that, you give it a file name, and it takes the whole image off of the chip and puts it on your laptop. You're done. You can also read it. You can write this way, too. You can pull some of the memory and all that. Really, all I want to do is just pull the whole chip. I want the full image, everything that's in the flash. Really, it's that simple. There are exceptions. There are harder things to get at. But basically, crack the thing open, find the right chip, connect your leads up with your $40 adapter, run some Linux software, and you're done. You now have this entire flash on your laptop. That's it. Simple, right? Yeah. Well, it's not always that easy. One, the memory I showed you had some fairly large leads for you to work with. Go check out some of the devices that are in the IoT village if you want to see really, really small leads. So if you have a small form factor chip, that gets a little more challenging. Those clips don't come in really tiny. In that case, you take out your microscope, and you start soldering tiny little wires onto each one of them. Sometimes you'll pull a connection out, but make sure all your connections are the same length. Doesn't matter. As long as they're under about 4 to 6 inches, you're fine. But no matter what, always, wherever you connect it, try to make sure the connections are roughly the same length. This is why I say that Microsoft is the best thing in the world, because when you're soldering really fine wires, that's a much easier way to do it. The other choice is to just desolder the chip. You go get some ChipQuick, hot air gun, you pull the chip off. You got to be careful when you heat them. Sometimes the flash gets messed up. But once you get the chip off and cleaned up, then you can buy sockets for it. This is just a very nice little board, but all you do is you press down on this. You can kind of see them there. The little legs will draw back. You put the chip in. When you let go, the legs will come down. Instant contact down to the connector. The trick is now you need one of these sockets for every single form factor of the chip. Notice here, these are both SCIOC 8s, but they're two different sizes, 150 mil, 200 mil. So as you work with more and more of the chips, you get more and more of these sockets. Boy, do you end up with a lot of these sockets. And at 40, 50 bucks a piece, this takes a little bit to build up time. But most of the major chips, these actually are generally for programming the chip before you put it on. But there's no reason you can't use them to pull it off. On the underside of these are pins you can connect to or put in a breadboard or attach to a Daddy Prog or something. This is a little more extreme. But when you get to those very fine chips, this is the way you end up having to do it. So what do we do now? We've got a firmware. It's on my laptop. I pulled it. I've opened the case. I've got everything. I go look on my laptop. There's my SPI dump bin. I see that it's four megs. And it's data. Data. Oh, I was hoping for, like, something I would know what it was. Remember, this is the equivalent of just imaging your hard drive. There's an operating system. There's layouts. There's all sorts of stuff there. So now you have to carve this up. Well, most of the forensics tools you're used to from the disk drive world kind of can work, but they're not that great. Thankfully, somebody already solved this problem too. Binwalk. Again, on Linux. It's free. It's easy. It does everything you need. Binwalk is a firmware analysis tool designed for reverse engineering. It does all sorts of cool stuff, and you just run it. So what happens when I take Binwalk and I run it against this image that I downloaded? Well, it says, hey, there's my Binwalk. Extract everything out of that. And it says, hey, at this offset, I found a U-boot version string. At this offset, I found an image header. At this one, I found an LZMA compressed dictionary. Got some firmware in here. It tells you all the things that it found in there. This is the equivalent of finding all the files, right? Well, since I said minus E, it also was kind enough to extract every one of those files for me. By the way, as an aside, if you're a CTF player, this is a really good way to pull images out of or anything out of the stuff they give you. But here I now have a file system that tells me everything I need to know, and including right up there. The Squash FS is the one I'm looking for. That's most likely my operating system. Oddly enough, it was very kind to me. It already unpacked it for me. So in addition, that one step where I said extract everything, it found the file system, gave me the image for the file system, but it also took the time to unpack it for me. And when I look inside that directory, does this look familiar to anybody? Does anybody not know what to do? What do you do at this point for beginning to audit your firmware? It's Linux. Okay. Remember at the beginning I said I like it when I see a GUI? Well, if it's got a GUI, it most likely is some little real-time operating system. If it's just straight embedded firmware that you have to go into IDA Pro with, that's a little bit of pain. But this I recognize. From a software world, this is a piece of cake. And it extracted everything down. So I want to know if the GUI's been backdoored. Where do I go? What directory is the GUI in? It's a website? VAR, dub, dub, dub. Or in this case, just straight dub, dub, dub. And sure enough, there's the HTML pages. I now can begin auditing it like I'm a software guy. That's it. The whole OS is now available for auditing. We never powered the box up, right? We never knew the root password. Didn't matter to me. I just pulled the whole firmware off. And software auditing is, we're root. We have everything on there to do whatever we want. All with a $50 adapter and some free software on a Linux laptop. This is a great time to do this stuff. I remember, you know, like I said, $800, $1,200 programmers. Nah, $40 dongle. You're ready to go. And anybody can do this. So getting back to my GUI comment, I like GUIs because most likely it has an operating system. If it's not, say you're on an infusion pump or something like that where it's just straight playing around with it, you'll get out an image that's executable. You always have strings, right? IDA Pro is probably your most useful tool because it talks a million different chipsets, all the different CPUs. It has them all built in. If not, Binary Ninja will do a lot of them. That's the new one. Vivisect, which is an old one from Kinshota guys. And Visigoth and Kinshota wrote it for CTF stuff. Radari, which I misspelled. All of these things, as long as you can match up the CPU architecture, you can begin pulling a firmware apart. Sometimes they're not as easy as, it's a Linux box, but hey, it's something you work with. So obviously you need to close the stuff up. Hardware can be a funny thing to report. Just be very careful talking to the hardware people. They get really upset when you do this, especially as it's really simple. And when you start finding flaws, what are they going to do? Recall all the little print servers and update them all? So you report a hole and make it public, it's going to be out there a really long time. There's not a lot of software pushes for these little embedded devices. And they're very dangerous. And if you go anywhere near an industrial or medical device, be especially careful. This is where I get back to that whole thing about taking really good pictures and writing a nice report when you report it to them. The more professional you look there, the less problems you will have with them in my experience. So this all looked pretty simple, I think. We bought our device at Fry's. We pulled it apart. We had a great time. We didn't electrocute ourselves. This is a bonus, right? So we've audited it. We find holes. We do all this thing. But at the beginning, I told you I wasn't really all that worried about that aspect of it. What else can you do at this point? Well, Linux has all the Squash FS tools. There's absolutely no reason I can't just take what I unpacked and put my own back door in it, put it back in the device, because we know that Binwalk gave us the exact layout of the image that we needed. It's really not that hard to create a new image to put on there. And, oh, it turns out Flash ROM is just as easy at writing that it does read. Now I have a new Flash on it. I put my clip on. I put the Flash back in. Now you have a Trojan device. Connect it to any network. You control now what it does. You're a pen tester. You now have a back door in. Notice I said pen tester, not malicious actor. But it's not that hard to see how this goes. And we're really right back to the whole auditing question because you modify it. You put the firmware back on it. Who's going to audit it? And you get back to the question of, I can see this coming in the near future where it's going to start showing up in courts and they're going to say, can you prove that the firmware has not been modified? That this is the firmware that was shipped and that it's the latest firmware. More of these IoT devices get out there. More of these embedded systems. More of these self-driving cars. All this stuff's going to end up with the insurance industry and legal stuff. So, hope that was interesting. Anything? Any questions? I got about 15 minutes. I do have all the devices that if you just kind of want to meet me off to the side, you can take a look at them, get a close look. You can see how big things really are. But if you want to hang on for a second, I'll take questions when we're done because there's a little bit more to talk about, right? I've made this sound very simple. And to a large extent, it is. If you find the right devices with the right chips, but what do you do next? You've got your, you know, your first shikra. You're pulling your first images off. You're trojan-ing your first, you know, print server to drive your friends up the wall by having it print out chicken, chicken, chicken instead of what they sent. Fun stuff like that. But there are other problems that pop up when you start opening your firmware or your hardware up. If we go back to that TP-Link WR-814 where I was dissing everybody who needs a serial port, well, what happens when you find these little connectors on here? How do you know what those connectors are? Can anybody tell me what this connector is? Four pins in a row. Eh, probably a UART. How about that one? Probably a JTAG. What's the pin out of it? How do you know? Again, how do you know it's a serial port? Or a UART? Which are the same thing. Or a JTAG connector? A lot of times, you'll find these all over and you want to know what they are. If your problem is an unlabeled connector on the board, one of your first investments, if you have a little bit more money, about $175, this device is very handy. It's Joe Grant's JTAGulator. What's it do? You wire it up to those things and you run a little program on it and it tells you, hey, I think that's a serial port and I think this is the parameters. And what you connected to my pin one, I think is this pin. Same with the JTAG. It's a really handy way to identify those little headers. If you can find them. So if they are kind enough to give you a header, something like this makes it a lot easier to walk through and it's actually pretty reliable for just a little board. If your problem is reading and writing to the chips, like your Shikra is just not cutting it, you may need to step up to something a little heavier like an actual programmer. They are also generally much, much faster. But where they really come in handy for me is simply most of them have a pull down where you just say, I have an I2C EEPROM or a SPI EEPROM. Here's the manufacturer. Here's the chip. It knows how to talk to it. It handles all that. This is, you know, about a, I think this is a total phase. So this is about a $250 programmer that does SPI and I2C. You can step up to a Dataprog, which will do pretty much any chip you can think of. If you see the guys who are doing like laptop BIOSes and all that, that's what they're doing. They're attaching the clips to it and using something like a Dataprog. They're able to pull out a lot more. The real plus of these is you don't have to do a lot of configuration and they're lightning fast. So if you're auditing a lot of things, they do save you a lot of time. But like I said, for the hobbyists, they can be a little expensive unless you're really into it. If you want to know more about the protocols, I glossed over the protocols and just said, hey, connect to these things. I absolutely recommend getting yourself a little USB logic analyzer. Most people recommend the Saly logics. I actually kind of like this cheap one called a Zero Plus Lap C. It's about half the price of a Saly. It only is USB 2. But it comes with like 110 different protocol decryptors in it. So you can say, in this case, I've said I'll wire up each of the pins. I've pulled the signal out. Then I say, hey, decode that as spy. And you'll actually see the messages as they go past. Again, fairly useful. Not too expensive. All in all, you're talking, you know, 300 or 400 for a little device like this that you can just carry with you. It's a little box that big, powered by USB. There's one in my back, so if you want to come look at it. But again, if you want to learn more about the protocols, it's a great way. Now, learning about the protocols, though, doesn't help you because, again, you're back to that bit banging and watching one byte go by at a time. The adapters and the downloaders, if you're really into firmware analysis, you just need to speed. You don't care about what bits went where. But this is handy for telling you when things go wrong. So there are a great many of these USB ones out there. They're not that useful for the download, but they're terrific for understanding how the protocols work. Make sure you get one that has the protocol dissectors in it. A lot of times, they'll just give you the signal. You want the one that will interpret those signals and say, if this is a serial port, then read it this way. If this is a serial port, if this is a spy, read it that way. And getting back to everybody's favorite, if you need both debug access, the ability to stop and start things, things like let the kernel load and then go in and edit kernel parameters or bypass the login screen or something, these are very handy. The JTAG adapter kind of serves two purposes. Because it can talk to each of the chips, it not only is useful for putting the firmware on and off the box, it also can be used for things like stopping the CPU, modifying values in memory, things like that. It is really the tool of choice for pulling basically anything where you want to go too deep on it. But I wanted to talk a little bit about JTAG because JTAG is really persnickety. It seems like every company, even though it's kind of a standard around what the wires are, everybody does it a little differently. So every time you have a chip, there's a JTAG adapter that goes with it. I'm a heavy FPGA guy, so the top one is my official Xilinx adapter for talking to Xilinx FPGA chips. One thing, you know, that's all it does is talk to them. It costs a lot of money for a genuine Xilinx. The bottom one is my Chinese knockoff that I bought on eBay that has a little switch right here that if you click it one way, it'll talk the Xilinx protocol. If you click it the other way, it'll talk the Altera, which is another FPGA manufacturer protocol. I've even seen ones that have three. This actually has two different sets of circuits to talk to them in one, and it's, what, 50 bucks compared to hundreds of dollars for the official Xilinx one. So getting back to whether your firmware has been pirated, I wonder how they managed to make it work. So if you're not into FPGAs, how many people know what ARM is? Everybody like ARM? Yeah, ARM is great. How do you talk to ARM for JTAG? Well, most of us use a SEGGER. SEGGERS are wonderful little devices. They talk to lots of the ARM chips. It's what we use. Here you see the $69 student version of the $400 SEGGER JLINK. It's what we all use. Terrific little thing. Next to it, you see the $25 knockoff from China. Funny, it looks... By the way, the official SEGGER is brown. The student version is white. That looks amazingly like the real one. It even says SEGGER right on it. But it's $25. And yet it works exactly the same way. Again, you got to kind of wonder how they made it work exactly the same way. I personally love playing with these things. When I put this up in Kyle Tools or any of my ARM development environments, it pops up fine. It seems to work just great. It's actually pretty interesting to pull some of these low-cost ones apart, take a look at them, and see how they compare. The biggest difference I've noted with the SEGGER is the lines, the wires tend to be a little noisier. The signals aren't as clean. I don't think they put as many decoupling caps in. But they work. As long as you have a good, clean physical connection, they work pretty well. But anytime you see something like this, you got to remember the protocols are often so specific, you got to wonder if they're sharing firmware. So if you open it up and pull the firmware, you can begin to look for pirated firmware, which I think, again, is going to be something that's coming up. People are starting to write books on how to do intellectual property in firmware and become an expert witness at it. I'm thinking this is the future for a lot of this stuff. In the case of these two J-Links, they run different versions of software. My official one is running 9.3. The bottom one is version 8. The back side at least looks a little different. The front, it looks really like a SEGGER, but the back side does definitely make it clear that it's not an official SEGGER made in Germany. And as any good forensics examiner will tell you, you cannot stand up in court with anything that is pirated or not the official version. Using any one of those SEGGERS in a court case would get you thrown out as an expert witness. Why? Because the one is the student version, which means that I can't use it for anything official. So that would be a violation of my terms of use. That would get me kicked out of court. The other one is counterfeit, which again would get you thrown out of court. So when you are actually going to do this for a business or anything official, you kind of have to go back and buy the official versions of things. Just be careful about that. You can get away with a Shikra that you own, but you can't get away with a counterfeit SEGGER. So that's the end of my time. Like I said, I have all of the stuff out there. I can take any questions. Remember, I just wanted to give you a basic intro. There's lots of caveats everywhere. Yes? I tend to buy the Pomonas, which are the cheapest, for the simple reason that I go through them and I need so many different ones. Yeah. PSYOC 150s are fine. Yeah. I've been perfectly happy with those. Although I also, as you see, prefer to solder on just a clip on the top that matches up with my analysis unit. To me, that's easier.