1 00:00:00,000 --> 00:00:00,640 Quick intro. 2 00:00:00,640 --> 00:00:01,700 I'm Mickey. 3 00:00:01,900 --> 00:00:03,280 That's Jesse. 4 00:00:03,620 --> 00:00:05,280 We hack things. 5 00:00:05,460 --> 00:00:07,320 We give talks. 6 00:00:07,420 --> 00:00:08,180 That's who we are. 7 00:00:08,180 --> 00:00:11,160 There's a lot of stuff online. 8 00:00:11,160 --> 00:00:13,340 We work for a company called Eclipsium. 9 00:00:13,460 --> 00:00:17,740 We want to mention them because they help us fund all of this stuff. 10 00:00:19,420 --> 00:00:25,840 Quick terminology, for those unaware, UART is a serial communication protocol. 11 00:00:25,880 --> 00:00:32,360 Wow, it's really distracting, that noise from the other place. 12 00:00:33,940 --> 00:00:35,340 Don't tempt me. 13 00:00:36,360 --> 00:00:47,040 Okay, so UART is a serial communication protocol, usually in IoT devices, OTA over the air, UVC, basically read it yourselves. 14 00:00:48,700 --> 00:00:53,420 One thing I want to be clear about that I do want some participation. 15 00:00:53,420 --> 00:00:57,560 If anyone has a question, shout because I can't see anything. 16 00:00:57,560 --> 00:00:59,180 I have a light in my eyes. 17 00:00:59,340 --> 00:01:08,040 So either come to the microphones and ask us a question or interrupt, yell, everything's cool as long as you do it, you know, with taste. 18 00:01:09,100 --> 00:01:17,380 Another thing I want to be clear about, there's multiple ways to hack a thing. 19 00:01:17,460 --> 00:01:19,460 We did it one way. 20 00:01:19,740 --> 00:01:23,680 I'm sure there's at least 12 people here that can do it better. 21 00:01:25,240 --> 00:01:26,880 I'll start with a story. 22 00:01:29,140 --> 00:01:34,500 Back in the COVID days, we did a lot of e-meetings, you know, video calls, all that stuff. 23 00:01:34,500 --> 00:01:36,220 And I needed a good webcam. 24 00:01:36,380 --> 00:01:39,100 So I found one that did 60 frames per second. 25 00:01:39,100 --> 00:01:40,700 I'm like, yeah, I buy it. 26 00:01:40,740 --> 00:01:42,860 I plug it into my computer. 27 00:01:42,860 --> 00:01:47,720 And then a year goes by and it starts to be flaky in meetings. 28 00:01:47,720 --> 00:01:52,260 And I'm like, okay, it's been on the market for two years. 29 00:01:52,260 --> 00:01:55,400 There must be a firmware update that I haven't applied yet. 30 00:01:55,900 --> 00:01:59,500 I should go and apply that. 31 00:01:59,500 --> 00:02:03,340 So I find the firmware update tool. 32 00:02:03,340 --> 00:02:04,500 I go on their website. 33 00:02:04,500 --> 00:02:05,820 I download it. 34 00:02:05,820 --> 00:02:10,240 That's the URL for the web archive for the original tool. 35 00:02:11,340 --> 00:02:15,680 I recommend that you save it because it's no longer on the internet. 36 00:02:16,500 --> 00:02:21,620 So I download the tool and I install it, right? 37 00:02:21,680 --> 00:02:22,980 Run the installer. 38 00:02:23,960 --> 00:02:25,740 Get the GUI for the installer. 39 00:02:25,740 --> 00:02:27,400 It automatically opens it up. 40 00:02:27,600 --> 00:02:29,920 It shows the camera, the firmware version. 41 00:02:31,040 --> 00:02:32,480 But did you see it? 42 00:02:34,140 --> 00:02:36,380 It extracts into a folder. 43 00:02:37,640 --> 00:02:42,400 Me, being an inquisitive mind, I'm like, okay, something's sus here. 44 00:02:42,620 --> 00:02:45,000 I open and look at the files. 45 00:02:49,220 --> 00:02:50,640 You see it? 46 00:02:54,200 --> 00:03:02,860 I take a closer look and I say to myself, like, what the fuck? 47 00:03:03,660 --> 00:03:09,880 Why does a webcam need almost an 8 meg firmware update? 48 00:03:11,320 --> 00:03:13,260 So take a look at it again. 49 00:03:15,300 --> 00:03:17,680 There's a .sh script. 50 00:03:17,680 --> 00:03:20,020 Keep in mind this is a Windows updater. 51 00:03:21,400 --> 00:03:26,420 U-boot, a USB update binary. 52 00:03:27,120 --> 00:03:31,120 Some weird ass looking file, OTA. 53 00:03:31,720 --> 00:03:33,540 And an auto update TXT. 54 00:03:33,540 --> 00:03:36,000 Okay, something is off here. 55 00:03:37,100 --> 00:03:41,160 I like to hack IOT, so bin walk. 56 00:03:41,600 --> 00:03:41,680 I don't know why I'm doing this. 57 00:03:41,700 --> 00:03:46,760 I swear, this is one of the most beautiful bin walks I've ever gotten in my life. 58 00:03:46,920 --> 00:03:49,940 If you ever run bin walk, you see a lot of sometimes noise. 59 00:03:50,200 --> 00:03:51,760 This is the whole dump. 60 00:03:51,760 --> 00:03:54,340 This is how the firmware for the camera looks. 61 00:03:55,280 --> 00:03:57,180 Now I really have to open this. 62 00:03:58,060 --> 00:03:59,240 Open this device. 63 00:03:59,240 --> 00:04:01,680 And it's like hard. 64 00:04:01,680 --> 00:04:03,560 The front panel is glued in. 65 00:04:04,300 --> 00:04:05,560 I rip it apart. 66 00:04:05,560 --> 00:04:06,380 I open it up. 67 00:04:06,380 --> 00:04:07,180 I look at the back. 68 00:04:07,180 --> 00:04:08,440 I see an SOC. 69 00:04:08,500 --> 00:04:10,000 You see this stuff. 70 00:04:10,020 --> 00:04:13,540 You go like, okay, I'd expect to see a chip on a webcam. 71 00:04:13,980 --> 00:04:15,820 USB to the chip. 72 00:04:15,820 --> 00:04:18,940 The chip does its, you know, conversion of the image. 73 00:04:19,400 --> 00:04:20,860 Passes on the USB. 74 00:04:21,200 --> 00:04:22,420 Normal stuff. 75 00:04:22,420 --> 00:04:28,260 What you'd normally expect from a Linux running target or a system or a device is to have the trifecta. 76 00:04:28,440 --> 00:04:33,500 The CPU, the memory and the storage. 77 00:04:33,940 --> 00:04:37,260 I didn't see memory, so I'm like, okay, weird. 78 00:04:37,520 --> 00:04:38,600 Look at the back. 79 00:04:38,600 --> 00:04:42,660 I see a spy and then I see these pads. 80 00:04:42,660 --> 00:04:44,020 I call them sus pads. 81 00:04:44,860 --> 00:04:47,620 It's three pads on the middle of a PCB. 82 00:04:47,620 --> 00:04:48,500 I'm like, okay. 83 00:04:48,780 --> 00:04:50,420 Turns out, there you are. 84 00:04:51,000 --> 00:04:54,360 So maybe I can hotwire this thing. 85 00:04:54,480 --> 00:04:55,760 So I hotwire it. 86 00:04:56,900 --> 00:04:58,540 And this is what I see. 87 00:05:02,170 --> 00:05:02,890 Okay? 88 00:05:02,890 --> 00:05:09,550 So at this point, um, I'm a bit processing. 89 00:05:09,550 --> 00:05:11,190 I'm like, okay, what did I see? 90 00:05:11,390 --> 00:05:14,470 I see Linux on a CPU. 91 00:05:14,470 --> 00:05:15,910 What Linux version? 92 00:05:16,290 --> 00:05:17,310 Firmware version. 93 00:05:17,310 --> 00:05:23,710 And this is the exact process of emotions that I've had at the time. 94 00:05:26,090 --> 00:05:28,150 Then it turned into this. 95 00:05:30,190 --> 00:05:32,570 And then it came into that. 96 00:05:34,710 --> 00:05:35,670 Okay. 97 00:05:36,030 --> 00:05:37,630 I'm going to hand it off to Jesse now. 98 00:05:40,030 --> 00:05:44,570 So we've already seen some kind of suspicious things already. 99 00:05:44,570 --> 00:05:50,450 So we started to dive into what the firmware update process actually does and how that works. 100 00:05:50,450 --> 00:05:58,690 So the way their package arrives, you have this firmware tool executable and then a couple DLLs. 101 00:05:58,690 --> 00:06:06,290 There's this HD 510 SDK DLL that has most of the update code itself. 102 00:06:06,490 --> 00:06:11,290 And then it has a helper function that's AIT UBC extension API. 103 00:06:11,290 --> 00:06:18,290 It's basically just used for, there's something in UBC or USB video class, it's called extension units. 104 00:06:18,290 --> 00:06:21,790 And those are used for configuring different things about the camera. 105 00:06:22,050 --> 00:06:26,850 This really, most of the update code runs in that HD SDK. 106 00:06:27,010 --> 00:06:29,210 It only calls three of the functions through this helper. 107 00:06:29,210 --> 00:06:36,850 There's a lot of other stuff in this extension unit helper library that is used for other types of devices. 108 00:06:36,850 --> 00:06:40,270 So they just pulled this in for a few small commands. 109 00:06:40,270 --> 00:06:55,610 And then together, those will take instructions from the auto update.txt which will then basically parse commands from the OTA and send commands and the firmware file to the device itself. 110 00:06:55,830 --> 00:07:04,850 And if you look at that auto update, it just has this E star command and then the name of the other file to parse and then reset. 111 00:07:06,170 --> 00:07:13,390 If we look in the OTA, these are even more suspicious because it's just SF probe. 112 00:07:13,390 --> 00:07:17,970 It's like spy flash probe and we're probing chip select zero. 113 00:07:18,210 --> 00:07:20,230 And then spy flash erase. 114 00:07:20,230 --> 00:07:26,230 This particular region offset, this particular size and then it's TFTP transfer. 115 00:07:26,230 --> 00:07:31,290 That doesn't really make sense over this USB interface for how they're doing it. 116 00:07:31,290 --> 00:07:37,450 But we'll go with that and then write that region to that offset that they just erased. 117 00:07:37,690 --> 00:07:40,990 This is literally the full update script that it runs. 118 00:07:41,710 --> 00:07:46,290 We take a closer look at how this actually works in the internals. 119 00:07:46,290 --> 00:07:49,070 I mentioned the UVC extension units . 120 00:07:49,210 --> 00:08:00,850 They're only doing one call to get a property for this specific vendor extension extension unit to get the firmware version and then also switch the camera into firmware update mode. 121 00:08:01,130 --> 00:08:12,030 Extension units are used for a bunch of other things for different cameras like if you have like a pan, tilt, zoom, all of that, those are configured using extension units. 122 00:08:12,410 --> 00:08:23,530 But when you send this specific vendor, specific set property, it reboots the device and comes up as a mass storage device which is kind of interesting. 123 00:08:23,770 --> 00:08:41,630 And then from then on, it's sent, it's using SCSI commands, basically SCSI direct, SCSI pass through commands in order to use vendor specific SCSI op codes to continue sending command and data to the device. 124 00:08:41,730 --> 00:08:53,970 And then it also sends this interesting USB updater op bin and uboot.bin for the camera to run during that update process, which is also something that we're concerned and suspicious about. 125 00:08:54,370 --> 00:08:56,410 But here's some of the code. 126 00:08:56,410 --> 00:09:11,910 It's just doing the open device by path using that helper library and then sending this extension set with a specific GUID and then a specific control selector to say what specific request I'm doing within this extension unit. 127 00:09:12,050 --> 00:09:17,530 Once it does this, it just starts waiting and looks to see, has a new mass storage device popped up? 128 00:09:17,530 --> 00:09:21,050 Can I find the specific device I'm looking for? 129 00:09:21,390 --> 00:09:25,770 So at that point it starts sending SCSI commands. 130 00:09:25,770 --> 00:09:28,410 If you look at the bottom, there's this device IO control. 131 00:09:28,630 --> 00:09:34,130 The specific IOCTL number is OX4D004. 132 00:09:34,130 --> 00:09:37,250 That's the specific IOCTL for SCSI pass through. 133 00:09:37,450 --> 00:09:39,870 And it's used for other mass storage devices. 134 00:09:40,090 --> 00:09:50,410 But in this case we're just sending an inquiry request where we get information back from the device about the specific device from this inquiry request. 135 00:09:51,010 --> 00:09:56,390 In this case they're using this in order to determine what mode the camera is operating in. 136 00:09:56,390 --> 00:10:00,910 So after it reboots, it comes up in what's called ROM mode. 137 00:10:01,210 --> 00:10:10,650 And by doing this inquiry command they can determine if it's in ROM mode based on inside of the buffer it will have a G or a C at a specific offset. 138 00:10:11,250 --> 00:10:16,170 If it has a UPD at a different offset, it's in update mode. 139 00:10:16,270 --> 00:10:19,530 And if it's in UBO, it's in UBOOT mode. 140 00:10:19,690 --> 00:10:29,730 And the way that this works is that it will transition the camera into update by sending that UVC extension unit request. 141 00:10:29,830 --> 00:10:31,550 And then it will send an inquiry. 142 00:10:31,650 --> 00:10:35,630 Once it's in ROM mode, it will send the updater. 143 00:10:35,650 --> 00:10:38,890 And then once it's in updater mode, it will send UBOOT. 144 00:10:38,890 --> 00:10:49,050 And then once it's in UBOOT mode, it will just literally send UBOOT commands over that mass storage channel that it's still using, which is kind of an interesting way to do this. 145 00:10:49,570 --> 00:10:53,510 So they are using vendor specific SCSI op codes to transfer data. 146 00:10:53,590 --> 00:11:07,550 The TFT command instead of doing network operations, they have special handling to convert that into there's a load info command that they send which says here's the address to load this at in memory. 147 00:11:07,550 --> 00:11:08,870 Here's the size. 148 00:11:08,950 --> 00:11:29,570 And then the update tool itself will then calculate an MD5 hash, pass that over and then start sending chunks of that buffer in multiple different SCSI write requests using that specific vendor op code with a sub op code to say these are the chunks and then the last chunk has a different sub op code. 149 00:11:29,710 --> 00:11:37,250 But all the other commands are just sent as literal strings to run and by the camera to interpret in this UBOOT that's running for you now. 150 00:11:38,310 --> 00:11:43,950 So when you're looking at the camera UART itself, it basically looks like this. 151 00:11:43,950 --> 00:11:52,550 And you can see the camera is running and then it switches into UBOOT mode and waits a little bit while it's doing things. 152 00:11:52,550 --> 00:11:55,410 And you start seeing things like this run command at the end. 153 00:11:55,410 --> 00:12:01,890 Those are literal commands that are being run by this, that are being sent from the updater tool to be run by UBOOT in the camera. 154 00:12:02,070 --> 00:12:11,330 So it will do the run commands and then it will do this operation of erase, transfer the data and then write. 155 00:12:11,710 --> 00:12:19,930 And we can look at this and these basically map to our commands that were in that auto update TXT or the OTA TXT. 156 00:12:20,490 --> 00:12:32,550 One interesting thing that we noticed is if you look at the order for here, they're erasing the spy region and in this case they are erasing only the root file system and the kernel. 157 00:12:32,610 --> 00:12:37,950 So they erase the file system and then they transfer the new image to update. 158 00:12:37,950 --> 00:12:42,550 So if you look at the bottom there, there's an MD5 pass. 159 00:12:42,770 --> 00:12:44,310 What happens if that fails? 160 00:12:44,310 --> 00:12:52,090 If there's like an integrity ‑‑ if there's an integrity problem while they're transferring that file, maybe it was a file that isn't going to work. 161 00:12:52,150 --> 00:13:00,510 They've already erased the image and there isn't really any retry and send the copy, send the firmware file again if that fails. 162 00:13:00,510 --> 00:13:03,590 So that's another thing to take a look at. 163 00:13:04,150 --> 00:13:10,130 But at this point, it's a pretty straightforward method of how we can do the updates. 164 00:13:10,170 --> 00:13:11,990 I'll pass that back to Becky. 165 00:13:13,270 --> 00:13:16,090 Spoiler alert, it breaks the camera. 166 00:13:20,040 --> 00:13:21,340 That was easy. 167 00:13:22,740 --> 00:13:27,600 So we've seen their GUI and their tool and everything. 168 00:13:27,600 --> 00:13:29,800 Can we just simplify and make our own tool? 169 00:13:29,800 --> 00:13:35,500 Because we know they're using the third party API from some SOC vendor. 170 00:13:36,420 --> 00:13:38,380 Short answer is yes. 171 00:13:38,420 --> 00:13:40,460 And it's in C sharp. 172 00:13:40,460 --> 00:13:52,860 And the simplest thing is because we got lucky and the firmware update tool is in C sharp, we threw it in our IL disassembler and got the assembly and hacked it together. 173 00:13:52,860 --> 00:13:55,080 And you can convert it to PowerShell if you'd like. 174 00:13:55,080 --> 00:13:56,020 It's fun. 175 00:13:56,900 --> 00:14:01,940 And it works the same, calls the DLLs and fun. 176 00:14:02,580 --> 00:14:06,200 So a quick topic change. 177 00:14:08,160 --> 00:14:11,380 Why the fuck would you put Linux in a webcam? 178 00:14:13,960 --> 00:14:17,740 The quick answer is basically money. 179 00:14:19,300 --> 00:14:37,920 If there's a company that sells you an SOC that has all this integrated already in it and it works and you just got to rebrand it and maintain a, a small workforce of people to maintain the updates over a couple of years that already do other things, it's cheaper to do it that way but it's not always secure. 180 00:14:42,080 --> 00:14:43,720 The way it looks is like this. 181 00:14:43,720 --> 00:14:46,040 The SOC vendor is called Sigma Star. 182 00:14:46,280 --> 00:14:48,660 They make this chip. 183 00:14:49,020 --> 00:14:57,800 You go on the website, they sell all these kinds of SKUs of it, they do for webcams, IOT, all kinds of stuff. 184 00:14:58,040 --> 00:15:08,800 They are a subsidiary of a company called M-Star Semiconductor that doesn't appear to be alive, it's only on paper and that is a subsidiary of Mediatek. 185 00:15:10,300 --> 00:15:23,220 Out of Sigma Star's SOCs we've identified so far, we've seen, um, in TP-Link, which credit to TP-Link, they do publish their GPL code, which is great. 186 00:15:23,380 --> 00:15:25,980 Nexigo and OBSBot. 187 00:15:25,980 --> 00:15:29,080 Never heard of these before this, uh, this research. 188 00:15:29,760 --> 00:15:31,940 But we'll get to that in a second. 189 00:15:32,220 --> 00:15:41,540 Uh, when you go to their website, the fun, the, the good thing about these companies when they, when they want to sell their product, they build a full vertical stack of everything you need. 190 00:15:41,920 --> 00:15:49,880 So, the SDK, the code, the documentation, the data sheets, the examples, everything. 191 00:15:50,060 --> 00:15:53,100 You go to the website and you get all the data you need. 192 00:15:53,860 --> 00:15:56,380 That's, that's the link to go there. 193 00:15:56,380 --> 00:16:00,560 You do need, uh, to create a credential. 194 00:16:01,440 --> 00:16:05,660 Supposedly it will get you access to the source and the SDK. 195 00:16:05,720 --> 00:16:11,260 I have tried, I think it's been two months with two different accounts. 196 00:16:11,440 --> 00:16:17,240 Uh, one is Gmail, one is a cor, Gmail didn't work so I went with my corporate email to see maybe they filter. 197 00:16:17,240 --> 00:16:18,920 No, they just don't give a shit. 198 00:16:19,300 --> 00:16:22,980 Um, there's no data, there's no, nothing. 199 00:16:23,100 --> 00:16:25,440 It is like pulling teeth. 200 00:16:25,980 --> 00:16:26,880 It's terrible. 201 00:16:26,880 --> 00:16:28,900 So, what can you do? 202 00:16:28,900 --> 00:16:30,420 So, do it yourself. 203 00:16:31,140 --> 00:16:36,200 You go Google things, GitHub things, look in the forums. 204 00:16:36,760 --> 00:16:40,160 Surprise, you can go through LinkedIn and you can go through Twitter. 205 00:16:41,140 --> 00:16:41,940 Why? 206 00:16:42,400 --> 00:16:43,400 In a second. 207 00:16:43,560 --> 00:16:56,060 Um, so the process is like this, you Google for the files, you find them on GitHub, you find them on Google and you repeat this over and over and over and over again. 208 00:16:56,100 --> 00:16:58,960 And if you can go into the Russian forums, you get bonus points. 209 00:17:01,280 --> 00:17:05,500 There's a GitHub repo with four, sorry, GitHub user with four repos. 210 00:17:05,920 --> 00:17:10,380 One of them is the actual USB tool from Sigma Star. 211 00:17:10,380 --> 00:17:17,780 It's a bit of an older version but it, they keep things the same way over generations because people are lazy. 212 00:17:18,240 --> 00:17:22,580 Um, and if it works they just keep it moving over the years, the technology. 213 00:17:22,820 --> 00:17:25,980 You get the U-Boot, you get the Linux, you get the, their SDK. 214 00:17:26,480 --> 00:17:29,980 Um, the next two are open directories. 215 00:17:30,480 --> 00:17:35,840 So, you just find random stuff in open directories. 216 00:17:36,220 --> 00:17:41,280 And the last one is an open IPC kinda sorta, um, implementation. 217 00:17:41,280 --> 00:17:42,880 Open IPC if you don't know. 218 00:17:42,880 --> 00:17:50,180 It's, um, it's for internet cameras that you can open, you can use open source code to do it. 219 00:17:50,180 --> 00:17:52,220 And it supports Sigma Star's chipsets. 220 00:17:52,220 --> 00:17:55,520 So, they do have a kernel for that. 221 00:17:56,400 --> 00:18:00,020 But like I said, no help from them. 222 00:18:00,060 --> 00:18:02,300 I thought maybe there's a chance. 223 00:18:02,580 --> 00:18:03,500 Nothing. 224 00:18:03,760 --> 00:18:04,800 Forget about it. 225 00:18:04,820 --> 00:18:13,500 Um, the only other thing we could do is reach out to Lenovo and say, can you give us the GPL code? 226 00:18:15,780 --> 00:18:17,680 And this is how it went. 227 00:18:19,080 --> 00:18:24,520 We asked for the GPL code, Lenovo asks Sigma Star for GPL code. 228 00:18:24,520 --> 00:18:29,380 Sigma Star's, Sigma Star gives Lenovo the code, Lenovo gives us the code. 229 00:18:29,380 --> 00:18:30,960 We build it, it fails. 230 00:18:31,060 --> 00:18:37,220 We go to Lenovo and we go back to Lenovo and say, we need more, uh, it's not complete. 231 00:18:37,700 --> 00:18:39,240 Again, cycle. 232 00:18:40,260 --> 00:18:42,280 We get the code, it works. 233 00:18:42,700 --> 00:18:50,760 We build all our demos for the talk and then we're like, you know what, we want to take the extra step, do something, we did something crazy, let's do something even more crazy. 234 00:18:51,640 --> 00:18:56,400 Uh, we requested the GPL again and nothing yet. 235 00:18:57,520 --> 00:19:00,080 Um, hopefully we'll get it. 236 00:19:00,080 --> 00:19:05,580 So, we do have the U-Boot, we have the kernel, we don't have the latest SDK. 237 00:19:06,260 --> 00:19:09,500 We have a bunch of stuff from GitHub, what can we do? 238 00:19:09,920 --> 00:19:12,840 We do know the structure of how it looks. 239 00:19:12,840 --> 00:19:17,340 They do have, for the same SOC you can build either for, uh, Spynor or Spynand. 240 00:19:17,760 --> 00:19:19,320 In our case it's a NOR. 241 00:19:19,400 --> 00:19:21,480 This is how the, the partition looks like. 242 00:19:21,480 --> 00:19:27,340 We're going to focus on these two because it's easier, it's the easiest way for anyone to get into this world. 243 00:19:28,280 --> 00:19:35,360 Uh, just build a kernel or modify a file system and that's what we know. 244 00:19:35,360 --> 00:19:36,580 We know, this is what we know. 245 00:19:36,580 --> 00:19:42,560 We know the camera runs Linux, we know how to build a Linux, we know we can flash it, we know how to flash it. 246 00:19:44,080 --> 00:19:46,820 So, here comes the fun part. 247 00:19:48,560 --> 00:20:00,070 Can we turn the camera into a camera? 248 00:20:00,070 --> 00:20:02,430 We have a laptop, we have a camera, this one. 249 00:20:03,670 --> 00:20:05,470 We plug the USB in. 250 00:20:10,590 --> 00:20:16,430 Uh, I opened the camera app on the, on the background just to show, I disabled the, the built-in camera. 251 00:20:16,990 --> 00:20:23,830 The camera shoots out a text and then it reboots into normal, regular code. 252 00:20:24,670 --> 00:20:26,370 Take a picture of him too. 253 00:20:26,370 --> 00:20:27,790 Okay, cool. 254 00:20:31,030 --> 00:20:32,350 And that's it. 255 00:20:32,350 --> 00:20:39,470 So, we, we took the kernel, we built it, we added the hit stack, USB gadgets, cool. 256 00:20:39,850 --> 00:20:47,270 The camera boots up, it's a hit, it's a keyboard, it types in stuff, it's cool, it's funny. 257 00:20:49,350 --> 00:20:51,450 Um, what? 258 00:20:52,930 --> 00:20:54,250 There's more. 259 00:20:54,290 --> 00:20:57,170 So, um, so this is the, this is the, this is the, this is the how do we do that? 260 00:20:57,170 --> 00:20:58,910 The, the file system is read only, right? 261 00:20:58,910 --> 00:21:05,430 It's, it's a spy chip, it loads it to memory and then runs it and every change you do doesn't persist across reboots. 262 00:21:06,250 --> 00:21:12,530 Um, so it turns out there's a, there's a section in memory called environment variables, every system usually has it. 263 00:21:12,950 --> 00:21:24,890 Um, in this case we just added our own variable called implant and the camera just, the, our code in the camera checks if implant is one, run the hit payload, change it to zero. 264 00:21:24,890 --> 00:21:34,150 Next time the camera reboots, implant is zero, if, if, if the code is, if the implant is zero, boot into the normal Lenovo flow. 265 00:21:34,450 --> 00:21:35,410 That's it. 266 00:21:36,530 --> 00:21:39,930 This is how it looks from the camera side. 267 00:21:41,190 --> 00:21:56,470 The camera boots, you see implant equals one, means run the payload, start sending key strokes, this opens an admin command prompt and starts saying, psst, I'm your camera, this is an admin command prompt, I'm going to become a camera now. 268 00:21:57,130 --> 00:22:09,830 It reboots, implant is now zero and it just follows the normal Lenovo boot flow and it's a regular camera. 269 00:22:10,910 --> 00:22:14,190 Okay, let's, uh, change gears. 270 00:22:14,730 --> 00:22:23,050 Uh, for some god awful reason, uh, the RCS script in the camera has Telnet D starting in it. 271 00:22:24,030 --> 00:22:29,450 So can we have a network gadget on the camera? 272 00:22:29,570 --> 00:22:30,790 Let's try it. 273 00:22:34,110 --> 00:22:38,730 So we plug in a camera , I don't know if it's playing. 274 00:22:39,430 --> 00:22:40,610 Yeah, it's playing now. 275 00:22:41,090 --> 00:22:48,850 So we plug in a camera, integrated camera is off, just to be sure. 276 00:22:49,290 --> 00:23:02,630 I'm going to show that there's an, there's an RNDIS gadget, once it's plugged in, it flashed, means the USB event happened, USB Ethernet means the camera's connected. 277 00:23:04,090 --> 00:23:09,210 As you can see, it's connected alongside a keyboard from the same composite device. 278 00:23:12,640 --> 00:23:36,760 Here we, uh, open Teraterm, Telnet to it, AI Scion, no password, we drop, drop into a shell, I go to my folder, I run the script, it issues the usual I am evil keyboard script, and then I go and I reboot the camera, I don't, I type reboot, it's wrong, 279 00:23:36,760 --> 00:23:45,020 I need to type, no, I do, I type reboot, it works, it's fine, I open the, uh, the camera app in Windows and then I wait. 280 00:23:52,440 --> 00:23:54,320 And that's it, it's a normal camera. 281 00:23:58,080 --> 00:24:00,840 Uh, so, what else can we do? 282 00:24:00,840 --> 00:24:02,220 We got to this point. 283 00:24:03,380 --> 00:24:06,700 Um, better buckle up for this one. 284 00:24:08,060 --> 00:24:16,400 This is a PowerShell script that all it does is share the Internet connection from the host Wi-Fi to the gadget. 285 00:24:19,200 --> 00:24:21,740 I see you're getting the, where we're going with this. 286 00:24:24,560 --> 00:24:34,220 So, on the left top is the webcam UI, on the bottom left is a Kali machine that we have in Microsoft's cloud, and on the right is the laptop. 287 00:24:39,090 --> 00:24:52,110 We start hosting a payload, we start Metasploit listening on the 443, and then you have Metasploit running and listening. 288 00:24:53,630 --> 00:24:56,370 Um, yeah, listening. 289 00:24:57,730 --> 00:25:01,710 The moment, the moment the text starts running on the top left, the camera's plugged in. 290 00:25:02,310 --> 00:25:07,710 Uh, Wi-Fi is connected to a, uh, network called local host, sorry for the confusion. 291 00:25:08,490 --> 00:25:14,690 That's it, it's connected to a Wi-Fi, nothing says shared, nothing there, just normal Wi-Fi. 292 00:25:15,090 --> 00:25:19,130 Camera plugged in, you are scrolling, 293 00:25:23,380 --> 00:25:28,560 the camera now goes to and fetches that PowerShell script. 294 00:25:34,500 --> 00:25:41,960 The, the camera has now enabled Internet connection sharing between the Wi-Fi and the RNDIS gadget. 295 00:25:42,020 --> 00:25:59,560 The camera now has Internet, but the camera wants to show you, so here we go, there's the gadget, the camera opens the properties for the Wi-Fi controller, tabs over, Internet connection sharing, hits enter, and we have the Wi-Fi controller . 296 00:25:59,560 --> 00:26:02,320 And we have a, an interpreter session open on the camera. 297 00:26:11,340 --> 00:26:20,720 I open a shell to the camera from the cloud, I just reboot it, because the flag tells it to run as normal camera now. 298 00:26:23,400 --> 00:26:28,740 Usual Windows camera app to show you there's no camera found, but it's connected, it will pop it up. 299 00:26:32,740 --> 00:26:33,700 Yay! 300 00:26:45,240 --> 00:26:49,320 To be honest, this whole demo is structured around this GIF, so I'm not going to show it . 301 00:26:49,320 --> 00:26:50,420 That's it. 302 00:26:53,920 --> 00:26:57,200 So, um, go have fun. 303 00:26:57,200 --> 00:27:02,060 You can buy this camera on Amazon right now, 45 bucks, uh, even cheaper on eBay. 304 00:27:02,920 --> 00:27:11,020 Uh, if you're, uh, if you, uh, if you're afraid, if you want to go deeper and you want to play with it, get two. 305 00:27:11,020 --> 00:27:12,340 Always get two. 306 00:27:13,060 --> 00:27:14,540 Uh, pro tip. 307 00:27:15,340 --> 00:27:16,840 And get a flash tool. 308 00:27:17,060 --> 00:27:21,600 I recommend, if you have money, buy, uh, Dirty Prog. 309 00:27:21,600 --> 00:27:28,460 If you don't, if you have 50 bucks, buy the, uh, the Tigard by Joe Fitz, also known the Tigard King. 310 00:27:29,600 --> 00:27:33,880 Um, or any other spy flashing tool. 311 00:27:35,200 --> 00:27:37,580 Let's go rent a little bit of the other vendors. 312 00:27:37,580 --> 00:27:42,100 So, um, quick question, anyone here from Lenovo? 313 00:27:42,220 --> 00:27:43,600 Raise your hand. 314 00:27:44,760 --> 00:27:47,140 Don't be shy, I'm not going to do anything bad. 315 00:27:48,180 --> 00:27:50,500 No one here from Lenovo? 316 00:27:51,760 --> 00:27:52,880 Okay. 317 00:27:53,180 --> 00:27:54,760 I'm not offended. 318 00:27:55,820 --> 00:28:03,580 Um, so we looked at other cameras, and it turns out there's a bunch of other cameras running Linux. 319 00:28:04,840 --> 00:28:09,620 Uh, the Opal Tadpole is running Linux on an Ambarella SOC. 320 00:28:10,260 --> 00:28:20,640 Uh, there's a story behind that, I think I'm going to tell that in a second, I don't remember if it's in the slides, but they published the, the, the GPL code yesterday. 321 00:28:21,420 --> 00:28:26,920 Next to go is Sigma Star SOC, crickets, nothing. 322 00:28:26,920 --> 00:28:28,980 Uh, TP-Link, love it. 323 00:28:28,980 --> 00:28:33,520 They already burn, they already got burned by GPL, so they publish it, they don't argue with that. 324 00:28:33,880 --> 00:28:38,140 Uh, and OBS Bot is another unknown, uh, brand. 325 00:28:38,140 --> 00:28:46,740 OBS is Open Broadcasting Studio, if you're not familiar with it, that's a very popular tool, open source tool to do a lot of video capturing. 326 00:28:47,140 --> 00:28:52,200 So, some companies rebranded it, and is selling cameras. 327 00:28:52,760 --> 00:28:59,800 Sigma Star SOCs, but newer kernel, ask for GPL, no answer. 328 00:29:00,000 --> 00:29:01,580 So, we're going to drop an O there. 329 00:29:02,920 --> 00:29:08,740 Um, this is how the Opal Tadpole motherboard looks like. 330 00:29:08,800 --> 00:29:18,080 Remember I said, in the beginning, the trifecta, you get the SOC, the RAM, and the storage, it's right there, you can see it, it's three chips. 331 00:29:18,360 --> 00:29:23,380 Easiest to recognize, you know, you see this, you get a wide attack surface. 332 00:29:24,820 --> 00:29:35,520 OBS Bot, um, Sigma Star SOC, they were kind enough, to mark on the board, T and R, which is TX and RX. 333 00:29:36,360 --> 00:29:43,200 So, you connect it, and this is what you get. 334 00:29:43,200 --> 00:29:46,120 So, this is going to be an O day, real quick, I'm going to run you through it. 335 00:29:46,540 --> 00:30:04,060 Um, you boot, you hold enter, you get into the boot loader, you print the environment variables, remember print env, you see in the environment variables, it mounts the UBI file system as, um, sorry, I'm going faster than my explanation in the video. 336 00:30:04,060 --> 00:30:11,900 RO, so it's mounting the NAND as read only, and it in it's, into the Linux RC executable. 337 00:30:11,900 --> 00:30:13,660 So, we're going to change those. 338 00:30:18,680 --> 00:30:23,800 We're going to set env, RW, and in it to bin SH, 339 00:30:30,160 --> 00:30:32,720 and save env. 340 00:30:32,720 --> 00:30:33,460 Don't ever forget to save env. 341 00:30:33,460 --> 00:30:33,460 So, we're going to 342 00:30:37,480 --> 00:30:41,000 reboot , because that doesn't work, so type reset. 343 00:30:43,180 --> 00:30:54,100 The camera resets and falls into bin SH, you fall into a root shell, you just change the password, root, root, it's too short, but it will change it anyway. 344 00:30:56,180 --> 00:31:00,500 You reboot, you go back into your boot, and then you have to revert your changes. 345 00:31:01,560 --> 00:31:16,280 So, you change it back to RW, because you don't want anyone messing with your changes, and Linux RC, the usual stack, and it boots into the normal vertical, the normal code, normal camera code. 346 00:31:16,520 --> 00:31:25,260 At the end, it's OBS Linux, OBS boot Linux, you just type root, root, and you have a root shell. 347 00:31:33,270 --> 00:31:36,550 Okay, so, I can't believe I'm saying this. 348 00:31:37,350 --> 00:31:43,030 There's Linux and webcams now, so, go look at that stuff. 349 00:31:45,350 --> 00:31:59,550 There's a whole, like, we've done this 10 years ago, we're going to do this thing again, where you have to do a root of trust, verify firmware signatures, do all that stuff, but now we have to do it in webcams and everything else that runs Linux. 350 00:32:04,560 --> 00:32:13,520 Basically, all the stuff that we have to deal with IoT, move that, move that mindset into USB. 351 00:32:13,520 --> 00:32:17,920 So, think of every USB device also as an IoT device. 352 00:32:19,120 --> 00:32:20,940 Now, GPL compliance. 353 00:32:24,900 --> 00:32:33,840 I've done a lot of, of, of complaining to people for GPL code for this project for a while. 354 00:32:34,580 --> 00:32:39,140 Basically, any device that runs GPL code, you can ask for the source. 355 00:32:41,520 --> 00:32:46,060 They don't usually do that, especially if they're in China. 356 00:32:46,840 --> 00:32:52,540 But, you can, you can harass them into compliance. 357 00:32:53,500 --> 00:32:59,180 Okay, so, there's, there's a way to do this. 358 00:32:59,180 --> 00:33:03,580 You can track people down on LinkedIn and Twitter and social media, which I did in a second. 359 00:33:04,400 --> 00:33:12,280 And you can also contact the Software Freedom Conservancy, and they can help as well. 360 00:33:13,180 --> 00:33:20,920 What I did, I have no shame, so I just contact Opal co-founders on LinkedIn. 361 00:33:20,920 --> 00:33:24,700 I counted the OBS bot CEO on LinkedIn. 362 00:33:25,200 --> 00:33:28,320 The next to go co-founder, I just contacted the co-founders. 363 00:33:28,320 --> 00:33:30,820 I just went, give me code. 364 00:33:30,980 --> 00:33:37,400 And I, pro tip, use GPT to word legal sounding messages. 365 00:33:39,180 --> 00:33:43,420 I got a response on Twitter from one of the co-founders of Opal. 366 00:33:43,420 --> 00:33:46,180 Any, give me a chance , anyone from Opal here? 367 00:33:49,380 --> 00:33:51,480 Ah, thank you for coming. 368 00:33:52,040 --> 00:33:53,460 So, good job. 369 00:33:53,460 --> 00:33:54,940 Get GPL code. 370 00:33:57,260 --> 00:34:03,100 Cool story about Opal, they do firmware updates over web USB. 371 00:34:04,000 --> 00:34:06,800 And because they were good, I'm not going to say more about that. 372 00:34:07,620 --> 00:34:15,920 Um, so, a, a little bit of experience of how to work with PSIRTs as a security, a security researcher. 373 00:34:16,380 --> 00:34:28,960 When you talk to product security response teams, there's a lot of communication that goes on in the background between what the PSIRT team does that face you when you, when you contact Lenovo or any other big OEM. 374 00:34:29,940 --> 00:34:32,020 They have to go talk to their product team. 375 00:34:32,020 --> 00:34:35,520 So there's a lot of sometimes miscommunications. 376 00:34:35,520 --> 00:34:44,000 At first we were told that these devices are end of development and turns out it was not the case. 377 00:34:44,000 --> 00:34:47,520 So we have to, we have to change things. 378 00:34:47,520 --> 00:34:54,140 Anyway, if you've seen the movie, you know how I feel. 379 00:34:54,640 --> 00:34:57,040 This is the Lenovo statement, we're going to skip that. 380 00:34:57,600 --> 00:35:00,480 Updates, links, firmware updates over that link. 381 00:35:01,600 --> 00:35:04,420 Um, this is the disclosure for them. 382 00:35:04,420 --> 00:35:07,080 They, they published it yesterday. 383 00:35:07,540 --> 00:35:10,220 Uh, arbitrary code execution as a medium. 384 00:35:11,040 --> 00:35:13,300 Someone needs to help me math this. 385 00:35:13,860 --> 00:35:24,700 Um, physical access, I don't know, I can have software execution on the host if it's connected to the camera, then I can flash the camera. 386 00:35:24,700 --> 00:35:27,760 I guess you can word it as physical access, I don't know. 387 00:35:28,580 --> 00:35:31,320 Bottom line, this is not a camera . 388 00:35:31,860 --> 00:35:39,660 Uh, I want to thank Rainforest Puppy for, uh, GPL advice and, uh, Case for helping us battling the, the kernel. 389 00:35:40,480 --> 00:35:57,420 There is a bunch of shit on this mega link, um, including an OVA VMware image for you to take, download and install and build your own Sigma Star Kernel and other stuff in the GitHub. 390 00:35:58,040 --> 00:35:58,840 Questions? 391 00:36:00,080 --> 00:36:01,800 Okay, you can clap now, sorry. 392 00:36:06,920 --> 00:36:08,660 We were, we were rushing it a little bit. 393 00:36:08,660 --> 00:36:09,780 We have five minutes, I know. 394 00:36:09,780 --> 00:36:12,780 We, we were stressed out that we won't have enough time. 395 00:36:14,260 --> 00:36:16,760 Okay, now we're open for questions. 396 00:36:18,240 --> 00:36:20,280 Just yell them out if you have them. 397 00:36:21,160 --> 00:36:23,460 Or run to the next talk, it's fine too. 398 00:36:30,860 --> 00:36:37,880 Either yell it louder or... How long did it take us to reverse the camera? 399 00:36:39,420 --> 00:36:40,420 Minutes. 400 00:36:41,280 --> 00:36:44,960 It's, it's basically building blocks that you know exist. 401 00:36:44,960 --> 00:36:49,660 Linux, you look at it, it's like hacking classic IOT but over USB. 402 00:36:51,540 --> 00:36:52,640 Thank you. 403 00:36:54,560 --> 00:36:56,740 More questions, give me more questions. 404 00:36:57,100 --> 00:36:59,160 Yes, yell it out. 405 00:37:03,530 --> 00:37:07,070 Anybody, anybody can buy one of these, flash it and resell it. 406 00:37:07,070 --> 00:37:07,890 Yes. 407 00:37:08,630 --> 00:37:10,210 I have a, I have a question. 408 00:37:10,270 --> 00:37:10,930 Yeah. 409 00:37:10,930 --> 00:37:26,750 I, uh, I bought a, a very similar generic Chinese webcam, uh, about two years ago and a couple of weeks ago I was doing some ADB debugging on my Android phone and when I ran ADB list devices, the camera showed up. 410 00:37:27,110 --> 00:37:28,310 Yeah, that, that'll be it. 411 00:37:28,310 --> 00:37:29,390 Yeah, have fun. 412 00:37:29,570 --> 00:37:30,110 Yeah. 413 00:37:30,110 --> 00:37:30,410 Yeah. 414 00:37:30,410 --> 00:37:31,870 We do that too. 415 00:37:33,670 --> 00:37:35,150 Android's a Linux too. 416 00:37:35,150 --> 00:37:35,690 Yeah, go ahead. 417 00:37:36,270 --> 00:37:39,410 How many times did Linux fail to build? 418 00:37:39,650 --> 00:37:40,690 Oh God. 419 00:37:41,250 --> 00:37:47,290 Um, so Linux failed to build a couple of times but maybe mainly because we got incomplete source. 420 00:37:48,110 --> 00:37:48,230 Oh. 421 00:37:48,930 --> 00:38:05,550 There, there was a bug in... Oh, there, there was a bug in, uh, the HID gadget that we had to patch for getting the, to get the HID stack to work but in the second iteration of GPL code they already gave us the fixed version. 422 00:38:06,210 --> 00:38:07,070 Oh, okay. 423 00:38:07,070 --> 00:38:08,230 So it works . 424 00:38:08,930 --> 00:38:11,150 Yeah, building the kernel is fun. 425 00:38:11,290 --> 00:38:12,710 Just take a deep breath before you do it. 426 00:38:12,710 --> 00:38:13,370 Go ahead. 427 00:38:14,690 --> 00:38:18,650 I think it, you sounded surprised to see Linux in these. 428 00:38:18,650 --> 00:38:21,310 I've, I've been an embedded developer for a long time myself. 429 00:38:21,310 --> 00:38:25,270 What was it you expected to see, like Wind River, FreeRTOS, something like that? 430 00:38:25,270 --> 00:38:31,510 Uh , simple, like it's, it's a freaking convert a CMOS image to USB. 431 00:38:31,510 --> 00:38:31,970 That's it. 432 00:38:31,970 --> 00:38:34,030 It just takes an image and put it on. 433 00:38:34,130 --> 00:38:34,930 Why? 434 00:38:35,090 --> 00:38:37,510 Well, it looked like a... Wait, wait, hold on. 435 00:38:37,530 --> 00:38:38,910 The AIs, I get it. 436 00:38:38,910 --> 00:38:43,710 There's a lot of, you expand things, facial recognition, Windows hello, all that stuff, I get it. 437 00:38:44,490 --> 00:38:55,630 But I was surprised to see it because I wasn't expecting it, I was expecting the host to handle most of the processing versus the camera to do all that. 438 00:38:55,710 --> 00:39:01,330 Do you feel like that's a trend you see accelerating, just shoveling more horsepower into those things? 439 00:39:01,830 --> 00:39:08,010 I'd say over the past ten years there would be a trend of just shoving Linux into things. 440 00:39:08,630 --> 00:39:13,010 How's that affecting like the prototyping cycle for these guys? 441 00:39:13,010 --> 00:39:17,610 Are they kicking stuff out even faster, figuring they can just patch it? 442 00:39:18,990 --> 00:39:23,370 It's, it's a low, it's a, it's a more convenient learning curve. 443 00:39:23,790 --> 00:39:26,830 And it, it helps handle your attrition of staff. 444 00:39:26,930 --> 00:39:34,590 Because all you need to do is bring in people that know Linux and they can pick up where the other left off and just maintain the stack. 445 00:39:35,430 --> 00:39:37,710 I guess it's cheaper. 446 00:39:37,710 --> 00:39:47,310 So by attrition of staff you mean you're seeing kind of the same education fall off in everything that isn't Windows or Linux in China as here? 447 00:39:47,310 --> 00:39:50,410 When I, when I say education of staff I mean learning curve. 448 00:39:50,410 --> 00:39:58,050 If you have a custom SOC with your own custom stack with not, with complicated proprietary code, learning curve is wild. 449 00:39:58,490 --> 00:40:00,210 But if you have Linux it's simple. 450 00:40:00,210 --> 00:40:03,330 Just bring someone who knows the basics, ramp them up fast. 451 00:40:07,710 --> 00:40:11,870 So you mentioned that you were able to get internet access over USB. 452 00:40:11,930 --> 00:40:22,390 Is it possible that you could use this method to implement something like say an IP webcam or like functionally upgrade the camera to do something it didn't do before? 453 00:40:22,670 --> 00:40:24,770 So funny you mention that. 454 00:40:25,170 --> 00:40:32,850 We, we, we were missing files at the end of the, of the cycle of the GPL. 455 00:40:32,850 --> 00:40:34,030 Let's call it that way. 456 00:40:34,530 --> 00:40:41,210 And some, a couple of those files, not you guys, I'm pointing at Opal, not, not you guys, the, the Sigma Star people. 457 00:40:42,490 --> 00:40:51,650 They had kernel modules specifically for the IR SOC, the IR chip and the, the CMOS chip. 458 00:40:52,310 --> 00:41:00,270 So we were hoping we can get those kernel modules and just use an interpreter and just webcam, snapshot, go wild. 459 00:41:00,450 --> 00:41:02,370 But we didn't get that in time. 460 00:41:03,190 --> 00:41:04,210 So, yeah. 461 00:41:04,450 --> 00:41:07,950 You can do, you can do crazy stuff with this. 462 00:41:07,950 --> 00:41:09,650 It's a computer on a USB. 463 00:41:09,970 --> 00:41:12,430 It's a bash bunny basically with a camera. 464 00:41:15,050 --> 00:41:16,350 More questions? 465 00:41:16,430 --> 00:41:22,550 We got no time, so catch me in the hallway.