1 00:00:00,000 --> 00:00:06,160 All right. Let's have some fun here. So this presentation is the setup for tomorrow. 2 00:00:06,420 --> 00:00:11,520 Tomorrow I will be back here in the hardware hacking village. We will have USB sniffers and 3 00:00:11,520 --> 00:00:15,600 fuzzers and you can come play to your heart's content. So today I'm just going to do a quick 4 00:00:15,600 --> 00:00:21,140 introduction to USB in general, a little bit about the protocol and a little bit about how we go and 5 00:00:21,140 --> 00:00:27,400 attack it. Now what I'm talking about today is not the bad USB type attacks. I'm talking about 6 00:00:27,400 --> 00:00:35,520 attacking an operating system via the USB port. So we're attacking system drivers via the USB port. 7 00:00:35,720 --> 00:00:39,960 It's a great way to get into the thing and I hope you see that today. So introduction to USB 8 00:00:40,520 --> 00:00:45,960 fuzzing. I'm Matt Duarte. You want to hear about stuff? Crypto monkey. Twitter handle is 9 00:00:45,960 --> 00:00:53,100 cryptomonkey. And let's talk about it. So what is USB? Back in the olden days where I'm from, 10 00:00:53,280 --> 00:00:56,900 there used to be different ports for keyboards, things like that. They came up with the universal 11 00:00:56,900 --> 00:00:57,280 serial. 12 00:00:57,400 --> 00:01:02,560 You can put any kind of a device on it. These are the guys who got together, Hewlett Packard, Intel, 13 00:01:02,800 --> 00:01:07,220 all that. They came up with a standard for it and they've revised it several times. Most of the 14 00:01:07,220 --> 00:01:12,480 revisions deal with two things. The speed at which it can transfer data and the amount of power 15 00:01:12,480 --> 00:01:17,580 that it consumes. So everything I talk about when I talk about the spec is out of this. If you get 16 00:01:17,580 --> 00:01:22,860 the presentation, there's a link here, www.usb.org. Home, it will have all the specs for you. 17 00:01:22,900 --> 00:01:27,220 They're free to download. So quick agenda, what we're going to do, look at the USB, 18 00:01:27,400 --> 00:01:31,280 hardware, software, talk a little bit about the protocols and then look at how we're going to get 19 00:01:31,280 --> 00:01:38,000 in. The tool tools I use are the Face Dancer 21 and UMAP Pi. I like this setup because you don't 20 00:01:38,000 --> 00:01:43,220 have to be like Uber Elite to do this. With the Face Dancer 21, it's a dongle made by Travis 21 00:01:43,220 --> 00:01:47,660 Goodspeed. It will take care of creating packets for you. You can do the fuzzing, all sorts of 22 00:01:47,660 --> 00:01:52,440 tricks there. UMAP is a very nice Python fuzzing thing that you can get right off GitHub and try 23 00:01:52,440 --> 00:01:57,380 out. I'll demo it all tomorrow. So first of all, the hardware. What is the hardware? The hardware is 24 00:01:57,400 --> 00:02:02,420 USB. Some of you may know this already. USB is a four-wire protocol. There's four wires inside 25 00:02:02,420 --> 00:02:08,160 that cord you have. Ground and power, five volts, and there's some amperage differences. The other 26 00:02:08,160 --> 00:02:14,040 two are data wires. There's no signal and transmit, receive like in serial. It's differential data. 27 00:02:14,780 --> 00:02:19,440 So that means there's a positive and negative. You just have to interpret them. Some connectors do 28 00:02:19,440 --> 00:02:25,020 have this fifth pin, the OTG. That's really so you can use your phone as a USB battery, things 29 00:02:27,400 --> 00:02:32,880 like that, when it comes to fuzzing. So everybody's seen the connections. The key thing to remember 30 00:02:32,880 --> 00:02:38,180 is that with the exception of the USB 3 here, everything here is just different form factors of 31 00:02:38,180 --> 00:02:44,780 those same four wires. And why they all differ has to do with what their function is. Specifically, 32 00:02:45,000 --> 00:02:50,580 the flat square type A's that you're used to, they're the only ones allowed to put power into the 33 00:02:50,580 --> 00:02:56,760 wire. All these other connectors should never put power into the wire. That's the key point. USB 3 just 34 00:02:57,400 --> 00:03:01,980 has a few extra pins, but we're going to concentrate on USB 2 today. I think you've seen most of the 35 00:03:01,980 --> 00:03:08,340 connections, right? Everybody knows their connections? Cool. So only type A puts power on the 36 00:03:08,340 --> 00:03:14,740 wire. You got that. The key to a lot of this fuzzing stuff, and this is just my advice from 37 00:03:14,740 --> 00:03:20,560 having done this for a long time, use the shortest USB cables possible. Because we're going to be 38 00:03:20,560 --> 00:03:25,480 putting several devices on a USB bus, and there's only so much power you can get out of the USB bus. 39 00:03:26,020 --> 00:03:27,380 So one of the things I really like about this is, if you're using a USB cable, you're going to have to 40 00:03:27,380 --> 00:03:34,340 really enjoy these really short 6-inch cables you can get off Amazon. Definitely, if you're going to be 41 00:03:34,340 --> 00:03:38,420 doing the fuzzing where you put multiple devices in line, do this. You don't want to lose your power 42 00:03:38,420 --> 00:03:46,060 to the cable when you have to charge up multiple devices. So within the wire, no matter whether 43 00:03:46,060 --> 00:03:50,920 you're using all the way up to USB 3, there's multiple speeds. They can all exist on the same bus. 44 00:03:51,600 --> 00:03:56,400 In fact, they normally do. There's low speed, full speed, and high speed in the USB 2 spec. 45 00:03:57,380 --> 00:04:01,940 If you use a keyboard, no matter what, latest computer, latest keyboards, you're still going to use 46 00:04:01,940 --> 00:04:10,240 this USB low speed, the low, the 1.5 megabits a second. Also known as USB 1.1. Full speed gets you a 47 00:04:10,240 --> 00:04:14,940 little bit more than high speed. Not only do they differ in speed, they also differ in the amount of 48 00:04:14,940 --> 00:04:21,080 data they can transfer at once, and we'll take a look at that in a second. So let me talk a little 49 00:04:21,080 --> 00:04:25,700 bit about the USB networks. You have a laptop, you want to know a little bit about what USB you have, 50 00:04:27,380 --> 00:04:31,580 you want to know how many networks are set up. So there's always one host adapter. That's what 51 00:04:31,580 --> 00:04:36,540 you're going to see in your computer. This is the one USB master. Then below that, there can be a 52 00:04:36,540 --> 00:04:41,920 series of hubs. There's allowed to be up to five hubs between any device and the root hub, which 53 00:04:41,920 --> 00:04:46,080 is the one built into your computer. So you can chain these hubs all you want. Interestingly 54 00:04:46,080 --> 00:04:52,300 enough, there's probably a hub in your computer already, so you lose one off of that list. Also, 55 00:04:52,380 --> 00:04:57,240 you can only have on the entire network 127 devices. It's just the way the addressing works. 56 00:04:58,440 --> 00:05:06,340 So here's an example of my Dell desktop at home. The output of LS USB.T. You can see the tree of 57 00:05:06,340 --> 00:05:12,200 what we have here. The interesting thing is at this top one where you see I have four USB host 58 00:05:12,740 --> 00:05:18,400 masters. Below it, there's another set of USB devices that are the hubs. They're actually built 59 00:05:18,400 --> 00:05:23,640 into the computer. So when you look at the back of a desktop and you see four ports, those aren't 60 00:05:23,640 --> 00:05:27,360 all independent USB. They're actually the first tier of hubs that are built into your computer. 61 00:05:28,180 --> 00:05:32,600 That's why you lose one. Then you can see the device is plugged into it. What I'm going to be 62 00:05:32,600 --> 00:05:38,000 showing you tomorrow in here and a little bit later is the idea of pretending to be a different 63 00:05:38,000 --> 00:05:43,260 device here to attack into the computer. It's actually pretty simple when you get the hang of 64 00:05:43,260 --> 00:05:48,260 it. So different computers have different ways of doing it. When you grab the slides later, 65 00:05:48,480 --> 00:05:52,680 they'll be posted. You'll see I have everything in here, how to do it on Mac, how to do it on 66 00:05:52,680 --> 00:05:56,740 Windows and how to do it on Linux. So you'll see a little bit of redundancy in the slides, but I 67 00:05:56,740 --> 00:05:57,360 wanted to cover everything. I'm going to show you how to do it on Windows and how to do it on Linux. 68 00:05:59,200 --> 00:06:04,020 That's just the Mac version. It's out of the Apple developer hardware tools for Xcode. It's 69 00:06:04,020 --> 00:06:08,700 called IO reg explorer. Gets you the same kind of thing. The tree with all the devices on it. 70 00:06:08,760 --> 00:06:14,540 We'll need this later to do some fuzzing. And funny thing is if you've got an older Mac that 71 00:06:14,540 --> 00:06:20,860 doesn't have USB 3, you may actually see some USB 3 ports on it. That's because they actually are 72 00:06:20,860 --> 00:06:26,400 coming in via the Thunderbolt connection. If you have a Thunderbolt hub that you connect your old 73 00:06:26,400 --> 00:06:32,820 Mac to, it might have USB 3 on it. So you're doing actually USB via Thunderbolt into your 74 00:06:32,820 --> 00:06:37,700 computer. You're getting to see this an awful lot, too. Newer computers, if you have a USB 2 port, 75 00:06:37,860 --> 00:06:43,560 it's probably a step down from USB 3. So again, watch out because there's a lot of different ways 76 00:06:43,560 --> 00:06:49,860 of sneaking USB ports in. Also, they're used internally in the computer. And finally, the 77 00:06:49,860 --> 00:06:55,180 Windows device manager has a little bit of data. I recommend you go look at this tool here called 78 00:06:55,180 --> 00:06:56,380 USB view. It's a little bit more advanced. It's a little bit more advanced. It's a little bit more 79 00:06:56,380 --> 00:06:59,320 advanced. It'll get you to the same thing. So what we're looking at here is just trying to figure 80 00:06:59,320 --> 00:07:05,360 out what devices are on the computer, what ones are built in. The reason I care what's built in is 81 00:07:05,360 --> 00:07:12,380 because those are the ones the drivers will already be loaded. Later on, I'll show you how we're 82 00:07:12,380 --> 00:07:18,260 going to instantiate a driver that hasn't been loaded. So quick and dirty, you guys got the idea 83 00:07:18,260 --> 00:07:23,080 of the whole hierarchy hubs and addresses. You can dig into it. There's all sorts of things about 84 00:07:23,080 --> 00:07:26,360 how that works. But what I want to get on to is the kind of protocol that we're going to get on to. 85 00:07:26,380 --> 00:07:30,840 Before we go there, though, let's look at what happens when you connect a USB device to a 86 00:07:30,840 --> 00:07:38,360 computer. So I'm going to discuss the Linux 3X kernel, not because it's particularly any better or 87 00:07:38,360 --> 00:07:44,820 worse. They all work basically the same way. This is my lovely diagram of how it works. You have 88 00:07:44,820 --> 00:07:50,340 this idea of the USB hardware connects to the computer. It goes into something in the Linux 89 00:07:50,340 --> 00:07:56,000 kernel called USB core. This is the first part of the Linux kernel that's there. It handles all the 90 00:07:56,000 --> 00:07:56,360 generic stuff in the Linux kernel. It goes into something in the Linux kernel called USB core. It 91 00:07:56,380 --> 00:08:01,700 handles all the generic types of USB devices, so no specificity. But it will hand it off onto a 92 00:08:01,700 --> 00:08:08,220 device driver that is specific to whatever you just plugged in, a keyboard, a mouse, a video 93 00:08:08,220 --> 00:08:13,020 camera, whatever. These are the ones that we're going to start attacking more. This one's pretty 94 00:08:13,020 --> 00:08:16,700 robust, and it doesn't do much. It doesn't have a lot of hooks into it. This one's a lot more fun. 95 00:08:17,100 --> 00:08:24,440 It's then exported as a device out to user land, then other programs will attach to it. Yes? Oh. 96 00:08:25,520 --> 00:08:33,380 Sorry about that. As I was saying, USB core is pretty generic. These other drivers are the ones 97 00:08:33,380 --> 00:08:38,040 that we're going to instantiate and play with quite a bit. I'll show you how to do that. Within each of 98 00:08:38,040 --> 00:08:43,060 the drivers, then, there's also this concept of there's a hierarchy of drivers. Besides the USB 99 00:08:43,060 --> 00:08:48,680 core, there might be a USB device driver and then a specific device driver on top of that. Think of 100 00:08:48,680 --> 00:08:54,180 attaching a USB key fob, right, your storage device. Well, it's going to have a very generic USB 101 00:08:54,180 --> 00:08:58,360 core, something that talks USB, and then there will be something that actually talks the file 102 00:08:58,360 --> 00:09:04,480 system itself. Meaning going in through the USB port, you're actually able to attack every one of 103 00:09:04,480 --> 00:09:09,460 these things, depending on what the data you send in is. And we can construct any kind of 104 00:09:09,460 --> 00:09:18,480 arbitrary packet using UMAP and the FaceDancer hardware. So what kinds of things are already 105 00:09:18,480 --> 00:09:23,700 loaded in the kernel? I use the LS mod grep USB that will get you all the USB devices that are in 106 00:09:23,700 --> 00:09:24,160 there. I use the USB core, something that talks USB, and then there will be something that actually 107 00:09:24,180 --> 00:09:28,020 talks USB. And if you want to take a look, you can look in the library's directory. You can see 108 00:09:28,020 --> 00:09:34,160 what also can be loaded. You can also see them as they're added by looking in var log messages or 109 00:09:34,160 --> 00:09:41,040 var log kernel or just tail off var log message or tail off D message and you'll get each of them as 110 00:09:41,040 --> 00:09:47,280 they connect. Again, that's telling us what device or what part of the operating system we're 111 00:09:47,280 --> 00:09:53,220 going to attack each time. And I just did it a different way. I looked at the PCI bus. You can 112 00:09:53,220 --> 00:09:54,160 see the different devices here. You can see the different devices here. You can see the different 113 00:09:54,160 --> 00:10:01,820 devices here. The key thing is when you do an LS PCI, you will see the actual USB bus is device ID1D. 114 00:10:02,100 --> 00:10:06,900 This means I can go into the proc file system and actually pull out all sorts of very interesting 115 00:10:06,900 --> 00:10:16,340 data about it. What the device's firmware was. What drivers, all the kinds of data here. All of 116 00:10:16,340 --> 00:10:20,940 these things give me ideas of what I can attack when I come in and send the different types of 117 00:10:20,940 --> 00:10:24,140 packets. So I'm going to go ahead and show you what I can attack when I come in and send the 118 00:10:24,160 --> 00:10:24,640 different types of packets. So I'll show you right now. On the right hand side, I'm getting a little more 119 00:10:24,640 --> 00:10:31,700 detailed. If I drive into each one, there's another, I can take a look at all the different cues. Also 120 00:10:31,700 --> 00:10:36,480 notice there's a manufacturer. There's a specific device name and then there's a generic device 121 00:10:36,480 --> 00:10:41,460 name. So you have the idea that you could have a HIT device that is a keyboard. And there's a 122 00:10:41,460 --> 00:10:46,940 generic keyboard driver for that. You can also have a Logitech MX, you know, 700. There might be a 123 00:10:46,940 --> 00:10:51,600 specific driver for that. They both are valid when you plug in the keyboard and they both can be used. 124 00:10:54,160 --> 00:10:57,420 idea of OSX, you can use the KX stack command to get the same 125 00:10:57,420 --> 00:11:00,060 thing. All we're doing right now is looking at a computer and 126 00:11:00,060 --> 00:11:05,700 seeing what was connected to it. So now that I have an idea from 127 00:11:05,700 --> 00:11:08,720 the operating system what can be seen, I'm going to take a step 128 00:11:08,720 --> 00:11:11,860 back and go, okay, what other devices got in there and what 129 00:11:11,860 --> 00:11:16,160 addresses do they have? This bus I said can only have 127 things 130 00:11:16,160 --> 00:11:20,240 on it, including hubs. So let's look at how that all sets up. 131 00:11:21,000 --> 00:11:23,980 What I have here is some dumps. If you want to know where the 132 00:11:23,980 --> 00:11:28,100 dumps are from, I'm using a hardware thing called a Beagle 133 00:11:28,100 --> 00:11:31,900 480 sniffer. I will show you also a little bit how to do it 134 00:11:31,900 --> 00:11:36,880 with just straight Linux and USB, the USB mon, kernel driver 135 00:11:36,880 --> 00:11:39,820 and Wireshark, but I use the hardware because I get to see 136 00:11:39,820 --> 00:11:43,000 the electronics. But the idea is there's this thing called a 137 00:11:43,000 --> 00:11:46,540 transaction. This is the first transaction you have and it has 138 00:11:46,540 --> 00:11:49,820 this idea of a setup packet. The interesting thing here is 139 00:11:49,820 --> 00:11:52,680 while these two devices are talking on the network, there is 140 00:11:52,680 --> 00:11:53,860 no concept of an address. 141 00:11:54,860 --> 00:11:57,980 The device is actually just talking to the root hub and just 142 00:11:57,980 --> 00:12:01,260 saying, hey, I want to set up. The root hub will later on give 143 00:12:01,260 --> 00:12:05,080 it its actual address. So it's completely controlled by the 144 00:12:05,660 --> 00:12:09,920 host adapter. Nothing happens, no packets are ever initiated 145 00:12:09,920 --> 00:12:15,180 way down at the devices. The host always asks, hey, who are 146 00:12:15,180 --> 00:12:20,120 you? Tell me. Hey, use this address. Okay, I will use this 147 00:12:20,120 --> 00:12:23,120 address from now on. So the first packet or the first 148 00:12:23,120 --> 00:12:26,020 transaction is set up is made up of three packets, a setup, 149 00:12:26,200 --> 00:12:29,020 some data and an ACK. It's a little different than TCP IP 150 00:12:29,020 --> 00:12:32,620 where those are just flags. They are actually separate packets 151 00:12:32,620 --> 00:12:35,980 that are passed through. And the idea of these transactions can 152 00:12:35,980 --> 00:12:39,700 be one packet long, two, three, four, I haven't seen any fives 153 00:12:39,700 --> 00:12:42,800 yet, but each of them go together. They all get slapped 154 00:12:42,800 --> 00:12:45,280 in and they make a single transaction. This is the initial 155 00:12:45,280 --> 00:12:48,820 setup transaction. And each one also is self-identifying. They 156 00:12:48,820 --> 00:12:52,000 have different purposes. This is a setup. There's ones that do 157 00:12:53,380 --> 00:12:56,060 data. There's ones that say I want to leave the network or I 158 00:12:56,060 --> 00:12:58,960 want more power. All of those things are different transaction 159 00:12:58,960 --> 00:13:02,960 types that you can play with. Each one will begin with a token 160 00:13:02,960 --> 00:13:06,500 of a couple of bytes. We can go through this when you look at 161 00:13:06,500 --> 00:13:09,700 the stuff. This is what you'll need to start taking a look at 162 00:13:09,700 --> 00:13:12,400 it. This is what we're going to need to fuzz also. We need to 163 00:13:12,400 --> 00:13:14,500 understand the structure of a packet before we can start 164 00:13:14,500 --> 00:13:19,780 fuzzing. Skip through those. I just want to put this in. This 165 00:13:19,780 --> 00:13:22,800 is straight out of the manual, but what's important here is the 166 00:13:23,120 --> 00:13:27,340 different types of packets there are. Setups, starter frames, and 167 00:13:27,340 --> 00:13:31,380 then ins and outs. That's really actually a simple protocol. Just 168 00:13:31,380 --> 00:13:34,300 things I need to get my address, tell it I'm coming or going. 169 00:13:34,440 --> 00:13:38,320 Other than that, there's just the host telling you I'm sending 170 00:13:38,320 --> 00:13:41,620 you data or the host saying I want you to send me data. So 171 00:13:41,620 --> 00:13:44,440 again, like I said, that key fob that you put in will never send 172 00:13:44,440 --> 00:13:47,220 data to the host. It will always get asked, please send me the 173 00:13:47,220 --> 00:13:51,880 data and just respond. So the host initiates all the 174 00:13:51,880 --> 00:13:53,100 transactions. So the host initiates all the transactions. 175 00:13:53,620 --> 00:13:56,660 There's only one address in the transaction, and that is what the 176 00:13:56,660 --> 00:14:00,720 device is. So when we initially set up to this and looked at the 177 00:14:00,720 --> 00:14:03,900 packet, you can't see it here, but source and destination were 178 00:14:03,900 --> 00:14:07,020 both zero. It doesn't even have an address yet. The first thing 179 00:14:07,020 --> 00:14:10,300 it has to do is go through and try to get that address so that 180 00:14:10,300 --> 00:14:11,820 you can have the different devices and you don't get 181 00:14:11,820 --> 00:14:16,460 confused here. The idea, there's some data packets, there's a 182 00:14:16,460 --> 00:14:18,800 bunch of checks. There's different kinds of data packets. 183 00:14:18,900 --> 00:14:22,120 They have different sizes if you want to do bulk data transfer 184 00:14:22,120 --> 00:14:23,100 or not. So there's different kinds of data packets. There's a 185 00:14:23,120 --> 00:14:23,340 bunch of options. We don't have a lot of choice there. So 186 00:14:23,340 --> 00:14:25,660 it's not all that important, but you have to remember to fuzz each 187 00:14:25,660 --> 00:14:27,960 one of them individually because they will come up in different 188 00:14:27,960 --> 00:14:33,640 ways. And ACKs, NAKs, STALs and YETs are just different types 189 00:14:33,640 --> 00:14:37,520 of ACKs. There's more, TCP and IP you only have the ACK packet. 190 00:14:37,720 --> 00:14:40,600 This has different ones. They can say things like I was 191 00:14:40,600 --> 00:14:44,000 expecting you to send me data and you didn't. That's a NIEC 192 00:14:44,000 --> 00:14:48,440 packet, which I think is kind of funny. But I want to get on to 193 00:14:48,440 --> 00:14:52,180 the actual fuzzing part. This is all like I said, stuff straight 194 00:14:53,120 --> 00:14:54,320 you can take a look at it. 195 00:14:54,540 --> 00:14:57,380 But what we're trying to do is get an idea of the structure of a packet 196 00:14:57,380 --> 00:14:58,860 so we can begin to address that. 197 00:15:00,520 --> 00:15:01,480 And there we go. 198 00:15:01,640 --> 00:15:05,540 Okay, so now let's take a look at how you do these things. 199 00:15:05,640 --> 00:15:08,460 We've talked about how to look at the stuff on there. 200 00:15:08,720 --> 00:15:11,160 I've breezed through the kind of setup at this point. 201 00:15:11,780 --> 00:15:13,500 But how do we get at the data? 202 00:15:13,840 --> 00:15:15,540 In the case of a hardware sniffer, 203 00:15:15,680 --> 00:15:19,380 what you do is you actually put the hardware sniffer where that X is 204 00:15:19,380 --> 00:15:21,000 right in the middle of the wire. 205 00:15:21,000 --> 00:15:25,520 So this thing has a connection on it, two connections here. 206 00:15:25,740 --> 00:15:28,120 One just goes to the device, the other goes to the computer, 207 00:15:28,180 --> 00:15:29,140 and it sits in line. 208 00:15:29,620 --> 00:15:31,340 There's another connection on the other side 209 00:15:31,340 --> 00:15:33,120 that actually leads to the analysis computer. 210 00:15:34,260 --> 00:15:37,720 But the idea here is I'm actually intercepting the data 211 00:15:37,720 --> 00:15:43,280 as it passes through and able to create basically a wire shard of that data. 212 00:15:43,440 --> 00:15:46,460 I do it outside, so I'm looking at what's actually on the wire. 213 00:15:46,620 --> 00:15:49,580 I'm able to look at how much power it's drawing, all of those things, 214 00:15:49,660 --> 00:15:50,980 by intercepting on the wire. 215 00:15:51,000 --> 00:15:56,180 The nice part is neither one of these devices knows that it's being intercepted. 216 00:15:56,760 --> 00:15:59,860 There's no changes, there's no hop count changes or anything like that. 217 00:15:59,980 --> 00:16:02,520 It just happens, and I get to see what's there. 218 00:16:03,060 --> 00:16:05,920 The problem with these sniffers is I can't insert data. 219 00:16:06,800 --> 00:16:08,800 So I'm going to show you how to do that in a second. 220 00:16:09,920 --> 00:16:10,480 There you go. 221 00:16:10,660 --> 00:16:12,080 Sorry, I did have a picture of it. 222 00:16:12,300 --> 00:16:13,240 You get the idea. 223 00:16:13,600 --> 00:16:15,500 It's about a $1,200 device. 224 00:16:15,900 --> 00:16:19,080 It's useful, but mainly only if you want to look at the power stuff. 225 00:16:20,420 --> 00:16:20,820 So. 226 00:16:21,000 --> 00:16:23,380 Let's go back to that idea of that first handshake. 227 00:16:23,580 --> 00:16:26,980 You saw the setup packet saying, hey, I'm now on your bus. 228 00:16:27,180 --> 00:16:28,640 I would like to do something here. 229 00:16:29,240 --> 00:16:31,500 So first we do the hardware handshaking. 230 00:16:32,020 --> 00:16:34,020 Then we set up the first set of transactions. 231 00:16:34,180 --> 00:16:36,140 We start a frame, a setup, some in-data. 232 00:16:36,380 --> 00:16:40,820 All this goes to device 0 and .0. 233 00:16:40,900 --> 00:16:42,380 That's these two columns up here. 234 00:16:42,760 --> 00:16:45,360 That is the root adapter up at the top. 235 00:16:45,640 --> 00:16:47,500 So he's saying, hey, I'm on here. 236 00:16:47,940 --> 00:16:50,500 There's no source and destination addresses yet. 237 00:16:51,000 --> 00:16:54,400 So, we're going to assign a destination address now from the host adapter. 238 00:16:55,540 --> 00:16:57,340 Let's take a look at the transaction here. 239 00:16:57,480 --> 00:17:00,260 All this is really saying, this is a fancy way of looking at it. 240 00:17:00,400 --> 00:17:05,020 It says address 0, endpoint 0, wants to set the address of hex 16, 241 00:17:05,600 --> 00:17:07,520 which is 22 in decimal to the device. 242 00:17:07,780 --> 00:17:10,700 He's saying, okay, I now see you. 243 00:17:10,800 --> 00:17:14,000 I want you from now on to talk as if you're device 22. 244 00:17:14,400 --> 00:17:16,480 Think of this as the DHCP for the bus. 245 00:17:17,360 --> 00:17:20,700 But it's kind of nice because it means you don't have to ever pre-configure USB. 246 00:17:21,000 --> 00:17:24,860 It just connects, and then the host adapter says, here's your address, here's your address. 247 00:17:25,300 --> 00:17:28,380 It handles it all for you up to the 127 that's allowed. 248 00:17:30,100 --> 00:17:34,980 I put this up also because every one of these fields is now open when we start fuzzing it 249 00:17:34,980 --> 00:17:39,240 for overflows, wrong numbers, what happens if I give it a device ID above. 250 00:17:39,740 --> 00:17:40,940 That can cause crashes. 251 00:17:41,120 --> 00:17:46,220 All these are ways that we can get to the software by screwing with these different types of packets. 252 00:17:47,700 --> 00:17:49,660 And finally here, I like this picture. 253 00:17:49,760 --> 00:17:50,840 So, what you have is... 254 00:17:50,840 --> 00:17:56,520 You have to set up with no addresses, and then you'll notice after I told it to start using 22, 255 00:17:56,840 --> 00:18:00,580 from now on he's saying, I'm device ID 22, root 0. 256 00:18:03,660 --> 00:18:05,160 I don't think you need much more of that. 257 00:18:05,200 --> 00:18:06,340 Everybody kind of get that idea? 258 00:18:07,260 --> 00:18:12,140 Cool. So, there's a whole bunch of new transactions as it's set up, 259 00:18:12,200 --> 00:18:16,280 but mostly what it's doing is just negotiating how large a packet do I accept, 260 00:18:16,560 --> 00:18:19,840 what should the address I should use, all before it goes into these kind 261 00:18:19,840 --> 00:18:21,300 of bulk transfers of data. 262 00:18:21,580 --> 00:18:23,920 Now, there's lots of different modes that you can connect. 263 00:18:24,220 --> 00:18:28,280 Remember I said that the devices you connect never initiate a packet. 264 00:18:28,580 --> 00:18:33,460 So, one of the things you negotiate with the host is, well, do I want you to pull me every second? 265 00:18:33,760 --> 00:18:37,320 Do I do bulk transfers, like I'm a camera or a storage device? 266 00:18:38,080 --> 00:18:42,120 It has actually different modes for things that send just a little bit of data regularly, 267 00:18:42,640 --> 00:18:48,820 like a keyboard, or things that send a lot of data but irregularly, like a flash drive. 268 00:18:49,840 --> 00:18:54,120 So, there's all these different modes, but all of them are negotiated in this initial handshake. 269 00:18:57,220 --> 00:18:58,520 Yeah, I don't care. 270 00:18:59,460 --> 00:19:02,580 The second way of sniffing, so let's change gears here a little bit. 271 00:19:02,660 --> 00:19:07,020 If you don't need to see the electrical part of it, this is one of the ways I like to do it. 272 00:19:07,760 --> 00:19:10,800 There is a module built into most Linuxes. 273 00:19:10,800 --> 00:19:14,960 It's not loaded by default, but you can mod probe it in called mod USB. 274 00:19:15,460 --> 00:19:18,880 When you insert it in here, you mod probe it in, it actually allows you 275 00:19:18,880 --> 00:19:19,760 to intercept the traffic. 276 00:19:19,840 --> 00:19:22,700 Between USB core and the USB driver. 277 00:19:23,700 --> 00:19:26,820 What this means is you're able to do this without any hardware. 278 00:19:26,980 --> 00:19:29,620 If you have a Linux box, you probably already have this software. 279 00:19:30,040 --> 00:19:33,260 So, as long as you don't care about the hardware side of it, power stuff, 280 00:19:33,720 --> 00:19:35,500 you're good to get traffic this way. 281 00:19:35,900 --> 00:19:40,320 Even better, once you do that, it shows up in Wireshark. 282 00:19:41,340 --> 00:19:43,980 Once you mod probe that in, you fire up Wireshark. 283 00:19:44,040 --> 00:19:46,900 It says, oh, hey, do you want to sniff the USB device instead? 284 00:19:47,500 --> 00:19:49,820 And you get all of that nice Wireshark stuff. 285 00:19:49,820 --> 00:19:51,280 It's a Wireshark dissector, but for USB. 286 00:19:52,200 --> 00:19:55,120 So, at this point, what we're doing is we're just looking at a normal connection. 287 00:19:55,340 --> 00:19:57,020 We're figuring out what fields we can attack. 288 00:19:58,020 --> 00:19:59,980 But this is the cheap way to do it. 289 00:20:00,020 --> 00:20:00,700 Much easier. 290 00:20:01,380 --> 00:20:05,980 There are also equivalent drivers in, well, let me finish Linux first. 291 00:20:06,340 --> 00:20:09,220 Pseudo mod probe, USB mod in, and you can do this. 292 00:20:09,400 --> 00:20:12,840 Once you do that, like I said, Wireshark is your friend. 293 00:20:13,160 --> 00:20:15,620 And you don't have to have a special form of Wireshark. 294 00:20:15,820 --> 00:20:16,800 It's just built in. 295 00:20:16,860 --> 00:20:19,240 It just doesn't show up until you mod probe that in. 296 00:20:19,960 --> 00:20:23,020 So, fairly useful little thing that a lot of people don't know. 297 00:20:24,240 --> 00:20:29,120 On Windows, you can use something called USB PCAP to do it. 298 00:20:29,240 --> 00:20:30,640 It does the same thing. 299 00:20:30,720 --> 00:20:33,700 It will bring it in and allow you to capture the traffic that way. 300 00:20:34,200 --> 00:20:36,540 When you grab the slides, there's a link to it here. 301 00:20:37,580 --> 00:20:38,960 So, you can also do this. 302 00:20:39,020 --> 00:20:41,780 I haven't found a good way to do it in OSX, let's put it that way. 303 00:20:42,720 --> 00:20:48,360 Also, another good way if you're a pen tester or you do a lot of your malware work in VMs, 304 00:20:49,060 --> 00:20:49,800 since you know. 305 00:20:49,820 --> 00:20:54,380 When you plug in a USB device to something running VMWare, it pops up and says, do you 306 00:20:54,380 --> 00:20:57,060 want to connect to, in my case, your Mac or the Linux? 307 00:20:57,680 --> 00:20:58,940 And I say, oh, Linux. 308 00:20:59,160 --> 00:21:04,460 Well, once you do that, VMWare is actually passing all those Linux, all those USB transactions 309 00:21:04,460 --> 00:21:05,040 through. 310 00:21:05,260 --> 00:21:10,440 A few modifications in the VMX file, you can have it dump it to a file for you and 311 00:21:10,440 --> 00:21:11,420 then you can analyze it. 312 00:21:11,580 --> 00:21:16,680 So all of these are ways for you to intercept a USB transaction as it goes by and see all 313 00:21:16,680 --> 00:21:18,440 the things that are in a normal setup. 314 00:21:22,160 --> 00:21:25,980 And there is a program that helps you do it, but this is actually just a giant text 315 00:21:25,980 --> 00:21:26,240 file. 316 00:21:26,700 --> 00:21:28,860 I personally like the Wireshark way better. 317 00:21:28,900 --> 00:21:29,860 I like the dissectors. 318 00:21:31,520 --> 00:21:37,300 And you can try to do it with OSX, but they have not updated this package in a really 319 00:21:37,300 --> 00:21:40,900 long time and I'm not sure you want to bring in the kernel extension from another version. 320 00:21:41,500 --> 00:21:42,680 So I don't do that. 321 00:21:46,060 --> 00:21:48,120 Up until now, we've looked at this. 322 00:21:48,120 --> 00:21:53,260 When you connect a USB keyboard to something, you think it's just a keyboard. 323 00:21:53,540 --> 00:21:57,160 But I'm sure you've seen combined keyboards and mouses. 324 00:21:57,820 --> 00:22:02,520 I'm sure you've seen things like a video camera that does both video and has a microphone. 325 00:22:03,140 --> 00:22:09,000 One of the interesting things about USB is within one connection, you can actually put 326 00:22:09,000 --> 00:22:09,880 multiple devices. 327 00:22:10,360 --> 00:22:15,840 In fact, it's the thing that actually makes bad USB work because you can be a bad device 328 00:22:15,840 --> 00:22:18,100 and you can be a device that is perfect. 329 00:22:18,120 --> 00:22:22,780 So you can have a key fob that when you insert it, oh, it looks like I'm a storage device, 330 00:22:23,040 --> 00:22:27,140 shows up as a storage device, the user doesn't know any better, but it can also have other 331 00:22:27,140 --> 00:22:27,500 devices. 332 00:22:27,960 --> 00:22:32,640 What's interesting here is that it's built into the protocol and it doesn't require a 333 00:22:32,640 --> 00:22:33,040 different address. 334 00:22:33,300 --> 00:22:37,400 Within that one address, you can have multiple streams of data acting like they're coming 335 00:22:37,400 --> 00:22:38,340 from different devices. 336 00:22:39,540 --> 00:22:45,060 This is kind of fun because this is how we hide malicious transactions and malicious 337 00:22:45,060 --> 00:22:48,020 attacks within what looks like normal traffic. 338 00:22:48,460 --> 00:22:50,500 Because the user never realizes it. 339 00:22:50,580 --> 00:22:51,480 They put the key fob in. 340 00:22:51,540 --> 00:22:52,540 It works like it's supposed to. 341 00:22:52,600 --> 00:22:58,000 They don't ever think that I put in extra things or extra channels of data and I'm attacking 342 00:22:58,000 --> 00:23:00,040 extra drivers that they never thought of. 343 00:23:00,620 --> 00:23:04,000 This also gives you access to drivers that aren't normally loaded. 344 00:23:04,600 --> 00:23:08,980 So what I'm looking at here in the dump here is just the total number of end points in 345 00:23:08,980 --> 00:23:12,860 the configuration, and we're going to look at that concept next of where we're going 346 00:23:12,860 --> 00:23:13,420 to go with that. 347 00:23:14,180 --> 00:23:18,100 The other thing to take a look at this is you'll notice that there's device clients. 348 00:23:19,460 --> 00:23:21,860 That's what I was talking about, the generic devices. 349 00:23:22,120 --> 00:23:22,840 I'm a keyboard. 350 00:23:23,100 --> 00:23:23,640 I'm a mouse. 351 00:23:24,280 --> 00:23:28,680 And then you get into the specific ones with the manufacturer strings, and there you have 352 00:23:28,680 --> 00:23:31,920 a device vendor ID and a version number within that. 353 00:23:32,200 --> 00:23:36,700 That's your one that I'm a Logitech M7000 keyboard. 354 00:23:37,180 --> 00:23:40,500 They both are valid and they both work in instantiating drivers. 355 00:23:42,120 --> 00:23:45,960 The other thing you can see here is if you look, what I was talking about with multiple 356 00:23:45,960 --> 00:23:46,460 things in here. 357 00:23:46,460 --> 00:23:48,540 These interfaces are the parts. 358 00:23:48,760 --> 00:23:53,460 So it's one device, but it has all these different interfaces in it that it can do. 359 00:23:54,040 --> 00:23:56,620 Hardware input, audio streaming, audio control. 360 00:23:56,900 --> 00:24:01,500 So I can do volume control and I can bring in data, and I'm also a human interface device. 361 00:24:02,140 --> 00:24:04,760 All in one connection that you never saw. 362 00:24:06,300 --> 00:24:11,480 So the easiest way to describe this is to understand that you're probably generally 363 00:24:11,480 --> 00:24:13,740 used to thinking about a device. 364 00:24:14,080 --> 00:24:15,320 I had one cable. 365 00:24:15,440 --> 00:24:16,040 I plugged it in. 366 00:24:16,460 --> 00:24:16,620 It's one thing. 367 00:24:17,260 --> 00:24:22,860 But within the computers, they're thinking of it as this idea of configurations, which 368 00:24:22,860 --> 00:24:28,560 you rarely see more than one of, but then the interface descriptors say, hey, I am a 369 00:24:28,560 --> 00:24:29,660 type of device. 370 00:24:29,740 --> 00:24:30,360 I'm a microphone. 371 00:24:30,500 --> 00:24:31,060 I'm a keyboard. 372 00:24:31,340 --> 00:24:33,600 Then within that, you have endpoint descriptors. 373 00:24:33,760 --> 00:24:35,840 All conversations are one way. 374 00:24:36,400 --> 00:24:40,440 So in other words, if you have something that both reads and writes to a device, you define 375 00:24:40,440 --> 00:24:41,500 two different endpoints. 376 00:24:41,720 --> 00:24:43,300 One reads it. 377 00:24:43,320 --> 00:24:44,340 It sends data out. 378 00:24:44,380 --> 00:24:45,620 The other receives it in. 379 00:24:46,460 --> 00:24:50,480 So it's kind of your equivalent of your transmit and receive in serial, except in this case, 380 00:24:50,540 --> 00:24:51,740 they're both one-way channels. 381 00:24:52,380 --> 00:24:57,300 So even your normal key fob, you're going to have several channels in there, one for 382 00:24:57,300 --> 00:24:59,660 when it gets written to, one for when it gets read from. 383 00:25:00,220 --> 00:25:02,220 They get grouped together in an interface. 384 00:25:02,480 --> 00:25:05,800 I'm a key fob, which will eventually get into a device. 385 00:25:06,080 --> 00:25:09,120 I'm a, you know, whatever brand of key fob you use. 386 00:25:11,380 --> 00:25:15,700 So all of this is fun because this is how I hide different devices in there. 387 00:25:15,700 --> 00:25:21,200 But it also means that you can fuzz multiple parts of the thing at the same time because 388 00:25:21,200 --> 00:25:26,120 it is these interface descriptors that are the ones that are tied to a specific driver 389 00:25:26,120 --> 00:25:27,500 in the operating system. 390 00:25:27,800 --> 00:25:29,040 It's not a device. 391 00:25:29,520 --> 00:25:30,680 It's the interfaces. 392 00:25:30,880 --> 00:25:34,000 That's why you can have a microphone and a video in the same line. 393 00:25:34,220 --> 00:25:41,600 It'll be just one, you know, Logitech camera, but it'll file up two different drivers when 394 00:25:41,600 --> 00:25:42,100 we bring it in. 395 00:25:43,080 --> 00:25:43,640 So. 396 00:25:44,540 --> 00:25:45,120 All right. 397 00:25:45,200 --> 00:25:45,660 All right. 398 00:25:45,660 --> 00:25:48,400 So a single USB device can set up a variety of things. 399 00:25:48,620 --> 00:25:50,980 And just remember that they're always one way. 400 00:25:51,100 --> 00:25:52,820 They're either designated in or out. 401 00:25:53,060 --> 00:25:56,500 Out devices go from the computer to the device you attach. 402 00:25:56,740 --> 00:26:01,880 In devices means that I'm taking, I send a command, say send me data, and the device 403 00:26:01,880 --> 00:26:05,680 sends the data to up to the actual host control. 404 00:26:06,980 --> 00:26:10,880 There's also control signals you can send, like I said, for changing with power. 405 00:26:11,360 --> 00:26:15,580 Again, you always go through this process where I send you data. 406 00:26:15,660 --> 00:26:16,580 And you do whatever I say. 407 00:26:18,740 --> 00:26:22,780 In the different endpoint types, we have this idea of guaranteed delivery for packets. 408 00:26:23,960 --> 00:26:26,920 So a control endpoint is one type. 409 00:26:27,120 --> 00:26:29,780 Remember I said there could be different ones there, ins and outs? 410 00:26:30,440 --> 00:26:32,720 There could also be one called a control endpoint. 411 00:26:33,020 --> 00:26:36,040 A control endpoint is for doing the configuration data. 412 00:26:36,240 --> 00:26:38,280 It is guaranteed to always get there. 413 00:26:38,400 --> 00:26:41,700 So it's your TCP on the UDP bus, for want of a better term. 414 00:26:41,920 --> 00:26:44,460 But it always is sent to endpoint zero. 415 00:26:44,620 --> 00:26:44,980 All right. 416 00:26:46,180 --> 00:26:50,640 Interrupts are ways of setting, you can change the different sizes of them. 417 00:26:50,740 --> 00:26:54,300 You can send small amounts of data, and they're guaranteed delivery. 418 00:26:55,280 --> 00:26:58,320 So small amount of data, you're talking keyboards here. 419 00:26:58,400 --> 00:27:00,300 This is like the low end of the USB. 420 00:27:01,240 --> 00:27:02,760 Those are interrupt driven ones. 421 00:27:03,080 --> 00:27:07,860 And then the big ones that you use for moving lots of data are the bulk and the isochronous. 422 00:27:08,620 --> 00:27:10,200 That would be for your key fobs. 423 00:27:10,380 --> 00:27:13,800 So even we have, I told you, we have these different interface types with the different 424 00:27:13,800 --> 00:27:14,080 speeds. 425 00:27:16,640 --> 00:27:17,640 Let's skip that one for now. 426 00:27:20,100 --> 00:27:24,060 Once you get the different flows in, they'll bundle together into an interface and we'll 427 00:27:24,060 --> 00:27:24,840 come up with stuff. 428 00:27:25,840 --> 00:27:27,480 So let me skip that part. 429 00:27:27,740 --> 00:27:27,920 Okay. 430 00:27:29,680 --> 00:27:31,200 So this is the part I wanted to get to. 431 00:27:32,060 --> 00:27:35,020 When you connect in, you're going to have all of these different things. 432 00:27:35,140 --> 00:27:36,080 So now I've connected it. 433 00:27:36,100 --> 00:27:36,760 I've got my power. 434 00:27:36,880 --> 00:27:37,440 I've got my address. 435 00:27:37,680 --> 00:27:39,740 I've told you here are my endpoints, all that. 436 00:27:40,020 --> 00:27:45,060 Each one of those endpoints is going to identify itself out as to where it comes from with 437 00:27:45,060 --> 00:27:50,020 these things that in the spec are called B class type, B class subtype, B device protocol. 438 00:27:50,620 --> 00:27:51,940 That's your bulk and all that. 439 00:27:52,660 --> 00:27:55,840 Each of those things are the fields that we use to identify ourselves. 440 00:27:56,100 --> 00:27:59,740 So when we go on and use the face dancer, those are the things we're going to fake 441 00:27:59,740 --> 00:28:01,320 to be a different fake device. 442 00:28:01,960 --> 00:28:06,720 So I can cause it to instantiate anything I want as long as I can fake those things. 443 00:28:07,180 --> 00:28:09,620 They also, they'll tell you what type of device it is. 444 00:28:09,680 --> 00:28:11,620 Again, HIDs are things like keyboards and mouses. 445 00:28:12,320 --> 00:28:14,160 Then you can go into specific models. 446 00:28:14,160 --> 00:28:15,680 You can go into different models to load a driver. 447 00:28:15,820 --> 00:28:17,340 Otherwise, they'll just use the generic one. 448 00:28:18,480 --> 00:28:21,300 So how do you go about getting on this and attacking? 449 00:28:21,500 --> 00:28:25,760 All I've talked about so far is this idea of how the normal transactions are set up 450 00:28:25,760 --> 00:28:26,940 and how we see the data. 451 00:28:27,420 --> 00:28:30,720 The idea now is we're going to pretend to be another device. 452 00:28:31,080 --> 00:28:35,540 And last year, we saw Carson Knowles' presentation on bad USB. 453 00:28:36,120 --> 00:28:41,140 What he showed in that presentation was I'm going to take a USB key fob and I'm going 454 00:28:41,140 --> 00:28:44,140 to change the software in it so that it works. 455 00:28:44,160 --> 00:28:46,660 It still looks like a key fob, but I'm going to have it do other things. 456 00:28:48,320 --> 00:28:48,680 Great. 457 00:28:48,860 --> 00:28:52,100 But I don't want to have to write the stuff every time. 458 00:28:52,560 --> 00:28:57,260 So I go on and I'm going to go through and change what I want on the fly. 459 00:28:57,540 --> 00:29:01,360 Bad USB, he wrote it once and he was just able to keep doing the attacks. 460 00:29:01,840 --> 00:29:05,680 So the concept of a single device being able to come in and do multiple things was great. 461 00:29:05,940 --> 00:29:07,040 He showed it could be done. 462 00:29:07,180 --> 00:29:11,760 But I want to be able to do it on the fly because for fuzzing, I want to do it over and over again. 463 00:29:15,700 --> 00:29:18,220 And his problem, like I said, he had to write it once. 464 00:29:18,380 --> 00:29:20,660 So he locked the firmware into the device. 465 00:29:21,120 --> 00:29:22,760 I want to be able to do it on the fly. 466 00:29:23,840 --> 00:29:27,680 The key thing to get here, though, is he didn't do anything that was not in the protocol. 467 00:29:28,460 --> 00:29:30,280 He just pretended to be another device. 468 00:29:30,780 --> 00:29:32,620 So all of this used a normal protocol. 469 00:29:32,840 --> 00:29:34,920 He didn't crash anything or do anything weird. 470 00:29:35,120 --> 00:29:39,820 He came in through the normal protocol and said, oh, yeah, I'm not only a key fob, I'm 471 00:29:39,820 --> 00:29:40,360 also a keyboard. 472 00:29:40,500 --> 00:29:41,760 I want you to start typing this. 473 00:29:42,200 --> 00:29:44,140 Or I'm also this type of DMX. 474 00:29:44,160 --> 00:29:46,080 I want you to start pulling memory out. 475 00:29:49,320 --> 00:29:52,600 So if you want to take a look at his presentation, it is posted here. 476 00:29:52,920 --> 00:29:54,060 There's a video of it up. 477 00:29:54,660 --> 00:29:58,020 So again, when you grab the notes, you can take a look if you're not sure what I'm talking 478 00:29:58,020 --> 00:29:58,720 about, what he did. 479 00:29:59,420 --> 00:30:03,600 But what I want to do is start attacking the systems via the USB port. 480 00:30:05,880 --> 00:30:08,740 So way back, I started with the Beagle 480. 481 00:30:08,840 --> 00:30:13,260 I could see the transactions, and I started with a device called a Teensy, a special form 482 00:30:13,260 --> 00:30:13,720 of Arduino. 483 00:30:14,620 --> 00:30:21,540 What's special about it is the USB chip they used, it could be programmed to identify itself 484 00:30:21,540 --> 00:30:22,540 any way you wanted. 485 00:30:23,080 --> 00:30:25,480 So it could say, oh, I'm a keyboard, I'm a mouse. 486 00:30:25,580 --> 00:30:26,580 We used to play with these things. 487 00:30:26,640 --> 00:30:27,100 They were great. 488 00:30:27,260 --> 00:30:29,160 But they had the same problem with bad USB. 489 00:30:29,320 --> 00:30:33,120 You had to program it on one computer, then carry it over and connect it to another computer. 490 00:30:33,820 --> 00:30:36,620 It worked great, and there's some great slides about it. 491 00:30:36,680 --> 00:30:37,640 There's some great presentations. 492 00:30:38,340 --> 00:30:42,220 Then I saw this presentation at DEF CON where a guy said, oh, I can do that programmatically. 493 00:30:42,220 --> 00:30:47,480 And I took a look, and sure enough, somebody had created a dongle that could do this. 494 00:30:47,700 --> 00:30:52,940 Travis Goodspeed created this thing called a Face Dancer 21, and you can now buy them. 495 00:30:53,520 --> 00:30:58,780 Zipiter sells them online, and actually, I think Hacker Warehouse is selling them down 496 00:30:58,780 --> 00:31:00,560 in the vendor area right now. 497 00:31:01,740 --> 00:31:11,580 It's just a small USB dongle, and it looks like this, two USB ports that allows me to 498 00:31:11,580 --> 00:31:16,580 connect a computer to it, say, I want you to be this device with these endpoints, and 499 00:31:16,580 --> 00:31:20,920 then it connects to your host computer and says, hi, I'm this device with these endpoints. 500 00:31:21,300 --> 00:31:28,280 And you can do this over and over again because this little dongle can also shut itself down, 501 00:31:28,760 --> 00:31:33,360 remove it, appear to remove itself from the computer and reconnect itself without removing 502 00:31:33,360 --> 00:31:34,060 any wires. 503 00:31:34,360 --> 00:31:36,760 So again, this is the key to making this work. 504 00:31:36,840 --> 00:31:39,360 This is why we can do this cheap now. 505 00:31:39,660 --> 00:31:41,500 We have the software to do the fuzzing. 506 00:31:41,500 --> 00:31:43,140 We have the little dongles we can buy. 507 00:31:43,460 --> 00:31:46,800 It's now achievable for anybody to just go in and USB hack. 508 00:31:47,200 --> 00:31:49,580 You don't need a $1,200 sniffer or something. 509 00:31:49,820 --> 00:31:51,160 You can just use this. 510 00:31:52,020 --> 00:31:52,780 Much cheaper. 511 00:31:53,300 --> 00:31:56,560 And it took a little while to get the software out, but I went through. 512 00:31:56,620 --> 00:31:57,520 I got the software. 513 00:31:57,820 --> 00:31:59,840 But this is really a pretty good circuit. 514 00:31:59,960 --> 00:32:01,700 It's just a different form of as good FET. 515 00:32:02,040 --> 00:32:06,920 The key thing is it has two USB chips on it, one for one side, one for the other, and 516 00:32:06,920 --> 00:32:11,040 I use, I connect my computer to it, I say, I want you to do this, and then it goes out 517 00:32:11,040 --> 00:32:12,900 the other side and pretends to be the entire device. 518 00:32:13,720 --> 00:32:14,440 Very handy. 519 00:32:15,180 --> 00:32:17,220 Again, he's got presentations up on it. 520 00:32:17,340 --> 00:32:19,200 He first presented it in this YouTube. 521 00:32:19,440 --> 00:32:20,340 You can go pull it out. 522 00:32:20,420 --> 00:32:21,700 I think it was from CC3. 523 00:32:22,600 --> 00:32:26,700 But again, you can take a look at what it is yourself or you can come by tomorrow. 524 00:32:27,000 --> 00:32:28,880 I'll be here all day and play with it. 525 00:32:28,920 --> 00:32:29,660 I have several ones. 526 00:32:30,120 --> 00:32:31,700 We can take a look at how it works then. 527 00:32:33,280 --> 00:32:35,560 The other part was it's not just the hardware. 528 00:32:35,780 --> 00:32:37,220 We needed something to help it out. 529 00:32:37,920 --> 00:32:41,020 He wrote some good basic software that lets you talk to it. 530 00:32:41,040 --> 00:32:45,700 You know, there's escapee interface for those of you who want to just create custom packets. 531 00:32:46,100 --> 00:32:47,700 But that's still not enough to fuzz. 532 00:32:47,780 --> 00:32:49,100 We needed kind of the next level. 533 00:32:52,240 --> 00:32:53,460 My hardware set up. 534 00:32:54,020 --> 00:32:57,700 I use my computer here to set it up and I just have it connect in. 535 00:32:57,960 --> 00:33:00,160 I'm able to put anything I want on the wire. 536 00:33:00,560 --> 00:33:04,180 So I went through all that protocol knowledge so we know what to put on the wire. 537 00:33:04,620 --> 00:33:06,380 Now we're going to take a look at how to do it. 538 00:33:08,240 --> 00:33:09,240 I already said that. 539 00:33:09,400 --> 00:33:09,660 So. 540 00:33:09,660 --> 00:33:12,040 You can get the software straight out of GitHub. 541 00:33:13,160 --> 00:33:15,360 Again, totally open source to do with it. 542 00:33:15,480 --> 00:33:17,500 If you buy one, here's how to set it up. 543 00:33:19,140 --> 00:33:22,820 And like I said, he gives you a good basic escapee interface but nothing more. 544 00:33:25,340 --> 00:33:30,380 So lots of people then took that basic interface and decided to play with it in different ways. 545 00:33:30,700 --> 00:33:34,720 We've seen a couple of people create some nice custom software for doing the fuzzing. 546 00:33:34,880 --> 00:33:39,340 But what they really did was they wrote their fuzzer and pointed it at these custom libraries. 547 00:33:39,340 --> 00:33:41,560 I wanted one that did fuzzing right out of the box. 548 00:33:42,220 --> 00:33:47,480 So again, Daniel Mende's presentation about doing this is pretty funny. 549 00:33:47,600 --> 00:33:49,260 He did his custom fuzzer, Dizzy. 550 00:33:49,860 --> 00:33:54,320 Works beautifully but it requires, it would be fairly technical to get it to work. 551 00:33:58,480 --> 00:33:59,300 Programming the face dancers. 552 00:33:59,620 --> 00:34:01,580 If you come by, I'll give you the videos, too. 553 00:34:01,700 --> 00:34:04,560 I just have some videos of like programming it but I don't have them on this laptop. 554 00:34:07,880 --> 00:34:08,260 Again. 555 00:34:08,440 --> 00:34:08,660 Just. 556 00:34:08,700 --> 00:34:09,220 This is just. 557 00:34:09,340 --> 00:34:12,860 This is not the programming info for how you do it in this case. 558 00:34:13,240 --> 00:34:14,160 I like this way. 559 00:34:14,300 --> 00:34:16,060 You just go pull the latest image off the web. 560 00:34:16,220 --> 00:34:17,100 It installs it. 561 00:34:17,120 --> 00:34:18,840 Takes about 30 seconds and you're ready to go. 562 00:34:20,540 --> 00:34:22,080 So next layer of software. 563 00:34:22,680 --> 00:34:25,400 This is a presentation I saw several years ago at DEF CON. 564 00:34:25,540 --> 00:34:26,480 It took them a little while to get it up. 565 00:34:26,900 --> 00:34:31,560 Andy Davis of the NCC group put out a set of Python libraries called UMAP. 566 00:34:32,260 --> 00:34:35,320 This is what makes it easy now for anybody to come and fuzz. 567 00:34:35,680 --> 00:34:38,220 If you have Python and PySerial on your box. 568 00:34:38,220 --> 00:34:39,820 You're ready to use a face dancer. 569 00:34:40,180 --> 00:34:41,140 It's that simple. 570 00:34:42,180 --> 00:34:44,220 He's got, his presentations are up. 571 00:34:44,260 --> 00:34:46,300 His GitHub account is there if you want to pull this stuff. 572 00:34:46,680 --> 00:34:48,520 This is what I've been working off of. 573 00:34:48,760 --> 00:34:51,160 It does scanning as well as fuzzing. 574 00:34:52,240 --> 00:34:54,840 So when you run it, you just take a look at it. 575 00:34:54,920 --> 00:34:57,300 It's a very basic framework for USB fuzzing. 576 00:34:59,040 --> 00:35:01,800 The only trick is, for me, it's Python 3. 577 00:35:02,100 --> 00:35:03,880 All the good FET stuff is Python 2. 578 00:35:04,520 --> 00:35:06,760 And it also requires Python 3 serial. 579 00:35:06,960 --> 00:35:08,140 But as long as you have that installed. 580 00:35:08,140 --> 00:35:09,200 You should be ready to go. 581 00:35:10,020 --> 00:35:12,320 So this is what it can do out of the box. 582 00:35:12,840 --> 00:35:16,020 It can list all the different devices that it can pretend to be. 583 00:35:16,740 --> 00:35:18,900 Identify the supported devices on a connected host. 584 00:35:19,120 --> 00:35:26,180 So I can tell this, go ahead and run that script, minus I, and it will go and connect 585 00:35:26,180 --> 00:35:28,080 to your host and say, I'm this device. 586 00:35:28,200 --> 00:35:28,720 I'm this device. 587 00:35:28,940 --> 00:35:34,480 And just do it over and over again until it's enumerated all the possible devices that 588 00:35:34,480 --> 00:35:34,800 are there. 589 00:35:35,200 --> 00:35:37,700 The interesting thing is that each time it does this. 590 00:35:38,140 --> 00:35:41,640 It's causing that computer to load the appropriate driver. 591 00:35:42,580 --> 00:35:48,220 Now if you're on Windows or Mac and you've seen that driver before and accepted the signed 592 00:35:48,220 --> 00:35:50,660 driver, it will just load it without telling you at all. 593 00:35:50,940 --> 00:35:53,020 It will just go, boom, unloaded, no problem. 594 00:35:53,260 --> 00:35:56,980 If it's a new device that it's never seen before, it will cause a popup. 595 00:35:57,940 --> 00:35:59,060 Linux doesn't do that. 596 00:35:59,540 --> 00:36:04,260 Linux, if it has the device somewhere in the memory or in its file system, it just loads 597 00:36:04,260 --> 00:36:04,420 it. 598 00:36:04,880 --> 00:36:07,340 It logs it, but it never causes a popup. 599 00:36:07,340 --> 00:36:08,660 So, kind of fun there. 600 00:36:09,740 --> 00:36:12,900 So he gives you one here, it will be in the source code tomorrow. 601 00:36:13,220 --> 00:36:15,840 You can just walk through the different data classes and see. 602 00:36:16,040 --> 00:36:18,540 All it's going to do is just step, show me all the devices. 603 00:36:22,680 --> 00:36:26,340 And again, when you grab the other stuff, there's videos, I just don't have them here, 604 00:36:26,480 --> 00:36:27,780 but I left the slide in. 605 00:36:30,440 --> 00:36:34,560 So the nice thing about device scanning is you don't actually have to have the device. 606 00:36:34,780 --> 00:36:36,800 You're just running through the list of numbers. 607 00:36:36,800 --> 00:36:42,460 So you'll get to see all the device types regardless of the manufacturer, if the driver 608 00:36:42,460 --> 00:36:42,740 is there. 609 00:36:42,960 --> 00:36:49,020 So when I gave you before the case of the keyboard, the MX700 Logitech, it will tell 610 00:36:49,020 --> 00:36:53,540 you, yes, I have a keyboard driver for the generic, but it will also come back and say, 611 00:36:53,640 --> 00:36:58,420 oh, yeah, when I ran through this list, I also noticed he has the specific driver for 612 00:36:58,420 --> 00:37:02,020 the Logitech M700 or for the Canon camera or whatever. 613 00:37:02,320 --> 00:37:05,600 That gives you an idea of your targeting if you're looking at attacking somebody. 614 00:37:05,800 --> 00:37:05,960 Okay. 615 00:37:08,260 --> 00:37:14,960 And the idea that in Linux there's no confirmation, in Windows there's no confirmation as long 616 00:37:14,960 --> 00:37:16,220 as you've seen the driver before. 617 00:37:16,660 --> 00:37:20,100 But it's also kind of fun to do because it causes somebody to have a lot of pop-ups, 618 00:37:20,620 --> 00:37:22,740 which annoys the heck out of them if they don't know what's happening. 619 00:37:24,780 --> 00:37:28,100 And example pop-up, I'm sure you've all seen these before. 620 00:37:32,820 --> 00:37:36,380 So it also has built in this idea of fingerprinting a system. 621 00:37:36,800 --> 00:37:40,960 Just like in Nmap where we send packets and we can tell what the operating system on the 622 00:37:40,960 --> 00:37:44,600 other end is by how they respond, you can do the same thing with USB. 623 00:37:44,820 --> 00:37:50,040 What drivers were built in already, what messages did it handle, this is kind of Nmap for operating 624 00:37:50,040 --> 00:37:50,380 systems. 625 00:37:50,960 --> 00:37:53,720 Now, it might seem kind of silly to you for, like, a desktop or laptop. 626 00:37:53,960 --> 00:37:54,960 You can kind of know, right? 627 00:37:55,280 --> 00:38:01,700 But if you have, say, a small embedded router that has a USB port on it, you can then look 628 00:38:01,700 --> 00:38:03,340 and see what the operating system is. 629 00:38:05,140 --> 00:38:06,780 That will give you ideas of where you are. 630 00:38:06,780 --> 00:38:09,980 You can attack it, what different operating systems are available. 631 00:38:10,200 --> 00:38:14,920 It can also get down to about the version level, though that's a little sketchy sometimes. 632 00:38:15,580 --> 00:38:20,700 But again, it's similar to the way Nmap scans, but handy for identifying embedded devices. 633 00:38:23,160 --> 00:38:25,020 And there's the OS detection. 634 00:38:25,980 --> 00:38:30,080 And finally, the part that we're all here for, right? 635 00:38:30,430 --> 00:38:31,240 The fuzzing part. 636 00:38:31,820 --> 00:38:36,520 You can set it to, you can control the device, what the vendor ID is. 637 00:38:36,520 --> 00:38:37,660 What the PID is. 638 00:38:37,760 --> 00:38:40,000 All of these are for the setup part of it. 639 00:38:40,240 --> 00:38:44,300 Once you do this, it will just go through all the valid message types you told it to 640 00:38:44,300 --> 00:38:47,100 do and look and fuzz each one of the fields individually. 641 00:38:47,620 --> 00:38:49,920 So you end up sitting there, you know, in the page. 642 00:38:50,180 --> 00:38:52,780 It will walk through all the fields that are there automatically. 643 00:38:53,120 --> 00:38:54,640 You don't have to memorize them. 644 00:38:54,720 --> 00:38:59,260 Although if there is a field you're interested in, then you're able to pick it specifically. 645 00:38:59,860 --> 00:39:04,800 So that's why I picked this particular system to talk about, just because it really lowers 646 00:39:04,800 --> 00:39:05,260 the bar. 647 00:39:05,260 --> 00:39:08,200 It makes it pretty easy for anybody to get on this and do it. 648 00:39:10,320 --> 00:39:12,280 You can also do entire classes. 649 00:39:12,480 --> 00:39:17,640 So I can say just scan, just attack the HID devices, just fuzz the HID devices, and leave 650 00:39:17,640 --> 00:39:18,700 the cameras out of it. 651 00:39:22,220 --> 00:39:27,500 And the command lines for that are minus F and minus S. Sorry, my laptop. 652 00:39:27,780 --> 00:39:30,320 I would add videos for all this so I could show you. 653 00:39:30,700 --> 00:39:32,300 But different laptops, sorry. 654 00:39:32,640 --> 00:39:35,100 All the ones that are in there are in this test case. 655 00:39:35,100 --> 00:39:37,100 You can edit it yourself. 656 00:39:37,380 --> 00:39:39,900 It's pretty well-documented Python for you to work with. 657 00:39:41,240 --> 00:39:46,180 And you'll get a very good correspondence between what's in that list and the printouts 658 00:39:46,180 --> 00:39:50,360 that you get out on those USB spec sheets or all the sniffing you got. 659 00:39:51,320 --> 00:39:53,060 And of course, another fuzz run. 660 00:39:53,920 --> 00:39:58,660 Fuzz runs generally take 40 minutes to an hour to do a complete run. 661 00:39:58,840 --> 00:40:01,840 So I would highly advise you target as much as possible. 662 00:40:03,040 --> 00:40:03,820 All right. 663 00:40:03,820 --> 00:40:04,020 All right. 664 00:40:04,600 --> 00:40:05,080 All right. 665 00:40:05,100 --> 00:40:05,240 All right. 666 00:40:05,240 --> 00:40:06,820 That's about as far as I'm going to take it. 667 00:40:07,820 --> 00:40:11,620 I'll take you up to the point where you crash, where you get a crash, the kernel panics, 668 00:40:11,680 --> 00:40:12,480 we get the dump. 669 00:40:12,680 --> 00:40:17,880 Now, how you choose to exploit that is a whole different set of talks and a whole different 670 00:40:17,880 --> 00:40:18,220 arc. 671 00:40:18,920 --> 00:40:20,800 The idea is to get to a crash. 672 00:40:21,120 --> 00:40:26,760 But when you're on the good side, to be honest, if you can fuzz something through USB and 673 00:40:26,760 --> 00:40:29,180 get a crash, that's good enough to get you a bug bounty. 674 00:40:29,760 --> 00:40:34,680 I know for a personal thing, all you need is the crash to win the bug bounty most of 675 00:40:34,680 --> 00:40:34,980 the time. 676 00:40:35,100 --> 00:40:36,640 You don't even have to have an exploit. 677 00:40:37,340 --> 00:40:38,800 You can just move on to the next one. 678 00:40:38,900 --> 00:40:40,600 If you do an exploit, they'll pay you a little bit more. 679 00:40:40,760 --> 00:40:44,460 But a crash is almost good enough on a lot of these bug bounty programs that I've been 680 00:40:44,460 --> 00:40:44,720 doing. 681 00:40:46,640 --> 00:40:51,340 Also keep a close eye when you're doing your fuzzing on the PID of the process that might 682 00:40:51,340 --> 00:40:55,020 end up with the data because sometimes they'll restart on you and you might miss it. 683 00:40:55,120 --> 00:40:56,840 You might get a crash and not realize it. 684 00:40:58,540 --> 00:41:01,760 So, and that's the goal right there. 685 00:41:01,900 --> 00:41:02,880 We want blue screens. 686 00:41:03,040 --> 00:41:04,660 Because when we get blue screens, we're going to get a crash. 687 00:41:04,660 --> 00:41:08,680 That means we've successfully managed to do our fuzzing. 688 00:41:08,900 --> 00:41:10,140 We found something wrong. 689 00:41:10,580 --> 00:41:13,620 And you'll notice that I am in USBD.SYS. 690 00:41:13,940 --> 00:41:16,080 So obviously I hit something good here. 691 00:41:20,080 --> 00:41:24,060 Specifically, it's not out yet, but they're going to pay me about three grand for this 692 00:41:24,060 --> 00:41:24,720 particular crash. 693 00:41:29,520 --> 00:41:31,740 And like I said, I'm not going to go too much into it. 694 00:41:31,800 --> 00:41:34,640 Once you have a crash, you'll get the cord up and you'll go into the much more technical. 695 00:41:34,640 --> 00:41:35,820 Traditional exploit development. 696 00:41:38,080 --> 00:41:44,420 So my advice, of course, is if you choose to do this, obviously just report any crashes 697 00:41:44,420 --> 00:41:45,740 you find to the right people. 698 00:41:46,040 --> 00:41:51,000 And what I mean by that is do not call Microsoft up with a crash in the Logitech stuff. 699 00:41:51,700 --> 00:41:53,080 That goes to Logitech. 700 00:41:53,340 --> 00:41:58,000 Microsoft probably gets tons and tons of reports that have nothing to do with code they wrote. 701 00:41:58,300 --> 00:42:02,520 Because everybody else, all these third party drivers are the ones that caused the crashes. 702 00:42:03,320 --> 00:42:03,800 So. 703 00:42:04,640 --> 00:42:06,360 If you want more info, grab the slides. 704 00:42:06,640 --> 00:42:07,360 I have some links here. 705 00:42:07,720 --> 00:42:10,040 Here are some things that will help you get started with this. 706 00:42:11,080 --> 00:42:15,120 Obviously, if you're in the Seattle area, both NET9 and Black Lodge Research, where 707 00:42:15,120 --> 00:42:19,400 we meet and we talk about this stuff a bit, like I said, feel free to stop by. 708 00:42:19,740 --> 00:42:20,580 So that's it. 709 00:42:20,840 --> 00:42:21,940 I hope it was interesting. 710 00:42:22,220 --> 00:42:25,060 I'm sorry I didn't get to show you the videos, so I'm a little faster. 711 00:42:25,820 --> 00:42:28,460 Tomorrow I'll be here, like I said, with these, with that. 712 00:42:28,540 --> 00:42:30,760 Come join me if you want to try fuzzing out for yourself. 713 00:42:31,140 --> 00:42:32,860 Take a look at what we can do with these things. 714 00:42:33,820 --> 00:42:34,620 And I'll take care. 715 00:42:34,640 --> 00:42:34,800 If you have any questions. 716 00:42:35,460 --> 00:42:35,620 Sorry. 717 00:42:35,820 --> 00:42:36,260 Yeah. 718 00:42:37,020 --> 00:42:38,620 I cannot hear a word you're saying. 719 00:42:38,960 --> 00:42:39,880 What's happening tomorrow? 720 00:42:40,760 --> 00:42:44,580 I will be here first thing when I wake up tomorrow, and I will leave when this 721 00:42:44,580 --> 00:42:45,120 place closes. 722 00:42:46,580 --> 00:42:49,920 So say 10 or 11 a.m. tomorrow through the day. 723 00:42:50,520 --> 00:42:51,760 I'm not doing anything else. 724 00:42:51,880 --> 00:42:54,660 I'll be right back there, probably in that back corner table. 725 00:42:55,140 --> 00:42:59,460 And like I said, in addition to that, this is the USB sniffer. 726 00:42:59,640 --> 00:43:04,560 I have the I2C sniffer, the spy sniffer, the CAN bus sniffer for all you cars. 727 00:43:04,640 --> 00:43:08,940 I have a million dongles, whatever you want to talk about. 728 00:43:09,100 --> 00:43:10,400 I'll talk pretty much any protocol. 729 00:43:10,860 --> 00:43:14,700 But I'm primarily talking about USB today, and we're going to do the USB stuff. 730 00:43:14,960 --> 00:43:17,280 I have a system you can just straight SSH into. 731 00:43:17,420 --> 00:43:18,660 You don't have to install any software. 732 00:43:19,000 --> 00:43:25,420 If you want to, you need Python serial, Py2, Py serial, and Py3, Py serial, and you can 733 00:43:25,420 --> 00:43:26,340 pull the software off GitHub. 734 00:43:27,480 --> 00:43:28,200 Any other questions? 735 00:43:29,620 --> 00:43:30,020 Cool. 736 00:43:30,200 --> 00:43:31,340 So I hope that's a start. 737 00:43:31,440 --> 00:43:32,480 You're welcome to the slides. 738 00:43:32,620 --> 00:43:34,140 I know I zipped through them. 739 00:43:34,640 --> 00:43:38,420 Lots of links in there for you to follow, and if you want, you can have the videos, 740 00:43:38,480 --> 00:43:38,640 too. 741 00:43:38,740 --> 00:43:40,160 They're just MP4s. 742 00:43:40,360 --> 00:43:42,660 And you can see fuzzing runs and things like that. 743 00:43:42,860 --> 00:43:47,340 I show you things like here's the de-message and what happens when I'm fuzzing, and you 744 00:43:47,340 --> 00:43:49,880 just see it loading driver after driver after driver. 745 00:43:50,360 --> 00:43:54,180 But like I said, a good fuzzing run will take you about 40 minutes, so the videos are sped 746 00:43:54,180 --> 00:43:54,320 up. 747 00:43:55,500 --> 00:43:56,060 Anything else? 748 00:43:57,080 --> 00:43:57,440 Yeah. 749 00:44:02,280 --> 00:44:03,360 Bring me a USB drive. 750 00:44:03,560 --> 00:44:03,880 All right. 751 00:44:04,500 --> 00:44:04,620 All right. 752 00:44:09,080 --> 00:44:09,500 Cool. 753 00:44:09,500 --> 00:44:09,900 Any other questions? 754 00:44:11,620 --> 00:44:12,040 Cool. 755 00:44:12,080 --> 00:44:12,420 Thanks a lot. 756 00:44:12,460 --> 00:44:12,600 Yeah. 757 00:44:17,480 --> 00:44:21,440 There's a form of this presentation on the NEG 9 website if you want it. 758 00:44:21,600 --> 00:44:23,240 If not, I'll give you this presentation. 759 00:44:23,780 --> 00:44:25,100 It's almost the same. 760 00:44:26,240 --> 00:44:26,660 So. 761 00:44:28,360 --> 00:44:28,980 Anything else? 762 00:44:29,320 --> 00:44:29,740 Cool. 763 00:44:29,880 --> 00:44:31,120 Hey, thanks for stopping by. 764 00:44:31,220 --> 00:44:32,000 I hope that was interesting. 765 00:44:33,020 --> 00:44:34,600 And like I said, I'll see you next time. 766 00:44:34,620 --> 00:44:36,260 If you got any questions, come see me. 767 00:44:36,260 --> 00:44:37,260 I got nothing better to do. 768 00:44:37,340 --> 00:44:37,440 Bye.