00:00:00.067,00:00:06.540 >>Without further adieu, because we stay on schedule. Philippe is here uh, from uh, from Portland, 00:00:06.540,00:00:12.279 by way of uh, France from what I understand. And he is going to talk to, the, talk to us about 00:00:12.279,00:00:17.918 uh, breaking into embedded devices, including phones, uh, phones that you might have on 00:00:17.918,00:00:23.991 your desk at work phones that might be, I'm not even gonna get into that, phones that might be 00:00:23.991,00:00:28.228 around. Let's learn about embedded device hacking. Let's give Philippe a big round of 00:00:28.228,00:00:33.233 applause. [Applause]. Have a good time man. >>Thank you. Thank you, everyone um, so I’m 00:00:35.569,00:00:39.573 really excited to be here, it’s like a big honor and um, yes, so today we are going to talk about 00:00:39.573,00:00:43.510 hardware hacking and um, I’m going to show you this introduction to it and I hope 00:00:43.510,00:00:48.282 um, I can show some love about um, hardware hacking. So uh, who am I? I’m Philippe Laulheret um, 00:00:48.282,00:00:53.820 I’m a senior security researcher at McAfee, um, Advanced Threat Research. So I, I do um, 00:00:53.820,00:00:58.792 software and hardware phone research, and you can find me on Twitter at PHLaul. Before doing 00:00:58.792,00:01:03.964 McAfee, I spent 2 years doing uh, embedded security and before that I was a C++ Dev. So I'm 00:01:03.964,00:01:09.403 not, not coming from a um, software background actually. So you could wonder like, why 00:01:09.403,00:01:13.407 should you care about um, hardware hacking in the first place? Right? Um, I can see like 00:01:13.407,00:01:18.512 two main reasons uh, first is that it's actually really fun and empowering to be able to um, 00:01:18.512,00:01:22.115 you know, break op, break, open a device that you would like have in your home at work 00:01:22.115,00:01:25.953 wherever. And instead of considering that it's a black box, you can instead you know, 00:01:25.953,00:01:30.023 like start poking at it and understanding how it works. And then in a more like pragmatic 00:01:30.023,00:01:36.196 way um, if, if we consider like security in the past couple of years uh, software is becoming 00:01:36.196,00:01:41.468 much and much harder to like break. Like if you try to uh, I know like, pwn like uh, whatever 00:01:41.468,00:01:45.639 like um, a media device like a web server like find, finding a vuln in the web server by itself 00:01:45.639,00:01:49.376 is kind of hard. With, if instead you can just like open the device, solder a couple of 00:01:49.376,00:01:53.747 wires, and get like a shell from that, that's much easier. So hardware hacking is great, 00:01:53.747,00:01:58.585 because it's also like a lot of uh, low hanging fruits basically. So uh, today, we're 00:01:58.585,00:02:03.256 going to talk about uh, Avaya phones um, and especially like the 9. The phone picture on the 00:02:03.256,00:02:08.729 right side of the slide is a 9611g model. Uh, so Avaya is like one of the biggest uh, VoIP 00:02:08.729,00:02:13.900 um, solution provider you can find them like all over the place. Uh, Google's like 90% of 00:02:13.900,00:02:18.372 the Fortune 100 company and I think that's specific model of phone started in 2006, and is 00:02:18.372,00:02:22.342 going to be enough life like at the end of the year or something. And the funny um, on 00:02:22.342,00:02:27.114 the bottom right of my slides there is this a funny like um, screenshots from like a page 00:02:27.114,00:02:33.487 from like a really old software firmware for these phones. Where um, actually like, you can see 00:02:33.487,00:02:38.058 that um, you can only download that specific firmware, if you're like a DOD customer so 00:02:38.058,00:02:41.928 um, basically then, uh, see that these phones are going to a lot of different places. So uh, 00:02:41.928,00:02:46.566 we're getting prior art. Uh, in hardware hacking, it’s like a lot of information nowadays is 00:02:46.566,00:02:51.538 on the internet, like you, you can find a lot of blog posts, tutorials um, there’s always 00:02:51.538,00:02:56.276 like the Hardware Hacking Village that you all go, go and check out. Uh, CTF as well where 00:02:56.276,00:03:02.115 you can like practice, uh, like kind of like the softer side of stuff and um, on my slides, I 00:03:02.115,00:03:06.686 like a bunch of links at the end uh, so you can like download the slides at later time and um, 00:03:06.686,00:03:11.258 also the slides uh, I’ve like, the one I've uploaded I’ve like, more text on them. So it's like 00:03:11.258,00:03:17.264 a more like standalone. So you can read more um, and yeah, I read that in security uh, I 00:03:17.264,00:03:22.169 found like 2 RC’s in the same uh, phone uh, something like five years ago or something, um, 00:03:22.169,00:03:26.907 and they like talk at RSA called Stepping P3wns I would also recommend to check out online. 00:03:26.907,00:03:31.845 So uh, for the next 40 minutes um, so I'm going to talk about um, hardware hacking and use 00:03:31.845,00:03:36.783 that phone as a base to like support that conversation. Um, And basically the idea of like 00:03:36.783,00:03:41.788 the whole situation is um, uh, like couple of like, 12 years ago, maybe uh, via Fox and open 00:03:44.491,00:03:49.496 source codes, and um, they never applied security patches to that. And um, it turns out that 00:03:51.731,00:03:56.336 like me, by poking at the device, I found that and it was like, women like unnoticed for 00:03:56.336,00:03:59.840 like 10 years as they were like actually like a CV that got released like, yeah 10 years ago 00:03:59.840,00:04:04.478 for Defcon. So I'm going to talk about uh, how I found that like that it was like some stupid 00:04:04.478,00:04:09.449 like you know God inside that firmware. But more interesting, I think is uh, talking about the 00:04:09.449,00:04:15.088 whole process, you know, like, how I did it, um, and why I did what I did it Why? Oops, sorry. 00:04:15.088,00:04:21.561 Why I did stuff I did when I did it um, you know like, magic like sharing um, the process so that. 00:04:21.561,00:04:25.332 And you know, also like sharing uh, know, what if the stuff I tried didn't work or, or 00:04:25.332,00:04:29.836 selection stuff that didn't work, because, you know what, what works for one device might 00:04:29.836,00:04:33.106 not work for another. And having just like that mental model of what we can do and what you 00:04:33.106,00:04:37.077 cannot uh, helps you a lot approaching at any kind of device. And that's, I really 00:04:37.077,00:04:42.048 think why I want people to take away from that talk is more like um, learning the process of that 00:04:42.048,00:04:47.454 you can check out like whatever device you have. And yeah, we want to like insist that um, if 00:04:47.454,00:04:51.091 I can do it, I think everyone in this room can do it as well. As I said I’m more from like 00:04:51.091,00:04:54.694 software background, and the hardware hacking is still like, you know, like um, little scary, 00:04:54.694,00:04:58.832 little foreign to me, but it's in the end, it's really not that hard if you have like a good 00:04:58.832,00:05:03.770 process and you know, me work with patience. So uh, how did whole project start uh. Um, uh, 00:05:06.273,00:05:09.509 to be honest, I was like, you know, working at work, and there were like all these cubicles, on 00:05:09.509,00:05:14.114 the, on every desk, I see this like phone like standing on, on the desk. I’m like, wait a 00:05:14.114,00:05:17.951 minute, these phones are running Linux, they have you know, network access, they have like 00:05:17.951,00:05:22.822 mics and stuff is like, how, how secure is that? You know, like, I know, you, you wonder like, 00:05:22.822,00:05:27.894 what's up with it, did people consider the security of this? So um, the first step before you 00:05:27.894,00:05:31.998 know even like, I still like stealing my coworkers phone and breaking it apart, you can like, 00:05:31.998,00:05:35.635 and that's generally [inaudible], you can check out the FCC websites usually like 00:05:35.635,00:05:41.007 any device that has Wi Fi or Bluetooth, has to be um, on the FCC website for a compliance 00:05:41.007,00:05:46.446 reason. So, that's what I found. Um, That's not my phone. That's like a, also model of same 00:05:46.446,00:05:50.517 brands, basically and like pretty close. So you see all these cool pictures. But more 00:05:50.517,00:05:55.989 interesting is the, the inside of the phone. Uh, so we can then see it and on the left side in 00:05:55.989,00:05:59.993 right, in red um, I’ve highlighted this like random debug connector, I don't know 00:05:59.993,00:06:05.265 what it is, but that's interesting to see that's there. And on the right side um, there 00:06:05.265,00:06:09.469 is like that, like um, in purple there is that flash memory. So that's usually where the file 00:06:09.469,00:06:14.040 system of the phone is going to be stored. And the whole point of that is just to get an idea 00:06:14.040,00:06:17.711 of what to expect, you know, before even approaching a real target, like building hardware 00:06:17.711,00:06:23.416 and stuff. So that um, you, you know, like if it's going to be an easy target or hard target 00:06:23.416,00:06:27.554 uh, you know, if everything was covered in black epoxy, that will be harder. So another 00:06:27.554,00:06:34.494 important step is like figure, um, getting like um, online material, like um, you know, um, 00:06:34.494,00:06:38.298 marketing brochure, so you have an idea of what the phone, what are phone capabilities in the 00:06:38.298,00:06:43.536 ecosystem surrounding it, so that you have an idea of um, you know, like the attack surface. 00:06:43.536,00:06:46.840 And you can also find like user manuals and stuff. And for instance, I found that one that 00:06:46.840,00:06:51.144 was pretty cool. It's like a user, like a, advanced user manual that says, oh, if you 00:06:51.144,00:06:55.448 want a serial connection to the phone, you need that funky box. And uh, yeah, which is 00:06:55.448,00:06:59.819 interesting it teach, it tells us that yeah, you can find it’s serial connection and you may 00:06:59.819,00:07:03.857 have had some special hardware for that, but, are we going to see that in a bit. And uh, after 00:07:03.857,00:07:08.662 that, you also want to check like forms and um, so that you can find out what poor user are 00:07:08.662,00:07:13.867 doing like for instance, I found like the default passwords for the phone in debug interface, 00:07:13.867,00:07:19.472 because um, and system admin. So here, uh, talk uh, talking about that online. And uh, if you're 00:07:19.472,00:07:23.677 lucky, you can also download if you're more of an idea of uh, what's up there. And then we'll 00:07:23.677,00:07:28.815 cover that in a minute. Okay, so uh, what do we do now, uh, now we have an idea of like, what it 00:07:28.815,00:07:32.652 might look inside. This is a hardware hacking talk. So we're going to provide volunteers and 00:07:32.652,00:07:36.856 so the point is like you open the phone first. Um, and the trick is like, usually you 00:07:36.856,00:07:41.094 always expect to find the same stuff inside. And uh, if you look at the labours of the 00:07:41.094,00:07:45.799 components, you will see uh, you, and you Google that uh, you will find out like what it is. 00:07:45.799,00:07:50.437 So for instance that's my phone, and um, you can see the centre of the CPU a, above it like the 00:07:50.437,00:07:55.942 RAM, in like a lavender ish colour, like some unpopulated like header that I marked with a 00:07:55.942,00:07:59.379 question mark. This, I think the same way, there are the one we were like seeing in the picture 00:07:59.379,00:08:03.483 before and I, it might be JTag, I did not have to use it. So I don't know actually. Uh, in 00:08:03.483,00:08:07.787 proper, we have like the Eeprom’s that’s uh, with the whole like some settings and 00:08:07.787,00:08:13.159 stuff. Uh, in dark blue in the bottom of the um, of the slide is like a keyed RJ45. So I was 00:08:13.159,00:08:15.995 kind of, kind of confused when I was looking at that. And I didn't know even the term for 00:08:15.995,00:08:20.633 it. And the idea is just a regular, RJ45 uh, like Internet plug, but with a weird um, 00:08:20.633,00:08:26.639 connector so that you cannot plug the, the wrong stuff into it. Um, and uh, more interesting 00:08:26.639,00:08:30.744 in yellow uh, the UART’s. So it's UART is kind of like the serial console and um, we have 00:08:30.744,00:08:35.215 like these experts like uh, pads. And so usually like in manufacturing or something you 00:08:35.215,00:08:40.286 would have like a pogo pins that would like generally connect to the pads. And this uh, that one 00:08:40.286,00:08:43.456 is actually really interesting, because you would find like serial con, you'd expect to find 00:08:43.456,00:08:47.894 the serial consol on that. And on the back, we can see the NAND flash that we've seen the 00:08:47.894,00:08:52.999 previous picture. And um, yeah, from that is like where the file system would be, like stored on, 00:08:52.999,00:08:58.004 on the device. So okay, you have um, you, we looked at the stuff inside and the, the like, other 00:09:00.740,00:09:05.612 thing that's interesting to look at is test points and debug headers. So, and like basically 00:09:05.612,00:09:08.915 all this kind of stuff that on those components. And you can ask, why would you expect to 00:09:08.915,00:09:13.953 find them inside? And a couple of reasons like ones like just, usually like the Dev board that, 00:09:13.953,00:09:17.557 that the guys are going to use is the same as the production board. And maybe they're not, 00:09:17.557,00:09:21.227 just not going to solve the other debug components. It's the same as if you are like 00:09:21.227,00:09:26.065 software, and it was built with like debug symbols, for instance. And um, also like part 00:09:26.065,00:09:30.970 of the manufacturing process um, you, this test points and stuff might be used for like flashing 00:09:30.970,00:09:34.974 the device ,or making sure it's flashed properly. And sometimes, you know, like something died on 00:09:34.974,00:09:40.146 um, in, in the, in the real world. And they want to like do a post mortem to understand what 00:09:40.146,00:09:43.249 happened. And that's useful as well. So what kind of stuff you want to look for in that 00:09:43.249,00:09:48.555 situation? You want to look at UART that we like looking at before. JTag that I'm going to, 00:09:48.555,00:09:51.724 uh, cover like in a minute. And then like you can also have like random test point that are 00:09:51.724,00:09:55.562 chilling there that like all over um, the all over the table, all over the board. And there 00:09:55.562,00:10:00.467 might be like long test points, er, like labour like TP1, TP2, whatever. And sometimes that, 00:10:00.467,00:10:03.236 that might be like not interesting to you, but sometimes you can find 00:10:03.236,00:10:08.641 interesting stuff like um, you might find that like oh if you short like TP64 uh, with ground 00:10:08.641,00:10:13.279 is going to reset the device, which might be actually useful in some extent. So uh, looking 00:10:13.279,00:10:19.953 at UART uh, so as I said is for like serial connection. And it comes in like 3 or 4 pins. The 3 00:10:19.953,00:10:26.125 pins will be uh, ground uh, transmit and receive. And the fourth pin would be like DCC, so 00:10:26.125,00:10:29.829 3 volts, 5 volt whatever. And usually you don't care about that one, you don't even want to 00:10:29.829,00:10:36.536 plug it, you don't have to. And might uh, yeah, and uh, the, the trick to know is uh, the serial 00:10:36.536,00:10:40.673 console uh, some data at different speed. And there are only like a couple of it's, 00:10:40.673,00:10:45.678 called like Baudrates. And there was only like a few uh, common baud rates values, so if you try 00:10:45.678,00:10:50.383 to plug your, your system in on, into the UART, and you just see gibberish on screen, the, 00:10:50.383,00:10:53.987 probably the reason is, you just have the baud rate wrong and you could just like try to cycle 00:10:53.987,00:10:58.758 through like all the possible, possible one, and it would find something eventually I think. 00:10:58.758,00:11:05.331 Um, JTag is another one that's um, interesting um. So that's for like hardware debugging and 00:11:05.331,00:11:10.570 ways that you could, like, you know uh, debug the CPU usually, and execute like instruction by 00:11:10.570,00:11:15.708 instruction and whatnot. And it, they come in many different uh, shapes, number of pins and 00:11:15.708,00:11:20.880 whatnot. So some example like on the bottom of the slides uh, but actually only a couple of wires 00:11:20.880,00:11:25.451 are interesting and uh, at the end of the slides I have like a link to an article about like 00:11:25.451,00:11:29.856 understanding JTag better. But basically, like, if you look on the top right side uh, of my 00:11:29.856,00:11:34.093 slides, there is like a Dev board and say like a nice uh, JTag Connector like plugged 00:11:34.093,00:11:38.731 there. And on the other hand, like on the bottom right, it's like some uh, random device I 00:11:38.731,00:11:43.536 was looking at, which you can see, there should be a JTag, but it's never been soldered on and 00:11:43.536,00:11:48.241 so I had to solder directly onto that stuff. And the trick to remember here, if you kind of 00:11:48.241,00:11:53.746 like solder your own connector, is uh, you actually may have to add like extra resistors called 00:11:53.746,00:11:57.650 like pull up and pull down resistors that connects like one pin to ground or one pin to like 00:11:57.650,00:12:01.854 VCC. And the point of that is, actually, I don’t know the point of that, but uh, the reason is 00:12:01.854,00:12:06.392 that if you don't have them, it might not work well or it's more work most of the time, it's 00:12:06.392,00:12:11.097 going to be glitchy. So um, and if you follow the instructions from like, for instance like a 00:12:11.097,00:12:15.568 arm, a specification for like what resistor you need, so, you might skip them, but then you 00:12:15.568,00:12:19.205 might waste time like understanding why it's a weird, like weirdly f*****d up 00:12:19.205,00:12:24.577 sometimes. So I would recommend the pull up and pull down resistors. So that's just random 00:12:24.577,00:12:28.414 board that my coworker was looking at uh, just to show you that what I said is actually 00:12:28.414,00:12:33.152 fairly generic. Uh, on the left side, we have like UART. On the right side there like some JTag 00:12:33.152,00:12:38.191 connectors. Uh, up there is the mmm, the primary there is like, the main CPU, whatever that’s 00:12:38.191,00:12:43.429 under like a shield. And usually you, you do that for um, preventing um, interferences. So 00:12:43.429,00:12:47.533 it's like a Wi Fi module, so that's why. And the good thing to know is usually the shield is 00:12:47.533,00:12:50.837 grounded. So like, if you're looking for the ground on your thing, you're like, either the 00:12:50.837,00:12:54.207 shield on that kind of stuff, or like the casing around the Ethernet port or whatever is 00:12:54.207,00:12:59.612 also act, actually like fairly useful. So uh,now that we learn how to uh, look into stuff, we 00:12:59.612,00:13:04.817 need to know what hardware you need for um, interfacing with what's inside. So I'm going to 00:13:04.817,00:13:09.789 present like a bunch of uh, cool hacking tool set that's important. So the first one uh, 00:13:09.789,00:13:12.792 you may want this pin or like the stickers, I don’t know if you're familiar with that um, 00:13:12.792,00:13:17.397 the actually, like, what's really important is like, safety. Um, so you know, don't 00:13:17.397,00:13:21.868 work with stuff that’s plugged in the wall. Uh, remember to unplug stuff working like well 00:13:21.868,00:13:27.774 ventilated room, it's important. And uh, yeah, just don't be stupid when you're like uh, 00:13:27.774,00:13:34.313 messing with hardware uh, but yeah. So next uh, picture from the lab uh, I'm holding a um, 00:13:34.313,00:13:38.785 soldering irons. You can usually switch tip for like a fairly large tip for like big soldering 00:13:38.785,00:13:43.289 and tiny ones for small soldering. I have a microscope, so that's really useful for 00:13:43.289,00:13:47.860 doing uh, tiny soldering. And the trick is I, I tend to drink a lot of coffee and I shake, so 00:13:47.860,00:13:51.731 I will, I would, I was thinking like I couldn’t do that, but actually, if you um, if you 00:13:51.731,00:13:55.301 careful and the, the trick is like really try to um, you know, when you soldering, like try to 00:13:55.301,00:13:59.238 hold your arm like straight and well grounded. And under the microscope, you can actually do 00:13:59.238,00:14:03.376 a lot of stuff that’s, you just don’t think, you wouldn't be able to use, you would think you 00:14:03.376,00:14:08.748 shouldn't be able to do it, but you actually, actually can. [Breathes out], sorry, um. Top 00:14:08.748,00:14:12.385 right side um, it's more actually used for the tiny soldering and the um, mid sec 00:14:12.385,00:14:18.891 top right is like flux, so it's kind of um, magic glue, magic uh, gooey sta, it’s a substance 00:14:18.891,00:14:23.930 that you put on um, pins to uh, when you start doing surface mount or pads so that it works 00:14:23.930,00:14:29.869 really well. So don't, never forget, flux. Uh, bottom is um, sa, like, in the same uh, size, 00:14:29.869,00:14:34.173 like uh, copper wires, like a minal wire that you use, usually for making codes, you know, for 00:14:34.173,00:14:40.279 like radio or whatever. Um, and the trick is that the, the wire is actually um, coated in uh, 00:14:40.279,00:14:44.617 varnish so it doesn't short. And you can use it to do like really tiny point to point like 00:14:44.617,00:14:48.254 soldering, and that's actually really useful. And just next to it, you have like some 00:14:48.254,00:14:51.791 desoldering wick. So like, the idea is, if you put too much solder and you f**k it up uh, 00:14:51.791,00:14:56.929 you can put the wick on top of the solder block that you messed up with and you um, put the 00:14:56.929,00:15:00.767 soldering iron on top of that, it's going to get really hot, so you want to hold it through like 00:15:00.767,00:15:05.171 the plastic casing and it’s going to absorb all the like extra solder. And you can clean 00:15:05.171,00:15:10.109 up your stuff. Then I put a picture of like some random like uh, jumper wires that are, are, 00:15:10.109,00:15:15.481 or usually, always useful to have. And on the bottom right, I have like that crazy heat uh, 00:15:15.481,00:15:20.019 gun. Uh, it's just like 60 bucks at Home Depot. It's meant to like, help paint dry or 00:15:20.019,00:15:23.389 something, I'm not sure, but it's actually really useful for if you’re on the chip, if you 00:15:23.389,00:15:27.527 want to remove component by just like heating them and pulling them off. So uh, more cool 00:15:27.527,00:15:33.099 hardware um, that's a multimeter. Um, if you're not familiar with that, it's easy to 00:15:33.099,00:15:38.004 for, find voltage of chip you don't know, like what's the actual voltage, so the black 00:15:38.004,00:15:42.742 goes to ground and the, with the red you uh, with the white probably select poking around to 00:15:42.742,00:15:47.280 uh, measure the voltage. And there was a really cool stuff is you can set in continuity mode 00:15:47.280,00:15:51.150 and when you have like connection between the two probes, it beeps. So if you do 00:15:51.150,00:15:54.887 like crappy soldering job, as I was describing just before, you can make sure that you actually 00:15:54.887,00:15:58.691 did a proper job where like everything is connected the way you think, by you know making 00:15:58.691,00:16:03.062 sure that both like, when you probably, both side it actually beeps. And that's actually 00:16:03.062,00:16:08.668 fairly useful uh, tool. The other one is, this is a Logic Analyzer. Uh, the name is like a 00:16:08.668,00:16:12.672 Sally, um, that's a brand. And the idea is, the same as in software, you have like ways of 00:16:12.672,00:16:16.676 communicating between process, like in hardware, you have like ways of communicating between 00:16:16.676,00:16:20.780 chips or the CPU and the chip. And it’s uh, it's like a lot of different standards, different 00:16:20.780,00:16:24.283 ways of doing stuff. But the logic analyzer like know a lot of them and it's going to 00:16:24.283,00:16:28.788 convert like a bunch of signals going , going on to wires into actual data. And that's actually 00:16:28.788,00:16:32.625 really useful. That would be your eyes, like when you're doing uh, debugging, you know. 00:16:32.625,00:16:36.963 And that's like your snapshot of like some SPI communication uh, which spies with some random 00:16:36.963,00:16:42.435 protocol. Uh, that's like an FTDI cable also come in many uh, serial cable, it comes in many 00:16:42.435,00:16:47.139 different shapes and stuff. And the idea is just like, when you want to do like UART, you, you 00:16:47.139,00:16:52.078 plug that into your laptop, and you connect the user side to like the UART port and you get 00:16:52.078,00:16:56.849 like a console, it shows up as a serial port. And uh, as an example I’ve um, on the bottom 00:16:56.849,00:17:01.153 right um, like a raspberry pi that’s, you can actually get to serial console and you don't 00:17:01.153,00:17:07.426 need like HDMI cable or anything to interface with that. Whoo. Um, the Bus Pirate uh, also like 00:17:07.426,00:17:13.633 cool device um, it does um, It, it's kind of dependent of the hardware hacking at um sorry, 00:17:13.633,00:17:18.871 with um, the Sally logic analyzer, so instead of absorbing data, it's like send 00:17:18.871,00:17:23.409 data, so it speaks a bunch of different protocol and you can use Python to programme it. So 00:17:23.409,00:17:26.979 it's extremely useful if you want to like read flash, programme um, microcontrollers 00:17:26.979,00:17:31.984 and that kind of stuff. Um, more cool stuff I covered. I was talking about JTag, that's the 00:17:34.153,00:17:38.891 JTag debuggers that you, that's where you would plug actually like the Digitech port on. They 00:17:38.891,00:17:42.862 come in many different like uh, price range and whatnot. So on the bottom right is a fly 00:17:42.862,00:17:47.700 swatter it's like, probably like 30 bucks, I think. And it works okay, and above it it's like a J 00:17:47.700,00:17:51.704 Link, which is more fancy. And the idea like, the more expensive the stuff is, the 00:17:51.704,00:17:55.174 more, the probably the more reliable it is. And it comes with like better software and 00:17:55.174,00:17:59.979 whatnot. And on the bottom right, the pink bodies are JTagulator later that Joe Grand, 00:17:59.979,00:18:04.550 the same guy who made up those badges uh, made. And it's really awesome. So, if you're like that 00:18:04.550,00:18:07.853 board, you don't know what it is until like a bunch of test point and you like, I bet there is 00:18:07.853,00:18:11.290 some JTag somewhere in it, but you don't know where. You can just wire like all the test 00:18:11.290,00:18:16.295 points to the TJagulator and is going to brute force like and try to find everything. So it's 00:18:16.295,00:18:22.168 really cool. Um, those are interest, important tool is uh, Flash readers. So usually Flash 00:18:22.168,00:18:27.940 content, the Flash as the file system and stuff. And um, so you want to like interface with 00:18:27.940,00:18:31.744 that. And uh, it comes in two flavour, I guess, you can do like in circuit stuff. So you 00:18:31.744,00:18:35.815 have like either like your little like clamp that you put on the chip or a little 00:18:35.815,00:18:42.421 rectangular one um, in to clip on. Um, so like the Raspberry Pi is a good one for that. And on 00:18:42.421,00:18:47.393 the top right, is like a flash cat, uh, it’s like useful for the rectangular one. Um, but you 00:18:47.393,00:18:51.230 can also like, choose to like, actually disorder the chip and, in that case, you would have 00:18:51.230,00:18:55.167 like some socket adapter. So you can clip the chip on and then you plug it into your Flash cat 00:18:55.167,00:18:59.672 and whatever, and it's going to read it. And that, I will cover like why, whats, my, whats, why 00:18:59.672,00:19:06.345 it's important like both in a minute. And finally, it's kind of the um, last uh, hope. So 00:19:06.345,00:19:10.282 let's say uh, you know your Flash is encrypted, there is no UART , there is no firmware. So 00:19:10.282,00:19:14.253 you can try to do like the more crazy stuff like, first injection and such an attack. So 00:19:14.253,00:19:19.925 that's the chips whispers like more like a kind of hard, more badass device. And the idea with 00:19:19.925,00:19:26.499 that is um, it, you can do stuff like um, you are wire it um, to the CPU and you're going to drop 00:19:26.499,00:19:30.736 the power on the CPU for like a split second and it’s going to like mess up some instruction 00:19:30.736,00:19:34.173 and you can bypass checks and stuff. That's pro, what people use for like gaming console 00:19:34.173,00:19:40.680 hacking and, and um, that kind of stuff. So uh, what do we do now um, that we have an idea of 00:19:40.680,00:19:47.253 what's inside the phone and um, you know um, the tools we can use. So like, I think it's three 00:19:47.253,00:19:52.591 posts potential track, one is messing with the UART, so the serial console, and this one is 00:19:52.591,00:19:55.828 uh, messing with the flash and trying to recover the firmware or something and then maybe you 00:19:55.828,00:20:00.032 can just download the firmware online. And the three are like valid approach and sometimes 00:20:00.032,00:20:03.235 it's good to just go from one to another to another and you know what, whatever you find like 00:20:03.235,00:20:07.506 some hardware you can like go from one to another. Uh, so I went for the UART first and 00:20:07.506,00:20:12.912 that's what I'm greeted at by when I connect my FTDI cable to the UART ports that I, I was 00:20:12.912,00:20:17.783 doing before. So um, we can see that on the left side, the, the um, the console thing, it's like 00:20:17.783,00:20:21.387 dot dot dot, usually when you see that, you can press space or escape and it's going to 00:20:21.387,00:20:26.525 interrupt the booting process of the phone. And in that situation, uh, but somehow here 00:20:26.525,00:20:30.963 it didn't work. And I, I will cover that why in a minute. And on the top right side of the 00:20:30.963,00:20:35.067 slide um, we can see like it read something from the EEPROM and then decided to set the 00:20:35.067,00:20:39.338 console to Dev null. So you don't want console to be Dev null because if that goes 00:20:39.338,00:20:43.642 nowhere. But that's interesting to know that um, there is some potential there. And finally, 00:20:43.642,00:20:48.247 it's like booting in next so it con, confirm us that it's a uniques port, but then uh, 00:20:48.247,00:20:52.918 there's nothing more uh, after that. So there's some good thing, bad things. The problems 00:20:52.918,00:20:57.022 are like nothing shows up after like the Linux is as we did, probably because of the Dev null 00:20:57.022,00:21:02.495 situation. And when I press keys are talking and um, I'm going to like come up with like, why that 00:21:02.495,00:21:07.233 happened. So at that point, I was still like, okay, I, I cannot go anywhere. So I'm going 00:21:07.233,00:21:11.704 to try to recover the firmware to try to understand what's up with that. Uh, multiple ways of 00:21:11.704,00:21:17.109 recovering firmwares uh, is like an easy ways like you can do it online. And actually that worked 00:21:17.109,00:21:21.780 um, there is like a quick snapshot of that, uh, sometimes it’s encrypted. On our case, it 00:21:21.780,00:21:26.852 wasn't. Um, but, yeah. So you can also try to sniff a firmware update uh, that’s really useful 00:21:26.852,00:21:30.623 for IoT devices in general. And you can use a network tab, which is like the thing pictured on 00:21:30.623,00:21:36.061 the top right of the slide. Um, or you can mirror your port on your switch or whatever. Uh, the 00:21:36.061,00:21:40.699 problem with all of that is oftentimes a firmware updates going to do over like h, HTPS, 00:21:40.699,00:21:45.171 or it might be, in this case, you're like stuck. And then you want to go for like a more like 00:21:45.171,00:21:48.974 uh, hardware hacking stuff or like you’re going to dump a flash, for instance. And like 00:21:48.974,00:21:53.579 even more advanced techniques that I will briefly like uh, talk about. So how do you dump a 00:21:53.579,00:21:57.883 flash? There’s two ways, as I was mentioning, just before, you can do in circuit programming 00:21:57.883,00:22:02.454 and um, out of circuits. So in circuit is cool, because you don't have to, you know, like 00:22:02.454,00:22:07.293 remove stuff, break stuff. But a couple of issue is that um, the main idea is to read the flash, 00:22:07.293,00:22:11.597 you need to power the flash. And if you, if it's like still plugged into the whole system. 00:22:11.597,00:22:14.833 Uh, it, when you're like Raspberry Pi, for instance, going to try to read the flash, 00:22:14.833,00:22:19.138 it's going to tr, try to power like everything else that's connected to the same like like 00:22:19.138,00:22:24.643 power line. And either you know, USB Pi is not strong enough to power like a VoIP phone, which 00:22:24.643,00:22:29.715 you would expect. And in that case uh, but it's just not going to work. Or maybe your Raspberry 00:22:29.715,00:22:34.119 Pi is really strong and it’s going to do it, but then the problem is the CPU stop booting 00:22:34.119,00:22:37.723 and it’s going to talk with the flash and that's going onto to mess up your stuff. So in that 00:22:37.723,00:22:42.127 situation, you have like two choices usually, either you can try to like lift up the pin, the 00:22:42.127,00:22:46.966 ball pins, so that it doesn't happen. Or you can kind of go a little more like hero approach 00:22:46.966,00:22:51.804 where you want to keep the CPU in reset. So I've been successful with that many times 00:22:51.804,00:22:55.875 or I just like starts like trying to ground like random test points, of stuff on the 00:22:55.875,00:23:00.179 boards, praying that is not going to find anything. And usually at, at some point like, 00:23:00.179,00:23:03.449 I'm going to notice that okay, when I do that the phone like light up, it doesn't boot, 00:23:03.449,00:23:08.420 that's good. And maybe better ways you can desolder the chip with it like to be like heatgun 00:23:08.420,00:23:12.324 or whatnot. You have to be careful though, because if you like pull it too hard, you might 00:23:12.324,00:23:17.029 like bend pins and is going to be like useless. Um, with a good trick to know is that you can 00:23:17.029,00:23:21.600 make a little like um, tinfoil hat or whatever, like on the chip, so that like when you're 00:23:21.600,00:23:25.271 heating up the chip, like the stuff around, it doesn't get too hot. Er, so you don't 00:23:25.271,00:23:28.674 accidentally like knock off like some like tiny like components, that would be like a pain in the 00:23:28.674,00:23:33.812 butt to um, put back. And uh, bottom right is like I was, I was, I thought I would have to 00:23:33.812,00:23:37.216 do that on the phone. So I wanted to practice first and then just took like some random 00:23:37.216,00:23:41.920 uh, USB thumb drive and I tried. And actually, that worked really ff, nice. But the trick is to 00:23:41.920,00:23:46.792 remember, I also put some flux because it helps. And uh, yeah, just don't, be careful with, 00:23:46.792,00:23:51.397 when you put it off. A few other tricks that actually didn't work on this one. But I, good to 00:23:51.397,00:23:56.935 know. Uh, U-Boot is the most common boot loader uh, not used here, but it's, you would find 00:23:56.935,00:24:01.206 that on pretty much every other device. And the idea is you can also instruct a boot process of 00:24:01.206,00:24:05.644 that and asked nicely you would, hey, can you load the flash in memory, and then uh, U-Boot is 00:24:05.644,00:24:10.316 also able to dump in a Hex like in the screen um. The, the memory, is this way, you can 00:24:10.316,00:24:13.919 just get, write into the script to do that and recover everything from the flash, which 00:24:13.919,00:24:20.392 is really cool. But usually like Dev don't like letting you do that. They said they lock that 00:24:20.392,00:24:24.396 approach, so, so you cannot like press space to interrupt the boot process. But there is a 00:24:24.396,00:24:29.835 trick that I also call like the Yolo approach where, instead, when. The idea is like U-Boot is 00:24:29.835,00:24:33.839 going to load from the flash like the, the new scanner or something. But if while it’s 00:24:33.839,00:24:38.610 happening, you start like poking with, you know, like a wired is connected into ground and they 00:24:38.610,00:24:43.415 started poking the NAND flash, like some of the pins, it's going to mess up like what’s uh, 00:24:43.415,00:24:47.386 u-boot is reading and after a couple of tries, u-boot is going to be like, d**n that kernel is 00:24:47.386,00:24:51.590 f**ked up, I don't know what to do and it’s going to give you like a shell. So that's really 00:24:51.590,00:24:55.728 cool. But yeah, as I said that one we don’t work on our phone unfortunately. But uh just some 00:24:55.728,00:24:59.965 cool example that I found online was like some guy actually did that. And uh, I underlined in 00:24:59.965,00:25:03.635 uh, in the like purple on, on the bottom, like the command you need to use to like log the, 00:25:03.635,00:25:08.574 the, the flash in memory. And on the right side, the secondary block of text is um, sorry, is, 00:25:08.574,00:25:13.579 how uh, you will just panicking and be like, er, I don't know how to do with your kernel and 00:25:13.579,00:25:18.584 give you the, the shell. So uh, how um, so a few more like tricks for um, dum, dumping the 00:25:21.687,00:25:26.291 flash, so you can use JTag. So usually you have uh, if, if JTag works, you're going have to be 00:25:26.291,00:25:30.396 able to um, dump the RAM. So in this case, that won't be really like dumping the flash, it will 00:25:30.396,00:25:34.133 involved dumping the firmware, but, in a lot of devices it’s going to load the whole stuff in 00:25:34.133,00:25:37.936 memories, so if you can dump the memory you are, you, you the same means you pretty good 00:25:37.936,00:25:42.207 there. And kind of the last hope with this. That's one of my favourite about hardware hacking 00:25:42.207,00:25:48.280 is, you can do crazy uh, stuff uh, and an example is a Scanlime um, that person on the internet 00:25:48.280,00:25:52.851 who um, she had a um, a Wacom tablet that she wanted to dump the um, the firmware off and 00:25:52.851,00:25:55.754 there was like no attack surface at all, which she realised that like when you [inaudible] USB 00:25:55.754,00:26:01.493 stuff, and when you plug your USB um, onto the laptops, there is some USB exchange that I 00:26:01.493,00:26:06.131 don't know anything off, but it sounds like USB descriptor. And if you, if you glitch the CPU 00:26:06.131,00:26:10.736 just at that time, um, it's going to like, know, miss like a binary check and is going to 00:26:10.736,00:26:15.507 send a way more data. And with that uh, she was able to recover like the full flash, full memory 00:26:15.507,00:26:19.711 or something. So it's really impressive, but, and that's what's kind of awesome about 00:26:19.711,00:26:24.650 hardware hacking. Okay, so uh, we recovered the firmware uh, in my case, just by downloading 00:26:24.650,00:26:29.388 online, but, what do we do now? We want to analyse it. Um, the best tool for that is called 00:26:29.388,00:26:34.026 Binwalk. And it's just basically magic dictionary that's going to like look at your binary blog of 00:26:34.026,00:26:37.663 stuff and be like, mmm, halfway through it looks like there is a zip file, I'm going to try to 00:26:37.663,00:26:41.400 extract it. It tries, maybe it works, maybe it doesn't depending if it was actually zip 00:26:41.400,00:26:45.304 filed or not. And it does that for everything. And uh, it might also find like compressed file 00:26:45.304,00:26:52.144 system such as Squashfs, JFFS2 etc. And sometimes like your um, your firmware file might just 00:26:52.144,00:26:57.683 start with like Elf headers or just like random like ARM code that you could like, look at. So 00:26:57.683,00:27:01.954 I haven't been work on. So that's the firmware file, I don't know it from the website. 00:27:01.954,00:27:06.125 And once again, it's easy mode, it's just a doc file. And they already like split it up into 00:27:06.125,00:27:11.296 boot 1, boot 2 and JFFS2. So like, Binwalk has nothing to do here, really, and I can just 00:27:11.296,00:27:14.800 extract the all file system. And that's cool, because from there, I can look at what's on the 00:27:14.800,00:27:19.938 phone, just like that. Uh, but the more interesting, use case for Binwalk is, I took like a 00:27:19.938,00:27:24.476 different uh, firmware file for like, a [inaudible] phone. And this one is way more 00:27:24.476,00:27:28.614 interesting, because Binwalk for, find like a way more lot, lot of stuff. And uh, I've 00:27:28.614,00:27:33.085 highlighted, like you find the file system and is able to extract it. And there's also 00:27:33.085,00:27:36.588 that random like my SQL stuff, which I think is a false positive, then you need to be 00:27:36.588,00:27:40.125 aware that there will be a lot of false positives, so don't blindly trust what the Binwalk 00:27:40.125,00:27:45.063 says. And uh, really, really funny stuff that I was looking at uh, if you run strings on 00:27:45.063,00:27:50.869 that specific image um, you will find a U-Boot strings. So, that fun is using U-Boot and the cool 00:27:50.869,00:27:55.841 stuff I was describing before, would actually work on that one, look. So now that you have 00:27:55.841,00:27:59.678 extracted the firmware file, what do you want to look for? One of the most uh, interesting 00:27:59.678,00:28:04.950 stuff is uh, finding the you, update mechanism. So assuming you have uh, encrypted firmware, 00:28:04.950,00:28:08.854 like if you reverse engineer that you might find the keys and how to extr, to extract like 00:28:08.854,00:28:12.724 subsequent uh, firmware updates without having to do like, any hardware stuff. And then you 00:28:12.724,00:28:17.563 want to look for like secrets, like uh, passwords, certificates and so and so forth. Uh, 00:28:17.563,00:28:21.066 originally, my goal was to look at the main binaries. So that's just the thing and deal with 00:28:21.066,00:28:25.837 like the VoIP stack. Uh, that could be make sense to look at that. And um, also you want to 00:28:25.837,00:28:30.108 look at the bootloader because, it may have a hidden commands, explain why all console is not 00:28:30.108,00:28:35.781 working, that kind of stuff. So, remember, the point of all of that was, I wanted to get a 00:28:35.781,00:28:41.653 shell on the device and um, what's the process to do that? So, the one I want to go for is, 00:28:41.653,00:28:45.223 I want to fix the serial console, you know like the Dev null was not cool. Um, but also 00:28:45.223,00:28:50.562 approach will be like messing with your boot arguments. Um, not working here, obviously. Uhm 00:28:50.562,00:28:55.033 but you know, you can specify the console you want and the, uniscript can be marked, oh I 00:28:55.033,00:28:59.638 want Bin bash as my uniscript and you have a console. Uh, and like kind of last resort stuff 00:28:59.638,00:29:03.642 that I was considering as well is, you could patch the firmware. In our case the 00:29:03.642,00:29:08.513 firmware is signed. So uh, that won't work unless you try to glitch it, which really hard. 00:29:08.513,00:29:13.485 But you can also try to patch a file system. So the way Binwalk extract the JFFS2 stuff, you 00:29:13.485,00:29:18.190 could modify it and then like repackage and flush it directly onto the flash. And that's 00:29:18.190,00:29:23.895 usually accurate, foolproof methods like, that would work in most cases. So instead, I'm 00:29:23.895,00:29:29.901 going to uh, reverse uh, um, the Bootloader. And um, for that, um, because I wanted to 00:29:29.901,00:29:34.973 understand like, why Dev null, a con, the console was set to Dev null and stuff. I'm just going 00:29:34.973,00:29:39.611 to cover um, in much detail and I would be come on you to check out Azeria Labs Tutorials that 00:29:39.611,00:29:44.416 cover everything, which just useful here um. There is this notion in ARM of literal pool. 00:29:44.416,00:29:49.988 Which is um, inside the code section, you would find some little chunk of data and that's 00:29:49.988,00:29:54.893 usually like used to la, loading registries, um, absolute addressees, imminent values, 00:29:54.893,00:30:00.699 magic offset, that kind of stuff. And uh, FYI, like in ca, in case of function calls um, 00:30:00.699,00:30:06.204 the arguments are going to R0 to R3. The rooted value is in RVO. And when you like, want to 00:30:06.204,00:30:10.342 return from your caller, it's, the, the return address is saved in like the LR register, that 00:30:10.342,00:30:15.447 stand for like link register. Um, and the big trick, big problem here is um, we're like 00:30:15.447,00:30:19.785 trying to load the boot loader. So it's uh, it's not really Elf. So if you tried to import in 00:30:19.785,00:30:23.989 IDA, IDA doesn't know what to do with it and so you need to find the loading address for that 00:30:23.989,00:30:29.494 stuff, so it match what, where the phone is loading it. Couple of tricks um, so none of your 00:30:29.494,00:30:34.232 load key is going to be printed on screen, that's our case, sweet. Um, but otherwise, you 00:30:34.232,00:30:38.403 want to look at like header file, headers in the, in the bootloader file or maybe recent 00:30:38.403,00:30:43.709 vectors so that stuff for like, specifically for ARM, like the CPU needs to know uh, specific 00:30:43.709,00:30:50.082 addresses where like, a recess or an intrep happening and it's like funny like um, square like, 00:30:50.082,00:30:54.152 how it’s being set up. So if you find that and you find like what looks like an intrep vector 00:30:54.152,00:30:58.490 handle or something, you can find like, ah, that must be the address. And uh, finally, the 00:30:58.490,00:31:02.094 literal pool I was mentioning uh, really useful with a because it's going to contain like 00:31:02.094,00:31:06.565 absolute addresses or point to strings and stuff. So uh, if, if like you have strings, and they 00:31:06.565,00:31:10.569 look like all f**ked up, you probably got the wrong address. And uh, Quarkslab, uh, what a 00:31:10.569,00:31:15.440 blockbuster blog, so I would recommend you checking it out. So as I said, in our case, it 00:31:15.440,00:31:21.113 was easy. Um, when it boots it prints uh, the jump, whatever. And that's actually WIFI loaded. 00:31:21.113,00:31:25.784 And um, on the bottom right side, it's like a bunch of uh, strings um, so it's a bunch of 00:31:25.784,00:31:31.223 addresses that point to strings. Uh, the system snapshot from IDA and um, we can see that uh, 00:31:31.223,00:31:36.394 um,it's all the strings like prints well, so that means that it's loaded properly. It's not 00:31:36.394,00:31:41.066 like all messed up. Okay, so now that we have the bootloader and we can like work it with IDA, 00:31:41.066,00:31:46.171 uh, we want to search for strings uh, we were looking at, you know, like that sentence 00:31:46.171,00:31:50.308 like EEPROM read successful, whatever. So we can use like cross reference in IDA to find 00:31:50.308,00:31:54.980 where the string is coming from and look at the function that handles that. And uh, yeah, just 00:31:54.980,00:32:00.685 as a FYI, but like EEPROM and Spi, so the EEPROM that's on the board is called a Spiprom and 00:32:00.685,00:32:05.223 Spi is just one of this protocol I was mentioning before. EEPROM is just uh, like a small memory, 00:32:05.223,00:32:10.228 um, whatever. And the spi uh, protocol is just like 4 wires um, and the ID to CPU in command 00:32:12.597,00:32:16.968 and EEPROM like reply, and uh, and that's a dump from like using the logic analyzer to have 00:32:16.968,00:32:22.307 a look at what it would look like in real life. Uh, that's the data sheets of the EEPROM 00:32:22.307,00:32:27.512 that you can find on, online, if you google the, the label on it. Um, the cool thing is in the 00:32:27.512,00:32:33.552 bottom left uh, of the slide, it tells you like, the pinouts, so you how to connect stuff to it. 00:32:33.552,00:32:39.124 And on the right side of the slide um, it tells you which, which, upcodes are for Spi 00:32:39.124,00:32:44.596 command would send. Like for instance, if you send uh, 3 it’s going to be read, read, if you 00:32:44.596,00:32:48.433 send 2, it's going to be write. So that's uh, that's something useful to know, right? Oops, 00:32:48.433,00:32:54.472 sorry. Back to the um, back to the IDA and the uh, bootloader, we can see uh, the strings we 00:32:54.472,00:32:58.210 were like looking for. And something is for me promising is, we can see the uh, console 00:32:58.210,00:33:02.180 set to Dev null, but above that, that I could bur, 2 of the option and it’s actually saying 00:33:02.180,00:33:08.253 like, oh, setting console to like UART 0 or UART 1. So we want these ones to be printed. 00:33:08.253,00:33:14.793 Um, that's a, that's a function that actually does print that string. And uh, what it does is 00:33:14.793,00:33:20.131 roughly um, cleaner, clear some bites on the stack. And then you read for me from from a magic 00:33:20.131,00:33:25.637 address. And it's going to compare like bytes um, that has just been read. When if we have 00:33:25.637,00:33:30.408 the good value, it’s going to actually print on the console setting, the console for uh, Dev 00:33:30.408,00:33:36.815 ttyAMA0. So we want that to happen. Uh, and something you can ask me is like, oh, how did 00:33:36.815,00:33:40.719 you find that read EEPROM function, you know? And there like more a couple of ways of 00:33:40.719,00:33:45.156 doing that. Uh, the easy way that I've highlighted in green, that screenshot, is uh, on the 00:33:45.156,00:33:49.661 bottom right, you can see some like logging that says, oh, EEPROM read fails. So I know 00:33:49.661,00:33:54.132 that function is responsible for reading EEPROM. Uh, but maybe, maybe the few more I’m going to 00:33:54.132,00:34:00.505 look is not uh, as uh, variables. In which case um, as I said before, like, to read 00:34:00.505,00:34:03.875 from a EEPROM you know you have to send 3over SPI. So, if you find like the SPI function, and 00:34:03.875,00:34:05.877 you see like sending 3, you know what it is. This whatever highlighted in yellow. But then 00:34:05.877,00:34:07.879 like, how do you find a spi function in this kind of um, programme? Uh, 2 ways for that. 00:34:07.879,00:34:09.881 Um, my guess once again, it was logged, so it was easy. But usually like, the main trick is 00:34:09.881,00:34:11.883 um, you have this um, something called um, mapped uh, IO MMO mapped IO. It's this kind of 00:34:11.883,00:34:16.888 like magic address values in the CPU that like if you write to them, it's actually going to 00:34:24.796,00:34:29.801 send data over like you auto spi or whatever. If you're lucky, you're going to have a data 00:34:36.174,00:34:41.947 sheet for the CPU. And it specifies exactly what are those addresses. If you're unlucky um, 00:34:41.947,00:34:45.717 you have to guess and that's really hard. And, at the time, maybe you should like look for 00:34:45.717,00:34:49.988 something else, or just you know, you're going to spend a lot of time on that. So we want 00:34:49.988,00:34:54.659 to uh, patch the EEPROM now, so we can uh, build the console. The plan of action is, we know 00:34:54.659,00:34:59.664 the read, write comments uh, we want to interface with the flash. So to do that um, uh 00:34:59.664,00:35:04.402 sorry, the EEPROM, we, we um, we needed like a spiuh, device and that we've seen before the Bus 00:35:04.402,00:35:09.007 Pirate is a perfect candidate for that. And we need to connect to the chip, uh, unfortunately, 00:35:09.007,00:35:13.478 like it's really tiny one and so like the clip I was showing how like too big for that. You can 00:35:13.478,00:35:17.215 buy online some rigs that people make um, it's like, expensive, and it's like five weeks to get 00:35:17.215,00:35:22.954 them. So instead, I went kind of crazy and I tried to solder like um, little wires onto the thing. 00:35:22.954,00:35:26.358 And I was like, honestly, that's never going to work, but happened to actually work. And 00:35:26.358,00:35:30.061 that was like, sweet. And uh, it's all like look like cross because it’s like all the flux 00:35:30.061,00:35:34.699 that remains on that. Um, and that's the code for the Bus Pirate. It's super like 00:35:34.699,00:35:40.305 boilerplate uh, thing. And when you just write um, this magic values that uh, sorry, I was 00:35:40.305,00:35:45.577 asked to like, replace, them with like, images. But uh, the idea is like, just after that 00:35:45.577,00:35:51.750 you're greeted with console is set to uh, like your R0 and now we have a lot of more stuff uh, 00:35:51.750,00:35:56.521 printed on console, which is great. But unfortunately I, I get like this a harder like, the 00:35:56.521,00:36:00.291 input are still like not working, I was like trying to press space or type like, it’s 00:36:00.291,00:36:05.030 as, asking for oh, you want to look as root? What’s, I type, nothing happens, like ah, what 00:36:05.030,00:36:09.567 happened? Did I just cut the trace, so you cannot send data? We have the boards, we can look 00:36:09.567,00:36:15.206 at it, um. So uh, this just like, like a zoom up on the thing and at that time, I was 00:36:15.206,00:36:18.977 like, you know, looking at the UART pad and start like with my millimetre, like trying to beep 00:36:18.977,00:36:23.048 out, like where it goes, you know it’s, following the continuity testing. And 00:36:23.048,00:36:26.651 eventually it reached some wires, like on the right side and wires are that little hole 00:36:26.651,00:36:31.089 that's connect one side of the ball to the other. So the trick is the actual like trace that 00:36:31.089,00:36:35.727 connects UART to whatever uh, goes to the other side of the board and goes oh, back and 00:36:35.727,00:36:39.831 forth. And it's like really, like tedious. And eventually I kind of lost where it was going. 00:36:39.831,00:36:44.836 But it was kind of under that MOD port, uh, that's like the keyed RJ45. Um, and so um, 00:36:48.707,00:36:54.979 remember like the recon side uh, recon part, um, we have that box and it’s like ah, d**n, that’s, 00:36:54.979,00:36:59.417 that’s the thing. So I kind of went via like, my euro approach again where, I was holding like 00:36:59.417,00:37:01.352 a, a plug, like a jumper cable in my um, the transmit of my FTDI cable. And uh, so I had 00:37:01.352,00:37:03.354 like this like wire that I could poke around. And on the other side, I was like pressing keys 00:37:03.354,00:37:05.356 on the console trying to see if something happened. And meanwhile, I was poking like to 00:37:05.356,00:37:10.361 the pins one by one. And I think at the second one, it actually worked. And I got greeted by uh, 00:37:14.632,00:37:19.637 like a root shell on the device. So that was cool um. But the trick was um, the, on the right 00:37:24.142,00:37:28.179 side of like a proper setup, where I plugged my ethernet cable into the plug. So at that 00:37:28.179,00:37:31.983 time, I didn't want know where the key the RJ45 was. So I was just like sanded the plastic of 00:37:31.983,00:37:36.688 the ethernet cable so I could like shove it in, and yeah, it just works, so that was nice. 00:37:36.688,00:37:40.892 Uh, now that we have a root shell is it like uh, a lot of debug strings prin, printed on 00:37:40.892,00:37:45.697 screen and that's annoying. So um, the trigger was like, I want to kill the process, it's like, 00:37:45.697,00:37:49.467 sha, that's like flooding my console. Uh, there’s a watchdog that’s going to reboot the 00:37:49.467,00:37:53.638 device if that happens, so I highlight in the corner, like the magic commands that you can 00:37:53.638,00:37:58.209 run to kill that. It’s just like a random, unique stuff. Uh, so now we can finally do some Vuln 00:37:58.209,00:38:02.580 research. Um, and really what you are going to do is look at process running, poke around, 00:38:02.580,00:38:09.454 look at open ports. Uh, there's just a bunch of processes, uh, new sequel stuff, but um, that’s 00:38:09.454,00:38:11.990 when it’s all getting interesting. I think at some point I was tired of looking in 00:38:11.990,00:38:16.861 the IDA and I was like, I’m going to poke more. And I looked at DHClient and like huh, and 00:38:16.861,00:38:20.899 the really funny parts like, I run the DHClient and I see this like 2007 copyright. I was like, 00:38:20.899,00:38:25.837 woah, that's not a good thing. And if you just run DHClient by itself, it's Segfaults, like 00:38:25.837,00:38:30.742 that's weird. And if you like, run it the right way, they print a debug message that say oh, we 00:38:30.742,00:38:36.814 modified it to work it better on our device. I’m like, huh, that's interesting. So, if we 00:38:36.814,00:38:40.985 look back, and we look for the specific version, it turns out that, 10 years ago, actually, 00:38:40.985,00:38:46.191 for DEFCON uh, Jon Oberheide um, really is like an exploit for that specific version of the 00:38:46.191,00:38:51.296 DHClient, so I was like, well, that's, that's easy. Um, but we want to make sure it's actually 00:38:51.296,00:38:56.768 vil, still vulnerable. So the um, the phone was like a doing like um, Stack Overflow, like 00:38:56.768,00:39:01.806 while handling DHCP options. So we can compare the original source code with the patch 00:39:01.806,00:39:05.977 source code because DHClient is open source. And just keep in mind, that might be like 00:39:05.977,00:39:11.149 mitigation, like stack cookies, ASLR whatnot. So if we look at the vulnerable code on the left 00:39:11.149,00:39:16.354 side, we can see a memcpy like highlighted in red. That’s using like data.len as a field. Or on 00:39:16.354,00:39:21.726 the patched version that we place, that by 4. So the idea is like, this bug is uh subnet, uh, 00:39:21.726,00:39:26.064 it's a bug in the subnet mask and link, and the subnet mask should be like 4 bytes. But, the 00:39:26.064,00:39:30.068 way the HTP option works, is that you can send up to like 255 bytes, I think, and it used to 00:39:30.068,00:39:34.739 just dumly trust, whatever you're sending, which is bad. And if we look in IDA like the 00:39:34.739,00:39:39.510 actual like function, uh, we can see there is no stack canary and the vinner, the, the, on the 00:39:39.510,00:39:43.881 left, on the right side, it's, it's not using that magic 4, so it's, it’s obviously like still 00:39:43.881,00:39:48.853 vulnerable. So it simple to exploit stuff. Um, working on the phone os TDS, I was like, 00:39:48.853,00:39:52.991 I'm going to try to set up QEMU um, if you're not familiar with QEMU it’s kind like emulation of 00:39:52.991,00:39:58.329 ARM stuff or like mini of system and can do either like Userland or Full-System. Userland 00:39:58.329,00:40:02.600 wouldn't work here because uh, DHCP is um, more going, try to modify an IP and stuff and 00:40:02.600,00:40:06.271 that's not cool. Um, but instead, we can do, do a Full-System emulation and uh, 00:40:06.271,00:40:11.442 those tutorials tell you how to like, set up a query match for that. And we just want to set up 00:40:11.442,00:40:16.314 the network properly, uh, because we want to interface with the DHCP and naturally um, 00:40:16.314,00:40:23.254 the um, QEMU stack would give you a digi, DHCP for yourself, so you have to be, stay like 00:40:23.254,00:40:29.427 don't do that and, yeah. So I run it in DH in QEMU and after like [inaudible] fault and it's 00:40:29.427,00:40:33.097 still Segfault and it’s like, huh. So it turns out that like, Avaya modified stuff that 00:40:33.097,00:40:38.036 actually causing the Segfault. And um, I was going to go back too fast, because I'm running 00:40:38.036,00:40:42.140 like a little of out of time. But uh, basically it's creating that weird socket, uh, it’s like 00:40:42.140,00:40:46.844 a name socket and uh, so that’s like the main application that the VOIP stack can talk with 00:40:46.844,00:40:51.749 DHClient and show options. Um, and uh, the idea’s like, that's like the main application, then 00:40:51.749,00:40:56.220 we can see what it does. That's non, not super interesting. But basically on the left side, it’s 00:40:56.220,00:41:00.325 like sending data to configure DHClient at startup and on the right side, I re-implemented 00:41:00.325,00:41:06.130 that in Python. And uh, you can run that with like Socat, um, so, Socat is just like, kind of 00:41:06.130,00:41:10.702 like Netcat in um, in more like um, more tools, so you can share that name socket and the idea, 00:41:10.702,00:41:17.408 you run the Python script on the host, you on socket on the um, QEMU like binar, image, and that 00:41:17.408,00:41:23.982 just work. So now we can start debugging uh, DHClients, um, you can run GDB, we can try to like, 00:41:23.982,00:41:28.586 actually run the bug. I do, I couldn't compile the original proof of concepts, it was like 00:41:28.586,00:41:32.790 using a really old tools and it's just after like, hella, like couple of hours like, ah 00:41:32.790,00:41:37.362 f**k that, I’m tired. So instead uh, I use a Scapy based uh, exploit. Scapy is a Python 00:41:37.362,00:41:40.865 library that lets you like, you know, mess with uh, network packets, like a fairly low 00:41:40.865,00:41:47.839 level. And um, so now we want to like reach the um, vulnerable part, vulnerable code, so um, I 00:41:47.839,00:41:52.844 was explaining the bug in the uh, subnet mask option. And how, the way DHCP works is like a 00:41:52.844,00:41:57.982 tea, tag length value like type of stuff. So you say, Oh, this option is a uh, subnet mask, 00:41:57.982,00:42:02.487 here's the length, here’s the value. And obviously it was like, it would be 4, but if you 00:42:02.487,00:42:08.826 send more, it's fine. But for the DHCP specs. And so we can use Scapy for doing that. So uh, 00:42:08.826,00:42:12.630 that's my, like a chunk of my Scapy script and just the payload in properly is 00:42:12.630,00:42:17.235 interesting. Um, basically just sending the subnet mask option with uh, data that will be like 00:42:17.235,00:42:22.240 A, A, A, A, B, B, B, B, C, C, C, C and so on and so forth. So that um, when it crashes in GDB 00:42:24.542,00:42:29.947 uh, we can see like all the register we control, and we know um, exactly um, you know, if we 00:42:29.947,00:42:33.851 want to af, affect which register, which chunk of the shell code we need to change. 00:42:33.851,00:42:37.522 And we can see that we actually controlling uh, [“pc’s” so the programme console, so that's 00:42:37.522,00:42:43.294 good. We know that we have um, we can exploit, we have control, control for execution. And there 00:42:43.294,00:42:47.532 like a few more details that I'm going to skip over. But um, we need to sta, to craft a shell 00:42:47.532,00:42:52.870 code now. Uh, unfortunately, like it's it looks like the stack is uh, you cannot execute 00:42:52.870,00:42:57.408 the stack, so we will have to work it. And that's tedious. But um, cool stuff is like if you 00:42:57.408,00:43:01.512 look for there is like a system calling, that binary that I think also, Avaya added. And we 00:43:01.512,00:43:06.250 do control R4. So if we put us, if we can put a string in memory in an address we know, that 00:43:06.250,00:43:12.223 could be a value like, system comment, and put the address in R4, we good. Um, so if you think 00:43:12.223,00:43:17.728 about it, DHCP client, DHClient, sorry, receive configuration values from the server. So 00:43:17.728,00:43:22.366 probably there is going to be stuff that are stored somewhere and um, it turns out that ASLR 00:43:22.366,00:43:27.605 is disabled, I, sorry, I forgot to mention that. Um, but then we, the idea is like, I just 00:43:27.605,00:43:31.909 some like, sending like A, A, A, A’s as like, a bunch of uh, options and then look at memory 00:43:31.909,00:43:36.180 to see if I could find that string somewhere. And eventu, eventually, the domain option 00:43:36.180,00:43:40.852 was a good one. And so um, now I can show you uh, a cool demo that's, what happened when you 00:43:40.852,00:43:45.857 actually run the whole stuff. So uh, on the, um, on the left side, we have the phone that's 00:43:49.093,00:43:53.364 booting. The phone is booting and the window uh, the 10 minute window is like, on the left side 00:43:53.364,00:43:58.503 is a, rog DHCP client running off payload. And on the right side is um, it's a web server 00:43:58.503,00:44:02.707 that uh, will provide like uh, life post exploitation kind of stuff. So we can see the packet 00:44:02.707,00:44:07.211 is running. To make sure it works, I was uh, catting dev random on the uh, on the 00:44:07.211,00:44:13.451 screens. That's why it's looks like noise. It's fetching data from the um, web server and and 00:44:13.451,00:44:18.789 I don’t know if you can see but it’s loading like steve.data. Uh, FYI, like, Steve is actually 00:44:18.789,00:44:24.695 my uh, boss. That's him. [Laughter] And uh, just then um, uh, still like ex, I don’t know 00:44:24.695,00:44:28.533 if there is sound but I’m ex- filtrating audio from the main speaker. And you can see it in 00:44:28.533,00:44:33.004 VLC that when I'm speaking and clapping my hands, it's actually like reading the audio on the 00:44:33.004,00:44:37.942 attacker laptop. So that's pretty scary because you can turn your um, phone into um, you 00:44:37.942,00:44:42.947 know, listening device. [Applause]. Thank you. So um, yeah, and just FYI like all the 00:44:49.987,00:44:53.024 tools I use like actually already on the phone, like you're like Netcat, your like 00:44:53.024,00:44:58.329 stuff to like dim the audio to like, SDN, so you, ju, just like writing some shell script, like 00:44:58.329,00:45:03.734 bash script, whatever. So um, as conclusion uh, for mitigation, like, you want to make sure you 00:45:03.734,00:45:06.804 monitor your network so that you don't have like bugs like sending uh, you know, like weird 00:45:06.804,00:45:13.477 DHCP packets. And uh, actually like McAfee uh, firewall, like can detect that. FYI, you want 00:45:13.477,00:45:17.782 to segregate your network um, to make sure that, for instance, the coffee pot is not able to 00:45:17.782,00:45:23.154 like send weird DHCP packets to your phone. And make sure IT actually patch your phone, 00:45:23.154,00:45:26.490 because you know, it took, it's the patch notes release like, Avaya release a patch like a 00:45:26.490,00:45:31.128 month ago. So make sure it's actually patched. And uh, if you want to think about why this 00:45:31.128,00:45:35.166 kind of bug happened like, tech, technical data is really hard to handle and, no [inaudible] 00:45:35.166,00:45:42.006 someone in good face um. Okay. Um, somebody would face um, fogged the stuff and they forget 00:45:42.006,00:45:47.245 about it. So um, and just as a really quick um, embedded systems are not black boxes, so 00:45:47.245,00:45:52.516 I would just encourage everyone to um, look at them and uh, you can do it now as well. So if you 00:45:52.516,00:45:56.254 have question uh, ask me on Twitter or whatever and thank you for your time, guys. 00:45:56.254,00:46:00.491 [Applause]