So my name is Aapo. I do a lot of things with IoT, but especially for my work, security research, consulting, and mainly look at IoT and other kinds of devices. I work a lot on cryptography and network protocols. Outside of that, bug bounty. So if you run a hardware bug bounty program, you know where to find me. And I'm also a coach for a Finnish CTFT. But yeah, so here is some IoT and my trusty EPC and I want to kind of see how it works. I might want to hack it or I might want to check out something about it. This particular device connects to the internet with an ethernet port or Wi-Fi. So that should be quite straightforward. If we want to know where it's connecting to, and that's a big part of IoT, we can simply plug in an ethernet cable to the device and the other ends to our laptop. And then on our laptop in the ethernet interface, we will see any traffic it's trying to send. We can do the same with Wi-Fi. So if we have our access point, the device connected to it. And then again, we will see the traffic on the ethernet interface. But there are some kind of devices and especially industrial IoT that have a very specialized job and they have been made to be very cheap. So they have only one way to connect to the internet. And nowadays a big part of it is something else than ethernet or Wi-Fi. So today we will be talking about these kind of devices. So some kind of 4G connection on this one and how that works. There's a modem, you plug in a SIM card and it connects to 4G and it's connected to the internet. But the problem is how do we actually see the data? So this is kind of the topic of today. There are also different kind of devices. They might have multiple ways of connecting to the internet. So here we have a phone currently connected to my Wi-Fi access point and I can see everything it's sending to the internet. Or can I? So if you might not be able to see it, but there's a little 5G icon there so it's actually connected to 5G as well. So question is, is there traffic over 5G as well? So it might be something built in, there might be something malicious. So let's talk about that. So why would you want to look into mobile network traffic? If you're just a tinkerer, if you're at Defcon here or watching this video, then you might be curious. You might care about your privacy. You might think, where do my devices talk to? Is there some kind of unencrypted private information flying through the air? And if you are in traveling in some countries you might want to kind of know what exactly your devices are sending. From offensive security point of view, we might think that can we tamper with the traffic and find vulnerabilities? If you do penetration testing and you have these kind of devices, you need to hack them, you need to kind of do some kind of security audit or something like that. You might want to look at the traffic. Can you say we've kind of penetration tested this if you haven't looked at the mobile traffic? From defensive point of view, you might want to detect malicious traffic or just filter some unwanted things. You can do this in most cases on the device. So if you have a phone, you can install something and it will kind of filter things or endpoint detection or whatever. But if you have some advanced malware on your phone, it might not respect the on-device protections. So if it's running on very low inside the operating system, it can easily just not allow the endpoint protection to run. So we might not want to do the testing on the device, we want to do it outside. So what are these mobile networks? Sometimes called like cellular networks and these come in different flavors. There is 2G, 3G, 4G, 5G, etc. Some older ones, but I think these are the currently used. And in 4G and in 5G, there are these slightly different like NB-IoT is a special version of LTE. But the main thing is that you have different frequency bands and special radios that can talk with these protocols. Usually the mobile networks are operated by internet service providers, so ISPs, and they have massive amounts of base stations all over the world. So if you have civilization, you most likely have a mobile network there. And how you use these mobile networks is you just buy a subscription from an ISP, they will give you a SIM card or send it to you, and then you plug the SIM card into your device, the SIM card authenticates you to the network, and then you connect. You can kind of send text messages or phone calls, but nobody really does that anymore. So it's mainly used to route IP traffic from your device to the internet or wherever you want to go. Usually this mobile network stuff, this is very specialized, and it comes in this separate hardware module called a modem, and that's a separate device on your device. These modems are very complex, usually run their own operating systems, and are basically a small computer that you just connect to your board, and then it handles a lot of things. Here you can see a picture of this, so on the left we have a mobile device. It has a CPU and a modem, and the CPU runs some kind of operating system, Linux or Windows or whatever, and then talks with the modem and offloads the actual mobile network thing to it, and then you just give it data, and the data somehow finds its way into the internet. On 4G we have these cell towers, so these are the base stations that are all over the world, and your device usually connects to the nearest one or the one with the least amount of traffic, so they handle it themselves. The cell tower is connected to the ISP infrastructure, so there's different kind of things, we're not going to go that in depth, because this talk not only covers 4G, but all kinds of mobile networks. But usually they have similar way of operating, so first the radio connects to a serving gateway, and some kind of authentication mechanism, so the SIM card from the modem talks with the auth, and then your mobile device is then, the traffic is routed with these packet gateways to the internet. So how do we intercept this mobile network traffic? So if we want to analyze it, we need to see it, to see it we need to somehow intercept it at some point. So of course the easiest way to intercept traffic is on the device. So just log in, run TCP dump, and you will see the network connections. So if you have a Linux based device, the CPU is sending the data to the modem, but you can look at the traffic already on the device, so no need to any kind of fancy things. So if you can do this, it's very powerful, and especially if you want to know if your device is accepting connections, you might want to take a look at that from the device. So no need to scan all UDP ports if you just like, type in a command that shows you all listening UDP ports. This however, requires root access to the device, so if you want to hack something, um, you might not have this, or if you have some kind of secure device, like an iPhone, you might not be able to, uh, have enough permissions to do this. And also I said that the modem has its own operating system, might have some over there updates, uh, some of the functionality can be offloaded to it, so for example FTP, uh, you can just say to the modem that hey, download these files from this FTP server and hand them to me. And that might not be secure, and if you're just looking at the traffic on the device, you will most likely, you will not see that. And if you're doing penetration testing and you have been relying on this, I have bad news for you, you haven't kind of done your work really well. And we have found a lot of vulnerabilities in the modems. So if we actually want to intercept the traffic, um, there is the CPU, there's a modem, so how this works is they have some kind of serial interface, usually not encrypted because you don't really need to, and um, just kind of look at the board and find the traces and sniff them. Um, this work with these AT commands, sometimes a little bit different, but basically the CPU says to the modem that hey, please make a connection to Google and then send this data through that connection and you will get the traffic. So you can just kind of sniff the traffic and decode it and or even replace the modem with your own software based simulator. So this is something that we've already done. Um, in some cases it's quite simple. If you have kind of uh, clear traces and you just solder your serial port adapter to it and pull the modem to reset, you can do this. But of course it requires hardware reverse engineering and some tiny soldering and again, uh, there's very complex setup sometimes, so um, it might not be as easy as is shown here. And we cannot see the modem's own traffic, uh, here as well. Um, I usually have written my own because it's quite simple to do, but I found this uh, GitHub project that seems to have uh, made similar thing. So if you want to play around with this, you can look at that and uh, try it out. The next thing I tried uh, to run my own base station because I want to see the modem traffic. I figured out just like I have my Wi-Fi access point, I'll do a 4G access point. Um, you can uh, buy this, uh, you can build your own and um, the software defined radios can do pretty much anything nowadays. Just a couple hundred bucks and uh, open source software and, and you can do this. A basic setup, like a thousand bucks, not that much if you're into kind of uh, professional uh, penetration testing. Uh, but it requires a week worth of work to get some running. And if you want to buy the commercial thing then it's, it's really expensive. Uh, the problem with these, the radio bands are heavily licensed. They are used uh, quite a lot and that means that kind of all available bands have been bought by someone. Uh, so it's illegal to run without a Faraday cage. So you need to have a kind of pouch uh, that you put your radio in and your device in and you have to kind of uh, be careful not to leak the thing because someone will find you and uh, come find you. Some of the frequency bands can be licensed. Uh, some countries have unlicensed bands but then you're limited into that one band or uh, that one physical location where you are running this. So if you're into this, there's the Libra Cellular, they have good instructions how to do this, but I have something better for you. So let's go back to the 4G mobile network. We have our mobile device, it talks to the cell tower and then there's the authentication and some other stuff. But what exactly is that other stuff? Like I said, the device is authenticated with SIM card, but it's not authenticated with SIM cards. And then there's some kind of uh, packet filtering uh, going on. There is this thing called lawful interception that uh, kind of means that your traffic uh, can be inspected by the authorities. Uh, and I think if it can be inspected then it most likely is. Um, but yeah. Other things that it does is policy enforcement. So basically it means uh, if you buy a slow speed subscription it will make sure that you won't uh, get good speeds. They calculate the billing so if you have a kind of per megabyte subscription then they calculate the megabytes. Then they route the packets. So there might be some kind of ISP internal things like uh, DNS servers. So some of the things might not go to the internet at all. Um, so they might go to kind of uh, internal uh, DNS service or, or something else. But um, also the packets can be routed internally in different ways. So we have these things uh, called APNs. Uh, which basically mean that um, how to uh, route your packets uh, inside the ISP. So this is something that if you're old you know what these are because you've kind of gotten a new SIM card you put it in and it doesn't work. And then you need to go to these and then you need to type something. But nowadays you might not even uh, know that these exist. So, and if you need to type something you just type in internet and then you get to the internet. Uh, these are actually used uh, so you might have some kind of uh, restricted internet or something. So uh, some ISP is um, uh, offer some kind of child safe things so they do more, more things uh, uh, or some kind of uh, at some point you can kind of get more speed if you, from some, certain ISP. So if you don't use the internet but you use something else then it's faster because there's less people there or, or something like that. But usually just um, you use what the, comes with the subscription. So these uh, a big change nowadays that these are pushed usually through the network to your device. So when you connect and you don't have an APN, the modem asks the network that hey, like do you have something for me and then it's automatically set up. You can change these uh, configure them manually on the device um, but it might not be respected by the ISP. So it basically just tells the ISP, hey this is what I want, but it can of course offer you whatever it wants. So there is this uh, thing called private APN. So um, something that uh, you can kind of buy as a service. So if you run uh, big fleets of IOT devices, you might want uh, to buy this uh, from an ISP. So they will set you up with a internal network where uh, your devices are connected to and they might not go to the internet at all or there might be some uh, uh, kind of you can run your own server there or uh, something like that. It's a private network um, and they can be configured uh, however. So routing, filtering, everything can be configured and direct connection between the devices are kind of at least uh, you can configure them to be allowed. So this is a big difference to normal uh, APNs that you cannot really do device to device connections, but you just have to go through the internet. These also by default usually they don't filter the traffic, so it's um, sometimes the ISPs don't really like some kind of uh, traffic or if you do like port scanning over mobile network, they might shut you down and you don't really know if it uh, works or not. But so you can also set the private APN to connect you to the internet, so you have access to all these services and then you can get uh, also access the internet uh, maybe even with a static IP that then you can configure your servers to only accept that. So then, it's used quite heavily in IOT, so that's where I found out that this exists and I, a lot of the customers are using this. So I kind of figured that this sounds something that kind of, if we want to do this uh, inspect the packets and they use the same things for the lawful interception things, then it might help me kind of uh, look at my traffic. So, I had this question, could I get a private APN? Sounds expensive and uh, I went on a journey to send a bunch of emails to different ISPs and uh, I found out that there's a huge variance in price and usability. So, the first place I went, they had this uh, contact us for pricing and they were like, yeah, we can do this uh, no problem, so you just pay us 3K to get started and then 500 monthly. So I was like, yeah, this sounds a bit too much for a proof of concept and I might as well just run my own base station in a couple of offices. Uh, the next place they were also contact us for pricing, but I was pleasantly surprised. So, they also said that hey, just go to our self service portal and activate it and you're good to go. And they had a 100 USD setup fee and 150 bucks a month. So this is completely doable. There's another place, so they have this uh, $10 setup fee and 75 cents per hour. So different uh, pricing models, so if you look at the, in the similar schemes here, so the first one, if you kind of no matter how much you use it, it's 250 bucks, but uh, then for a year it's just 2K. So you can rent it out easily and uh, other one, so 30 bucks a day, 100 bucks a week and 6.5K for a year. So if you want to kind of uh, do it for longer times, you might want to have this uh, local ISP and then uh, if you just want it for a day, then you can just do it. You have options for that. There is a lot of difference in coverage, so some of them are really global, they offer services in all the countries, some are US specific, some are EU specific and even uh, some are just uh, inside your country. There's also differences in the available data plans, so you still have to pay for your subscription even though you have the private APN because it's kind of a different thing. Um, some of the like IOT orientated ISPs, they offer a really good pricing that you only pay like 2 bucks a year if you send 100 kilobytes of data a year. But if you want to uh, look at your phone traffic, I recommend not using these uh, IOT things uh, because it might be uh, costly. But some of uh, just the regular ISPs offer this, so then you can uh, use your own uh, already kind of own subscriptions and you can have like unlimited data for uh, whatever you are paying for it in your country. And then you can push that to the private APN. So how to configure this? Like once you buy it, first you want to disable the traffic filtering if there is one. Um, and then disable routing to the internet because we don't want the devices to connect to the internet without us seeing it. Next, just uh, site to site VPN between the private APN on kind of our cloud server. We could do a bunch of these things inside the private APN, but I kind of like to be in control uh, of what I do and have like command line access to the server where, where the data is. But once we have the tunnel, we can set our cloud server as the default gateway for the network and that basically means that all the data from the SIM cards first go to the private APN and then it's just shoved through the VPN tunnel uh, into our cloud server. And this basically should mean that the SIM card data is now on our cloud server. And so we need to add some mobile devices to the private APN, so we have our SIM card, we push it into the device. Uh, some ISPs uh, kind of require you to set some uh, APN settings uh, on the device so they are not pushing anything to the devices or they uh, are roaming and you kind of need to set it up. Uh, and kind of some of the ISPs that say that you need to set the APN and you need to set it to this, you might be able to just set anything and it works like on some carriers and then some it doesn't and it's, it's weird. So uh, uh, yeah. And then there are some ISPs like if you actually run uh, both the kind of ISP and you run the kind of infrastructure and you run the cell towers and everything, then you have more control over things. So you have this easy check box that just redirect everything uh, to the private APN no matter what settings or anything there's on the device. So this is uh, something that uh, you want to look for uh, when you are uh, testing devices that don't want to be tested. Uh, because then you just uh, it thinks it's connected to normal internet but it's connected to you. And this should be it. So profit. Uh, let's see. So this is a proof of concept for this. So I talked about there's the IOT device connected to some of uh, some AS uh, ISP and then there's a private APN configured uh, inside the ISP. We have the IPsec VPN tunnel to our server and then I'm SSH into the server. So uh, yeah. Let's see a demo. So uh, here we have the trusty EPC. So it's kind of, it doesn't require fancy things. You just SSH into your uh, server. My server is called private APN because it's connected to the private APN. Here we are running a TCP dump. So the interface is the IPsec VPN tunnel interface and we're looking for traffic from host uh, 10.2.2.2.0.1. And yeah. So we have the uh, 2.2.2.0.1 SIM card. So that has like statically uh, static IP that every time that uh, SIM card is pushed to a device it will get that IP address and here it is uh, booting up. And I'm really interested to see what it actually does. So let's see. Of course takes some time to boot but uh, we have uh, yeah. And now we see some traffic. So it wants to know the time. So not that interesting after all. But if you leave the SIM card to the device then you will see some uh, unencrypted uh, location data from that. So if you're running that tracker somewhere, uh, the ISP knows where you're kind of uh, exactly where you're running it. It's kind of uh, one nice thing about this setup is also you just kind of uh, put the SIM card into something and then you see the traffic. So here is a modem. It's used to connect uh, laptops or ethernet based devices uh, to the internet with 4G. So here it's booting up. And I like I said, it runs its own operating system. This is kind of a device but it might also be a chip uh, inside your phone or whatever. But they run their own operating systems. So once it's uh, booted up uh, we can see that it has, so it actually says here zero devices connected. But there's uh, data there. So it's connecting to netgear.com and uh, a lot of, doing a lot of things. So it's downloading or checking for software updates. But luckily we can see that it's uh, 443 so it's DLS traffic and I couldn't use my certmetem tool to hack that so it's, it can be okay, maybe. But now we at least know that it's, it's not uh, completely bad. And also, so here, next up we have an iPhone. So we're booting it up and uh, I have the SIM card tray and you can see me struggle getting it in. So this is the kind of hardest part of the setup is actually kind of boosting the SIM card inside. One of our project uh, kind of penetration tester pushed the SIM card and it, we heard this kind of clunk, clunk, clunk, clunk, clunk because it was inside the device and it was a competition and we only had 30 minutes so we had to shake it out of the device. But yeah, that was one joke and uh, that's all of them. So if we push the SIM card into the device, you can see it's actually locked. So this is the first boot before unlock. We push a SIM card into an iPhone, so let's see what happens. Yep, so it's connecting to somewhere. So in here I think it's doing uh, some uh, push notifications so it's uh, getting that. And I think it uh, won't do that many things before you actually unlock it but we are actually seeing something. So if you are into hacking locked devices, you might want to look into this. So yeah, so this is the demo. That's uh, how easy to actually run it uh, once you've set it up. Yeah, and let's get back to this question. So is there traffic over 5G as well? So of course when I made this slide I was like hey, I will need to kind of uh, check it. So this is my phone, I connected it to a Wi-Fi, then I pushed the same SIM card into it and this is what I see. So even though it's connected to Wi-Fi, you will see traffic. So these are the, I think similar Apple push notifications. Uh, first when I Googled these IP addresses I went kind of uh, the first match was some weird Russian forum and I got scared. Um, but turned out it's uh, maybe not some uh, malware on my phone. But yeah, so there is uh, something that the operating system does so it overrides the Wi-Fi and pushes directly uh, through the 5G. And if there is some kind of advanced malware then it might also pop up here. So proof of concept it's kind of uh, kind of uh, yes. So uh, from kind of moving on from the proof of concept to an actual project that uh, you guys can use. Uh, so I collaborated with some IOT security experts. Some of them are here in the room and they have had the same exact problems. So, how do you, of course they have the problem of how do you kind of uh, look at your mobile traffic and bunch of them were in the face of using their own uh, kind of mobile base stations and uh, software defined radios and kind of trying to use an IOT device that you need to kind of boot up and then you need to press a button. But once it's inside the bag it's kind of hard to best press the button and uh, then I told about this that hey I, I kind of uh, think this is the way to do it and, and kind of I can see them contemplating kind of uh, years worth of uh, doing all the previous steps. Um, and yeah some uh, I also heard that they are running similar setup than I do. Like one person I know that has been running this uh, and a bunch of that haven't. So of course I'm from Finland. We have the kind of uh, holy land of uh, network connectivity so of course everything works there. Uh, it's cheap and uh, stuff like that. So I wanted to look at the US where it's uh, the opposite. There's, it's not cheap. Um, and also EU and global stuff. So it turns out a lot of ISPs and companies offer affordable private APNs and um, they a little bit different but uh, I created this uh, GitHub page so it's online now. And you can see this uh, to get uh, some up to date things. So they are, there are global ISPs there. So one of the ten bucks uh, to set up and twenty bucks per day thing works everywhere. Uh, if you've seen me uh, before today I've kind of given out bunch of SIM cards so you can try this out. But uh, there would, should be something there that works in your country. Uh, but of course the global IOT providers might be too expensive for your use case if you want to use more data. Uh, and if you want to use kind of your existing uh, mobile plans or you want to use your local ISP, you really should kind of show them this GitHub page and ask them hey, do you want to go there on the GitHub page so people will buy your services and uh, figure out if you can make it work. Uh, if they have to do it manually it will be expensive. So uh, usually you want to look for something that has a, a self service portal that works. But yeah. So this is my kind of uh, full set up. And this is the GitHub that I run. So I have uh, multiple IOT devices connecting to an ISP and so a global ISP one of the devices is in Helsinki in uh, in my home. One is here in Las Vegas. And they are kind of in the opposite sides of the world but they still connect to the same ISP. And they do the ISP stuff. Go into the private APN. Uh, different uh, ISPs have different kind of uh, different tunnels. But uh, they end up in my, my server. There I run WireGuard but you can also set up uh, another type of VPN uh, for your pentesting like uh, workstations. So here I have on the right like a Kali Linux machine in Helsinki. Uh, some of my colleagues maybe be in Stockholm and they have the same. And uh, with this uh, VPN server on the cloud server. So there's like one to one mapping. So IOT like SIM card one goes to VPN profile one and the VPN profile one is opened uh, in Helsinki. And then the traffic just magically goes there. So once you set up this uh, if you are working in a company, your colleagues will love you. You just hand them out SIM cards. You hand them out uh, uh, VPN profiles. And then like they're hey, what's this? And you just hey, push that in there and then just double click that and then you see the data and everyone's amazed and you're a hero. So uh, it's that easy. But you can of course don't have to have this fancy set up if you just want to do everything on the cloud server you can do it there. Um, also like I said on the GitHub you have um, a list of uh, private APNs. The list is quite small because I use things that I found that work in Finland. When I flew here I tested uh, London. So in London this works great. Uh, here uh, I run into the problem that the modem I was using to kind of uh, figure out if they work in different ways. Uh, doesn't work in the U.S. because I noticed that the U.S. has different mobile network stuff for some reason. But um, I tested that these work well on my phone here. So I just push it into my phone and I can see the traffic uh, on the server. So confirmed to work well um, everywhere in the world. But yeah, so let's wrap up and um, go back to the kind of why do, would you want to do this? So curiosity and privacy. Fifty bucks, couple days of tinkering on a device, like that's a good deal. Uh, it's actually the fifteen bucks is like one evening of like six hours of of uh, tinkering with this. So not, not much. And even if you use this uh, if you want to use it for a longer time you might want to look into uh, other options that are kind of uh, less expensive in long term. But hackerspaces or even tiniest penetration testing companies, like two K a year should be a no brainer to uh, if you really want to look at the traffic. Offensive security. So if you do penetration testing on IoT and you say to your customers that hey we kind of look at the device and look where it's connected to, you really need some kind of setup to do this. And two thousand a year versus an illegal setup that's kind of, you need to have your best engineers work a week on, so that's really expensive as well. These devices, especially in industrial IoT, uh, they're everywhere and people don't really look at their traffic that much. So there's just a handful of companies that actually I know that do this, but now anyone can do this. And like I said, maybe some new attack vectors for high security devices that if you can push a SIM card in and it, you get the data then you can also uh, send some uh, malicious things uh, to it. Defensive point of view. So these private APNs, uh, like I connect it to my server, but you can connect the IPsec tunnel to your existing firewall. So if you are running some kind of uh, firewall, then uh, you can just connect this to it. Um, kind of the first devices might kind of uh, cost something and then you, it costs more to add devices but the cost goes down uh, gradually. So if you have thousands of devices, it will be still uh, quite uh, inexpensive to do. And the mobile phone malware infections, they might not communicate at all over Wi-Fi or VPN. So there was this uh, hack, some kind of some triangles or something and uh, they said that when they noticed the hack, uh, they were uh, scanning there or like they were looking at their Wi-Fi traffic at their office and they noticed that some of the phones were sending things to some uh, C2 servers. And they also analyzed the malware and the malware had these properties that it can detect if it's been uh, run over Wi-Fi or VPN and not do it. So it might have been misconfigured to allow traffic over Wi-Fi because why would you, people are looking at the Wi-Fi, why would you do your malicious stuff over that? So it might have just been a misconfigured malware that they happened to find through their Wi-Fi. So I, my thing that the advanced malware that sometimes are not that advanced uh, might get better at this or they might already be doing this and that was just one uh, slip up. Uh, so yeah, if you're targeted by uh, advanced malware, you might want to do kind of, this kind of thing. But you can find the project details, you can uh, snap a uh, photo of this to remember it and you can find me here at DEF CON or the internet and uh, thank you for your uh, coming here.