Mike Davis. I'm here to talk about hacking or HackRF. Louder. Can you hear me now? Yeah? Okay, I'll just shout a bit. I'm a little bit hungover and got a bit of a cold, so, you know, my voice is a bit deep. Yeah, so I'm talking about hacking or HackRF. Basically, the idea is to show you guys how to take HackRF apart a little bit and maybe modify it and make it do some things it's not supposed to, which is kind of cool. I'm Elastic Ninja on Twitter, Mike Davis. I'm doing a master's in information security and, yeah, I love hacking stuff. I've done a lot of hardware talks and I built this badge as well. So, yeah, you can talk to me about that later if you want. Okay, so what is a HackRF? So I've actually got my HackRF organized. I've got my HackRF organized. I've got my HackRF organized. I've got my part on the table in front of me here, and it's a pretty sketchy setup there, but that's a HackerRef pretty much open. It's a software-defined radio, and you can get it from Great Scott Gadgets. It's quite a nice accessible device. It's $330, I think, and it's open source hardware, which is why I get all excited about it. So one of the fun things about a HackerRef, if you want to change it, is actually taking it apart. The first time I did it, there were a lot of bad cracking noises, and I actually broke the case. I used the tool on the left, and if you go search on the Internet, there's quite a few talks about how to actually do it the proper way, and the best way is to use HackerRef. Okay, so this is Jarad Boone, Sharebrains' little guitar pick, and he's got a very specific type, so you can just go buy one at the store, and the thing just pops open. So he's actually done a 10-second video on it, so that's what you can look at. So here's a map of the world, of the internals of the HackerRef. On the top right-hand section is just RF and Dragons and, like, don't fiddle there. There's not a lot you can do in there, but you can try to do what you can do change it in software. So that's the interesting part. But I'm going to focus on the other side of it, which is basically everything from the RF section onwards. If you go have a look at the baseband header, you can get the raw 20 megahertz baseband, both the transmit and the receiver is in there. The only problem I have with that header is I don't think it's a good RF header. So if you want to do something with that, you probably want to replace it or maybe put something with better contacts in it. This is the CPLD. It does a lot of the heavy lifting, decimation, and moving the data from the, sorry, I didn't mention the front end, which is the little chip on the bottom left there. And that samples the raw baseband and turns it into digital data. So that's actually the bit that gives you the digital part of the STR. So the CPLD is kind of like a, I 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 logical device. It's not really what it is. It's a logical device. You can program it to map, I mean, in this case, I think it's mapping pins between the front end and the actual processor. It does decimation and does a whole bunch of other RF type activities. And then you've got the actual microcontroller itself with all the headers. And that's the bit that's pretty interesting for me. And if you take a look at this, this is a great fit. So they've actually chopped the hacker up in half and just given you that bit on the left there in a slightly different format. A slightly different chip as well. But if you ask them about the great fit, it's quite a nice little device. I think 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. 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 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 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 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 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 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 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 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. 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 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. 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 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 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 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. 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 general purpose IO pins. In this case, it's neatly wrapped up in the, for the, anyway, they've got three LEDs in the front of the hacker ref, so this is neatly wrapped up in a little LED on, LED off, and LED toggle. And so you can literally just, for hello world, replace the whole main loop with just LED on, delay for half a second, LED off, and delay again. And I'm going to try my best not to break this. So you can see the green light, I hope, and that is currently blinking. So that's basically that code there, just blinking every half second or so. Okay. So when you program the device, normally, there's the hacker ref SPI flash, and that just interacts with the USB and then pushes that, pushes your binary into the flash chip, and then, you know, as soon as you reboot, it loads off that, and it's fine. But I tend to remove the USB handling because most of what I'm doing doesn't actually have USB attached to it. So after breaking the USB, you have to use DFU util, and it's super easy. You just push the DFU button on the front, reset it, and then it's in DFU mode, and that'll get it into, it'll get your code onto the device. Getting it back is an interesting exercise in Git reset and that kind of thing. Okay. So that's the typical loop that I, I mean, that's the base of the loop. So the question is, how do you break USB or why does it break? Where was that code? So this is the actual main loop in the normal code. And as you can see, there's two different ways to do this. One is by using the two sets of USB kind of transfer code, and it runs that continuously. And as soon as you take that out, I think it's within a couple of seconds, the device, it times out and it stops responding to USB in terms of the host. Actually, I've forgotten the word, but disconnects it. So it's very quickly not useful as a USB device. I mean, you can leave this stuff in here, but if there's no USB device connected while your stuff is running, weird things happen. So I just take it out. Yeah. Okay. So I did the blinky demo. Sorry. Right. So obviously you want to do something useful with a hacker. If you don't want to just blink an LED, well, you may want to do that, but so there's quite a few interesting other open source projects. There's the port of hack, which I'll describe later. I've got a badge that I wrote, so I use some of that code. And if you dig around in the hacker code itself, there's a lot of, you know, there's a lot of, you know, there's a lot of bits of code that actually access the hardware in interesting ways. So like there's a blinky demo in the actual hacker of source code. So you can go dig around there, have a look, but port of hack is actually a thing to look at if you want to build something that's not a host based SDR, you know, or a host connected SDR. And I'll show you that just now. One of the more interesting things about what I've been doing is trying to power a hacker without blowing it up. So I can push it into the USB bus, which means that I run the risk of blowing up my computer when I program it. But if you're careful enough, you can basically power it off, put 5 volts into the V bus, and then it manages the rest itself. So you can even, can't really plug a battery in there. There is actually a V bat pin, but I haven't tried that. I'm not actually sure what that does. But it says battery. Sorry? Okay. Yeah, that makes more sense. So I'm going to push it into the USB bus. But if you want to, you really need to give it 5 volts and then it's, everything's happy. So, um, okay. So I, I built a shaky demo. It basically, um, I'll show you the code now, but it sits in a loop and it, um, it pulls, pulls a 2.4 gig spectrum into little bins and then tries to display it on my little badge here. So I did it in my hotel room. It's a little bit sketchy, but it kind of works. Um, also the contrast is a bit rubbish. I don't know if you can all see that. But so in theory, that's the 2.4 spectrum, uh, just doing a waterfall down here. So again, the Portapak does a much better job of this. Um, and it's a really nice sort of, um, device. But, uh, if you wanted to put a display on, there's also display drivers, uh, on the, well, there's a display, uh, peripheral on the actual hacker app as well. So you could plug that in too. Um, so, um, so, um, so, this is just a bit banged SPI talking to my badge. Okay. Anyway. Um, so the reason I started all of this was I wanted to have multiple hacker apps, um, synchronized so I could do TX and RX or I could do, uh, like multiple, so the whole band of Wi-Fi or, uh, in the one case it was, uh, direction finding. So that was my actual intent and the reason I started taking my devices apart. I also have far too many hacker apps because I was trying to do that kind of thing. So, um, uh, if you want to buy one. Anyway, um, but, uh, so it was relatively simple. It's just, like, basically plugging a few GPIOs in together and synchronizing the clocks. So you'll see, you'll see on the hacker app there's two ports on the back and those are for, um, for accessing the device, um, accepting or transmitting a clock. And, um, the clock in the hacker app is not that great. So it drifts a bit. I think it's a, it's just a standard or relatively standard crystal and it's got 20 to 100 ppm kind of, um, accuracy. So there are, um, changes you can make to it to get much better. So doing things like GPS and that kind of thing you can actually do with a hacker app, but you need to do a lot of work. But anyway, so, um, the problem with this approach is you've got multiple USB ports that you have to plug in and plug out. So, um, so, um, the, the, the, you have to synchronize. And it turns out that synchronized USB is actually a terrible idea. So it doesn't actually work, but it, uh, for very low bandwidth signals you can actually get away with it. So the, the difference between the time of arrival of packets and that kind of thing is actually, it's, you can get away with it. But, um, I gave up on that project. Uh, and I started thinking about cutting a hacker app in half. And, uh, so the idea is that what I want to do is take the RF section on one side, not physically cutting it, sorry, but, uh, I don't know what would happen, but taking the RF section on one side and putting the processing section on another and then hopefully making little boards that I can plug the, uh, you plug multiple RF sections into and, and then the discussion becomes what kind of processor do you use and how do you get all 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 kind of, uh, kind of put it on the shelf for now, but I still, I still dream about it. It's like something I'd really like to do. Um, and there is actually a great Scott gadget board out there that does multiple, it can do, uh, it adds another radio section to the hacker app. Um, I've kind of forgotten the name of it, um, but it's a work in progress and I think that might be the easier path. I'm not sure. But, um, so if you have a look around at the, um, at Michael Osmond's GitHub repo, you'll actually find it there. Like all of the boards, the great pet and everything are there. So, um, if you wanted to go and make one and give me one, that'd be great. But, um, anyway, so that's a project I'm working on. Um, I also fly drones and, uh, that's a picture of my drone hanging off a wire that I, it took me ages to get out of, get it off of there. But, um, one of my projects is actually to put hacker apps, uh, or a, one hacker app that I'm willing to risk onto a drone and use it in practice. So, um, that's a project that I'm working on. So, um, that's a place of, um, uh, the FPV gear that I, that you can buy commercially. So, uh, the FPV gear that you can buy commercially is pretty shockingly bad stuff. Um, it's, uh, FM modulated, um, uh, video signal and it doesn't do well with, you know, interference. It doesn't do well with the bad antenna. So I thought maybe I could do better. So I've been strapping hacker app onto it and trying to receive the signal and I'm, I'm getting somewhere, you know. But I'm, I'm, I'm always worried about that, you know, landing up on, on something and then my hacker app is, you know, gone. So, anyway. Um, so all of the things I've been talking about are kind of encapsulated in a port-a-pack. Um, you can buy it at, uh, at the vendor area. It's got a little screen. It's got buttons. It's got, um, it's got a battery. It's got all the things in there. Um, I haven't bought one because I like to break stuff myself. But, uh, this thing's pretty cool if that's all you're looking for. Okay. Um, yeah. And that is pretty much my talk. So, yeah.