All right. Let's have some fun here. So this presentation is the setup for tomorrow. Tomorrow I will be back here in the hardware hacking village. We will have USB sniffers and fuzzers and you can come play to your heart's content. So today I'm just going to do a quick introduction to USB in general, a little bit about the protocol and a little bit about how we go and attack it. Now what I'm talking about today is not the bad USB type attacks. I'm talking about attacking an operating system via the USB port. So we're attacking system drivers via the USB port. It's a great way to get into the thing and I hope you see that today. So introduction to USB fuzzing. I'm Matt Duarte. You want to hear about stuff? Crypto monkey. Twitter handle is cryptomonkey. And let's talk about it. So what is USB? Back in the olden days where I'm from, there used to be different ports for keyboards, things like that. They came up with the universal serial. You can put any kind of a device on it. These are the guys who got together, Hewlett Packard, Intel, all that. They came up with a standard for it and they've revised it several times. Most of the revisions deal with two things. The speed at which it can transfer data and the amount of power that it consumes. So everything I talk about when I talk about the spec is out of this. If you get the presentation, there's a link here, www.usb.org. Home, it will have all the specs for you. They're free to download. So quick agenda, what we're going to do, look at the USB, hardware, software, talk a little bit about the protocols and then look at how we're going to get in. The tool tools I use are the Face Dancer 21 and UMAP Pi. I like this setup because you don't have to be like Uber Elite to do this. With the Face Dancer 21, it's a dongle made by Travis Goodspeed. It will take care of creating packets for you. You can do the fuzzing, all sorts of tricks there. UMAP is a very nice Python fuzzing thing that you can get right off GitHub and try out. I'll demo it all tomorrow. So first of all, the hardware. What is the hardware? The hardware is USB. Some of you may know this already. USB is a four-wire protocol. There's four wires inside that cord you have. Ground and power, five volts, and there's some amperage differences. The other two are data wires. There's no signal and transmit, receive like in serial. It's differential data. So that means there's a positive and negative. You just have to interpret them. Some connectors do have this fifth pin, the OTG. That's really so you can use your phone as a USB battery, things like that, when it comes to fuzzing. So everybody's seen the connections. The key thing to remember is that with the exception of the USB 3 here, everything here is just different form factors of those same four wires. And why they all differ has to do with what their function is. Specifically, the flat square type A's that you're used to, they're the only ones allowed to put power into the wire. All these other connectors should never put power into the wire. That's the key point. USB 3 just has a few extra pins, but we're going to concentrate on USB 2 today. I think you've seen most of the connections, right? Everybody knows their connections? Cool. So only type A puts power on the wire. You got that. The key to a lot of this fuzzing stuff, and this is just my advice from having done this for a long time, use the shortest USB cables possible. Because we're going to be putting several devices on a USB bus, and there's only so much power you can get out of the USB bus. So one of the things I really like about this is, if you're using a USB cable, you're going to have to really enjoy these really short 6-inch cables you can get off Amazon. Definitely, if you're going to be doing the fuzzing where you put multiple devices in line, do this. You don't want to lose your power to the cable when you have to charge up multiple devices. So within the wire, no matter whether you're using all the way up to USB 3, there's multiple speeds. They can all exist on the same bus. In fact, they normally do. There's low speed, full speed, and high speed in the USB 2 spec. If you use a keyboard, no matter what, latest computer, latest keyboards, you're still going to use this USB low speed, the low, the 1.5 megabits a second. Also known as USB 1.1. Full speed gets you a little bit more than high speed. Not only do they differ in speed, they also differ in the amount of data they can transfer at once, and we'll take a look at that in a second. So let me talk a little bit about the USB networks. You have a laptop, you want to know a little bit about what USB you have, you want to know how many networks are set up. So there's always one host adapter. That's what you're going to see in your computer. This is the one USB master. Then below that, there can be a series of hubs. There's allowed to be up to five hubs between any device and the root hub, which is the one built into your computer. So you can chain these hubs all you want. Interestingly enough, there's probably a hub in your computer already, so you lose one off of that list. Also, you can only have on the entire network 127 devices. It's just the way the addressing works. So here's an example of my Dell desktop at home. The output of LS USB.T. You can see the tree of what we have here. The interesting thing is at this top one where you see I have four USB host masters. Below it, there's another set of USB devices that are the hubs. They're actually built into the computer. So when you look at the back of a desktop and you see four ports, those aren't all independent USB. They're actually the first tier of hubs that are built into your computer. That's why you lose one. Then you can see the device is plugged into it. What I'm going to be showing you tomorrow in here and a little bit later is the idea of pretending to be a different device here to attack into the computer. It's actually pretty simple when you get the hang of it. So different computers have different ways of doing it. When you grab the slides later, they'll be posted. You'll see I have everything in here, how to do it on Mac, how to do it on Windows and how to do it on Linux. So you'll see a little bit of redundancy in the slides, but I wanted to cover everything. I'm going to show you how to do it on Windows and how to do it on Linux. That's just the Mac version. It's out of the Apple developer hardware tools for Xcode. It's called IO reg explorer. Gets you the same kind of thing. The tree with all the devices on it. We'll need this later to do some fuzzing. And funny thing is if you've got an older Mac that doesn't have USB 3, you may actually see some USB 3 ports on it. That's because they actually are coming in via the Thunderbolt connection. If you have a Thunderbolt hub that you connect your old Mac to, it might have USB 3 on it. So you're doing actually USB via Thunderbolt into your computer. You're getting to see this an awful lot, too. Newer computers, if you have a USB 2 port, it's probably a step down from USB 3. So again, watch out because there's a lot of different ways of sneaking USB ports in. Also, they're used internally in the computer. And finally, the Windows device manager has a little bit of data. I recommend you go look at this tool here called USB view. It's a little bit more advanced. It's a little bit more advanced. It's a little bit more advanced. It'll get you to the same thing. So what we're looking at here is just trying to figure out what devices are on the computer, what ones are built in. The reason I care what's built in is because those are the ones the drivers will already be loaded. Later on, I'll show you how we're going to instantiate a driver that hasn't been loaded. So quick and dirty, you guys got the idea of the whole hierarchy hubs and addresses. You can dig into it. There's all sorts of things about how that works. But what I want to get on to is the kind of protocol that we're going to get on to. Before we go there, though, let's look at what happens when you connect a USB device to a computer. So I'm going to discuss the Linux 3X kernel, not because it's particularly any better or worse. They all work basically the same way. This is my lovely diagram of how it works. You have this idea of the USB hardware connects to the computer. It goes into something in the Linux kernel called USB core. This is the first part of the Linux kernel that's there. It handles all the generic stuff in the Linux kernel. It goes into something in the Linux kernel called USB core. It handles all the generic types of USB devices, so no specificity. But it will hand it off onto a device driver that is specific to whatever you just plugged in, a keyboard, a mouse, a video camera, whatever. These are the ones that we're going to start attacking more. This one's pretty robust, and it doesn't do much. It doesn't have a lot of hooks into it. This one's a lot more fun. It's then exported as a device out to user land, then other programs will attach to it. Yes? Oh. Sorry about that. As I was saying, USB core is pretty generic. These other drivers are the ones that we're going to instantiate and play with quite a bit. I'll show you how to do that. Within each of the drivers, then, there's also this concept of there's a hierarchy of drivers. Besides the USB core, there might be a USB device driver and then a specific device driver on top of that. Think of attaching a USB key fob, right, your storage device. Well, it's going to have a very generic USB core, something that talks USB, and then there will be something that actually talks the file system itself. Meaning going in through the USB port, you're actually able to attack every one of these things, depending on what the data you send in is. And we can construct any kind of arbitrary packet using UMAP and the FaceDancer hardware. So what kinds of things are already loaded in the kernel? I use the LS mod grep USB that will get you all the USB devices that are in there. I use the USB core, something that talks USB, and then there will be something that actually talks USB. And if you want to take a look, you can look in the library's directory. You can see what also can be loaded. You can also see them as they're added by looking in var log messages or var log kernel or just tail off var log message or tail off D message and you'll get each of them as they connect. Again, that's telling us what device or what part of the operating system we're going to attack each time. And I just did it a different way. I looked at the PCI bus. You can see the different devices here. You can see the different devices here. You can see the different devices here. The key thing is when you do an LS PCI, you will see the actual USB bus is device ID1D. This means I can go into the proc file system and actually pull out all sorts of very interesting data about it. What the device's firmware was. What drivers, all the kinds of data here. All of these things give me ideas of what I can attack when I come in and send the different types of packets. So I'm going to go ahead and show you what I can attack when I come in and send the different types of packets. So I'll show you right now. On the right hand side, I'm getting a little more detailed. If I drive into each one, there's another, I can take a look at all the different cues. Also notice there's a manufacturer. There's a specific device name and then there's a generic device name. So you have the idea that you could have a HIT device that is a keyboard. And there's a generic keyboard driver for that. You can also have a Logitech MX, you know, 700. There might be a specific driver for that. They both are valid when you plug in the keyboard and they both can be used. idea of OSX, you can use the KX stack command to get the same thing. All we're doing right now is looking at a computer and seeing what was connected to it. So now that I have an idea from the operating system what can be seen, I'm going to take a step back and go, okay, what other devices got in there and what addresses do they have? This bus I said can only have 127 things on it, including hubs. So let's look at how that all sets up. What I have here is some dumps. If you want to know where the dumps are from, I'm using a hardware thing called a Beagle 480 sniffer. I will show you also a little bit how to do it with just straight Linux and USB, the USB mon, kernel driver and Wireshark, but I use the hardware because I get to see the electronics. But the idea is there's this thing called a transaction. This is the first transaction you have and it has this idea of a setup packet. The interesting thing here is while these two devices are talking on the network, there is no concept of an address. The device is actually just talking to the root hub and just saying, hey, I want to set up. The root hub will later on give it its actual address. So it's completely controlled by the host adapter. Nothing happens, no packets are ever initiated way down at the devices. The host always asks, hey, who are you? Tell me. Hey, use this address. Okay, I will use this address from now on. So the first packet or the first transaction is set up is made up of three packets, a setup, some data and an ACK. It's a little different than TCP IP where those are just flags. They are actually separate packets that are passed through. And the idea of these transactions can be one packet long, two, three, four, I haven't seen any fives yet, but each of them go together. They all get slapped in and they make a single transaction. This is the initial setup transaction. And each one also is self-identifying. They have different purposes. This is a setup. There's ones that do data. There's ones that say I want to leave the network or I want more power. All of those things are different transaction types that you can play with. Each one will begin with a token of a couple of bytes. We can go through this when you look at the stuff. This is what you'll need to start taking a look at it. This is what we're going to need to fuzz also. We need to understand the structure of a packet before we can start fuzzing. Skip through those. I just want to put this in. This is straight out of the manual, but what's important here is the different types of packets there are. Setups, starter frames, and then ins and outs. That's really actually a simple protocol. Just things I need to get my address, tell it I'm coming or going. Other than that, there's just the host telling you I'm sending you data or the host saying I want you to send me data. So again, like I said, that key fob that you put in will never send data to the host. It will always get asked, please send me the data and just respond. So the host initiates all the transactions. So the host initiates all the transactions. There's only one address in the transaction, and that is what the device is. So when we initially set up to this and looked at the packet, you can't see it here, but source and destination were both zero. It doesn't even have an address yet. The first thing it has to do is go through and try to get that address so that you can have the different devices and you don't get confused here. The idea, there's some data packets, there's a bunch of checks. There's different kinds of data packets. They have different sizes if you want to do bulk data transfer or not. So there's different kinds of data packets. There's a bunch of options. We don't have a lot of choice there. So it's not all that important, but you have to remember to fuzz each one of them individually because they will come up in different ways. And ACKs, NAKs, STALs and YETs are just different types of ACKs. There's more, TCP and IP you only have the ACK packet. This has different ones. They can say things like I was expecting you to send me data and you didn't. That's a NIEC packet, which I think is kind of funny. But I want to get on to the actual fuzzing part. This is all like I said, stuff straight you can take a look at it. But what we're trying to do is get an idea of the structure of a packet so we can begin to address that. And there we go. Okay, so now let's take a look at how you do these things. We've talked about how to look at the stuff on there. I've breezed through the kind of setup at this point. But how do we get at the data? In the case of a hardware sniffer, what you do is you actually put the hardware sniffer where that X is right in the middle of the wire. So this thing has a connection on it, two connections here. One just goes to the device, the other goes to the computer, and it sits in line. There's another connection on the other side that actually leads to the analysis computer. But the idea here is I'm actually intercepting the data as it passes through and able to create basically a wire shard of that data. I do it outside, so I'm looking at what's actually on the wire. I'm able to look at how much power it's drawing, all of those things, by intercepting on the wire. The nice part is neither one of these devices knows that it's being intercepted. There's no changes, there's no hop count changes or anything like that. It just happens, and I get to see what's there. The problem with these sniffers is I can't insert data. So I'm going to show you how to do that in a second. There you go. Sorry, I did have a picture of it. You get the idea. It's about a $1,200 device. It's useful, but mainly only if you want to look at the power stuff. So. Let's go back to that idea of that first handshake. You saw the setup packet saying, hey, I'm now on your bus. I would like to do something here. So first we do the hardware handshaking. Then we set up the first set of transactions. We start a frame, a setup, some in-data. All this goes to device 0 and .0. That's these two columns up here. That is the root adapter up at the top. So he's saying, hey, I'm on here. There's no source and destination addresses yet. So, we're going to assign a destination address now from the host adapter. Let's take a look at the transaction here. All this is really saying, this is a fancy way of looking at it. It says address 0, endpoint 0, wants to set the address of hex 16, which is 22 in decimal to the device. He's saying, okay, I now see you. I want you from now on to talk as if you're device 22. Think of this as the DHCP for the bus. But it's kind of nice because it means you don't have to ever pre-configure USB. It just connects, and then the host adapter says, here's your address, here's your address. It handles it all for you up to the 127 that's allowed. I put this up also because every one of these fields is now open when we start fuzzing it for overflows, wrong numbers, what happens if I give it a device ID above. That can cause crashes. All these are ways that we can get to the software by screwing with these different types of packets. And finally here, I like this picture. So, what you have is... You have to set up with no addresses, and then you'll notice after I told it to start using 22, from now on he's saying, I'm device ID 22, root 0. I don't think you need much more of that. Everybody kind of get that idea? Cool. So, there's a whole bunch of new transactions as it's set up, but mostly what it's doing is just negotiating how large a packet do I accept, what should the address I should use, all before it goes into these kind of bulk transfers of data. Now, there's lots of different modes that you can connect. Remember I said that the devices you connect never initiate a packet. So, one of the things you negotiate with the host is, well, do I want you to pull me every second? Do I do bulk transfers, like I'm a camera or a storage device? It has actually different modes for things that send just a little bit of data regularly, like a keyboard, or things that send a lot of data but irregularly, like a flash drive. So, there's all these different modes, but all of them are negotiated in this initial handshake. Yeah, I don't care. The second way of sniffing, so let's change gears here a little bit. If you don't need to see the electrical part of it, this is one of the ways I like to do it. There is a module built into most Linuxes. It's not loaded by default, but you can mod probe it in called mod USB. When you insert it in here, you mod probe it in, it actually allows you to intercept the traffic. Between USB core and the USB driver. What this means is you're able to do this without any hardware. If you have a Linux box, you probably already have this software. So, as long as you don't care about the hardware side of it, power stuff, you're good to get traffic this way. Even better, once you do that, it shows up in Wireshark. Once you mod probe that in, you fire up Wireshark. It says, oh, hey, do you want to sniff the USB device instead? And you get all of that nice Wireshark stuff. It's a Wireshark dissector, but for USB. So, at this point, what we're doing is we're just looking at a normal connection. We're figuring out what fields we can attack. But this is the cheap way to do it. Much easier. There are also equivalent drivers in, well, let me finish Linux first. Pseudo mod probe, USB mod in, and you can do this. Once you do that, like I said, Wireshark is your friend. And you don't have to have a special form of Wireshark. It's just built in. It just doesn't show up until you mod probe that in. So, fairly useful little thing that a lot of people don't know. On Windows, you can use something called USB PCAP to do it. It does the same thing. It will bring it in and allow you to capture the traffic that way. When you grab the slides, there's a link to it here. So, you can also do this. I haven't found a good way to do it in OSX, let's put it that way. Also, another good way if you're a pen tester or you do a lot of your malware work in VMs, since you know. When you plug in a USB device to something running VMWare, it pops up and says, do you want to connect to, in my case, your Mac or the Linux? And I say, oh, Linux. Well, once you do that, VMWare is actually passing all those Linux, all those USB transactions through. A few modifications in the VMX file, you can have it dump it to a file for you and then you can analyze it. So all of these are ways for you to intercept a USB transaction as it goes by and see all the things that are in a normal setup. And there is a program that helps you do it, but this is actually just a giant text file. I personally like the Wireshark way better. I like the dissectors. And you can try to do it with OSX, but they have not updated this package in a really long time and I'm not sure you want to bring in the kernel extension from another version. So I don't do that. Up until now, we've looked at this. When you connect a USB keyboard to something, you think it's just a keyboard. But I'm sure you've seen combined keyboards and mouses. I'm sure you've seen things like a video camera that does both video and has a microphone. One of the interesting things about USB is within one connection, you can actually put multiple devices. In fact, it's the thing that actually makes bad USB work because you can be a bad device and you can be a device that is perfect. So you can have a key fob that when you insert it, oh, it looks like I'm a storage device, shows up as a storage device, the user doesn't know any better, but it can also have other devices. What's interesting here is that it's built into the protocol and it doesn't require a different address. Within that one address, you can have multiple streams of data acting like they're coming from different devices. This is kind of fun because this is how we hide malicious transactions and malicious attacks within what looks like normal traffic. Because the user never realizes it. They put the key fob in. It works like it's supposed to. They don't ever think that I put in extra things or extra channels of data and I'm attacking extra drivers that they never thought of. This also gives you access to drivers that aren't normally loaded. So what I'm looking at here in the dump here is just the total number of end points in the configuration, and we're going to look at that concept next of where we're going to go with that. The other thing to take a look at this is you'll notice that there's device clients. That's what I was talking about, the generic devices. I'm a keyboard. I'm a mouse. And then you get into the specific ones with the manufacturer strings, and there you have a device vendor ID and a version number within that. That's your one that I'm a Logitech M7000 keyboard. They both are valid and they both work in instantiating drivers. The other thing you can see here is if you look, what I was talking about with multiple things in here. These interfaces are the parts. So it's one device, but it has all these different interfaces in it that it can do. Hardware input, audio streaming, audio control. So I can do volume control and I can bring in data, and I'm also a human interface device. All in one connection that you never saw. So the easiest way to describe this is to understand that you're probably generally used to thinking about a device. I had one cable. I plugged it in. It's one thing. But within the computers, they're thinking of it as this idea of configurations, which you rarely see more than one of, but then the interface descriptors say, hey, I am a type of device. I'm a microphone. I'm a keyboard. Then within that, you have endpoint descriptors. All conversations are one way. So in other words, if you have something that both reads and writes to a device, you define two different endpoints. One reads it. It sends data out. The other receives it in. So it's kind of your equivalent of your transmit and receive in serial, except in this case, they're both one-way channels. So even your normal key fob, you're going to have several channels in there, one for when it gets written to, one for when it gets read from. They get grouped together in an interface. I'm a key fob, which will eventually get into a device. I'm a, you know, whatever brand of key fob you use. So all of this is fun because this is how I hide different devices in there. But it also means that you can fuzz multiple parts of the thing at the same time because it is these interface descriptors that are the ones that are tied to a specific driver in the operating system. It's not a device. It's the interfaces. That's why you can have a microphone and a video in the same line. It'll be just one, you know, Logitech camera, but it'll file up two different drivers when we bring it in. So. All right. All right. So a single USB device can set up a variety of things. And just remember that they're always one way. They're either designated in or out. Out devices go from the computer to the device you attach. In devices means that I'm taking, I send a command, say send me data, and the device sends the data to up to the actual host control. There's also control signals you can send, like I said, for changing with power. Again, you always go through this process where I send you data. And you do whatever I say. In the different endpoint types, we have this idea of guaranteed delivery for packets. So a control endpoint is one type. Remember I said there could be different ones there, ins and outs? There could also be one called a control endpoint. A control endpoint is for doing the configuration data. It is guaranteed to always get there. So it's your TCP on the UDP bus, for want of a better term. But it always is sent to endpoint zero. All right. Interrupts are ways of setting, you can change the different sizes of them. You can send small amounts of data, and they're guaranteed delivery. So small amount of data, you're talking keyboards here. This is like the low end of the USB. Those are interrupt driven ones. And then the big ones that you use for moving lots of data are the bulk and the isochronous. That would be for your key fobs. So even we have, I told you, we have these different interface types with the different speeds. Let's skip that one for now. Once you get the different flows in, they'll bundle together into an interface and we'll come up with stuff. So let me skip that part. Okay. So this is the part I wanted to get to. When you connect in, you're going to have all of these different things. So now I've connected it. I've got my power. I've got my address. I've told you here are my endpoints, all that. Each one of those endpoints is going to identify itself out as to where it comes from with these things that in the spec are called B class type, B class subtype, B device protocol. That's your bulk and all that. Each of those things are the fields that we use to identify ourselves. So when we go on and use the face dancer, those are the things we're going to fake to be a different fake device. So I can cause it to instantiate anything I want as long as I can fake those things. They also, they'll tell you what type of device it is. Again, HIDs are things like keyboards and mouses. Then you can go into specific models. You can go into different models to load a driver. Otherwise, they'll just use the generic one. So how do you go about getting on this and attacking? All I've talked about so far is this idea of how the normal transactions are set up and how we see the data. The idea now is we're going to pretend to be another device. And last year, we saw Carson Knowles' presentation on bad USB. What he showed in that presentation was I'm going to take a USB key fob and I'm going to change the software in it so that it works. It still looks like a key fob, but I'm going to have it do other things. Great. But I don't want to have to write the stuff every time. So I go on and I'm going to go through and change what I want on the fly. Bad USB, he wrote it once and he was just able to keep doing the attacks. So the concept of a single device being able to come in and do multiple things was great. He showed it could be done. But I want to be able to do it on the fly because for fuzzing, I want to do it over and over again. And his problem, like I said, he had to write it once. So he locked the firmware into the device. I want to be able to do it on the fly. The key thing to get here, though, is he didn't do anything that was not in the protocol. He just pretended to be another device. So all of this used a normal protocol. He didn't crash anything or do anything weird. He came in through the normal protocol and said, oh, yeah, I'm not only a key fob, I'm also a keyboard. I want you to start typing this. Or I'm also this type of DMX. I want you to start pulling memory out. So if you want to take a look at his presentation, it is posted here. There's a video of it up. So again, when you grab the notes, you can take a look if you're not sure what I'm talking about, what he did. But what I want to do is start attacking the systems via the USB port. So way back, I started with the Beagle 480. I could see the transactions, and I started with a device called a Teensy, a special form of Arduino. What's special about it is the USB chip they used, it could be programmed to identify itself any way you wanted. So it could say, oh, I'm a keyboard, I'm a mouse. We used to play with these things. They were great. But they had the same problem with bad USB. You had to program it on one computer, then carry it over and connect it to another computer. It worked great, and there's some great slides about it. There's some great presentations. Then I saw this presentation at DEF CON where a guy said, oh, I can do that programmatically. And I took a look, and sure enough, somebody had created a dongle that could do this. Travis Goodspeed created this thing called a Face Dancer 21, and you can now buy them. Zipiter sells them online, and actually, I think Hacker Warehouse is selling them down in the vendor area right now. It's just a small USB dongle, and it looks like this, two USB ports that allows me to connect a computer to it, say, I want you to be this device with these endpoints, and then it connects to your host computer and says, hi, I'm this device with these endpoints. And you can do this over and over again because this little dongle can also shut itself down, remove it, appear to remove itself from the computer and reconnect itself without removing any wires. So again, this is the key to making this work. This is why we can do this cheap now. We have the software to do the fuzzing. We have the little dongles we can buy. It's now achievable for anybody to just go in and USB hack. You don't need a $1,200 sniffer or something. You can just use this. Much cheaper. And it took a little while to get the software out, but I went through. I got the software. But this is really a pretty good circuit. It's just a different form of as good FET. The key thing is it has two USB chips on it, one for one side, one for the other, and I use, I connect my computer to it, I say, I want you to do this, and then it goes out the other side and pretends to be the entire device. Very handy. Again, he's got presentations up on it. He first presented it in this YouTube. You can go pull it out. I think it was from CC3. But again, you can take a look at what it is yourself or you can come by tomorrow. I'll be here all day and play with it. I have several ones. We can take a look at how it works then. The other part was it's not just the hardware. We needed something to help it out. He wrote some good basic software that lets you talk to it. You know, there's escapee interface for those of you who want to just create custom packets. But that's still not enough to fuzz. We needed kind of the next level. My hardware set up. I use my computer here to set it up and I just have it connect in. I'm able to put anything I want on the wire. So I went through all that protocol knowledge so we know what to put on the wire. Now we're going to take a look at how to do it. I already said that. So. You can get the software straight out of GitHub. Again, totally open source to do with it. If you buy one, here's how to set it up. And like I said, he gives you a good basic escapee interface but nothing more. So lots of people then took that basic interface and decided to play with it in different ways. We've seen a couple of people create some nice custom software for doing the fuzzing. But what they really did was they wrote their fuzzer and pointed it at these custom libraries. I wanted one that did fuzzing right out of the box. So again, Daniel Mende's presentation about doing this is pretty funny. He did his custom fuzzer, Dizzy. Works beautifully but it requires, it would be fairly technical to get it to work. Programming the face dancers. If you come by, I'll give you the videos, too. I just have some videos of like programming it but I don't have them on this laptop. Again. Just. This is just. This is not the programming info for how you do it in this case. I like this way. You just go pull the latest image off the web. It installs it. Takes about 30 seconds and you're ready to go. So next layer of software. This is a presentation I saw several years ago at DEF CON. It took them a little while to get it up. Andy Davis of the NCC group put out a set of Python libraries called UMAP. This is what makes it easy now for anybody to come and fuzz. If you have Python and PySerial on your box. You're ready to use a face dancer. It's that simple. He's got, his presentations are up. His GitHub account is there if you want to pull this stuff. This is what I've been working off of. It does scanning as well as fuzzing. So when you run it, you just take a look at it. It's a very basic framework for USB fuzzing. The only trick is, for me, it's Python 3. All the good FET stuff is Python 2. And it also requires Python 3 serial. But as long as you have that installed. You should be ready to go. So this is what it can do out of the box. It can list all the different devices that it can pretend to be. Identify the supported devices on a connected host. So I can tell this, go ahead and run that script, minus I, and it will go and connect to your host and say, I'm this device. I'm this device. And just do it over and over again until it's enumerated all the possible devices that are there. The interesting thing is that each time it does this. It's causing that computer to load the appropriate driver. Now if you're on Windows or Mac and you've seen that driver before and accepted the signed driver, it will just load it without telling you at all. It will just go, boom, unloaded, no problem. If it's a new device that it's never seen before, it will cause a popup. Linux doesn't do that. Linux, if it has the device somewhere in the memory or in its file system, it just loads it. It logs it, but it never causes a popup. So, kind of fun there. So he gives you one here, it will be in the source code tomorrow. You can just walk through the different data classes and see. All it's going to do is just step, show me all the devices. And again, when you grab the other stuff, there's videos, I just don't have them here, but I left the slide in. So the nice thing about device scanning is you don't actually have to have the device. You're just running through the list of numbers. So you'll get to see all the device types regardless of the manufacturer, if the driver is there. So when I gave you before the case of the keyboard, the MX700 Logitech, it will tell you, yes, I have a keyboard driver for the generic, but it will also come back and say, oh, yeah, when I ran through this list, I also noticed he has the specific driver for the Logitech M700 or for the Canon camera or whatever. That gives you an idea of your targeting if you're looking at attacking somebody. Okay. And the idea that in Linux there's no confirmation, in Windows there's no confirmation as long as you've seen the driver before. But it's also kind of fun to do because it causes somebody to have a lot of pop-ups, which annoys the heck out of them if they don't know what's happening. And example pop-up, I'm sure you've all seen these before. So it also has built in this idea of fingerprinting a system. Just like in Nmap where we send packets and we can tell what the operating system on the other end is by how they respond, you can do the same thing with USB. What drivers were built in already, what messages did it handle, this is kind of Nmap for operating systems. Now, it might seem kind of silly to you for, like, a desktop or laptop. You can kind of know, right? But if you have, say, a small embedded router that has a USB port on it, you can then look and see what the operating system is. That will give you ideas of where you are. You can attack it, what different operating systems are available. It can also get down to about the version level, though that's a little sketchy sometimes. But again, it's similar to the way Nmap scans, but handy for identifying embedded devices. And there's the OS detection. And finally, the part that we're all here for, right? The fuzzing part. You can set it to, you can control the device, what the vendor ID is. What the PID is. All of these are for the setup part of it. Once you do this, it will just go through all the valid message types you told it to do and look and fuzz each one of the fields individually. So you end up sitting there, you know, in the page. It will walk through all the fields that are there automatically. You don't have to memorize them. Although if there is a field you're interested in, then you're able to pick it specifically. So that's why I picked this particular system to talk about, just because it really lowers the bar. It makes it pretty easy for anybody to get on this and do it. You can also do entire classes. So I can say just scan, just attack the HID devices, just fuzz the HID devices, and leave the cameras out of it. And the command lines for that are minus F and minus S. Sorry, my laptop. I would add videos for all this so I could show you. But different laptops, sorry. All the ones that are in there are in this test case. You can edit it yourself. It's pretty well-documented Python for you to work with. And you'll get a very good correspondence between what's in that list and the printouts that you get out on those USB spec sheets or all the sniffing you got. And of course, another fuzz run. Fuzz runs generally take 40 minutes to an hour to do a complete run. So I would highly advise you target as much as possible. All right. All right. All right. All right. That's about as far as I'm going to take it. I'll take you up to the point where you crash, where you get a crash, the kernel panics, we get the dump. Now, how you choose to exploit that is a whole different set of talks and a whole different arc. The idea is to get to a crash. But when you're on the good side, to be honest, if you can fuzz something through USB and get a crash, that's good enough to get you a bug bounty. I know for a personal thing, all you need is the crash to win the bug bounty most of the time. You don't even have to have an exploit. You can just move on to the next one. If you do an exploit, they'll pay you a little bit more. But a crash is almost good enough on a lot of these bug bounty programs that I've been doing. Also keep a close eye when you're doing your fuzzing on the PID of the process that might end up with the data because sometimes they'll restart on you and you might miss it. You might get a crash and not realize it. So, and that's the goal right there. We want blue screens. Because when we get blue screens, we're going to get a crash. That means we've successfully managed to do our fuzzing. We found something wrong. And you'll notice that I am in USBD.SYS. So obviously I hit something good here. Specifically, it's not out yet, but they're going to pay me about three grand for this particular crash. And like I said, I'm not going to go too much into it. Once you have a crash, you'll get the cord up and you'll go into the much more technical. Traditional exploit development. So my advice, of course, is if you choose to do this, obviously just report any crashes you find to the right people. And what I mean by that is do not call Microsoft up with a crash in the Logitech stuff. That goes to Logitech. Microsoft probably gets tons and tons of reports that have nothing to do with code they wrote. Because everybody else, all these third party drivers are the ones that caused the crashes. So. If you want more info, grab the slides. I have some links here. Here are some things that will help you get started with this. Obviously, if you're in the Seattle area, both NET9 and Black Lodge Research, where we meet and we talk about this stuff a bit, like I said, feel free to stop by. So that's it. I hope it was interesting. I'm sorry I didn't get to show you the videos, so I'm a little faster. Tomorrow I'll be here, like I said, with these, with that. Come join me if you want to try fuzzing out for yourself. Take a look at what we can do with these things. And I'll take care. If you have any questions. Sorry. Yeah. I cannot hear a word you're saying. What's happening tomorrow? I will be here first thing when I wake up tomorrow, and I will leave when this place closes. So say 10 or 11 a.m. tomorrow through the day. I'm not doing anything else. I'll be right back there, probably in that back corner table. And like I said, in addition to that, this is the USB sniffer. I have the I2C sniffer, the spy sniffer, the CAN bus sniffer for all you cars. I have a million dongles, whatever you want to talk about. I'll talk pretty much any protocol. But I'm primarily talking about USB today, and we're going to do the USB stuff. I have a system you can just straight SSH into. You don't have to install any software. If you want to, you need Python serial, Py2, Py serial, and Py3, Py serial, and you can pull the software off GitHub. Any other questions? Cool. So I hope that's a start. You're welcome to the slides. I know I zipped through them. Lots of links in there for you to follow, and if you want, you can have the videos, too. They're just MP4s. And you can see fuzzing runs and things like that. I show you things like here's the de-message and what happens when I'm fuzzing, and you just see it loading driver after driver after driver. But like I said, a good fuzzing run will take you about 40 minutes, so the videos are sped up. Anything else? Yeah. Bring me a USB drive. All right. All right. Cool. Any other questions? Cool. Thanks a lot. Yeah. There's a form of this presentation on the NEG 9 website if you want it. If not, I'll give you this presentation. It's almost the same. So. Anything else? Cool. Hey, thanks for stopping by. I hope that was interesting. And like I said, I'll see you next time. If you got any questions, come see me. I got nothing better to do. Bye.