1 00:00:00,000 --> 00:00:05,340 My name is Michael Coppola and I will be presenting Owning the Network, Adventures in 2 00:00:05,340 --> 00:00:13,040 Router Rootkits. To start off, just a little bit who I am. I'm a security consultant at a 3 00:00:13,040 --> 00:00:17,820 small consulting firm, Virtual Security Research out of Boston. And just a side note, we 4 00:00:17,820 --> 00:00:22,980 are hiring. I'm an undergraduate at Northeastern University. Just in the past I've done 5 00:00:22,980 --> 00:00:28,800 some stuff, played some competitions and won some of them. And if you want to see more 6 00:00:28,800 --> 00:00:34,300 information about this talk as well as some other work I've done, my site is poppopret.org. 7 00:00:37,260 --> 00:00:44,800 So a little bit, how did I come on this topic? How did this all start? A year ago I was on a 8 00:00:44,800 --> 00:00:49,640 penetration test and I came across a device called a MicroTik router. Basically MicroTik is 9 00:00:49,640 --> 00:00:54,340 a brand of router that's based on a very minimalistic Linux distribution but there's a 10 00:00:54,340 --> 00:00:58,780 lot of stuff going on in the user land. It's specifically designed to be used for 11 00:00:58,800 --> 00:01:02,260 IPv6 support. Basically one thing of interest is that you can install modules on these 12 00:01:02,260 --> 00:01:08,840 routers through the MPK packages. So you can install new features like a SOX proxy, a VPN, 13 00:01:09,040 --> 00:01:13,780 IPv6 support and even do crazy things like virtualization on the router itself. So this got 14 00:01:13,780 --> 00:01:19,800 me thinking, if we can install code on these MicroTik routers, even if they're vendor 15 00:01:19,800 --> 00:01:25,360 provided, what happens if we're able to create our own MPK package and possibly execute our 16 00:01:25,360 --> 00:01:28,780 own code on the device? Can we get a root shell? And this got me thinking about that. So I'm 17 00:01:28,800 --> 00:01:37,600 thinking, unfortunately, there wasn't the work done on MPK packages was mostly done on the 18 00:01:37,600 --> 00:01:41,520 existing work was mostly done on very old versions. I believe it was version 2 of the 19 00:01:41,520 --> 00:01:47,520 MicroTik router. And there's not very many of those around. But version 2 you can basically 20 00:01:47,520 --> 00:01:52,060 blow apart the MPK package, stick your own code in, package it and run Homebrew software on 21 00:01:52,060 --> 00:01:58,720 the device. But newer versions, I believe three or four, version 3 or 4, the MPK format had 22 00:01:58,800 --> 00:02:03,140 an extra layer of encryption. And no one had really figured that out yet. But they got me 23 00:02:03,140 --> 00:02:08,360 thinking, if this idea could be applied to MicroTik routers, why not apply it to all consumer 24 00:02:08,360 --> 00:02:15,180 routers? As many of you have probably seen, this page or something similar to it on your 25 00:02:15,180 --> 00:02:20,900 consumer router, you can download an update for the firmware from Netgear site or the Belkin 26 00:02:20,900 --> 00:02:26,840 site or D-Link site and basically reflash the router through the web interface and you get a 27 00:02:26,840 --> 00:02:28,780 newer version of it. But what happens if you don't have a new version of it? Well, you can 28 00:02:28,800 --> 00:02:34,840 take that version of the software right off the firmware, right off the vendor site, manipulate 29 00:02:34,840 --> 00:02:40,960 it to install our own code and then reflash the device through the web panel. So the big 30 00:02:40,960 --> 00:02:47,980 question brings us to, can a universal process be developed to modify SOHO router firmware 31 00:02:47,980 --> 00:02:52,580 images to deploy malicious code without altering the interface or functionality of the device? 32 00:02:52,960 --> 00:02:58,780 And in hacker circles, we like to call this a rootkit. So the first thing we're going to do is 33 00:02:58,780 --> 00:03:02,300 we're going to build a rootkit. So the intentions of this talk, I'm not going to teach you how to be a 34 00:03:02,300 --> 00:03:07,260 super elite hacker. I'm not a reverse engineer, but I'm going to share my experience pursuing a 35 00:03:07,260 --> 00:03:11,040 topic and the challenge I encountered, the mistakes I made, and hopefully you guys can take 36 00:03:11,040 --> 00:03:16,220 something away from this talk. Go home and do the same stuff that I was able to do. Gain some 37 00:03:16,220 --> 00:03:22,480 better insight into the internals of the routers and release a project that I've been working on 38 00:03:22,480 --> 00:03:28,760 for the past number of months to help facilitate basically the back-dooring of routers. And I'm 39 00:03:28,780 --> 00:03:33,300 going to do some demos, pop some shells and put on some devices. That's why everybody's here. 40 00:03:35,700 --> 00:03:43,460 So some prior work before getting into this. I wanted to see what work had already been done. 41 00:03:44,740 --> 00:03:51,200 Three main areas that I found a lot of help with was the open WRT and DDWRT communities. They've 42 00:03:51,200 --> 00:03:55,820 done a lot of work with custom firmware, homebrew firmware, a lot of reverse engineering and 43 00:03:55,820 --> 00:03:58,760 profiling of the router devices and the firmware. So I'm going to talk a little bit more about 44 00:03:58,780 --> 00:04:04,580 the firmware that runs on them. As well as a project called firmware mod kit. And basically 45 00:04:04,580 --> 00:04:10,520 it's a conglomeration of a lot of tools to help deconstruct and reconstruct firmware images. 46 00:04:10,900 --> 00:04:16,500 And as well as the site dev TTY S0. They've done a lot of firmware modding, reverse 47 00:04:16,500 --> 00:04:24,440 engineering, as well as exploitation of routers and embedded devices in general. So what are the 48 00:04:24,440 --> 00:04:28,740 use cases for something like this? I'm sure as many of you have seen out in the field or 49 00:04:28,780 --> 00:04:33,460 in a pen test, a lot of things have default passwords, admin, admin, admin password or just 50 00:04:33,460 --> 00:04:39,260 no password at all. Especially home routers. You plug them into a network, plug your computers 51 00:04:39,260 --> 00:04:44,260 in and you go. Basically if you have access to the admin panel, what's the worst that you can 52 00:04:44,260 --> 00:04:49,500 do? You can forward some ports if you really wanted to. You can DOS a network. But that 53 00:04:49,500 --> 00:04:56,700 doesn't help somebody who actually wants to further their exploitation of the network. So if 54 00:04:56,700 --> 00:04:58,760 as well as if there's a vulnerability to the network, you can do something like this. You can 55 00:04:58,780 --> 00:05:01,760 have a vulnerability in the router itself that gets you access to it, whether it's at the 56 00:05:01,760 --> 00:05:07,080 command level, like a shell, or just access to the admin panel through remote code execution or 57 00:05:07,080 --> 00:05:13,100 an auth bypass. I believe the two talks after me will actually be doing more of that stuff. As 58 00:05:13,100 --> 00:05:18,380 well as one vector which I didn't look much into but seems very possible is actually CSRFing 59 00:05:18,380 --> 00:05:26,080 the file upload. You can iframe the, put an iframe to a default IP 192.168.1.1 as well as 60 00:05:26,080 --> 00:05:28,760 like a default password, which is probably going to be there. And then you can actually do 61 00:05:28,780 --> 00:05:32,580 something like this. And you can see CSRF the actual uploading of firmware. So browse to a 62 00:05:32,580 --> 00:05:37,380 website and you get owned. Not just your computer, not just your browser, but your entire network. 63 00:05:39,200 --> 00:05:45,100 So a couple of routers that I looked at specifically for this project. The WNR 1000 version 3. 64 00:05:46,300 --> 00:05:52,240 It's made by Netgear. And it uses the proprietary Netgear CHK format, which we'll go into a 65 00:05:52,240 --> 00:05:57,540 little bit more later for the actual structuring of the firmware image. It uses a MIPS 66 00:05:57,540 --> 00:05:58,760 architecture. And as we'll see, it's a little bit more complex. It's a little bit more 67 00:05:58,780 --> 00:06:01,560 complex than what you might see. Almost every consumer router out there, at least that I was 68 00:06:01,560 --> 00:06:08,180 able to use was based on MIPS. And these use really old versions of Linux, which is great. 69 00:06:09,220 --> 00:06:15,380 This one was used in Linux 2.4.20, which I believe came out in November of 2004 or 2002. 70 00:06:15,880 --> 00:06:22,520 And that's really old. It uses the common firmware environment bootloader as well as for the 71 00:06:22,520 --> 00:06:28,340 read-only squashfs file system version 3.0. The next router that I looked at was the WEGR 72 00:06:28,780 --> 00:06:33,920 2.4 version 9. Pretty much same specs across the board except it's using an older version of 73 00:06:33,920 --> 00:06:45,420 squashfs. Next router was the Belkin FD5-7234 with version 1110. It uses the extended firmware 74 00:06:45,420 --> 00:06:51,280 header format, which is proprietary to Belkin, I believe. Again, MIPS, same old version of 75 00:06:51,280 --> 00:06:58,120 Linux, same bootloader, but this uses the read-only file system. And as well as the 76 00:06:58,120 --> 00:06:58,760 trendnet, which is a little bit more complex. It uses the same old version of Linux, same 77 00:06:58,760 --> 00:07:09,780 format, TW652BRP version 3.2R. This uses the proprietary Realtek firmware format. Again, MIPS 78 00:07:09,780 --> 00:07:15,900 using a newer version of Linux 2.6, but I believe this one came out in 2006. It's still pretty 79 00:07:15,900 --> 00:07:23,500 old. For a bootloader, it doesn't use CFE, but instead it uses the DOS U-boot bootloader and 80 00:07:23,500 --> 00:07:28,740 it uses a newer version of squashfs. So basically, what's the difference between the two? 81 00:07:28,760 --> 00:07:34,040 So this is the generalized technique that I came up with, the five points, profile the image, 82 00:07:34,260 --> 00:07:38,300 extract the parts from the image, deploy the payload, repack the image and update the 83 00:07:38,300 --> 00:07:43,860 metadata, in that order. It seems fairly intuitive when you break it down like that. But 84 00:07:43,860 --> 00:07:49,920 going from zero to the end product, it took a lot of playing around, a lot of trial and error. 85 00:07:50,480 --> 00:07:57,020 And this is, by following these steps, you can essentially use the same generalized technique 86 00:07:57,020 --> 00:07:58,740 and approach any firmware image that you want. 87 00:08:02,880 --> 00:08:07,920 So before we even started, or before I even started working on this project, we needed to 88 00:08:09,000 --> 00:08:14,360 basically see, obviously we're going to be reflashing the device, but obviously we're probably 89 00:08:14,360 --> 00:08:17,860 going to be reflashing it with something that it's not supposed to be flashed with. So what 90 00:08:17,860 --> 00:08:21,580 happens when we break the device, how are we going to recover from it, because you're not going 91 00:08:21,580 --> 00:08:27,200 to go out and buy 50 routers at $20 each. So one thing that I found out was that nearly every 92 00:08:27,200 --> 00:08:28,740 consumer router that I found, they were not going to be able to recover from it. So that's 93 00:08:28,760 --> 00:08:33,720 one thing that I found out. They offer a serial port on the circuit board itself. There are 94 00:08:33,720 --> 00:08:41,420 four or six or any number of solder pads on the device. And basically what you have to do is 95 00:08:41,420 --> 00:08:46,880 find the terminals, solder the connectors, and you get a root shell, as well as access to the 96 00:08:46,880 --> 00:08:53,940 bootloader. And it lets you profile the device, it lets you view the startup sequence and view 97 00:08:53,940 --> 00:08:58,740 more information about what hardware is actually running on it and what specific software is 98 00:08:58,760 --> 00:09:04,120 running on it. It lets you test new payloads fairly quickly and easily as well as debugging 99 00:09:04,120 --> 00:09:09,740 when payloads go wrong or when reflashing the device goes wrong in case it rejects the 100 00:09:09,740 --> 00:09:15,060 firmware that you tried to reflash it with or it just doesn't work at all. And again, the 101 00:09:15,060 --> 00:09:20,500 bootloader, by breaking to the bootloader, gives you an easy recovery, a quick testing of new 102 00:09:20,500 --> 00:09:26,820 firmware images. And we'll go into how that works very soon. So basically connecting to the 103 00:09:26,820 --> 00:09:32,220 console, you're looking for four pins, ground, VCC, which is positive voltage, TX, RX for 104 00:09:32,220 --> 00:09:41,400 transmit and receive. And just for example, on the WGR614B9, these six pins at the bottom left 105 00:09:41,400 --> 00:09:46,920 constitute the serial port, but we only care about four of them. A closer look, we have VCC, 106 00:09:47,080 --> 00:09:53,220 RX, TX, and ground. This can mostly be found usually by trial and error, just by trying every 107 00:09:53,220 --> 00:09:56,800 possible configuration of connecting the pins to the solder pads. And then we have the 108 00:09:56,820 --> 00:10:00,360 WGR614B9. But if you want to do it intelligently, there's also, you can use a multimeter and 109 00:10:00,360 --> 00:10:05,140 first find ground and then find a positive voltage testing for resistance and then basically 110 00:10:05,140 --> 00:10:12,220 trying every configuration for RX and TX. So basically this would be the serial pin out for 111 00:10:14,320 --> 00:10:19,440 the WGR614B9. We have the four pins and we're going to connect ground to ground, VCC to VCC, 112 00:10:19,620 --> 00:10:24,280 but we're going to cross TX and RX because we want the transmitting side to go to the receiving 113 00:10:24,280 --> 00:10:26,800 side and the receiving side to go to the transmitting side. So we're going to connect ground 114 00:10:26,820 --> 00:10:32,700 to ground to the transmitting side. And basically this very simple circuit of crossing TX and 115 00:10:32,700 --> 00:10:39,720 RX is what constitutes a null modem. But we run into a problem. We can't directly connect to the 116 00:10:39,720 --> 00:10:44,760 router because computers run at 12 volts and routers run at 3.3 volts. And if you connect it 117 00:10:44,760 --> 00:10:49,640 directly, it's going to fry the router and that's not very constructive. So what we need to do is 118 00:10:49,640 --> 00:10:53,380 introduce a voltage shifter into the circuit to prevent damage and facilitate this communication. 119 00:10:54,540 --> 00:10:56,800 So luckily SparkFun has the ability to do that. So we're going to connect ground to ground and 120 00:10:56,820 --> 00:11:00,080 we're going to use these little kits you can buy for $7. They're really fun solder projects. 121 00:11:00,940 --> 00:11:06,740 Put them together. You plug in a serial cable on one side and you have your four terminals on the 122 00:11:06,740 --> 00:11:11,500 other side. And this is the end result of what it looks like. Really simple. You have some LEDs 123 00:11:11,500 --> 00:11:16,660 that show when communication is going. And this is what it looks like actually soldered to the 124 00:11:16,660 --> 00:11:20,660 board. You don't really want to solder directly to it because these are very small and fragile 125 00:11:20,660 --> 00:11:26,800 solder pads. Usually you want to ‑‑ one thing that people do is they actually use the 126 00:11:27,640 --> 00:11:32,760 microphone jack or headphone jack and then you can have one of those on either side and just plug it 127 00:11:32,760 --> 00:11:38,520 in. And you only have to solder it once. But as you see, we have ground and BCC on either side 128 00:11:38,520 --> 00:11:43,560 connected to each other and RS and TX are crisscrossing. So again, receiving goes to the 129 00:11:43,560 --> 00:11:49,340 transmitting and transmitting goes to receiving. So by doing this, you can see we put up the 130 00:11:49,340 --> 00:11:54,480 router, we connect to the serial console and we have a root shell. Obviously this doesn't help us 131 00:11:54,480 --> 00:11:56,800 for the end product, but it lets us mess around with the router so we don't have to worry about 132 00:11:56,820 --> 00:12:01,780 what's on the file system, see what's running in the kernel. It basically lets us do some 133 00:12:01,780 --> 00:12:08,400 debugging with real feedback in real time. So this is once the router has booted up. And the 134 00:12:08,400 --> 00:12:14,180 next one is actually breaking to the boot loader. As you see, we broke to CFE prompt just by 135 00:12:14,180 --> 00:12:20,340 holding down control C at the initial boot up sequence. And if you run the TFTPD command in 136 00:12:20,340 --> 00:12:26,800 CFE, it will actually start listening on a TFTP server. And you can send that to the 137 00:12:26,800 --> 00:12:31,780 router. It sends firmware images over Ethernet to it. It will right then and there do some 138 00:12:31,780 --> 00:12:35,620 integrity checks, tell you if the checksums are wrong and tell you what it's supposed to be. And 139 00:12:35,620 --> 00:12:41,460 then if everything works out, it will reflash the device, write it to memory and then try to 140 00:12:41,460 --> 00:12:44,900 boot into it. And then you have real time feedback to see if your firmware works or not and 141 00:12:44,900 --> 00:12:51,440 what to do to fix it in case it doesn't. So now we have ways to recover. We have a way to 142 00:12:51,440 --> 00:12:56,020 debug. How are we going to do the first step, profiling the actual firmware image itself? 143 00:12:59,140 --> 00:13:04,480 So this question that we have is basically what exactly makes up this giant blob of binary? 144 00:13:04,800 --> 00:13:11,780 We download something from Netgear and it's just a .bin file, it's a .CHK file. And you have 145 00:13:11,780 --> 00:13:16,420 no idea what it is. Is there a boot loader in there? Is it a kernel, a file system? These 146 00:13:16,420 --> 00:13:23,360 concepts that we know run on this device but we don't know exactly where it is located. And 147 00:13:23,360 --> 00:13:26,780 early attempts to find these items were very difficult. So we had to do a lot of research and 148 00:13:26,800 --> 00:13:30,460 things that were crude and limited in helpfulness. Basically you run strings on it, run 149 00:13:30,460 --> 00:13:37,320 hex dump, run file on it, but nothing really gives us any tangible feedback. One thing that 150 00:13:37,320 --> 00:13:42,640 we can notice immediately is that there is this, there's a string that looks something like 151 00:13:42,640 --> 00:13:47,940 a serial number or a model number and it says Netgear at the end. But again, that's just 152 00:13:47,940 --> 00:13:51,200 something interesting. It doesn't actually give us any tangible feedback on where to go from 153 00:13:51,200 --> 00:13:56,780 there. So if we ran a file at, there was a file at the end of the file and we ran a file 154 00:13:56,800 --> 00:14:00,760 command at offset zero and that didn't help us. What happens if you run the file command at 155 00:14:00,760 --> 00:14:06,400 every possible offset? Basically, will we be able to find a file system? Will we be able to 156 00:14:06,400 --> 00:14:13,500 find a kernel? And no, we can't because it's a giant mess. There's tons of false positives. 157 00:14:13,920 --> 00:14:19,740 And if you actually filter all the false positives, you still don't have any data that actually 158 00:14:19,740 --> 00:14:24,980 helps you. But luckily, doing some research online, there's this great tool called Binwalk. I 159 00:14:24,980 --> 00:14:32,540 believe the FRAC, F-R-A-K talk the other day actually integrated with Binwalk as well. 160 00:14:34,660 --> 00:14:41,360 Basically, this tool identifies headers, files, and code inside just generally files, but 161 00:14:41,360 --> 00:14:45,680 specifically suited towards firmware images. It uses a mix of libmagic and custom signature 162 00:14:45,680 --> 00:14:50,300 database in order to detect these headers. And it's made by the great guys at dev TTY zero. 163 00:14:50,960 --> 00:14:54,960 And the best part is that Binwalk runs in seven seconds. So it's really easy to use. It's 164 00:14:54,960 --> 00:14:58,980 really fast. It runs in seven seconds, and my script ran for two hours. And it got amazing 165 00:14:58,980 --> 00:15:05,440 results, and it was accurate right off the bat. So we see here we have a TRX from our header. 166 00:15:05,620 --> 00:15:08,840 We don't know exactly what that is, but maybe we'll look at it a little bit later. We have 167 00:15:08,840 --> 00:15:13,380 this blob of LZMA. We don't know what it is, but we'll look at it later. And we have this file 168 00:15:13,380 --> 00:15:18,400 system using the read-only squashFS format. This is something that we can work with, and we'll 169 00:15:18,400 --> 00:15:24,840 look at that next. So basically, extracting from the image, how are we going to take these 170 00:15:24,840 --> 00:15:24,940 items out of the image? Well, first of all, we're going to look at how we're going to use these 171 00:15:24,960 --> 00:15:30,560 items and work with them from this giant blob. We want to, in this specific image, we want to 172 00:15:30,560 --> 00:15:35,700 extract the headers, the LZMA blob, and the squashFS file system. Fairly simple. Just use DD. 173 00:15:36,260 --> 00:15:40,040 We'll start off at zero because we're fairly certain there's going to be a header. Even if it 174 00:15:40,040 --> 00:15:44,880 didn't detect it, it has to be something off at zero. And we'll take the first 86 bytes to 175 00:15:44,880 --> 00:15:52,440 include the first header and the TRX header. Simple. Second one, just take the LZMA blob. And 176 00:15:52,440 --> 00:15:54,940 you don't have to worry too much about how big it is because the LZMA blob is going to be the 177 00:15:54,960 --> 00:15:58,220 first header. The LZMA will actually just disregard any garbage at the end of the file. And 178 00:15:58,220 --> 00:16:02,540 we take out this blob, we decompress it and run strings on it, and lo and behold, here is our 179 00:16:02,540 --> 00:16:07,820 Linux kernel. Maybe we can work with this a little bit later. And extracting the squashFS file 180 00:16:07,820 --> 00:16:12,800 system. Again, just find the offset and extract it. And now the next step is going to be unpacking 181 00:16:12,800 --> 00:16:18,860 the file system because that would be the easiest to work with. And if you need to find a way to 182 00:16:18,860 --> 00:16:24,800 unpack squashFS, basically, we use the unsquashFS utility. And firmware market has a great 183 00:16:25,700 --> 00:16:30,900 collection of, I believe, almost every unsquashFS utility that's available publicly on the 184 00:16:30,900 --> 00:16:35,840 internet. Ones that are both open source, also proprietary patches that vendors add to squashFS 185 00:16:35,840 --> 00:16:41,320 for their own firmware images. But the only problem is that none of them worked. So what are 186 00:16:41,320 --> 00:16:47,480 we going to do? The great thing about these routers is that I believe back in 2009 there was a 187 00:16:47,480 --> 00:16:53,720 big issue with the fact that all these routers were running Linux, they were running BusyVox, 188 00:16:53,860 --> 00:16:54,780 they were running squashFS, they were running Linux, they were running Linux, they were running 189 00:16:54,800 --> 00:17:01,060 squashFS, all open source GPL software, but they're not releasing source code for them. So in 190 00:17:01,060 --> 00:17:07,700 2009, everybody basically was forced to release their source code. So we can go online to NetEar 191 00:17:07,700 --> 00:17:12,280 site, download the source code for this router, and look for maybe this unsquashFS utility is in 192 00:17:12,280 --> 00:17:17,840 there, but it's not. And we see there's no unsquashFS.c in this directory, but we know it's 193 00:17:17,840 --> 00:17:22,580 supposed to be there because it's in the make file. But they removed it. So there's a couple 194 00:17:22,580 --> 00:17:24,780 different options that we could basically take at this point. 195 00:17:24,800 --> 00:17:31,000 We can try to reverse engineer the actual proprietary patches that NetEar added to this 196 00:17:31,000 --> 00:17:36,440 specific squashFS archive. Or maybe we can keep looking online for something that 197 00:17:37,000 --> 00:17:44,580 doesn't have. But again, that didn't work. And I usually like to not put forth effort if it's not 198 00:17:44,580 --> 00:17:52,120 necessary. It's part of the whole lazy hacker thing. But so why don't we just ask NetEar for the 199 00:17:52,120 --> 00:17:53,700 utility. Maybe they'll come through. 200 00:17:54,800 --> 00:18:00,580 So we send off a little ticket, basically say, hi, I believe that this utility is supposed to be in 201 00:18:00,580 --> 00:18:06,480 here. It's not in the source code. May I have it, please? And the response is, I'm sorry that we 202 00:18:06,480 --> 00:18:12,060 cannot modify the source code of this router because it's not an open source. And first of all, 203 00:18:12,100 --> 00:18:17,900 that makes no sense just English-wise. And second of all, the source code is available. That's the 204 00:18:17,900 --> 00:18:24,780 reason I'm sending the ticket in the first place. So I send a reply. Thank you. I believe the 205 00:18:24,780 --> 00:18:32,360 this is GPL. However, please release the source code. And he replies, he sends me a link on the 206 00:18:32,360 --> 00:18:37,800 NetEar site. And possibly, oh, maybe this is our answer. Maybe there's some different source code 207 00:18:37,800 --> 00:18:44,700 that I didn't see on the site. And he sends me a link to the former download page. All right. 208 00:18:44,760 --> 00:18:50,180 So I'm like two weeks into this already. And I'm getting kind of frustrated. But I'm still being 209 00:18:50,180 --> 00:18:54,760 polite. So I ask, can we escalate this ticket to NetEar? 210 00:18:54,760 --> 00:18:56,720 And he replies, I don't think he wants to do technical support, like to second level technical 211 00:18:56,720 --> 00:19:01,500 support, somebody who isn't just reading off the script and possibly get some actual answers. 212 00:19:02,400 --> 00:19:08,660 So he escalates the ticket. Two weeks later I get a reply. Here is a download link to the file 213 00:19:08,660 --> 00:19:11,580 you requested. And it worked. 214 00:19:22,080 --> 00:19:24,740 So if there's any lesson to be taken away from this, I would be very happy to take a look. 215 00:19:24,760 --> 00:19:31,560 from this. It never hurts to ask and you don't know what will happen. All right, great. Next 216 00:19:31,560 --> 00:19:36,320 step, deploying the payload. We have this unpacked file system. How can we deploy a 217 00:19:36,320 --> 00:19:42,640 payload into this thing and then put it back together and then get code execution on the 218 00:19:42,640 --> 00:19:47,080 device? So just looking at the environment, we have a minimalistic Linux system. We have two 219 00:19:47,080 --> 00:19:50,980 vectors we can do this through. User land which is dirtier, quicker, more portable. You can 220 00:19:50,980 --> 00:19:55,740 run a single binary across every device because it's the same architecture. It's all Linux. Or 221 00:19:55,740 --> 00:20:00,220 you can do kernel land which is stealthier but you have more development considerations and 222 00:20:00,220 --> 00:20:05,340 it's less portable. You have to tailor it to each specific device. So just looking at user 223 00:20:05,340 --> 00:20:10,060 land, it's very simple. Just do a quick backdoor code and see. Drop it on the file system. 224 00:20:11,140 --> 00:20:16,000 Again, you have the same one binary which is executable across nearly every device. You 225 00:20:16,000 --> 00:20:20,400 have the file, but you have a problem. The file is visible. The process is visible. The 226 00:20:20,400 --> 00:20:20,960 file is visible. The process is visible. The process is visible. The process is visible. The 227 00:20:20,960 --> 00:20:24,480 process is visible. The process is visible. But honestly, who cares? No one is going to see 228 00:20:24,480 --> 00:20:30,700 the file system. No one is going to see the process list unless you solder into the pads which 229 00:20:30,700 --> 00:20:36,460 at that point is probably sitting in an FBI office in some forensic person's desk. But one 230 00:20:36,460 --> 00:20:39,800 problem which might come up is that there's a small subset of routers where you can actually 231 00:20:39,800 --> 00:20:45,460 view the list of currently active connections. I didn't come across that very often, but I 232 00:20:45,460 --> 00:20:50,600 know that my own home router does that. So it's something that we should consider. So how can we 233 00:20:50,600 --> 00:20:55,640 combat this? Well, at that point, we're going to have to go to kernel land, but I'll talk about 234 00:20:55,640 --> 00:21:04,140 that next. So very simply, compile, cross-compile your C to MIPS, drop it on the file system, and 235 00:21:04,140 --> 00:21:09,220 basically find some binary that's always going to run on boot, which is the HTTP server, 236 00:21:09,840 --> 00:21:15,280 replace it with a shell script that runs our bind shell in the background, and then dispatch it 237 00:21:15,280 --> 00:21:20,580 off to the real HTTP server. And as you see, pack it together, boot up the server, and you can 238 00:21:20,580 --> 00:21:24,620 start the device. And we netcat to the port, and we have remote root shell. 239 00:21:26,480 --> 00:21:31,640 So our next vector could be infecting via kernel land. We have three possible methods through 240 00:21:31,640 --> 00:21:37,440 this, infection through a Linux kernel module, infection through def Kmem, we're basically 241 00:21:37,440 --> 00:21:44,120 editing kernel memory on the fly, or we can do static kernel patching. The problem is that a bug 242 00:21:44,120 --> 00:21:48,800 in the code is not just going to kill our payload as Usuland would, but it's actually going to take 243 00:21:48,800 --> 00:21:53,900 down the router and take down the entire network. So if we do do any kernel and modifications, 244 00:21:54,180 --> 00:21:58,380 we're going to have to have as little code as possible, as much code as possible in use 245 00:21:58,380 --> 00:22:05,100 land if possible. And another issue is it has to be compiled against the specific kernel 246 00:22:05,100 --> 00:22:10,880 tree if you're doing a Linux kernel module. And even though a lot of routers use the same 247 00:22:10,880 --> 00:22:14,400 version of Linux, it's not very universal because we're going to have to download the 248 00:22:14,400 --> 00:22:18,380 source code for each router and compile it against that tree. And if you've worked with 249 00:22:18,380 --> 00:22:27,060 any GPL source code archives from like any routers, you'll find that they don't actually 250 00:22:27,060 --> 00:22:31,220 compile on the first try. They don't compile on the second try or the third try. So it's a 251 00:22:31,220 --> 00:22:36,640 real pain in the butt. But again, we have this benefit that all the files, processes and 252 00:22:36,640 --> 00:22:43,980 connections are hidden. So let's see, we'll take a look at Linux kernel modules. We won't 253 00:22:43,980 --> 00:22:48,280 look at KMM or set of kernel patching. That could be future work. But even, it's not in 254 00:22:48,280 --> 00:22:48,360 time. So let's take a look at Linux kernel modules. We won't look at KMM or set of kernel 255 00:22:48,360 --> 00:22:49,760 patching. That could be future work. But even, it's not entirely necessary. It's just more 256 00:22:49,760 --> 00:22:54,120 work than you actually need to do. The great thing about using old versions of Linux is that 257 00:22:54,120 --> 00:23:01,460 basic rootkit techniques from old frac articles from 2000, 2001, 1999 are still relevant. As 258 00:23:01,460 --> 00:23:06,380 well as all the rootkit code that has been updated in years such as a door. So just a quick 259 00:23:06,380 --> 00:23:13,420 look at LKMs. You need an in and exit function that runs on install and uninstall. And if we 260 00:23:13,420 --> 00:23:18,220 want to hide processes, we simply hook the redirectory function that's associated with the 261 00:23:18,220 --> 00:23:23,860 slash proc directory. Every process running on the system is represented by a directory in 262 00:23:23,860 --> 00:23:29,340 slash proc with a PID as the name. If you want to hide files and directories, we simply hook 263 00:23:29,340 --> 00:23:33,140 the redirectory function associated with the folder that it's in. If you want to hide 264 00:23:33,140 --> 00:23:40,760 connections, we simply hook the output functions associated with proc net TCP and UDP. So a 265 00:23:40,760 --> 00:23:47,460 quick structure of how LKMs would look on Linux 2.4 is simple. You have an init module, 266 00:23:47,460 --> 00:23:54,140 a clean up module function. We put our hooking code in the module and put our unhooking code in 267 00:23:54,140 --> 00:23:58,480 the clean up module. And it's pretty much the same concept but it's a little different on 2.6. 268 00:23:59,280 --> 00:24:03,540 Except the only difference is that you can really just define arbitrary names for your in and 269 00:24:03,540 --> 00:24:13,100 exit functions. So a quick look how would we hide processes and the same idea of files on Linux 270 00:24:13,100 --> 00:24:17,440 2.4 and 2.6. Again, it's simple. You simply open a file pointer to the file pointer and you 271 00:24:17,460 --> 00:24:23,360 do the slash proc directly if you were looking to hide processes. You do some magic to find the 272 00:24:23,360 --> 00:24:31,760 redirectory pointer within the file pointer structure. And basically it's just a game of 273 00:24:31,760 --> 00:24:36,160 swapping out file pointers. You take the redirectory pointer that's there and simply set it 274 00:24:36,160 --> 00:24:40,920 to pointer to your new function, which in this case is the end product redirectory function. 275 00:24:41,380 --> 00:24:46,260 And it takes a callback, a pointer to a callback function called fill directory which we're 276 00:24:46,260 --> 00:24:46,820 going to have to replace. 277 00:24:47,460 --> 00:24:53,160 Fill directory is run on every iteration, every item in the directory that is being called on. 278 00:24:53,400 --> 00:24:59,340 So all we do is inside this fill directory function is simply have a conditional, is this the 279 00:24:59,340 --> 00:25:04,800 file, is this the process ID that we're looking to hide? If so, return zero. If not, run the 280 00:25:04,800 --> 00:25:12,200 original one. Very simple. Looking at hiding connections, hiding connections in 2.4 is 281 00:25:12,200 --> 00:25:17,440 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. 282 00:25:17,440 --> 00:25:24,220 A lot of dirty C code that you have to write. Looking at a door in G, this is how it's done. It 283 00:25:24,220 --> 00:25:35,420 couldn't off it on slide, but basically the same concepts apply. Basically run the initial, run 284 00:25:35,420 --> 00:25:41,120 the original function that returns the information associated with active connections, listening 285 00:25:41,120 --> 00:25:47,420 ports on the router. And simply parse out the information that you have. And that's it. 286 00:25:47,440 --> 00:25:55,720 So we get the original output of TCP, simply iterate through and remove any entries that we don't 287 00:25:55,720 --> 00:26:02,400 want and then display it to the user. And then Linux 2.6 is a little easier, but again it follows 288 00:26:02,400 --> 00:26:08,820 the same method. Open a file pointer to the TCP, replace the file pointer to the function that 289 00:26:08,820 --> 00:26:16,920 is used whenever you call TCP or read from it and simply run the original TCP for sequence show function. 290 00:26:17,440 --> 00:26:22,060 And then parse through the output and remove anything that you don't need or you don't want to show. 291 00:26:22,640 --> 00:26:32,780 And every network utility on Linux basically is just parsing output from ProcNet TCP, ProcNet UDP. 292 00:26:33,180 --> 00:26:39,360 Net stat is literally just a wrapper around this file, this virtual file and just prints it out in 293 00:26:39,360 --> 00:26:47,320 pretty formats. Bringing to the next step, repacking the image. Okay, so we have a router image. We were able to 294 00:26:47,440 --> 00:26:51,300 extract everything that we wanted, unpack the file system, deploy our payload. How are we going to 295 00:26:51,300 --> 00:26:56,780 put it all back together? It's fairly simple. Just rebuild the file system in the opposite way that you 296 00:26:56,780 --> 00:27:01,580 unpacked it. Append the extracted and generated parts back together again. Pad any sections to 297 00:27:01,580 --> 00:27:06,500 define links if necessary. If you look at hex dumps, you'll see that even though there is a file 298 00:27:06,500 --> 00:27:15,820 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. 299 00:27:20,040 --> 00:27:27,260 We won't worry about metadata yet. We'll take care of that next. Build the file system again. Just with the 300 00:27:27,260 --> 00:27:33,720 appropriate utility inversion. You unpack it with squashfs 2.1. Repack it with squashfs 2.1. Little 301 00:27:33,720 --> 00:27:39,520 . Make sure everything matches up. We can use binwalk to verify that we put it back together the way 302 00:27:39,520 --> 00:27:45,420 that we took it apart. Padding the image is simple. Just DD from dev zero. Add it to the end until you get 303 00:27:45,420 --> 00:27:47,420 where you want to be. And we're going to leave this thing there. And we're going to go ahead and 304 00:27:47,440 --> 00:27:52,420 gave 58 bytes at the beginning as a placeholder for regenerating that unknown header at the 305 00:27:52,420 --> 00:28:00,980 beginning of the firmware image that we saw with the binwalk output, there was offset 58, 306 00:28:01,020 --> 00:28:04,840 there was a TRX header, but the first 58 bytes we weren't able to identify. But we'll take a 307 00:28:04,840 --> 00:28:11,200 closer look at that in the next section. Updating the image metadata, basically this 308 00:28:11,200 --> 00:28:18,400 specific firmware router, this specific firmware had a netgear CHK header. You can tell by the 309 00:28:18,400 --> 00:28:28,120 first four bytes are the magic number, star, pound, dollar sign, carat. And this is ‑‑ we 310 00:28:28,120 --> 00:28:33,640 found this by graphing through the source code for the router, not for the specific string, 311 00:28:33,800 --> 00:28:38,360 but for the hexadecimal representation of it. And it was in a defined somewhere in some 312 00:28:38,360 --> 00:28:41,180 random file. And looking through, we have other things that we found. We have a lot of 313 00:28:41,180 --> 00:28:46,240 other data points such as header length and 8 bytes of reserved data, which doesn't really 314 00:28:46,240 --> 00:28:51,420 affect anything. We don't care what's in there. And it's kernel checksum, root file system 315 00:28:51,420 --> 00:28:55,760 checksum, the kernel length, root file system length, image checksum, header checksum, and 316 00:28:55,760 --> 00:29:01,720 then this board ID, which as you can see, next slide, this is that string that we found in our 317 00:29:01,720 --> 00:29:10,100 initial profiling of the device. And the HDR0 immediately after it isn't actually part of the 318 00:29:10,100 --> 00:29:14,780 board ID, but it's actually the beginning of our TRX header. And the TRX header is used to 319 00:29:14,780 --> 00:29:21,760 provide metadata about the Linux kernel that was directly after it. As you see, we have the 320 00:29:21,760 --> 00:29:26,300 header length, which is 58 bytes, reserved 8 bytes, which we don't really care about. It has no 321 00:29:26,300 --> 00:29:31,500 effect on anything we do. The kernel checksum, which we're going to have to ‑‑ we don't 322 00:29:31,500 --> 00:29:35,480 have to worry about because we didn't change the kernel, but if we did change it, we'd have to 323 00:29:35,480 --> 00:29:39,880 update this checksum. And apparently in this specific router, they actually don't care 324 00:29:40,100 --> 00:29:45,920 about the root file system checksum because the length and the checksum are both zeroed out on 325 00:29:45,920 --> 00:29:50,160 the stock firmware image. The kernel length, which we don't have to change, and the image 326 00:29:50,160 --> 00:29:54,740 checksum and the header checksum, which we're going to have to recalculate this because we 327 00:29:54,740 --> 00:30:01,180 changed the image and we changed the header. And how are we going to generate this? Luckily 328 00:30:01,180 --> 00:30:05,700 that we have the source code, we have this beautiful utility called packet. You literally 329 00:30:05,700 --> 00:30:10,080 give it all the inputs that you need and it creates the header. And then you can actually 330 00:30:10,100 --> 00:30:17,080 create the header for you and automatically prepends it to the firmware image and bam, this is 331 00:30:17,080 --> 00:30:22,100 our final product. We're going to reflash the device with this and we're going to get our show. 332 00:30:23,600 --> 00:30:29,460 So this is where my code comes in. I developed over the past few months a framework called the 333 00:30:29,460 --> 00:30:34,640 router post exploitation framework. Basically it extracts and exploits a process of back to 334 00:30:34,640 --> 00:30:40,080 router firmware images. I believe the website is up. It's in a Redmine repository. It's a 335 00:30:40,100 --> 00:30:43,100 great tool. So if you want to grab it, do it quick before somebody pulls out the Redmine zero 336 00:30:43,100 --> 00:30:50,000 data and takes it down. And basically the way that it works is you provide input from our 337 00:30:50,000 --> 00:30:55,020 image, you provide the output from our image to the file name that you want output to and the 338 00:30:55,020 --> 00:30:58,580 name of the payload and it does everything magically. You don't have to worry about 339 00:30:58,580 --> 00:31:05,680 extracting, putting it back together. And basically this is going to allow us to basically 340 00:31:10,100 --> 00:31:16,860 create new firmware images for devices and we don't have to, again, worry about the internals but 341 00:31:16,860 --> 00:31:21,200 just say which payload do we want. Do you want a bind shell, do you want a network sniffer, do you 342 00:31:21,200 --> 00:31:27,580 want a botnet and it will create this. You ask for input depending on which payload you decide 343 00:31:27,580 --> 00:31:34,260 and it pops out a nice firmware image, reflash the device and we have our shell. So I'm going to 344 00:31:34,260 --> 00:31:35,140 do some demos here. 345 00:31:45,960 --> 00:31:48,760 All right. Let me just swap this out. 346 00:32:19,320 --> 00:32:20,840 All right. 347 00:32:52,260 --> 00:33:10,060 So just a little bit about this. This is Arpeth. This is the list of the 348 00:33:10,100 --> 00:33:15,300 things that you can do with it. Basically a couple of flags that just generate more 349 00:33:15,300 --> 00:33:22,060 information. And if you want to, you can leave the temporary files in slash temp so that you can 350 00:33:22,060 --> 00:33:29,900 instrument on the files if you want to do anything else with them in their extracted form. And 351 00:33:30,440 --> 00:33:39,220 we'll take a look at what modules we have so far. There we go. These are all the former images I've 352 00:33:39,220 --> 00:33:40,080 been looking at so far. I'm going to go ahead and show you a little bit more of this. I'm going to 353 00:33:40,100 --> 00:33:45,560 show you the software. We have Belkin, D-link, and there's four stages at which the module can be 354 00:33:45,560 --> 00:33:51,000 at. Verified, which means it works, you finished the module for that specific router or for that 355 00:33:51,000 --> 00:33:55,780 specific firmware image, tried it on hardware and it works. It's verified. Unverified, which 356 00:33:55,780 --> 00:34:01,200 means you wrote the code, you're fairly certain it's going to work right off the bat or very little 357 00:34:01,200 --> 00:34:09,460 modifications, but it's awaiting testing on a actual hardware and I tried to test it on many 358 00:34:09,460 --> 00:34:17,060 devices as I could, but unfortunately Ebay always doesn't have the largest selection. There's 359 00:34:17,060 --> 00:34:22,160 roadblock, which basically means there's going to be some work involved. There's something that's 360 00:34:22,160 --> 00:34:26,140 stopping the progress moving forward with unpacking and repacking the image. There's going to be 361 00:34:26,140 --> 00:34:31,980 some reverse engineering work involved and testing, which means it's currently in development. So 362 00:34:31,980 --> 00:34:39,440 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 363 00:34:39,460 --> 00:34:43,160 how it works. Let me just set up a network here and we'll start reflashing some routers. 364 00:35:03,360 --> 00:35:03,840 Okay. 365 00:35:10,020 --> 00:35:12,100 All right. 366 00:35:44,400 --> 00:35:50,520 Again, just emulating some sort of attack on a default router that's out there. You log in with 367 00:35:51,040 --> 00:35:57,480 default credentials, admin password. We go to the router update page and this gives us a vector 368 00:35:57,480 --> 00:36:08,400 to introduce arbitrary code to execute on the device. So we have... We have our firmers here. 369 00:36:08,460 --> 00:36:09,440 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 370 00:36:09,460 --> 00:36:13,920 going to use... We're going to use... We're going to use... We're going to use... We're going to use... 371 00:36:14,500 --> 00:36:24,340 WNR 1000 version 3 firmware. And you want to output it to... A firmware image that lets us 372 00:36:24,340 --> 00:36:32,160 spawn a bind shell. Now, this is very simple. It checks the checksum against... Of the firmware 373 00:36:32,160 --> 00:36:38,620 image that you input against the module checksum and extracts all the items from the firmware image 374 00:36:38,620 --> 00:36:45,100 and asks which port you want to listen on. You want to listen on an elite port. And this is our 375 00:36:46,040 --> 00:37:00,700 outputted firmware image. Now we're going to reflash the device with this. And it's going to ask 376 00:37:00,700 --> 00:37:07,840 us, is the same one that you want? Yes. And this will just take a minute. In the meantime, does 377 00:37:07,840 --> 00:37:25,580 anybody have any questions? Sorry? Yes. Yeah, it was a linksys device. This particular linksys 378 00:37:25,580 --> 00:37:32,340 device uses a file system called PFS slash 0.9. There is very, very, very little information 379 00:37:32,340 --> 00:37:37,820 about this file system or archive format available online. And the only implementations that we have 380 00:37:37,820 --> 00:37:45,320 found are very broken. They only provide limited support on unpacking the firmware or the file 381 00:37:45,320 --> 00:37:51,100 system. No support for repacking it back together. And the only potentially full implementation I 382 00:37:51,100 --> 00:37:57,840 found was on a completely Japanese site. All the documentation was in Japanese. And it was written 383 00:37:57,840 --> 00:38:03,620 in a scripting language called Hot Soup Processor, which was just... Don't want to deal with that. 384 00:38:19,600 --> 00:38:35,080 Just another few seconds, and it should be ready already. 385 00:38:42,980 --> 00:38:45,480 And here's our shell listing on the device. 386 00:38:54,260 --> 00:38:56,300 Okay, this is fine and dandy. 387 00:38:56,360 --> 00:38:59,640 We have a root shell on this device that we can access any time remotely. 388 00:39:00,040 --> 00:39:03,260 But the file system is read-only, and that's the real pain in the butt. 389 00:39:03,440 --> 00:39:05,060 This thing has very, very low graphics. 390 00:39:05,080 --> 00:39:10,700 limited capacity for installing any new software on it. The only writeable part is in slash 391 00:39:10,700 --> 00:39:16,840 temp and we only have a couple of kilobytes to actually install new code on it. So we'll run 392 00:39:16,840 --> 00:39:26,380 into a couple of other proof of concepts here. Say instead we didn't want to have a bind shell 393 00:39:26,380 --> 00:39:34,060 but instead we wanted to install a network sniffer. And if you want extra output, verbose 394 00:39:34,060 --> 00:39:40,740 output, just give the slash V flag. And you can see all the intermediary steps that are going 395 00:39:40,740 --> 00:39:47,380 on. We extract the firmware, we unsquash the file system and we insert our payload. Which 396 00:39:47,380 --> 00:39:54,220 port do we want to sniff track on? Port 80. Which port do we want to listen on? In order to 397 00:39:54,220 --> 00:40:04,040 receive this sniff traffic, port 113 goes through and we'll use the same file name. So we 398 00:40:06,580 --> 00:40:16,200 create a filter, add a new file, write an update, upload and it flashes again. 20 399 00:40:16,200 --> 00:40:28,080 seconds. How many of you were planning to stay in here for FX's talk? There's a possibility of 400 00:40:28,080 --> 00:40:34,040 clearing the room there's a possibility of switching this over to track one. So first thing 401 00:40:34,060 --> 00:40:36,020 Hang tight. We'll let you know what we're going to do. 402 00:40:41,780 --> 00:40:49,720 So any other questions in the meantime? The question was did I find any writers that 403 00:40:49,720 --> 00:40:56,060 had signed firmware images? Signed firmware images. Personally, I did not. A lot of these 404 00:40:56,060 --> 00:41:02,880 personal devices are just using obfuscated proprietary firmware formats. The most are 405 00:41:02,880 --> 00:41:09,800 compressed, but, again, you can decompress them or have some patched to open source utility. 406 00:41:10,200 --> 00:41:14,460 But no, I actually did not come across any that were signed. But that is one thing that 407 00:41:15,600 --> 00:41:17,800 vendors could do in order to prevent this type of attack. 408 00:41:24,720 --> 00:41:31,580 Let's see if this works. I may have just bricked a router. Let's try a different one. 409 00:41:33,480 --> 00:41:34,880 There we go. 410 00:41:48,200 --> 00:41:49,600 There we go. 411 00:41:49,940 --> 00:41:51,340 There we go. 412 00:41:51,340 --> 00:41:51,860 There we go. 413 00:42:14,700 --> 00:42:15,580 There we go. 414 00:42:17,300 --> 00:42:17,860 There we go. 415 00:42:38,620 --> 00:42:49,720 There we go. 416 00:42:49,720 --> 00:42:51,580 While this goes, any other questions? Yes? 417 00:42:56,140 --> 00:43:03,040 The question was do old writers use BusyBox? Yeah, as far as I was able to tell, almost 418 00:43:03,040 --> 00:43:08,020 every writer just used BusyBox. BusyBox is a single binary that's let you include a whole 419 00:43:08,020 --> 00:43:13,940 bunch of common Unix utilities in a single binary. And instead of having a different 420 00:43:13,940 --> 00:43:18,020 binary for LS, a different binary for CAT, with all the extra overhead, you just have 421 00:43:18,020 --> 00:43:19,700 a single binary and you have a similar binary. So that's what we're trying to do here. So, 422 00:43:19,700 --> 00:43:23,160 I think, to the original one. But, yes, everyone that I did encounter did use BusyBox. 423 00:43:26,540 --> 00:43:26,940 Yes? 424 00:43:30,140 --> 00:43:30,540 . 425 00:43:34,940 --> 00:43:35,820 Sorry, say that again? 426 00:43:36,980 --> 00:43:37,380 . 427 00:43:47,020 --> 00:43:48,940 Sorry, could you come up closer? I can't hear you. 428 00:43:58,580 --> 00:43:59,860 . 429 00:44:03,640 --> 00:44:04,920 . 430 00:44:04,920 --> 00:44:07,020 I don't think I have. 431 00:44:07,660 --> 00:44:08,300 . 432 00:44:13,400 --> 00:44:14,040 Yes? 433 00:44:14,460 --> 00:44:15,360 . 434 00:44:16,220 --> 00:44:17,000 Sorry, sorry. 435 00:44:17,700 --> 00:44:21,060 The sniffer is running in in user land, it opens the raw 436 00:44:21,060 --> 00:44:26,120 socket and all ports and simply prints the output to, pipes the output to another port. 437 00:44:29,120 --> 00:44:39,700 Hopefully this writer comes back. There we go. Okay. So, we to the control 438 00:44:39,700 --> 00:44:45,340 port. And here we can see the dump of all TCP packets that are going through it. So, 439 00:44:48,960 --> 00:44:52,660 Obviously, we don't have ‑‑ I don't have a network connection here or Internet connection 440 00:44:52,660 --> 00:44:58,540 so I can't go out and show any going to Facebook or anything. But you can see just accessing 441 00:44:58,540 --> 00:45:03,700 the router from the admin panel, you can see all the traffic going through. We can go back 442 00:45:03,700 --> 00:45:11,880 and inspect it and find any passwords, say, if we were logging into the panel. Here, authorization 443 00:45:11,880 --> 00:45:21,300 basic and base 64 encoded version of what our login is. So my last demo, let me just get the 444 00:45:21,300 --> 00:45:21,680 setup here. 445 00:45:45,820 --> 00:45:50,980 So this is great. We can get a shell, we can sniff network traffic, but what if we wanted to do 446 00:45:50,980 --> 00:45:56,440 something just completely and utterly malicious or if we wanted to install a botnet on our 447 00:45:56,440 --> 00:46:06,900 firmware image. So the address of our router or of our IRC server, port of our IRC server 448 00:46:07,580 --> 00:46:11,860 channel and prefix of the network. And then we can go and see what the network is doing. 449 00:46:21,300 --> 00:46:23,320 Hope this works. 450 00:46:33,660 --> 00:46:35,060 Oops. 451 00:46:42,140 --> 00:46:45,240 And wait for this thing to finish reflashing. 452 00:46:45,540 --> 00:46:53,140 And if all goes in well, all goes well, then we should be seeing a new nick in the channel. 453 00:46:53,340 --> 00:46:53,460 Yes. 454 00:46:58,900 --> 00:46:59,380 Yeah. 455 00:46:59,740 --> 00:47:02,580 I mean, obviously there are vulnerabilities in the rider itself. 456 00:47:02,860 --> 00:47:05,000 You can always get access to the admin panel. 457 00:47:05,060 --> 00:47:10,500 But the best protection, I guess, is just to set a strong password on the admin panel. 458 00:47:13,600 --> 00:47:14,620 Any other questions? 459 00:47:16,780 --> 00:47:17,080 Yes. 460 00:47:20,340 --> 00:47:25,380 I believe the question was can you upgrade the firmware from a modified firmware? 461 00:47:26,200 --> 00:47:27,160 Yes, you could. 462 00:47:27,340 --> 00:47:31,820 That's one potential route for future development. 463 00:47:32,500 --> 00:47:35,040 Obviously you can make it so you can prevent anything. 464 00:47:35,040 --> 00:47:36,420 Any new firmware is being flashed to it. 465 00:47:36,540 --> 00:47:39,240 But that might be conspicuous. 466 00:47:39,880 --> 00:47:45,960 But yes, at the moment, rewriting the firmware after it's been installed will overwrite the 467 00:47:45,960 --> 00:47:47,980 firmware and put a fresh copy on it. 468 00:47:52,340 --> 00:47:53,380 Any other questions? 469 00:47:55,320 --> 00:47:55,880 Yes. 470 00:48:01,240 --> 00:48:05,340 The question was have I tried any other man-in-the-middle attacks such as SSL strip? 471 00:48:05,840 --> 00:48:06,680 I have not. 472 00:48:06,800 --> 00:48:08,460 But there's definitely a lot of potential. 473 00:48:08,700 --> 00:48:12,640 The only issue that might be a limiting factor is compiling all the code and getting it on the router. 474 00:48:12,820 --> 00:48:16,780 Because you really only have like 10 kilobytes to work with. 475 00:48:21,040 --> 00:48:23,920 Actually, reflashing the router killed my connection. 476 00:48:25,880 --> 00:48:27,700 How much space do you have? 477 00:48:31,260 --> 00:48:33,160 I don't remember how much you have. 478 00:48:33,360 --> 00:48:35,960 But again, it's only a couple kilobytes or like a megabyte or something. 479 00:48:36,520 --> 00:48:38,240 There's very little space on these routers. 480 00:48:44,140 --> 00:48:46,620 And here is our bot netted router. 481 00:48:47,040 --> 00:48:49,320 And we can do all sorts of fun stuff with it. 482 00:48:50,420 --> 00:48:53,500 We can send it shell commands. 483 00:48:54,720 --> 00:48:55,120 Hopefully. 484 00:49:03,720 --> 00:49:07,320 The demo guys are not looking upon us favorably today. 485 00:49:09,140 --> 00:49:11,880 But take my word for it, there's a lot of cool stuff you can do with this. 486 00:49:12,120 --> 00:49:14,840 There's actually an implemented DDoS command just for fun. 487 00:49:17,420 --> 00:49:23,320 But if you check this out online, there is on the site, you can download this and test it out on your own router. 488 00:49:23,900 --> 00:49:26,180 This is the first time it actually hasn't worked. 489 00:49:29,340 --> 00:49:34,880 So I believe I've run out of time. 490 00:49:35,060 --> 00:49:37,800 But quickly, some things I'd like to give. 491 00:49:39,060 --> 00:49:44,860 The people at midnightcode.org, they did a lot of work with Belkin reverse engineering and profiling. 492 00:49:45,200 --> 00:49:49,940 I'd like to thank Dan Rosenberg for kicking my butt in the gear to actually get a talk submitted. 493 00:49:50,740 --> 00:49:53,300 And as well as the great people at OpenWR.com. 494 00:49:53,300 --> 00:49:56,120 And DGWRT who have helped a lot along the way. 495 00:49:56,280 --> 00:49:57,280 So thank you.