00:00:00.868-->00:00:06.573 >> Hey everybody, welcome to DefCon! [applause] [whoop] [whistles] Alright, we got LoRa 00:00:06.573-->00:00:12.946 Smart Water Security Analysis. This is your presenter Jun Li, give hm a, give him a warm 00:00:12.946-->00:00:17.951 welcome! [applause] >> Thanks. Thank you everyone, uh, first, uh, I would like to, uh, I would 00:00:20.687-->00:00:25.692 like to clarify that this work is not only done by myself, it was done, mainly done by my, my, 00:00:29.363-->00:00:36.003 my team, my team members. And one of the members, uh, because the US consulate rejected, uhm, 00:00:36.003-->00:00:41.008 his visa so, he not, he cannot be here. So, yea, uh, every year we got speakers rejected, uh,of 00:00:44.912-->00:00:51.151 the visa, I think, uh, this gentlemen might be, uh, a big national security threat for 00:00:51.151-->00:00:56.223 the, the United consulate. [laughter] Okay, I'm going to record a short video for him 00:00:56.223-->00:01:01.161 just to get him, uhm, what it feels to present in front of such a huge bunch of, uh, 00:01:03.964-->00:01:08.969 hackers. So, everybody. [cheer] Oh, just, sorry, sorry, sorry. [clapping] [laughter] I, okay. 00:01:14.174-->00:01:19.179 [applause] Okay, let's shoutout to Zeng Yingtao, his name is Tao, okay. [cheering] 00:01:24.418-->00:01:27.788 [whistling] [applause] Okay, thank you. [chuckle] Yea, yea, every, uh, got many friends 00:01:27.788-->00:01:33.327 rejected. Uh, so, let me quickly introduce my company and our team. Uh, my, my team is called 00:01:33.327-->00:01:39.199 Unicorn Team we are doing wireless security, hardware security, and so on. And, uh, we 00:01:39.199-->00:01:45.138 are from, uh, the largest security company called 360 Security Technology, in China. 00:01:45.138-->00:01:51.812 [sniff] And, uh, today I am going to, uh, present how the, the, the process we took to 00:01:51.812-->00:01:56.817 analyse this, this, uh, so-called smart, "smart water meter". So, this how it looks 00:01:58.885-->00:02:03.824 like in real life. So, uh, on the net. You can see there, it's like, just look like the normal 00:02:06.827-->00:02:11.832 water meter but there is a dial - the red circle. So, that's just like a magnet, so, when, 00:02:13.934-->00:02:19.706 when the water meter runs the magnet will rotate and the there will be a, uh, a magnet sensor, 00:02:19.706-->00:02:24.711 uh, ano-, under the cover on the next slides, I will show you. And on the right, is a, uh, a 00:02:28.615-->00:02:34.988 solar panel, solar panel powered, uh, gateway way which, uhu, just like relays, a, uh. 00:02:34.988-->00:02:41.795 Water meter data, uh, to the server of the uh, the GPRS. But communication between this water 00:02:41.795-->00:02:47.901 meter and the gateway is using, uh, LoRa which is, kind of prior-, Proprietary in, uh, 00:02:47.901-->00:02:52.906 protocol. And this is the, uh, the camera of that water meter we use to exploit there is the 00:02:55.876-->00:03:00.814 circuit board and there is, uhm, an antenna and also there, this is gateway which you can see 00:03:03.283-->00:03:08.288 there is, a, a, uhm. There's a, uh, a GPRS module and then LoRa transmitting module. So, this is 00:03:11.658-->00:03:16.663 uh, uh, actual the parameters of, and the models of the chips. So, you can see there is an, an 00:03:18.832-->00:03:23.837 NCU which is used to configure the, uh, LoRa chip everytime it pops up because, uh, this might 00:03:28.075-->00:03:33.747 be, uhm. So, we will later introduce how we can, uh, attack the communication between the 00:03:33.747-->00:03:39.019 MCU and the LoRa module and we have that antenna parameter and then the battery. So, this, uh, 00:03:39.019-->00:03:43.990 the way, why they are going o use this LoRa, uh, communication? Is because it's 00:03:43.990-->00:03:50.263 low-power, so, this uh, little battery can power it up to 10 years. So, that's why they are 00:03:50.263-->00:03:55.268 using this. And there is a hard, uhm, centre to like, to detect the rotation of the magnet as I 00:03:59.272-->00:04:04.211 have here. So, I dunno if you can see it. It's a pointer or something? No. So, uh, there's a 00:04:08.815-->00:04:13.820 magnet sensor called TMR 3-0-1 that can detect, uh, water meters, uh, when it's running. 00:04:16.790-->00:04:21.795 And, and, there, there is a MCU to configure, uh, MCU is here to configure this LoRa module, uh, 00:04:27.634-->00:04:32.639 chip. And this is a, a gateway disassembly, so there is a, uh, a GPRS module here, uh, the 00:04:35.175-->00:04:41.681 white, the white rectangle and there is a LoRa module. So, it's just like very typical 00:04:41.681-->00:04:46.686 architecture for IoT device. And there's, there is a, a EEPROM for to store the data of the, 00:04:51.258-->00:04:56.263 maybe to when it's, the GPRS to, to maybe gather the water meter data. And, uh. [cough] Actually 00:05:00.167-->00:05:05.172 the, the gateway used, used, and implemented and using are different, uh, chip but they are 00:05:08.208-->00:05:14.614 using the same chip as the, as the water meter. So, uh they have to use, because this is 00:05:14.614-->00:05:19.619 cheaper than to use another, like chip dedicated to, for the, for the gateway. Now, let's talk 00:05:24.925-->00:05:29.930 about how we can like infect the, uh, the water meter data. So, you can, as we said, it's 00:05:32.199-->00:05:38.471 just used detecting the rotation of the magnets. So, we can use a strong magnet to put it near 00:05:38.471-->00:05:43.476 the, the centre TMR 3-0-1 in the centre to just to interfere the, the signal. So you can see when 00:05:47.247-->00:05:52.252 the magnet, uh, rotate then the rotate, uh, produced on the, uh, the water meter in the centre 00:05:54.788-->00:05:59.793 will, will change. So, uh, we can use a, you can see a if the. You can see if the-. There's no, 00:06:07.000-->00:06:12.005 no pointer? Okay, o you can see this when the magnet is in this angle there is, a, a 400 00:06:14.808-->00:06:21.047 milliwatt voltage and when the angle change the, the the water change accordingly. So, uh, this 00:06:21.047-->00:06:27.153 how they can detect, uh, water meter when it's running. So, we use a strong magnet to interfere 00:06:27.153-->00:06:32.158 with this, uh, magnetic, magnetic sphere so. Becuase the, the cover is a plastic so it's, 00:06:34.227-->00:06:40.467 it's still working so you can, hm, spoof the sensor data to see that we're, we're not using any, 00:06:40.467-->00:06:45.472 uh, water. But this can be, uh, caught if they come, come to your house she, actually takes 00:06:48.975-->00:06:53.980 the,uh, a look at the, uh, the, the, the water meter. So, that's one way to, to spoof the sensor 00:07:01.087-->00:07:06.092 data. And another way is just to, just to dis-, disassemble it and use like the water 00:07:08.395-->00:07:13.400 deregulator to, uh, spoof the water usage. It's the same, the same effect. [mouse-click noise] 00:07:20.440-->00:07:25.445 So, the LoRa frequency is different, uh, in each country, so, this is, uh, for for example 00:07:28.381-->00:07:33.386 in the US is 915 uh, uhm, megahertz. So, indeed other countries are different, so when 00:07:36.589-->00:07:41.594 you're trying to like, to research on this kind of met-, LoRa based device you need to 00:07:45.165-->00:07:50.170 treat, maybe change your, your HDR device in order to detect that frequency in order to catch 00:07:52.305-->00:07:57.610 the signal. So, this is a. Format of the packet, so you'll have this parambole that will 00:07:57.610-->00:08:03.583 notify the receiver that the packet's coming. And then you have this, uh up chirp down 00:08:03.583-->00:08:08.588 chirp that will encoding data, so, there, there, there's, actually very pretty complex 00:08:10.757-->00:08:16.696 enough parameters where you need to configure, so, uh, and when we do, uh, wireless research, 00:08:16.696-->00:08:21.968 security research, we often use like HDR. So, we have to configure the parameters for, 00:08:21.968-->00:08:28.842 for, for the receiver or for the decoder. So, there are many, many sets of, sets of 00:08:28.842-->00:08:35.815 configuration so, uh, actually, uh, researchers from the US company [indiscernible] hey are 00:08:35.815-->00:08:40.820 doing, uh, wireless. So, they did something to like, uh, uhm, to decode the LoRa traffic but 00:08:44.591-->00:08:49.062 they're, we tried them, their, their code but it's not working. I guess it's, uh, because the 00:08:49.062-->00:08:54.067 configuration of the parameters are different. So, we have to write our own, uh. Decoding code 00:08:56.102-->00:09:01.041 for this, for this, uh, traffic. So, actually we, uh, one of our team member wrote, uh, the, the 00:09:04.077-->00:09:10.917 code to, uh, use, use in Mac lab to decode the traffic and we upload the, uh, this module to, 00:09:10.917-->00:09:16.823 the our GitHub, so if you are interested in doing some more LoRa research in the future you 00:09:16.823-->00:09:21.828 can go look at the code. That's, this, it's turned out very easy to use, so, uh, we. We reach to 00:09:25.398-->00:09:30.403 another method. So, actually, uh, because I said as there is a Mac MCU used to configure the, 00:09:33.273-->00:09:38.278 uh, LoRa module everytime is put, it's powered down, so, what it does, uh, it's using SPI 00:09:41.214-->00:09:46.219 communication to configure the, the LoRa module. The, the cause parameters which frequency they 00:09:48.922-->00:09:55.261 are and the, uh, the different, uh, encryption factors, something like that. So, we use 00:09:55.261-->00:10:00.266 the, the, this Nortek analyser to uh, capture the traffic and the serial, uh, communication, 00:10:04.103-->00:10:09.108 uh, interface and we can, uh, we can figure out how this, uh, uh, uh, LoRa front and LoRa 00:10:12.145-->00:10:18.718 transceiver are configured. So, and then we just go and buy another, uh, LoRa module and use 00:10:18.718-->00:10:23.623 the same configuration in order to receive the, uh, in order to decode the traffic. So, it's, 00:10:23.623-->00:10:28.628 it's pretty smart this kind of thing. So, you have, once you've go all the traffic, uh, on the 00:10:33.900-->00:10:39.506 serial com-, communication you have to figure out what those traffic means. So, we got this, 00:10:39.506-->00:10:45.812 uh, we figure out it by looking at the documentation where this is what kind of instruction we 00:10:45.812-->00:10:51.818 trust. So, for example. There are this, when we receive this traffic it means that we send 00:10:51.818-->00:10:56.823 the frequency to the. Uh, 490, uh, 492 point and the 25 megahertz. That's the frequency 00:11:01.261-->00:11:07.100 we mentioned in the previous slides where we see that there's different country are using 00:11:07.100-->00:11:12.105 different frequency so you can see this is, uh, the Chinese frequency. Okay, we now, now we 00:11:16.643-->00:11:22.782 got the configuration, so we use another module to configure it the same way. And we can receive 00:11:22.782-->00:11:27.787 the traffic. Mh, okay, so now we got the traffic, we have to reverse engineer the 00:11:30.156-->00:11:36.729 communication protocol and see, to see what, how they can transmit the data. Uhm, yea, 00:11:36.729-->00:11:42.135 surprisingly we find it, that not encoded it's just sent in plain text perhaps it thinks 00:11:42.135-->00:11:47.140 that LoRa, uh, communication it's by itself its very hard to decode. So, this, they are using 00:11:49.375-->00:11:54.380 kind of, like, mh, their quite ordinary uh, protocol. So, there is a unique ID of each, uh, 00:11:59.719-->00:12:04.657 water meter. And, uh, actually, we can spoof all the traffic. And, uh, they are, are 00:12:08.127-->00:12:13.132 transmitting the, the water usage data and the, also the temperature. So, so, let's, uh, 00:12:16.903-->00:12:21.908 see if, uh, the privacy, privacy risks. For example, if I say that, uh there is no water 00:12:26.713-->00:12:33.019 usage, because the, the water usage data is sent in, is transmitted in plain text so we 00:12:33.019-->00:12:38.658 can actually save the data to say that if somebody's at home and using their, uh, water meter 00:12:38.658-->00:12:43.663 and the, or, and so we can actually profile the habits of this, uh, uh user. Uh, so to say 00:12:47.000-->00:12:52.305 if, uh, his working routine - when he comes home and when he leave for work, something like 00:12:52.305-->00:12:57.310 that. And, uh, we can also, like. Uh, like, spoof the data to make somebody like say, say 00:13:01.814-->00:13:06.819 they are using a lot of water and get them overcharged. And, uh... And we can also forward 00:13:11.090-->00:13:16.095 the, uh, forward the, uh, gateway to ensure instructions, for example the, uh, because 00:13:20.700-->00:13:27.674 this is like a [indiscernible] two way communication, so not only the water meter have to, 00:13:27.674-->00:13:32.679 uh, upload water usage data but also there's the server like issue some command to the, to 00:13:36.516-->00:13:41.521 the water meter. So, uh, we, and, and also the LoRa is not only used in, uh, water meter, 00:13:44.857-->00:13:49.862 so, it, they are using it to control gas valves or other like them. Or, you can just think 00:13:52.098-->00:13:57.103 like of similar kind, like GPRS or GP. They can be used anywhere to, to build a connected device. 00:14:00.306-->00:14:05.311 So, we, if we can, uh, get traffic or spoof the traffic, we can cause, uh, other chaotic, 00:14:11.651-->00:14:16.656 uh, consequences. So, this is the, or like how the, the, the communication links works. So, 00:14:20.960-->00:14:25.965 the water meter, uh, actually send the data to the gateway and the LoRa gateway, uh, transm, 00:14:28.935-->00:14:33.940 transmit and send the data to the server using GPRS. And GPRS might notice the traffic is 00:14:36.042-->00:14:41.781 that, that communi-, communication is not safe. Everybody maybe can sleeve or 00:14:41.781-->00:14:46.786 maybe spoof the traffic. So, we can use like fake station to, uh, spoof, to, uh, to attack 00:14:48.988-->00:14:53.993 those. To do man in the middle or to just spoof the, the gateway. And the. So, this is 00:14:58.698-->00:15:03.636 uh, my colleague trying to, uh, like, spo-, uh, sleeve the GPRS traffic so instead of this, uh, 00:15:06.405-->00:15:11.410 base station open using BT, uh, openBTS and the, we managed to get this, uh, gateway to 00:15:16.883-->00:15:22.889 communicate through our fake, our fake base station. And actually this is very common 00:15:22.889-->00:15:27.894 kind of attack. Especially, especially in China. So, people are using maybe like, like, uh. 00:15:30.129-->00:15:35.134 Uh, disk GPRS to unlock shared bugs. So, people are used to trying to spoof the, uh, unlock 00:15:38.805-->00:15:45.077 command to make the bug open itself. Yea, so we are doing that. This is kind of, very 00:15:45.077-->00:15:50.082 common, common techniques. [couching] So, when we get the, uh, when we got the base fake, 00:15:53.219-->00:15:58.124 the fake base station setup and the, the way, the gateway connect to our fake base station 00:15:58.124-->00:16:03.062 we can see what data it, it it's sending to the, uh, to the server. And when, we, we analyse 00:16:07.366-->00:16:12.371 it using Wireshark and to, and to reverse engineer the, the, the protocol used to, between 00:16:15.241-->00:16:20.246 the gateway and the server. So, this is uh, uh how the, the traffic look like. So you can 00:16:22.315-->00:16:27.320 see there the, uh, gateway ID, there's a header. And a cont code and also payload, so, and 00:16:31.224-->00:16:36.229 all kinds of information. Again it's not, it's not encrypted - it's just using a CRC to, to, to 00:16:38.564-->00:16:43.569 check this integrity of the packet. So. So, we can actually, as I've said, we can like 00:16:56.816-->00:17:03.456 explore for the gateway to fake water meter data, uh, water usage data to the server. So, 00:17:03.456-->00:17:08.461 nice, take a look at the overall, uh, communication link. The water meter to the gateway; 00:17:10.463-->00:17:15.468 the gateway to the server; and the. So, we have, uh, reversed engineered the, uh, tool 00:17:18.905-->00:17:23.910 communication link and the using all kind of pri-, tool proprietary communication 00:17:26.512-->00:17:31.517 protocol. So, the line is over LoRa protocol, uh over LoRa; another line is over GPRS. So, 00:17:36.923-->00:17:41.494 let's once again to see, this whole, uh, like, testing environment. We have have this 00:17:41.494-->00:17:46.499 magnet to interfere with the magnet centre. We have this, uh, Arduino module used to do, uh, 00:17:49.335-->00:17:54.340 configure the uh, module, LoRa module we used to sleeve the traffic. Because we have like 00:17:56.809-->00:18:01.747 reverse engineered the con, con, configuration process of the, uh, M-, M-, MCU to the. To the 00:18:06.252-->00:18:11.524 LoRa module. So, we can use Arduino, Arduino to configure our module to sleeve the 00:18:11.524-->00:18:16.529 traffic. And, uh, the next step is to, to, like use openBTS to reverse, to analyse the 00:18:19.565-->00:18:24.570 communication between. The server and the, uh gateway. So, conc, so, in, in conclusion that 00:18:31.944-->00:18:36.949 the, uh, we can see that, uh. So there are, once again, like sleeve privacy data to profile 00:18:39.719-->00:18:44.724 this user. And we can, uh, actually use the data to forge the, the data in each stage. The 00:18:50.796-->00:18:55.801 LoRa stage where the, the, the water usage information communication with the gateway, 00:18:58.371-->00:19:03.309 we can spoof traffic between the gateway and the server. So, actually, we, we, we uh, 00:19:09.215-->00:19:14.220 everytime we, we break something we have to figure out, out a way to actually remediate or just 00:19:17.523-->00:19:22.528 to, to, to remediate it. So, this, uh, is using LoRa bin-, binary, uh, protocol. This 00:19:30.836-->00:19:35.841 protocol is brought out by LoRa alliance and, uh, uh. So, we can use for example to prevent, uh, 00:19:43.616-->00:19:48.621 data from being, uh, spoofed or forged we using message integrity, in like maybe HashMap 00:19:50.723-->00:19:55.728 in like based on some kind of encryption key to check the integrity of the packets. We can 00:19:57.863-->00:20:04.003 also use, uh, like the encryption, uh, I think, that the. Why? Why didn't they use 00:20:04.003-->00:20:10.609 encryption in the first place? Is because this is like quite uh, a low-power application and 00:20:10.609-->00:20:15.614 the encryption may, may consume a, a lot of power. So, that's why they didn't like encrypt the 00:20:18.050-->00:20:24.256 water meter in the first place. Or they just like think, like obscurity, like security, 00:20:24.256-->00:20:29.795 something like that. They think that LoRa is hard to decode, it's not, it's not like the GPRS 00:20:29.795-->00:20:34.800 that you can easily. Like, like to to spoof the traffic. So, so, we can, we proof that we can 00:20:38.104-->00:20:43.109 steal network traffic so they can improve, improve that the sys, security by encrypting 00:20:45.478-->00:20:50.483 this, uh, traffic in each state. So, we, we have this, uh, this is actually the LoRa, uh, uh, 00:21:01.794-->00:21:06.799 standard by LoRa alliance and everybody can look at it. They are, they are like the secure, 00:21:10.069-->00:21:16.876 uh, measures but it seems that they are failing it. So, we, so anybody have any questions? 00:21:16.876-->00:21:21.881 This, this is a reference, uh, the past here reassures they have done a, a great job 00:21:24.049-->00:21:29.054 providing people with the, the code to decode the, the LoRa traffic. And we have this, uh, 00:21:31.957-->00:21:36.962 visual resources. So, anybody having, has any questions? Or no? Okay, you, you. [off-mic 00:21:46.839-->00:21:51.844 question] [applause] Uh, okay, I will, I will try my best to answer your question. Shoot. 00:22:05.858-->00:22:11.163 [off-mic question] How can a company protect their infrastructure? [off-mic 00:22:11.163-->00:22:16.168 question] Uh, they have already deployed infrastructure, how can they protect that? Yea, I don't 00:22:19.572-->00:22:25.144 think they can, they can actually do that because usually, usually with this kind 00:22:25.144-->00:22:30.149 of communication they don't have over air update mechanisms so you have to maybe replace, uh, 00:22:33.886-->00:22:38.891 infrastructure. So you have to think of security at the, in the first place. Or you can just, 00:22:42.194-->00:22:47.199 like, for example the magnets that we, that you can change the plastic cover to, uh, like, 00:22:49.702-->00:22:56.375 metal, metal cover so that will be preventing some of the use of, uh, interfere with magnet 00:22:56.375-->00:23:03.082 sensor using a strong magnet. So, if, if somebody don't want to pay water fee they just put 00:23:03.082-->00:23:08.087 this magnet and the water meter so it's not running, so yea. So anybody, anybody else has 00:23:15.628-->00:23:19.498 question? [audience noise] Okay, thank you! [applause]