1 00:00:00,000 --> 00:00:09,560 Mike Davis. I'm here to talk about hacking or HackRF. Louder. Can you hear me now? Yeah? Okay, 2 00:00:09,640 --> 00:00:15,020 I'll just shout a bit. I'm a little bit hungover and got a bit of a cold, so, you know, my voice 3 00:00:15,020 --> 00:00:20,140 is a bit deep. Yeah, so I'm talking about hacking or HackRF. Basically, the idea is to show you 4 00:00:20,140 --> 00:00:25,240 guys how to take HackRF apart a little bit and maybe modify it and make it do some things it's 5 00:00:25,240 --> 00:00:33,220 not supposed to, which is kind of cool. I'm Elastic Ninja on Twitter, Mike Davis. I'm doing 6 00:00:33,220 --> 00:00:40,160 a master's in information security and, yeah, I love hacking stuff. I've done a lot of hardware 7 00:00:40,160 --> 00:00:46,680 talks and I built this badge as well. So, yeah, you can talk to me about that later if you want. 8 00:00:47,980 --> 00:00:55,040 Okay, so what is a HackRF? So I've actually got my HackRF 9 00:00:55,040 --> 00:00:55,220 organized. I've got my HackRF organized. I've got my HackRF organized. I've got my 10 00:00:55,220 --> 00:01:00,200 part on the table in front of me here, and it's a pretty sketchy setup there, but that's a 11 00:01:00,200 --> 00:01:06,240 HackerRef pretty much open. It's a software-defined radio, and you can get it from Great Scott 12 00:01:06,240 --> 00:01:17,220 Gadgets. It's quite a nice accessible device. It's $330, I think, and it's open source hardware, 13 00:01:17,220 --> 00:01:26,000 which is why I get all excited about it. So one of the fun things about a HackerRef, if you want 14 00:01:26,000 --> 00:01:31,320 to change it, is actually taking it apart. The first time I did it, there were a lot of bad 15 00:01:31,320 --> 00:01:40,440 cracking noises, and I actually broke the case. I used the tool on the left, and if you go search 16 00:01:40,440 --> 00:01:45,600 on the Internet, there's quite a few talks about how to actually do it the proper way, and the best 17 00:01:45,600 --> 00:01:47,200 way is to use HackerRef. 18 00:01:47,220 --> 00:01:52,360 Okay, so this is Jarad Boone, Sharebrains' little guitar pick, and he's got a very specific type, 19 00:01:52,460 --> 00:01:57,560 so you can just go buy one at the store, and the thing just pops open. So he's actually done a 20 00:01:57,560 --> 00:02:04,780 10-second video on it, so that's what you can look at. So here's a map of the world, of the 21 00:02:04,780 --> 00:02:12,700 internals of the HackerRef. On the top right-hand section is just RF and Dragons and, like, 22 00:02:12,700 --> 00:02:17,200 don't fiddle there. There's not a lot you can do in there, but you can try to do what you can do 23 00:02:17,200 --> 00:02:22,320 change it in software. So that's the interesting part. But I'm going to focus on the other side of 24 00:02:22,320 --> 00:02:29,860 it, which is basically everything from the RF section onwards. If you go have a look at the 25 00:02:29,860 --> 00:02:37,180 baseband header, you can get the raw 20 megahertz baseband, both the transmit and the receiver is in 26 00:02:37,180 --> 00:02:42,180 there. The only problem I have with that header is I don't think it's a good RF header. So if you 27 00:02:42,180 --> 00:02:46,760 want to do something with that, you probably want to replace it or maybe put something with 28 00:02:46,760 --> 00:02:53,500 better contacts in it. This is the CPLD. It does a lot of the heavy lifting, decimation, and 29 00:02:53,500 --> 00:02:58,700 moving the data from the, sorry, I didn't mention the front end, which is the little chip on the 30 00:02:58,700 --> 00:03:04,400 bottom left there. And that samples the raw baseband and turns it into digital data. So that's 31 00:03:04,400 --> 00:03:15,140 actually the bit that gives you the digital part of the STR. So the CPLD is kind of like a, I 32 00:03:15,140 --> 00:03:16,740 like to call it a weak FPGA, but that's what it is. It's kind of like a, I like to call it a 33 00:03:16,760 --> 00:03:21,640 logical device. It's not really what it is. It's a logical device. You can program it to map, I 34 00:03:21,640 --> 00:03:28,440 mean, in this case, I think it's mapping pins between the front end and the actual processor. It 35 00:03:28,440 --> 00:03:37,200 does decimation and does a whole bunch of other RF type activities. And then you've got the actual 36 00:03:37,820 --> 00:03:42,300 microcontroller itself with all the headers. And that's the bit that's pretty interesting for me. 37 00:03:45,480 --> 00:03:51,740 And if you take a look at this, this is a great fit. So they've actually chopped the hacker up in 38 00:03:51,740 --> 00:03:58,040 half and just given you that bit on the left there in a slightly different format. A slightly different 39 00:03:58,040 --> 00:04:03,120 chip as well. But if you ask them about the great fit, it's quite a nice little device. I think 40 00:04:03,120 --> 00:04:11,920 they've done a lot of talks on like infrared and all that kind of thing. And basically you can also use it as a kind of logic analyzer as well if you want. 41 00:04:12,640 --> 00:04:24,480 So that's quite a cool thing. So most of the work I've done has been in this little section here. It involves a lot of this kind of thing, breadboards and 42 00:04:24,480 --> 00:04:33,380 little wires sticking all over the place. I've seen someone did a very nice PCB to join two hacker refs together. It was an academic 43 00:04:33,380 --> 00:04:41,580 project and I'll try and find that link. But it's really cool what they did. They worked on the CPLD side and modified that to 44 00:04:42,300 --> 00:04:53,300 two hacker refs. I focused on the processor side and I failed. So anyway, I had a good time doing it. So like I said before, one of the great things about the 45 00:04:53,300 --> 00:05:12,280 hacker ref is that it's open source hardware. They publish all the schematics and you can go have a look through it. And really you can go to Michael Osmond's GitHub and just have a look at the, have a look at it in KiCad. So when you're 46 00:05:12,300 --> 00:05:42,280 opening KiCad, that's the kind of view you get. You can see all the traces between the different components. And if you do a little bit of work, you can just get rid of all the layers that you don't care about. And instead focus on the processor and the headers for this particular thing. The data sheet for the processor that they use is really hard to, like if you look for the pin outs, it's somewhere in the middle of the document. And I can never find it. I wanted to put it on the page here. But basically, it's just a little bit of a 47 00:05:42,300 --> 00:06:12,240 puzzle. But basically, most of the pins that you would be interested in are actually mapped to the headers. So the question is, is it just open source hardware and are multiple manufacturers manufacturing it? So Grayskull Gadgets designed it and make it. And I believe there's a thing called a blue 48 00:06:12,300 --> 00:06:42,280 RF or something like that, which is cheaper and uses cheaper components and breaks more often. And occasionally if you ask them very nicely, they'll fix it for you. But I wouldn't recommend using it. Especially because it's literally a clone that's using cheaper parts. So I'd rather support Grayskull Gadgets. But there are, I mean, you can make it yourself. So I'll talk a little bit later about what I want to do and how I want to change it. And so I'll be kind of, I'll be making a few myself. But I'll be making a few myself. 49 00:06:42,300 --> 00:07:12,280 And then making it open source as well. Yep. Okay, so it's got a, I didn't put the name on it. LPC 4320 is on the hacker app. Like I said, that data sheet is terrible in terms of just trying to find the pin out. Usually it's the first 10 pages. But in this case, I checked last night, I couldn't actually find it. But it has everything you need in there for to do what you want to do. It's got two cores in it. So 50 00:07:12,300 --> 00:07:42,280 it's got an M4, which is a reasonably powerful kind of processor. And then it's got a little M0 sitting on the side. That is, it's kind of difficult to get them to communicate. But you can actually pass data between them. So that's useful for things like driving displays and doing all that kind of thing. While the main processor does a lot of the hard work. As I'll show you later, there's DMA in the, as you'd expect from a modern processor. And a lot of the hacker apps, the main loop in the hacker app does a lot of the hard work. 51 00:07:42,300 --> 00:08:12,280 But it doesn't actually do anything. So most of the work is done in DMA. So if you want to fiddle in there, it's a little bit of assembly and that kind of thing. But it's not a lot of code. It can drive an SD card. It can drive Ethernet. It's got ADCs and DACs. So you can do things like sample microphones and output speakers and that kind of thing. It's pretty cool. And it's got all the rest of the kind of things you may expect. Just a quick overview of all the different headers. There's a lot of 52 00:08:12,300 --> 00:08:42,200 There's four headers. There's P22. It's got stuff like the clocks and SPI. You can see in the bottom left there. I don't use this very often. P28 headers. These are all the ones that are surrounding the actual processor. Again, this is SD card stuff. There's your baseband header. And like I said, I'm not sure. I haven't tried it. But I'm not sure that that's actually, I'm not sure that you'd actually be able to get the quality of 53 00:08:42,200 --> 00:09:12,160 signal that you want out of it. But I haven't really tried it. So yeah. And this is the one that I normally play with. It's got a whole bunch of things. It's got the, you can get push voltage into it. You can get voltage out of it. A lot of ground pins and a whole bunch of GPIO pins that are kind of useful. Okay. So the firmware is also open source. So you can just go to Michael Osmond's GitHub repo and you can 54 00:09:12,200 --> 00:09:38,660 play with the firmware. So as I said before, the typical main loop is just setting up USB mainly. And then just sitting in a while true. So it doesn't really do a lot. Normally I take this out and replace it with something else. And in this case, I want to show off a little the typical kind of hello world, which is a blinky light, blinky LED. 55 00:09:50,420 --> 00:10:12,180 I believe so. But I'll tweet them out. Make it easy. Have you got it? Yeah. Okay. So, I mean, if you want to, typically, if you want to blink a light, you have to interact with GPIO pins. So just 56 00:10:12,200 --> 00:10:19,440 general purpose IO pins. In this case, it's neatly wrapped up in the, for the, anyway, they've 57 00:10:19,440 --> 00:10:23,620 got three LEDs in the front of the hacker ref, so this is neatly wrapped up in a little LED on, 58 00:10:23,780 --> 00:10:32,620 LED off, and LED toggle. And so you can literally just, for hello world, replace the whole main 59 00:10:32,620 --> 00:10:39,680 loop with just LED on, delay for half a second, LED off, and delay again. And I'm going to try my 60 00:10:39,680 --> 00:10:49,580 best not to break this. So you can see the green light, I hope, and that is currently blinking. 61 00:10:51,580 --> 00:10:58,380 So that's basically that code there, just blinking every half second or so. 62 00:11:02,880 --> 00:11:09,260 Okay. So when you program the device, normally, there's the hacker ref SPI flash, 63 00:11:09,680 --> 00:11:15,400 and that just interacts with the USB and then pushes that, pushes your binary into the flash 64 00:11:15,400 --> 00:11:20,620 chip, and then, you know, as soon as you reboot, it loads off that, and it's fine. But I tend to 65 00:11:20,620 --> 00:11:24,840 remove the USB handling because most of what I'm doing doesn't actually have USB attached to it. 66 00:11:26,120 --> 00:11:31,720 So after breaking the USB, you have to use DFU util, and it's super easy. You just push the 67 00:11:31,720 --> 00:11:38,320 DFU button on the front, reset it, and then it's in DFU mode, and that'll get it into, it'll get 68 00:11:38,320 --> 00:11:39,180 your code onto the device. 69 00:11:40,340 --> 00:11:45,040 Getting it back is an interesting exercise in Git reset and that kind of thing. 70 00:11:51,960 --> 00:11:59,100 Okay. So that's the typical loop that I, I mean, that's the base of the loop. So the question is, 71 00:11:59,120 --> 00:12:06,360 how do you break USB or why does it break? Where was that code? So this is the actual main loop in 72 00:12:06,360 --> 00:12:09,660 the normal code. And as you can see, there's two different ways to do this. One is by using the 73 00:12:09,660 --> 00:12:15,580 two sets of USB kind of transfer code, and it runs that continuously. And as soon as you take 74 00:12:15,580 --> 00:12:21,220 that out, I think it's within a couple of seconds, the device, it times out and it stops responding 75 00:12:21,220 --> 00:12:28,880 to USB in terms of the host. Actually, I've forgotten the word, but disconnects it. So it's 76 00:12:28,880 --> 00:12:33,620 very quickly not useful as a USB device. I mean, you can leave this stuff in here, but if 77 00:12:33,620 --> 00:12:38,960 there's no USB device connected while your stuff is running, weird things happen. So I just take it 78 00:12:38,960 --> 00:12:49,620 out. Yeah. Okay. So I did the blinky demo. Sorry. Right. So obviously you want to do something 79 00:12:49,620 --> 00:12:54,000 useful with a hacker. If you don't want to just blink an LED, well, you may want to do that, but 80 00:12:55,860 --> 00:13:00,400 so there's quite a few interesting other open source projects. There's the port of hack, which 81 00:13:00,400 --> 00:13:06,020 I'll describe later. I've got a badge that I wrote, so I use some of that code. And if you dig 82 00:13:06,020 --> 00:13:08,940 around in the hacker code itself, there's a lot of, you know, there's a lot of, you know, there's a 83 00:13:08,960 --> 00:13:13,900 lot of bits of code that actually access the hardware in interesting ways. So like there's a 84 00:13:13,900 --> 00:13:19,920 blinky demo in the actual hacker of source code. So you can go dig around there, have a look, but 85 00:13:20,360 --> 00:13:25,520 port of hack is actually a thing to look at if you want to build something that's not a host 86 00:13:25,520 --> 00:13:32,680 based SDR, you know, or a host connected SDR. And I'll show you that just now. One of the more 87 00:13:32,680 --> 00:13:37,420 interesting things about what I've been doing is trying to power a hacker without blowing it up. So 88 00:13:38,960 --> 00:13:44,900 I can push it into the USB bus, which means that I run the risk of blowing up my computer when I 89 00:13:44,900 --> 00:13:50,300 program it. But if you're careful enough, you can basically power it off, put 5 volts into the V 90 00:13:50,300 --> 00:13:57,240 bus, and then it manages the rest itself. So you can even, can't really plug a battery in there. 91 00:13:57,280 --> 00:14:03,780 There is actually a V bat pin, but I haven't tried that. I'm not actually sure what that does. But 92 00:14:03,780 --> 00:14:08,940 it says battery. Sorry? Okay. Yeah, that makes more sense. So I'm going to push it into the USB bus. 93 00:14:08,960 --> 00:14:14,060 But if you want to, you really need to give it 5 volts and then it's, everything's happy. So, um, 94 00:14:15,600 --> 00:14:23,640 okay. So I, I built a shaky demo. It basically, um, I'll show you the code now, but it sits in a loop 95 00:14:23,640 --> 00:14:30,240 and it, um, it pulls, pulls a 2.4 gig spectrum into little bins and then tries to display it on my 96 00:14:30,240 --> 00:14:36,140 little badge here. So I did it in my hotel room. It's a little bit sketchy, but it kind of works. 97 00:14:42,020 --> 00:14:47,080 Um, also the contrast is a bit rubbish. I don't know if you can all see that. But so in theory, 98 00:14:47,140 --> 00:14:53,080 that's the 2.4 spectrum, uh, just doing a waterfall down here. So again, the Portapak does a 99 00:14:53,080 --> 00:14:58,940 much better job of this. Um, and it's a really nice sort of, um, device. But, uh, if you wanted 100 00:14:58,940 --> 00:15:04,180 to put a display on, there's also display drivers, uh, on the, well, there's a display, uh, 101 00:15:04,200 --> 00:15:08,940 peripheral on the actual hacker app as well. So you could plug that in too. Um, so, um, so, um, so, 102 00:15:08,940 --> 00:15:25,060 this is just a bit banged SPI talking to my badge. Okay. Anyway. Um, so the reason I started 103 00:15:25,060 --> 00:15:32,520 all of this was I wanted to have multiple hacker apps, um, synchronized so I could do TX and RX or 104 00:15:32,520 --> 00:15:38,920 I could do, uh, like multiple, so the whole band of Wi-Fi or, uh, in the one case it was, uh, 105 00:15:38,940 --> 00:15:44,280 direction finding. So that was my actual intent and the reason I started taking my devices apart. 106 00:15:44,840 --> 00:15:49,800 I also have far too many hacker apps because I was trying to do that kind of thing. So, um, uh, if 107 00:15:49,800 --> 00:15:55,720 you want to buy one. Anyway, um, but, uh, so it was relatively simple. It's just, like, 108 00:15:55,720 --> 00:16:04,880 basically plugging a few GPIOs in together and synchronizing the clocks. So you'll see, you'll 109 00:16:04,880 --> 00:16:08,920 see on the hacker app there's two ports on the back and those are for, um, for accessing the 110 00:16:08,920 --> 00:16:13,080 device, um, accepting or transmitting a clock. And, um, the clock in the hacker app is not that 111 00:16:13,080 --> 00:16:18,880 great. So it drifts a bit. I think it's a, it's just a standard or relatively standard crystal and 112 00:16:18,880 --> 00:16:26,780 it's got 20 to 100 ppm kind of, um, accuracy. So there are, um, changes you can make to it to get 113 00:16:26,780 --> 00:16:31,320 much better. So doing things like GPS and that kind of thing you can actually do with a hacker 114 00:16:31,320 --> 00:16:36,920 app, but you need to do a lot of work. But anyway, so, um, the problem with this approach is 115 00:16:36,920 --> 00:16:38,900 you've got multiple USB ports that you have to plug in and plug out. So, um, so, um, the, the, the, 116 00:16:38,900 --> 00:16:43,580 you have to synchronize. And it turns out that synchronized USB is actually a terrible idea. So 117 00:16:43,580 --> 00:16:48,500 it doesn't actually work, but it, uh, for very low bandwidth signals you can actually get away 118 00:16:48,500 --> 00:16:53,200 with it. So the, the difference between the time of arrival of packets and that kind of thing is 119 00:16:53,200 --> 00:17:00,780 actually, it's, you can get away with it. But, um, I gave up on that project. Uh, and I started 120 00:17:01,340 --> 00:17:07,800 thinking about cutting a hacker app in half. And, uh, so the idea is that what I want to do is take 121 00:17:07,800 --> 00:17:12,520 the RF section on one side, not physically cutting it, sorry, but, uh, I don't know what would 122 00:17:12,520 --> 00:17:18,120 happen, but taking the RF section on one side and putting the processing section on another and 123 00:17:18,120 --> 00:17:23,360 then hopefully making little boards that I can plug the, uh, you plug multiple RF sections into 124 00:17:24,960 --> 00:17:30,080 and, and then the discussion becomes what kind of processor do you use and how do you get all 125 00:17:30,080 --> 00:17:37,780 that data across. So then all of a sudden I'm working with USB 3 and FPGAs and that kind of thing. So, um, I'm 126 00:17:37,800 --> 00:17:42,660 kind of, uh, kind of put it on the shelf for now, but I still, I still dream about it. It's like 127 00:17:42,660 --> 00:17:49,320 something I'd really like to do. Um, and there is actually a great Scott gadget board out there that 128 00:17:49,320 --> 00:17:55,720 does multiple, it can do, uh, it adds another radio section to the hacker app. Um, I've 129 00:17:55,720 --> 00:18:00,380 kind of forgotten the name of it, um, but it's a work in progress and I think that might be the 130 00:18:00,380 --> 00:18:07,760 easier path. I'm not sure. But, um, so if you have a look around at the, um, at Michael Osmond's 131 00:18:07,800 --> 00:18:11,820 GitHub repo, you'll actually find it there. Like all of the boards, the great pet and everything 132 00:18:11,820 --> 00:18:18,600 are there. So, um, if you wanted to go and make one and give me one, that'd be great. But, um, anyway, 133 00:18:18,700 --> 00:18:25,560 so that's a project I'm working on. Um, I also fly drones and, uh, that's a picture of my drone 134 00:18:25,560 --> 00:18:30,540 hanging off a wire that I, it took me ages to get out of, get it off of there. But, um, one of my 135 00:18:30,540 --> 00:18:36,120 projects is actually to put hacker apps, uh, or a, one hacker app that I'm willing to risk onto a 136 00:18:36,120 --> 00:18:37,780 drone and use it in practice. So, um, that's a project that I'm working on. So, um, that's a 137 00:18:37,800 --> 00:18:44,340 place of, um, uh, the FPV gear that I, that you can buy commercially. So, uh, the FPV gear that 138 00:18:44,340 --> 00:18:50,660 you can buy commercially is pretty shockingly bad stuff. Um, it's, uh, FM modulated, um, uh, 139 00:18:50,740 --> 00:18:56,080 video signal and it doesn't do well with, you know, interference. It doesn't do well with the 140 00:18:56,080 --> 00:19:01,900 bad antenna. So I thought maybe I could do better. So I've been strapping hacker app onto it and 141 00:19:01,900 --> 00:19:07,240 trying to receive the signal and I'm, I'm getting somewhere, you know. But I'm, I'm, I'm always 142 00:19:07,240 --> 00:19:12,460 worried about that, you know, landing up on, on something and then my hacker app is, you know, 143 00:19:12,500 --> 00:19:20,600 gone. So, anyway. Um, so all of the things I've been talking about are kind of encapsulated in a 144 00:19:20,600 --> 00:19:26,520 port-a-pack. Um, you can buy it at, uh, at the vendor area. It's got a little screen. It's got 145 00:19:26,520 --> 00:19:31,640 buttons. It's got, um, it's got a battery. It's got all the things in there. Um, I haven't bought 146 00:19:31,640 --> 00:19:36,500 one because I like to break stuff myself. But, uh, this thing's pretty cool if that's all you're 147 00:19:36,500 --> 00:19:36,920 looking for. 148 00:19:37,240 --> 00:19:46,200 Okay. Um, yeah. And that is pretty much my talk. So, yeah.