Hi, everyone. Oh, my God. Hi. Will that go over there? We'll give you 10 minutes. We have 10 minutes. Test. Okay. Hello, everyone. Welcome to the annual phenolate speech at DEF CON. We got plenty of material to cover, so I might actually step over some stuff pretty quick. And if you got questions, the idea is I will hang out on the first pool, and you're going to buy me beer, and I answer your questions. Okay, let's go. What we're going to do. First, if you catch Richard Thiem's talk, lots of people are concerned about what's the matrix? Are we in the matrix? How to hack the matrix? So we thought we're going to look at it and tell you how to hack the matrix. Then we have some GSM stuff, you know. After that short, fun excurs, we will actually cover GSM and GPRS basics. GSM is swapping over, finally, to the United States, so you finally got decent phones. And I thought it would be quite useful. To actually give you an introduction and how the backbones work. So we will also discuss two things about the mobile phone networks, attacking mobile phones and attacking mobile phone backbones. And of course, this being a phenolate speech, we have the usual Cisco Oday crap and shell codes and stuff. Hacking the matrix. There is a product from made by Interisys. They used to be Cabletron. It's called the Matrix. So just because they gave it the wrong name, I started looking at it. This is basically a switch router. So you have a switch and you basically can say this and that port is now going to be a router. And well, to sum it up, the vulnerabilities it got. If you do anything for management, you better have TCP IP working, right? So this being an embedded system. You do like 10 connections or you complete 10 TCP handshakes to any given service that you use for management. Let's say it's Telnet or SSH and that's about it. Nobody else is going to do that anymore. The same thing on the switch ports that are not assigned to a router. They used this very advanced technique for calculating initial sequence numbers for TCP. That's known as the 64K rule. So NMAP will actually tell you it's a piece of crap and it's easy to hijack. So well, when you unpack the box, it is a switch. So as soon as someone Telnets there, you can hijack the connection easily. And also of course it does OSPF. For those of you I talked to years ago, you know that OSPF is quite useful and you can do lots of things with it. The bad thing is vendors tend to read RFCs incompletely, so they actually read the part that told them how to build the packets for OSPF, but they didn't read the part that told them how to make OSPF work. So you just sit there and flood it with OSPF hello messages, which basically means here's a new router, here's the next new router, here's the next new router. And instead of validating that first and then tell everyone else, it will tell everyone else in the network right away, which translates to all you need is one of those boxes in your OSPF network and it will actually kill the whole network for you. And, well, to make a long story short, last year I said if you got an embedded system and it got port 80 TCP open, you can bet your assets vulnerable. So same holds true for the matrix, which answers the question how to hack the matrix, use ADCP. Okay, GSM basics. The global system for mobile communication, GSM, is actually used for quite a while and was standardized by the ETSI. In contrast to the mobile networks you got here, usually there is a very specific difference between what they call the terminal equipment and everyone else calls a phone, and the SIM card. And, you know, it's a very specific difference between what they call a phone and what they call a SIM card. That is actually a smart chip handling all your information. You use the SIM card to authenticate the key material on the SIM card to authenticate and you use your caller ID and other IDs to authenticate. The phone does not matter. The GSM core networks actually rely on this information to find out who you are and actually bill you for the service they provide. So lots of people have tried to do call-to-call. Caller ID spoofing and other stuff with GSM. Some succeeded in very limited environments. But, in general, it's all fine and all good. Which actually changes. It changes with what's known as GPRS, the General Packet Radio Service. Well, this service now is pretty much like the internet was compared to leased line services. So, you had, in the beginning of networking, you had leased line services and direct connections and then you had GPRS. And, you know, you had GPRS. And, you know, you had GPRS. And, you know, you had GPRS. And, you know, you had GPRS. And, you know, you had GPRS. And, you know, someone came up with the internet thingy and all the packet forwarding crap. And all hell broke loose. Same here. So, this is actually packet services for mobile phones. So, you can surf web faster and do all kinds of stuff with it. And, consequently, the whole backbone infrastructure is running on IPv4. Now, authentication is a bit different here. If you want to find out which network you're talking to, you use the APN. And the access point name. This is something you transmit to the GSM network and it will figure out on which site you will pop up. So, that does not have to be the internet or a web gateway. And then, optionally, you got PPP running over that, giving you IP addresses and, of course, doing this chat path thingy, find out who you are if you got the right username and password. APNs. You should actually think of an APN as a URL. It is quite similar, actually, because you give it a name and it will tell you which network you're talking to, in contrast to a real URL telling you which server you're talking to. So, the same thing in full color. What you got here is actually a very basic picture of a GSM network. You got the guy here being the mobile phone, talking to the PLMN, which is the public land mobile network. Everyone else just says the mobile network. You got the HLR, which is the home location register, and you can actually think of it as a huge fucking database. Often it runs Oracle. If you're Rome, there's another thing that's called the visitor location register. And the HLR actually holds all the information about you and your credentials and what you're supposed to do. And what you're supposed to do. What you're not supposed to do. Then you got the SGSNs and the GGSNs. The SGSNs are the serving GPRS support node. And GGSN gateway GPRS support node. Think of the GGSN as a backbone router and the SGSN as the one actually talking to the HLR and forwarding this stuff. So, it's pretty much like a framework network. And of course, you got more than one GGSN. So, you got one facing the internet. You got others facing... You got them in the same company dedicated networks. So, big companies go there and say, OK, you're doing GPRS. That is quite useful. So, you got, let's say you got any kind of logistics company like UPS or FedEx and they got what I call the oversized Game Boys and where you're supposed to sign on. These devices have to talk back and actually make sure that, well, you signed and the package was delivered. And well, it's quite easy for them to actually order GPRS services. an APN and every time those devices have to talk to the network, they open the APN, say, this is where I want to talk to, and now they end up being in the UPS internal network instead of the internet. Of course, nobody prevents you from doing the same. So GPRS attack points. First, the GGSN, as I said, is just another IPv4 device. At stake, I actually figured that out. They had a Nokia GPRS box hanging off the internet and they actually found a vulnerability there, something totally simple like a special TCP option. You can actually expect a lot of stuff going on with those, especially on the networks that face not the internet, but some company networks. The scary thing here is Cisco also does GGSNs. Now, as I said, GPRS is an IPv4 device, so it's not necessarily a GPRS device, but it's a GPRS device. APNs can actually be gassed. They're not considered a secret. It's like the URL. Most of the APNs are actually either the URL of the company's homepage or the company name, so you can just go ahead and try it. I did that in Germany and it turned out that lots of major companies actually have their company name as APN and you get asked for a username and password via PPP. Of course, this being a large user base, you often find usernames and passwords where it's called test and test and yeah, you know how that works. The thing here is you can actually do APN filtering in an HLR, but no provider does it for a simple design failure reason. You can only say that a user account is allowed to do all APNs you want or a limited list. Now, that would be pretty bad for the database if they had to write that down into the database for 22 million customers, so they don't, say, that. They just say, oh, one can go to whatever APN he wants and yeah, the GGSN were the authentication servers or radio servers that are hanging off there doing the authentication and with a large username and actually user account database, you sure as hell find weak passwords. So but there is actually more to it. So if you happen to have for what ever... Another reason, maybe for staying at DEF CON or talking to some guys, you happen to have one single computer in a mobile phone provider's network. It can be the secretary's Windows PC or whatever. You can actually do quite some interesting stuff. There is the GPRS tunneling protocol, GTP. It's standardized here for everyone who loves to read boring documents. You can actually get that off the ETSI web page. The protocol is actually designed to transport user data and control data via IPv4 in the GPRS backbones and is also used in UMTS backbones, so the third generation that you didn't even hear of. The protocol can control pretty much everything in the network. This includes setting up modifying tunnels. Connections, data transfer path. You can modify the VPN access for an active subscriber. You control how they roam. Of course, you control how the accounting works. Both the control connections and the user data are ran over the same protocol, so we are talking about all the same thing. The most funny thing is actually already on the fifth page of the standard because it says that every device... SGSN and GDN. SGSN is supposed to support this protocol, including version zero. What they did was actually they standardized their inability to fix the protocol. Even if they come up with a new version that isn't so screwed as the one we're now talking about, the devices are supposed to support the screwed version. This is in the standard. I would say that was not a good move. What's it all about? What's the cool about it? This is in protocol running over IP, so we're quite familiar with it. It runs on UDP, which enables us to spoof. It has no authentication. You can create, update, or delete user contexts to your Lightning with one UDP packet. You can modify or remove billing information with one UDP packet. You can actually reroute traffic and redirect traffic over the backbone, guess what? One UDP packet. You can actually invite people into VPNs. You've got one of those boxes, and you've got a friend who got a GPRS phone. You can actually invite him actively to one of the company VPNs, one UDP packet. Of course, you can force people to roam. Roaming is handled by GDPR. It's the same thing as the UDP between the SGSNs. I was actually wondering why there isn't someone, maybe I did, starting a company as a mobile phone provider and just having one SGSN and constantly sending out UDP packets and make all the users roam over you, which I think is a good business concept, but it wasn't declared as such in the standard. . The fun thing is. How they dealt with security is this. They say, we're ETSI, we're doing GSM, so we don't care about IP. Someone else is going to make IP secure, period, end of statement. Assume you do not have a computer in a mobile phone network. Of course, most of you are not supposed to have one. There is other stuff you can actually do with GPRS and Bob. This is anonymous HTTP. The good thing here is a lot of people, especially at this conference, have a certain interest in doing HTTP without revealing their real IP address to the server they're talking to. Those reasons might include something like Unicode or web applications or other overflows that you might find in port 80 applications. How do you do that? The web protocol is actually the vehicle to go for. You have the wireless transport protocol and the wireless session protocol. The wireless transport protocol is used to do basic transport stuff. The wireless session protocol is actually the one doing a session over the UDP stuff you talk on the air interface to your mobile network. Now, this is used to actually talk to something that's called a WAP gateway. The WAP gateway is supposed to work as a proxy, both in protocol terms and in HTTP terms. It will accept UDP on one side, which is your phone, and it will talk TCP to the other, and it will grab down the webpages you asked for, do something that they call compiling, which basically means take an HTTP or, in this case, WML tags, make them non-tags, so compile them. And one binary format, so it's smaller, and send it to your phone. So, WSP in the default setting that your phones use is a connection over UDP, so it got actually numbers to track the connection and the session, which you compare for those of you who know DNS and the DNS IDs for packets, for requests. This is pretty much the same idea here. Now, an often overlooked fact is that actually the standard says there is a way, um, to do connectionless WSP. Connectionless WSP means, um, you're not setting up a connection. You just send the HTTP request to the WAP gateway. This has several advantages. First of all, you can tell the WAP gateway you're not really interested in the answer, which means it's not gonna send one. Um, the second thing is, this being UDP, of course, we can easily spoof again. Um, which now means we're actually, um, giving the company, the mobile phone company, money by, um, using GPRS, and, but we're actually not using our own source IP address, but someone else's. And this is quite okay. Um, the WAP gateway does not filter that. Usually, I have not seen a WAP gateway or any other device in a mobile network that will actually detect spoofing. But they might exist. Correct me if I'm wrong. So, you actually got anonymous HTTP request capabilities, and to make it nice and have a little drop of sugar on top of it, it's billed to someone else. You just find out which IP addresses are used, which, of course, you do with this ICMP-sending utility called ping. And then, you use their IP addresses. So, um, not only is your HTTP-based attack anonymous, but someone else is gonna pay for it. So, um, this is the summary of how to do that, in case you wanna try that at home. Um, the good thing is, um, you don't actually need to have a phone. There are open WAP gateways in the internet. So, you can actually look for, um, UDP port 9200, and, well, then apply your responsible, um, procedure in dealing with new ways of exploiting things. Subtitles by the Amara.org community Yeah. Um, I had a certain problem with an NDA here. So, I just wanted to make sure that this is covered in the slides. Go make me drunk. Um, okay. From the backbone to the, um, actual devices, this is the thing we're talking about. The Siemens S55. Now, there are lots of smart people actually dealing with PDA-sized phones and, um, other, yeah, the new generation. The new generation stuff that runs SymbianOS. And I'm not really smart enough to compete with them. Um, so, we had a different reason looking at that one. Simple for the reason was, um, we had it. And those Simi smartphones, as I call them, are very widespread use. It's like the camera phones and MMS crap and Java applications. And so, we picked actually one, um, to play with it. It got Bluetooth. So, what's bad about the Bluetooth implementation here is every time you start a connection, it will, of course, ask you if you want to pair with this device. This is fine. Well, if you start the next connection, it will ask you again. So, you open about a hundred connections and it will have a hundred message boxes on the screen. Bad thing is, there's not being windows. You don't see that those are multiple message boxes lying on top of each other. So, you acknowledge one or disagree. You dismiss one and it still looks the same. You have no idea what's going on. Um, and, well, the same problem actually holds true for the connection, um, what is that, the connection resources in the phone. So, you do more connects to it. At some point in time, um, it's so busy waiting for the user to acknowledge or dismiss this pairing, um, that it doesn't have any connections left. So, if this guy had a headset or anything else, actually working with the phone, this changed. It's no longer working. And all you need is something that's called an L2 ping. It's just a layer two, um, kind of ping. So, that's quite easy. The big inbox is something I really like to do in airport lounges. You got all the executives with their, um, little nice phones. And, well, everything they do is, like, they get the phone, they set a new background picture and turn on every possible feature. So, um, the thing is, the S55 accepts whatever files you send it and puts it in a directory saying incoming data. Now, it is quite easy and not really time consuming to send 2,100 files. Unfortunately, it is quite time consuming to delete 2,100 files on your phone. Because they actually got a function that's called delete all. But this function seems to use a counter for what all actually means. That is byte sized. So, you can actually delete 255 files at the same time. Um, but this is not gonna win the race against the one sending the files. And it is, by the way, quite annoying when they're on the phone because it keeps peeping. Okay, so the next big thing that, um, the vendors of the phones actually advertise is the whole Java stuff. Well, if you remember last year, I hate Java. Um, but Java is actually supposed to be a secure programming language. And this is done by having exceptional circumstances in your program code, um, manifest themselves as exceptions. One of those exceptions is a null pointer. Well, a null pointer exception shouldn't kill a Java virtual machine. Actually, here it does. So, everything that could possibly trigger a null pointer exception, which often is just leaving out data, um, will result in what we call the widescreen of death. Because, as you see on the picture, this is how it looks like. All you have to do is trigger a null pointer exception, and we're gonna show you how. Um, there is a thing called the jot files. Jot files are actually text files. They're comparable to, like, INI files on Windows. Um, they're lying around on WAP servers. So, you serve WAP, and it says, download Java application. Or, it says, click here. Um, and you actually pull down a jot file, and it figures out what the name of the Java application is, what size, where it comes from, uh, what classes it needs, and stuff. And, of course, the name of the Java application is quite interesting, because it wants to ask you if you want to install it or not. Um, and that's stored in the midlet name. Well, if the midlet name is missing, you get what you see here, the widescreen of death. So, you can actually build, uh, WAP pages with evil Siemens links, which is quite funny. But, the other thing is even more funny. I didn't find a way to exploit it. Um, but that might be just a stupid me. Um, you have an overlong midlet name. So, in case the user actually is stupid enough to acknowledge the installation of the Java application A-A-A-A-A-A, um, what happens is, it will create a directory to put the Java application in. So, it passes, um, the Java application name as a directory name to the core operating system. Now, there seems to be a limit, which means that if you have a normal name, that works well. If you have an overlong name, it will actually overwrite the name of the file and some structures that are supposed to, um, yeah, run the file system. So, you cannot delete this. You actually have to flash the phone and remove all the data by, like, reformatting the whole phone, which is the reason this little fucker here doesn't know any other ringtones than the default one anymore. So, but even with the Java stuff, well, you can crash it, but you can actually do more. Spy.jar, um, the idea actually is here, um, that you can have some limited information pulled off the phone by Java applications. Most phones will actually complain if a Java application tries to, um, make a connection outgoing and, like, send data. Well, the Siemens doesn't. The Siemens just says, um, well, it does a tiny little beep, nobody really hears, and then, um, lets you through. The question is, which information can you get? In the standard Java classes, Java X and all the mid-led stuff, there isn't any interesting, but we got the company class trees, and, of course, Siemens got one, and they're growing every time. This is the, um, information from, like, today. Um, it might change with the next firmware, and they got new classes. But today, you also can, uh, you already can get, um, the list of missed calls. Now, the information what calls you missed and from which number they came can be quite interesting if it's, um, sent to some external server. And, of course, you can also, um, get the, um, IMEI of the phone, so you can actually identify the phone correctly. Um, so we tried that, and you can have a Java application. It could be a little game or whatever, um, whatever it is posing as, and every time you play the game, it's actually telling some web server in south of Russia, um, which calls you missed. I don't think that's a good idea. Time.jar is very, very funny because it shows that Java does not necessarily prevent you from doing stupid things. Um, sending an SMS or placing a call can be a costly thing, depending on where you call or where you send the SMS to. I don't actually know if you got, um, so-called value-added services, um, uh, SMS and MMS in the States already, so where an SMS costs you about three bucks. Um, but we got quite a lot of them in Europe, and guess what they're offering. Um, so normally, it is supposed to actually ask you, um, when a Java application will trigger the phone to call someone or send an SMS. Um, it is supposed to ask you and say, hey, look, um, do you want to do that? But we got a little problem here. This confirmation is done by a dialog. Now, Java, not being the fastest programming language in the world, um, has a timing issue here. If you, before you try to send the SMS, actually, um, fill the screen and do something else on it. So, to make that visual, this is what it is supposed to do. For those who cannot read it, it says allow sending SMS to whatever number, and, well, you're supposed to press yes or no. Due to the timing problem, you can ask different questions like, would you like to play a game? I had the idea, um, of actually using the two buttons that are supposed to say yes or no, um, as a control in some, uh, jump and run game. So, you would actually press yes, um, approximately 50 times, uh, 50% of the time, and send about 1,000 SMS, each three bucks. The next thing we got here is something that is actually, uh, related to the whole MMS picture phone thingy. Well, of course, to send pictures and do MMSs, you need to have, um, image formats. So, the image format of choice here is GIF and, um, JPEG. Now, the GIF file format, um, as you all know, supports multiple frames for animated GIFs. For that to be flexible, you got something in the file format that is called the virtual screen, which describes, um, which area on the screen is actually covered by the sum of all, um, frames in the GIF file. Now, what you can do here is send a GIF file that actually, um, has, in one of the frames, offsetting in this virtual screen. This is supported by the standard. The good thing about that is, um, well, the virtual screen itself is not really supported by Siemens. So, um, you're actually writing the GIF data into some memory that is not displayed, um, but holds something different. So, if you actually open such a GIF file or you get an MMS with it, um, your phone will crash. It will crash and it will just go off. It is very interesting, but, um, you can make this permanent by placing this picture as a background image on the phone, which is pretty much the last thing you did with the phone. Okay. Enough of that crap. Um, I'll actually go and do some of the Cisco stuff. This was not intended to be here, but, um, since a lot of people were talking about the latest, um, iOS bug where you could, like, deny of service a device, and actually some brilliant people sent very extensively explained, um, IRC chat logs to full disclosure, um, claiming this might be exploitable, I thought I'd gonna comment on it. So, the recently discovered bug is, for those of you who don't have email, um, that there is a way with, like, um, ad form packets to fill the input queue. Now, the question was, is this exploitable? Well, my question is, uh, when you're stuck in a traffic jam, does that mean you control the traffic light? Um, you can describe the bug as something like you have people checking in in Alexis Park and you got, like, 75 people that go into the front counter, and then, um, you kind of, like, kill the person behind the counter, which still doesn't mean you get their money. So, to answer the question, no, it's not exploitable. But the good question would really be, what is the problem? The problem here is that iOS is interrupt and message driven. So, the processes themselves are responsible for draining the queues, which, obviously, those four processes didn't do. Um, and, well, most processes in iOS, for what I know, do their own protocol parsing. Means the IP header is actually parsed at a central place, but everything else is parsed each and every time in each and every process, whoever is responsible for it. That means if you got 100 types processes, um, 99 can do IP protocol parsing quite well, and one is totally fucked up. And all you have to do is find the one. So, that obviously, um, leads to the point, can we expect more of that? Um, I guess the simple and short answer is yes. Um, the bug is actually a design failure in my eyes. Um, iOS 12.3 is already out, and it's already deferred. And there are some specific protocols that are handled differently and have higher priorities and stuff. So, it's just a matter of time. Um... The effects of the bug were not as bad as we thought, because Cisco actually went to the background providers and told them up front, here, um, is something major coming, so please filter that. Um, and the bug actually was found, Cisco internally, so, um, they could do that, but what if the next bug is not? Well, at this point in time, here is the one, um, finding the bug. Um, he's the only one from the Cisco stat team. I'm glad he is here. He didn't get credit in the advisory, so I wanted to give him credit here. Okay, back to bugs that we found. Um, Cisco iOS 11 and X, um, 11X and below, there is the UDP Echo service. Now, NASA is telling you, um, since ages that the UDP Echo service is bad because someone can do ping-pong attacks on it. Um, on Cisco, the UDP Echo service is actually worse because they got a bug here that is, on first time, very small. You look at it, and, um, you send the UDP Echo request packet, and in the UDP length, you actually say it's longer than you actually, um, include the data of, so you have one single character in the packet, but you say the packet was 100 bytes long. You get a 100 bytes answer. Now, we tried and tried to look at how much data we actually can get back, and it ended up being something about 19K with one packet. So that could be quite useful because that is I.O. memory. I.O. memory is used on Cisco for handling all the crap that, um, has something to do with the packets themselves and some limited routing information. So, um, we actually got comparable bugs in 12.x, um, like the Cisco Express forwarding. That's a certain way of, um, yeah, getting packets from A to B that Cisco uses. I think it's now the standard setting. Um, this one had a comparable bug where the IP length was the trigger. So there is more of it. But back to the UDP Echo service. What can we do with it? Oh, now here's something, um, because people started complaining about, um, finding bugs in 11 is useless because nobody uses 11. This is a founder, uh, this is a router actually, um, alive in the Internet. Um, he found it. It runs I.O.S. 9. Well, this one is not even available on the Cisco FTP service anymore. So people do update their routers once in a time. Okay, the UDP Echo, um, info leak bug actually is quite useful because we can do reliable I.O.S. fingerprinting. In the past we got the problem, um, that you got like 22,000 different I.O.S. images, um, sitting on Cisco. And, well, you don't know what the router you're targeting is running. Now you can because it contains block headers which contain addresses who allocated the block. Um, you got addresses of the allocating image, uh, allocating function, um, which change per image so you know which image it is. And you got address ranges for I.O.S. memory and heap memory, and those change by platform. So you can fingerprint it. This is what you actually get back. Um, you see you have the allocation stuff, um, and the pointers we talked about last year. They're all platform specific, but you also got the ring buffer information and the actual packets in the device. So question is, can we? Um, and yes, we can. There is, of course, the possibility of draining the router of memory leakage and actually get 19K per packet back and parse that correctly. So we came up with FinaLit I.O. Sniff, which is remote I.O.S. sniffing. You don't need any account. You just need UDP echo. What it does is actually pulling down the information, um, parsing the memory block, um, identify them, identify the packet offset, do the packet decoding and present you with a nice TCP dump-like output. So, um, this being the receive buffers, it's quite useful because, well, the router receives certain information, especially when people log in. Um, so what you see here are the first two lines or three lines of, um, stuff that actually is sent to the router when someone is telnetting to it. Well, the first lines he's probably sending are the passwords. So that's quite useful. But there is another bug. Um, Cisco has an HTTP service. And as I said earlier, if you've got an embedded system and it got a TCP port 80 open, it is vulnerable. Well, Cisco is no exception. Um, the HTTP server on 11.x and, um, 12, up to 12.2, um, has an integer overflow. It unfortunately requires you to send two gigabytes of data. Um, but, well, I actually did a survey on people and said, is this bullshit, or should we actually, um, go ahead and see if we can exploit it? And most said, yeah, I don't care. If I wait a week and I got root on a device, that's fine. And since that is the stack-based overflow, um, and it might be quite interesting to do because last year we did heap overflows, we did it. So, exploitation issues in the past for those who missed last year, um, we need server-based, uh, image-dependent information like previous pointers, size, volume, I.O. memory, stack location, location of the own code, um, which probably means, uh, you should already have a console connection to the router you're trying to hack. And this isn't really practical. So, um, things change. What we got now is the UDP echo memory leak. Um, we see Attica provide the data, which is the UDP stuff you send there in the first place. Um, we have live I.O.S. memory addresses, the leaked memory block headers, if you remember. And we have the ability to fill multiple memory locations because it's a ring buffer. So we just send it multiple times. And we got the HTTP overflow, which is a direct frame pointer overwrite and return address overwrite, so it's straightforward to exploit. So what we, what we can do is, um, we actually send full-blank full binary shell code there, um, via the UDP echo block. On the response, we see where it ended up, and we can calculate the exact address it is. We also have no limitations on byte because UDP echo doesn't care what it got in a payload. Um, we need actually to, um, select a good address from those in the ring buffers because if the router is not sitting in a phenolate lapse, it has probably something else to do, namely, uh, forwarding packets. So it's using the ring buffers actually to do the job, and, uh, we need to find a way to actually have a stable, um, address where the shell code survived and is not overwritten by other IP packets. But, well, if we figure that out, we own the box. So, combined, we actually send the maximum URL length allowed by iOS. Um, then we send two gigabytes of additional URL elements. Which has a nice side effect because it keeps counting and counting, um, the number of bytes received and compares it to the size of the buffer. Now, after you send two gigabytes of data, this being a signed integer, the number of bytes received variable will be negative. And this is smaller than the size of the buffer, so they can still copy it. Which means they're overflowing the buffer. Then, after sending all the crap over there, uh, we perform a UDP memory leak several times so we get all the code addresses, make an intelligent decision on which address to use, well, and complete the overflow. For those of you who prefer, like, all in color, here it is, um, HTTP connect legalize URL, um, send lots of As, do the UDP echo, get the info back, repeat until happy, send the overflow, own the box. End of slide. A problem we got here is, of course, um, the binary via HTTP. Um, we're overriding the return address, so, um, HTTP doesn't really like characters, like line feeds, character turns, slashes, zero bytes are obviously bad, um, but we found out that the HTTP encoding, you know, the percent XYZ and stuff that everyone, like, uses to screw up in their web servers, um, is actually performed on the same buffer before the overflowed function returns. So we can actually do, um, overflow and use the HTTP encoding so we can use arbitrary addresses, which made it even easier. I said we need an intelligent address selection, um, so what we are doing is, um, there are several strategies that are listed here. I'm running out of time, so I'll skip over and just tell you, use the second smallest address or the third smallest address is the best way to do. You will see it in the code. Now shellcode. Um, we had shellcode in the past that overwrote the complete configuration, which unfortunately means you lose all the juicy info, um, like the passwords they use, and they're never, never going to use on any other router in their network. Um, and the routing information, um, information access lists, all the stuff you could be interested in, um, so we figured we need new shellcode, and for that we actually did binary research on iOS. Um, iOS, uh, Cisco actually supports serial debugging via GDP, but it sucks. Um, but they also got some debugging capability in the ROM monitor, um, which is comparable to what you have in your PC as a BIOS. And so you can set breakpoints and do disassembly. The cool thing here is, um, code identification of the critical, um, part of the huge chunk of code you got is quite simple because the string that is, um, shown in a function is actually stored right next to the function in the text segment. Um, and that's before the function. So all you do is turn on every possible debugging you can give and, um, do whatever you wanted to find out and then look for the strings, find them in the code, disassemble the function, after that, and you got the function using those strings. So equipped with this knowledge, um, we actually figured out we need new shell code, call it next generation code, whatever. Um, what we do is runtime iOS patching. We actually teach the Cisco device to forget about certain functions it performed before, namely password validation. So, um, with the new shell code you turn it to the device and it stops doing the annoying user error authentication, give me the password stuff. It just drops you on the user shell. And, of course, um, the same is possible for the enable password. So, um, it will actually ask you for the enable password when you say enable but, um, it will not validate the results. Of course, you can do other stuff. Um, you could actually introduce something like forgetting about to check if the BGP neighbor I'm talking to is really the one I'm supposed to talk to. So, um, if you have pure imagination, the problem here is, um, we have to keep iOS running. Well, the overflow actually destroys a lot of stuff on the heap because of the, um, encoding we use. Um, we send 24 bytes and they end up being 8 bytes, but we destroyed a lot. Um, but the Motorola call structure actually saves frame pointer and stack pointer pretty comparable to, um, the Intel ones. And so all you need to do is search the stack of words for, um, information that was set there by a function preamble and use this information and do a clean return and better, like, clear the return, um, information so it will actually return faults and nobody cares. This is the code. Um, I guess nobody can read it there. Um, it just finds the return and cleans. Um, yeah, you can check it out on the slides later. iOS runtime patching advantage. Um, of course, the router stays online. It doesn't reboot anymore. Deconfiguration is preserved, so if you're interested in stuff like the passwords that are so heavily encrypted with the password 7 algorithm, um, and of course, um, it proves that what people talked about for years and years back during iOS runtime code is actually possible and quite easy. Disadvantages, of course, it's depending on the image, so we got the image dependence again. Um, you need, therefore, a lot of data in the large target list and, well, you actually got annoying messages on a console saying checksum error because it does checksum the text segment and, um, figures out that there is a problem. But, of course, um, we patched that out as well. So this is what the exploit is. Um, Cisco Kazim asked, um, reliable iOS remote exploitation. That's just a summary. Um, and this is how it looks like. Quite easy. She's bad. Okay, here is something, um, lots of people for the last years were complaining that all the presentations held on BlackHat are actually, um, held the same way on DEF CON and there is no value add. So here's our value add to DEF CON. Um, what about image independent shellcode? We can actually, um, instead of modifying the image, we can actually modify the configuration. Now, the configuration is portable over images and versions. So all we need to do is have a shellcode that does string search, um, memcopy, and checksums. Well, we can do that. Config modification code. Um, we start searching at the beginning of the NVRAM. Um, we look for occurrences of, um, like interesting data. Um, let's say password and enable. Um, we replace it with our information. Um, and here, right, replace authentication information for the listed services. We then just need to recalculate the checksum, um, for the NVRAM and write it back. And this is how that looks like. You know, IOS also has the advantage, um, of ignoring lines with bullshit. So, um, we can actually replace the stuff and, um, introduce a line feed. The rest of the encrypted strings ends up being bullshit. IOS ignores it. That's fine. Advantages here. It's image independent. Um, the configuration is pretty much preserved except for the passwords. But, of course, we can change the shellcode and copy the passwords elsewhere. Um, and we have actually more choices of what to do. We can have shellcodes just renaming every router to, like, piece of crap. Um, disadvantage, of course, it's still, um, platform dependent. But, well, we cannot change that except for, um, if one of the guys that sees this challenge comes up with a, um, cross-platform shellcode for Motorola and MIPS. Um, and the router has to reboot. So we got a little downtime. So what? What's the whole thing about? Well, didn't we mention last year that you shouldn't run unneeded services like UDP echo? Um, that you actually should protect your infrastructure and, um, that you actually should not copy data into buffers that are not large enough to hold them. So the problem here is iOS moves forward. Um, the new iOS versions actually got legal interception built in. Half a year ago I was, um, talking to Jaya, who did the, um, legal interception talk, and I said that would be quite interesting because um, then you can wear a t-shirt saying my other computer is your legal interception system. Well, um, this seems to become true slowly. Well, and if your infrastructure is owned, um, you can't defend your systems, of course. One, okay. Um, and one thing I wanted to mention is that there are more people than we, um, researching iOS exploitation. As a birthday gift, I got Body of Secrets, James Bamford. It actually has a whole page on the fact that, um, the NSA is actively trying to find hacks for iOS so they can take over Cisco routers. I just wanted to mention that here. Um, so, you actually got some very excellent, um, experience on DEF CON. We just have to identify the people. So, the defense part. Of course, mobile phones, that's easy. Turn the crap off. Do not do Bluetooth or have no, um, infrared enabled when you're sitting in the airport. Do not run any Java code just because it says it's gonna show you titties. Um, when you receive files, delete them right away. Um, think of your mobile phone as a crappy version of Outlook. And, well, if you got a chance, um, keep your phone firmware up to date. Some vendors actually, um, allow you to do that. For others, you have to arrest, um, the people at the shop. And, if you're, anyone is with a company doing that, um, don't do GPRS VPNs. Defense Cisco, um, well, in some memory, do not trust devices just because they're in a black box. It doesn't mean they're more secure. It mostly means they're less secure. Um, keep your iOS up to date. If possible, actually block every direct communication to your routers. There is no legitimate use to someone else in the internet talk directly to your router. So, if you had done that in the first place, even the, um, queue filling bug wouldn't even affect you. And, of course, um, to do that, you should prefer out of management. Um, so the one talking to your router is actually coming in on a different interface. And, well, you should include your router in the IDS watchlist. Well, I was racing through it, and I guess I made it on time. Um, thanks a lot for being here. And, well, I will be at the pool, um, for questions. Um, I know that most people don't see the lower part of the screen, but this is something they just got in Germany out with the advertisements, and I thought, we're gonna change that a bit. And, thanks very much.