WEBVTT

00:00.000 --> 00:02.060
So good morning and welcome.

00:02.080 --> 00:05.600
I know this is kind of early Sunday morning, so I really appreciate you guys all being here.

00:06.160 --> 00:09.300
Today we're going to be talking about hacking and implanting a drop cam.

00:10.520 --> 00:13.080
So we both work at the R&D team at Cinec.

00:13.080 --> 00:17.100
Cinec does crowdsource vulnerability discovery with vetted security researchers.

00:17.760 --> 00:18.860
My name is Patrick Wardle.

00:18.860 --> 00:24.640
I've worked at various acronymed places, but currently I'm the director of research at Cinec.

00:25.380 --> 00:26.760
And I'm Colby Moore.

00:26.760 --> 00:31.100
I formerly worked at VRL and currently work at Cinec as a security research engineer.

00:31.680 --> 00:33.880
More like a security ninja, I think.

00:35.840 --> 00:36.240
All right.

00:36.240 --> 00:37.500
So what are we going to talk about today?

00:37.880 --> 00:40.040
First, a brief overview of drop cam.

00:40.500 --> 00:43.340
Then how we got a root shell on the device.

00:44.120 --> 00:47.120
Following that, we're going to talk about some vulnerabilities that we found.

00:47.620 --> 00:52.340
And then finally, we want to present a persistent implant that we designed for drop cam.

00:54.780 --> 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.

01:02.940 --> 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.

01:12.000 --> 01:17.640
So in the talk, when we talk about implants, we're talking about persistent code that is malicious.

01:18.820 --> 01:23.360
Hooking means intercepting function calls, usually by installing a hook or a detour.

01:24.540 --> 01:30.200
A Trojan is a malicious piece of software that pretends to be something legitimate.

01:31.680 --> 01:34.540
Injection is all about getting code into a remote process.

01:35.540 --> 01:41.740
And finally, a backdoor is some code that provides, you know, undetected remote control of the device.

01:41.740 --> 01:43.240
Now, it's a little sad when I hear these terms.

01:43.240 --> 01:45.440
I actually now think of the computer term first.

01:46.400 --> 01:49.440
But my wife likes that, so I guess that's the silver lining there.

01:51.280 --> 01:52.700
So what is a drop cam?

01:52.700 --> 01:57.000
Well, as you can see from their definition, it's a cloud-based video Wi-Fi solution.

01:57.060 --> 02:00.040
And at the core of it is the camera, the actual drop cam device.

02:00.420 --> 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.

02:10.540 --> 02:14.280
Now, one of the main appeals of drop cam is its trivial set-up process.

02:14.480 --> 02:19.980
Really all the camera needs to get set up is the name or SSID and password of your wireless network.

02:20.580 --> 02:21.780
Now, there's two ways to do this.

02:21.780 --> 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.

02:29.200 --> 02:32.500
Now, once the set-up is complete, the camera will be connected to the Wi-Fi network.

02:32.960 --> 02:35.220
From then on, it's pretty much fully autonomous.

02:35.220 --> 02:36.660
You really don't have to worry about it anymore.

02:36.660 --> 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.

02:44.020 --> 02:46.660
So there's a lot of IP-based video solutions out there.

02:46.660 --> 02:48.180
So what's special about drop cam?

02:48.180 --> 02:49.680
Why did we choose to go after it?

02:50.660 --> 02:52.740
Well, now drop cam is owned by Google.

02:52.740 --> 02:56.800
And Google has indicated it will become the core of their push into the connected home.

02:56.920 --> 02:59.060
So in other words, soon there's going to be drop cams everywhere.

03:00.120 --> 03:03.060
Now, when we started this research, we didn't know that Google would buy drop cam.

03:03.060 --> 03:05.820
If we had, we probably would have tried to get hired there, get some equity.

03:05.820 --> 03:07.920
But it was still a pretty appealing target.

03:08.800 --> 03:09.880
For one, it's really popular.

03:09.880 --> 03:12.880
You see all over the Bay Area, it's a best -selling device on Amazon.

03:13.800 --> 03:16.760
Secondly, it shows up in interesting places like homes and offices.

03:17.060 --> 03:20.920
Again, the Bay Area, all the start-ups pretty much use drop cams for their security solutions.

03:20.920 --> 03:22.860
So good target in that point of view.

03:23.180 --> 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.

03:32.460 --> 03:34.400
Now Colby is going to talk about routing a drop cam.

03:35.580 --> 03:40.200
So based on the network footprint, we figured taking a hardware approach would be best .

03:40.200 --> 03:42.440
So naturally the first thing to do was crack the camera open.

03:44.040 --> 03:47.780
Conveniently, drop cam left us this mysterious header right here.

03:48.560 --> 03:53.800
Probing around revealed what looked like a 3.3 volt UART on there.

03:54.380 --> 03:59.340
So we hooked it up to the FTDI to serial to USB connector that you guys are all familiar with.

04:00.120 --> 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.

04:09.100 --> 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.

04:16.180 --> 04:22.140
We wrote a serial brute forcer to try admin, admin, admin password, all the standards, but really no luck.

04:22.660 --> 04:27.540
So at this point we should probably mention the drop cam is running essentially just Linux.

04:27.540 --> 04:28.600
It's a miniature computer.

04:28.720 --> 04:33.200
It's running a Linux system on chip from a company called Ambarella based in the Santa Clara Bay area.

04:33.940 --> 04:39.300
And so, you know, we figured we'd take more of a Linux approach to maybe getting root in this box.

04:40.900 --> 04:42.940
So we decided to go after the boot loader.

04:43.200 --> 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.

04:50.620 --> 04:52.940
Now, this is Ambarella's custom boot loader.

04:54.860 --> 04:58.080
Now, looking at the boot loader, we got a couple options here.

04:58.080 --> 05:00.040
The set EMV one looked pretty promising.

05:00.880 --> 05:03.300
And it looks like there's an option to change the boot parameters.

05:04.120 --> 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.

05:14.640 --> 05:15.780
And yeah, that worked.

05:18.580 --> 05:22.680
So now we got to get rid of that password so we can get on the system, right?

05:23.400 --> 05:27.440
So we checked out Etsy shadow and it wouldn't open.

05:27.440 --> 05:30.520
So it looks like it was SIM linked to mount drop cam shadow.

05:30.720 --> 05:36.380
So we checked out Etsy F stab and it gave us the necessary information we needed to mount up that share.

05:36.660 --> 05:40.720
So we went ahead and mounted it up and now we have access to the shadow file.

05:40.720 --> 05:44.100
I went ahead and just knocked out that hash and saved.

05:44.400 --> 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.

05:53.900 --> 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.

06:03.440 --> 06:06.080
So we're going to talk a little bit about the vulnerabilities that we found.

06:06.900 --> 06:09.100
So first let's talk about the environment.

06:09.100 --> 06:11.780
Since we have a root shell we can now poke around and explore.

06:12.600 --> 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.

06:19.660 --> 06:21.320
We're going to talk about that a lot later.

06:21.520 --> 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.

06:32.160 --> 06:35.440
So overall the drop cam is decently secure.

06:35.440 --> 06:38.440
There were no open ports or exposed network services.

06:38.760 --> 06:41.000
All communications were SSLed properly.

06:42.100 --> 06:45.960
And the drop cam employs device specific provisioning from the factory.

06:46.000 --> 06:50.300
That's likely why we couldn't crack the root password because each device has its own unique password.

06:51.120 --> 06:53.080
It also employs automatic updates.

06:53.080 --> 06:57.540
It beacons out regularly and checks drop cam for updates and they're pushed down and the whole device is reflashed.

06:57.540 --> 06:59.740
So it's pretty robust in that sense.

07:01.060 --> 07:03.280
But let's take a look at the first bug.

07:03.660 --> 07:06.980
The camera is using open SSL for comms to drop cam servers.

07:07.340 --> 07:11.000
But it's running an old version of open SSL so it's vulnerable to heart bleed.

07:12.060 --> 07:14.020
So what can we do with that?

07:15.540 --> 07:21.200
Drop cam says our cameras won't communicate with anyone on the Internet, only drop cam's cloud servers.

07:21.520 --> 07:22.920
But that's not really true.

07:22.920 --> 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.

07:32.400 --> 07:35.440
So realistically now that we have these keys, what can we do?

07:36.040 --> 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.

07:42.580 --> 07:45.800
But you should note that it authenticates using the very same certificates that we stole.

07:46.280 --> 07:53.000
So a hacker with these certs could spoof a drop cam video feed providing false video to the cloud DVR.

07:53.360 --> 07:55.840
So should a user really trust what they're seeing?

07:56.720 --> 08:01.060
For the record, we notified drop cam of this heart bleed bug and they patched it fairly recently.

08:01.260 --> 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.

08:09.320 --> 08:11.880
There's nothing the consumer can really do at this point.

08:13.820 --> 08:17.060
So then for most of its functionality, drop cam runs busy box.

08:17.400 --> 08:20.080
But unfortunately the version is outdated and vulnerable.

08:21.020 --> 08:25.720
Basically it's an old bug that allows command injection via malicious DFCP response.

08:26.060 --> 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.

08:32.720 --> 08:38.000
This is really only triggered if the host name is used by another utility.

08:38.280 --> 08:44.380
But we checked out the vulnerable source code and compared it to the disassembly from drop cam and it definitely matches.

08:45.060 --> 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.

08:54.880 --> 08:58.000
So all those bugs are pretty cool, but we had to open up the camera.

08:58.000 --> 09:00.840
So wouldn't it be nice if we could implant the device without opening it up?

09:01.180 --> 09:03.600
Luckily there's an app for that.

09:05.080 --> 09:10.320
It's called direct USB and we found a copy somewhere in the dark corners of the internet, specifically Russia.

09:11.480 --> 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.

09:22.000 --> 09:24.540
And we believe this is how the devices are provisioned at the factory.

09:24.980 --> 09:28.060
When we questioned drop cam about this, they didn't deny it.

09:28.520 --> 09:31.380
Ultimately we were able to read and write unsigned data to the camera.

09:31.380 --> 09:36.760
So realistically an attacker could walk into the home, plug into a drop cam, reflash with malicious software in minutes.

09:38.440 --> 09:39.480
And back to Patrick.

09:40.320 --> 09:43.640
So there's more to drop cam than just the software that runs on the camera.

09:43.640 --> 09:47.320
So recall that a user may use their computer to initially configure the device.

09:47.520 --> 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.

09:54.900 --> 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.

10:02.600 --> 10:05.120
The end result is a connected and configured camera.

10:07.120 --> 10:10.680
Unfortunately, this application which runs at root is world writable.

10:10.920 --> 10:16.660
So in a proof of concept, a non-privileged host-based attacker can wait until any drop cam is plugged in.

10:17.320 --> 10:22.420
They can then inject a malicious payload into the mounted drop cam setup utility.

10:23.720 --> 10:27.120
Now when the application is run and elevated, so is the attacker's code.

10:27.960 --> 10:33.820
Now the Windows installer setup configuration utility has a similar privilege escalation vulnerability as well.

10:33.820 --> 10:37.280
Drop cam is still patching that so we can't go into details at this time.

10:38.900 --> 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.

10:46.560 --> 10:49.400
However, the same cannot be said for their iOS application.

10:50.660 --> 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.

10:57.400 --> 11:03.380
Now since the drop cam iOS application does not use SSL pinning, a man in the middle attack can occur.

11:04.580 --> 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.

11:15.520 --> 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.

11:20.940 --> 11:24.020
It reveals a username and password for a drop cam account.

11:25.160 --> 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.

11:36.520 --> 11:40.400
Now this is really good for the bad guys, not good for the rest of us.

11:44.730 --> 11:47.710
So now that we have a good way to implant the camera, let's have some fun.

11:48.090 --> 11:50.870
Introducing our full featured implant, cuckoo's egg.

11:51.030 --> 11:55.210
For those who are unaware, the cuckoo lays its egg in other nests.

11:57.810 --> 11:59.390
See how many you guys get it.

12:00.210 --> 12:03.730
Given the robust capability of the drop cam, our malicious software should.

12:04.370 --> 12:06.610
C, we want to be able to intercept video.

12:06.750 --> 12:08.510
Here, we want to hot mic a room.

12:09.170 --> 12:12.970
Propagate, we want to infect other hosts when they connect to the drop cam or it's plugged in.

12:13.430 --> 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.

12:18.050 --> 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.

12:23.490 --> 12:25.750
We want to be able to drop to a command shell to use our tools.

12:26.250 --> 12:29.790
And we want to be able to connect a basic network survey and a device survey.

12:31.350 --> 12:35.750
So conceptually the drop cam will sit on a corporate network and talk out to the drop cam's cloud.

12:36.390 --> 12:39.290
But with our implant, it will also talk out to us.

12:39.750 --> 12:42.750
We also need a method for other devices on the drop cam's network.

12:44.010 --> 12:46.170
We also need a method, sorry.

12:49.170 --> 12:49.570
What?

12:52.290 --> 12:53.090
Okay.

12:53.470 --> 12:54.170
Well, anyway.

12:54.410 --> 12:57.870
So our implant even comes with its own slogan.

12:58.030 --> 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.

13:07.940 --> 13:11.460
So in a real world scenario, how do we install our malicious software?

13:11.540 --> 13:14.780
We don't have remote code execution but there's a lot of options.

13:15.100 --> 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.

13:28.120 --> 13:30.240
Realistically that stuff never happens, right?

13:30.920 --> 13:32.200
No further comment.

13:32.920 --> 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.

13:39.240 --> 13:43.680
And that alone would be an appropriate anti tamper mechanism.

13:43.840 --> 13:44.940
What do you guys think?

13:49.610 --> 13:51.490
Now what about sending one as a gift?

13:51.650 --> 13:53.990
Recently a friend's incubator space was broken into.

13:54.170 --> 13:57.910
Is it too far-fetched to think that management might send them security cameras to implement?

13:58.210 --> 13:59.250
Probably not.

14:00.930 --> 14:03.030
Is a break in entering scenario really plausible?

14:03.270 --> 14:03.950
Maybe.

14:04.290 --> 14:06.810
Drop cam's argument was that you would see an attacker coming.

14:06.810 --> 14:10.110
However, only one third of users sign up for drop cam's cloud recording.

14:10.470 --> 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.

14:17.210 --> 14:19.010
Now what makes drop cam a good target?

14:20.010 --> 14:24.090
The drop cam CEO said all software products are susceptible to jail breaking.

14:24.090 --> 14:24.530
And that's true.

14:24.530 --> 14:25.710
We tend to agree with that.

14:25.790 --> 14:27.710
But the drop cam really is the low hanging fruit.

14:28.290 --> 14:29.470
Here are the other options.

14:32.600 --> 14:37.700
Someone could go after a computer that often has full disk crypto, boot password and there's no forensic tools.

14:38.240 --> 14:40.820
They could go after a printer but it runs a proprietary operating system.

14:40.820 --> 14:41.900
You've got to crack it open.

14:41.900 --> 14:43.720
A printer can't see, can't hear.

14:43.720 --> 14:45.100
There's a lot of things it can't do.

14:45.840 --> 14:50.000
They could go after a gaming console but again, it runs sign code and has DRM protection.

14:50.000 --> 14:52.660
You've got to crack it open and it's generally turned off.

14:53.380 --> 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.

14:59.880 --> 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.

15:19.650 --> 15:24.590
So in order to create an advanced implant, we needed to fully understand how the drop cam worked.

15:25.410 --> 15:30.170
In other words, we had to answer questions such as how does it hear, see or think?

15:30.370 --> 15:33.530
Where is its core logic, the main module of the brain?

15:33.590 --> 15:36.410
And finally, can this be manipulated or rewired?

15:37.810 --> 15:40.970
The drop cam has many hardware and software components.

15:41.370 --> 15:45.090
However, these all kind of come together in the connect binary, which I'll be talking about a lot.

15:45.270 --> 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.

16:01.810 --> 16:06.290
Unfortunately, the connect binary is packed with UPX, which is not normally a problem.

16:06.330 --> 16:08.750
Unfortunately, when we tried to unpack it, it failed.

16:09.930 --> 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.

16:19.770 --> 16:25.030
Now, the unpacker stub matched the UPX source code, indicating it wasn't a custom version of UPX.

16:25.210 --> 16:30.630
So we figured perhaps the binary was perhaps modified after the fact in some way to prevent unpacking.

16:31.830 --> 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.

16:38.150 --> 16:41.410
But this revealed exactly where the unpacking exception occurred.

16:42.030 --> 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.

16:49.450 --> 16:51.390
That unfortunately then errored out.

16:52.770 --> 16:55.290
Now, connect is a normal ELF executable.

16:55.290 --> 16:56.530
It's not a shared library.

16:56.530 --> 16:59.270
So I was a little confused why I was taking this code path.

16:59.350 --> 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.

17:07.310 --> 17:11.870
Once we did this, we then re-invoked UPX to attempt to unpack the binary and that worked.

17:11.870 --> 17:15.270
Connect was fully unpacked and even fully runnable, which is really nice.

17:16.290 --> 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.

17:22.510 --> 17:24.110
So I guess thanks to Dropcam for that.

17:28.050 --> 17:31.650
So now that we've talked about all these cool capabilities, let's talk about the core of our implant.

17:31.950 --> 17:38.170
We wanted to create something simple, portable to other devices and have the ability to leverage third-party libraries.

17:39.050 --> 17:42.330
So since we don't have to be too stealthy, Python seemed like a natural choice.

17:43.770 --> 17:46.590
We cross-compiled and stripped down Python to reduce the disk footprint.

17:47.490 --> 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.

17:58.620 --> 18:02.360
It's great that we have an implanted camera and all, but how is it going to talk to us?

18:03.300 --> 18:07.600
All comms are done over HTTPS and call out through the secure networks firewall.

18:08.100 --> 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.

18:16.420 --> 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.

18:30.800 --> 18:32.260
Which connection is legit?

18:34.440 --> 18:37.440
What about if we wanted to ship a ton of these cameras out in the wild?

18:37.920 --> 18:39.280
How will we know where they end up?

18:40.160 --> 18:44.520
Cuckoo's egg runs a camera side Wi-Fi survey and ships it back to the CNC server.

18:44.780 --> 18:51.420
The CNC server then sends the survey back to Google's geolocation APIs and returns the device location.

18:51.820 --> 18:52.680
Thanks, Google.

18:57.960 --> 19:02.780
We also wanted our implant to autonomously propagate to Windows or Mac-based computers.

19:03.660 --> 19:08.120
Since we control the camera, we actually control the set-up application as well.

19:08.460 --> 19:11.280
So we simply replace it with a malicious implant installer.

19:11.980 --> 19:18.280
Now, whenever the user runs the implant or the set-up application, they're actually running the implant installer first.

19:18.280 --> 19:20.240
And that's executed with root privileges.

19:21.140 --> 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.

19:28.060 --> 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.

19:41.580 --> 19:44.920
So Apple loves to tout their many anti-malware mitigations.

19:44.960 --> 19:51.840
However, some of these are trivially bypassed while others can be avoided altogether, which allows our implant to execute freely.

19:51.840 --> 19:53.080
It's not detected at all.

19:53.320 --> 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.

20:04.000 --> 20:14.380
This talk describes bypasses for XProtect, which is Apple's antivirus product, Gatekeeper, the OSX sandbox, and even signed coding requirements.

20:14.380 --> 20:18.400
For example, it's able to load unsigned kernel module into the kernel.

20:18.400 --> 20:19.880
So sorry, Apple.

20:22.380 --> 20:27.300
Now a major component of our implant is the ability to grab and manipulate audio and video.

20:28.420 --> 20:33.320
Now I mentioned the Kinect binary talks to both the audio and video cards that reside in kernel mode.

20:33.720 --> 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.

20:41.020 --> 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.

20:47.120 --> 20:53.420
Since the Kinect binary exclusively opens the audio card, we have to inject a module into the Kinect process.

20:54.380 --> 20:56.660
So here are the various relevant components.

20:56.840 --> 21:00.180
The Kinect binary is continually reading the audio stream.

21:00.840 --> 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.

21:11.340 --> 21:15.480
Now DropCam uses a standard Linux framework to read audio, which is kind of cool.

21:15.580 --> 21:23.700
So to get the audio, it invokes the send PCM read end function, which retrieves audio frames containing audio buffers.

21:23.780 --> 21:26.380
This is where the implant installs its audio hook.

21:27.340 --> 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.

21:36.680 --> 21:40.940
So here is the code that is inserted as an audio hook.

21:40.980 --> 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.

21:49.620 --> 21:50.620
So pretty straightforward.

21:52.700 --> 21:53.200
All right.

21:53.200 --> 21:54.280
Now on to video.

21:54.720 --> 22:01.300
So by disassembling the Kinect binary, we were able to uncover how the camera accesses and streams video to the cloud.

22:02.520 --> 22:07.880
In the disassembly, you can see it opening the video device, which is slash dev slash IAV.

22:07.920 --> 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.

22:17.420 --> 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.

22:25.000 --> 22:28.620
The eye octals are all undocumented and many take undocumented structures.

22:28.620 --> 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.

22:40.120 --> 22:44.260
So I mentioned we wanted to clone the video and stream it to the implant servers.

22:44.940 --> 22:50.820
Now, undocumented eye octals and structures result in a ton of reverse engineering and a ton of seg faults.

22:51.140 --> 22:55.400
However, we eventually got it all figured out and we wanted to describe that here.

22:56.040 --> 22:59.900
So first you open the slash dev slash IAV device.

23:00.020 --> 23:04.600
Then you get the H264 encoding parameter so that the stream you exfil can be decoded.

23:05.240 --> 23:11.200
You then map the bit stream buffer memory and the digital signal processor memory.

23:12.000 --> 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.

23:22.200 --> 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.

23:30.300 --> 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.

23:38.000 --> 23:39.240
So that's kind of a cool feature.

23:39.300 --> 23:40.740
I don't want Google seeing what I'm up to.

23:42.880 --> 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.

23:49.140 --> 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.

24:00.740 --> 24:03.180
So again, here are the various relevant components.

24:04.100 --> 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.

24:11.000 --> 24:12.540
So we really don't want that.

24:13.320 --> 24:18.820
However, the injected module will intercept these frames and inject other frames.

24:19.320 --> 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.

24:27.760 --> 24:29.820
So take a little bit of a closer look.

24:30.260 --> 24:34.760
Here's the video device and the connect binary which is reading frames.

24:35.720 --> 24:37.720
The injected module installs another hook.

24:37.720 --> 24:44.580
This time it's an IOCTL hook and watches for the IOC read bit streams EX IOCTL.

24:45.660 --> 24:50.720
Now when this IOCTL is called, it populates a structure with various values.

24:50.840 --> 24:54.760
Through reverse engineering, we were able to determine what these values were.

24:55.240 --> 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.

25:07.520 --> 25:12.580
Now the easiest way to manipulate the video stream is just to wait for a frame type of JPEG full.

25:12.620 --> 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.

25:20.380 --> 25:25.440
The other frames are not ideal because H26 encoding pretty much just encodes deltas.

25:25.440 --> 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.

25:30.260 --> 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.

25:37.340 --> 25:37.720
All right.

25:37.720 --> 25:39.020
So video demo time.

25:39.020 --> 25:42.160
I wanted to show you how we can transparently lock the video stream.

25:42.160 --> 25:45.020
If you look at the top left is the drop cam feed.

25:45.020 --> 25:48.200
So this is what the user is going to see and this is what we are manipulating.

25:48.580 --> 25:51.120
The top right is a shot from an external camera.

25:51.240 --> 25:55.620
Bottom left is the sys log output and bottom right is the attacker's console.

25:56.540 --> 25:56.980
All right.

25:56.980 --> 25:59.600
So you see a mom coming to tuck her kid in.

26:01.260 --> 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.

26:08.700 --> 26:15.320
We then see... an attacker that somehow looks like Colby.

26:15.320 --> 26:16.940
Got to work on your disguises.

26:17.680 --> 26:19.560
The video now is locked to frame.

26:19.560 --> 26:23.020
It's injecting these JPEG full frames in so the video is frozen.

26:23.020 --> 26:27.220
But you can see the camera is still counting up so the user is not going to notice.

26:27.600 --> 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.

26:35.360 --> 26:38.460
Now, I'm sure the mom is going to accept this child as one of their own.

26:41.660 --> 26:45.460
Well... apparently not.

26:55.990 --> 26:56.510
All right.

26:56.510 --> 26:57.290
Back to Colby.

26:57.930 --> 26:58.570
All right.

26:58.570 --> 27:02.010
So we built this awesome implant that does everything an attacker could dream of.

27:07.990 --> 27:10.350
But how do we control it?

27:11.090 --> 27:14.010
So naturally a sleek web control panel is needed.

27:14.370 --> 27:19.010
On the main screen all the cameras call back with their name and location so targeting is super easy.

27:19.930 --> 27:23.930
From there it's easy to select a target and a job to be sent down to the drop cam.

27:23.930 --> 27:26.810
We support all the commands we talked about previously.

27:27.710 --> 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.

27:34.650 --> 27:40.130
We have a series of completed and unsent jobs.

27:40.310 --> 27:44.570
Queued up is an execute and execute task whereas there are several completed surveys.

27:44.570 --> 27:47.010
Results are reported in a convenient JSON format.

27:48.810 --> 27:51.450
For this next part we need a bit of disclaimer.

27:51.450 --> 27:56.210
The stuff we're about to do is theoretically possible on any device, not just drop cam.

27:56.410 --> 27:59.570
However, we were just kind of curious how far we could take things.

27:59.870 --> 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.

28:08.530 --> 28:11.390
Could someone turn this network device into a true cyber weapon?

28:12.850 --> 28:17.670
Most embedded systems contain what are called general purpose input and output, GPIO for short.

28:18.030 --> 28:21.190
What if we use this camera's GPIO pins to control something external?

28:21.390 --> 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.

28:29.210 --> 28:33.570
In this case we decided to interface with the drop cam status LED seen circled up above.

28:33.710 --> 28:37.250
The status LED is really just tied to one of the drop cam's GPIO pins.

28:37.690 --> 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.

28:46.070 --> 28:48.370
So here's some pseudocode to show what we did.

28:48.390 --> 28:52.470
We figured out how to toggle the status LED at a set frequency, just in a loop up there.

28:52.830 --> 28:57.450
Then we installed a microcontroller to listen for the square wave that we're generating on the LED.

28:58.270 --> 29:00.390
So it's listening for that specific frequency.

29:00.710 --> 29:04.670
And then when the microcontroller gets the frequency it's looking for, something amazing happens.

29:04.890 --> 29:07.570
If your camera starts blinking, get out of the way.

29:09.890 --> 29:11.850
So here's one possible scenario.

29:11.930 --> 29:16.510
Please note that the following was performed in compliance with all local laws and you should not try this at home.

30:32.430 --> 30:34.270
Oh, that's tragic.

30:42.470 --> 30:44.170
Well, that's a wrap.

30:44.170 --> 30:46.490
You probably heard that the Internet of things is blowing up.

30:46.490 --> 30:49.090
So remember you saw it first here at DEF CON 22.

30:49.870 --> 30:52.830
Again, I'm Patrick and this is my coworker Colby.

30:52.830 --> 30:54.350
Feel free to contact us.

30:54.350 --> 30:56.550
We probably won't plug in any devices you send us.

30:57.370 --> 30:58.990
Any questions now?

30:58.990 --> 31:00.150
We have a few extra minutes.

31:02.430 --> 31:03.550
Yes, in the front.

31:13.200 --> 31:13.680
Great.

31:13.680 --> 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?

31:19.440 --> 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.

31:30.580 --> 31:34.400
So in our testing, we didn't see any specific degradation or anything.

31:34.400 --> 31:36.800
And sometimes the video stream goes in and out anyway.

31:36.940 --> 31:39.840
So independent of us.

31:40.760 --> 31:41.840
Any other questions?

31:45.760 --> 31:46.300
Awesome.

31:46.300 --> 31:47.260
Well, thanks again.

31:47.260 --> 31:49.480
Remember, don't trust cameras from strangers.

