start	end	text
0	5620	Good morning, DEF CON. We are going to be hacking some baby monitors and Wi-Fi cameras today.
6680	10280	So, a little bit about me. My name is Mark Mager. I'm senior manager of security research at
10280	14560	Elastic. My background is primarily in Windows malware research and reverse engineering.
15720	21800	So, what do we need to know about Wi-Fi cameras and baby monitors today? Basically, we're going
21800	25660	to assume they're the exact same thing because they pretty much have the same feature set.
25660	31940	They're literally marketed and sold as equivalent devices. So, what we're talking about is the
31940	39920	$10 cameras you can find on Amazon that require internet connectivity to that specific vendor's
39920	45480	cloud platform. And there's very basic operations, pan, tilt, zoom, things along those lines,
45480	50320	motion detection, whatever. But yeah, that's what we're talking about when we say Wi-Fi cameras for
50320	58200	today. So, why Wi-Fi cameras? Well, there's literally almost 125 million households across
58200	64860	the world that have these cameras installed within their house. So, these things are everywhere.
65160	69820	And they're obviously going anywhere and they're super cheap. So, you're going to find them
69820	74620	everywhere. The attacks that are typically associated with these cameras, what you're
74620	81600	probably going to hear about usually is people spying on babies and families, terrorizing them,
81600	87080	that sort of thing. A bit upsetting there. And even things like Russians performing
88440	96220	reconnaissance on targets within Ukraine. So, when we set out to evaluate the attack
96220	100660	surface for Wi-Fi cameras, we wanted to break things down into a few different
100660	107040	common attack vectors that broke down primarily into leak credentials and cloud vulnerabilities.
107320	113720	Those seem to be the most common attack vectors, the most frequently seen ones
115360	121580	in more of the attacks that we kind of see across the board. But yeah, so, kind of focusing on those
121580	128920	two, that's certainly what we wanted to kind of dig into was any vulnerabilities specific to
128920	136560	the cloud platforms, the applications that control the cameras, and the camera hardware itself.
139500	145380	Hello, DEF CON. I'm Eric Forte and I'm doing the presentation with Mark. And I'm a security
145380	149860	research engineer at Elastic. I'm on the Threat Research and Detection Engineering team, otherwise
149860	156460	known as TRADE. And my background is in Linux software development, IoT systems, UAVs, civil
156460	162180	space sector, and then also doing some threat research. And so when we're talking about these
162180	166700	cameras, for the purposes of this talk, we looked at a number of different cameras, but we're
166700	173780	going to primarily focus on the WandsView Q5 and the WandsView Q6. And as far as why we picked
173780	180180	these cameras, it was sort of clear to see on the Amazon reviews that they might have something for
180180	184720	us to look at, some vulnerabilities that other people had just come across because they were
185360	193700	readily hacked enough that it took notice. So these cameras are made by WandsView, but there
193700	199440	are other vendors that also produce cameras, such as Sonado and some others as well, which we'll
199440	205420	touch on a little bit more in a little bit. But they're primarily under the AJ Cloud management
205420	212260	infrastructure. And so this is going to be the cloud services that provide you with the apps,
212260	217160	with the way of connecting to it. So the WandsView versus Sonado versus others may have
217160	221780	their own little differences in the apps themselves. But primarily, this cloud interface
221780	228320	is with AJ Cloud, and we'll get into a lot more of that in a minute. So when we were first with
228320	232720	these cameras, we kind of looked at a few different approaches for how we were going to try and
232720	238620	see if we could get some of those similar Amazon review results. So first, we were looking at
238620	243280	remote access. So this is going to be accessing the camera through whatever companion app that
243280	248900	ships with the camera. We also were going to look at some local attacks. So going to be some active
248900	253960	and passive networking recon, in addition to seeing what else other services and things were
253960	260100	running there. Also looking at some device physical manipulation, which obviously these
260100	266080	are Wi-Fi cameras. They're not necessarily like closed circuit TV cameras. So we're expecting that
266080	270280	there's going to be some physical attacks, which there are. We'll get to that. But
271140	278220	this is still, again, as an attack vector, can enable some other aspects. Then finally, looking at
278220	283500	the hardware itself. So looking at the chip and seeing what we can use, what we can either get
283500	288040	the firmware off, what we can do to kind of, again, extend that vulnerability process, look for
288040	294560	serial communications and things like that. Which, spoiler alert, we found some over UART.
294560	299880	So for our lab setup, we have a number of different things that we wanted to look at,
299880	304520	right? So we've got different apps. So we want to have a very controlled environment,
304520	309140	because we know, say, one, they're easy to hack. So we don't want to be hacked ourselves.
309140	315520	But on top of that, we know as these are largely, say, Chinese make cameras, that they may also want
315520	321280	to be watching what we're doing. So we wanted to have a completely different setup. And so we have
321580	326600	a mobile hotspot. I like the T-Mobile T9s. They're cheap. You can get them for about 20 bucks, and
326600	332860	they do the job great. We have the camera, of course, itself. Then we needed, say, Windows and
332860	337000	Linux operating systems. You don't actually need Linux, except I would argue that you do. But
337620	342880	practically speaking, you don't need Linux to be able to run any of these things. But we used that.
342880	349580	But we did need Windows to also look at the companion Windows app, in addition to the iOS
349580	356440	and Android apps, which we had phones and virtual machines set up for as well. From a software side,
356440	361800	we use a number of different tools, including, say, Wireshark, running Android Studio to try
361800	366600	and see what we could find out from the app, various other sort of decompiling mechanisms,
366600	373340	and also using the Elastic Stack to look at the network communication logs and how we can parse
373340	379560	some of the different protocols that we saw. And we will, again, we'll talk to that more in a
379560	385420	some peer-to-peer traffic there. From a hardware standpoint, since we wanted to do the full gamut
385420	391400	of going from complete hardware takedown as well as looking at all the software, we had some hardware
391400	397720	teardown tools. I like what iFixit has, but of course you can take your pick. Then we needed
397720	404580	some USB TTY connector, right? So in this case, you know, it's just your typical Adafruit USB TTY
404580	411700	serial connector there. We also have a, and we'll get to it more in a minute, but using the GreatFET
411700	418080	1 as a logic analyzer, and to be able to read voltages and things like that in case we needed
418080	423060	to actually hard pull something off of the chip, solder something or things like that. Ultimately,
423060	429240	we didn't need to do that, but we were prepared for that nonetheless. Raspberry Pi, because it's
429240	436680	image and distribute, so for doing cross compilation and things like that, cheap,
436680	445740	easy to come by. And then also, we used Alpha Wi-Fi, just a USB Wi-Fi NIC, which for us,
445740	451440	why this was important and why you'll need some NIC that you can get active, or rather passive
451440	457260	sniffing on, is because you're going to want to capture all of the traffic going from the camera
457260	462740	to the cloud, and not just what will appear as network traffic, and we'll get to that in a little
462740	467800	bit, because you're going to, to follow along, you'll need to parse some other additional
467800	473600	protocols. So, getting a little bit into our remote and local recon, initial attacks were
473600	479440	limited. They had a fairly locked down attack surface. The active network and local reconnaissance
479440	485000	doesn't reveal too much or too much interesting as far as running on the traffic, or rather running
485000	491980	on the camera. The network traffic itself is fairly mundane. It uses encrypted web sockets,
491980	495920	which is a good sign, right, that they are at least using encryption, things like that.
496560	501420	So, we tried to do some man-in-the-middle attacks, but ultimately, we weren't particularly
501420	506920	successful with that. Looking at the apps themselves, they were likely obfuscated with
506920	513600	ProGuard. We couldn't, just from the, from being, unpacking the APK, get too far there.
514520	520340	But, so those APKs were just not easily that debuggable. But just as a quick note,
520340	524620	ultimately, there's three lines of communication. We're going from the mobile app to the cloud,
524620	528840	the mobile app to the camera, and then also from the camera to the cloud, and then the mobile app.
528840	533120	And that, just as a sort of primer, we'll get into that more in a little bit.
533920	539720	Just as far as the physical device itself, again, we weren't really expecting it to be that secure.
539720	544800	It has an exposed reset button, so if you had this sitting, like, let's say, up here on stage,
544800	549320	if you were to walk by, hit the reset button, and then flash a QR code, you could steal the camera,
549320	553640	and then now it's yours. You have full control over it. Again, that's not particularly surprising,
553640	563100	because that's part of the expected setup process. So, in that sense, there's no,
563100	569500	so there's also an exposed SD card slot. So, as we came to discover later, this can be used to
569500	573660	load alternative firmware as well. We'll get into what the bootloader looks like in a minute, too,
573660	578960	but this, if you were to craft a malicious SD card, you could go plug it into the camera,
578960	584340	and then also have a field day there, too. The hardware recon starts to get a little bit more
584340	592180	interesting. So, when we look at the chip, it's an Experse T31 SoC. It's primarily a MIPS processor,
592180	597200	but it also has a companion RISC-V processor. But the primary thing I want you to focus on,
597200	604480	for the sake of the demonstration, is that we have an I2C and UART bus that we should,
604480	611760	could be looking for, right, on the hardware, on the chip itself. We also have a secure boot,
611760	616160	which may, you know, that could throw a wrench into things. And then we also have a hardware
616160	620600	watchdog supported by this chip. Doesn't necessarily mean they're using it, but again,
620600	626340	these are things that we can look for in our hardware recon. So, in tearing down hard the
626340	634980	camera, we found a potential UART, UN access ports there. And so we connected a logic analyzer,
634980	642320	the great FET1, looked at the voltages, used some of the protocol detection, saw that it appears to
642320	650880	be UART. And if we look at the actual signal, we saw that it indeed was. So, we go ahead and
650880	655980	use screen, but you can use, again, whatever your favorite tool is to connect over default
655980	664320	baud rate to UART. And lo and behold, on boot, we have UBOOT. So that, of course, is useful for us.
664320	669800	But also, we, in further expecting this, that secure boot is not enabled by default, as far
669800	676100	on the camera, even though the chip supports it. So, we can just do a quick boot into single user
676100	680500	mode and get a root shell so that we can start poking around further. Now, this camera was
680500	687220	particularly easy to do this because you could just straight set the environment variables for
687220	691420	UBOOT to be able to boot into single user mode and get root. Other cameras that we looked at
691420	695540	were not as simple as this. And sometimes you have to use memory offsets and things like that,
695540	701900	but this one in particular was fairly straightforward. So, again, we can hit boot
701900	706980	and then just drop into our root shell and then be able to poke around on the camera.
707060	712600	So, now that we're there, a few things that we want to then do to go forward. First off,
712600	717480	we may want to try and establish persistence. But if you've done this type of attack before,
717480	722500	going to single user mode, especially on embedded devices, and just embedded devices in general,
722500	727940	you might see that you're on a read-only file system. Well, many times this is only read-only
727940	735700	ish. It's not quite truly read-only. So, if we take a look at fstab, we can see that a number
735700	744120	of these mount points are separated, but then also they are tempfs shares. So, we can then
744980	751440	make our own tempfs partition or just mount a tempfs partition for read-write access,
751440	756420	modify the desired settings, and we can run whatever we want, of course, and have persistence.
756480	762140	Which, largely, for these type of devices, you will need this type of interface, whether it be
762140	768060	for... there's other methods for logging, but again, when Linux is running, it often needs to
768060	772500	be able to make some level modifications. So, this is just walking through one way of doing that,
772500	778900	of saying, hey, I want to create a tempfs share for dev, and then go ahead and mount it,
778900	786860	and then also then mount Etsy, such that I can make Etsy read-write as well, which, of course,
786860	793560	gives us access to some other things. And so, just demonstrating there that if I run... that
793560	799480	if I just create a file, then it does, in fact, show up, as opposed to when it didn't before.
799620	803200	So, if you want... so, that's just one way, of course, then you can go and do whatever you want
803200	808640	from that perspective. But if you want to go log into the existing root user, of course, you can
808640	815340	pull Etsy password, and then go and just use John the Ripper or something to crack that hash,
815340	820800	and go from there. But for our purposes, again, we want to keep looking for the other software
820800	826220	vulnerabilities. So, this gives us an easy way to pull the firmware over the serial connection.
826420	831000	So, we... and in addition to the firmware, we're pulling a JFS to read-write partition containing
831000	837100	any log data, again, just might be useful for us. So, this is just demonstrating how you can... one
837100	841480	way of pulling the firmware. There are a number of different ways, but this is just how we did it
843480	848220	using... using binwalk, and then, of course, just echoing the bytes out in the appropriate format
848220	853420	over the serial connection. So, with that, I'm going to hand it over to Mark to see what he did
853420	861500	with the firmware. All right. So, as Eric mentioned earlier, we definitely were running into issues
862060	868080	with the iOS and Android apps for WandsView specifically, right? So, we're hitting our
868080	873000	heads against the wall a little bit. So, we kind of backed things up a little bit and went directly
873000	879660	to WandsView's site, and they host a version of WandsView Cloud that is for older versions of
879660	885520	Windows. I think it says Windows 7 specifically on their site. But the main takeaways from that
885520	891300	is that that app is still compatible with all WandsView devices. It does have a limited feature
891300	896680	set. I mean, they're still trying to push you towards using the apps. You know, that's totally,
896680	902000	you know, their sort of thing because they want everybody to sign up for their cloud plan so they
902000	908460	can make more money off of everybody, not just the $10 sales, you know, from the device itself,
908460	915000	right? A couple other things related to that, this Windows app, is it does generate a significantly
915000	920680	less amount of network traffic. That's going to come in handy later. And the binaries are not
920680	928580	packed. Eric mentioned that the APKs look like they're probably packed with ProGuard. So, you
928580	934740	know, definitely being able to disassemble and decompile and debug pretty easily. That helps
934740	941640	out quite a bit. And then last, but certainly not least, is that it does generate a very, very
941640	948100	verbose debug log file, which I'm going to dig into right now. And the first thing we noticed
948100	954540	when we ran it the first time, it logs user account credentials in clear text. That's obviously
954540	962880	terrible. So, yeah, not a great sign of things. And as Eric mentioned before, we had significant
962880	968000	difficulties trying to man the middle of any of the app traffic before, so we had no visibility
968000	977320	into that. But helpfully, their developers decided to actually log all post request and response data
977320	981480	so it's all there in the clear. Who needs to man the middle of anything when you have it in the
981480	989700	clear on a file on disk? So, yeah. So, digging into it, yeah, we could definitely get a ton of
989700	997180	insight into the sign-on process that we did not have before, including the actual endpoint APIs,
997180	1007300	as well as, you know, all the fields that are involved both in the requests and responses. So,
1007300	1015260	it's not really a ton there. It's more just initial setup. This check is more just to see
1015260	1021860	if this is a valid account that you're attempting to sign on. And then this here is where the actual,
1021860	1027300	let's see, yeah, is an initial account where, but, yeah, challenge involved where
1028020	1033820	the token's generated for that specific client application, and then there's a little bit of
1033820	1039400	key exchange that happens. But, yeah, not too much else going on there. This is where the sign-on
1039400	1044360	really begins. Assaulted and, yeah, your password is at least assaulted and hashed, so it's not
1044360	1051880	set in the clear, thank God. And then, yeah, I mean, it's mostly just to initialize the session
1051880	1058720	and to confirm that you are allowed to log into this account. From there, we, things really start
1058720	1065160	to get interesting because now we can, now that we're logged in, we can request a list of devices
1065160	1070360	that are associated with that specific account. And as you can see here, there's a specific device
1070360	1076480	ID, along with some more configuration information, primarily endpoint URIs.
1078080	1087340	And then there's another device configuration API endpoint that's hit. This is very notable,
1087340	1092340	we're going to refer back to this later, but this is where a device ID is first transmitted
1092340	1101780	from the application to the cloud. And, you know, more configuration information comes through.
1101980	1109120	We'll dig into that a bit. And then the last request we really dig into is fetch infos. And
1109120	1119700	this provides a much, much larger picture of the data that is stored for that specific device.
1119700	1126200	And there's a lot to kind of dig into, but what you'll want to really highlight on is there's a
1126200	1131980	snapshot URL that's provided. And that just happens to be publicly accessible. And that's
1132040	1141680	a picture of my kitchen. So from back in April. So digging further into more of the response data,
1141680	1148560	there's a few things certainly to note here that are a bit concerning, right? The firmware version,
1148560	1155360	the very specific firmware version that is running on the device itself, that's referenced there,
1155360	1161180	along with the next firmware version they're supposed to upgrade to, along with the actual SSID
1161700	1167520	that the device is currently signed onto, along with some other network configuration information
1167520	1174560	including its MAC address. And then we also have, you know, geolocation data, you know, in the form
1174560	1183360	of, you know, time zone data and things like that. So going back to the device configuration request,
1184060	1189640	what we tried to do first is we wanted to see if we could actually access other devices that
1189640	1196220	weren't associated with our particular account. So we tried a very naive approach where all we
1196220	1203440	wanted to do was simply just replace the device ID in that particular request. And without really
1203440	1208060	doing a significant amount of reverse engineering, we can locate that pretty easily based off of the
1208060	1213940	verbose log data because if we just look up post request, we can, you know, we can see how many
1213940	1220360	times that's specifically logged to the log file. And then we can cross-reference that with
1221480	1228500	the disassembly in IDA in order to target the specific device configuration post request
1229190	1235860	to get a better idea of where we would want to jump in. And so digging further into the particular
1235860	1242720	function, what we decided to do is we needed to set a breakpoint at this particular address, which
1242720	1250680	would be before the post request actually goes out, before the JSON is fully formed as well.
1251040	1255060	You know, we're going to swap out the device IDs and memory and then resume execution. So pretty
1255060	1261940	straightforward. What this ends up kind of looking like is, you know, I wrote up maybe a 60-line
1262480	1267560	Python script that does this all for us, which we will dig into right now.
1268510	1278680	Okay, so what we have right here is, well, first I'll demonstrate that this account is...
1283620	1297540	So we already have one specific camera that is tied to this account. And it's offline at the
1297540	1302980	moment, so it's not really concerning that, right? We'll attempt to connect to it, but nothing's going to happen.
1312710	1316670	Now, if we kick off the exploit script, what it's going to do is it's going to launch
1317190	1324610	the same WandsView cloud for Windows app. We'll proceed to sign in as expected.
1327030	1335710	And once we hit our breakpoint, we will swap out the device ID in memory. And then once it
1335710	1354720	has finished here, it will resume execution. And we're online. So the thing is...
1359660	1364340	So yeah, we can do everything in the app. We can pan and tilt.
1366080	1370620	Yeah, I mean, like I said, it is a bit more limited feature set compared to
1370620	1379340	the mobile apps. But basically, right, we've proven we can get access to an account or a device that's
1379340	1386820	not associated with our account. It's obviously a very, very significant access control vulnerability.
1388000	1395200	So yeah, you know, certainly that was a pretty big discovery, you know, right off the bat.
1398960	1402960	So you might have seen in the background that there was, you know, certainly a lot of
1402960	1408700	network traffic being generated in the background. It was all primarily UDP,
1409200	1415440	but we hadn't really no idea what it is in particular. Now, doing research before
1415440	1423480	we submitted to DEF CON, we did come across a particular IoT peer-to-peer protocol called PPPP
1424300	1432380	that was pretty significantly researched and detailed by Polymer PC. His website,
1432380	1439280	he presented at DEF CON 28 in 2020, fully tearing down the protocol and all that. So
1439840	1445260	ideally, this was going to be something that, you know, maybe that was going to be in use here too.
1445260	1452840	So we kind of set out to explore that by just looking for references to P2P and PPPPP. And yeah,
1452840	1460280	sure enough, within the Wandscape Cloud binary itself, as well as the DLLs, we found, you know,
1460280	1467120	numerous references, even references to their specific PDBs, which reference both, you know,
1467120	1472960	multiple peer-to-peer terms. So yeah, we're pretty sure that we're dealing with the same
1472960	1480080	protocol. And going from there then, there is a excellent dissector for this peer-to-peer
1480080	1486340	protocol that is available and posted on GitHub as of last year. You know, we load it in and all
1486340	1492420	of a sudden that UDP traffic, we have no idea what it is, turns into a very recognizable messaging
1492420	1498960	sequence that's associated with peer-to-peer. So very, very briefly, the peer-to-peer protocol
1498960	1506420	is used by a ton of IoT devices across hundreds of vendors. It's been in use for, you know,
1506420	1511140	the better part of the last decade, if not longer. It uses UDP hole punching in order
1511140	1518200	to circumvent restrictive network configurations. And it allows you, you know, these apps to connect
1518200	1522600	to the cameras from anywhere in the world, right? They want it to be as accessible as possible,
1522600	1526780	right? That's the whole point of these devices. And yeah, sometimes the connections are either
1527460	1531000	direct to the camera, depending on the configuration, or they go through a relay
1531000	1536320	if they have to, you know, get around certain restrictions.
1541320	1548100	So now we have established some initial access, right? So we also have, as we looked at a little
1548100	1553760	bit before, the firmware, which we can now go into some of that static reverse engineering.
1553760	1560200	We have packet capture for the camera and the app network communications. We have log files
1560200	1566440	from both the windows and the camera logs. The logs, as when we logged in before under root,
1566440	1571220	we of course have access to all of the D message logs and things like that as well.
1571300	1578160	And then we can get the camera logs from any of its hardware mechanisms as well for the audio
1578160	1582800	and camera, pan, tilt, zoom, et cetera. So now we want to kind of establish some more
1582800	1588760	advanced access for looking for some additional exploits. So one, or first, we're going to look
1588760	1593620	for that live log output for some immediate feedback to determine some of the control flow.
1593620	1599240	Again, from the windows app, right, we were able to see that some of the, they are logging the
1599240	1603600	post request and responses. So we're hopeful that they're going to do something similar on the
1603600	1608720	camera, but we also want to establish a, we want to have a debugger running on that camera so we
1608720	1614920	can look at some of these applications and see what we can do. So first for live log output,
1614920	1620740	it's very, very simple, very easy. You plug the serial, you just get your serial shell over,
1620740	1624620	you aren't plugged into say in this case, a Raspberry Pi, but again, you could use whatever
1624620	1629180	you like and it spits out the logs over serial by default. So you don't even necessarily need
1629180	1634100	to use the root access or boot the single user mode to just get the logs. But again,
1634100	1640000	that's just one way of doing it. But one thing that we'll quickly run into is the kernel watch
1640000	1645800	dog. So if the watch dog is not written to, it reboots the camera. So this, what we're seeing
1645800	1653480	here is if you try to kill the init, the primary app, or in this case, we'll get to it in a minute,
1653480	1658800	but if you start to kill off things in the camera to go look at them or pause things,
1658800	1664100	it will trigger the, the, the kernel watchdog process, which will then reboot the camera.
1664380	1668940	This isn't the only say security mechanism. This is just the one that the primary one that you
1668940	1673320	would have to get around to be able to run a debugger, to be able to look at the primary
1673320	1679320	application that they're running on the camera, which they call init app, which, which handles
1679320	1685100	all of the connection to the AJ cloud, providing all of the video streaming and the rest of the
1685100	1692460	control of the camera. They wrap this init app in a daemon.sh script, which is just a simple while
1692460	1697540	loop that says, Hey, keep kicking off the init app. If I have to kick it off more than X number of
1697540	1702140	times, reboot it again, acting sort of like a, again, a catch all in case something went really
1702140	1708640	wrong, but that init app is reporting into the watchdog. And so this is, that's, so if you either
1708640	1713200	kill the init app or again, kill the daemon and then kill the init app, that's where you're going
1713200	1717400	to end up rebooting the device. And so if you're using single user mode to get root, you're going
1717400	1722880	to lose that. And I, and some of the, unless you have set up some level of persistence, you're
1722880	1728840	going to lose any of the edits as well. So of course, next step is to defeat the watchdog. So
1728840	1733060	there are a couple of approaches here, right? That you could do. So the first one, um, which you can
1733060	1739020	actually get this example right off from the, uh, the kernel watchdog API, um, information from the,
1739020	1744080	the Linux kernel, you could just simply write some C code to keep sending a live messages to the
1744080	1749500	watchdog, right? And so since we have root access, we could do something like that. However, this
1749500	1753860	approach is not necessarily what we want to do and not what we wanted to do either, because the
1753860	1760840	problem, the fundamental problem with this is that while you could keep sending the messages, or you
1760840	1765580	could even use like take hold of the kernel semaphores and keep it open just for yourself.
1765580	1772460	So init app can't write to it. That doesn't necessarily help you because init app, if it
1772460	1777880	can't write to it, then it's going to know that you're here and know that you're now disabling
1777880	1783140	its ability to operate. And then it may change the way that it's going to operate. In this case,
1783140	1787660	we know say that it, that it does, but again, that's not necessarily the approach you want to
1787660	1791940	use, even though it might work for, for your environment. So there's another way. Um, there's,
1791940	1794480	there's other ways other than these two, but these are just the ones we're going to talk through
1794480	1801000	today. Um, there's the magic close feature, which if you go look in the Linux kernel driver, uh,
1801000	1807320	what the watchdog driver API from Linux kernel 2.4.18, you can see that there, if you write a
1807320	1811140	magic character, in this case, an uppercase V, there's another character that'll work as well.
1811140	1816760	But if you write that to dev watchdog, and that's the last thing that gets written to
1816760	1822120	dev watchdog, it then can cleanly disable the watchdog, uh, the, the kernel watchdog.
1822120	1828720	Now, as a note, the camera is not running Linux kernel 2.4.18, but it does still work. Um, so
1828720	1833940	your mileage may vary. It's running a three dot kernel, but, um, again, it's still, still may
1833940	1838740	work. So you could write a simple script such as this, or again, however you would like to do it
1838740	1843260	to just simply continuously write V. And the reason why you may want to do something like
1843260	1848740	this instead of just write V and stop is something, some other process, especially as you're doing
1848740	1853120	your reverse engineering might come along and reactivate the watchdog. So if you want to try
1853120	1858840	and keep making it such that, that you're not going to be rebooted, or at least as have some
1858840	1863720	protection against that, you, you might want to continuously write to it. So now with the
1863720	1868680	watchdog generally defeated, we need to be able to run a debugger on the camera, which means we
1868680	1873880	need to be able to compile binaries that can run on the camera. Um, so in this case, we discovered
1873880	1882080	that our, our camera is a little Indian MIPS. Um, so just as a quick, um, example, we can compile
1882080	1889860	arbitrary C code using just out of the box, um, like the MIPS Linux GCC compilers. We can run a
1889860	1896420	quick hello MIPS and see. So I did not know this at the time when I was doing it. I built a tool
1896420	1903000	chain and compiled, uh, compiled GDB server myself using that tool chain. But later on, we found that
1903000	1906920	there is a prebuilt one that works that that's the link to be able to get to it again, again,
1906920	1911440	that will be available, but what you'll need to do to be able to run GDB server, you'll need to
1911440	1916040	make sure that you're exporting the proper paths to get the proper libraries that an app needs,
1916040	1920680	then expose it over some port. It could be, it works over serial. I would recommend if you can
1920680	1924660	use it, doing it over networking, just because the serial debugging can be very slow when you're
1924660	1931840	using this many libraries. Um, and again, just an example of how to do that. Um, so we can then
1931840	1938020	connect to our, um, use, and this is actually one important note. When you're using GDB to connect
1938020	1944620	to GDB server, you will likely, you very likely need to use the multi-architecture version.
1944620	1949600	Otherwise it will not work unless you happen to be running, um, little Indian MIPS on your
1949600	1956900	laptop, which at least for me, I'm not. Um, but once you get there, again, we know that an in-app
1956900	1962660	is calling out to the watchdog. So we need to overwrite those functions in memory with no ops
1962660	1969480	to be able to have it not call to the watchdog at all. Is this absolutely necessary? Maybe not,
1969480	1972780	but it will make it a lot cleaner for us if we just don't have to worry about it. So that's,
1972780	1976540	that's what we did. And you can, at least in our case, we were able to find that, that,
1976540	1983560	that those locations were where those functions were and, uh, we just overwrote them. Sure. So
1983560	1988400	I'll hand it over to Mark. All right. Uh, so yeah, we're going to skip over the, the, this
1988400	1993040	second demo, uh, and just kind of jump right into it. So, uh, with the peer-to-peer discovery,
1993040	1997920	what we wanted to do is build a client so we could actually connect directly to our camera,
1997920	2003080	uh, and, uh, issue commands to it in order to, uh, attack and exploit it, right? Uh, so the
2003080	2008980	peer-to-peer, uh, servers, you can discover them, uh, using Nmap or Masscan, uh, and delivering
2008980	2017080	that 4-byte payload, uh, to UDP port 607222. Um, and yeah, so very briefly how to establish a
2017080	2022860	peer-to-peer connection, uh, you need to send it a hello message from the client, uh, it'll,
2022860	2029000	it'll act back, uh, you need to query for a specific device ID if this peer-to-peer server
2029000	2034580	has any idea of it, uh, those are device IDs are also serial numbers that are found on the bottom
2034580	2040080	or on the back of these devices, um, and hopefully the peer-to-peer server will say that it knows
2040080	2045380	how to access the device, uh, and then instruct you, uh, to punch a hole to a specific IP and
2045380	2052840	port, um, and then once we have the idea of where we're supposed to go to, uh, we can query that
2052840	2059760	specific relay server or the device itself, uh, you know, if we can connect to it, um, it should
2059760	2064040	hopefully say yes, uh, and then it'll send its packets back and then, yeah, your peer-to-peer
2064040	2068200	connection is ready. Uh, so yeah, there, there's a good exploit script that we kind of based some
2068200	2072820	of our work on, uh, definitely check that out when you get a chance. Um, but yeah, basically, uh,
2072820	2077860	in order to prove things out, uh, we, we looked at how the camera panned initially over Wireshark,
2077860	2083860	uh, it was very easy to tell which specific, uh, packet belonged to a pan operation, uh, then we
2083860	2090100	trace that back to, uh, debug, debug log messages from the firmware, uh, and then actually dug into
2090100	2096620	the firmware itself specifically to find where, uh, where that log, uh, message is being generated
2096620	2103300	and what function is primarily handling, um, a lot of the comms and all that. So, uh, very brief,
2103300	2111980	uh, demo and we're gonna just kind of jump ahead to our more compelling demo of essentially what
2111980	2120020	you can do, um, with our discovery of, of how to build a peer-to-peer client. So, um, what we can
2120020	2127760	see here is there is a, uh, there's an INI file on the camera itself that has the serial number.
2127760	2134960	And what we find out is that that's, that is the only way that the device knows what its own device
2134960	2142180	ID is. And so there is actually a command through peer-to-peer that allows us to overwrite the
2142180	2148920	contents of that INI file. So what we're trying to do is overwrite, uh, the, the serial number
2148920	2155140	itself to an arbitrary value that's just going to completely brick this machine and make it
2155140	2159560	completely inaccessible to the internet. And essentially the user's gonna have to throw it
2159560	2166840	away because there's no way to restore that unless you have access like we do. Uh, and so we send our
2166840	2173180	packets, uh, and what we can see here is we pulled up the same INI file and now it's full of garbage.
2175260	2179180	And we actually have another command we're going to send to it that's going to crash and reboot
2179180	2185680	the cam. Uh, and from there, uh, what we can see is, you know, things are kind of already going
2185680	2191820	haywire a little bit. Uh, the camera is attempting to reboot right now, but what we'll find out
2191820	2198660	pretty shortly here is that it has, uh, it will attempt to issue requests to AJ Cloud's
2198660	2203560	infrastructure, but ultimately it's going to be unsuccessful because it's sending along
2204640	2208120	absolute garbage, uh, in its curl requests.
2210660	2216720	And if we kind of like skip ahead a little bit here, this is a press for time. Um, what we can
2216720	2229350	see here, yeah, if you, if you kind of highlight that, there's not much there. Ah, yes. So yeah,
2229350	2244480	that doesn't really look like a good curl request. Okay. So very, very briefly, um,
2244480	2250320	what devices are actually affected by this, right? Uh, so Wansview, every single device
2250320	2255260	associated with Wansview is affected, including pet feeders, light bulbs, indoor and outdoor
2255260	2260700	cameras. Uh, Galu as well, since they're, uh, you know, an affiliate company of Wansview,
2260700	2266980	uh, and Sonato as well. Um, and then also Philemi is another, uh, manufacturer that,
2266980	2273240	that we, uh, were able to experiment with. Um, but ultimately the affected vendors,
2273240	2279020	uh, it all stems from AJ Cloud. It's whoever's running their device firmware on their cloud
2279020	2285000	platform. And this ultimately affects seven different vendors, possibly even more. We
2285000	2291140	weren't able to confirm all of these. So just real quick, what are some things that the vendors
2291140	2295340	did right? They have certificate web-based authentication. It was fairly difficult to do
2295340	2299720	some man-in-the-middle attacks from that. They have signed and obfuscated APKs, another good
2299720	2304380	thing. They have a pared-down local operating system that at least attempts to be read-only.
2304380	2309260	They could have had secure boot, but again, they have a read-only-ish file system. So you
2309260	2314520	have to do some work even with physical access to be able to go and attack the machine. What
2314520	2318880	they did wrong, of course, unauthenticated cloud access. The demos that we showed you, again,
2318880	2324440	did not require any authentication. We have significant verbose debugging in the log app,
2324440	2329860	the vulnerable peer-to-peer access, and again, no secure boot despite the SoC supporting it. And
2329860	2335260	it's very easy to manipulate when you have physical access. So mitigations, of course,
2335260	2339060	if you want to use them, segment them off your network. The critical vulnerabilities in the
2339060	2343720	cloud infrastructure will put your data at risk. So we would just recommend not using them at all.
2343720	2350620	Again, restrict the inbound, outbound comms. You basically just want to block all of the
2350620	2355360	different traffic that you have. You could also flash it with a different operating system.
2355360	2360700	For sake of time, I'm going to kind of run through this really fast. OpenIPC, I would recommend you
2360700	2366100	checking it out. At least the Q5 is directly supported. So you could flash it with that,
2366100	2372400	but it supports a lot of different SoCs. So our tools that we used for this demo,
2372400	2378960	we'll be releasing them shortly on GitHub. And feel free to follow along with the demo.
2379240	2383800	There's some other future research opportunities. Again, apologies for having to run through this
2383800	2389240	real quick. But thank you so much for coming to our talk. Special thanks to, of course,
2389240	2394980	the following here, and definitely follow us on Twitter, and Elastic Security Labs.
2394980	2396580	So again, thank you very much, DEF CON.
