00:00:00.000,00:00:05.005 >>So, uh, I'm going to talk about Bluetooth low energy 5 PRNG today for fun and jamming 00:00:08.108,00:00:13.113 and maybe more. So, for those who don't know me, I am Security Evangelist and also senior 00:00:15.916,00:00:21.555 security researcher, digital security, uh, French IT security company specialized, uh, in the, 00:00:21.555,00:00:26.560 uh, IUT and I'm also the main developer BtleJack, or "Beetle Jack", uh, which is a BLE 00:00:29.963,00:00:35.736 Swiss-army knife. So we are going to talk about the BLE 5 and, uh, especially what's new 00:00:35.736,00:00:40.741 in BLE 5 specifications and, uh, we will go through some specific features. And also some, uh, 00:00:43.176,00:00:49.883 some interesting stuff in this, uh, in this protocol. So, first of all I am going to recap what 00:00:49.883,00:00:54.955 BLE is for those who are not familiar with this protocol. So, this protocol has been 00:00:54.955,00:01:01.628 introduced in 20, in 2010 as, uh, "Bluetooth Smart" so this was the first name of this 00:01:01.628,00:01:05.999 protocol and Bluetooth Core Specification version 4 point 0 and it has evolved since then. 00:01:05.999,00:01:11.004 Other version 4 point 1 in 2013, 4 point 2 in 2014, version 5 in 2016 and last, version 5 point 00:01:15.676,00:01:21.515 1, you know, this year. Uh, uh, in the beginning of this year. So, it's, uh, evolving very 00:01:21.515,00:01:26.520 quickly, uh, as a protocol an, uh, it's, uh, it's designed to, to, to be very effective so, 00:01:29.356,00:01:34.361 people behind this protocol produces, uh, produced a lot of different versions. But the, uh, 00:01:36.396,00:01:41.401 industry, uhm, it's difficult for the industry to, to keep up with this, uh, evolution. This 00:01:44.137,00:01:50.143 protocol provides some secret mechanisms such as pairing so you can exchange keys between 2 00:01:50.143,00:01:56.717 devices for, to, to be able to encrypt communications. And this, uh, pairing mechanism can 00:01:56.717,00:02:02.155 be done with a pin code, so this is, uh, something, uh, very easy - you just exchange a 6 digit 00:02:02.155,00:02:08.095 pin code between the 2 devices and derive some keys from. Also, from, uh, from out of bin data 00:02:08.095,00:02:14.334 and also, uh, edit some, Elliptic-curve Diffie–Hellman negotiation. This is, uh, 00:02:14.334,00:02:19.439 something provided by this protocol and it's cool. Some version of this pairing, uh, are 00:02:19.439,00:02:25.278 not very secure, uh, as it was demonstrated before, years before, uh, before but some of 00:02:25.278,00:02:31.018 them are pretty strong such as the elliptic-curves. This protocol also provides secure 00:02:31.018,00:02:36.456 connections - so that means you can secure connection between devices and this is, uh, very 00:02:36.456,00:02:41.528 interesting because this, uh, secure connection, BLE secure connection is a, a pretty strong 00:02:41.528,00:02:47.300 when, when it's correctly implemented uh, in the, uh, in the applications. And this 00:02:47.300,00:02:52.572 secure connection provide encryption and authentication - that means nobody can tap into 00:02:52.572,00:02:58.812 an existing connection of even inject some malicious packets in this, in, uh, you know, in 00:02:58.812,00:03:03.383 specific connections. And, last but not least, there is also what we call the "channel 00:03:03.383,00:03:09.056 selection algorithm". So, to make this clear, clear, uh, this Bluetooth low-energy protocol 00:03:09.056,00:03:14.061 uses channel hopping to insure, to, to, to, to make these connections reliable. Uhm, this 00:03:16.530,00:03:21.101 channel hopping mechanism is very simple - when 2 devices create a connection they are 00:03:21.101,00:03:26.406 going to jump from one channel to another. Uh, in order to avoid packet collisions, so, 00:03:26.406,00:03:31.078 this, uh, the'll have a connection to be, uh, steady, you know? Even if there are a 00:03:31.078,00:03:36.716 lot of devices in the same room. And this channel selection algorithm, is not the security 00:03:36.716,00:03:42.389 mechanism when the, but when it comes to sniffing - when you are trying to sniff, a, uh, BLE 00:03:42.389,00:03:48.028 connection. This can make, this can be an issue because you, from, you didn't need to know 00:03:48.028,00:03:53.033 what this, uh, algorithm is and how to recover from this, uh, hopping sequence that will 00:03:55.268,00:04:00.974 follow an existing connection. So, this makes sniffing complicated. There are also 00:04:00.974,00:04:06.379 well-known attacks, uh, especially on BLE 4, which is the first one, sniffing you can 00:04:06.379,00:04:12.652 easily sniff BLE connections, so this is pretty straightforward. Even secure BLE connection - 00:04:12.652,00:04:18.492 when the pairing is not so secure. You can also jam an existing connection - this is 00:04:18.492,00:04:24.464 what I showed last year at DefCon with Btlejack. So it's possible to disconnect 2 devices 00:04:24.464,00:04:30.637 and once uh, uh, the device is disconnected it advertise again and you can connect to it and 00:04:30.637,00:04:36.176 take control of it. But you can also hijack a connection - that means you can force a 00:04:36.176,00:04:41.181 disconnection from one device to another and then exploit this, uh, connection without the other 00:04:43.750,00:04:48.088 device noticing the disconnection. So it's possible to take complete control of, uh, 00:04:48.088,00:04:55.028 a device this way. So, again, uhm, you can do this with a lot of different, uh, various 00:04:55.028,00:05:01.434 hardware. On the left of the screen there is the Ubertooth which is a well-known device 00:05:01.434,00:05:06.673 used to, to sniff BLE connections. In the middle Bluefruit LE sniffer which is 00:05:06.673,00:05:11.711 the, one of the, one of the first ADM bluetooth low energy sniffer available on the market, 00:05:11.711,00:05:18.151 uh, costs around, uh, 40 bucks. And, uh, on the right of the screen with the, the micro bit 00:05:18.151,00:05:22.923 which is, uh, which is broadcasting company, uh, sponsored, but the developed to, 00:05:22.923,00:05:27.928 deigned to, to teach UK students how to code. Uhm, Betlejack uses this last bomb, this Micro:Bit 00:05:33.934,00:05:38.939 to allow attackers to sniff, jump and hijack the, uh, some connections. Let's go back to 00:05:45.445,00:05:50.450 the new features introducing BLE 5, BLE 5 introduces, uh uh, a better throughput, at 2, 2 00:05:52.519,00:05:58.758 megabits per second, uh, better range up to 800 feet or 240 meters, and an improved 00:05:58.758,00:06:04.497 coexistence. And we going away shortly, uh, uh, for this, first 2 better throughput, better 00:06:04.497,00:06:09.502 range. Basically it add, it adds 2 new files, uh, to the, uh, bluetooth low energy protocol - 00:06:12.172,00:06:17.177 the 2 megabit per seconds, uh, uncoded PHY that that was the speed of, uh, uh, the any BLE 00:06:19.379,00:06:25.418 connection and more data in the same amount of time. And, uh, also, the LE Coded PHY, which, 00:06:25.418,00:06:30.423 uh, improve the range times, uh, 4 times the actual range for BLE 4 but, uh, 125 kilobits per 00:06:33.360,00:06:39.699 second speed. And, uh, 2 times the same range at 500 kilobit per second. So, this, this is 00:06:39.699,00:06:44.704 some kind of trade off you you we do between range and speed. If you have a look at the 00:06:48.408,00:06:54.247 packets sent around this, uh, two new files, uh, that would be the LE Coded Phy which is, a, a 00:06:54.247,00:06:59.719 new PHY introducing BLD 5. And, and there is, there is another PHY - the LE Uncoded PHY which 00:06:59.719,00:07:05.959 is the actual, uh, the BLE 4 PHY. And in these packets, you would find, uh, an access 00:07:05.959,00:07:10.964 address which is a 32-bit value, uhm, identifying a connection between the 2 devices. But the 00:07:13.133,00:07:19.406 problem is that the hardware we are using, such as the micro bit or even the other , uh, blue, 00:07:19.406,00:07:24.411 blue, blueframe LE sniffer. This other, cannot cope with these new PHYs and that's pretty much 00:07:27.080,00:07:32.085 the issue, the issue here. So, the other may be useful but for these new PHYs, it's going to be 00:07:35.155,00:07:40.160 a problem. So, we're going to cover this later. The main point here is that the BLE 5 protocol 00:07:42.896,00:07:49.469 in, introduces a new channel selection algorithm. Of the old one, as mine shown here, this is 00:07:49.469,00:07:54.474 a, a, uhm, very simple, uh, sequence generator based on some modulo. The new channel 00:07:57.410,00:08:03.049 selection algorithm introduces a PRNG-based random generator, PRNG-based channel selection 00:08:03.049,00:08:07.954 algorithm. This is based on, on a random number generator. This is, this is, uh, a problem for 00:08:07.954,00:08:12.959 us because, as Mike Ryan showed in uh, 2013 it was very easy to recover, uh, a very, uh, a key 00:08:17.030,00:08:22.001 value of the first channel selection algorithm which is the, uh, "hopinc" value 00:08:22.001,00:08:27.974 mentioned in this slide. But, with a PRNG, the, the, uh, task is much harder because you, you 00:08:27.974,00:08:32.979 need to break this random number generator to, to be able to sniff, uh, hijack and jam an 00:08:35.648,00:08:41.755 existing connection. Luckily, the devices implementing this channel, this channel selection 00:08:41.755,00:08:46.760 algorithm, uh, advertise the, uh, a very specific bit. And if this bit is set, the ChSel bit 00:08:50.230,00:08:52.232 then this device hop on this new channel selection algorithm. Luckily, the devices 00:08:52.232,00:08:54.234 implementing this channel, this channel selection algorithm, uh, advertise the, uh, a very 00:08:54.234,00:08:56.236 specific bit. And if this bit is set, the ChiSel bit then this device hop on this new channel 00:08:56.236,00:08:58.238 selection algorithm. So, basically, what are the consequences regarding known 00:08:58.238,00:09:03.710 attacks on BLE 5? First of all, there was a completely different new hopinc button used, so 00:09:03.710,00:09:09.149 basically the old version, the first channel selection algorithm generates a 37-channel 00:09:09.149,00:09:11.151 sequence. and this new channel selection algorithm then generates a 65 536 channel 00:09:11.151,00:09:14.587 sequence. And, basically the device will loop over the sequence, so this is, a, uhm, 00:09:14.587,00:09:19.592 more complicated and our first approach we, we got when we are developing th, uh, BLE 4 tools, 00:09:28.701,00:09:33.706 uh, couldn't work here. So, sniffing new connection is still possible because you only need 00:09:36.109,00:09:42.982 some software able to, to follow this new channel security, channel selection algorithm. 00:09:42.982,00:09:47.520 Because, at the beginning of a connection you get everything you need to synchronize with 00:09:47.520,00:09:54.227 this connection and follow packets. But, as an attacker, we won't be able to jam or hijack 00:09:54.227,00:09:59.899 BLE 5 devices, because the connection is always, is already established and we don't have 00:09:59.899,00:10:06.673 these values use, uh, used to compute the, uh, sequence of channels. The, uhm, we need to 00:10:06.673,00:10:12.278 go and synchronize and follow a connection. So, we also need a new hardware that support, 00:10:12.278,00:10:17.283 supports BLE 5 new PHYs but, uh, that's another question. It's, uh, just like some guys at BTC 00:10:19.919,00:10:26.192 decided to introduce this PRNG, uh, in order to mess up with the, the actual tools. Well, 00:10:26.192,00:10:31.197 this is what, what I believed when I uh, started this, this research. So, let's see, let's 00:10:33.566,00:10:38.571 have a look at the random number generator. First of all, it uses a channel identifier, value, uh, 00:10:40.740,00:10:46.446 value as a seed - which is a 16-bit value. Uh, this, uh, random number generator relies 00:10:46.446,00:10:53.119 on basic operations, some add, multiply, XOR, bit permutation and so on. And it also uses 00:10:53.119,00:10:58.124 some, uh, channel remapping but this is the same with BLE 4. This channel identifier value is 00:11:00.627,00:11:06.866 computed from Access Address, so, you, this, this is the 32-bit value identifying your 00:11:06.866,00:11:12.038 link between the 2 devices, so, basically identifying your connection. Uhm, and the, the 00:11:12.038,00:11:17.310 computation is the following - you take the access address 0 to 15 and you XOR this value, the 00:11:17.310,00:11:22.315 XOR this value with 16 to 31 - so you, you get a 16, uh, 16-bit value. And then we are going to 00:11:26.753,00:11:32.759 use, uh, a lot of, uh, computation and, uh, specific routine called MAM for "Multiple 00:11:32.759,00:11:38.731 Add Mod" and basically, this routine performs some computations and takes 2 values 00:11:38.731,00:11:43.736 - A and B - 16-bit values and produces an, a 16-bit output. And this is just 3 times in a 00:11:46.639,00:11:51.644 row, uh, these are some other computations in between to create a random number. Based on 00:11:55.248,00:12:01.955 this random number, then we compute the actual channel for a given counter, a given value of 00:12:01.955,00:12:06.960 the counter used here. So, when this, uh, when this channel selection algorithm generates a 00:12:09.429,00:12:16.369 sequence it goes from, uh, a, a counter from 0 to 4k and then generates every possible channel 00:12:16.369,00:12:21.374 and this, this creates a, uh, a sequence of channels and the devices we go over, loop over 00:12:23.910,00:12:28.915 the sequence. So, when I saw this, uh, I was like, "Wow! What's this stuff? What, what 00:12:31.451,00:12:36.623 the f**k?" And I wasn't alone, I, I found some people on Twitter also complaining about 00:12:36.623,00:12:41.628 this specification and especially this PRNG. Well, there's something to do. Uh, if 00:12:46.099,00:12:51.270 you have a look at this, uh, generator then you may have noticed that the channel 00:12:51.270,00:12:56.209 identifier, which is a 16-bit value, is computed from the Access Address which is 00:12:56.209,00:13:02.482 basically public. So, we need this to sniff the connection, so, this a known value. And, 00:13:02.482,00:13:07.487 also, the next value, uh, is generated from the, next random value, is generated from the 00:13:07.487,00:13:12.492 counter, so not from some internal state that, usually, PRNG used to, to, to create 00:13:15.261,00:13:20.266 another random value. So, since access address is public, then we can go from 32 unknown bits 00:13:23.903,00:13:28.908 to 16 unknown bits - so this, uh, quite easy and this PRNG, uh, uh, is it really a PRNG if 00:13:33.646,00:13:37.950 you really look at the, uh, specification, then we know that the channel identifier is 00:13:37.950,00:13:43.923 constant since it is derived from the access address. And what, uh, this function does, 00:13:43.923,00:13:48.928 it, it generates a fixed sequence of 60, of 65 thousand values indexed by a counter. 00:13:52.098,00:13:56.069 Normally, this counter bears random number counter generators are used to parallel, 00:13:56.069,00:14:01.708 parallelize, uh, sorry in French. This is a very easy excuse but, anyway, uhm. 00:14:01.708,00:14:06.713 [laughter] Yea, for this, uh, this generator fixed sequence of values, uhm this is very 00:14:11.451,00:14:17.857 interesting for us for, for, you know, something type. But that function does, in fact, just 00:14:17.857,00:14:22.862 randomise some channels, and that's it. So what do we need to break it? If we consider the, 00:14:26.132,00:14:31.137 uh, just consider the channel identifier as known, you know, this is derived from the access 00:14:31.137,00:14:37.176 address. We are left with a 16-bit unknown value which is a counter and if you can figure 00:14:37.176,00:14:42.181 out where we are in the sequence, of, uh, 65536 values, then we would find out what this 00:14:45.651,00:14:50.857 counter value is, and once we get this value, it's done. You can synchronize with a 00:14:50.857,00:14:55.862 connection and then follow a connection and then jam, hijack, and do whatever you want.. So, 00:14:58.431,00:15:03.369 how to guess the counter value? As an attacker we can only monitor, uh, some events, uhm, 00:15:05.571,00:15:10.376 and these events are the following - we can determine when the packet is received on 00:15:10.376,00:15:16.582 this specific channel. And, based on this, you can also determine when, uh, the time 00:15:16.582,00:15:22.288 between 2 packets received on 2 different channels, so, basically, we can deduce 00:15:22.288,00:15:27.293 something from, uh, some measures we can do on this, this specific connection. If all 37 00:15:30.997,00:15:36.602 data channels are used, then the, uh, channel selection algorithm uses a very simple 00:15:36.602,00:15:41.607 equation or simple computation to, to derive the channel for a specific counter. Uh, but if not 00:15:44.010,00:15:49.015 - if this, uh, this channel are not all used, this is more complex. But in fact, this, uhm, 00:15:51.317,00:15:56.589 this doesn't make things more complex, more complicated, uh, uh, in this way. But I will, I 00:15:56.589,00:16:01.794 will focus on the first case. The first case that we are going to use all the 37 data channels 00:16:01.794,00:16:06.799 to make things, to make things simpler. My first approach was to use a sieve, uh, I'm quite 00:16:09.268,00:16:15.908 sure you're, you all know about a stent, a sieve used to find prime numbers, we are basically 00:16:15.908,00:16:22.448 doing the same. Our goal is to eliminate every possible candidate in multiple rounds and 00:16:22.448,00:16:28.855 in the smallest number of rounds to be more precise. The program decides to do this is to be able 00:16:28.855,00:16:33.993 to, uh, to, is to know the hop interval value which is basically the time between two 00:16:33.993,00:16:40.933 hops in the, uh, in the hopping mechanism. So, how it works, we are going to consider control of 00:16:40.933,00:16:46.439 0 - so, just say that, that it's 0, its, uh, hypothetical - that is not a real value we are 00:16:46.439,00:16:52.678 looking for. And we compute, uh, channel C 0 from this PRMG function with this candidate 00:16:52.678,00:16:58.050 counter and, and based on the, uh, channel identifier of course. And we wait for the 00:16:58.050,00:17:04.857 packet, so we get the packet that time, T 0 on channel 0, on channel C 0. And we do the same 00:17:04.857,00:17:10.596 on the next channel, so, we increase the, the counter with control of 1, we compute the 00:17:10.596,00:17:15.601 next channel and then we wait and we get the packet at time T 1. So, we're then been measuring 00:17:18.471,00:17:23.476 the spent in between, so, data T, it was T1 minus T0. And since we know the hop interval, the 00:17:26.379,00:17:31.584 time between two hops then we can deduce the number of hops between these two packets. So, 00:17:31.584,00:17:36.589 by doing this, we can create a pattern, the, uh, would be very useful to, to see the sequence. 00:17:40.092,00:17:46.832 So, basically, just, uh, by going through the sequence and looking for a specific part, 00:17:46.832,00:17:51.837 composed of two channels - channel C 0 at, uh, uh, say index 200 for instance, at 200 00:17:54.807,00:17:59.812 plus "n", so C1. By doing this, you will get, uh, between 200 and 400 candidate values for 00:18:04.050,00:18:09.055 this counter. So, remember we're, we are looking for the, uh, counter used at T 0. And we 00:18:12.224,00:18:18.397 do it, uh, we repeat the operations, we take the first candidate out of the, uh, 00:18:18.397,00:18:23.402 remaining candidates and we complete C 0, C 1 - we get a packet a C 0 and then C1. And 00:18:27.239,00:18:32.979 then we apply oursieve again. We are going to filter these, uh, all this cand, candidates and 00:18:32.979,00:18:37.984 keep only the matching ones and you do this until one candidate is left and this candidate is 00:18:40.619,00:18:45.625 the, your, your, the value of your counter at T 0. So, since, uh, I, I had no BLE 5 devices, 00:18:48.527,00:18:54.700 at this time, I decided to implement, to simulate this, uh, this attack. So, I will show the 00:18:54.700,00:18:59.705 result for his, uh, simulation. So, I wrote my, uh, I wrote everything in Python, Python 3, 00:19:04.343,00:19:11.183 and I created this script to simulate PHY. So, basically, I just thought, uh, a counter 00:19:11.183,00:19:17.957 randomly generated, which is the 13600, and I will go through every candidate, uh, each run 00:19:17.957,00:19:22.962 reducing the number of candidates. sorry, here 21, 11, 6, 3, 2 until we, uh, get a 00:19:26.198,00:19:30.970 single candidate. And this candidate is found in 600 which is in fact the value we're 00:19:30.970,00:19:35.975 looking for, for T 0. So that's good! [applause] [whistling] Yea, I, I love when a plan comes 00:19:45.518,00:19:50.523 together. The problem here is that we need to know what this hop interval value is. Uh, I 00:19:54.126,00:19:59.999 suppose this value was known during my first simulation but in fact I don't know this value. 00:19:59.999,00:20:05.738 So, how to guess this value, well, it's uh, some basic math you have to do. Since we are 00:20:05.738,00:20:10.609 going to measure time differences between packets received on various channels 00:20:10.609,00:20:17.550 then we can, uh, do so, we can compute the GCD, the Greatest Command Divisor of all these 00:20:17.550,00:20:24.056 measures and since this measures of time are normally multiples of the value we are looking for, 00:20:24.056,00:20:30.663 we will get this value. So, again, I simulated this, uh, this computation but it's very 00:20:30.663,00:20:35.935 quick, so I, I have no video for this one but, uh, by doing only 10 measures I rather want to 00:20:35.935,00:20:40.940 recover the hop interval. And I performed a lot of tests, and this test show that, uhm, if 00:20:46.512,00:20:51.517 you're here for only 5 measures, if you counted 5 measures then you get, uh, approximately 00:20:53.919,00:21:00.326 success rate of 95 percent of success. So, this is critical, if you're, if you get 10 00:21:00.326,00:21:05.331 measures, then you are quite sure to get the correct value. But, that's cool, so, basically, 00:21:08.801,00:21:14.840 what I got here is that a way to recover the approximate value and the, another way to get the 00:21:14.840,00:21:19.845 counter value, uh, the value of the control, sorry, uhm, at a specific time. So, let's do it 00:21:21.914,00:21:26.919 and practice! With a real device! Uh, the problem in fact is the version of the protocol 00:21:29.421,00:21:34.426 has been released in 2016 and still there is no compatible devices, uh, else, on the 00:21:37.062,00:21:43.035 market. So, uh, I wasn't about to find something to buy that implemented this, uh, this 00:21:43.035,00:21:48.040 protocol. So, uh, I'm sorry, there is, there is, uh, there is no video for sex toy hack this 00:21:50.276,00:21:55.281 time, or drone hack, uh, but anyway. So, uhm, based on my, uh, first research, uh, I 00:21:57.550,00:22:03.989 decided to try to apply this, uh, these attacks on some, uh, BLE 5 devices, see that they are 00:22:03.989,00:22:08.994 not devices I'm going to make some. I, uh, I ordered, so, on the site, uh, on the internet, 00:22:12.331,00:22:19.004 the 2 data man board from Nordic, uh, which support this new protocol with the correct 00:22:19.004,00:22:25.511 ASDK and the correct stack. And uh, uh, uh, just as I program this, uh, this board with a very 00:22:25.511,00:22:30.516 basic examples, uhm, 1 - making a, an LED blink and providing a BLE 5-compatible device. And 00:22:33.819,00:22:39.391 another, uh, able to connect to the first one. So, basically, two devices that can create a 00:22:39.391,00:22:46.232 connection in between and transfer data. And I also decided to improve my BeetleJack 00:22:46.232,00:22:51.237 tool by, uhm, by implementing some features - new features for BLE 5. So, uh, Beetle, 00:22:53.372,00:22:58.477 BeetleJack can do the job but only for the legacy PHY which is the 1 megabit per second uncoded 00:22:58.477,00:23:03.415 PHY. But, doesn't matter, my diplomat board is compatible with this file, so, it's okay. 00:23:05.885,00:23:10.889 And I modify BeetleJack to compute these hopinterval, while this uh, this tool, was mapping 00:23:13.259,00:23:18.364 channels because usually when you are attacking, uh, an existing BLE connection, you 00:23:18.364,00:23:24.336 need to know what channels aren't used. Now, remember I suppose that all 37 channels are 00:23:24.336,00:23:31.110 used but that is not always the case. So, by doing this, uh, I modified the, the code to, to be 00:23:31.110,00:23:36.115 able to get this, uh, this, hop interval while mapping but I, I, first problem, uhm, this problem 00:23:39.852,00:23:44.857 is that nobody when you are using CSA and algorithm. This is 37-channel sequence and you look 00:23:47.926,00:23:53.866 over this this sequence but there is no doubles, you know? Uh, each channel only appears 00:23:53.866,00:23:59.872 once in this sequence so it's very easy to determine this hopinterval value. And you 00:23:59.872,00:24:04.877 measure the time spent between 2 packets received on the same channel and then you divide it 00:24:04.877,00:24:10.349 by 37 and it gives you the, the value you want. But this is not the case with this random number 00:24:10.349,00:24:15.354 generator,uh, a channel can appear twice or maybe more. Do, during the sequence. So, I had 00:24:18.290,00:24:23.295 to compute automatically the, uh, uh, timeout, to be sure that, uh, uh, a channel is 00:24:25.297,00:24:30.336 correctly used. Anyway, and I tested in this CDC-based technique to cover the, the 00:24:30.336,00:24:35.341 hopinterval and it works pretty well, once, in fact you smash, uh, when, once you, uh, solve, 00:24:37.810,00:24:43.549 solve all the, all the issues bit on timeout. So, this is an example output of what I get, 00:24:43.549,00:24:50.189 what I get, uh, when I, uh, tried this on some recovery system, on this, uh, this 00:24:50.189,00:24:55.194 connection, so... I get a hop interval for 160 which is, uh, pretty much it, so that's good. 00:24:57.463,00:25:02.401 Great success for first time. But, the main part is to be able to recover the counter used, uh, 00:25:04.503,00:25:10.042 at specific time during the connection. So, Implemented this algorithm, the sieve algorithm, 00:25:10.042,00:25:16.248 and I started trying this, uh, this algorithm. So, the first round, uh, went pretty well, I, 00:25:16.248,00:25:22.321 I went from 65-thousand, uh, candidates to about 250 candidates. Which is, which is 00:25:22.321,00:25:27.793 what I'd showed you, uh, a few minutes ago. So, that was pretty cool but the next round's 00:25:27.793,00:25:32.798 completely messed up. Uh, I wasn't able to get any data. So, I was a bit puzzled and it turns 00:25:36.769,00:25:41.774 out my filter routine took a h**l of a time to execute. And, integers, uh, delay and I, I get 00:25:45.711,00:25:52.251 lost in the connection. So, uh, this is a, uh, uhm, simple algorithm problem, so yea, I was 00:25:52.251,00:25:58.457 a bit p*****d at this time. Uh, uh, so, I, I decided to redesign my attack and to solve this 00:25:58.457,00:26:03.829 problem I moved form sieve to a pattern machine algorithm, which is basically what I was also 00:26:03.829,00:26:09.668 using. So, normally, during my sieve attack I, uh, I measure and then I, uhm, filter all the 00:26:09.668,00:26:14.673 candidates. This time I'm going to do all the measures in, uh, during the first part of the 00:26:17.443,00:26:22.448 attack and then filter all the candidates just at the end. And, by doing this, I get, uhm, more 00:26:24.583,00:26:30.856 complex pattern but in fact, uh, I'm quite sure to get the correct value. And, by doing 00:26:30.856,00:26:37.729 this, you end up with 10 data T values, so, some, times difference between packets that 00:26:37.729,00:26:42.568 was sent in various channels. And, based on this, we look for this hopping pattern in our 00:26:42.568,00:26:49.308 sequence and we did use a counter exactly as we, as we did before. Yea, that rocked! I was 00:26:49.308,00:26:54.313 able to guess the counter value, uh, so, we'll show, I will show you an example of this later. 00:26:57.816,00:27:04.223 So, that was pretty cool! So, from this, uh, uhm, I do massive jazz, that's good! You'll get 00:27:04.223,00:27:09.995 the control value, uh, get the control value - now this is easy-peasy everything you need 00:27:09.995,00:27:15.767 to, to do is just to synchronize with the existing connection. Well! Good! So, I develop my, 00:27:15.767,00:27:20.639 uh, uh, the firmware and in order to synchronize with the connection and, uh, yea. There 00:27:20.639,00:27:25.644 was some kind of issue here, uhm, didn't work at all. So, I got the, uh, correct hopinterval 00:27:28.113,00:27:34.920 value, I got the correct, uh, counter but I wasn't able to synchronize. And, uh, I looked 00:27:34.920,00:27:39.925 at my code a bit, once more, you know, just to be sure that I didn't f**k it up. And I 00:27:42.194,00:27:47.466 stumbled upon this part of the code, this is the filtering routine. What this code does is 00:27:47.466,00:27:54.373 just going through all the candidates and filter this, uh, this candidates, so they sent 00:27:54.373,00:27:59.378 the signal version of this and I need to, to go through the 65-thousand, and 5, and 5536 00:28:01.947,00:28:06.952 candidates and it takes a h**l of time, again, and by doing this, I will just, uh, 13 hops 00:28:10.756,00:28:16.461 away from the correct value - at the moment I was trying to synchronize. So, by doing this, 00:28:16.461,00:28:21.833 just adding 13 to the, uhm, counter value, I was able to synchronize to an existing 00:28:21.833,00:28:26.838 connection. And, that's pretty much it for this, this, uh, recovery. I will show you, now, 00:28:29.241,00:28:31.243 uh, a video of, uh, everything working with this, uh, this firmware. Uh, for the video, uh, 00:28:31.243,00:28:36.248 purpose of the video, I just provide the channel map and the hopinterval value. So, as you 00:28:38.984,00:28:43.989 can see, uh, this, uh, this tool is trying to recover the PRNG internal counter, which is the, 00:28:50.896,00:28:55.901 unknown values, 16 bits, it takes some time, uhm, generally less than a minute to, to deduce 00:28:58.570,00:29:04.476 this, this value. So, it's pretty cool because if you are trying to attack a, a real life 00:29:04.476,00:29:09.581 and you have to be next to or near the device to, to attack it. So, if it takes less than a 00:29:09.581,00:29:16.021 minute, it's okay, should be very short. And once the, uh, counter has been recovered, then 00:29:16.021,00:29:22.494 we capture data sent over these devices. So, by doing this we got the correct value for the 00:29:22.494,00:29:27.666 hop interval and then we get the correct value for the counter. So, that's pretty much it, you, 00:29:27.666,00:29:32.671 you get a, a way to sniff... Yup, sorry. You get a way to sniff, uh, data over BLE 5 00:29:36.074,00:29:42.080 connection, but remember, it's only on the, on the 1 megabit per second, uh, uncoded file. 00:29:42.080,00:29:47.919 And you can also try to jam a connection. So, basically, once you, you're synchronised with 00:29:47.919,00:29:54.059 this, uh, this connection, you can, you can inject packets as well. And this is what I do, I 00:29:54.059,00:30:00.632 did last year, uh, for, you know, when I was attacking some devices. And, this can also be 00:30:00.632,00:30:05.637 done, with, uh, my BLE 5 devices while it's, uh, how do you say? This is, yea, uh. [chuckle] 00:30:09.441,00:30:15.380 Something very special! Because, uhm, I got my device on the, on the screen here so I'm gonna, 00:30:15.380,00:30:20.385 going to recover, the PRNG internal counter and you can see some LEDs, uh, normally at the, 00:30:23.822,00:30:28.827 uh, bottom right of the screen. Uh, this LED which, when it's LED 2 that is, uh, uh, lit, then 00:30:31.430,00:30:37.035 it means the connection is still active. I'm going to jam this, uh, this connection and... 00:30:37.035,00:30:42.607 [chuckle] And pay attention to this, this is, this will be very quick, there is, uh, some LED 00:30:42.607,00:30:47.612 blinking, uh, turning as the, the connection has been, uh, lost and disconnected so, here, 00:30:50.849,00:30:55.854 uh, I successfully jammed, an existing connection BLE 5 connection, by using Beetlejack. 00:30:59.524,00:31:04.463 [applause] Uh, yup... back to the slides. So, uhm, since, uh, everything went smooth with 00:31:17.342,00:31:22.347 this, uh, this attack, I decided to release a new version of this tool of Btlejack, version 2, 00:31:24.616,00:31:29.221 including this, all this research, I made on this, uh, this channel selection algorithm 00:31:29.221,00:31:35.927 number 2. So, it's, it's working, but I tested it on a, a very few devices, I only get 2 00:31:35.927,00:31:42.434 of them, so, uh, I dunno what, uh, if this tool work with, with any type of devices BLE 5 00:31:42.434,00:31:48.273 compatible devices. So, uhm, I give you the code, I give you all the tools and, uh, this 00:31:48.273,00:31:54.346 version of the software has not been published on paper, and just not to mess with, uh, the 00:31:54.346,00:31:59.117 actual version because I, I'm not sure since I made a lot of modifications on firmware I'm 00:31:59.117,00:32:05.357 not sure that the, uh, this version may, uh, alter the, you know, the behaviour of, uh, the 00:32:05.357,00:32:11.029 actual BTLE, uh, Btlejack version. So, just to make things, things clear you can, 00:32:11.029,00:32:17.002 uh, clone this repository and then, uh, install, uh, the device by using some python 00:32:17.002,00:32:22.007 automatic installer, uh, Python MSI and that's it. So, yeah, all the code is available, open 00:32:24.242,00:32:29.247 source, that's its URL. So, to, to conclude, not so quickly, but, uh, anyway. Uhm, what this 00:32:33.351,00:32:38.356 talk, uh, demonstrated is that the TABLE 5 CSA number 2, sorry, the second channel selection 00:32:40.759,00:32:45.764 algorithm, PRNG is weak. Uhm, but there is a reason for that. Remember, at first, at the 00:32:48.300,00:32:53.572 beginning of this research I was just thinking, thinking that, uh, this PRNG has been 00:32:53.572,00:32:58.577 introduced in this version of BLE to p**s hackers, uh, trying to attack BLE devices. But, in 00:33:01.513,00:33:06.518 fact, uh, after, after the, uh, uh, uh, I had some other thoughts about this, this, uh, 00:33:08.887,00:33:13.892 this PRNG, uh, well, it's not really a PRNG, uh, as it's used here. And, of course, 16 bits 00:33:17.195,00:33:22.567 out of 32 is easily guessed and the last 16 bit is a counter so this is very easy to, easy to 00:33:22.567,00:33:27.572 recover. But in fact, this PRNG has been designed to improve coexistence, not security, the 00:33:30.041,00:33:34.613 goal of the, uh, the guys who designed this protocol, not this protocol - this channel 00:33:34.613,00:33:41.152 selection algorithm, and this PRNG, uh, in particular was to improve the coexistence of 00:33:41.152,00:33:47.525 devices in this, say, same space. By doing this, yea, it works, you can get a lot of BLE 00:33:47.525,00:33:54.099 5 devices and with this system you can get a lot more devices that we will use to, to have in 00:33:54.099,00:34:00.672 uh, uh, with the BLE 4 version and also the counter-based random number generators are 00:34:00.672,00:34:05.677 easier to implement and consumes, uh, far less uh, power and memory. And so, in a, in the 00:34:08.580,00:34:15.253 IUT world - this is something that makes sense. So, is it a, uh, a vulnerability? We'll, I 00:34:15.253,00:34:20.492 don't think so. I, I don't think it's a vulnerability but in fact, it doesn't stop, uh, 00:34:20.492,00:34:25.497 hackers, uhm, to jam or hijack, uh, existing connections. Uh, future work will include, uh, 00:34:30.068,00:34:35.073 some, uh, a lot of development for Btlejack - as I said, there really are two new PHYs 00:34:38.243,00:34:43.248 introducing this BLE 5 version, BLE 5, uh, protocol, and this, uh, new files are supported by a 00:34:46.318,00:34:51.323 new ordic system and chip, called the uh, nRF52840. And this, uh, this chip is, uh, very 00:34:53.825,00:34:59.497 interesting because, it, uh, implements all the PHYs natively, so we don't have to do 00:34:59.497,00:35:06.371 some, uh, some, uh, SDR stuff or anything. We can just use the features of this, uh, of this 00:35:06.371,00:35:12.477 chip to be able to decode, and alter the data packet over the air. So, this quite interesting, 00:35:12.477,00:35:18.383 but the fact is that, uh, demands a lot of work to probe Beetlejack to this new platform 00:35:18.383,00:35:23.388 because, uh, both of them are made by Nordic but there are some differences in the way 00:35:25.824,00:35:30.829 these chips handles BLE, uh, BLE protocol. But, luckily someone called Marcus Mengs made some 00:35:34.466,00:35:39.471 research recently on Logitech unifying devices and this, this guy, this dude, made a lot of, 00:35:42.574,00:35:47.579 uh, uh, of code compatible with this chip and I talked with him, we exchange a lot of memes, and 00:35:50.115,00:35:56.688 uh, and this guy has a lot of, uh, some piece of code ready to use to implement this, so, uh, I 00:35:56.688,00:36:03.328 think, uh, I think if he is kind enough to share with me some tricks he did on this, on this 00:36:03.328,00:36:10.068 chip, I will be able to port Beetlejack to this new platform and get rid of the micro bit, 00:36:10.068,00:36:15.073 uh, stuff. So, this, is, uh, this is, it. Uh... I think I said, uh, almost everything I 00:36:19.611,00:36:24.616 wanted to say. Uhm, the research materials, the, all the notes scripts I wrote, everything I 00:36:27.852,00:36:33.792 showed you with, uh, Python scripts is also, uh, also available on, uh, uh, GitHub 00:36:33.792,00:36:38.797 repository, which, uh, is the following "BLE 5 dash research", uh, research, on GitHub which, 00:36:38.797,00:36:44.636 uh, you can get everything, uh, I developed and try it. Insult me if your, uh, your code is, 00:36:44.636,00:36:49.641 is, you know, dirty and I'm not that clear. But, in fact you can, uh, simulate, uh, 00:36:51.676,00:36:57.415 everything the way I did and test it against some, uh, I dunno, maybe some new attacks 00:36:57.415,00:37:02.353 you're, uh, looking for. So, thank you very much for attending this talk, and, uh, I 00:37:05.457,00:37:10.462 hope this was, uh, yea, cool. [applause]