My name is Michael Coppola and I will be presenting Owning the Network, Adventures in Router Rootkits. To start off, just a little bit who I am. I'm a security consultant at a small consulting firm, Virtual Security Research out of Boston. And just a side note, we are hiring. I'm an undergraduate at Northeastern University. Just in the past I've done some stuff, played some competitions and won some of them. And if you want to see more information about this talk as well as some other work I've done, my site is poppopret.org. So a little bit, how did I come on this topic? How did this all start? A year ago I was on a penetration test and I came across a device called a MicroTik router. Basically MicroTik is a brand of router that's based on a very minimalistic Linux distribution but there's a lot of stuff going on in the user land. It's specifically designed to be used for IPv6 support. Basically one thing of interest is that you can install modules on these routers through the MPK packages. So you can install new features like a SOX proxy, a VPN, IPv6 support and even do crazy things like virtualization on the router itself. So this got me thinking, if we can install code on these MicroTik routers, even if they're vendor provided, what happens if we're able to create our own MPK package and possibly execute our own code on the device? Can we get a root shell? And this got me thinking about that. So I'm thinking, unfortunately, there wasn't the work done on MPK packages was mostly done on the existing work was mostly done on very old versions. I believe it was version 2 of the MicroTik router. And there's not very many of those around. But version 2 you can basically blow apart the MPK package, stick your own code in, package it and run Homebrew software on the device. But newer versions, I believe three or four, version 3 or 4, the MPK format had an extra layer of encryption. And no one had really figured that out yet. But they got me thinking, if this idea could be applied to MicroTik routers, why not apply it to all consumer routers? As many of you have probably seen, this page or something similar to it on your consumer router, you can download an update for the firmware from Netgear site or the Belkin site or D-Link site and basically reflash the router through the web interface and you get a newer version of it. But what happens if you don't have a new version of it? Well, you can take that version of the software right off the firmware, right off the vendor site, manipulate it to install our own code and then reflash the device through the web panel. So the big question brings us to, can a universal process be developed to modify SOHO router firmware images to deploy malicious code without altering the interface or functionality of the device? And in hacker circles, we like to call this a rootkit. So the first thing we're going to do is we're going to build a rootkit. So the intentions of this talk, I'm not going to teach you how to be a super elite hacker. I'm not a reverse engineer, but I'm going to share my experience pursuing a topic and the challenge I encountered, the mistakes I made, and hopefully you guys can take something away from this talk. Go home and do the same stuff that I was able to do. Gain some better insight into the internals of the routers and release a project that I've been working on for the past number of months to help facilitate basically the back-dooring of routers. And I'm going to do some demos, pop some shells and put on some devices. That's why everybody's here. So some prior work before getting into this. I wanted to see what work had already been done. Three main areas that I found a lot of help with was the open WRT and DDWRT communities. They've done a lot of work with custom firmware, homebrew firmware, a lot of reverse engineering and profiling of the router devices and the firmware. So I'm going to talk a little bit more about the firmware that runs on them. As well as a project called firmware mod kit. And basically it's a conglomeration of a lot of tools to help deconstruct and reconstruct firmware images. And as well as the site dev TTY S0. They've done a lot of firmware modding, reverse engineering, as well as exploitation of routers and embedded devices in general. So what are the use cases for something like this? I'm sure as many of you have seen out in the field or in a pen test, a lot of things have default passwords, admin, admin, admin password or just no password at all. Especially home routers. You plug them into a network, plug your computers in and you go. Basically if you have access to the admin panel, what's the worst that you can do? You can forward some ports if you really wanted to. You can DOS a network. But that doesn't help somebody who actually wants to further their exploitation of the network. So if as well as if there's a vulnerability to the network, you can do something like this. You can have a vulnerability in the router itself that gets you access to it, whether it's at the command level, like a shell, or just access to the admin panel through remote code execution or an auth bypass. I believe the two talks after me will actually be doing more of that stuff. As well as one vector which I didn't look much into but seems very possible is actually CSRFing the file upload. You can iframe the, put an iframe to a default IP 192.168.1.1 as well as like a default password, which is probably going to be there. And then you can actually do something like this. And you can see CSRF the actual uploading of firmware. So browse to a website and you get owned. Not just your computer, not just your browser, but your entire network. So a couple of routers that I looked at specifically for this project. The WNR 1000 version 3. It's made by Netgear. And it uses the proprietary Netgear CHK format, which we'll go into a little bit more later for the actual structuring of the firmware image. It uses a MIPS architecture. And as we'll see, it's a little bit more complex. It's a little bit more complex than what you might see. Almost every consumer router out there, at least that I was able to use was based on MIPS. And these use really old versions of Linux, which is great. This one was used in Linux 2.4.20, which I believe came out in November of 2004 or 2002. And that's really old. It uses the common firmware environment bootloader as well as for the read-only squashfs file system version 3.0. The next router that I looked at was the WEGR 2.4 version 9. Pretty much same specs across the board except it's using an older version of squashfs. Next router was the Belkin FD5-7234 with version 1110. It uses the extended firmware header format, which is proprietary to Belkin, I believe. Again, MIPS, same old version of Linux, same bootloader, but this uses the read-only file system. And as well as the trendnet, which is a little bit more complex. It uses the same old version of Linux, same format, TW652BRP version 3.2R. This uses the proprietary Realtek firmware format. Again, MIPS using a newer version of Linux 2.6, but I believe this one came out in 2006. It's still pretty old. For a bootloader, it doesn't use CFE, but instead it uses the DOS U-boot bootloader and it uses a newer version of squashfs. So basically, what's the difference between the two? So this is the generalized technique that I came up with, the five points, profile the image, extract the parts from the image, deploy the payload, repack the image and update the metadata, in that order. It seems fairly intuitive when you break it down like that. But going from zero to the end product, it took a lot of playing around, a lot of trial and error. And this is, by following these steps, you can essentially use the same generalized technique and approach any firmware image that you want. So before we even started, or before I even started working on this project, we needed to basically see, obviously we're going to be reflashing the device, but obviously we're probably going to be reflashing it with something that it's not supposed to be flashed with. So what happens when we break the device, how are we going to recover from it, because you're not going to go out and buy 50 routers at $20 each. So one thing that I found out was that nearly every consumer router that I found, they were not going to be able to recover from it. So that's one thing that I found out. They offer a serial port on the circuit board itself. There are four or six or any number of solder pads on the device. And basically what you have to do is find the terminals, solder the connectors, and you get a root shell, as well as access to the bootloader. And it lets you profile the device, it lets you view the startup sequence and view more information about what hardware is actually running on it and what specific software is running on it. It lets you test new payloads fairly quickly and easily as well as debugging when payloads go wrong or when reflashing the device goes wrong in case it rejects the firmware that you tried to reflash it with or it just doesn't work at all. And again, the bootloader, by breaking to the bootloader, gives you an easy recovery, a quick testing of new firmware images. And we'll go into how that works very soon. So basically connecting to the console, you're looking for four pins, ground, VCC, which is positive voltage, TX, RX for transmit and receive. And just for example, on the WGR614B9, these six pins at the bottom left constitute the serial port, but we only care about four of them. A closer look, we have VCC, RX, TX, and ground. This can mostly be found usually by trial and error, just by trying every possible configuration of connecting the pins to the solder pads. And then we have the WGR614B9. But if you want to do it intelligently, there's also, you can use a multimeter and first find ground and then find a positive voltage testing for resistance and then basically trying every configuration for RX and TX. So basically this would be the serial pin out for the WGR614B9. We have the four pins and we're going to connect ground to ground, VCC to VCC, but we're going to cross TX and RX because we want the transmitting side to go to the receiving side and the receiving side to go to the transmitting side. So we're going to connect ground to ground to the transmitting side. And basically this very simple circuit of crossing TX and RX is what constitutes a null modem. But we run into a problem. We can't directly connect to the router because computers run at 12 volts and routers run at 3.3 volts. And if you connect it directly, it's going to fry the router and that's not very constructive. So what we need to do is introduce a voltage shifter into the circuit to prevent damage and facilitate this communication. So luckily SparkFun has the ability to do that. So we're going to connect ground to ground and we're going to use these little kits you can buy for $7. They're really fun solder projects. Put them together. You plug in a serial cable on one side and you have your four terminals on the other side. And this is the end result of what it looks like. Really simple. You have some LEDs that show when communication is going. And this is what it looks like actually soldered to the board. You don't really want to solder directly to it because these are very small and fragile solder pads. Usually you want to ‑‑ one thing that people do is they actually use the microphone jack or headphone jack and then you can have one of those on either side and just plug it in. And you only have to solder it once. But as you see, we have ground and BCC on either side connected to each other and RS and TX are crisscrossing. So again, receiving goes to the transmitting and transmitting goes to receiving. So by doing this, you can see we put up the router, we connect to the serial console and we have a root shell. Obviously this doesn't help us for the end product, but it lets us mess around with the router so we don't have to worry about what's on the file system, see what's running in the kernel. It basically lets us do some debugging with real feedback in real time. So this is once the router has booted up. And the next one is actually breaking to the boot loader. As you see, we broke to CFE prompt just by holding down control C at the initial boot up sequence. And if you run the TFTPD command in CFE, it will actually start listening on a TFTP server. And you can send that to the router. It sends firmware images over Ethernet to it. It will right then and there do some integrity checks, tell you if the checksums are wrong and tell you what it's supposed to be. And then if everything works out, it will reflash the device, write it to memory and then try to boot into it. And then you have real time feedback to see if your firmware works or not and what to do to fix it in case it doesn't. So now we have ways to recover. We have a way to debug. How are we going to do the first step, profiling the actual firmware image itself? So this question that we have is basically what exactly makes up this giant blob of binary? We download something from Netgear and it's just a .bin file, it's a .CHK file. And you have no idea what it is. Is there a boot loader in there? Is it a kernel, a file system? These concepts that we know run on this device but we don't know exactly where it is located. And early attempts to find these items were very difficult. So we had to do a lot of research and things that were crude and limited in helpfulness. Basically you run strings on it, run hex dump, run file on it, but nothing really gives us any tangible feedback. One thing that we can notice immediately is that there is this, there's a string that looks something like a serial number or a model number and it says Netgear at the end. But again, that's just something interesting. It doesn't actually give us any tangible feedback on where to go from there. So if we ran a file at, there was a file at the end of the file and we ran a file command at offset zero and that didn't help us. What happens if you run the file command at every possible offset? Basically, will we be able to find a file system? Will we be able to find a kernel? And no, we can't because it's a giant mess. There's tons of false positives. And if you actually filter all the false positives, you still don't have any data that actually helps you. But luckily, doing some research online, there's this great tool called Binwalk. I believe the FRAC, F-R-A-K talk the other day actually integrated with Binwalk as well. Basically, this tool identifies headers, files, and code inside just generally files, but specifically suited towards firmware images. It uses a mix of libmagic and custom signature database in order to detect these headers. And it's made by the great guys at dev TTY zero. And the best part is that Binwalk runs in seven seconds. So it's really easy to use. It's really fast. It runs in seven seconds, and my script ran for two hours. And it got amazing results, and it was accurate right off the bat. So we see here we have a TRX from our header. We don't know exactly what that is, but maybe we'll look at it a little bit later. We have this blob of LZMA. We don't know what it is, but we'll look at it later. And we have this file system using the read-only squashFS format. This is something that we can work with, and we'll look at that next. So basically, extracting from the image, how are we going to take these items out of the image? Well, first of all, we're going to look at how we're going to use these items and work with them from this giant blob. We want to, in this specific image, we want to extract the headers, the LZMA blob, and the squashFS file system. Fairly simple. Just use DD. We'll start off at zero because we're fairly certain there's going to be a header. Even if it didn't detect it, it has to be something off at zero. And we'll take the first 86 bytes to include the first header and the TRX header. Simple. Second one, just take the LZMA blob. And you don't have to worry too much about how big it is because the LZMA blob is going to be the first header. The LZMA will actually just disregard any garbage at the end of the file. And we take out this blob, we decompress it and run strings on it, and lo and behold, here is our Linux kernel. Maybe we can work with this a little bit later. And extracting the squashFS file system. Again, just find the offset and extract it. And now the next step is going to be unpacking the file system because that would be the easiest to work with. And if you need to find a way to unpack squashFS, basically, we use the unsquashFS utility. And firmware market has a great collection of, I believe, almost every unsquashFS utility that's available publicly on the internet. Ones that are both open source, also proprietary patches that vendors add to squashFS for their own firmware images. But the only problem is that none of them worked. So what are we going to do? The great thing about these routers is that I believe back in 2009 there was a big issue with the fact that all these routers were running Linux, they were running BusyVox, they were running squashFS, they were running Linux, they were running Linux, they were running squashFS, all open source GPL software, but they're not releasing source code for them. So in 2009, everybody basically was forced to release their source code. So we can go online to NetEar site, download the source code for this router, and look for maybe this unsquashFS utility is in there, but it's not. And we see there's no unsquashFS.c in this directory, but we know it's supposed to be there because it's in the make file. But they removed it. So there's a couple different options that we could basically take at this point. We can try to reverse engineer the actual proprietary patches that NetEar added to this specific squashFS archive. Or maybe we can keep looking online for something that doesn't have. But again, that didn't work. And I usually like to not put forth effort if it's not necessary. It's part of the whole lazy hacker thing. But so why don't we just ask NetEar for the utility. Maybe they'll come through. So we send off a little ticket, basically say, hi, I believe that this utility is supposed to be in here. It's not in the source code. May I have it, please? And the response is, I'm sorry that we cannot modify the source code of this router because it's not an open source. And first of all, that makes no sense just English-wise. And second of all, the source code is available. That's the reason I'm sending the ticket in the first place. So I send a reply. Thank you. I believe the this is GPL. However, please release the source code. And he replies, he sends me a link on the NetEar site. And possibly, oh, maybe this is our answer. Maybe there's some different source code that I didn't see on the site. And he sends me a link to the former download page. All right. So I'm like two weeks into this already. And I'm getting kind of frustrated. But I'm still being polite. So I ask, can we escalate this ticket to NetEar? And he replies, I don't think he wants to do technical support, like to second level technical support, somebody who isn't just reading off the script and possibly get some actual answers. So he escalates the ticket. Two weeks later I get a reply. Here is a download link to the file you requested. And it worked. So if there's any lesson to be taken away from this, I would be very happy to take a look. from this. It never hurts to ask and you don't know what will happen. All right, great. Next step, deploying the payload. We have this unpacked file system. How can we deploy a payload into this thing and then put it back together and then get code execution on the device? So just looking at the environment, we have a minimalistic Linux system. We have two vectors we can do this through. User land which is dirtier, quicker, more portable. You can run a single binary across every device because it's the same architecture. It's all Linux. Or you can do kernel land which is stealthier but you have more development considerations and it's less portable. You have to tailor it to each specific device. So just looking at user land, it's very simple. Just do a quick backdoor code and see. Drop it on the file system. Again, you have the same one binary which is executable across nearly every device. You have the file, but you have a problem. The file is visible. The process is visible. The file is visible. The process is visible. The process is visible. The process is visible. The process is visible. The process is visible. But honestly, who cares? No one is going to see the file system. No one is going to see the process list unless you solder into the pads which at that point is probably sitting in an FBI office in some forensic person's desk. But one problem which might come up is that there's a small subset of routers where you can actually view the list of currently active connections. I didn't come across that very often, but I know that my own home router does that. So it's something that we should consider. So how can we combat this? Well, at that point, we're going to have to go to kernel land, but I'll talk about that next. So very simply, compile, cross-compile your C to MIPS, drop it on the file system, and basically find some binary that's always going to run on boot, which is the HTTP server, replace it with a shell script that runs our bind shell in the background, and then dispatch it off to the real HTTP server. And as you see, pack it together, boot up the server, and you can start the device. And we netcat to the port, and we have remote root shell. So our next vector could be infecting via kernel land. We have three possible methods through this, infection through a Linux kernel module, infection through def Kmem, we're basically editing kernel memory on the fly, or we can do static kernel patching. The problem is that a bug in the code is not just going to kill our payload as Usuland would, but it's actually going to take down the router and take down the entire network. So if we do do any kernel and modifications, we're going to have to have as little code as possible, as much code as possible in use land if possible. And another issue is it has to be compiled against the specific kernel tree if you're doing a Linux kernel module. And even though a lot of routers use the same version of Linux, it's not very universal because we're going to have to download the source code for each router and compile it against that tree. And if you've worked with any GPL source code archives from like any routers, you'll find that they don't actually compile on the first try. They don't compile on the second try or the third try. So it's a real pain in the butt. But again, we have this benefit that all the files, processes and connections are hidden. So let's see, we'll take a look at Linux kernel modules. We won't look at KMM or set of kernel patching. That could be future work. But even, it's not in time. So let's take a look at Linux kernel modules. We won't look at KMM or set of kernel patching. That could be future work. But even, it's not entirely necessary. It's just more work than you actually need to do. The great thing about using old versions of Linux is that basic rootkit techniques from old frac articles from 2000, 2001, 1999 are still relevant. As well as all the rootkit code that has been updated in years such as a door. So just a quick look at LKMs. You need an in and exit function that runs on install and uninstall. And if we want to hide processes, we simply hook the redirectory function that's associated with the slash proc directory. Every process running on the system is represented by a directory in slash proc with a PID as the name. If you want to hide files and directories, we simply hook the redirectory function associated with the folder that it's in. If you want to hide connections, we simply hook the output functions associated with proc net TCP and UDP. So a quick structure of how LKMs would look on Linux 2.4 is simple. You have an init module, a clean up module function. We put our hooking code in the module and put our unhooking code in the clean up module. And it's pretty much the same concept but it's a little different on 2.6. Except the only difference is that you can really just define arbitrary names for your in and exit functions. So a quick look how would we hide processes and the same idea of files on Linux 2.4 and 2.6. Again, it's simple. You simply open a file pointer to the file pointer and you do the slash proc directly if you were looking to hide processes. You do some magic to find the redirectory pointer within the file pointer structure. And basically it's just a game of swapping out file pointers. You take the redirectory pointer that's there and simply set it to pointer to your new function, which in this case is the end product redirectory function. And it takes a callback, a pointer to a callback function called fill directory which we're going to have to replace. Fill directory is run on every iteration, every item in the directory that is being called on. So all we do is inside this fill directory function is simply have a conditional, is this the file, is this the process ID that we're looking to hide? If so, return zero. If not, run the original one. Very simple. Looking at hiding connections, hiding connections in 2.4 is actually a big pain in the butt. Not that you don't know how to do it, but it's just a lot of parsing. A lot of dirty C code that you have to write. Looking at a door in G, this is how it's done. It couldn't off it on slide, but basically the same concepts apply. Basically run the initial, run the original function that returns the information associated with active connections, listening ports on the router. And simply parse out the information that you have. And that's it. So we get the original output of TCP, simply iterate through and remove any entries that we don't want and then display it to the user. And then Linux 2.6 is a little easier, but again it follows the same method. Open a file pointer to the TCP, replace the file pointer to the function that is used whenever you call TCP or read from it and simply run the original TCP for sequence show function. And then parse through the output and remove anything that you don't need or you don't want to show. And every network utility on Linux basically is just parsing output from ProcNet TCP, ProcNet UDP. Net stat is literally just a wrapper around this file, this virtual file and just prints it out in pretty formats. Bringing to the next step, repacking the image. Okay, so we have a router image. We were able to extract everything that we wanted, unpack the file system, deploy our payload. How are we going to put it all back together? It's fairly simple. Just rebuild the file system in the opposite way that you unpacked it. Append the extracted and generated parts back together again. Pad any sections to define links if necessary. If you look at hex dumps, you'll see that even though there is a file system at offset 1,000 and ends at offset 2,000, sometimes they'll just put 10 kilobytes of nullbytes just to reach some padding. We won't worry about metadata yet. We'll take care of that next. Build the file system again. Just with the appropriate utility inversion. You unpack it with squashfs 2.1. Repack it with squashfs 2.1. Little . Make sure everything matches up. We can use binwalk to verify that we put it back together the way that we took it apart. Padding the image is simple. Just DD from dev zero. Add it to the end until you get where you want to be. And we're going to leave this thing there. And we're going to go ahead and gave 58 bytes at the beginning as a placeholder for regenerating that unknown header at the beginning of the firmware image that we saw with the binwalk output, there was offset 58, there was a TRX header, but the first 58 bytes we weren't able to identify. But we'll take a closer look at that in the next section. Updating the image metadata, basically this specific firmware router, this specific firmware had a netgear CHK header. You can tell by the first four bytes are the magic number, star, pound, dollar sign, carat. And this is ‑‑ we found this by graphing through the source code for the router, not for the specific string, but for the hexadecimal representation of it. And it was in a defined somewhere in some random file. And looking through, we have other things that we found. We have a lot of other data points such as header length and 8 bytes of reserved data, which doesn't really affect anything. We don't care what's in there. And it's kernel checksum, root file system checksum, the kernel length, root file system length, image checksum, header checksum, and then this board ID, which as you can see, next slide, this is that string that we found in our initial profiling of the device. And the HDR0 immediately after it isn't actually part of the board ID, but it's actually the beginning of our TRX header. And the TRX header is used to provide metadata about the Linux kernel that was directly after it. As you see, we have the header length, which is 58 bytes, reserved 8 bytes, which we don't really care about. It has no effect on anything we do. The kernel checksum, which we're going to have to ‑‑ we don't have to worry about because we didn't change the kernel, but if we did change it, we'd have to update this checksum. And apparently in this specific router, they actually don't care about the root file system checksum because the length and the checksum are both zeroed out on the stock firmware image. The kernel length, which we don't have to change, and the image checksum and the header checksum, which we're going to have to recalculate this because we changed the image and we changed the header. And how are we going to generate this? Luckily that we have the source code, we have this beautiful utility called packet. You literally give it all the inputs that you need and it creates the header. And then you can actually create the header for you and automatically prepends it to the firmware image and bam, this is our final product. We're going to reflash the device with this and we're going to get our show. So this is where my code comes in. I developed over the past few months a framework called the router post exploitation framework. Basically it extracts and exploits a process of back to router firmware images. I believe the website is up. It's in a Redmine repository. It's a great tool. So if you want to grab it, do it quick before somebody pulls out the Redmine zero data and takes it down. And basically the way that it works is you provide input from our image, you provide the output from our image to the file name that you want output to and the name of the payload and it does everything magically. You don't have to worry about extracting, putting it back together. And basically this is going to allow us to basically create new firmware images for devices and we don't have to, again, worry about the internals but just say which payload do we want. Do you want a bind shell, do you want a network sniffer, do you want a botnet and it will create this. You ask for input depending on which payload you decide and it pops out a nice firmware image, reflash the device and we have our shell. So I'm going to do some demos here. All right. Let me just swap this out. All right. So just a little bit about this. This is Arpeth. This is the list of the things that you can do with it. Basically a couple of flags that just generate more information. And if you want to, you can leave the temporary files in slash temp so that you can instrument on the files if you want to do anything else with them in their extracted form. And we'll take a look at what modules we have so far. There we go. These are all the former images I've been looking at so far. I'm going to go ahead and show you a little bit more of this. I'm going to show you the software. We have Belkin, D-link, and there's four stages at which the module can be at. Verified, which means it works, you finished the module for that specific router or for that specific firmware image, tried it on hardware and it works. It's verified. Unverified, which means you wrote the code, you're fairly certain it's going to work right off the bat or very little modifications, but it's awaiting testing on a actual hardware and I tried to test it on many devices as I could, but unfortunately Ebay always doesn't have the largest selection. There's roadblock, which basically means there's going to be some work involved. There's something that's stopping the progress moving forward with unpacking and repacking the image. There's going to be some reverse engineering work involved and testing, which means it's currently in development. So let me just... So I'm going to go ahead and show you a little bit more of this. I'm going to show you how it works. Let me just set up a network here and we'll start reflashing some routers. Okay. All right. Again, just emulating some sort of attack on a default router that's out there. You log in with default credentials, admin password. We go to the router update page and this gives us a vector to introduce arbitrary code to execute on the device. So we have... We have our firmers here. We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... We're going to use... WNR 1000 version 3 firmware. And you want to output it to... A firmware image that lets us spawn a bind shell. Now, this is very simple. It checks the checksum against... Of the firmware image that you input against the module checksum and extracts all the items from the firmware image and asks which port you want to listen on. You want to listen on an elite port. And this is our outputted firmware image. Now we're going to reflash the device with this. And it's going to ask us, is the same one that you want? Yes. And this will just take a minute. In the meantime, does anybody have any questions? Sorry? Yes. Yeah, it was a linksys device. This particular linksys device uses a file system called PFS slash 0.9. There is very, very, very little information about this file system or archive format available online. And the only implementations that we have found are very broken. They only provide limited support on unpacking the firmware or the file system. No support for repacking it back together. And the only potentially full implementation I found was on a completely Japanese site. All the documentation was in Japanese. And it was written in a scripting language called Hot Soup Processor, which was just... Don't want to deal with that. Just another few seconds, and it should be ready already. And here's our shell listing on the device. Okay, this is fine and dandy. We have a root shell on this device that we can access any time remotely. But the file system is read-only, and that's the real pain in the butt. This thing has very, very low graphics. limited capacity for installing any new software on it. The only writeable part is in slash temp and we only have a couple of kilobytes to actually install new code on it. So we'll run into a couple of other proof of concepts here. Say instead we didn't want to have a bind shell but instead we wanted to install a network sniffer. And if you want extra output, verbose output, just give the slash V flag. And you can see all the intermediary steps that are going on. We extract the firmware, we unsquash the file system and we insert our payload. Which port do we want to sniff track on? Port 80. Which port do we want to listen on? In order to receive this sniff traffic, port 113 goes through and we'll use the same file name. So we create a filter, add a new file, write an update, upload and it flashes again. 20 seconds. How many of you were planning to stay in here for FX's talk? There's a possibility of clearing the room there's a possibility of switching this over to track one. So first thing Hang tight. We'll let you know what we're going to do. So any other questions in the meantime? The question was did I find any writers that had signed firmware images? Signed firmware images. Personally, I did not. A lot of these personal devices are just using obfuscated proprietary firmware formats. The most are compressed, but, again, you can decompress them or have some patched to open source utility. But no, I actually did not come across any that were signed. But that is one thing that vendors could do in order to prevent this type of attack. Let's see if this works. I may have just bricked a router. Let's try a different one. There we go. There we go. There we go. There we go. There we go. There we go. There we go. While this goes, any other questions? Yes? The question was do old writers use BusyBox? Yeah, as far as I was able to tell, almost every writer just used BusyBox. BusyBox is a single binary that's let you include a whole bunch of common Unix utilities in a single binary. And instead of having a different binary for LS, a different binary for CAT, with all the extra overhead, you just have a single binary and you have a similar binary. So that's what we're trying to do here. So, I think, to the original one. But, yes, everyone that I did encounter did use BusyBox. Yes? . Sorry, say that again? . Sorry, could you come up closer? I can't hear you. . . I don't think I have. . Yes? . Sorry, sorry. The sniffer is running in in user land, it opens the raw socket and all ports and simply prints the output to, pipes the output to another port. Hopefully this writer comes back. There we go. Okay. So, we to the control port. And here we can see the dump of all TCP packets that are going through it. So, Obviously, we don't have ‑‑ I don't have a network connection here or Internet connection so I can't go out and show any going to Facebook or anything. But you can see just accessing the router from the admin panel, you can see all the traffic going through. We can go back and inspect it and find any passwords, say, if we were logging into the panel. Here, authorization basic and base 64 encoded version of what our login is. So my last demo, let me just get the setup here. So this is great. We can get a shell, we can sniff network traffic, but what if we wanted to do something just completely and utterly malicious or if we wanted to install a botnet on our firmware image. So the address of our router or of our IRC server, port of our IRC server channel and prefix of the network. And then we can go and see what the network is doing. Hope this works. Oops. And wait for this thing to finish reflashing. And if all goes in well, all goes well, then we should be seeing a new nick in the channel. Yes. Yeah. I mean, obviously there are vulnerabilities in the rider itself. You can always get access to the admin panel. But the best protection, I guess, is just to set a strong password on the admin panel. Any other questions? Yes. I believe the question was can you upgrade the firmware from a modified firmware? Yes, you could. That's one potential route for future development. Obviously you can make it so you can prevent anything. Any new firmware is being flashed to it. But that might be conspicuous. But yes, at the moment, rewriting the firmware after it's been installed will overwrite the firmware and put a fresh copy on it. Any other questions? Yes. The question was have I tried any other man-in-the-middle attacks such as SSL strip? I have not. But there's definitely a lot of potential. The only issue that might be a limiting factor is compiling all the code and getting it on the router. Because you really only have like 10 kilobytes to work with. Actually, reflashing the router killed my connection. How much space do you have? I don't remember how much you have. But again, it's only a couple kilobytes or like a megabyte or something. There's very little space on these routers. And here is our bot netted router. And we can do all sorts of fun stuff with it. We can send it shell commands. Hopefully. The demo guys are not looking upon us favorably today. But take my word for it, there's a lot of cool stuff you can do with this. There's actually an implemented DDoS command just for fun. But if you check this out online, there is on the site, you can download this and test it out on your own router. This is the first time it actually hasn't worked. So I believe I've run out of time. But quickly, some things I'd like to give. The people at midnightcode.org, they did a lot of work with Belkin reverse engineering and profiling. I'd like to thank Dan Rosenberg for kicking my butt in the gear to actually get a talk submitted. And as well as the great people at OpenWR.com. And DGWRT who have helped a lot along the way. So thank you.