1 00:00:00,000 --> 00:00:02,060 So good morning and welcome. 2 00:00:02,080 --> 00:00:05,600 I know this is kind of early Sunday morning, so I really appreciate you guys all being here. 3 00:00:06,160 --> 00:00:09,300 Today we're going to be talking about hacking and implanting a drop cam. 4 00:00:10,520 --> 00:00:13,080 So we both work at the R&D team at Cinec. 5 00:00:13,080 --> 00:00:17,100 Cinec does crowdsource vulnerability discovery with vetted security researchers. 6 00:00:17,760 --> 00:00:18,860 My name is Patrick Wardle. 7 00:00:18,860 --> 00:00:24,640 I've worked at various acronymed places, but currently I'm the director of research at Cinec. 8 00:00:25,380 --> 00:00:26,760 And I'm Colby Moore. 9 00:00:26,760 --> 00:00:31,100 I formerly worked at VRL and currently work at Cinec as a security research engineer. 10 00:00:31,680 --> 00:00:33,880 More like a security ninja, I think. 11 00:00:35,840 --> 00:00:36,240 All right. 12 00:00:36,240 --> 00:00:37,500 So what are we going to talk about today? 13 00:00:37,880 --> 00:00:40,040 First, a brief overview of drop cam. 14 00:00:40,500 --> 00:00:43,340 Then how we got a root shell on the device. 15 00:00:44,120 --> 00:00:47,120 Following that, we're going to talk about some vulnerabilities that we found. 16 00:00:47,620 --> 00:00:52,340 And then finally, we want to present a persistent implant that we designed for drop cam. 17 00:00:54,780 --> 00:01:01,420 So first let's talk a little bit, give a little bit of an overview, talk about some background information, talk about what drop cam is. 18 00:01:02,940 --> 00:01:11,540 Before jumping in, though, I always think it's a good idea to concisely define any possible ambiguous terms, especially since we're in Vegas , so there could be some confusion. 19 00:01:12,000 --> 00:01:17,640 So in the talk, when we talk about implants, we're talking about persistent code that is malicious. 20 00:01:18,820 --> 00:01:23,360 Hooking means intercepting function calls, usually by installing a hook or a detour. 21 00:01:24,540 --> 00:01:30,200 A Trojan is a malicious piece of software that pretends to be something legitimate. 22 00:01:31,680 --> 00:01:34,540 Injection is all about getting code into a remote process. 23 00:01:35,540 --> 00:01:41,740 And finally, a backdoor is some code that provides, you know, undetected remote control of the device. 24 00:01:41,740 --> 00:01:43,240 Now, it's a little sad when I hear these terms. 25 00:01:43,240 --> 00:01:45,440 I actually now think of the computer term first. 26 00:01:46,400 --> 00:01:49,440 But my wife likes that, so I guess that's the silver lining there. 27 00:01:51,280 --> 00:01:52,700 So what is a drop cam? 28 00:01:52,700 --> 00:01:57,000 Well, as you can see from their definition, it's a cloud-based video Wi-Fi solution. 29 00:01:57,060 --> 00:02:00,040 And at the core of it is the camera, the actual drop cam device. 30 00:02:00,420 --> 00:02:09,140 So besides an incredible simple set-up process, it's got some cool features, such as cloud recording, night vision, two-way talk and intelligent alerts. 31 00:02:10,540 --> 00:02:14,280 Now, one of the main appeals of drop cam is its trivial set-up process. 32 00:02:14,480 --> 00:02:19,980 Really all the camera needs to get set up is the name or SSID and password of your wireless network. 33 00:02:20,580 --> 00:02:21,780 Now, there's two ways to do this. 34 00:02:21,780 --> 00:02:27,960 This configuration can be done by either plugging the camera into the computer via USB or with a smartphone that has Bluetooth. 35 00:02:29,200 --> 00:02:32,500 Now, once the set-up is complete, the camera will be connected to the Wi-Fi network. 36 00:02:32,960 --> 00:02:35,220 From then on, it's pretty much fully autonomous. 37 00:02:35,220 --> 00:02:36,660 You really don't have to worry about it anymore. 38 00:02:36,660 --> 00:02:42,040 It's going to stream audio and video to the cloud and beacon to the drop cam servers for updates on a regular basis. 39 00:02:44,020 --> 00:02:46,660 So there's a lot of IP-based video solutions out there. 40 00:02:46,660 --> 00:02:48,180 So what's special about drop cam? 41 00:02:48,180 --> 00:02:49,680 Why did we choose to go after it? 42 00:02:50,660 --> 00:02:52,740 Well, now drop cam is owned by Google. 43 00:02:52,740 --> 00:02:56,800 And Google has indicated it will become the core of their push into the connected home. 44 00:02:56,920 --> 00:02:59,060 So in other words, soon there's going to be drop cams everywhere. 45 00:03:00,120 --> 00:03:03,060 Now, when we started this research, we didn't know that Google would buy drop cam. 46 00:03:03,060 --> 00:03:05,820 If we had, we probably would have tried to get hired there, get some equity. 47 00:03:05,820 --> 00:03:07,920 But it was still a pretty appealing target. 48 00:03:08,800 --> 00:03:09,880 For one, it's really popular. 49 00:03:09,880 --> 00:03:12,880 You see all over the Bay Area, it's a best -selling device on Amazon. 50 00:03:13,800 --> 00:03:16,760 Secondly, it shows up in interesting places like homes and offices. 51 00:03:17,060 --> 00:03:20,920 Again, the Bay Area, all the start-ups pretty much use drop cams for their security solutions. 52 00:03:20,920 --> 00:03:22,860 So good target in that point of view. 53 00:03:23,180 --> 00:03:31,200 And finally, it's kind of a juicy target because it has some really cool capabilities that, you know, we thought were pretty powerful and were just begging to be abused. 54 00:03:32,460 --> 00:03:34,400 Now Colby is going to talk about routing a drop cam. 55 00:03:35,580 --> 00:03:40,200 So based on the network footprint, we figured taking a hardware approach would be best . 56 00:03:40,200 --> 00:03:42,440 So naturally the first thing to do was crack the camera open. 57 00:03:44,040 --> 00:03:47,780 Conveniently, drop cam left us this mysterious header right here. 58 00:03:48,560 --> 00:03:53,800 Probing around revealed what looked like a 3.3 volt UART on there. 59 00:03:54,380 --> 00:03:59,340 So we hooked it up to the FTDI to serial to USB connector that you guys are all familiar with. 60 00:04:00,120 --> 00:04:07,340 And here's a little photo showing our ground connection and transmit and receive on pins 3 and 4, respectively, if you guys want to try this at home. 61 00:04:09,100 --> 00:04:15,280 So after a quick reboot, we have a serial console and major credit to drop cam for the sweet ASCII art right there. 62 00:04:16,180 --> 00:04:22,140 We wrote a serial brute forcer to try admin, admin, admin password, all the standards, but really no luck. 63 00:04:22,660 --> 00:04:27,540 So at this point we should probably mention the drop cam is running essentially just Linux. 64 00:04:27,540 --> 00:04:28,600 It's a miniature computer. 65 00:04:28,720 --> 00:04:33,200 It's running a Linux system on chip from a company called Ambarella based in the Santa Clara Bay area. 66 00:04:33,940 --> 00:04:39,300 And so, you know, we figured we'd take more of a Linux approach to maybe getting root in this box. 67 00:04:40,900 --> 00:04:42,940 So we decided to go after the boot loader. 68 00:04:43,200 --> 00:04:50,620 So if you hold enter on power on or you short the transmit and receive lines and power on the device, it should drop you to the boot loader. 69 00:04:50,620 --> 00:04:52,940 Now, this is Ambarella's custom boot loader. 70 00:04:54,860 --> 00:04:58,080 Now, looking at the boot loader, we got a couple options here. 71 00:04:58,080 --> 00:05:00,040 The set EMV one looked pretty promising. 72 00:05:00,880 --> 00:05:03,300 And it looks like there's an option to change the boot parameters. 73 00:05:04,120 --> 00:05:14,000 So we went ahead and just like, you know, root in a standard Linux box that you have physical access to, we went ahead and changed the parameter to slash bin slash SH and hope it drops us to a root shell. 74 00:05:14,640 --> 00:05:15,780 And yeah, that worked. 75 00:05:18,580 --> 00:05:22,680 So now we got to get rid of that password so we can get on the system, right? 76 00:05:23,400 --> 00:05:27,440 So we checked out Etsy shadow and it wouldn't open. 77 00:05:27,440 --> 00:05:30,520 So it looks like it was SIM linked to mount drop cam shadow. 78 00:05:30,720 --> 00:05:36,380 So we checked out Etsy F stab and it gave us the necessary information we needed to mount up that share. 79 00:05:36,660 --> 00:05:40,720 So we went ahead and mounted it up and now we have access to the shadow file. 80 00:05:40,720 --> 00:05:44,100 I went ahead and just knocked out that hash and saved. 81 00:05:44,400 --> 00:05:52,320 Went ahead and rebooted and reset the boot parameters in the boot loader and rebooted, boom, we have a full -featured root shell on the device. 82 00:05:53,900 --> 00:06:02,200 So there's some other research done previously and they really didn't find any vulnerabilities in the drop cam but we tend to have a little bit of a different opinion. 83 00:06:03,440 --> 00:06:06,080 So we're going to talk a little bit about the vulnerabilities that we found. 84 00:06:06,900 --> 00:06:09,100 So first let's talk about the environment. 85 00:06:09,100 --> 00:06:11,780 Since we have a root shell we can now poke around and explore. 86 00:06:12,600 --> 00:06:19,660 The drop cam is running ARM 32 bit Linux custom distribution and the heart of the drop cam is this connect executable. 87 00:06:19,660 --> 00:06:21,320 We're going to talk about that a lot later. 88 00:06:21,520 --> 00:06:29,180 They also left all sorts of goodies on the device for us, you know, drop bear, FTP, Telnet, GDB server, you know, thanks guys. 89 00:06:32,160 --> 00:06:35,440 So overall the drop cam is decently secure. 90 00:06:35,440 --> 00:06:38,440 There were no open ports or exposed network services. 91 00:06:38,760 --> 00:06:41,000 All communications were SSLed properly. 92 00:06:42,100 --> 00:06:45,960 And the drop cam employs device specific provisioning from the factory. 93 00:06:46,000 --> 00:06:50,300 That's likely why we couldn't crack the root password because each device has its own unique password. 94 00:06:51,120 --> 00:06:53,080 It also employs automatic updates. 95 00:06:53,080 --> 00:06:57,540 It beacons out regularly and checks drop cam for updates and they're pushed down and the whole device is reflashed. 96 00:06:57,540 --> 00:06:59,740 So it's pretty robust in that sense. 97 00:07:01,060 --> 00:07:03,280 But let's take a look at the first bug. 98 00:07:03,660 --> 00:07:06,980 The camera is using open SSL for comms to drop cam servers. 99 00:07:07,340 --> 00:07:11,000 But it's running an old version of open SSL so it's vulnerable to heart bleed. 100 00:07:12,060 --> 00:07:14,020 So what can we do with that? 101 00:07:15,540 --> 00:07:21,200 Drop cam says our cameras won't communicate with anyone on the Internet, only drop cam's cloud servers. 102 00:07:21,520 --> 00:07:22,920 But that's not really true. 103 00:07:22,920 --> 00:07:30,280 If we spoof DNS responses and trigger a client side heart bleed attack, we're able to download the camera's private and public SSL keys among other system information. 104 00:07:32,400 --> 00:07:35,440 So realistically now that we have these keys, what can we do? 105 00:07:36,040 --> 00:07:42,260 Normally the drop cam talks to the cloud via SSL and then you use your devices to view the video from the cloud. 106 00:07:42,580 --> 00:07:45,800 But you should note that it authenticates using the very same certificates that we stole. 107 00:07:46,280 --> 00:07:53,000 So a hacker with these certs could spoof a drop cam video feed providing false video to the cloud DVR. 108 00:07:53,360 --> 00:07:55,840 So should a user really trust what they're seeing? 109 00:07:56,720 --> 00:08:01,060 For the record, we notified drop cam of this heart bleed bug and they patched it fairly recently. 110 00:08:01,260 --> 00:08:08,400 However, they haven't rotated the camera's certificates so if anybody happened to have a bucket full of these certificates, we don't. 111 00:08:09,320 --> 00:08:11,880 There's nothing the consumer can really do at this point. 112 00:08:13,820 --> 00:08:17,060 So then for most of its functionality, drop cam runs busy box. 113 00:08:17,400 --> 00:08:20,080 But unfortunately the version is outdated and vulnerable. 114 00:08:21,020 --> 00:08:25,720 Basically it's an old bug that allows command injection via malicious DFCP response. 115 00:08:26,060 --> 00:08:31,780 So a user is able to inject commands via the host name parameter and they get propagated into the system host name. 116 00:08:32,720 --> 00:08:38,000 This is really only triggered if the host name is used by another utility. 117 00:08:38,280 --> 00:08:44,380 But we checked out the vulnerable source code and compared it to the disassembly from drop cam and it definitely matches. 118 00:08:45,060 --> 00:08:52,140 So we weren't able to trigger this bug right now because drop cam isn't using the host name in a way that would trigger this, but it could come back to bite them later. 119 00:08:54,880 --> 00:08:58,000 So all those bugs are pretty cool, but we had to open up the camera. 120 00:08:58,000 --> 00:09:00,840 So wouldn't it be nice if we could implant the device without opening it up? 121 00:09:01,180 --> 00:09:03,600 Luckily there's an app for that. 122 00:09:05,080 --> 00:09:10,320 It's called direct USB and we found a copy somewhere in the dark corners of the internet, specifically Russia. 123 00:09:11,480 --> 00:09:22,000 If you hold down the button on the back of the camera, the button that drop cam swears does nothing according to official docs, and you hold it down while you're powering the camera on, it enters a firmware update mode. 124 00:09:22,000 --> 00:09:24,540 And we believe this is how the devices are provisioned at the factory. 125 00:09:24,980 --> 00:09:28,060 When we questioned drop cam about this, they didn't deny it. 126 00:09:28,520 --> 00:09:31,380 Ultimately we were able to read and write unsigned data to the camera. 127 00:09:31,380 --> 00:09:36,760 So realistically an attacker could walk into the home, plug into a drop cam, reflash with malicious software in minutes. 128 00:09:38,440 --> 00:09:39,480 And back to Patrick. 129 00:09:40,320 --> 00:09:43,640 So there's more to drop cam than just the software that runs on the camera. 130 00:09:43,640 --> 00:09:47,320 So recall that a user may use their computer to initially configure the device. 131 00:09:47,520 --> 00:09:54,320 So to do this, the camera is plugged into the computer and then it mounts part of the camera as a share, which contains the setup utility. 132 00:09:54,900 --> 00:10:02,340 This utility, which requests root privileges to run, gets the SSID and password of the Wi-Fi network and then propagates that back to the camera. 133 00:10:02,600 --> 00:10:05,120 The end result is a connected and configured camera. 134 00:10:07,120 --> 00:10:10,680 Unfortunately, this application which runs at root is world writable. 135 00:10:10,920 --> 00:10:16,660 So in a proof of concept, a non-privileged host-based attacker can wait until any drop cam is plugged in. 136 00:10:17,320 --> 00:10:22,420 They can then inject a malicious payload into the mounted drop cam setup utility. 137 00:10:23,720 --> 00:10:27,120 Now when the application is run and elevated, so is the attacker's code. 138 00:10:27,960 --> 00:10:33,820 Now the Windows installer setup configuration utility has a similar privilege escalation vulnerability as well. 139 00:10:33,820 --> 00:10:37,280 Drop cam is still patching that so we can't go into details at this time. 140 00:10:38,900 --> 00:10:46,240 Now as Colby mentioned, the CEO of drop cam said that their cameras only talk to drop cam servers, which discounting things like Heartbleed is pretty much true. 141 00:10:46,560 --> 00:10:49,400 However, the same cannot be said for their iOS application. 142 00:10:50,660 --> 00:10:57,140 Now SSL pinning is an extra layer of security that ensures the client will only communicate with a well-defined set of servers. 143 00:10:57,400 --> 00:11:03,380 Now since the drop cam iOS application does not use SSL pinning, a man in the middle attack can occur. 144 00:11:04,580 --> 00:11:13,360 So if an attacker has a compromised root certificate or can coerce the user to install a certificate, for example, sending them an email, the connection can be man in the middle. 145 00:11:15,520 --> 00:11:20,800 So here we have a burp capture showing a man in the middle attack in action actually against my own phone, which is non-jailbroken. 146 00:11:20,940 --> 00:11:24,020 It reveals a username and password for a drop cam account. 147 00:11:25,160 --> 00:11:36,520 Now since drop cam does not use dual factor authentication or any shared or duplicate session alerts, an attacker with these credentials can persistently and surreptitiously spy on the user at any time. 148 00:11:36,520 --> 00:11:40,400 Now this is really good for the bad guys, not good for the rest of us. 149 00:11:44,730 --> 00:11:47,710 So now that we have a good way to implant the camera, let's have some fun. 150 00:11:48,090 --> 00:11:50,870 Introducing our full featured implant, cuckoo's egg. 151 00:11:51,030 --> 00:11:55,210 For those who are unaware, the cuckoo lays its egg in other nests. 152 00:11:57,810 --> 00:11:59,390 See how many you guys get it. 153 00:12:00,210 --> 00:12:03,730 Given the robust capability of the drop cam, our malicious software should. 154 00:12:04,370 --> 00:12:06,610 C, we want to be able to intercept video. 155 00:12:06,750 --> 00:12:08,510 Here, we want to hot mic a room. 156 00:12:09,170 --> 00:12:12,970 Propagate, we want to infect other hosts when they connect to the drop cam or it's plugged in. 157 00:12:13,430 --> 00:12:17,610 We want to be able to geolocate the drop cam, so if we send a bunch out in the wild, we know where they ended up. 158 00:12:18,050 --> 00:12:23,090 We want to be able to infill and exfil files in case we need to upload our new exploit or tool so we can pivot into the network. 159 00:12:23,490 --> 00:12:25,750 We want to be able to drop to a command shell to use our tools. 160 00:12:26,250 --> 00:12:29,790 And we want to be able to connect a basic network survey and a device survey. 161 00:12:31,350 --> 00:12:35,750 So conceptually the drop cam will sit on a corporate network and talk out to the drop cam's cloud. 162 00:12:36,390 --> 00:12:39,290 But with our implant, it will also talk out to us. 163 00:12:39,750 --> 00:12:42,750 We also need a method for other devices on the drop cam's network. 164 00:12:44,010 --> 00:12:46,170 We also need a method, sorry. 165 00:12:49,170 --> 00:12:49,570 What? 166 00:12:52,290 --> 00:12:53,090 Okay. 167 00:12:53,470 --> 00:12:54,170 Well, anyway. 168 00:12:54,410 --> 00:12:57,870 So our implant even comes with its own slogan. 169 00:12:58,030 --> 00:13:04,230 He sees you when you're sleeping, he knows when you're awake, he knows if you've been bad or good, just like the NSA JK. 170 00:13:07,940 --> 00:13:11,460 So in a real world scenario, how do we install our malicious software? 171 00:13:11,540 --> 00:13:14,780 We don't have remote code execution but there's a lot of options. 172 00:13:15,100 --> 00:13:24,340 We can intercept the package in transit, we could maybe gift a drop cam to somebody that's already been implanted or we could break and enter and modify it in the house. 173 00:13:28,120 --> 00:13:30,240 Realistically that stuff never happens, right? 174 00:13:30,920 --> 00:13:32,200 No further comment. 175 00:13:32,920 --> 00:13:39,240 We approached drop cam about this and they were convinced the adversary wouldn't be able to reshrink the drop cam as nicely as it was done to the factory. 176 00:13:39,240 --> 00:13:43,680 And that alone would be an appropriate anti tamper mechanism. 177 00:13:43,840 --> 00:13:44,940 What do you guys think? 178 00:13:49,610 --> 00:13:51,490 Now what about sending one as a gift? 179 00:13:51,650 --> 00:13:53,990 Recently a friend's incubator space was broken into. 180 00:13:54,170 --> 00:13:57,910 Is it too far-fetched to think that management might send them security cameras to implement? 181 00:13:58,210 --> 00:13:59,250 Probably not. 182 00:14:00,930 --> 00:14:03,030 Is a break in entering scenario really plausible? 183 00:14:03,270 --> 00:14:03,950 Maybe. 184 00:14:04,290 --> 00:14:06,810 Drop cam's argument was that you would see an attacker coming. 185 00:14:06,810 --> 00:14:10,110 However, only one third of users sign up for drop cam's cloud recording. 186 00:14:10,470 --> 00:14:16,310 Even then, if you just showed up with a Wi-Fi jammer, the camera doesn't cache any video locally so the video wouldn't get sent to the server. 187 00:14:17,210 --> 00:14:19,010 Now what makes drop cam a good target? 188 00:14:20,010 --> 00:14:24,090 The drop cam CEO said all software products are susceptible to jail breaking. 189 00:14:24,090 --> 00:14:24,530 And that's true. 190 00:14:24,530 --> 00:14:25,710 We tend to agree with that. 191 00:14:25,790 --> 00:14:27,710 But the drop cam really is the low hanging fruit. 192 00:14:28,290 --> 00:14:29,470 Here are the other options. 193 00:14:32,600 --> 00:14:37,700 Someone could go after a computer that often has full disk crypto, boot password and there's no forensic tools. 194 00:14:38,240 --> 00:14:40,820 They could go after a printer but it runs a proprietary operating system. 195 00:14:40,820 --> 00:14:41,900 You've got to crack it open. 196 00:14:41,900 --> 00:14:43,720 A printer can't see, can't hear. 197 00:14:43,720 --> 00:14:45,100 There's a lot of things it can't do. 198 00:14:45,840 --> 00:14:50,000 They could go after a gaming console but again, it runs sign code and has DRM protection. 199 00:14:50,000 --> 00:14:52,660 You've got to crack it open and it's generally turned off. 200 00:14:53,380 --> 00:14:58,880 Or they could go after a mobile phone but it's normally pass locked, again, runs sign code and it's really off person. 201 00:14:59,880 --> 00:15:12,600 So the drop cam, you don't need to open it up, no boot password, no disk crypto, no sign code, the operating system is open source, it's always on, has tons of capabilities and who's going to suspect that the security camera is spying on you. 202 00:15:19,650 --> 00:15:24,590 So in order to create an advanced implant, we needed to fully understand how the drop cam worked. 203 00:15:25,410 --> 00:15:30,170 In other words, we had to answer questions such as how does it hear, see or think? 204 00:15:30,370 --> 00:15:33,530 Where is its core logic, the main module of the brain? 205 00:15:33,590 --> 00:15:36,410 And finally, can this be manipulated or rewired? 206 00:15:37,810 --> 00:15:40,970 The drop cam has many hardware and software components. 207 00:15:41,370 --> 00:15:45,090 However, these all kind of come together in the connect binary, which I'll be talking about a lot. 208 00:15:45,270 --> 00:15:58,670 This binary is really the brain of the camera as it contains most of the drop cam specific operations such as talking to the audio and video devices, streaming content to the cloud and then also handling or executing commands that are received from drop cam servers. 209 00:16:01,810 --> 00:16:06,290 Unfortunately, the connect binary is packed with UPX, which is not normally a problem. 210 00:16:06,330 --> 00:16:08,750 Unfortunately, when we tried to unpack it, it failed. 211 00:16:09,930 --> 00:16:18,350 Now, since we wanted a full unpack, that would make everything easier from debugging to static analysis, we decided to look into this a little more. 212 00:16:19,770 --> 00:16:25,030 Now, the unpacker stub matched the UPX source code, indicating it wasn't a custom version of UPX. 213 00:16:25,210 --> 00:16:30,630 So we figured perhaps the binary was perhaps modified after the fact in some way to prevent unpacking. 214 00:16:31,830 --> 00:16:38,150 Now, I single stepped through the unpacking stub's instructions and followed along in the UPX source code, which was not fun. 215 00:16:38,150 --> 00:16:41,410 But this revealed exactly where the unpacking exception occurred. 216 00:16:42,030 --> 00:16:49,450 The code was checking a value within the binary's ELF header and then branching into a code path for unpacking shared library. 217 00:16:49,450 --> 00:16:51,390 That unfortunately then errored out. 218 00:16:52,770 --> 00:16:55,290 Now, connect is a normal ELF executable. 219 00:16:55,290 --> 00:16:56,530 It's not a shared library. 220 00:16:56,530 --> 00:16:59,270 So I was a little confused why I was taking this code path. 221 00:16:59,350 --> 00:17:06,350 So we decided to write a small Python script that simply unset the value in the ELF header that the UPX unpacking code was looking at. 222 00:17:07,310 --> 00:17:11,870 Once we did this, we then re-invoked UPX to attempt to unpack the binary and that worked. 223 00:17:11,870 --> 00:17:15,270 Connect was fully unpacked and even fully runnable, which is really nice. 224 00:17:16,290 --> 00:17:22,510 And actually using the inverse of this technique, so setting that member in the ELF header, we were actually able to create unpackable binaries as well. 225 00:17:22,510 --> 00:17:24,110 So I guess thanks to Dropcam for that. 226 00:17:28,050 --> 00:17:31,650 So now that we've talked about all these cool capabilities, let's talk about the core of our implant. 227 00:17:31,950 --> 00:17:38,170 We wanted to create something simple, portable to other devices and have the ability to leverage third-party libraries. 228 00:17:39,050 --> 00:17:42,330 So since we don't have to be too stealthy, Python seemed like a natural choice. 229 00:17:43,770 --> 00:17:46,590 We cross-compiled and stripped down Python to reduce the disk footprint. 230 00:17:47,490 --> 00:17:52,630 And then Python is then extracted to RAM disk on boot and our implant is kicked off all through an energy script. 231 00:17:58,620 --> 00:18:02,360 It's great that we have an implanted camera and all, but how is it going to talk to us? 232 00:18:03,300 --> 00:18:07,600 All comms are done over HTTPS and call out through the secure networks firewall. 233 00:18:08,100 --> 00:18:16,080 Our command and control and streaming data are sent over separate channels and our CNC server is set up on Amazon AWS infrastructure, the same as Dropcam's. 234 00:18:16,420 --> 00:18:29,440 Given the nature of our comms and by putting our CNC server on AWS, it really wouldn't be that easy to tell the difference between our regular Dropcam traffic and our implant by looking at network traffic or even to create appropriate IDS rules. 235 00:18:30,800 --> 00:18:32,260 Which connection is legit? 236 00:18:34,440 --> 00:18:37,440 What about if we wanted to ship a ton of these cameras out in the wild? 237 00:18:37,920 --> 00:18:39,280 How will we know where they end up? 238 00:18:40,160 --> 00:18:44,520 Cuckoo's egg runs a camera side Wi-Fi survey and ships it back to the CNC server. 239 00:18:44,780 --> 00:18:51,420 The CNC server then sends the survey back to Google's geolocation APIs and returns the device location. 240 00:18:51,820 --> 00:18:52,680 Thanks, Google. 241 00:18:57,960 --> 00:19:02,780 We also wanted our implant to autonomously propagate to Windows or Mac-based computers. 242 00:19:03,660 --> 00:19:08,120 Since we control the camera, we actually control the set-up application as well. 243 00:19:08,460 --> 00:19:11,280 So we simply replace it with a malicious implant installer. 244 00:19:11,980 --> 00:19:18,280 Now, whenever the user runs the implant or the set-up application, they're actually running the implant installer first. 245 00:19:18,280 --> 00:19:20,240 And that's executed with root privileges. 246 00:19:21,140 --> 00:19:27,600 We also use a homograph attack so that it's really difficult to actually tell which binary is the malicious one by simply looking at their names. 247 00:19:28,060 --> 00:19:39,980 We also made sure to disable the Bluetooth set-up feature so that the user was forced to plug the camera into the computer in order to configure it, which for us ensured that they would then infect their PC or Mac-based computer. 248 00:19:41,580 --> 00:19:44,920 So Apple loves to tout their many anti-malware mitigations. 249 00:19:44,960 --> 00:19:51,840 However, some of these are trivially bypassed while others can be avoided altogether, which allows our implant to execute freely. 250 00:19:51,840 --> 00:19:53,080 It's not detected at all. 251 00:19:53,320 --> 00:20:03,260 So if you want some more information, we gave a talk about the stuff at ShakaCon and also released an open source tool that can detect persistent OSX malware, which would also detect our implant on OSX. 252 00:20:04,000 --> 00:20:14,380 This talk describes bypasses for XProtect, which is Apple's antivirus product, Gatekeeper, the OSX sandbox, and even signed coding requirements. 253 00:20:14,380 --> 00:20:18,400 For example, it's able to load unsigned kernel module into the kernel. 254 00:20:18,400 --> 00:20:19,880 So sorry, Apple. 255 00:20:22,380 --> 00:20:27,300 Now a major component of our implant is the ability to grab and manipulate audio and video. 256 00:20:28,420 --> 00:20:33,320 Now I mentioned the Kinect binary talks to both the audio and video cards that reside in kernel mode. 257 00:20:33,720 --> 00:20:39,880 Data is read from these devices and then is streamed to the DropCam's cloud servers where it is consumed by the user. 258 00:20:41,020 --> 00:20:46,540 So first I'm going to talk about how our implant is able to hot mic the camera in order to listen in to everything. 259 00:20:47,120 --> 00:20:53,420 Since the Kinect binary exclusively opens the audio card, we have to inject a module into the Kinect process. 260 00:20:54,380 --> 00:20:56,660 So here are the various relevant components. 261 00:20:56,840 --> 00:21:00,180 The Kinect binary is continually reading the audio stream. 262 00:21:00,840 --> 00:21:09,140 But our injected module can then install a hook and gain access to the audio stream and then exfil it to our command and control servers. 263 00:21:11,340 --> 00:21:15,480 Now DropCam uses a standard Linux framework to read audio, which is kind of cool. 264 00:21:15,580 --> 00:21:23,700 So to get the audio, it invokes the send PCM read end function, which retrieves audio frames containing audio buffers. 265 00:21:23,780 --> 00:21:26,380 This is where the implant installs its audio hook. 266 00:21:27,340 --> 00:21:35,660 Again, the goal was to clone the audio and stream it to the cuckoo's egg server while letting it stream in parallel up to DropCam so the user wouldn't notice anything was amiss. 267 00:21:36,680 --> 00:21:40,940 So here is the code that is inserted as an audio hook. 268 00:21:40,980 --> 00:21:49,620 This code gets a pointer to the original send PCM read function, invokes it, and then simply exfiltrates any data or audio that's captured. 269 00:21:49,620 --> 00:21:50,620 So pretty straightforward. 270 00:21:52,700 --> 00:21:53,200 All right. 271 00:21:53,200 --> 00:21:54,280 Now on to video. 272 00:21:54,720 --> 00:22:01,300 So by disassembling the Kinect binary, we were able to uncover how the camera accesses and streams video to the cloud. 273 00:22:02,520 --> 00:22:07,880 In the disassembly, you can see it opening the video device, which is slash dev slash IAV. 274 00:22:07,920 --> 00:22:16,420 Now this device is backed by an umbrella chip that does all the video processing and H264 encoding in hardware, obviously for performance reasons. 275 00:22:17,420 --> 00:22:24,360 The second disassembly snippet shows the Kinect binary talking to this video device to get the actual video via an eye octal. 276 00:22:25,000 --> 00:22:28,620 The eye octals are all undocumented and many take undocumented structures. 277 00:22:28,620 --> 00:22:38,760 Luckily, there were some comments or error messages in the disassembly so we could maybe kind of get the name of the eye octal, which gave us some insight into perhaps what it was doing. 278 00:22:40,120 --> 00:22:44,260 So I mentioned we wanted to clone the video and stream it to the implant servers. 279 00:22:44,940 --> 00:22:50,820 Now, undocumented eye octals and structures result in a ton of reverse engineering and a ton of seg faults. 280 00:22:51,140 --> 00:22:55,400 However, we eventually got it all figured out and we wanted to describe that here. 281 00:22:56,040 --> 00:22:59,900 So first you open the slash dev slash IAV device. 282 00:23:00,020 --> 00:23:04,600 Then you get the H264 encoding parameter so that the stream you exfil can be decoded. 283 00:23:05,240 --> 00:23:11,200 You then map the bit stream buffer memory and the digital signal processor memory. 284 00:23:12,000 --> 00:23:21,800 Now, after you check that the video is actually being recorded, the video stream can finally be read with the IAV IOC read bit stream, yeah, bit stream EX eye octal. 285 00:23:22,200 --> 00:23:30,300 Now, besides this being really useful for an implant, this actually allows you to stream the video to a server or DVR of a choice. 286 00:23:30,300 --> 00:23:38,000 So this saves you money because you don't have to pay DropCam $30 a month to store your video and it also prevents Google from seeing what's going on, say, inside your house. 287 00:23:38,000 --> 00:23:39,240 So that's kind of a cool feature. 288 00:23:39,300 --> 00:23:40,740 I don't want Google seeing what I'm up to. 289 00:23:42,880 --> 00:23:49,140 So now we could clone the video feed, send it to an implant server while it was also streaming in parallel to DropCam. 290 00:23:49,140 --> 00:23:59,420 But we thought we wanted to take this a step farther and actually manipulate the live video stream on the device to do cool things like in the movies, for example, making an attacker invisible. 291 00:24:00,740 --> 00:24:03,180 So again, here are the various relevant components. 292 00:24:04,100 --> 00:24:11,000 The video card is going to generate frames which will, in this example, show the attacker, you know, breaking in or doing his bad things. 293 00:24:11,000 --> 00:24:12,540 So we really don't want that. 294 00:24:13,320 --> 00:24:18,820 However, the injected module will intercept these frames and inject other frames. 295 00:24:19,320 --> 00:24:25,240 These injected frames will then be streamed to the cloud instead and ultimately back to the user which will hide the attacker. 296 00:24:27,760 --> 00:24:29,820 So take a little bit of a closer look. 297 00:24:30,260 --> 00:24:34,760 Here's the video device and the connect binary which is reading frames. 298 00:24:35,720 --> 00:24:37,720 The injected module installs another hook. 299 00:24:37,720 --> 00:24:44,580 This time it's an IOCTL hook and watches for the IOC read bit streams EX IOCTL. 300 00:24:45,660 --> 00:24:50,720 Now when this IOCTL is called, it populates a structure with various values. 301 00:24:50,840 --> 00:24:54,760 Through reverse engineering, we were able to determine what these values were. 302 00:24:55,240 --> 00:25:06,240 Some of the relevant ones include the frame number, the address to the frame's raw H264 encoded data, the frame type, and finally the frame size. 303 00:25:07,520 --> 00:25:12,580 Now the easiest way to manipulate the video stream is just to wait for a frame type of JPEG full. 304 00:25:12,620 --> 00:25:20,300 Then moving forward, you can either just replay this frame to lock or freeze the video frame or actually inject other full frames as well. 305 00:25:20,380 --> 00:25:25,440 The other frames are not ideal because H26 encoding pretty much just encodes deltas. 306 00:25:25,440 --> 00:25:30,180 So if you're trying to intercept and manipulate a frame, a lot of times you don't actually have the full frame. 307 00:25:30,260 --> 00:25:35,980 These JPEG full frames happen every second so it's pretty easy to wait for them and then use them moving forward. 308 00:25:37,340 --> 00:25:37,720 All right. 309 00:25:37,720 --> 00:25:39,020 So video demo time. 310 00:25:39,020 --> 00:25:42,160 I wanted to show you how we can transparently lock the video stream. 311 00:25:42,160 --> 00:25:45,020 If you look at the top left is the drop cam feed. 312 00:25:45,020 --> 00:25:48,200 So this is what the user is going to see and this is what we are manipulating. 313 00:25:48,580 --> 00:25:51,120 The top right is a shot from an external camera. 314 00:25:51,240 --> 00:25:55,620 Bottom left is the sys log output and bottom right is the attacker's console. 315 00:25:56,540 --> 00:25:56,980 All right. 316 00:25:56,980 --> 00:25:59,600 So you see a mom coming to tuck her kid in. 317 00:26:01,260 --> 00:26:07,480 If you look at the attacker's window, they're going to then run the enable cam to activate the video lock. 318 00:26:08,700 --> 00:26:15,320 We then see... an attacker that somehow looks like Colby. 319 00:26:15,320 --> 00:26:16,940 Got to work on your disguises. 320 00:26:17,680 --> 00:26:19,560 The video now is locked to frame. 321 00:26:19,560 --> 00:26:23,020 It's injecting these JPEG full frames in so the video is frozen. 322 00:26:23,020 --> 00:26:27,220 But you can see the camera is still counting up so the user is not going to notice. 323 00:26:27,600 --> 00:26:34,980 Then we run the disable command which tells the camera feed to resync and then it's going to flip back to the baby. 324 00:26:35,360 --> 00:26:38,460 Now, I'm sure the mom is going to accept this child as one of their own. 325 00:26:41,660 --> 00:26:45,460 Well... apparently not. 326 00:26:55,990 --> 00:26:56,510 All right. 327 00:26:56,510 --> 00:26:57,290 Back to Colby. 328 00:26:57,930 --> 00:26:58,570 All right. 329 00:26:58,570 --> 00:27:02,010 So we built this awesome implant that does everything an attacker could dream of. 330 00:27:07,990 --> 00:27:10,350 But how do we control it? 331 00:27:11,090 --> 00:27:14,010 So naturally a sleek web control panel is needed. 332 00:27:14,370 --> 00:27:19,010 On the main screen all the cameras call back with their name and location so targeting is super easy. 333 00:27:19,930 --> 00:27:23,930 From there it's easy to select a target and a job to be sent down to the drop cam. 334 00:27:23,930 --> 00:27:26,810 We support all the commands we talked about previously. 335 00:27:27,710 --> 00:27:34,390 The camera calls home to the server at a standard interval to report job results and retrieve new jobs from the queue. 336 00:27:34,650 --> 00:27:40,130 We have a series of completed and unsent jobs. 337 00:27:40,310 --> 00:27:44,570 Queued up is an execute and execute task whereas there are several completed surveys. 338 00:27:44,570 --> 00:27:47,010 Results are reported in a convenient JSON format. 339 00:27:48,810 --> 00:27:51,450 For this next part we need a bit of disclaimer. 340 00:27:51,450 --> 00:27:56,210 The stuff we're about to do is theoretically possible on any device, not just drop cam. 341 00:27:56,410 --> 00:27:59,570 However, we were just kind of curious how far we could take things. 342 00:27:59,870 --> 00:28:07,250 Since physical access is easy enough and there's lots of free space inside the drop cam, it's conceivable to think that someone could add some extra hardware. 343 00:28:08,530 --> 00:28:11,390 Could someone turn this network device into a true cyber weapon? 344 00:28:12,850 --> 00:28:17,670 Most embedded systems contain what are called general purpose input and output, GPIO for short. 345 00:28:18,030 --> 00:28:21,190 What if we use this camera's GPIO pins to control something external? 346 00:28:21,390 --> 00:28:29,210 However, since we don't have a device schematic and toggling random pins is generally kind of frowned upon, we wanted to use a known quantity. 347 00:28:29,210 --> 00:28:33,570 In this case we decided to interface with the drop cam status LED seen circled up above. 348 00:28:33,710 --> 00:28:37,250 The status LED is really just tied to one of the drop cam's GPIO pins. 349 00:28:37,690 --> 00:28:45,250 But we needed a way to do this intelligently because the light comes on randomly and we didn't really want to be setting off whatever we're doing intermittently. 350 00:28:46,070 --> 00:28:48,370 So here's some pseudocode to show what we did. 351 00:28:48,390 --> 00:28:52,470 We figured out how to toggle the status LED at a set frequency, just in a loop up there. 352 00:28:52,830 --> 00:28:57,450 Then we installed a microcontroller to listen for the square wave that we're generating on the LED. 353 00:28:58,270 --> 00:29:00,390 So it's listening for that specific frequency. 354 00:29:00,710 --> 00:29:04,670 And then when the microcontroller gets the frequency it's looking for, something amazing happens. 355 00:29:04,890 --> 00:29:07,570 If your camera starts blinking, get out of the way. 356 00:29:09,890 --> 00:29:11,850 So here's one possible scenario. 357 00:29:11,930 --> 00:29:16,510 Please note that the following was performed in compliance with all local laws and you should not try this at home. 358 00:30:32,430 --> 00:30:34,270 Oh, that's tragic. 359 00:30:42,470 --> 00:30:44,170 Well, that's a wrap. 360 00:30:44,170 --> 00:30:46,490 You probably heard that the Internet of things is blowing up. 361 00:30:46,490 --> 00:30:49,090 So remember you saw it first here at DEF CON 22. 362 00:30:49,870 --> 00:30:52,830 Again, I'm Patrick and this is my coworker Colby. 363 00:30:52,830 --> 00:30:54,350 Feel free to contact us. 364 00:30:54,350 --> 00:30:56,550 We probably won't plug in any devices you send us. 365 00:30:57,370 --> 00:30:58,990 Any questions now? 366 00:30:58,990 --> 00:31:00,150 We have a few extra minutes. 367 00:31:02,430 --> 00:31:03,550 Yes, in the front. 368 00:31:13,200 --> 00:31:13,680 Great. 369 00:31:13,680 --> 00:31:19,260 So the question was, you know, while we're hooking the video and audio stream, did we see any degradation in the performance of the device? 370 00:31:19,440 --> 00:31:30,580 Since we were hooking pretty low level, where the IOPTLs are coming in, we're pretty much just mem copying them off and then putting that in a shared buffer where exfiltrate code would just pick it up and do that. 371 00:31:30,580 --> 00:31:34,400 So in our testing, we didn't see any specific degradation or anything. 372 00:31:34,400 --> 00:31:36,800 And sometimes the video stream goes in and out anyway. 373 00:31:36,940 --> 00:31:39,840 So independent of us. 374 00:31:40,760 --> 00:31:41,840 Any other questions? 375 00:31:45,760 --> 00:31:46,300 Awesome. 376 00:31:46,300 --> 00:31:47,260 Well, thanks again. 377 00:31:47,260 --> 00:31:49,480 Remember, don't trust cameras from strangers.