This is going to be a fun talk. There are things on the stage. Hopefully we see some demos. There are videos. There's audio. This should be a lot of fun. And remember, this is a first-time speaker. He wants his hydration afterwards, so we will give it to him afterwards per his election. Let's give him a big round of applause. Have a good time. Thanks. So, thank you very much. Everyone can hear me? Yes? No? Okay, great. So, welcome to my talk about having fun with IoT, the reverse engineering and hacking of Xiaomi IoT devices. So, the outline for my talk will be the following. I'll give you a short motivation. Why I did that, I'll give you an introduction into the Xiaomi cloud. Then we go to the overview of the devices. The next step would be that we... We reverse engineer the devices, and at the end, we modify them. Some info is about me. I'm a researcher at Northeastern University in Boston, and I'm working with Professor Givaro Nobir. But I'm also a grad student at the UTU Darmstadt in Germany. And my interest at the moment is like reverse engineering all kinds of interesting devices. For example, IoT, smart locks, and of course, physical locks. That's all the things that you need to know about me here. Okay, so for the motivation, why do we reverse IoT devices? Well... Some people do that to find and exploit bugs to hack other people. But for me, it's like a little bit different. I want to deattach the devices from the vendor. There have been like a very famous example in Europe with the company Yeelight, which disconnected all their European light bulbs because of the GDPR. Now they work again, but I mean, it showed that it's somehow critical. The other thing is we want to enhance functionality. For example, adding new features. Change the localization. The vacuum cleaner, for example, talks Chinese with me. My Chinese is not existing, so English would be better. And some devices have some geo-blocking things. So basically, if you buy a device in Taiwan, you cannot use it in China, for example. Another important thing is also to support our researchers. For example, there's a monitor lab at Northeastern where they have a lot of home appliances. And they're looking into the traffic of these. And in this lab, I washed last week my laundry, so it's a very nice lab. So, yeah. Okay, one important thing. Responsible disclosure. I get always the question, hey, did you disclose the vulnerabilities to the vendor? And the thing is, it's always a little bit complicated. So there's a specific conflict between rootability and device security. When I presented initially my talk in the Chaos Communication Congress about some rooting method for the vacuum cleaner for the generation one, if I would have told the vendor, about that beforehand, then I would have the problem that probably no one would be able to root this device. So see it as more or less as a service for the community instead of getting me rich by the bug bounty program. In this case, for this presentation, I contacted also the Xiaomi security team before that and told them what I want to publish. Okay, so how we started. In May 2017, Dani Wigemer and I were looking at a couple of devices and I bought a vacuum cleaning robot to clean my apartment. And this whole thing continued with the smart home gateways and light bulbs. And over the time, it got even more and more devices which I bought and take a look at. Now you might ask, hey, why I started with vacuum cleaners? And the thing is the following. This is the advertisement of Xiaomi about the vacuum cleaner generation one. And it tells you, hey, this thing has three processors and one of them is a quad core. Now you think like, hey, a quad core in a vacuum cleaner? How cool is that, right? So this was the initial thing how we started doing this research because it was like a very interesting platform. Okay, let's talk about the Xiaomi cloud. Xiaomi claims that they have actually the biggest IoT ecosystem worldwide with over 85 million devices and 800 different models which can be starting from vacuum cleaners, cameras, up to smart toothbrushes, smart toilet seats. You name it, they have everything probably. The interesting thing here is that not all the products which are labeled as Xiaomi are actually from Xiaomi. So we have like a lot of different vendors which are working in this ecosystem. They're using the same communication protocol and this cloud is also supporting different technologies. The interesting thing here is the implementations differ from manufacturer to manufacturer and the software quality is also like very, very different. Okay, so this is like a simplified like overview over the cloud. So what we have here is we have the three... The three main technologies, we have Wi-Fi, Bluetooth LE, and ZigBee. The central component for you as a customer is the smart home app which is installed on your smartphone and this is also used to provision the devices to connect them to the Wi-Fi. As soon as you provision them, they have their own connection to the Wi-Fi, through the Wi-Fi to the cloud, so your device is more or less out of the game there. Okay, let's take a look at this communication which is going from device to the cloud. So, to... To be able to communicate with the cloud, you need a few credentials and these are the following. So, you have a device ID which is unique for every device and you have two kinds of keys. The first key is the cloud key which is used for the device to cloud communication and this is static and this never changed. So if you do firmware updates, if you do provisioning, this is always staying the same. For many devices, it's also written in the one-time programmable memory so even if they would like to change it, it's not possible because it's like burned into the device. The other token, the other key is the token which is used for the app to device communication. For example, if you want to control your device in a local network, then you have to use this token. The thing here is that it's dynamic, so basically every time you provision your device newly, for example to your new Wi-Fi, then this token is like regenerated. Okay, the cloud protocol itself looks like the following, so you have like messages which are JSON formatted, and I have here one example. Okay, the cloud protocol itself looks like the following, so you have like messages which are JSON formatted, and I have here one example. example of that. This is the command for the registration, just to give you an impression of what's going on there. So as soon as the device is connected to the cloud, it tells like, hey, I'm connected to this Wi-Fi ID. I have like this version number and so on and so on. The firmware updates are quite interesting. So there are like three different methods how to, or like three different firmwares which you can update over the cloud. For example, the app updates, which is the usual software on your device. There you have like the URL and the MD5 checksum of the image. Then you have the MCU updates or the Wi-Fi updates. If you have like a Wi-Fi core in your device, then you can also update it. And you have the sub-device updates. For example, if you have a smart home gateway and connect it like to a smoke detector, then you can update the firmware of the smoke detector over ZigBee more or less. The interesting thing here is the MCU and firmware updates are not protected at all. So they don't put an MD5 checksum in there. So you can, if something happens on the device, you can update it. So you can update it. So you can update it. So you have no way of, on the download way of the firmware updates, you have no possibility to check actually integrity of it. Okay. So let's take a look at the other interface, the interface between the app and the cloud. The communication here is authenticated over OAuth and they have a layered encryption. So basically they connect over HTTPS, but inside of the HTTPS, they have a different payload, which is encrypted with AES and with a specific session key, which is generated. The message format here is JSON RPC, and the interesting function here is that the home app actually doesn't have all the functionalities which are required for the devices, but the app is downloading plug-ins after that. So as soon as you add a new device to your app, then it automatically downloads in the background a new plug-in, and the functionality is provided by the plug-ins. How does communication look like? So if you open your smart home app, and then this URL is called by your smartphone, and it demands more or less a list of devices which are belonging to your account. And here in this example, I have one device. This is like you see here, device ID. You see what kind of name it has, what kind of local IP address it has. But the interesting thing here is the following. There's a longitude, latitude field. And now you might ask, hey, why is that, right? So I take a look at this position, and I Google that. And I figure out it's actually the exact position of the device, in this case, like this power plug. And now the question is, how we got that? And the answer is very easy. If you have new devices, they open an open Wi-Fi access point. To be able to find this open Wi-Fi access point, you need to give the app the permission for localization. Because this is like the permission to scan for Wi-Fi access points is bounded to the localization permission in Android. So basically, you give them the localization permission. They find the access point, but they know also their position. And they tell the cloud, like, hey, I saw this device at this position. So at the end of the day, they know exactly where each device is. Here's one example of the communication relations if you have any random device. So the green box is, for example, all the internal components in the vacuum cleaner. And the right side is the cloud. So as I said, you need two credentials, the device ID and the key, to connect to the cloud. And then if the cloud is safe, you can connect to the cloud. So the cloud is sending you any information. It's encrypted. But you have a central component called MioClient, which is encrypting all the stuff and sending it to the internal components. So the MioClient is the core component, more or less, for the cloud communication. This is the most important for us as reverse engineers. This leads us to the next point, how to gain independence from the cloud. And the trick here is that we can proxy this communication. And for that, we developed our own implementation of the Xiaomi cloud, which is called DustCloud. And what it does is, by DNS redirection, you can redirect the traffic to the cloud, and then you can just proxy it through DustCloud. The exact thing about DustCloud is it can act as a proxy or endpoint server for devices, and it's more or less a Xiaomi cloud emulation. So the device can tell that it's not the cloud, for example. It can read the traffic in plain text. You can send commands to the devices. You can also change or suppress commands. For example, a lot of times, you don't want to have, for example, a request to be sent to the cloud. You want to send some firmware updates onto the devices so we can just suppress them. But the requirements for that is that we need to have the device ID, the cloud key, and we need to do DNS redirection that the device is communicating to our cloud. Okay. That's so much for the cloud. Let's move on with the devices. If you use the app for mainland China, or if you use the server for mainland China, which most of the people do because it supports most of the devices, then you have, more or less, 260 different models which are supported. This could be Wi-Fi, ZigBee, Bluetooth, or all together. And this is very dependent on which server you're sitting. So, for example, if you use mainland China, then you have, like, nearly all the devices. In Taiwan, it's, like, way less. And in the U.S., I think it's, like, a total of, like, 25 devices. The thing here is the models are not always compatible. So, like I said, if you buy a device in Taiwan, then most of the time you cannot connect it to mainland China or vice versa. Like I always told you, if you see some device with the label Xiaomi, it doesn't mean that it has to be produced by Xiaomi. So, I just figured out what kind of devices are actually produced by Xiaomi, and you see it's only 11%. So, out of the 260 devices, the biggest part is produced by Lumi. Xiaomi has 11%. And, for example, the company which produces nearly all of the Lightning stuff, Yeelink, is, like, around 10% in total, yeah. Out of these devices, I own, like, 42 myself, like, different models. And I have, like, 99 devices which I bought personally. So, I have more or less a quite good overview of what's going on with the cloud there. Okay. So, because this is a one-on-one track, I want to give you just a quick idea of what's going on with these IoT devices. So, we have different architectures. We have, like, Cortex-A, Cortex-M, which is... So, Cortex-A is more or less the stuff which is... It's in your smartphone, so it's very powerful. Cortex-M is more like an embedded controller, which is, like, not so powerful. And there's two flavors which they use more or less. If you have only Wi-Fi, then they use Mavic chips. If you have Wi-Fi and Bluetooth Elite combined, then they use Mediatek chips. There's also, like, MIPS chips available, and also Extensa, mainly known as ESP8266 or ESP32. So, the focus on this talk is actually only Cortex-A. If you're interested in Cortex-M, I give a talk about... about binary patching in the IoT Village, I think, one hour after this talk. So, you just can follow me to the other room. And I'll also give you a short introduction why I hate ESP8266 also at the IoT Village. Okay. Speaking of operation systems, there are different operation systems that you can find in those IoT devices. There are some for Linux, like on a vacuum cleaner. You have OpenWrt, which is used not only, like, on routers, but also in speakers or, like, in the washing machine. You have some embedded Linux, and you have RTOS, which is some real-time operation system, more or less, which is used in light bulbs, light strips, and so on. Speaking of implementations, they are very different from vendor to vendor. And here's, like, one example. So, I have, for example, the vacuum cleaner here, which has three processors. The firmware updates are encrypted, and they use HTTPS to download them, and all the debug interfaces are closed down. And the manufacturer here is RockRobo. Another vendor, Lumi. They have a smart home. They have a smart home gateway, and they use this malware chip, this Cortex-M chip that I told you, and they don't encrypt their firmwares at all. And the thing here is they don't even have an SSL stack in their firmware. So, even if they want to use SSL, they can't, because the firmware doesn't support it. And the debug interfaces are open here. So, JTAG, everything is there. Another case is Yeelink, where they have some Lightning products, where they use the MediaTek chip. And here, the firmware is also not encrypted, but they use HTTPS. The thing is, they don't check for the certificate, so you can just give it any certificate. And the fun fact here is, actually, they have root CAs in their firmware, but they don't check for that. There's a smart bonus on the smart home gateway. So, it's a Chinese device only. So, you can only, practically, you can only buy it in China. But it has some unknown communication to some server in Salt Lake City, which is kind of funny. Okay. So, one good news about the devices. The vendors are very lazy, and the developers are too lazy. So, the thing, what they do is, they just take the SDK, which is delivered by the chip. They modify some example, which fits more or less for their case. For example, like, oh, it switches to GPIO. So, just, like, let us take this. And as soon as this thing works, we just publish the firmware. For us, it's very good, because the firmwares are more or less all similar. So, the memory layout is quite the same. The functions, which I use for specific things, are the same. And the strings, for example, so log entries are also the same. So, it's very nice for us, because as soon as you know one device, you more or less have an idea of what's going on with other devices. Okay. Speaking of devices, let's get access to them. Some of the people say, like, yeah, I don't want you to open my device with the warranty seal and so on. And it's not always necessary to open the device. So, here is an example of the Xiaomi Wi-Fi router, where you can access the serial ports over the holes in the case. You can see that in the IoT Village. So, I have the router with me. You can just, try it yourself, so you just shine with some kind of light into that, and you see the port, and you just connect directly to the serial port. This is especially important for this device, because after the first power up, they close down the serial port. But if you connect to the serial port before you power it on for the first time, you can reset this flag, which disables the serial port, and then you have serial port forever. So, very important for this device. Okay. Let's start with our first device. And this device is this camera here. Which has also gateway functionality. So, it's a quite special device, which can also stock ZigBee. The internals are the following. They use the Hi3518 processor, which is quite typical stuff that you find on cameras, actually. It's a Cortex-A processor. They have 64 megabytes of RAM, 16 megabytes of flash. They use the MediaTek Wi-Fi chip over USB, which is also interesting. And they have some kind of embedded Linux. In addition to the camera functionality, they have also the ZigBee module. So, they can also speak ZigBee. The kind of devices which you can connect to this thing is motion detectors, temperature sensors, power plugs, smoke detectors. What could possibly go wrong? Or like smart door locks, for example. So, I opened this device a few times, and I found at some point the serial port. Unfortunately, after I break this device, because I unsoldered it quite too often. So, you have the serial port there, which is quite a little bit hidden. So, you see on the left side is next to the USB connector. So, if you put in some bridges there, then you can access the serial port over USB. But not using real USB, but serial. Yeah, right. So, speaking of leaked informations. Apparently, we have no idea how JFFS2 works. It's a special file system which you use most of the time for flash, which is rewritable. And the thing here is usually it tries to avoid writes on the flash. So, what happened here is, apparently, it's somewhere in the development process. They set up a base system, then they created credentials, then deleted the credentials again, copied the whole partition to the next device, and so on. And at some point, it landed in the final firmware. So, they took just the whole partition and put it there. And what you can find there is just by walking through the image of the SPI flash, you find their credentials of their devices. So, this is only one example for that, but they have like three different credentials for three different devices from their development in there. Which doesn't, this would show that it's not a super good quality of software here. Speaking of routing, actually, serial was not necessary. So, they have an open terminal port, and they have a hard-coded password there. This was kind of a thing, I mean, a hard-coded password is not always bad if you don't know it. So, this password is not published yet. And the thing is, apparently, they used the standard example again in this chip. And the password is not encrypted with MD5, but it's encrypted with Descript. And what Descript is doing, actually, it takes your password, cuts it to eight characters, and then encrypts with this, uses this password as a key to encrypt zeros. So, it took me like half a day to actually run it through the GPU to crack it. So, this is the password for this camera. And unfortunately, this is the same credential for all of the cameras. Yeah, which is kind of a problem, I guess. Right. I reported that to Xiaomi, but they didn't, like, really respond. I mean, responded, but they just, yeah, nevermind. Okay, speaking of modifications, first thing that you can do is, like, replace the Chinese sound files when it speaks English. You can replace TileNet through DropBeer. And, of course, you want to change your root password. And sometimes, you even want to replace the Wi-Fi, sorry, the camera software. Okay, let's go to the next device, to the Wi-Fi network speaker, which I have also here, which is more or less a thing of like a sound bar with some integrated functionality like Amazon Echo, but with a different Chinese Echo Alexa thing. If you open this device, you see, again, that it's a Cortex-A chip from Amlogic, which is quite usual for stuff like TVs and so on. It has 128 megabit of RAM, eight gigabit of flash, so you can put your music on it to play it around. It has Wi-Fi and Bluetooth through a Broadcom chip, and it runs OpenWrt. The thing here is they used a quite old version of Samba there, which is not so nice, actually. And this whole thing was released in 2006, sorry, 2016. If you open it, you can use, again, the serial ports, which are sometimes, which are, like, directly accessible, not protected at all. But the thing here is, for the routing, you actually not need to open the device. So there's, like, the classical thing, no input validation. So what happens here is you can just, can you see it? You can just execute any command here as root. So as soon as you have access in the local network to this device, you can just execute anything. Xiaomi told me, like, a few days ago, that this was fixed in April 2018. So it might be fixed, but most of the people who I know don't update, actually, the firmware of this kind of devices to be able to root them. So, yeah. Speaking of firmware updates, it's quite funny, because they query the firmware update information over HTTP. And, yeah, this is how this file is looking like. So I don't know if you can see it, but the thing is, you have here at the top the MD5 checksum of the firmware image, and the package is downloaded again over HTTP. This whole thing is packed in some kind of XML format, and it contains the X2 images. And again, it doesn't have any signatures. So basically, this is good for us, because we can just modify the... do some DNS redirection, and can just push any firmware updates we want on this device. But this is a little bit scary in terms of, you know, software quality. So we actually have, again, an SSL stack and OpenSSL on this device. So we could do SSL if we want to, but we don't want to, apparently. I'm not sure if it's still, like, vulnerable. Maybe they change it again, also, with this latest update, but just to give you an impression what you see out there in IoT. Okay. So let's move to the hardest device, more or less, and the vacuum cleaning robots. So for the Generation 1, Danny Wigema and I published that on the Chaos Communication Congress in 2017, so last December. But now it's also, like, Generation 2 and so on. So to give you an overview of what kind of devices we're talking of, this is Generation 1, what you see here. So it has a LiDAR sensor, this laser thing, to measure the room. It has a lot of other sensors, like, infrared sensors, ultrasonic sensors. A gyroscope is integrated in this device and an accelerometer. So it's basically a smartphone which has some wheels and has some vacuum function. If you tear it down, then it's actually, it's very nice to open the device because you don't have any weird connectors which can be, which can break. So it's, like, all the parts are drop-in parts, and it's very nice to, you know, reverse-engineer that, and the device is well-engineered. And taking a look at the PCB, you see that there's, on the main PCB, there are two processors, one on the left side. This is the quad-core AR16. With that connected is, like, 512 megabytes of RAM and we have 4 gigabyte of flash. The Wi-Fi module is connected over SDIO. And for all the retime tests, for the tires, for example, for the wheels, sorry, for the sensors, we have the SDM32, which is taking care of this one in the orange field, which is taking care of all the retime tests. There's one fun thing here. So the quad-core, the AR16 has a SWD connection to the SDM32, so it can update the flash over, like, more or less a JTAG thing. And on the other side, the SDM32 is taking care of all the energy stuff. So if anything is happening while the firmware update, if anything goes wrong, then this device is a bricked one because the SDM32 doesn't power on the device and the main processor doesn't have any chance to update, to repair the SDM32. So it's like a Texican standoff thing here. Okay. On the back side, no big surprises. At some point after reverse engineering, we figured out where the serial port is. The serial port is actually the only two test points on this huge field of test points which doesn't have a label, which is kind of interesting. All right. Generation 2. This is a device which was released in the end of 2017. So I think in December, November, December 2017. No big surprises. They use still the same combination of chips. They just changed a little bit the layout of the chips. So another question is, hey, how do we root that? And so a possible way to retrieve it first, the firmware is actually the following, just to unsolder the MMC chip. But I guess for most of the people here in this room, and including me, this would actually mean to brick the device because I don't think I'm able to resolder a BGA chip very nicely. So to resolder a BGA chip so that it's working after that. So the weapon of our choice for this case was aluminum foil, actually, to get access to the device. And now you might ask, hey, how does it work, right? And the trick is the following. So if you're taking a look at the pin layout of the chip, we figure out that the pins for the MMC chip are actually on the side of the application processor. So we can technically breach them somehow. And the trick is the following. So if you ever worked with all the CPUs, for example, if you have an Orange Pi, you know that they have a special mode. If they cannot load a valid image from the SD card or from the flash, then they go on this FAL mode, which is like a special mode to refresh the device. So what we did here is we took this aluminum foil and we're going under the BGA chip and short-cutting the MMC data lines. As soon as the device was trying to boot up, the image from the MMC flash, it wasn't possible, so it was falling back in the FAL mode, and then we could access it over USB, upload a small tool which dumps the whole MMC, modify the image, and rewrite the image again to the flash. So this was our initial way how we got access to this device. Looking at the image, it was a quite big surprise because we ran Ubuntu 14.04, mostly untouched, and they patched it also on a regular base, so you see, like, new package versions all the time if you have firmware updates. For all the navigation stuff, we have a software which is called Player, which is an open-source software, and we have, of course, also some proprietary software on the device, and one of them is a custom ADBD version. So as soon as you connect over micro-USB, you see that there's some ADBD server running, but you cannot really connect to that because you need to authenticate yourself against the device, and you can't do that because you don't have the information for that. So the vendor can do that, but you can't. There's one interesting thing here. They use IP tables to block the device against, like, attackers or you, and they block the SSH port, and they block this Player port. But apparently they don't know the trick about IP version 4 and IP version 6, so they don't know that IP tables blocks IP version 4 traffic, that's a good thing, but it doesn't block IP version 6 traffic, so IP version 6 is not blocked at all. As soon as the vacuum cleaner has an IP version 6 address, all ports are open. Not a good thing. Okay. Speaking of data which is available on the device, as soon as you get access to the device, they produce a lot of log files, and syslogs, stats, Wi-Fi credentials are in the log files and maps, and all the data is more or less uploaded to the cloud. So I figured out that it's more or less like 100 gigabytes of writes on the MMC per year, so it creates a lot of log files, and the most important thing for you now is if you do a factory reset, the data is not deleted. So the maps are still there, and the log files including your Wi-Fi credentials are still on the vacuum cleaner. So be careful if you sell IoT devices on eBay. Speaking of maps, this is how the maps looks like, so you have like a bitmap, which is 1024 pixels times 1024 pixels, and we have an accuracy of more or less like five centimeters per pixel. I think in stupid units it's like two inches, I believe. Yeah. Okay. So, let's take a look at MMC, and here, so what you see here is you have like multiple copies of the operation system, so system A and system B and the recovery version, and now for the next step of the firmware update, only like these partitions are out of, for our interest. So let's take a look at the, how the update process is working. So in the introduction I told you that the cloud can send like the update command to the device, and this is how it's happening, so we, it sends an encrypted packet to the, to the vacuum cleaner and says like, hey, please download the firmware update from this URL, and the MD5 checksum is the following. In the next part, what the vacuum cleaner is doing, it will happily do that, and download the firmware package to the data partition, checks in the next step if the MD5 checksum is actually the one which is, which has, which was received by the cloud. If it's, that's the case, it uses some secret key to decrypt the image, and unpacks it to the download partition. In the next step, what it does, and this is actually quite clever, they update the root password, so every device have a specific root password which is like burned in, into the device. And in the next step, the, this updated version is now, now imaged to the passive copy of the operation system. Next step is the, the vacuum cleaner takes some time to rethink and reboot, and reboots the now updated version of the, of the operation system, and in the last step they update like the former active version, and at the end of the day you end with a completely updated version. So this is more or less the standard way, also how other devices do that. So you have like two copies of the operation system, you always update first the passive copy, and then you change, you do updating the active copy. Okay. Taking a look at the firmware updates themselves, like I said, the MD5 is provided by the cloud, so this is the integrity. The images are encrypted to archives, and they have an X4 file system in there, and they are encrypted with AES-256, and they use a tool which is called the, called Zcrypt, which is delivered in all Linux distributions. The interesting thing here is the password is RockRobo, so not very creative for a firmware encryption password, and just like I said, also the same password for all devices, so basically you can create firmware with that. The fun thing here is actually they protect their sound packages way better, so the password for the sound packages is way more complex. So sound packages are just things where you can make your vacuum cleaners be like your transformers or something. So this kind of stuff is better protected than the actual firmware. How you can figure that out? How you find this kind of password? Well, if you risk engineer like the binaries, and you're just taking a look at the strings, then you find something like that. So Zcrypt, and then next to that some other string. First, when I remember when we were looking last year at this kind of binary, we first thought this is the host name, because the host name is also RockRobo. Later, after we figured out the password for the sound files, we figured out, oh, it's actually the password for RockRobo for the firmware. We couldn't believe it at first. I mean, it was like totally weird. Okay, now we have the firmware password, so let's root this thing remotely. So we can rebuild the firmware. We put our authorized key file into this image. We remove the IP tables roots for IP version 4. And then we just send the update command to the device, encrypt with the token, and point to our own HTTP server. So this is how it looks like. So we put our vacuum cleaner, for example, in the unprovisioned state. We ask him for the token, and then we send the update command to it, and it will happily update that. And then for today, you can SSH to that. You can install all your software for IP to get. Update, for example, install. Everything runs. And you can run everything. There's some, sadly, some counter measures which we can do against us. And one of them is, for example, we can change the firmware key. But this is now, I think it's useless, because we can quite easily figure it out. We can just take a look at that. And the other thing which we started to do, like in the recent versions of the firmware, we encrypt and obfuscate the log files and maps on the device. So it's like, it's a little bit more difficult to see the cloud communication clear. But here, it's again, the typical case of, yeah, here's the encryption key. And at least they tried. They quite, they make a quite good job to obfuscate the actual encryption key in the binary, but there's a small trick how you can get the key. And the trick is the following. So this binary is using the AES encryption functions of OpenSSL. And so it's imported as a dynamic library. And the interesting function here is encrypt init. So this is the standard OpenSSL function where one of the parameter is the AES key. If you use a tool like Ltrace, which you can happily install on the vacuum cleaner, it's in Ubuntu, then you can intercept this library call and then you see just the password in plain text. So very easy. As soon as you have root access, you want to stay persistent on the device. And the first thing you want to do is actually patch the recovery partition. So if anything goes wrong, you can just reinstall the recovery and then you have a rooted system again. So the same stuff, you can replace, for example, the ADB with the open source ADB version when you have USB access and disable the firewall, for example, too. If you want to make sure that this device can't do any updates anymore, you can kill the sys update process or you can just disable the secret tool when it cannot decrypt the updates anymore. And a good thing always, if you have root access to your device, get a copy of specific files like the device ID and the cloud key, or they have also the root password there, which is like device specific and later on you can access this device, for example, over SSH or over serial with this kind of root password. There's a small side note of one thing which I noticed like last year in cooperation with Jan Ruge and actually, the token is at AES 256-bit key and the method how we use to generate this key is the following. So we initialize a C function called srent and give it a seat. That's actually the time which they use there. And the thing about srent is actually it has only two power 31 states. So maybe not the best idea to create AES keys. And then we just run 16 times the rent function to get like every byte of the key. So at the end of the day, what it does mean is, so instead of breaking a 256-bit key, you just have to break something which has like two 31, sorry, which has only 31 bits. Not the best idea to generate cryptographically safe keys. This, by the way, this is just an example. So this is like I saw it multiple times and also in other IoT devices. A lot of devices generate their keys this way and this is not super clever. So about the summary. Now we can root this device remotely. We don't need default attack anymore because we know the passwords now. For the cloud connection, we can run it completely without the cloud. There is some support from third party tools like FEM, which is like an Android app where you can control your vacuum cleaner without the cloud. Or you can run it with your own cloud. In this case, that's cloud. So we have now rooted devices. So let's get fun with hacking them. So the first case, I have like some examples what you can do with them. First case is get a connection to the dark side. And this was an idea initially by Professor Nubir who said, hey, can this vacuum cleaner actually run Tor? And it can. And so let's just run a Tor hidden service on it. And so the reason for that why he asked that is there's a paper from 2015 which described a thing named onion bots where you use Tor to create a stealthy botnet with compromised IoT devices which communicate with some neighbor devices and so it cannot run or be really detected. Installing Tor is very easy. It's an Ubuntu so you just install the Tor package. You can make, for example, SSH accessible over Tor and you don't need any net anymore port forwarding so you can just access your vacuum cleaner remotely. Another thing, the generation two here has a lot of empty space in the case and you can use that for some things. For example, if you remember that I break one of the camera gateways and it has a Zigbee model which I just unsoldered and I connected it to the vacuum cleaner. I could take just the binaries for the gateway functionality from the camera and put it on the vacuum cleaner and then they run natively and now I have a zombie gateway vacuum cleaner which has Zigbee functionality and can clean your room. Another thing what some people did is they tried to put like more software on the device but the thing is you have only 512 megabytes of like this partition and one workaround for this is theoretically you can solder a USB stick into this thing so you have more space. Another example, you can use it as a mobile Wi-Fi mapper. This vacuum cleaner produces a lot of log files and the log files give you the X and Y position, the job position and from the kernel you can ask for example specific information about the Wi-Fi, the link level, kind of SSIDs. So this was one project I developed in this year, I think a few months ago with Endo2 on the Hack Bean pod in Boston and it was a mobile Wi-Fi mapper. So what happens here is so on the left side you see the layout of the office where the hackathon was happening and on the right side you see the signal strength of it. So in the X and Y. If you see it from the side it looks like a little bit better in terms of you see here again X and Y and here the signal strength. And this vacuum cleaner was driving around in this office and was mapping the Wi-Fi signal so then you know exactly okay where the Wi-Fi is like good or not good. If you need more additional space this was one thing which was done by one of the Desclosed users because he has a broken MMC chip and it's usually not recommended for everyone. So what he did is he actually unsoldered the MMC chip and soldered the SD card to it. And at the end of the day he had like double the space. And just to give you an idea how precise he worked, I mean this is really impressive. I couldn't do that. My hands are too shaky for that. And the last example. This is like a demo I actually wanted to do like in real but the thing is I can't connect really the vacuum cleaner to the Wi-Fi here so I have to do it here on video. IoT can chat with IoT devices and you see on the left side there's the Amazon Echo and on the right side there's the vacuum cleaner and let's see if it works. Hear nothing. 21 degrees Celsius with mostly sunny skies. Okay. Just redo it again. Alexa. What's the weather? Currently in Boston it's 21 degrees Celsius with mostly sunny skies. So you have like some speaker which can drive around in your apartment which can speak to your IoT. Okay. One word of warning. This is always a very important thing because many people don't understand like the problem in all these kind of cases. Never leave your devices unprovisioned. If you leave your devices unprovisioned it has this open Wi-Fi access point and someone else, your nice neighbor can provision that for you and can install some malicious firmware. The other thing is be very careful with used devices. If you buy devices out of Amazon Marketplace or eBay you have no idea what kind of software is running on these devices. You have no way to figure out if it's malicious software or not. Yeah. And another thing and this should be actually I mean common sense but some people still do that. Never install rooted firmwares from untrusted sources. For the vacuum cleaners we have been like in Russian forums a lot of like oh here we pre-rooted the devices for you and we changed the language files for you. I mean why people do install that? I mean it's very easy to create your own firmware but some people said like oh yeah I saved the five minutes I just downloaded this weird firmware from the Russian website. Jeez. Okay. So for the conclusion the best practices for IoT devices are actually not used. So the firmware signatures are completely missing. If they use HTTPS then it's sometimes broken or even not existing. Certificate verification is sometimes a real problem. Actually all hardware security features are missing. So sometimes you have things like that you disable JTAG that you enable secure boot and so on. They never use that. I never saw that in any of these devices. The good thing is we can modify the devices which is a nice thing. The bad thing is someone else can do that too. So be very careful with that. So this is more or less the end of my presentation but I want to thank some people. First I want to thank Danny Wiegemer who's like sitting here in the front. This was my partner in the research when we started that. Another person I want to thank is Professor Nobir from the Northeastern University. Also I want to thank the Xemo Labs at TU Darmstadt and because legal stuff is seen in the US a little bit more problematic also Andrew Sellers and his team from the Boston Cyber Law Clinic Boston University Cyber Law Clinic. And that's all. And if you have any questions I don't know if you have time now but you can meet me at the IoT Village in one hour or just write me a Telegram message and I created just for you guys a Twitter account so you can send me also Twitter messages or meet me in Boston. If you're in Boston I'm also around there. Thank you very much. Thank you.