00:00:00.067,00:00:05.205 >>Uh next up we have Smea talking about real penetration testing. Please give him a warm 00:00:05.205,00:00:10.210 welcome. [applause] >>Alright uh hi everyone uh as mentioned I am Smea and today I will be talking 00:00:17.618,00:00:22.623 about how to hack a buttplug. Um this is 1 of those just FYI, I don’t know if you’ve ever seen 1 00:00:24.625,00:00:30.664 in person, I had not. Um but I’ve been introduced to a lot of things over the past 2 years so, 00:00:30.664,00:00:35.569 you know, here we are. Uh you might be wondering what’s like, what does it even mean to hack a 00:00:35.569,00:00:39.072 buttplug? Because you know if- if you take a look at this it’s basically just like a piece of 00:00:39.072,00:00:42.342 silicone, obviously you are supposed to put it somewhere. Umm [audience groans] there’s 00:00:42.342,00:00:46.413 not much to it right? You don’t really need uh any electronics in here. But over the past 00:00:46.413,00:00:51.318 couple years- uh or couple of years I mean like past few decades even actually there’s 00:00:51.318,00:00:57.257 been uh the emergence of this uh new field called uh teledildonics. Um look at the 00:00:57.257,00:01:01.528 etymology for this, uh you know it’s from the Greek tele which means from afar uh and the 00:01:01.528,00:01:06.400 English dildo which apparently just means dildo. There’s no origin I tried to look it up uh 00:01:06.400,00:01:10.404 no one knows where this word came from. Uh but yeah it’s- it’s pretty self explanatory, 00:01:10.404,00:01:15.409 right? The idea is that you want to make sex toys that are controlable remotely uh, in- in 00:01:15.409,00:01:21.114 some way. Uh it actually uh you know enables a number of different scenarios. Um 00:01:21.114,00:01:24.484 basically [laughter] I ju- I just want to explain to you because not everyone is familiar 00:01:24.484,00:01:28.822 with this field, ok? Just want to explain how this works. Uh so you take this butt plug right, 00:01:28.822,00:01:34.294 uh you insert it [laughter] um eh and from there you- you- you’re actually able to like 00:01:34.294,00:01:38.432 control it from eh from your phone. Uh your phone from your laptop from any kind of device 00:01:38.432,00:01:41.635 really. So that’s that’s the first scenario. Second scenario is like technically kind of the 00:01:41.635,00:01:46.707 same thing it’s just you end up giving control to you know someone else. [laughter] Now 00:01:46.707,00:01:50.944 this is- this is an actual thing. Um and so they actually advertise this for like oh you 00:01:50.944,00:01:55.415 can like go up to the bar and like no one will know uh it’s kind of fun. Uh but technically 00:01:55.415,00:01:59.252 it’s like the exact same thing it’s just, it opens up you know a new kind of attack scenario 00:01:59.252,00:02:03.991 because you’re giving control over to possibly a stranger or you know someone else uh which 00:02:03.991,00:02:08.729 does change the threat model here. Uh the third scenario is gonna be the same thing, you 00:02:08.729,00:02:12.966 give control over to someone else but this time it’s gonna be over the internet. Um and you 00:02:12.966,00:02:16.236 can- you know you can kind of think of that as it’s probably not gonna be a stranger but it 00:02:16.236,00:02:20.941 might be. Uh it’s gonna be enabling uh people in long distance relationships possibly 00:02:20.941,00:02:26.580 to to- have some fun which is pretty cool. Um but but the real- where the real money is is 00:02:26.580,00:02:31.418 actually with using this uh as- as a sex worker and I’m [laughter] I’m not trying to 00:02:31.418,00:02:35.389 make a joke out of this. Like people actually do rely on these uh on these- on these things as- 00:02:35.389,00:02:41.395 as tools to make a living right? Um and in my opinion this actually is uh something that 00:02:41.395,00:02:45.399 kind of gives some legitimacy to this research because you know I’m I’m just hacking buttplugs 00:02:45.399,00:02:49.469 yes that’s funny but people do actually make a livelihood off of this, right? Uh it’s like 00:02:49.469,00:02:53.306 some scenarios are gonna be you know cam girls, cam boys, uh whatever you wanna call them, 00:02:53.306,00:02:59.513 people who uh basically provide dynamic you know sex entertainments uh over the 00:02:59.513,00:03:04.017 internet are getting paid to have people watch them and they sometimes have the ability to 00:03:04.017,00:03:08.588 you know get paid to give control over to their sex toy. Um they the company that makes 00:03:08.588,00:03:15.095 this butt plug actually has a patent on the concept of tipping money over the internet to 00:03:15.095,00:03:19.366 control a buttblug. Um which you know that’s a whole nother debate but it is kind of 00:03:19.366,00:03:23.403 interesting. The- 1 of the scenarios also is like you can- you can either yeah uh have it 00:03:23.403,00:03:28.508 vibrate in exchange for you know a 5 dollar tip or something, but it can also be you create a link 00:03:28.508,00:03:32.412 to control your buttplug and you give it out to someone on Twitter or someone on whatever 00:03:32.412,00:03:37.751 um just to give them control for a limited amount of time. Uh so people actually do you know rely 00:03:37.751,00:03:42.556 on these as tools for their work so it’s kind of important in my opinion to take a look at what 00:03:42.556,00:03:47.327 the security posture is here. Uh and so the security posture like let’s think about scenarios that 00:03:47.327,00:03:50.764 are interesting for- for us in- in terms of hacking these butt plugs. 1 of them is just gonna 00:03:50.764,00:03:54.668 be ok well you’re you’re using this locally, and someone is within the vicinity, notices 00:03:54.668,00:03:59.039 that you have a butt plug in and tries to hijack that connection. Uh there’s actually already been 00:03:59.039,00:04:02.843 a bunch of research into this so that’s not going to be our primary focus- focus here uh but 00:04:02.843,00:04:06.947 it is definitely a scenario that is kind of interesting. Uh we will note that you know doing 00:04:06.947,00:04:12.419 this might technically be sexual assault; I don’t know, uh it’s problematic. Please don’t do it 00:04:12.419,00:04:16.890 whether it’s legal or not, just don’t be a dick. Uh second scenario that’s kind of 00:04:16.890,00:04:22.462 interesting [scattered applause] is gonna be um. Is gonna be uh looking at doing the exact same 00:04:22.462,00:04:26.867 thing but remotely, right? Uh as I mentioned uh in some cases uh especially if you’re making 00:04:26.867,00:04:30.804 money off of this, you might be giving control over to from of your sex toy to a complete 00:04:30.804,00:04:34.808 stranger. Uh what does that mean? Are they going to be able to you know compromise your- 00:04:34.808,00:04:39.613 your devices, or compromise your butt plug, or do whatever, do something bad. Uh so that’s a 00:04:39.613,00:04:43.850 compromise scenario that’s totally legit and uh and- and more interesting in my opin- in 00:04:43.850,00:04:48.588 my opinion uh and kind of what we’re going to be focusing on. Uh and the third compromising 00:04:48.588,00:04:53.460 scenario uh would be the opposite, uh thinking about having someone who has a hostile 00:04:53.460,00:04:59.199 butt plug basically uh [laughter] who might be able to hack back into your computer, 00:04:59.199,00:05:03.537 into your phone or whatever, and then possibly hack into whoever is connected on the other end; 00:05:03.537,00:05:07.807 uh which is the other scenario that I don’t think people realize this is a real risk of 00:05:07.807,00:05:12.679 you know the hostile butt plugs in this world, so [laughter] This is something that we will 00:05:12.679,00:05:18.318 be exploring. Taking a look in practice. Uh now that we’ve uh you know introduced the whole 00:05:18.318,00:05:21.855 world of teledildonics, what does it look like in practice? Uh this is the Lovense Hush uh 00:05:21.855,00:05:27.194 which I will be doing a live demo on later on, just FYI. Uh it’s billed as the world’s first 00:05:27.194,00:05:32.199 teledildonic butt plug. Uh as mentioned it’s a butt plug. Uh I’m gonna just be saying butt 00:05:32.199,00:05:36.136 plug a lot in this talk just FYI [laughter] um and you can control it from your phone. It 00:05:36.136,00:05:40.073 has an IoS app, an Android app, you can control it from your computer; works on Mac OS and 00:05:40.073,00:05:44.644 Windows. Uh and on Windows you actually do need to use a special USB dongle which I would 00:05:44.644,00:05:48.815 show you but it’s plugged into my computer right now. Uh so that dongle is made by Lovense, 00:05:48.815,00:05:53.053 so the same company that makes these b- these butt plugs. And uh and yeah it’s like 5 dollars 00:05:53.053,00:05:56.890 it’s kind of interesting we’re gonna look into that. Uh and then you know the app actually 00:05:56.890,00:06:01.061 introduces uh social features so you can uh chat, video chat, uh send pictures, and then 00:06:01.061,00:06:06.433 obviously give control to your butt plug over to someone else. So in terms of uh you know kind 00:06:06.433,00:06:10.170 of like the threat map uh in my mind, uh this is what it looks like if you’re thinking about 00:06:10.170,00:06:15.976 the PC app. Uh so you have a BLE connection between the butt plug and the uh dongle and then the 00:06:15.976,00:06:21.348 dongle obviously is connected over USB uh and so on, right? Uh so the question here is: what 00:06:21.348,00:06:25.218 can you- what does it look like for each compromise scenario? What- well for the local case 00:06:25.218,00:06:28.922 it’s just compromise scenario 1, you just want to compromise the BLE connection. Uh again there’s 00:06:28.922,00:06:33.226 already been research in this, uh basically there’s no security there; anyone can uh kinda just 00:06:33.226,00:06:37.330 hijack that connection. There was a great talk last year uh about a tool called BTLE jack 00:06:37.330,00:06:41.167 which you can just totally uh use to take over this so that’s not what we’re gonna focus on. 00:06:41.167,00:06:47.774 Um the second uh kind of uh s- uh scenario for compromise was over the internet so we kind of 00:06:47.774,00:06:52.078 hijacking that connection somewhere or thinking about uh seeing how you can uh compromise 00:06:52.078,00:06:56.283 1 app from the other. And the first scenario uh is going to be trying to hack into the butt 00:06:56.283,00:07:01.488 plug, trying to hack into the dongle, trying to hack into the app, each from 1 to the other uh 00:07:01.488,00:07:06.760 and so that actually involves a lot more research. Uh the question is you know this is a 00:07:06.760,00:07:10.530 butt plug obviously it’s- well- I mean not obviously, there is actually an open source uh butt 00:07:10.530,00:07:14.734 plug project apparently. Um [laughter] No I’m not- I’m making a joke. It’s apparently 00:07:14.734,00:07:20.273 good work. Um and uh so the question is well where do we start right? I- I- I started 00:07:20.273,00:07:22.475 working on this, I was like “Well I don’t have- I dont have the code for the butt plug I 00:07:22.475,00:07:26.246 don’t have the code for the- the dongle so what do I do?” Well the PC app you can just download 00:07:26.246,00:07:30.517 it and put it into IDA and see what happens. Um turns out you actually don’t even need to put 00:07:30.517,00:07:34.621 it into IDA, because of course it’s a multi- uh platform app, it works on both Windows and 00:07:34.621,00:07:37.891 MacOS so of course it’s an electron app so of course everything is written not in 00:07:37.891,00:07:42.429 javascript. I don’t love javascript uh but the nice thing about it is that it does end up 00:07:42.429,00:07:47.033 uh still having a bunch of variable names, uh a bunch of uh field names for these objects uh 00:07:47.033,00:07:52.405 so it is kind of you know easy to reverse en- reverse engineer. Uh it is obfuscated but you can 00:07:52.405,00:07:57.477 just throw it in to a beautifier and try to figure out how things are going. Um and uh and yeah so 00:07:57.477,00:08:00.547 once you’ve done that you can just kind of like start looking for how the dongle works. Uh 00:08:00.547,00:08:05.885 turns out it’s just a serial port connection over USB. Um and and that uh allows you to start 00:08:05.885,00:08:10.490 then sniffing the connection between the dongle and uh the app. And 1 thing that you will 00:08:10.490,00:08:14.994 notice uh the uh- the sniffing uh data is on the right here; is that all these messages being 00:08:14.994,00:08:20.166 sent between the dongle and the- and the computer app are all in JSON. Uh which is kind of 00:08:20.166,00:08:24.637 interesting because, well JSON is obviously you know native for javascript apps and stuff so 00:08:24.637,00:08:28.975 that’s convenient. However for a USB dongle that is just basically a you know- a 32 bit 00:08:28.975,00:08:33.079 microcontroller, it’s kind of weird to have- to embed a JSON parser in there. And for us 00:08:33.079,00:08:37.083 it’s- it’s a good thing though because JSON parsers uh you know it’s a parser, there will 00:08:37.083,00:08:41.287 probably be a bug in there. Turns out there is a bug in there. Um but it’s kind of 00:08:41.287,00:08:45.525 annoying to uh to take a look at that without having the code of the- of the actual dongle. Uh 00:08:45.525,00:08:49.028 however since we do have the code of the app we can take a look at the update mechanism 00:08:49.028,00:08:54.200 because they have uh firmware updates for the uh USB dongle. From there you can find the URL 00:08:54.200,00:08:58.071 from which to dow- download that firmware and uh download it and see if it’s encrypted or signed 00:08:58.071,00:09:02.942 or anything. Uh turns out it’s none of these things so you can just grab it uh unzip it uh 00:09:02.942,00:09:07.113 throw it into IDA and uh see what it looks like. Uh from there we can kinda notice that 00:09:07.113,00:09:13.620 yeah it’s- it’s thumb-code um so it’s it’s pretty- pretty classic uh yeah uh ARM firmware code. Uh 00:09:13.620,00:09:17.524 throw it into IDA you can kinda see how it looks, start reverse engineering you notice- whoops. 00:09:17.524,00:09:23.363 Notice 2 things. Um first thing is it has 2 command handlers over USB, uh USB serial. 1 of 00:09:23.363,00:09:27.167 them is like these simple commands uh such as reset or like asking for the vice types 00:09:27.167,00:09:32.439 stuff like that. The other 1 is it basically if it doesn’t find a um a simple command it’s going 00:09:32.439,00:09:35.942 to throw it into the JSON parser which is what we expected uh and that’s where we can start 00:09:35.942,00:09:40.480 looking for bugs. 1 thing that is interesting is uh in the process symbol command’s uh 00:09:40.480,00:09:44.684 function is it does have a command for DFU uh so that’s device firmware update. So as 00:09:44.684,00:09:50.623 expected we do actually have the ability to uh to send these uh commands and get it into um uh- 00:09:50.623,00:09:54.561 firmware update mode. But looking into the JSON parser which is uh what we’re 00:09:54.561,00:09:59.399 interested in here. Uh of course we end up finding a bug uh the bug is in this function called 00:09:59.399,00:10:04.604 parse JSON string. Um and uh basically the- the- that function is just supposed to 00:10:04.604,00:10:09.375 allocate new buffer, copy the initial string into the uh- the- into that new buffer while also 00:10:09.375,00:10:15.014 handling things like escape sequences. Um the problem is uh the way that it works is first 00:10:15.014,00:10:17.650 it you know it calculates the len- the length of the new buffer that it’s going to 00:10:17.650,00:10:21.588 allocate then it allocates it and then it does that copy and so of course there’s a mismatch 00:10:21.588,00:10:26.092 between uh the length that it calculates and the length that it’s going to um actually use 00:10:26.092,00:10:32.532 at- at- at the end there. Uh the way that it works is that it supports uh you know the uh U 00:10:32.532,00:10:38.071 escape character sequence uh which takes 5 parameters instead of just you know 0 as uh- as it 00:10:38.071,00:10:43.443 expects. Uh and so because of that we’re actually able to kind of escape the uh null terminator 00:10:43.443,00:10:48.281 and make it such that the uh string length that was calculated first is uh is wrong. 00:10:48.281,00:10:53.286 So it’s a little animation here. Um. What’s going on here is that it starts calculating the 00:10:56.156,00:10:59.726 length, it runs into this escape character so it skips a character and then it finds the 00:10:59.726,00:11:04.697 null- k- null terminator and that’s the string uh- string length it’s calculating. Then 00:11:04.697,00:11:09.769 this loop that actually copies into that buffer. What happens is it runs into the escape 00:11:09.769,00:11:14.340 character, uh sequence. So it says ok there’s a backslash there’s a U that means that I 00:11:14.340,00:11:20.246 need to skip 6 characters. And so it’s actually skipping over the uh null terminator, which is 00:11:20.246,00:11:25.518 uh a problem. And then just kind- it kind of keeps going, it’s going to be copying all 00:11:25.518,00:11:29.322 these characters into that buffer which is only 6 bytes in length. So obviously there's a 00:11:29.322,00:11:34.060 problem, we can uh overflow out of the- out of this buffer and kind of just get code execution 00:11:34.060,00:11:39.465 that way. This is great, uh we do have this bug. At this point we don’t actually know uh what 00:11:39.465,00:11:43.570 the hardware is running, we don’t know you know- uh if it has DEP or anything like that. 00:11:43.570,00:11:48.708 Which uh kind of complicates um exploitation. So we do know there’s no SLR there’s no stack 00:11:48.708,00:11:52.445 cookies, so it’s basically hacking like it’s 1999 assuming there’s no DEP which is pretty 00:11:52.445,00:11:57.884 cool. Uh turns out the SoC is just a Nordic semiconductor SoC, uh very classic uh SoC using uh 00:11:57.884,00:12:03.690 a bunch of BLE IOT devices. Uh the nice thing is they also left us a bunch of debugging pads so 00:12:03.690,00:12:07.226 we can just connect to it, solder a couple things, and all the sudden we can just debug 00:12:07.226,00:12:11.598 this um- this dongle which is pretty great. Being able to debug the dongle, we can kinda 00:12:11.598,00:12:16.235 dump the contents of the heap. See what's there. It turns out the heap is only used for the uh 00:12:16.235,00:12:20.907 JSON allocators, uh the JSON parser so that’s not super great but it does also include uh 00:12:20.907,00:12:25.812 metadata. So what you’re gonna see here is that uh for each allocation you have a length 00:12:25.812,00:12:30.817 field as well as a um, as a uh next pointer for the free list assuming the allocation has been 00:12:30.817,00:12:36.155 freed. Uh so the easy thing here is that yes we can use our overflow to corrupt a length 00:12:36.155,00:12:42.262 field uh put to be zero that way um and then corrupt the uh the next pointer field that way the 00:12:42.262,00:12:47.267 next allocation assuming the pointer field points to uh a non 0 like a big enough value uh 00:12:47.267,00:12:53.406 we’ll be you know placed there. Uh and since we can place the allocation there and then uh 00:12:53.406,00:12:59.646 copy a new string into it, it’s very easy for us to um to use this to basically write 00:12:59.646,00:13:04.017 arbitrary data in arbitrary location. We can do this while the debugger uh connected and as 00:13:04.017,00:13:08.488 you can see on the right here, um we- we have the stack basically is being dumped and 00:13:08.488,00:13:12.191 the stack has been completely overwritten with just 8 characters uh that gives us code 00:13:12.191,00:13:17.697 execution on the USB dongle and uh that’s pretty cool. Um from there uh we unfortunately 00:13:17.697,00:13:22.969 remembered that there was a DFU mode on the dongle all along, uh and the DFU mode you know I 00:13:22.969,00:13:27.674 would expect coming from a video game hacking uh background I expected the DFU like the device 00:13:27.674,00:13:31.944 firmware update mode to just kind of you know, authenticate the update in any possible way. 00:13:31.944,00:13:37.817 Turns out, it kind of does with a CRC16 uh which if you know anything about crypto is not any 00:13:37.817,00:13:41.688 kind of authentication. I don’t think that they actually wanted to have authentication there, 00:13:41.688,00:13:46.159 they just kind of figured that “Well, who cares about getting you know code execution on a USB 00:13:46.159,00:13:51.264 butt plug dongle. Uh turns out I do. Uh so that’s unfortunate.[laughter] Uh but it 00:13:51.264,00:13:54.701 is- it is uh interesting uh at this point basically we have 2 different ways of getting code 00:13:54.701,00:13:59.238 execution on this dongle uh and the do- the JSON Parser way you know I- I- that I mentioned I 00:13:59.238,00:14:03.276 spent a lot of time on it, might not seem very useful because we have a device firmware update 00:14:03.276,00:14:06.913 mode but it turns out is actually going to come up again later with uh- with another 00:14:06.913,00:14:10.283 vulnerability that we’re gonna chain together so, you know I- I didn’t just say all that for 00:14:10.283,00:14:14.954 nothing. The point is, we can get code execution, uh we can flash on firmware, which is 00:14:14.954,00:14:19.492 pretty great. So at this point we have a compromised USB dongle from a PC app which is like yay 00:14:19.492,00:14:24.397 that was definitely the easiest part. Um from here what we want to do since we have control of 00:14:24.397,00:14:28.768 the dongle in theory, we should uh be able- well we want to like figure out a way to somehow get 00:14:28.768,00:14:34.140 code execution on the butt plug because you know- that’s kind of what we do. Um looking at the 00:14:34.140,00:14:37.677 hardware on the butt plug uh turns out that you know there was a debugger on the dongle, so 00:14:37.677,00:14:42.682 it might make sense to take a look at it. Uh it’s a s- very similar SoC, uh so it’s another 00:14:42.682,00:14:47.820 Nordic semiconductor SoC uh it’s a little bit beefier, it’s an M4 instead of an MM0, it has more 00:14:47.820,00:14:52.959 flash, has more ram, it’s pretty great. Um but it is the same technology basically uh just 00:14:52.959,00:14:58.131 more up to date. Um so the the nice thing is yeah we can’t- we can expect that there won’t be 00:14:58.131,00:15:01.768 any DEP, there won’t be any like more advanced mitigations on the- on the dongle so it’s 00:15:01.768,00:15:04.971 pretty easy. From there there’s a bunch of other things that were not on the uh- the USB 00:15:04.971,00:15:10.143 dongle board but there are a few things that were which is the SWD uh test point so with that 00:15:10.143,00:15:14.480 we can actually debug a butt plug. And this is what it looks like in practice, uh I’m kind of 00:15:14.480,00:15:18.184 terrible at soldering but I do have a bunch of buttplugs like this that are opened uh in my 00:15:18.184,00:15:24.657 bag. Um [laughter] uh so you know I- I don’t know why I’m telling you this but this is 00:15:24.657,00:15:29.295 pretty cool. Uh [laughter] from there uh the nice thing about being able to debug a butt plug 00:15:29.295,00:15:34.066 is that you can actually use this to dump the firmware. Uh and from there you know kind of 00:15:34.066,00:15:40.072 figured that if the dongle update mode was so insecure uh maybe the- you know maybe the 00:15:40.072,00:15:44.777 buttplug also had an update mode which is also super insecure. Uh it turns out that yes it does, 00:15:44.777,00:15:48.948 if you send it the same- the exact same DFU command that you sent the dongle, it will also go 00:15:48.948,00:15:53.019 into device firmware update mode. And from there you- there’s actually an app that uh 00:15:53.019,00:15:58.758 Nordic ships which is the nRF Toolkit app, uh or Toolbox app, it will just let you flash new 00:15:58.758,00:16:03.963 firmware to it. Uh at this point we don’t actually know the DFU mode is uh- as insecure as the 00:16:03.963,00:16:09.302 dongle, uh it could have been that they implemented uh you know asymmetrical keys uh to uh 00:16:09.302,00:16:15.107 to kind of uh authenticate the firmware. Of course fortunately for us they didn’t. Uh so you 00:16:15.107,00:16:21.480 can just kind of dump the- the buttplug firmware from uh from SWD, modify it, compute the new 00:16:21.480,00:16:25.184 CRC16, send it over. And this way you can see uh on the right here is the you have WireShark 00:16:25.184,00:16:30.189 uh the little WireShark uh trace there that kind of just see, uh has uh, the uh- the buttplug 00:16:33.092,00:16:37.897 sending back a little message saying hello from plug. Uh which means that yes we obviously we 00:16:37.897,00:16:41.133 just got code execution on the butt plug by not even doing anything, there’s no 00:16:41.133,00:16:45.571 vulnerability here it’s just- it’s just kind of by design you can uh reflash it, which might 00:16:45.571,00:16:49.942 be Lovense’s attempt to like, open up to the- open source community; it’s possible, it’s 00:16:49.942,00:16:52.812 unlikely. But the point is anyone who can connect to your buttplug at this point can get 00:16:52.812,00:16:57.817 code execution on it. Uh which seems kind of dangerous. At this point we do still require uh 00:17:02.889,00:17:07.193 being local like being in the uh- the physical vicinity of the butt plug to get code execution 00:17:07.193,00:17:11.464 on it, so that’s probably not as big a deal as uh, as we’d want it to be. But it’s still a good 00:17:11.464,00:17:15.434 question of being like “Ok, we have code execution on the butt plug, what can we do with this?” 00:17:15.434,00:17:19.205 Well there’s a few ideas that I had. The first 1 is if you can get code execution on the butt 00:17:19.205,00:17:24.710 plug, you can actually create butt plug ransomware. Uh [laughter] [coughs] you know 00:17:24.710,00:17:29.048 modify that firmware, you make it such that the DFU mode can’t be enabled until uh you give it 00:17:29.048,00:17:33.219 a certain key or something, and then you- you know you just- disable all the code that 00:17:33.219,00:17:37.290 creates vibrations and yeah you have your own r- ransomware you can ask maybe for like 50 bucks 00:17:37.290,00:17:43.095 to unlock it and protect it from future uh butt plug ransomware. Uh kind of butt plug vaccine if 00:17:43.095,00:17:47.233 you will. Uh so this is uh 1 scenario that could work. Another scenario that is kind of 00:17:47.233,00:17:51.938 interesting but I did not really look into that much is the idea of like weaponizing a butt plug 00:17:51.938,00:17:56.409 or any other sex toy like physically. Um and you know in the case of butt plug it really 00:17:56.409,00:18:01.714 just has 1 motor and uh a little battery, well like uh a pretty big battery actually, like I 00:18:01.714,00:18:05.184 guess probably 80 percent of the butt plug is a battery. So the question is you know I don’t 00:18:05.184,00:18:09.322 know if you remember like what happened with all these uh Samsung Galaxy Note phones when 00:18:09.322,00:18:13.926 they were like just kind of blowing up [crowd groans] well it- it might you know possibly 00:18:13.926,00:18:20.366 be possible to, you know.[chuckles] [audience laughs] Again, I’m not an 00:18:20.366,00:18:23.536 electrical engineer, I don’t know if this is actually possible, it probably isn’t, but 00:18:23.536,00:18:27.907 if it was, this would be bad. Um so you know um I’m gonna assume that this is not possible but it 00:18:27.907,00:18:30.743 is something that is worth thinking about because you do have actually a lot of other sex 00:18:30.743,00:18:35.181 toys that have other um- other things then a motor. Right? Uh you have sex toys that 00:18:35.181,00:18:39.385 apparently have- I I was looking at the code of the app uh and uh looking at all of the different 00:18:39.385,00:18:43.789 commands that work for different sex toys. There’s a command that it says that just says rotate so 00:18:43.789,00:18:48.594 clearly there’s some kind of moving part in this uh sex toy. Uh and I’m wondering you know 00:18:48.594,00:18:52.565 maybe, maybe there’s like a safety feature for that motor that is actually encoded in the 00:18:52.565,00:18:56.602 software right? Instead of in the hardware. So getting code execution on it could have uh 00:18:56.602,00:19:00.439 bad consequences. Same thing I think there’s like another sex toy that has some kind of uh air 00:19:00.439,00:19:05.011 pump uh which seems dangerous but I don’t actually know if it could be uh problematic. So it’s 00:19:05.011,00:19:09.382 something that’s worth looking into. And finally we do have our last thing which is the hostile 00:19:09.382,00:19:14.854 butt plug. Hostile in terms not of you know exploding your butt but as much as uh kind of trying 00:19:14.854,00:19:19.525 to hack into your other devices. Uh so that is something that’s worth thinking about and that’s 00:19:19.525,00:19:22.828 what we’re gonna be looking into, it’s like ok we have code execution on this, we know we 00:19:22.828,00:19:27.033 can do inherent ransomware, but can we start hacking other devices from our butt plug? Of 00:19:27.033,00:19:30.736 course the answer is gonna be yes. But for now I’m gonna pretend that we don’t know that. 00:19:30.736,00:19:36.042 So uh interestingly, uh well at this point we have code execution on butt plug, we have 00:19:36.042,00:19:40.780 to figure out if we can get code execution in the app from that butt plug so doing that is as 00:19:40.780,00:19:45.284 simple as trying to look into the uh- the way that the app kind of handles incoming 00:19:45.284,00:19:49.388 messages, right? Uh so first thing, so this is like the call back on the left uh in 00:19:49.388,00:19:54.093 javascript uh I guess this is how it works to talk over uh serial ports in uh in electron 00:19:54.093,00:19:59.131 app. Uh and what it does is it gets it N, N is like the incoming data, uh throws it into 00:19:59.131,00:20:04.270 uh, well it- it- it casts it to a string then it throws it to a bunch of different functions. 00:20:04.270,00:20:07.740 The first function is find dongle which basically just handles uh 1 of the 00:20:07.740,00:20:12.712 initialization messages that comes from the dongle. Uh the second 1 is onData, so this is 00:20:12.712,00:20:19.218 like the actual main uh command uh response uh handling loop, uh handling function. Uh and what 00:20:19.218,00:20:23.556 it does is yeah it takes this incoming JSON blob uh which can only be up to 32 characters in 00:20:23.556,00:20:27.793 length uh by the way. Uh I’m not sure why I didn’t mention that earlier, uh it’s kind of come up 00:20:27.793,00:20:33.599 in just a few minutes. Um so it it’s just going to parse that and it’s going to then use it to 00:20:33.599,00:20:37.336 do whatever. Uh it doesn't actually do a lot of processing on this uh- on this, it’s just 00:20:37.336,00:20:41.006 going basically going to like circumpair it to something be like oh what’s your status? Like 00:20:41.006,00:20:46.479 what’s your um- how- what’s your battery uh life? And stuff like that. Uh and the last function 00:20:46.479,00:20:50.449 that it calls into is actually much more interesting for us. Uh it’s- surprisingly it’s much 00:20:50.449,00:20:54.220 more interesting it’s uh I call it debug log, it doesn't really have a name in the actual code. 00:20:54.220,00:20:58.758 But what it does is it logs the uh- whatever’s incoming, like the serial data, it throws it to 00:20:58.758,00:21:04.096 the console that error um function. Uh so it prints it out to uh to console as uh- as an 00:21:04.096,00:21:08.901 error messages for some reason. But what it also does is it creates a new DOM eh- element, 00:21:08.901,00:21:14.106 like an HTML element, and it throws the entire contents that it just received over serial 00:21:14.106,00:21:19.812 into that element as HTML. Uh now I’m not a web dev but if you are you will probably think that 00:21:19.812,00:21:25.718 this is a massive uh cross side scripting vulnerability from a butt plug dongle. Uh so from 00:21:25.718,00:21:29.522 there basically, if you have control of the dongle and you can send anything over uh 00:21:29.522,00:21:35.728 serial, you can actually get the electron app to interpret that anything as being HTML. Uh 00:21:35.728,00:21:41.267 that’s problematic because HTML uh will have the ability to spawn uh new javascript code, 00:21:41.267,00:21:45.437 and new javascript code in an electron app uh basically is just yeah it just compromises 00:21:45.437,00:21:48.874 the computer because there’s no sandboxing or anything. So the question is: can we actually do 00:21:48.874,00:21:52.912 that with our limitation of having only 32 characters at a time? Uh turns out yes, 00:21:52.912,00:21:58.050 absolutely, we can absolutely do that. 1 of the uh ways of doing it is what I was showing on the 00:21:58.050,00:22:02.888 on- on the right up there. Uh you have an- an image uh tag with a source that doesn’t exist 00:22:02.888,00:22:08.594 and then you have the on error callback which is going to be called whenever they, uh 00:22:08.594,00:22:12.731 whenever it can’t actually be loaded. And so the screen shot is just showing that plugging in 00:22:12.731,00:22:17.403 this malicious dongle is going to allow you to uh execute javascript code in the app. So 00:22:17.403,00:22:22.875 that’s problematic. Uh it’’s kind of annoying to get a huge payload just because of um of 00:22:22.875,00:22:26.445 the fact that we can only do 32 characters at a time, but it’s entirely possible. So at this 00:22:26.445,00:22:31.183 point we’ve actually compromised the app from the USB dongle. So we’re halfway there to kind of 00:22:31.183,00:22:36.188 making it back to- from from our butt plug to the app which is pretty cool. Uh. Now of course 00:22:38.891,00:22:44.063 the question is uh because you know what the dongle does essentially is just act as a 00:22:44.063,00:22:49.368 little bridge between the dongle uh- between the butt plug and the app. Uh the question is: 00:22:49.368,00:22:54.206 whether we can just do- use the exact same vulnerability to uh compromise the uh the app from 00:22:54.206,00:22:58.877 the butt plug directly. Unfortunately the answer to that is no and the reason is that we 00:22:58.877,00:23:04.049 have another uh character length limitation on the messages that are coming from uh- from the 00:23:04.049,00:23:08.420 butt plug to the toy- to- to the app. The way it does- uh does this is on the right you have 00:23:08.420,00:23:14.226 this code that is in the- uh that is in the uh- the dongle uh- the dongle firmware. What it 00:23:14.226,00:23:18.130 does is it just grabs incoming data, if it sees that it’s more than 20 characters it just kind 00:23:18.130,00:23:22.901 of cuts it there and copy pa- uh copies it into the new buffer. Now a new buffer is actually on 00:23:22.901,00:23:27.406 the stack. And uh 1 of the, there’s actually a vulnerability there which is that they don’t 00:23:27.406,00:23:32.077 uh null terminate the- that- that string. So if you’re able to place some uninitialized data 00:23:32.077,00:23:35.914 after the string, you can actually send more than 20 characters up to the- up to the 00:23:35.914,00:23:40.486 app. Uh unfortunately I did not find a way to actually exploit this but it is uh it is a kind 00:23:40.486,00:23:46.325 of vulnerability so it’s it’s worth keeping in mind. [coughs] So uh problem here is yeah we 00:23:46.325,00:23:50.529 can’t actually use this to get code execution directly on the app from the butt plug. Which is 00:23:50.529,00:23:56.168 kinda sad. But- uh well it’s kinda sad for 1 thing uh what’s also kind of sad is that if you 00:23:56.168,00:23:58.837 took a look at that code there, it basically doesn’t really do anything with the input. It 00:23:58.837,00:24:02.641 literally just copy pastes it into a new string and sends that new string up. So we can’t 00:24:02.641,00:24:07.680 really find uh uh- any kind of um of uh you know uh memory corruption vulnerabilities in 00:24:07.680,00:24:12.351 the actual butt plug specific code. However uh the 1 thing that’s pretty cool is that 00:24:12.351,00:24:15.621 there’s way more code on this microcontroller then just the butt plug specific code that was 00:24:15.621,00:24:19.591 written by Lovense. There’s also this whole uh soft device region which is at the bottom of 00:24:19.591,00:24:24.630 memory. It’s uh it’s based at 0. Uh and so what this soft device is is basically a driver for 00:24:24.630,00:24:28.667 that SoC that was written by uh Nordic Semiconductors themselves. And so it’s going to 00:24:28.667,00:24:32.404 contain everything that you need to interface uh- interface with the hardware without having to 00:24:32.404,00:24:36.809 rewrite everything yourself. And so that’s going to include the BLE stack, uh so all the code 00:24:36.809,00:24:41.714 that’s going to handle the BlueTooth low energy protocol. Uh and so it might be possible 00:24:41.714,00:24:44.750 for us to take a look at that, kind of reverse engineer it because obviously it’s not open 00:24:44.750,00:24:50.222 source, and uh find a vulnerability in the Bluetooth- uh Bluetooth low energy stack. 00:24:50.222,00:24:53.726 That’s just what we did, uh in order to hack a butt plug we were finding bluetooth 00:24:53.726,00:25:00.132 vulnerabilities. Um and uh and yeah so so because we- we can kind of debug it- um debug that 00:25:00.132,00:25:03.702 the- buttplug or or the- the dongle firmware, it’s actually really easy to ju- kind of just 00:25:03.702,00:25:08.273 like follow uh the flow of data because there’s also no SLR and then it’s really easy to define 00:25:08.273,00:25:12.277 the code that is going to be uh handling those message. Uh and on the right here we actually 00:25:12.277,00:25:17.716 have 1 of those functions that handles these incoming messages um for the uh general attribute 00:25:17.716,00:25:22.721 protocol. Um for for central mode uh messages I guess. Um and so uh what- what I’m showing 00:25:24.923,00:25:30.629 specifically is actually uh the uh handler for um for 1 of the uh- very uh- 1 of the specific 00:25:30.629,00:25:36.001 commands in the- that protocol which is uh the Read By Type uh command. Uh which as I 00:25:36.001,00:25:39.838 understand it because I’m not really a bluetooth expert, uh it’s something that is going to 00:25:39.838,00:25:44.843 allow you to kind of request uh reading uh attribute handle uh you know data pairs back from uh 00:25:47.579,00:25:51.750 back from uh back from the device. So essentially you- you ask read by type to your 00:25:51.750,00:25:56.321 peripheral device, uh giving it a certain type and then it’s going to return all the handles 00:25:56.321,00:26:02.060 for all the attribute choices that are eh- you know um associated with that type. Uh so 00:26:02.060,00:26:06.698 that- what that means is that it’s possible for it to uh actually receive more than 1 00:26:06.698,00:26:12.271 attribute at a time, and the size of each attribute, uh handle attribute data pair is 00:26:12.271,00:26:16.375 encoded as a field inside of the packet. That means that we can actually control it. Now if you 00:26:16.375,00:26:22.181 look at the code, uh what it was doing in that um- what it was doing in that function is that 00:26:22.181,00:26:27.186 it has allocated on the stack a uh fixed length buffer uh for the uh attribute data, and that 00:26:29.488,00:26:34.426 fixed length buffer is going to uh have- be instruct basically that has just the handle value 00:26:34.426,00:26:38.697 and then a pointer to the data associated with that handle. So that’s what you can kinda see 00:26:38.697,00:26:44.870 with these uh little arrows there is that- I can actually yep. Uh oops. If you - you have 00:26:44.870,00:26:49.174 these little arrows there is that you- you can have in- at the bottom left there uh that’s 00:26:49.174,00:26:55.681 the actual binary like hex data that is inside of that buffer. And so you have the uh the uh 00:26:55.681,00:27:00.219 0XD handle and then a pointer that points to that data like the data in blue that’s 00:27:00.219,00:27:04.389 associated with it. And then the same thing for the uh second handle and third handle. And 00:27:04.389,00:27:10.162 because uh it’s on the stack um- no actually never mind that’s not a sentence that needed to be 00:27:10.162,00:27:15.167 said. So vulnerability here, uh if you read the code a little bit what you’re going to see is 00:27:15.167,00:27:20.973 that yeah, it reads that little uh purple field uh length field from the uh from the incoming 00:27:20.973,00:27:25.010 message so that’s completely controlled by a potential attacker, and if we look at what 00:27:25.010,00:27:31.149 happens if we place uh value 0 there, basically you end up with an un- unbounded uh infinite 00:27:31.149,00:27:36.154 loop. Uh so that loop is- sorry. Because it’s unbounded it doesn’t actually check that the- 00:27:41.260,00:27:45.998 the data it’s writing into the output buffer is within the output buffer. We have a very uh 00:27:45.998,00:27:50.068 classic uh stacks match kind of vulnerability which obviously is very unfortunate because on 00:27:50.068,00:27:54.373 these devices once you can smash the stack because there’s no stacker keys or you know ASLR or 00:27:54.373,00:27:58.110 DEP or anything, you basically immediately have code execution. In this case the problem is uh 00:27:58.110,00:28:02.981 because you have uh value 0 there uh in this specific case it’s actually going to be in 00:28:02.981,00:28:06.518 completely infinite loop. So you’re just going to overwrite all the data in ram with 00:28:06.518,00:28:10.556 garbage. Uh which is kind of unfortunate because that’s definitely gonna crash and not 00:28:10.556,00:28:14.760 gonna be useful. But if you think about using value 1 it actually is going to be bounded 00:28:14.760,00:28:19.264 by the number of bytes that are inside of the incoming message. And what that means is that 00:28:19.264,00:28:23.702 you're going to be able to uh overflow ever so slightly from that buffer, and uh then from 00:28:23.702,00:28:28.507 there uh because the stack- uh buff um buffer that is based on the stack, going to be able to 00:28:28.507,00:28:33.478 corrupt uh everything that’s near it. So taking a look at before uh wha- what happens when 00:28:33.478,00:28:37.082 you do actually use this uh overflow on the stack. In yellow is going to be the attribute 00:28:37.082,00:28:41.687 buffer that I was mentioning, then in blue is going to be a bunch of save registers, and uh 00:28:41.687,00:28:45.190 orange is actually the return address. So that’s kind of the things that you would kinda be 00:28:45.190,00:28:50.762 um corrupting on the stack. And then you run this um run the vulnerability, it’s going to 00:28:50.762,00:28:55.367 overwrite all this data on the stack with uh in this case completely well- it’s going to 00:28:55.367,00:28:58.904 write 2 things right it’s going to write the handle data which is actually only overwriting the 00:28:58.904,00:29:03.842 l- the l- lower uh the l- less significant bytes of uh of um of D words every uh 8 bytes. And 00:29:07.012,00:29:10.549 it’s going to be writing a bunch of pointers to data that we control. So it’s actually a 00:29:10.549,00:29:13.852 pretty useful primitive for us we can just kind of start corrupting everything. We can 00:29:13.852,00:29:18.156 corrupt the return address with a pointer that points inside of our packets. Uh and that’s 00:29:18.156,00:29:21.426 really great because uh basically that means that as soon as a function is going to 00:29:21.426,00:29:26.465 return, it’s going to execute code that is you know placed inside of our packet. Uh so it’s 00:29:26.465,00:29:30.469 basically- it’s basically a backdoor pa- packet if you think about it. It’s going to just 00:29:30.469,00:29:33.972 execute a piece of code you give it without really doing a lot of fuss which- which is pretty 00:29:33.972,00:29:40.212 cool. Um thing is uh you know the Corex- the Cortex MO CPU actually does not support ARM 00:29:40.212,00:29:45.884 mode. So we do have an alignment uh- uh requirement on that return address. It has to be uh 00:29:45.884,00:29:50.756 you know aligned to 2 plus 1 basically uh so that is 1 problem because if you look in 00:29:50.756,00:29:55.093 this specific case, what was overwritten on the uh the stack is actually not aligned to that 00:29:55.093,00:30:00.599 boundary. So this would actually crash, uh which is not great. There’s another uh requirement 00:30:00.599,00:30:04.603 that we have which is that there are saved uh registers there’s like actually uh like local 00:30:04.603,00:30:08.340 variables that we’re overwriting on the way over that are used on the return path of this 00:30:08.340,00:30:14.346 function. Uh 1 of them specifically is actually uh used to be dereferenced at a 32 bi- 00:30:14.346,00:30:19.851 bit binary- uh boundary. Uh and so what happens is that if it’s not actually uh aligned it’s 00:30:19.851,00:30:23.522 just going to crash. So that’s another thing that we have to take into account and basically 00:30:23.522,00:30:27.559 that means that we- we’re gonna have to slide this uh packet over in the way that it’s 00:30:27.559,00:30:32.564 allocated if we want to have any hope of it actually being exploitable. Fortunately that’s 00:30:32.564,00:30:37.469 really easy because the way that uh the uh- SoftDevice allocates these incoming packets is in 00:30:37.469,00:30:43.742 some kind of ring buffer with absolutely no um uh enforcements of any kind of alignment uh 00:30:43.742,00:30:48.280 requirements uh and so what that means is that if I send a packet of a certain length before or 00:30:48.280,00:30:51.950 after, I can control the alignments of this packet that I’m going to be sending 00:30:51.950,00:30:55.887 afterwards. So this is what you’re kinda seeing in- in yellow and in blue are 2 packets 00:30:55.887,00:31:01.193 are being sent before the uh exploit packet is sent. And that- that allows me to control 00:31:01.193,00:31:06.498 the alignment of that last packet and make it such that it is uh correctly uh aligned and 00:31:06.498,00:31:11.069 not crashy, which is what we want. From there the way that you actually exploit this to get 00:31:11.069,00:31:14.573 code execution, the way that’s useful and not just you know uh exploiting well not just 00:31:14.573,00:31:19.244 executing to uh- 2 instructions and then returning is that I send the first packet which is 00:31:19.244,00:31:23.749 going to contain a bunch of shellcode, then I send um another uh packet that’s going 00:31:23.749,00:31:27.352 to contain a bunch of data, another packet that’s going to be containing a lot of the data, 00:31:27.352,00:31:30.889 uh both of these are gonna be used by the shellcode. And then a third packet which is going to 00:31:30.889,00:31:35.227 be the 1 that actually triggers a vulnerability. Uh the way that it works is that the 1 that 00:31:35.227,00:31:38.964 triggers the vulnerability is going to exploit- execute a single instruction which is what 00:31:38.964,00:31:43.602 you see that C1 uh E7 instruction there. Uh what that does is it jumps back into the 00:31:43.602,00:31:48.640 green uh allocation into the green packet, uh and then that 1 is going to execute this very 00:31:48.640,00:31:53.145 simple piece of code which is- lo- loads a bunch of registers from the uh- I think the blue 00:31:53.145,00:31:58.650 packet. And then it’s going to uh use that to call in to a function, return cleanly, and 00:31:58.650,00:32:03.054 then we can just send that packet over again. So that allows me to basically by 00:32:03.054,00:32:08.693 sending 4 packets execute any arbitrary tiny piece of code within that uh [coughs] within 00:32:08.693,00:32:14.032 that uh remote dongle and then return and you know do that over and over again. Which is very 00:32:14.032,00:32:19.070 convenient because that way I can actually just call into memcpy and uh over and over and 00:32:19.070,00:32:23.775 do that to copy a larger shellcode binary and then we’re gonna jump into it and that 00:32:23.775,00:32:28.446 allows us to execute a lot more code. So at this point we actually just have completely 00:32:28.446,00:32:32.217 compromised this, we just need to write the shellcode. And so because we want our uh 00:32:32.217,00:32:36.922 compromise to be um permanent, basically we’re just going to write a little piece of 00:32:36.922,00:32:41.293 shellcode that’s going to overwrite a piece of flash, uh let us hook- hook into the uh 00:32:41.293,00:32:45.397 original dongle code and uh start sending uh you know the serial data that we were talking 00:32:45.397,00:32:50.402 about earlier. So this is what it looks like. Um. At this point if we have control over, uh an 00:32:57.509,00:33:01.513 app, we can control uh the dongle and the butt plug. With our control over a buttplug we 00:33:01.513,00:33:06.151 can control the dongle and the app, and so on. Uh so we’ve actually completely compromised 00:33:06.151,00:33:11.690 the uh- the local scenario in the case of the uh PC app. And it’s especially cool because 00:33:11.690,00:33:15.293 this last vulnerability that I just described actually is absolutely not specific to any 00:33:15.293,00:33:21.666 of these uh butt plugs. It’s uh for anything that uses a SoftDevice uh yeah on that SoC 00:33:21.666,00:33:24.970 uh which is basically everything that uses that SoC and apparently there are a lot of 00:33:24.970,00:33:30.308 devices that use this old uh NRF uh 5 1 8 2 2. So we have essentially found a 00:33:30.308,00:33:34.379 vulnerability that could also be used to compromise every one of those- those devices, assuming 00:33:34.379,00:33:38.884 that it’s configured in a- in a proper way. Or like a way that is you know uh conducive to 00:33:38.884,00:33:42.454 exploiting this vulnerability. So uh that’s kind of cool, uh finding vulnerabilities 00:33:42.454,00:33:45.624 potentially you know in like maybe smart locks or something like that just by hacking a butt 00:33:45.624,00:33:50.862 plug. Uh seems kind of worth it and surprising. Uh but it is- it’s the world we do live in at 00:33:50.862,00:33:55.600 this point. So the question is uh we have the ability to compromise an app from the butt 00:33:55.600,00:33:59.738 plug. What can we do with that? Uh well this is um you know we- we’re still just executing 00:33:59.738,00:34:04.276 javascript inside of uh the Lovense uh electron app, the question is what does that give 00:34:04.276,00:34:09.514 us? Uh because it’s Lovenese and that this is running at a Medium IL on Windows it turns out it 00:34:09.514,00:34:13.785 actually just gives us kind of everything. We can access all the- all the files on the- on 00:34:13.785,00:34:18.356 the file- on- on the computer, we can execute arbitrary code, uh just spawn uh any XC that- 00:34:18.356,00:34:23.461 that we want. Um so we’ve basically kind of compromised the- the computer just by uh by 00:34:23.461,00:34:29.968 doing this. Um which is you know kinda great um and and and helpful for us. Uh but the 00:34:29.968,00:34:33.939 question is from there uh even if we can create this ransomware that doesn’t just infect the 00:34:33.939,00:34:38.143 butt plug but also infects the host computer, uh can we actually make this go kinda 00:34:38.143,00:34:42.347 viral right? Because technically we can already compromise a butt plug from a different butt plug, 00:34:42.347,00:34:46.885 or from a different uh uh you know dongle and that could be something that we- could be used 00:34:46.885,00:34:50.488 like you know uh kinda spread this locally but it would be better if we could spread it 00:34:50.488,00:34:54.459 over the internet because you know obviously that would be uh much more people that you can 00:34:54.459,00:34:59.097 reach. Now the question is uh how do we do that? Well there are a lot of these uh social 00:34:59.097,00:35:03.301 features on the app uh such as the chat based uh stuff and the fact that you can just kinda 00:35:03.301,00:35:08.907 remotely control a toy. Um so the question is how does that interface work? Uh does that 00:35:08.907,00:35:12.143 allow us to kinda compromise the remote device? Of course the answer is gonna be yes, but how 00:35:12.143,00:35:16.348 does it work? Uh basically uh well it’s that’s what was showing at the- at the bottom 00:35:16.348,00:35:22.487 left there is uh a JSON object that is used to control the- the- the device remotely. Uh 00:35:22.487,00:35:26.291 it’s going to have kind of like the type of object it’s supposed to be and then in the- this ID 00:35:26.291,00:35:31.296 mode is going to give the um- the mac address of the butt plug that is supposed to be g- 00:35:35.000,00:35:37.002 controlled as well as the command so V means vibrate, uh and um and that’s what’s going 00:35:37.002,00:35:43.675 to be sent over as JSON to uh- to the remote app. Now, how does the remote app kinda use this? 00:35:43.675,00:35:47.946 Uh the thing that we can kinda think about here is that basically if we’re able to 00:35:47.946,00:35:52.083 somehow hijack this into allowing us to send an arbitrary string over to the dongle, we 00:35:52.083,00:35:56.321 can actually exploit the dongle JSON parser bug in order to get code execution there, and then 00:35:56.321,00:35:59.991 use that to kinda get code execution back on the app. Uh so it’s kinda convoluted but it 00:35:59.991,00:36:04.095 turns out it totally works. Uh the reason for that is that it doesn’t actually properly check 00:36:04.095,00:36:08.533 that the incoming data for like the vibrate command is actually an integer. Uh it does try to do 00:36:08.533,00:36:13.071 that check. Uh if you take a look on the right there uh at the bott- uh at the top uh in 00:36:13.071,00:36:19.210 the ID mode uh it does check that N which is the incoming uh vibration uh you know strength 00:36:19.210,00:36:24.149 data is greater quantities than 0. Uh and what that does is that it actually effectively checks 00:36:24.149,00:36:27.585 that it’s an integer that is positive. The reason for that is that if you can take a look on 00:36:27.585,00:36:31.723 the left there uh on Javascript if you do 12 is greater or equal than 0 it’s going to tell you 00:36:31.723,00:36:36.961 yes. Uh even if it’s a string, it’s going to tell you yes. Now if it’s a string that also 00:36:36.961,00:36:40.565 includes some text that is not uh a number it’s going to tell you no, it’s not, that’s not 00:36:40.565,00:36:43.301 gonna work. So that’s gonna block us. That’s what makes it such so you can’t just 00:36:43.301,00:36:49.107 arbitrarily uh inject uh a command into there. However uh if you take a look at the bottom 00:36:49.107,00:36:54.646 there, it has the exact same check but instead of checking that N is greater or equal in 0, 00:36:54.646,00:37:01.186 it’s checking that N is not uh less than 0. And the problem there is, well, if you check 00:37:01.186,00:37:05.023 that it’s not less than 0 then yes the string is also gonna tell you that is- that is- it is 00:37:05.023,00:37:09.661 not less than 0 but if you then you know kind of reverse that, it’s actually going to tell you 00:37:09.661,00:37:13.064 it’s true even though it’s not an actual string uh well even though it’s not an actual 00:37:13.064,00:37:17.135 integer. Uh so it’s kind of unfortunate I’m not sure why they decided to like flip that 00:37:17.135,00:37:21.272 test uh that test there like the filter. Uh but essentially it means that we can uh inject an 00:37:21.272,00:37:25.076 arbitrary string into this command that’s going to be sent over to the dongle and that 00:37:25.076,00:37:30.115 allows us to send the exact same uh exploit code that we sent over earlier that allowed us to 00:37:30.115,00:37:34.853 uh to comp- compromise the dongle for the uh JSON parser. So basically the only difference 00:37:34.853,00:37:38.756 here is that we can just do it over the internet uh basically exploit this firmware bug over 00:37:38.756,00:37:44.028 the internet just because they you know flipped a uh a check which is unfortunate. Uh so at 00:37:44.028,00:37:50.201 this point you know we have actually our viral uh butt plug worm um it’s going to allow us 00:37:50.201,00:37:53.838 to kind of uh compromise the dongle which allows us to compromise the app and then we 00:37:53.838,00:37:57.909 can go from app to app. Uh the only problem here is that we can only do this assuming that the 00:37:57.909,00:38:04.015 remote partner has accepted our request to con- control our toy. Uh but uh turns out you can 00:38:04.015,00:38:08.920 actually get code execution off the remote app in a much simpler way which is that they have uh a 00:38:08.920,00:38:13.291 chat uh feature where you can send texts. Turns out you can’t just send text, you can also 00:38:13.291,00:38:18.463 send HTML. Uh so kind of sending the exact same thing as before, sending this message, you can 00:38:18.463,00:38:23.468 pop alert. Um. [laughter] Again unfortunate, this is kind of uh very basic uh web dev stuff uh 00:38:25.503,00:38:31.643 because I could find it and I’m definitely not a web dev, so. At this point we can get code 00:38:31.643,00:38:36.214 execution just by sending a message. Uh so we basically achieved our goal. Uh this is 00:38:36.214,00:38:41.319 the payload I ended up using, uh it’s going to both uh you know spawn a local process to get 00:38:41.319,00:38:44.355 code execution on the actual device, maybe do some ransomware. And then it’s going 00:38:44.355,00:38:49.794 to also send that message to all your friends and create a uh, basically a uh a completely 00:38:49.794,00:38:55.133 viral uh you know exploit here. So we’ve compromised every node of the network, which is what I 00:38:55.133,00:38:59.938 wanted to do. So uh you know yay! Go us! [laughs] And that means that it’s time for a live 00:38:59.938,00:39:04.943 demo! [audience cheers] A little tired of trying to remember how all of this all works. Uh yeah 00:39:09.981,00:39:14.886 you can all see this. So uh please bare with me. Uh so first thing that I’m gonna show you is 00:39:14.886,00:39:18.456 uh this I’m gonna be actually using BTLE jack to kind of like try to hijack a connection 00:39:18.456,00:39:24.362 between a butt plug and this uh VM right here, uh this VM which hopefully works. Ok. So this VM 00:39:24.362,00:39:27.866 is just a regular Windows VM it’s connected to the dongle uh because VM ware lets you do 00:39:27.866,00:39:32.870 that. And I’m gonna turn on this butt plug. I hope you can hear it. [plug vibrates] [crowd 00:39:36.908,00:39:42.413 laughs] Um so this works, it’s on, then you can kind of add a toy, hopefully that’s gonna work 00:39:42.413,00:39:47.418 as well. [crowd chuckles] Oh wait, sh*t I forgot to do something. [laughs] Ok. Let’s 00:39:50.288,00:39:57.228 start over. Ok so disconnect that’s cool but uh it didn’t, I- I’m a dumb*ss. Come on. [sniffs] 00:39:57.228,00:40:00.665 So I actually want to disconnect this because I forgot to uh start the BTLE jack process on 00:40:00.665,00:40:04.969 that same uh side. Uh the only reason that we’re doing BTLE jack in this mode is that it’s 00:40:04.969,00:40:10.208 gonna be uh more successful uh for a live demo, but in theory well I mean not just in theory 00:40:10.208,00:40:12.877 actually in practice, you can also hijack an existing connection without having to 00:40:12.877,00:40:17.415 sniff it while it’s happening. So this is just to make things easier. Ok so now we’re gonna do 00:40:17.415,00:40:21.519 this again. Connect the toy. Hopefully the sniffers are going to detect that connection, 00:40:21.519,00:40:28.159 alright it detected a connection on the left there. That’s pretty good. Ok and then we have this 00:40:28.159,00:40:33.931 app that’s connected to our sex toy. Alright. So we can actually control it, I don’t know if you 00:40:33.931,00:40:38.937 can hear it. But it’s there. [laughter] Gonna stop it. Ok. Alright it’s stopped. From here 00:40:45.209,00:40:51.049 we should be able to actually hijack this connection. Uh the way we do that is- I’m trying to 00:40:51.049,00:40:56.054 remember this. Oh my god. I used to have a mouse for this, it was much easier. Ok then we copy 00:41:03.828,00:41:08.833 this parameter. I’m ss- really sorry about this um- gonna try and make it faster. Alright and 00:41:14.072,00:41:19.310 T which means hijack. So we’re gonna try and hijack this connection here. And if it works 00:41:19.310,00:41:23.081 it should uh kill the connection to this app and just- it should just happen. Ok so it’s trying 00:41:23.081,00:41:29.220 to hijack, and it hijacked the connection so that’s great, thank you BTLE jack for a great 00:41:29.220,00:41:33.491 tool. Uh so from here what you can see is that in here in the app it actually disconnected 00:41:33.491,00:41:37.995 because we now have control over the buttplug from ubuntu uh and so in theory we should be able 00:41:37.995,00:41:43.000 to make it uh for example, vibrate remotely. Uh no STR vibrate 20 is, oh not cibrate, 00:41:45.536,00:41:50.541 god d*mn it. Uh 20. Uh oh it’s it’s actually happening there. Uh so- so that works, that’s 00:41:58.649,00:42:03.588 great. [applause] Now we’re gonna put this into DFU mode, hopefully that also works it 00:42:07.291,00:42:13.631 should stop it if it works. There we go. It stopped. Okay so now it’s actually in firmware 00:42:13.631,00:42:17.935 update mode so at this point I take my phone, I’m gonna try and connect it. Hopefully it works 00:42:17.935,00:42:22.940 again. Uh yeah alright cool so from here please don’t look at my apps. Please don’t send me 00:42:27.011,00:42:32.016 any messages right now. Uh so you’re gonna grab the firmware version uh for the exploit, 00:42:34.652,00:42:40.625 version 27 that’s a lot of work. Uh and we should be able to say DFU Targ, ok so now we’re gonna 00:42:40.625,00:42:45.630 be flashing this new firmware from our phone. Uh it’s updating. Eh. Gonna just keep 00:42:49.767,00:42:54.772 this here for now. And from here uh what we’re gonna do assuming this works- alright it’s been 00:43:01.112,00:43:06.117 updated. So now what we can do is pull this up and uh try to connect back to it. Oh I think 00:43:08.886,00:43:13.891 it’s doing it on it’s own, let’s see. [laughs] And so [crowd laughs and applauds] So this 00:43:23.668,00:43:27.738 worked uh at this point we have gotten code execution on the dongle and then back on the 00:43:27.738,00:43:31.309 computer through this we downloaded an 0XE from the internet and we ran it uh. It 00:43:31.309,00:43:37.515 unfortunately encrypted our butt plug which uh [laughter] you know is unfortunate. Uh it’s 00:43:37.515,00:43:42.120 probably from North Korea [laughter]. And then what we can see is that I had this other uh 00:43:42.120,00:43:46.357 VM which was also running the app, this 1 is not connected to a dongle or anything as you can 00:43:46.357,00:43:51.195 tell, uh but it is connected to the internet. And it is like my friend. Uh and so [crowd laughs] 00:43:51.195,00:43:57.268 had a message and it just runs the exact same thing. Uh so we’ve achieved like butt plug 00:43:57.268,00:44:01.439 virality uh with this infected butt plug. Don’t connect to it right now unless you wanna like 00:44:01.439,00:44:07.211 you know um get your butt plug en- encrypted. [crowd laughs] Um and and yeah that’s- that’s 00:44:07.211,00:44:12.416 basically it. Uh the conclusion. Well ok. I think there’s a couple lessons that we can learn 00:44:12.416,00:44:16.888 from this um which is you know as I mentioned you know as- as much as this is kind of like a 00:44:16.888,00:44:20.491 funny line of research, uh in my opinion it is actually kind of important to uh look at the 00:44:20.491,00:44:24.228 security posture of the- of these devices; not only because it is actually used by people 00:44:24.228,00:44:28.566 for their livelihoods but also because in my opinion it is kind of uh uh very representative of 00:44:28.566,00:44:32.370 the current state of you know IoT and connected devices in general. It’s kind of like all 00:44:32.370,00:44:36.574 these different technologies which are both new and not new uh kind of like working together 00:44:36.574,00:44:40.211 and people don’t necessarily understand all the implications of like having 1 vulnerability 00:44:40.211,00:44:44.982 in 1 there in 1 component there is that you can kind of start chaining these things and uh 00:44:44.982,00:44:51.789 turn you know an XSS into uh a butt plug firmware uh hack or like uh a USB dongle uh hack 00:44:51.789,00:44:55.059 that should only be possible locally ends up being exposed to the internet and stuff like 00:44:55.059,00:45:00.831 that. So you know hopefully this kind of uh research applies to other things um and I wanted to 00:45:00.831,00:45:04.602 say something else but I completely forgot what it was. So uh I guess thanks for 00:45:04.602,00:45:08.940 listening and if you wanna find all the code uh that was uh in there uh go follow me on 00:45:08.940,00:45:11.976 Twitter. I’m gonna post this on GitHub uh later today if you want to start hacking your own 00:45:11.976,00:45:16.280 butt plugs. And I want- do want to thank uh all my friends who helped me uh make this, all my 00:45:16.280,00:45:20.952 friends who also introduced me to uh the world of connected butt plugs uh who are extremeley 00:45:20.952,00:45:26.524 gay. Uh I’m not gonna name names but you know who you are, Aaron. [laughter] Uh hah. Thank you 00:45:26.524,00:45:29.627 very much. [applause]