[00:00.740 --> 00:01.460] Jeez. [00:04.440 --> 00:09.080] Hi, my name is Zero Chaos. Welcome to the Wireless Village. Do I really need an amplifier? [00:09.080 --> 00:13.980] I am loud enough on my own. But unfortunately, the man behind me is very shy. He's a little [00:13.980 --> 00:18.180] new to the industry. As a matter of fact, he's so new to the world in general that the [00:18.180 --> 00:23.480] first time we met, he thought that I was actually Yosemite Sam. We spent a lot of time talking [00:23.480 --> 00:27.460] online and he said, you know, I thought you'd look different. I imagine kind of a cartoon [00:27.460 --> 00:35.100] man of some kind with a cowboy hat. Fortunately, his weird predilections for cartoon characters [00:35.100 --> 00:39.440] do not spill over into the wireless world, so he actually knows a few things about Bluetooth, [00:39.440 --> 00:45.160] but we're going to have to give him this microphone because he's so shy. He's so shy. It's really [00:45.160 --> 00:48.340] sad. But he's got awesome hair, so here you go, Mike. [00:49.000 --> 00:55.680] Thank you, Zero Chaos. Oh, this is weird. Hey, good morning, everybody. Who here likes [00:55.680 --> 01:00.640] Bluetooth? I like Bluetooth. Bluetooth is awesome. I know a thing or two about Bluetooth. [01:00.640 --> 01:07.420] He wasn't lying. But let's get right into it. Oh, yeah, my name is Mike. I'm a pen tester. [01:07.420 --> 01:13.560] I work for iSEC Partners. Anybody from iSEC here? Hey, iSEC Partners. Yay, part of NCC [01:13.560 --> 01:18.700] group. So before we get started, my standard note, you're going to hear me say Bluetooth [01:18.700 --> 01:24.000] Smart, BLE, maybe Bluetooth Low Energy. They're all interchangeable names for the same thing. [01:24.000 --> 01:39.020] So don't get confused. So this is an NSA playset talk. The NSA leaks... sorry. Game face. Okay. [01:39.020 --> 01:47.380] So, as everybody here knows, last July, there were some minor leaks, and we got a partial [01:47.380 --> 01:54.720] copy of the NSA ant catalog. And that is pretty much a catalog of all their capabilities [01:54.720 --> 02:02.140] for attacking targets. And the best thing from the catalog is, of course, the codenames. [02:02.140 --> 02:10.520] A couple codenames from the actual catalog. Deity Bounce is a Dell BIOS and RAID controller [02:10.520 --> 02:19.720] software implant that allows them to remotely take control. Night Stand is a portable system [02:19.720 --> 02:25.520] that wirelessly installs Microsoft Windows exploits from a distance of up to 8 miles. [02:25.520 --> 02:32.160] A very remarkably specific distance. And so these are some of the tools that the NSA uses [02:32.160 --> 02:38.920] in their SIGINT work to attack targets. Well, the NSA, they're not magical. They're not [02:38.920 --> 02:44.580] privy to any technology that we're not privy to. So we thought it would be a great idea [02:44.580 --> 02:49.100] to reimplement some of their capabilities and maybe introduce a few capabilities of [02:49.100 --> 02:56.540] our own. So here are a couple other playset... other codenames from the NSA playset. These [02:56.540 --> 03:03.920] are created and released by humans, just like you and me. So Twilight Vegetable, that's [03:04.020 --> 03:10.440] a GSM interceptor. I think it's like a Kali image that you just boot up and plug in a [03:10.440 --> 03:18.960] hack RF and boom, you can intercept GSM. And Slot Screamer, which is a tool for accessing [03:18.960 --> 03:24.200] memory on exposed buses. So like Thunderbolt exposed on Mac, you can get into PCI Express, [03:24.200 --> 03:29.380] that sort of thing. So fundamentally, the playset is about... well, fundamentally the [03:29.380 --> 03:36.920] Ant Catalog and the playset are about capabilities. And before we dig into new material, I actually [03:36.920 --> 03:41.260] wanted to talk about the capabilities that we already have in tools that already exist [03:41.260 --> 03:48.160] today. You can plug them in and use them. So here are kind of the tools of the trade [03:48.160 --> 03:52.840] when it comes to Bluetooth and BLE exploitation. You've got Ubertooth, you've got Crackle, [03:52.840 --> 04:00.820] and you've got BlueZ, the standard Linux Bluetooth stack. So Ubertooth 1 is a great device made [04:00.820 --> 04:07.680] by this guy up in the front row who's tweeting instead of paying attention. It is capable [04:07.680 --> 04:13.080] of some pretty cool stuff, like discovering undiscoverable devices. So even if your Bluetooth [04:13.080 --> 04:19.100] is on, even if you're undiscoverable, in a lot of cases, we can still find you. Undiscoverability [04:19.100 --> 04:24.140] is not a security mitigation. It can do some rudimentary BR sniffing. I don't think I'm [04:24.140 --> 04:28.880] telling a lie. And it has very robust BLE sniffing capabilities, which I've spent the [04:28.880 --> 04:32.260] last year and a half talking about. So I'm not going to talk about them today. And actually [04:32.260 --> 04:38.860] right now I'm working on some work in progress of having a complete Bluetooth dongle on the [04:38.860 --> 04:44.260] Ubertooth. So stay tuned for that. You buy an Ubertooth today, you can do at least the [04:44.260 --> 04:50.980] top three right out of the box. That's right, Dominic, right? Rudimentary BR sniffing? Rudimentary. [04:50.980 --> 04:56.720] He says it's fair. So ruling on the field. Crackle is something I talked about a lot [04:56.720 --> 05:04.420] last year. This cracks the BLE key exchange. And once you have the key, it doesn't matter [05:04.420 --> 05:08.600] that they're using really good crypto, because once you've got the key, whatever, if you've [05:08.600 --> 05:13.680] got the best lock in the world on your door, somebody with a key can still open it. And [05:13.680 --> 05:17.660] on top of that, it can also decrypt data if you give it the key. It's not that useful [05:17.660 --> 05:22.560] on its own. It needs to be paired with some kind of a sniffer. It works great with Ubertooth. [05:22.560 --> 05:29.000] If you've got a fancier, more expensive sniffer, it will work with that, too. So again, today, [05:29.000 --> 05:34.760] you go out, you download Crackle, shove some data into it, you can do all this stuff. And [05:34.760 --> 05:39.320] then finally, Blue Z. That's not their actual logo. That's a logo from some club in L.A. [05:39.320 --> 05:47.000] But they don't have a real logo, so I thought this was good. So Blue Z is actually the best [05:47.000 --> 05:52.900] Bluetooth stack in existence, in my opinion. It's better than anything else. And it is [05:52.900 --> 05:59.360] fully functional, basic rate, BLE, and it's able to act as a BLE master and a slave, which [05:59.360 --> 06:05.560] is kind of cool. You think of a laptop as a BLE master, like, oh, you're going to use [06:05.560 --> 06:10.980] the laptop to connect to some peripheral device. But that's not actually the only thing you [06:10.980 --> 06:18.300] can do. You can actually use a regular Linux laptop as a BLE peripheral. You can, say, [06:18.300 --> 06:24.340] pretend to be, like, a smartwatch or a Fitbit or anything. And that's all built into Blue [06:24.340 --> 06:29.120] Z. You have to write a little bit of code, but it's all there. So that's awesome. And [06:29.120 --> 06:33.660] it also comes with some multipurpose utilities for... they're intended to do things like [06:33.660 --> 06:39.620] debugging and, you know, general Bluetooth stuff, but it turns out they're great for [06:39.620 --> 06:44.760] doing recon. And if you want to learn more about that, you should check out my blog or [06:44.760 --> 06:48.540] Josh Wright's got a book coming out this year, which is excellent. I highly recommend it. [06:49.160 --> 06:55.000] So that's it for existing capabilities. Zero effort. You can do all this stuff today, which [06:55.000 --> 07:02.260] is really cool. But moving back on to the Ant Catalog, what kind of Bluetooth capabilities [07:02.560 --> 07:08.360] does the NSA have today? Well, it turns out they don't have any, at least according to [07:08.360 --> 07:13.240] the Ant Catalog that we have, which might lead you to think that even the NSA doesn't [07:13.240 --> 07:21.600] care about Bluetooth. But that's what's called wishful thinking. I'm pretty sure they've [07:21.600 --> 07:27.440] got some pretty nasty Bluetooth capabilities, partially because we probably don't have the [07:27.440 --> 07:33.360] full catalog. We didn't get a complete copy with the leaks. And also the catalog that [07:33.360 --> 07:39.100] we have is really old. It's from like 2008, I want to say. And that's like, you know, [07:39.100 --> 07:44.280] it's like internet years. It's crazy. And one of the main reasons I think that this [07:44.280 --> 07:49.480] is the case is because there's a company called Ellasys, and they make pretty much the Cadillac [07:49.480 --> 07:55.180] of Bluetooth sniffers. It can sniff basic grade, it can sniff EDR, it can sniff basically [07:55.180 --> 08:01.740] anything. It's got built-in capabilities for cracking pins and decrypting audio from headsets. [08:01.740 --> 08:06.860] So the fact that this is available commercially, I'm pretty sure the NSA's got like ten of [08:06.860 --> 08:12.500] these. The only problem for you and me is they cost like $30,000. So, you know, more [08:12.500 --> 08:19.880] like Ellasys, right? See what I did there? So we're in kind of a unique position. One [08:19.880 --> 08:29.800] sec. Everybody look at me while I swallow. So we're in a unique situation where we kind [08:29.800 --> 08:35.100] of have to guess at what the NSA can do based on the capabilities that they have in other [08:35.100 --> 08:40.740] areas and what they're likely to do. So actually, it's kind of a fun exercise. So I'm guessing [08:40.740 --> 08:44.220] they probably have the ability to intercept headsets. Like if you've got a Bluetooth headset [08:44.220 --> 08:48.460] paired with your phone, they can probably listen into your audio that way. And it's [08:48.460 --> 08:53.280] probably easier than trying to listen in on it through a GSM network, because Bluetooth [08:53.280 --> 08:58.740] is pretty simple, even VR Bluetooth. They probably do some surveillance, some movement, [08:58.740 --> 09:04.180] just tracking you based on Bluetooth. I'm going to assume they do some stack exploitation [09:04.180 --> 09:08.300] and remote code execution. And if you're interested in that at all, check out my handset talk [09:08.300 --> 09:15.120] where I did some of that on Android's Bluetooth stack. Remote keystroke surveillance jumps [09:15.120 --> 09:21.500] out at me as something they probably do, because a lot of people use Bluetooth keyboards. You [09:21.500 --> 09:25.740] type a lot of sensitive information in on Bluetooth keyboards. They can probably do [09:25.740 --> 09:31.100] something with that. And as long as they're doing surveillance, it's probably true that [09:31.100 --> 09:38.520] they're doing some injection too. So let's kind of focus on keyboards and mice, because [09:39.560 --> 09:44.120] they're one of the more common Bluetooth peripherals out there. I'm sure a lot of people in this [09:44.120 --> 09:49.480] room use a Bluetooth keyboard or a Bluetooth mouse. So the protocol they use is HID. It's [09:49.480 --> 09:55.580] pretty much the exact same protocol as HID over USB. It's just adapted to work over Bluetooth. [09:55.580 --> 10:00.920] And in fact, the specs for it constantly refer back to the USB HID spec. So it's basically [10:00.920 --> 10:06.640] the same thing. And when you do it over BLE, it's called HID over GAT. So if you see H-O-G-P [10:06.640 --> 10:13.720] or HID over GAT, that's all HID over BLE. So again, keystroke surveillance, if you can [10:13.720 --> 10:18.360] capture the Bluetooth packets that contain these HID reports, you can tell what people [10:18.360 --> 10:24.340] are typing. And furthermore, if you have any Bluetooth injection capabilities, it's pretty [10:24.340 --> 10:31.180] easy to inject HID reports and pretend that you're a keyboard, which is kind of like a [10:31.180 --> 10:35.820] rubber ducky, like a USB rubber ducky, except a blue ducky. [10:39.000 --> 10:46.860] So, the next question that you should be asking is, do BLE keyboards actually exist? And the [10:46.860 --> 10:53.220] answer is, no, not yet. There are some companies producing prototypes that you can get that [10:53.220 --> 10:57.500] work with certain OSs, but there are no commercially available ones that I've been able to find [10:57.500 --> 11:04.560] yet. But these guys are going to exist very soon. Because BLE is cheaper, it's lower power [11:04.560 --> 11:10.040] and it has longer battery life. And the thing is, BLE might totally exist. Like, this is [11:10.180 --> 11:18.180] a commercial BLE mouse that I got off of Amazon and works with any OS that has BLE capabilities [11:18.800 --> 11:24.440] and also comes with a little dongle in case your OS doesn't support it. It speaks BLE [11:24.440 --> 11:29.700] and then turns that into USB HID for the OS. And the pretty amazing thing about this is [11:29.700 --> 11:37.180] that this thing runs off of two AAA batteries for six months. That kind of power consumption [11:37.180 --> 11:42.680] is not possible with classic Bluetooth. And these chips are cheap enough that they give [11:42.680 --> 11:47.720] you a Bluetooth chip inside a dongle that you might not even need to use. It's like [11:47.720 --> 11:55.320] $2. So, from my perspective, BLE keyboards are an inevitability. I mean, the classic [11:55.320 --> 12:00.800] Bluetooth keyboards are going to die out. Everything is going to be BLE. And the thing [12:00.800 --> 12:04.960] about HID is that HID is HID is HID. It doesn't matter if you're a mouse. It doesn't matter [12:04.960 --> 12:10.600] if you're a keyboard. From the OS's perspective, if you speak HID, even if you're just a mouse, [12:10.600 --> 12:15.560] it's likely that you can act like a keyboard. So despite the fact that BLE keyboards don't [12:15.560 --> 12:19.300] yet exist, there's still a lot of possibility in this space. [12:21.100 --> 12:29.660] So, let's talk about targets. If you're trying to attack BLE keyboards and do surveillance [12:29.660 --> 12:34.600] and injection, you have to have an OS that supports HID over GAT. Or you have to deal [12:34.600 --> 12:38.420] with one of these little dongles that comes with it. But this is less interesting. The [12:38.420 --> 12:44.640] OS's that actually have support for this are Android 4.4, BlueDroid. I tested that. You [12:44.640 --> 12:49.920] compare this BLE mouse with an Android tablet, and you get a mouse pointer on the screen. [12:49.920 --> 12:57.460] And it's really weird. I've never seen anything quite like it. iOS 7, only on the iPad. Kind [12:57.460 --> 13:02.540] of an odd limitation. All iOS 7 devices are running pretty much the same OS with pretty [13:02.540 --> 13:09.620] much the same hardware. But only the iPad has keyboard and mouse support. Because, you [13:11.820 --> 13:17.560] know, Mac OS 10.9, native BLE mouse support. You can pair this guy with Mac OS 10.9 and [13:17.560 --> 13:24.480] use it as a mouse. You don't have to use a little dongle. Linux, BlueZ5. So Fedora 20, [13:24.480 --> 13:29.300] Arch Linux, not Ubuntu. These guys all have native BLE over GAT support, or HID over GAT [13:29.300 --> 13:36.000] support. And Windows 8 and Windows Phone 8. Blackberry 10 and Android less than 4.4 don't [13:36.000 --> 13:42.620] have support. So we've got five major OSs that could be used as targets for this type [13:42.620 --> 13:48.860] of attack. And these five major OSs pretty much represent the next couple years of computing, [13:48.860 --> 13:58.960] in my opinion. The one thing about HID is that the HID spec requires encryption. For [13:58.960 --> 14:02.520] obvious reasons. You don't want your keystrokes sent over in plain text, and you need authentication [14:02.940 --> 14:08.040] as well. And the link layer in BLE provides authenticated encryption. Not just encryption, [14:08.040 --> 14:14.920] but actual authentication. And I wanted to take a moment to talk about pairing versus [14:14.920 --> 14:20.080] encryption, because this is a really common confusion point. Pairing and encryption are [14:20.080 --> 14:26.420] not the same thing. Not in classic Bluetooth, and certainly not in BLE. You can have a link [14:26.420 --> 14:31.680] layer connection between two BLE devices, no encryption whatsoever, no authentication. [14:31.680 --> 14:38.880] They can just talk to each other and speak at. Now, if the device is properly secured, [14:38.880 --> 14:44.400] it will reject most requests unless the encryption is enabled. But it's totally possible to have [14:44.400 --> 14:51.280] an unencrypted connection pretty much between any two devices. Now, if you want to have [14:51.480 --> 14:54.620] a secured connection between two devices, the first thing you have to do is pair the [14:54.620 --> 15:00.440] devices, which is a fancy term for doing a key exchange process. Once you've done that [15:00.440 --> 15:06.020] pairing and you've got a shared key between the two devices, then after two devices establish [15:06.260 --> 15:10.860] a link layer connection, either end of the conversation can say, let's start doing encryption [15:10.860 --> 15:17.260] now. And then at that point, they both provide their secret keys and they do all sorts of [15:17.260 --> 15:20.860] little magic. And then since it's authenticated encryption, they can tell that both ends are [15:20.860 --> 15:25.860] using the same key, both ends are encrypted, and that part of the process is actually pretty [15:25.860 --> 15:30.740] secure. The pairing process, as I've discussed in the past, totally broken, totally crackable. [15:30.740 --> 15:34.920] Check out Crackle if you're interested in that. But the main takeaway is you can have [15:34.920 --> 15:41.540] BLE connections without encryption, you can have encrypted connections after you've paired, [15:41.540 --> 15:48.080] but pairing and encryption are not the same thing. Is that clear? Anybody confused? This [15:48.080 --> 15:53.920] guy shook his head no, gave me a thumbs up. Excellent. I like the feedback. So here's [15:53.920 --> 15:58.480] the life cycle of a typical HID device. Say this mouse, you're talking about this mouse. [15:58.600 --> 16:03.660] So a user pairs the HID device with a host. There's a special button sequence that you [16:03.660 --> 16:08.340] can press with this guy that puts it into pairing mode. Then on your host, you search [16:08.340 --> 16:13.180] for devices, you click the mouse, you pair with it, and at that point a key exchange [16:13.180 --> 16:19.300] occurs and the host and the mouse both have the same shared key. There's an authentication [16:19.300 --> 16:25.400] step that, depending on your device's capabilities, you may or may not be able to do more advanced [16:25.400 --> 16:29.960] authentication. Like if you've got a display and a keypad, you can do a numeric comparison [16:29.960 --> 16:34.140] to make sure nobody's man-in-the-middle view. This mouse is not capable of that. It only [16:34.140 --> 16:38.600] uses the just works pairing method, which pretty much provides no man-in-the-middle [16:38.600 --> 16:45.720] protection even in the best case. Sorry, tangent. Then after that, the host will connect to [16:45.720 --> 16:50.740] the HID device. It'll make a link layer connection, which is unencrypted. Then the host attempts [16:50.740 --> 16:55.680] to start encryption. It says, hey, let's start encryption. The devices set their controllers [16:55.680 --> 17:02.000] to do encryption. They set the key. And once that encrypted, authenticated connection is [17:02.000 --> 17:07.460] established, the HID device sends HID reports. The HID device will not send HID reports unless [17:07.460 --> 17:14.560] the connection is encrypted. There are a couple attack techniques that exploit weaknesses [17:14.560 --> 17:21.880] either in BLE or the host OS or other things. And I'll talk about all three of those in [17:21.880 --> 17:28.840] detail right now. So the first technique, you sniff the pairing and you crack the key. [17:28.840 --> 17:33.280] That's nothing new. That's just using uber teeth to sniff the pairing, using crackle [17:33.280 --> 17:39.380] to crack the key. Once you do that, you can impersonate the mouse and do all sorts of [17:39.380 --> 17:46.040] nasty stuff. Exploiting OS weaknesses is cool. And I'll explain that after I do a little [17:46.040 --> 17:49.500] diagram of the first one. And finally, forcing on pairing, which a lot of people have been [17:49.500 --> 17:51.860] asking me about. It's totally possible. It's pretty cool. [17:52.300 --> 18:00.900] So first, sniffing the pairing. You've got your laptop. You've got a BLE keyboard. I'm [18:00.900 --> 18:06.680] using keyboards and mice kind of interchangeably here. Just go with it. They establish a connection [18:07.320 --> 18:15.180] and they do their pairing and they do a key exchange and everything's golden. Meanwhile, [18:15.180 --> 18:20.160] the NSA is listening in with an uber tooth or an ELISA sniffer and they feed that data [18:20.160 --> 18:25.100] into crackle, which gives them, so at this point the NSA knows the Bluetooth address [18:25.100 --> 18:35.220] of the keyboard. They know the key that's used to secure the connection. Then an evil [18:35.220 --> 18:42.200] keyboard comes in, uses the same Bluetooth address, and the same key, and is able to [18:42.200 --> 18:47.340] talk to the host device. At this point, the host device can't tell that it's not talking [18:47.340 --> 18:54.500] to the original keyboard. And the NSA, or whoever is using this play set tool, can inject [18:54.500 --> 19:00.780] keystrokes into the host OS. This is all something that you can do today with stuff that exists. [19:00.780 --> 19:03.240] You don't have to write any code to do this. [19:04.640 --> 19:10.220] This is the least invasive technique. You cannot distinguish the fake keyboard from [19:10.220 --> 19:14.640] the real keyboard. The downside is that you must observe the pairing, and normally that [19:14.640 --> 19:20.000] only happens once. And furthermore, even if you do observe the pairing, it's pretty likely [19:20.000 --> 19:23.620] that you're going to miss one of the packets that gets transmitted during pairing, and [19:23.620 --> 19:28.410] if you don't have every single packet from pairing, you can't crack it. However, as a [19:28.410 --> 19:33.270] bonus, you get keystroke surveillance for free. All the data is encrypted with that [19:33.270 --> 19:39.550] same key that is exchanged during the pairing. So if you're the NSA and you want to passively [19:39.550 --> 19:41.810] observe people, this is the way to do it. [19:43.110 --> 19:48.090] So the second technique is OS exploitation. You've got your keyboard and your laptop, [19:48.090 --> 19:53.790] they're talking to each other, the NSA did not observe the pairing, everything is hunky-dory. [19:55.690 --> 20:01.690] The regular keyboard goes to sleep because you haven't typed on it in a long time. Meanwhile, [20:01.690 --> 20:06.750] an evil keyboard comes along, purporting to be this keyboard by using the same Bluetooth [20:06.750 --> 20:11.070] address, and it's about as hard to spoof a Bluetooth address as it is to spoof a Mac [20:11.070 --> 20:17.650] address, which is, say, trivial. So this guy claims to be this keyboard, and establishes [20:17.850 --> 20:22.190] a link layer connection with the host OS. The host OS, the first thing it's going to [20:22.190 --> 20:30.450] do is say, hey, let's start encryption. Meanwhile, the keyboard says, sorry, I don't have that [20:30.450 --> 20:36.550] encryption key. A properly behaved host OS at this point should disconnect the connection [20:36.550 --> 20:45.090] and say, fuck off, we're not friends. Certain host OSes say, nah, don't worry about it, [20:45.090 --> 20:52.030] we'll just do unencrypted, unauthenticated communication. And the evil keyboard can inject [20:52.030 --> 21:00.050] keystrokes into such a host OS. So this is more invasive. It's distinguished, the evil [21:00.050 --> 21:04.610] keyboard is distinguishable from a legitimate keyboard in that it doesn't have the key. [21:04.610 --> 21:10.450] So if you're trying to detect this attack, it's actually possible. And it also relies [21:10.450 --> 21:16.810] on OS bugs. So it's not universally applicable, but there are two major OSes on that list [21:16.810 --> 21:22.710] of targets that have this weakness. And unfortunately I can't name names at this point because disclosures [21:22.710 --> 21:29.390] are still in process, but, yeah, it's kind of nasty. And then finally, the last attack [21:29.390 --> 21:36.090] is the unpairing attack. This is the hardest attack to do, because most devices don't support [21:36.630 --> 21:41.730] unpairing, but some devices do. So you've got your keyboard and your host, they've got [21:41.730 --> 21:48.570] a Bluetooth connection going on, evil keyboard comes along, jams the connection, and then [21:48.570 --> 21:53.670] forces the devices to unpair by establishing a link layer connection with the host and [21:53.670 --> 22:01.410] saying, I don't have that key. Well, certain hosts in this situation will not try to do [22:01.410 --> 22:05.670] an unencrypted connection, will not say buzz off, they'll say, you don't have the key? [22:05.670 --> 22:10.990] Let's pair again. The only host I've found that has this problem is the little dongle [22:10.990 --> 22:16.590] that comes with a mouse, but if you're using a little dongle that comes with a mouse, you've [22:16.590 --> 22:22.590] got this problem. This is the most invasive attack. You can totally detect it because [22:22.590 --> 22:28.730] you're pairing with some wrong person. You just paired with the NSA, which is bad times. [22:29.050 --> 22:33.310] It's also the least broadly applicable. Like I said, this is the only device that I've [22:33.310 --> 22:39.810] found that this works with. So the user could notice that this is happening. Do you think [22:39.810 --> 22:49.800] the user is more likely to blame the NSA or their shitty Bluetooth keyboard? So that brings [22:49.800 --> 22:57.020] us to Tiny Alamo, my entry into the NSA play set. And because every NSA play set thing [22:57.020 --> 23:01.780] needs to have a sweet code name, I came up with mine. It actually handles all three scenarios. [23:02.000 --> 23:07.500] So I've got keystroke injection working in all three of the scenarios that I just described, [23:07.500 --> 23:12.320] and I even implemented DuckyScript from the USB rubber ducky, so you can reuse all of [23:12.320 --> 23:19.140] your favorite USB rubber ducky scripts. And now that brings us to the demo. So I have [23:19.280 --> 23:24.740] a victim laptop up here, very nicely provided by Dominic. So I'm going to switch the projector [23:24.740 --> 23:31.140] over to that keyboard, and I'm going to plug in the dongle that came with this Bluetooth [23:31.140 --> 23:46.960] mouse. And yeah, that works. So what's going to happen here is, so this mouse is paired [23:46.960 --> 23:52.360] with the dongle that he's plugging in right now. What I'm going to do from this laptop [23:52.360 --> 23:59.860] here is do the last attack, the forced unpairing attack that I just described. So I'm going [23:59.860 --> 24:05.420] to run some code on this laptop. It's going to impersonate this mouse using its Bluetooth [24:05.420 --> 24:11.420] address, and it's going to say, hey, I'm not just a mouse, I'm actually a keyboard, and [24:11.420 --> 24:23.420] try to inject keystrokes. So let's see if that works. So this is all pretty much turn [24:23.420 --> 24:29.140] key. It takes about 15 seconds right now. And oh, there it's connected, there it's sent [24:29.140 --> 24:52.540] the key. So yeah. So yeah. Yeah, can you just switch it back? Yeah. The code's not [24:52.540 --> 25:08.040] available yet. We're working on it. Thank you, Dominic. Great. This is the best projector [25:08.040 --> 25:14.140] I've ever used. So I can't name any names right now. I really wish I could tell you [25:14.140 --> 25:18.900] which host OSes are broken, but we just got the disclosures out to them. I'm probably [25:19.600 --> 25:23.860] going to get in trouble for demonstrating as much as I have, but I'll take that risk. [25:24.380 --> 25:28.560] So these are the ingredients that made that attack possible. It took one regular Bluetooth [25:28.560 --> 25:35.680] dongle, a Linux kernel capability called HCI user socket, SCAPI, some new code called PyBT, [25:35.860 --> 25:42.120] a little bit of Python glue, and optionally you can use an Ubertooth. And before I go [25:42.120 --> 25:48.100] on, the neat thing about this is you can use, you could actually implement this attack on [25:48.280 --> 25:53.280] a phone. It doesn't require any specialized hardware. All it needs is a regular Bluetooth [25:53.280 --> 26:01.920] dongle. So this is a pretty nasty attack. So HCI and HCI user socket are kind of key [26:01.920 --> 26:07.980] to this. HCI is the language that all Bluetooth dongles speak. It's sort of a high level language [26:07.980 --> 26:13.500] for telling the Bluetooth dongle to do things like set the Bluetooth address, enable advertising, [26:13.500 --> 26:17.100] try to connect to this guy, that sort of thing. It's all high level operations. They all speak [26:17.100 --> 26:22.280] pretty much the same language. And you can actually sniff this using a recent version [26:22.280 --> 26:26.280] of Wireshark. You can fire up Wireshark and see all the HCI commands that your Bluetooth [26:26.280 --> 26:33.680] stack is sending out to your dongle. So you can also send totally illegal stuff this way. [26:33.680 --> 26:38.080] And if you're interested in that, check out my CanSecWest talk where I use this to fuzz [26:38.080 --> 26:44.800] some Android stacks and actually implement an attack using it. HCI user socket is the [26:44.800 --> 26:50.900] magic that makes it easy. Normally the kernel does a lot of HCI for you on Linux and it [26:50.900 --> 26:54.980] kind of gets in the way if you're trying to break the rules. So HCI user socket is a capability [26:54.980 --> 26:59.640] that just tells the kernel, get out of the way. I will handle all the details of talking [26:59.640 --> 27:06.340] HCI. I don't need you. And this is something that a guy named Marcel Holtman, the BlueZ [27:06.340 --> 27:11.980] maintainer, implemented about eight months ago and it's finally made it into the main [27:11.980 --> 27:16.660] line Linux kernel. So if you're running a recent Linux distro, you have this. You can [27:16.660 --> 27:24.960] just with a Linux 3.15, which is available on Ubuntu 14.04 and Fedora 20 and Arch Linux, [27:24.980 --> 27:30.880] you can use HCI user socket to do low-level Bluetooth attacks. I will note that Kali is [27:30.880 --> 27:36.720] still using 3.14, so you're not going to have this capability there. And this is actually [27:36.860 --> 27:40.680] a screenshot of Wireshark sniffing some of the HCI that's going into the controller. [27:40.680 --> 27:48.760] So you can see it's writing some extended inquiry requests and setting BLE scan parameters [27:48.760 --> 27:52.220] and stuff like that. So if you're interested in playing with HCI and doing these low-level [27:52.220 --> 27:57.600] attacks, fire up Wireshark and see if you've got an interface like Bluetooth zero and just [27:57.600 --> 28:02.080] start sniffing it and you'll learn a heck of a lot about it. And if you don't have a [28:02.080 --> 28:06.540] recent enough Wireshark, you can use HCI dump, which comes with BlueZ since like ten years [28:06.540 --> 28:10.520] ago. And that'll produce capture files that Wireshark can open. [28:10.520 --> 28:16.300] The next ingredient is SCAPI. Who here has used SCAPI before? If you didn't raise your [28:16.300 --> 28:22.880] hand, get out of this room. No, but seriously, check it out. SCAPI is really, really, really [28:22.880 --> 28:29.780] good for not just Bluetooth stuff. It's actually really good for any kind of IP packet construction. [28:29.780 --> 28:35.980] It makes it really easy to construct both valid and totally invalid packets. So definitely [28:35.980 --> 28:41.140] check it out. It actually had some Bluetooth capabilities before, but I added a whole ton [28:41.140 --> 28:44.160] of crap to really flesh it out and make all this possible. [28:44.160 --> 28:49.000] So before, it had some rudimentary HCI and L2 cap support. I added tons of commands. [28:49.000 --> 28:55.240] I added support for the security manager protocol, which is how you do BLE pairing, and ADD and [28:55.240 --> 29:00.600] GATT, which are the high-level Bluetooth protocols. And I also added support for the Bluetooth [29:00.600 --> 29:05.940] user socket. So if you want to use HCI user socket, that's how much code it takes. It's [29:05.940 --> 29:14.140] super, super awesome. So I pushed the Bluetooth stuff to those guys in a pull request, and [29:14.160 --> 29:19.720] I think eventually it will make it into their main branch. But if you want to check this [29:19.720 --> 29:24.460] out, just talk to me after the talk. Or be patient. [29:25.000 --> 29:28.840] And then the other ingredient that makes this work is some software that I haven't released [29:28.840 --> 29:33.240] yet called PyBT. So in the process of doing this, I was just kind of hacking on Scappy [29:33.240 --> 29:39.380] and adding HCI commands and stuff, and it turns out I accidentally had a Bluetooth stack. [29:39.380 --> 29:46.620] So PyBT is pretty much a pure Python Bluetooth stack that uses Scappy for constructing packets [29:46.620 --> 29:50.920] and sends them off to HCI user socket. And this guy supports... right now it only supports [29:50.920 --> 29:57.760] BLE, but it has full pairing and key management support. It has a rudimentary GATT server. [29:57.760 --> 30:01.620] And this software is coming soon, once the disclosures get cleared up. It will probably [30:01.620 --> 30:04.700] be on my company's GitHub, but I'll tweet about it when it's available. [30:04.700 --> 30:10.560] But this is... so BlueZ is already a really good, really hackable Bluetooth stack, but [30:11.320 --> 30:16.500] it's too well behaved. It tries to handle all the edge cases in a way that won't cause [30:16.500 --> 30:21.280] your system to crash, instead of making it super hackable. So having this all available [30:21.280 --> 30:26.880] in Python makes that a lot easier. So check this out once this is available. [30:26.880 --> 30:31.640] And some people were asking about unpairing attacks earlier. This is where I've done all [30:31.640 --> 30:39.400] my implementations of BLE unpairing attacks. So you can try doing it in BlueZ. I don't [30:39.400 --> 30:46.240] recommend it. Hack on PyBT instead. And then the last thing is Ubertooth, which [30:46.240 --> 30:52.960] is an optional component that makes it really, really a lot easier. So what Ubertooth can [30:52.960 --> 30:58.640] do is pull addresses out of the air. It's not always necessary. A lot of times you can [30:58.640 --> 31:04.320] get away with just doing a regular BLE scan using HCI tool, which comes with BlueZ, but [31:04.320 --> 31:09.940] that will miss a lot of addresses that are otherwise right for the picking. So I recommend [31:09.940 --> 31:15.360] using an Ubertooth, because nobody uses BLE private addresses correctly. There are some [31:15.360 --> 31:19.920] super awesome privacy features that are a part of BLE, but literally nobody is using [31:19.920 --> 31:25.540] them properly. So you can just pull addresses out of thin air, which makes it super, super [31:25.540 --> 31:33.720] easy to impersonate devices. So kind of wrapping it all up and putting it all together to do [31:33.720 --> 31:39.660] the attack that I just demonstrated, use an Ubertooth to grab the Bluetooth address out [31:39.660 --> 31:44.480] of the air. I didn't do that because I just know this mouse's Bluetooth address. I kind [31:44.480 --> 31:51.580] of cheated. But there are enough moving parts. You launch PyBT, and that will talk to your [31:51.580 --> 31:56.880] legitimate Bluetooth dongle via HCI user socket that builds up all the packets using Scappy, [31:56.880 --> 32:02.520] and it pretty much acts like a regular Bluetooth stack up until this point. It's like, oh, [32:02.520 --> 32:09.180] set my advertising parameters, set my Bluetooth address, all that sort of stuff. And then [32:09.180 --> 32:13.080] it starts to advertise with the address of the mouse. You just send a couple of HCI commands [32:13.080 --> 32:19.220] and it will do that. You wait for the connection from the host, and then when the host says, [32:19.220 --> 32:23.920] hey, let's start doing encryption, you say, you send a message that says, sorry, I don't [32:23.920 --> 32:31.240] have the key. At that point, you start sending key strokes and you profit. That clear? Any [32:31.240 --> 32:36.260] steps that you need more explanation on, please let me know. I had like eight pieces of sushi [32:36.260 --> 32:46.200] for lunch, so I'm not firing on all eight cylinders. Okay. Yeah. That's a really good [32:46.200 --> 32:50.720] question. So the question was, if the other mouse is active, do you have to wait for that [32:50.720 --> 32:57.220] connection to die or kick it off or what? So, yes. The other mouse cannot be connected [32:57.220 --> 33:01.880] when you're trying to do this attack, but there are two ways you can get around that. [33:01.880 --> 33:07.220] The first is that these guys tend to put themselves to sleep after there hasn't been movement [33:07.220 --> 33:12.840] for a little while to save battery life. And the other thing is, I've got some pretty robust [33:12.840 --> 33:16.900] jamming code that I haven't published yet, but it's pretty easy to jam a Bluetooth connection [33:16.900 --> 33:25.980] or BLE connection, rather. That was a really fast presentation. I'm wrapping it up. So [33:25.980 --> 33:31.040] these are some URLs that you should check out. We've got Ubertooth, we've got Crackle, [33:31.040 --> 33:36.460] we've got Scaffy, we've got Blues, and I'm going to give a tweet for PyBT as soon as [33:36.460 --> 33:43.900] that's available, which will probably be not too long from now. I don't know. I was trying [33:43.900 --> 33:48.720] to send out disclosures during the week where everyone is at Black Hat and doesn't have [33:48.720 --> 33:55.160] their word computer, so maybe next time I should start a little bit earlier. I see lots [33:55.160 --> 33:59.140] of cameras, so I'm going to sit on this slide for a little while. I see more Isaac people [33:59.140 --> 34:22.950] show up. Hey Isaac! Question? A full MAC address is 6 bytes. So the question was, does Ubertooth [34:22.950 --> 34:27.630] get you the full MAC address or only the upper portion and the lower portion? That's only [34:27.630 --> 34:32.370] in classic Bluetooth. Since we're talking about BLE, you get all 6 bytes of the Bluetooth [34:34.290 --> 34:45.330] address. Yeah. BLE doesn't have the same UIP and LAP that classic Bluetooth does. Okay. [34:45.810 --> 34:49.510] That's actually pretty much it. I just want to give a lot of people thanks before we clap. [34:49.510 --> 34:54.390] Marcel Holtman is awesome. He's the best Bluetooth maintainer in the world and just totally added [34:54.390 --> 34:59.410] HCI user socket when I asked him to. Obviously need to thank Mike Osman, Dominic Spill, and [34:59.410 --> 35:04.150] the rest of the Ubertooth team for being awesome. I want to thank Marcel Holtman again because [35:04.150 --> 35:09.110] he really, without him this would not have been possible. Of course, thank you Zero Chaos [35:09.110 --> 35:13.910] and the DEF CON Wireless Village. I forgot to add thanks to Isaac Partners because they [35:13.910 --> 35:27.370] actually funded a ton of this stuff. And thank you. And that's it. So this time slot has [35:27.370 --> 35:35.250] about 20 minutes left in it. So if anyone wants to beat box, just come on up. Any questions? [35:36.270 --> 35:37.790] More from the back. [35:43.970 --> 35:50.210] So the question was, does BLE have the same channel hopping problems that classic Bluetooth [35:50.210 --> 35:56.210] had? And no, it's way, way, way easier to sniff. Way simpler channel hopping, way easier [35:56.210 --> 36:02.010] to sniff, like Ubertooth is a turnkey BLE sniffer, more or less. Mike Osman. [36:13.680 --> 36:19.680] So if you crack and spoof the first attack using Ubertooth and Crackle, can you inject [36:19.680 --> 36:23.980] keys while the original device is active? No, you can't. You have to either wait for [36:23.980 --> 36:27.180] it to go to sleep due to inactivity or jam the connection. [36:29.710 --> 36:33.170] More questions. More comments. [36:39.990 --> 36:45.830] Have I tried porting any of the existing Bluesey tools over to Pi BT? [36:45.830 --> 36:54.210] The other Bluetooth hacking tools, like BT pin crack and stuff from the Stone Age? [37:03.390 --> 37:07.390] I haven't tried implementing any other attacks on top of this, but I'm interested in it. [37:07.390 --> 37:10.150] So if you come up with a list of capabilities, shoot them my way. [37:12.470 --> 37:16.270] I wasn't planning on doing it, but I can try to sniff a pairing conversation since I've [37:16.270 --> 37:18.890] got some time to kill here. Unless... [37:19.550 --> 37:23.770] Okay. Show off some Ubertooth and Wireshark. [37:25.050 --> 37:27.730] Sorry? I've got... [37:27.730 --> 37:35.250] So up here I've got three Ubertooth, because in a BLE there are three advertising channels, [37:35.250 --> 37:40.150] so a connection can start on any one of those three. You need at minimum three Ubertooth [37:40.150 --> 37:46.330] to capture a given connection, under the assumption that these guys can capture every single packet. [37:46.330 --> 37:50.690] Which they can't, but this is better. So I'm going to go ahead and plug these guys in. [37:59.210 --> 38:00.810] Is Wireshark coming? [38:02.970 --> 38:08.690] Okay, so I've got Wireshark set up over here, and I've actually got it capturing from pipes [38:08.690 --> 38:12.770] right now, which you can kind of see down here. [38:13.030 --> 38:17.630] Wow, this is really hard. I use a track point most of the time, so this touchpad sucks. [38:18.850 --> 38:24.510] So Wireshark can capture from pipes, so if you've got anything that produces PCAP files, [38:24.510 --> 38:27.770] you can plug it into Wireshark directly, just by having it use pipes. [38:27.790 --> 38:31.530] The next version of Wireshark should actually have an interface that simplifies this a whole bunch. [38:31.530 --> 38:36.550] It's something I worked on with Mike Hershaw, but that still hasn't made it into the main branch yet. [38:36.570 --> 38:40.130] So I'm going to start these guys capturing. [38:44.150 --> 38:45.630] Give me one second. [39:14.490 --> 39:18.990] Okay, so what you're looking at now are just tons of Bluetooth packets that are flying by, [39:19.990 --> 39:23.230] from BLE advertising packets from devices that are in the room. [39:23.910 --> 39:26.750] I could put up some Wall of Sheep stuff if you want. [39:29.940 --> 39:33.320] So I just turned on this mouse, and I'm going to put it into advertising mode. [39:36.430 --> 39:39.830] And you'll see some packets just start screaming by in a second. [39:40.530 --> 39:44.210] They're not screaming, but... oh yeah, they are. You just can't see it. [39:44.210 --> 39:47.190] So I'm going to plug this into Dominic's laptop. [39:48.790 --> 39:52.850] And now, if we're lucky, we'll actually see a connection. [39:55.390 --> 39:57.710] I don't know if we caught it this time. [39:59.330 --> 40:01.410] I don't think it's actually paired yet. [40:05.410 --> 40:08.570] I know it's thrilling watching packets come by in Wireshark. [40:12.210 --> 40:15.410] Okay, so it paired. I don't think we caught the conversation. [40:15.410 --> 40:22.290] So Wireshark 1.12 has BLE support built in. [40:22.290 --> 40:27.030] So you can actually expand this and look at what the actual BLE packet looks like. [40:27.030 --> 40:32.470] And you can see somebody's... oh, this looks like somebody's tracking beacon. [40:32.470 --> 40:34.650] I mean, Fitbit. [40:40.220 --> 40:46.700] Okay, so right now I'm filtering on the pairing protocol for BLE, and that's not working. [40:46.700 --> 40:51.520] So I didn't catch an actual connection. [40:51.620 --> 40:52.940] So I'll try this again. [40:53.840 --> 40:59.700] So, Ubertooth is a pretty robust BLE sniffer, but it's not as good as a dedicated device. [40:59.960 --> 41:03.080] So I'll try that one more time before giving it up. [41:08.320 --> 41:10.420] So these guys should be pairing now. [41:10.420 --> 41:15.000] I got a pairing request, but it's not all the packets. [41:23.060 --> 41:29.660] So if this works, we should see about ten packets come by that are all the pairing packets. [41:29.660 --> 41:34.120] I don't think this is working right now, because we're only seeing the one. [41:36.080 --> 41:40.440] Try one last time. One more try. Third time's the charm, right? [41:40.660 --> 41:45.040] Kill this. Kill this. [41:46.620 --> 41:54.680] But I highly recommend anybody who wants to do some BLE sniffing, you should get not one, but three Ubertooth. [41:56.280 --> 41:59.020] And by the way, Mike, I'll be accepting beers later. [42:04.920 --> 42:08.320] Yeah, if you really want to go overboard, you could get 79 Ubertooth. [42:10.500 --> 42:14.040] I highly encourage everyone to get 79 Ubertooth. [42:16.160 --> 42:20.560] Yeah, and call Dominic. What's your day rate, Dominic? [42:22.920 --> 42:24.860] More than 79 Ubertooth. [42:27.200 --> 42:30.300] 79 Ubertooth, one laptop. That sounds like a shock site. [42:34.720 --> 42:35.600] Okay. [42:36.600 --> 42:40.280] If anybody has like a lucky rabbit's foot or something, throw it at me. [42:44.840 --> 42:46.660] A lucky rabbit's foot? [42:48.320 --> 42:49.640] Lucky beer bottle? [42:50.700 --> 42:53.540] Maybe something a little bit less solid. [42:59.720 --> 43:03.460] Actually, I'd also appreciate it if somebody played Yackety Sax right now. [43:06.220 --> 43:10.080] We got every packet that we needed, except for one. [43:10.080 --> 43:19.520] So a full pairing conversation consists of a pairing request, a pairing response, two pairing confirms, and two pairing randoms. [43:19.520 --> 43:26.520] And unless we get all of those packets, we cannot actually decrypt the key. [43:26.520 --> 43:34.480] But what I can show you is what the actual unencrypted and encrypted data looks like. [43:37.140 --> 43:40.240] .dataheader.length greater than zero. [43:40.400 --> 43:42.700] Oh, that's not what I want to do. [43:54.850 --> 44:01.070] So you can see all the packets that we've captured here. These are the non-zero length packets. [44:01.790 --> 44:07.930] Long story. So this is the encryption request that we get immediately following the pairing conversation. [44:07.930 --> 44:14.830] And then these unknown packets, unknown data, these are the encrypted L2CAP packets. [44:14.830 --> 44:21.270] So if we had that one missing packet, we could crack the key and decrypt all these guys. [44:21.430 --> 44:26.090] And Crackle does that totally automatically. It's pretty nice. [44:26.390 --> 44:36.130] So I gave it three tries. If you guys want to see it again, we should sit down somewhere where I don't have a microphone, and we can try this until it works. [44:36.570 --> 44:39.250] But yeah, I'm done. Thank you very much. [44:39.250 --> 44:39.650] .