All right now, wasn't that fun? So, yeah, I had to do that, got forced to do that. Good morning, everyone. I'm FX, this is FTR, and we're from Phenolite, nobody can pronounce that. And we're talking about attacking network-embedded systems, all kinds of, actually. Yeah, what are we going to do? It's like today's session over here. I can't see my screen, so I have to look over there all the time. We're talking about design failures. Actually, FTR is going to cover some neat shit you can do with printers. Basically, complimentary to Little Wolf's talk yesterday. And we, of course, released some tools, so you guys have some fun. And, yeah, after that, we talk about software vulnerability. And embedded systems, get some examples out, and then run a tutorial on how to root a Cisco. So, I pass on to FTR. Thanks for that. Okay, first, we have to define somehow what, for us, an embedded system is. And for the purpose of this speech, we think about an embedded system just as a small computer device running its custom OS. Which is used for one particular job. And, yeah, it's actually something small. It doesn't need a keyboard or a screen or something like that. And it's more fun if it has some kind of network connection, so that we can play with it and we'll have some fun. What are the most common problems with embedded systems? Obviously, since nobody is thinking about attacking them, the operating system itself covers... ...lots of undocumented functionality, which is still hidden, and therefore, normally, developers leave back some backdoors from the beginning of the development. And you can still access these functionalities, and so you can play with the system and have some more fun. And there are lots of different other features, like auto-do-something functions, which basically means you get a system out of the box and start it, and it's getting, from somewhere, a configuration. And therefore, some kind of... ...communication required, and sometimes, you can break into these protocols and have some fun with it. Finally, the biggest problem for the developers of these kinds of systems is that marketing comes up with a cool new feature that's required on a marketplace. Everything is fine, we're going to need this, and they enforce the developers to bring it out, and bring it up and running, and they develop it. And the time frame is really short and really limited, and so nobody is able to spend a solid security on how the new feature impacts the original design. And that's why we're going to need this embedded system. Okay, let's have some examples. Our first example will be the Lucent Brick. Lucent Brick actually is a really cool, really... ...handy layer 2 firewall, which is certified from the NSA, and seems to be secure, but it somehow has some problems with the ARP functionality. And the... What was the beam over there? Oh, it's the ARP. The ARP functionality in there has some really, really, really important problems, like at first, the biggest problem is that all ARP traffic will be forwarded to any... I hate that. Oh, thanks. All ARP traffic from a brick, through a brick, is forwarded to any... ...network segment this brick firewall is based on. And so, with the user knowing that ability, you can do an ARP sweep through the whole network, regardless what the firewall rule itself says. And that might be a big problem. Actually, a firewall is supposed to block traffic somehow, and if you use the blocking feature as firewall rules and it's still forwarding traffic, I mean, what's the use in that? The next problem in here is... ...is that you will be able to... ...poisoning the ARP table itself. If you just send an ARP reply at this normal C9 network, it will insert this entry into the ARP table and replace the existing one. And therefore, we have a cool example. The management server on top of the system... Thanks. ...is actually the heartbeat of the whole box. I mean, all configuration, all logging, everything is done on this and with this server. And therefore, it's really needful. And if you send in a spoofed ARP reply with the IP address of that server and another MAC address, the brick firewall will insert this one into its own ARP table. And will replace the ARP to the MAC address from the management server. And you guess what? The solution, the result of this is... ...yeah, the management server goes away and is no longer available. And what that means for us is... ...actually, no logging, no more management. I mean, then that's when the fun begins. Okay? I mean, this is one point. And it becomes harder since the whole ARP functionality is not stateful as it is supposed to be. You can send in tons of ARP replies. They never ask it for and it will fill out the ARP table. That means normally it's not a problem since the ARP cache is supposed to time out. But loose and brick firewall doesn't even let the ARP cache time out. So far you just fill up the ARP table till all the memory is exhausted and the machine crashes. And I think that's something different than I would expect from an NSA certified device. That's it. Maybe, maybe the NSA wants to have it that way. Who knows? The next example we have over here is from Ascend routers. The Ascend routers themselves uses an undocumented discovery protocol. Which is sent to the discard port. And normally you would expect that the discard port discards the packet while that's what it's used for. But no, we adapt this time and we do something different. Lost the idea by Ascend. And so when you send the right packet to this port you will get a new packet with lots of nice informations on it. These informations contain the IP addresses, the MAC addresses, the names, even what kind of devices you will find on the machine. Like T1 interface or something like that. I mean that's one thing. You can gather some information. But if you use that packet and change the values and send it right back and use the SNMP write community. Which is by guideline write. You can change these values. And obviously you don't want that someone is changing the IP address of your T1 interface. Okay. The next point. HP printers. HP printers. They are quite handy and useful for printing. And to configure these machines you can have several ways of accessing these machines. Like HTTP, Telenet, FTP, whatever. The most important ones are the HTTP port and the PJL port. Which allows you different information gathered from the machine. HP thought about security in some way. And introduced several ways of access this restriction. So it seems to be pretty cool. But there is one little problem. You have someone who thought about security. And the other one thought about usability. They are sitting far away in HP. And they don't know each other until we come to one major problem. For example, with only the knowledge of the SNMP read community. You can gather with this SNMP variable the HTTP password for full access. And once you got this, the printer is more or less yours. Okay. Next up is HTTP printers. PJL. PJL. It's supposed to be the printer job language. And normally whenever you do something with a printer and you print something out, you use this PJL. This is quite cool. You send out your stuff in that there. And you have some environment variables you can use it for. How many copies you want to print. Yeah. Which paper tray you want to use. And all this information. This is quite easy. And quite handy. And you very often use it. The whole security on even PJL for the environment variables is based on one single password. Which is actually a number between 1 and 65,535. And easily you can remotely brute force this in within six hours. And I mean, what kind of security is this in here? Okay. Let's go on. This is the PJL. PJL. That's what I want to go to. PJL also allows you access to the file system of the printer itself. I mean, it's a cool idea that the new printers. PJL. It's nice. My fault. PJL. Anyway. Yeah. PJL itself gives you access to the printer. file system of the printer. And with that file system, you will find lots of needful things like the firmware of the printer, like the print jobs, everything that's going on in the printer that's actually based on that file system. Once you have access to it, you can manipulate it in the way you like it. For example, we have here, it should be coming now. This is actually the one printer of the file system. It's a file system as you know it normally from every other system. It's just file entries, files you can copy, you can download, you can do whatever you want. You can create software like everything you need is on that machine. In order to get the PGL interface much more handy for you guys, we developed two kinds of tools. The first tool we developed is a command line tool. With that command line tool, you can access the file system, even the environment variables and all that stuff. This is running from the same source through our Windows and our Linux. It's really cool. It's really handy. The screenshot you have seen earlier is actually out of this tool. And for all the guys who don't like any kind of command line tools and need something to click on, we created a really, really nice looking tool that's called HiJetter. Ok, this is the basic interface. I mean it's very complicated to use. You have to type in the IP address in the right port which is more or less always the same. And just connect to the printer and then you will have access to the environment variables, the file system or even the display. For example, right here, you have the file system. On the left-hand side you have your local system and on the right-hand side you have the system of the printer. Just to get sure that you know how to use this system. two, okay? And as you can see, there you have the web server staff, the firmware staff, and everything you want to get on. The second is just for setting environment variables. Then there's a third dialog for setting display message. One cool thing is we have done, and we really scared people with their following idea, just setting the environment variable for locking the printer panel, so that nobody can go on the printer and switch on ready or something like that, and change the display message as a failure to insert coin. People get scared of that. Oh, shit. Okay, now I have to hurry up a bit. Another new feature within HP printers is ChaiVM. ChaiVM is a Java virtual machine, which is... introduced by HP normally for printers, but ChaiVM also, and that's a statement quoted from HP, and the last sentence is the most interesting. These appliances are powered by HP Chai-embedded software. That basically means HP is not going to do this only to supply printers with ChaiVM, also other systems. And that's where it comes interesting, because ChaiVM allows you to insert new modules onto the system. And that's a very interesting system to run your own services on a printer. In order to do this, HP introduced one service that's called ThisIs.Loader. This is a nice and really, really cool security feature that all the new servers you want to introduce has to be signed by HP. But it wasn't that stale as it should be, so HP released a new loader, the Easy Loader. The Easy Loader is a signed Java packet, so that you can upload it to the printer, but if you get this one running, you don't need... to get your new Java packet just signed in some, or you can just upload any kind of stuff you want to do. That's the complicated way and the more easiest way. Both of these loaders are actually nothing else to... and do nothing else than transforming the CS config file, which is based in a file system. Once you have access to the file system, you change this file, load it in your app, and yep, you have uploaded your new service. I think I'm going to skip this one, because we are a bit in a hurry. Anyway, as far as we have played with Chaibeam, Chaibeam is very stable. We had real problems with the development environment. You can get the HP in the real world. Something that runs in a development environment not necessarily must run stable on the printer. And, yeah, therefore, very often to use the... there's an impure way to reset the printer, but it's not going to do that. You get the Chai stuff up and running without going on the machine. What you can do with Chaibeam... yeah. What you can do with Chaibeam, we have developed one port scanner, which is actually running on the printer and scanning from the printer the remote network, so that we might just kick this on, wait a while, come back and get results. And that's more than funny. I mean, I don't even have to be on site. I'm using a printer. The next thing is, we decided that we don't want to spend power circuits on all laptops. We decided to use the printer for that. And we implemented a Chai Cracker, which is used to just break cryptic passwords, and somehow... The summarization of that is, everything you get running with Java, that you get running on the printer, you can do with the printer. I mean, this is fun, isn't it? I mean, the printer is not anymore a printer. It's more, it's actually a full powered machine you can play with. This is actually a screenshot from the Crypt Cracker running on the printer. The last thing I want to describe here is that there are already lots of nice services with Chai in the wild available. The most interesting are two ones of them. The one is the Notifier Service. The Notifier Service enables you to get a notification when something nice is going on on the printer. Maybe your boss is printing something after six and you want to know what it is, you get an email and you know what it is. And the last service, quite cool, is the Email Service. You can configure your printer to pull a certain pop account somewhere in the wild world. And whenever you send the right formatted email to this pop account, the printer pulls it down and executes a command which is hidden in. What does that mean to us? We just jump on the network, pick up the printer. We implement that service and whatever you do with your firewall, I don't care. As long as you let POP3 going out of the network, I can play with your printer. I don't need to be on site anymore. That's it from my side currently. All the stuff we have done you will find on finality.hp. You can download it from there. You will find there the command line tools, some of the Chai services, and even the Hydra as well. Now I have to hand over to TC. FX. Anyway, different style, different area. He wants you to describe software vulnerabilities and have some fun with Cisco. Thanks, FDR. Hey, hey, hey, don't waste my time, okay? Software vulnerabilities. I mean, yeah. Just try to figure out how to spell our website and then put slash HP on it. Okay, software vulnerabilities. Well, embedded systems actually are just a bunch of codes. So, and the guys who code it are just a bunch of developers. So, they do the same faults like Windows and Unix coders do, which basically is like input validation. We all know that stuff. Format strings, especially in the logging code. It's real bad. Buffer overflows, well-known stuff. I mean, even some buffer overflows on embedded systems got published to bug trick. And yes, you can do crosshead scripting on it. Actually, the HP printers are one example. You just go in, enter some additional information. It will show up on the website. And of course, it's crosshead scriptable. So, yeah, most embedded HTTP daemons I played with died pretty quickly. Like within five minutes. I never saw a rock-stable HTTP daemon for embedded systems. So, yeah, summary, limited resources lead to the fact that the developers think, oh, well, I skipped that check, I skipped that check, and the user's going to be nice. Buffer overflows, we have like four, just for starters. ZDR routers, quite nice routers. Actually, Ellucian product, actually pretty good routers. And they have an HTTP daemon. You do a long get request, you crash the router. I mean, it's so plain simple. Brother network printer, same thing. But you don't actually have to do a long get request. You just go to the Brother printer, to the web page. It asks you for the administrator password. You put over 100 characters in, click submit, it dies. HP. They did a cool switch. Prokoff. Actually, that vulnerability is pretty neat, because normally with SNMP right, you would really badly abuse the switch. No, you don't do that. You just fill that variable over here with 85 characters, and it doesn't die. No, it dies next time the admin tries to access the printer switch. That's like awesome. And, of course, even like cigarette box sized devices. And for the non-smokers, this is how a cigarette box looks like. There's a print service hanging off printers. They actually have the same vulnerabilities. You go to the print server. It asks you for a password. Guess what you do? You put a bunch of As in. You click submit. It dies, and it takes the printer with it. That's actually how the device looks. I mean, it's innocent, isn't it? Yeah. Common misconceptions. Stuff I always hear about exploiting embedded systems, it's like, it's so hard. It's way harder than writing a hack for Windows. I mean, you really have to reverse engineer the full firmware to find out how it's going. And then you really need to know how the syscalls work and how the libraries all get in and all that. And basically the worst thing that can happen is the device crashes. You know what? And, yeah, for all the guys here just don't know what to do after DEF CON, and to prove that wrong and make sure embedded system vendors actually understand that they should care about security and get some good coders, we're going to do a kind of tutorial on how to write exploits for iOS. So, now we go to some heavy duty shit. Actually, yeah, the problem here is... If you do something to a Cisco router, it will crash. I mean, honestly. If it doesn't feel good, it will crash. They have a bunch of platforms, so we need something that is, like, widely used. And, of course, we can't go to, like, ios.sourceforge.net and check out how it works. Actually, this is from the Cisco TFTP advisory saying that the worst thing that can happen is that the Cisco crashes. Let's see if that's true. Yeah. According to Cisco, the biggest problem are memory corruptions. Actually, 85% of all iOS bugs are memory corruptions. Now, if you put a bunch of A's somewhere in and it dies and it is a memory corruption, you can guess it is a heap exploit or at least a heap overflow. Let's see if we can explore that. So, to research the vulnerability, we actually found something with a TFTP server. Nobody uses it anyway, but we needed some to research it. It's just a lame bug. I mean, you send a TFTP request with a long file name, it crashes. Good. Actually, someone said yesterday to me that this was already published two years ago. So, if that's the case, I'm sorry. Okay. Taking it apart. Then, if we get, like, a crash dump on the console, that's basically one part of it. That's how it looks. So, without doing all that IDE stuff on the iOS image, we just do a correlation between the crash dump, this kind of info, core dumps, all kinds of stuff. And what we find out is this. Look, we have a block magic. This is like, okay, I start here. Common sense. The next thing is probably the process ID. I can't think of anything else that needs a 2 in here. Then, we have a memory block that is later. In memory, like, higher up. And also starts with the block magic. So, it's probably the next block. And if something points lower in memory, it might be the previous block. And, yeah, finally, we have the size over there with a quite funny, most significant bit, which we found out is used for, is that block in use or not? So, again, going to Cisco's website. They're all verbose about it. We check which memory address it is. Which addresses are used. Just to make sense of it, we check, oh, here, these are the models we have in the lab. So, and, of course, we are most interested in the NVRAM because it stores the config. So, putting it together, that's basically how it looks. Oh, great, you don't even see the errors. Yeah, let's do some laser pointer magic here. We have the magic block. We have the PID. We have some addresses. I mean, that's like serious overhead. We have the next pointer, previous pointer. Then we have size and usage. Then we have some field that's mostly one. I don't really care about it, but it's called RFCNT. For me, that sounds like reference count. And then we have a red zone that's basically a canary and makes sure that iOS catches it when it overflows the buffer. So, okay. What we plan to do here is we have that host block with our legitimate address. That's our legitimate data. That's basically where we're sitting in. That's why we call it the host block. And what we try to do is we overflow it, and the next block after that also has a header. So, we try to overflow it the way that we can influence that header here as intelligent as possible and hope that iOS makes some use of it and abuses itself. That's basically how it's planned to work. So, what happens if iOS frees the memory block we just overwrote? Basically, they have a double linked list. It's pointing back and forward. I mean, everyone who knows how that goes, it's just two pointers always pointing to the next and the previous block. And when it frees that, it will try to take out this block off the linked list, which is basically, yeah, that's the way it looks. It's a common pointer exchange operation, and that's what we looked for. Oh, I'm actually burning the table here. Cool. FTR, could you, like, take care of that fire stuff over here? Thank you. So, yeah, that's what we were looking for. And, yeah, let's see if we can exploit that a bit. But first, we have to find out what iOS actually needs of that. And it's quite funny. Because if you look... That's red, that's red, that's red. So, what is the other stuff for? I mean, you usually have to buy new memory if you put a new iOS image on the router. Now you know why. Okay, so we have that magic block. Of course, that's checked. The PID and these RAM addresses here are not checked at all. I don't actually know what they're used for. Funny, the next pointer is not checked. But the previous pointer has to be 100% correct. And the size field shouldn't contain any bullshit. And, of course, the red zone is checked so it finds out if it shit all over itself. But, you know what? Did you notice something? From here to here, we know everything. Or we can put in bogus values and it will not care. But one of the two pointers is used in a pointer operation. Let's take a Cisco. We overflow it over here. Put some stuff that's like the red zone from the last block. That's the magic beginning. We put some stuff in here. It doesn't really matter. Put the NVRAM address over here. And on a 2500, the free, this pointer exchange operation will then write this previous pointer right into the NVRAM. The fun part is what happens if this happens. The device notices, oh, fuck. I fucked up my memory. It's all toast. So safest thing to do, reboot. We got all used to that. But it comes up and says, oops, config checks on wrong. So what am I going to do? Either I sit here and be a useless piece of shit or I go out on the network and ask for a config. Well. So. What we do, obviously, we send that stuff over here. Device shits all over itself. Asks for a config. And, of course, we're the nice guys. You know. It's so hilarious. You don't need any special knowledge about it. That part, okay, here comes the review. Disadvantages, it only works on a 2500. So that sucks. And the attacker has to be on the same subnet or own the TFTP server. That also sucks. But the good part is you don't need to know shit. I mean, really. You just send it over and provide the new config. But let's see if it can get some more devices. In order to do that, we have to get around this annoying previous pointer check. It took us really a while to figure that out. But that's basically for the guys who know C. That's basically how it looks like. Means the block we are sitting in, the host block, actually gets checked. And iOS checks. Is that still okay? And while checking the next pointer of the host block, it sees if the place where it points to points back to the place where it got the address from in the first place. Like I'm pointing to FTR and someone is going to check if FTR is pointing back to me. So, yeah. How do we get around that? Still have no stable solution for that. But a pretty okay one. We just overflow it once. Uncontrolled. Just a bunch of As in there. It reboots. And this puts the device in a fairly predictable state. Because after the reboot, you can pretty much tell how the memory looks like. So, that's basically how we get around the previous pointer issue. Now we have that size field. iOS doesn't like it if you put in the size field that you override. You put in something like huge numbers, all F. It will notice it. It will say, no, no, no, no, no. That's bullshit. I don't have so much memory. I could use it, but I don't have it. And you can't do like normal values because we are doing a string overflow here. So, it sucks. We can't just put no bytes in here. Funny. If we put seven and all F in here, it works. It's all happy about it. I assume some developer decided to use 32-bit fields on iOS, which is mostly 164-bit platform anyway. And do the calculation that way. And just by right-shifting, left-shifting, adding something, it all makes sense again. So, this is the size field we're using. But since the size field, okay, let's go back. That one has a seven over here, which means the most significant bit is not set. So, what we do, we take a look at free memory blocks because if the MSP is not set, iOS thinks it's free. So, we need to look at free memory blocks. Again, we take our crash dumps and our hex dumps and all that and figure the following out. After all the overhead we've already seen, we got similar overhead. Another magic value over here. Adding more padding. This is like eight bytes, just so you know where your memory goes. Some address and code space never used. A pointer and yet another pointer. And since they're only in free blocks, we decided to call them free next and free previous. They basically have the same purpose. They run yet another linked list. I honestly never want to get the full picture on iOS memory management. And this information is probably also used when the block is freed to get two free blocks together to one big block. It's all textbook free exploit. And, yeah, we asked for it. We got it. These two pointers are not checked. So, we can write any pointer to any address in the address space of iOS. Thanks. That's basically what we do. There is a pointer. Pointer exchange can take place here. And it's all complicated. Like, where the previous pointer points to, that gets the value that's in the next pointer. So, and vice versa, plus 20 bytes for some offset. Yeah, so, we have something to write into memory. But what do we do with that? I mean, we can write one pointer. That's pretty neat. But where do we write it to? There is, if you do, like, a showman proc alloc, there is a place that's called process array. It obviously is an array of addresses. And, funny, it's the same number of elements like the number of processes you're running. So, it might be that it has an entry for every process. Yeah. It actually is that. It points to a huge process record. They have, I don't know, it's several hundred bytes of information for a process to run. But the first thing in this process record actually points to yet another memory block, which is the stack. And the second one points inside that memory block. So, obviously, it's a stack pointer. Cool. So, let's take it over. We have, like, on the 1600 series, we tested that. And it's quite easy because the free operation actually can write into any one stack. Every process you want. So, you just pick one. Mostly you pick a process that's not running too often, but it's kicked off, like, once a minute. A good target, I figured, is load meter because it doesn't do anything useful anyway. So. Yeah. And if you look at the stack here, that's, like, the safe stack pointer. And that's the safe return address. So, everyone who ever wrote an exploit knows that we now have, like, 5,000 ways of exploiting that thing. By either overriding the return address straight ahead over here. Overriding the stack pointer. And providing our own stack with the new return address. Actually changing the little stack pointer in that process array entry. Or just replace the little process array entry and provide our own. So, yeah. We got. We used the first one because it's, like, the most obvious. So. Next question. Buffer. We need some buffer to store some code. And here's the bad news. If you overflow it. And it thinks this is free. And this one should be freed. It will actually erase the memory and override it by OD. Oh, dear. But actually since the block we overflew is a free memory block. Or, yeah, we made it a free memory block. We don't care what it was before. We can have our exploit code in there. So. Let's write some shellcode. We have an example based on a Cisco 1600. It has that funny Motorola processor. Which really got me because I never coded Motorola before. The memory protection according to Motorola's manual is set in some base register. We found that base register after some serious wading through hex dumps over here in that address. Luckily it has no zeros in it. Cool. You can like disable that by changing the, actually the second bit. Changing it from one like protected memory to zero as in unprotected memory. And, yeah, then write some invalid value into the NVRAM and get the device. Yeah. So that's what we do. See, that code is like not huge. I mean, that's the whole code. That's all you need. It's totally free. It's incredibly simple. It takes the address of that protection base register. Does a write shift on it. Because the next bit is actually zero. So it's nice to us. We tricked the address of the NVRAM in here. And, yeah, then write some coffee babe stuff in there. So we got that NVRAM invalidated quite easily. What we actually did here to show how to get around pointer, is exchange things that work right in your shell code. This instruction over here, you see this 01010101. This is actually where the other pointer, it's an exchange. So, yeah, give and take. As in you buy beer, I buy beer. So that's where the other pointer is stored. You just put some innocent opcode in here. Get the data part overwritten. All set. Yeah. Summary. If you overflow once to get the predictable previous pointer, set all the stuff here. Fire it up. And you have the same reaction. Like it asks for a config. And that's how it looks like. I took out the legal ally here. Yeah. It has some error later on. I don't care. Comes up. Asks for the config. Asks for another config. Yeah. That's Cisco. And then you've got the device. But, you know, it still sucks. You still have to be on the same segment. So let's go on. We need some more info here. Which is iOS seems to use some kind of cooperative multitasking. But honestly, it more looks like a huge program that has tons of interrupt handlers to fire off important stuff. So it's not really tasked. I didn't find any task handler on it. There is no scheduling service or anything I'm aware of. Maybe one of you guys worked with Cisco and can tell me something. I don't know. But it's all interrupt driven. So that really sucks. The MVRAM actually contains a bit more than just the config. It has a checksum. It has a field for the size of the config. It actually contains the stack traces and all the stuff that you would normally use to do forensics on the router. So what's that? Yeah. So the config is actually like a long C string. It's just a string with some line feeds in it. You can do some funny shit with that. Anyone who gets bored with your Cisco, just play with the configs and long lines. I don't have to tell you more. And it's terminated by the end keyword and the normal zero byte. So it's basically a long C string. So what we do is write a remote share code. That one will have a minimum config in a backpack. Disable interrupts so we don't get interrupted. Unprotects MVRAM. Calculates the new checksum so iOS is all happy. Writes it to the MVRAM. And just to be nice, does a clean reset. Well, you don't need any Cisco. You don't need any knowledge about iOS. And the neat thing is it will run always. Always. Because you don't use iOS. You just kick it off. We still have that problem with the zero byte. Still, string overflow, no zero bytes. Everyone knows that. Yeah. But that's like solved ages ago. And we did it the same way. You have the self modifying code that first sits there, has no zero bytes. Bootstrap code decodes the rest of it. Uses a different pattern. Like D5 instead of 55. Because 55 would lead to colognes in the XOR config. And colognes are real bad in that particular overflow because they're used as delimiter between like file system name and file name. So that screws the overflow. Took me about three days to find that out. Yeah. Gets decoded. Gets executed. Plainly works. Then we had another problem which was really nice. The code worked. You're all happy. It comes up. It says, no, config fucked up. You check the config. You find out it wrote like every sixth byte. And it's a plain loop. I mean, it really writes every byte. And you try it again and it writes every other sixth byte. Hey. That's because the NVRAM chips are so fucking lame and slow. Like by design. And according to the manual, you're supposed to keep the address lines straight. So don't do any instructions on like A1 to A9. And pull the status register of that NVRAM thing. I don't know where that is. Honestly, in that huge memory area, I don't know where that is. So we just took some loops after every write. We loop a bit. Make the Cisco all happy and sweaty. And yeah. So we got around that problem. And that's what you can download. We call it Ultima Ratio. Go figure what that means. The code isn't actually that big. It has like the overflow. The fake block. This bootstrap code to decode all the other stuff. Export code to actually write a config. Has the config in the backpack. So what you do is you have your command line utility that takes the IP address. The previous pointer, which we still need, unfortunately. And you have this. And you have the config as like a file on your file system. Fired up. Got root on a Cisco. Yep. That's how it looks like. You see no crash info. No blah, blah, blah. I'm not feeling happy. Just boot straight. Legal lala. Figures out of the sudden. Oops. There's a new interface. Yeah, because the config we uploaded didn't say anything about Bree 0. So it just figured, oh, I'm a 1600. I'm all surprised about having a Bree interface. Yeah, then you just turn it to your router. And, well, it's your config. And it's your password. That's basically how it looks like in detail. I'm not expecting that everyone is going to get that right away. But, I mean, the presentation is on a CD. It's, again, the red block. Magic, PID, stuff, stuff. Next pointer, previous pointer, don't really matter. That size field, that funny size field. This ref field over here. Padding. Free magic. More padding. Actually, total crap over here. Yeah. More padding. Next pointer. Previous pointer. This one is pointing to the code. This one is pointing to the stack. And here we go. And that's how the XOR code is. That's what we use. I mean, if some guys here really know Motorola coding, you might come up with something more decent than that. But it's not too big. And you don't need any knowledge about iOS. I'm still putting the big M faces on that one. Yeah. Word to do. I mean, this is not like TESO SSH. This doesn't really, really work well if you don't have access, like, to the Syslog host or in the lab you do it with the console on and stuff. You don't, like, download it, fire it off, and turn off. That's not going to work. But I hope we showed that it works. And I hope that these heat exploits actually were basically a wake-up call. But anyway. So what do we have to do? We have to find differences. If someone has a bug for 12.2 iOS, just come over, tell me. I'll buy you a bunch of beers for it. We have the problem of smaller buffers. I mean, that buffer is just huge. It's 1,400 bytes, like, full UDP packet. We have to figure out how that works. Basically, my idea is to send in the shellcode via CDP. We have that previous pointer stack and stack addresses. That's still a problem, but bear with us. We will come back to you and have a solution for that one. And in VRAM config, we need some different shellcode, but that's, like, the easy part on it. We have to write to Flash instead of in VRAM to, like, take over GSRs. We need some anti-forensics shellcode, but actually after I had some people telling me how they do forensics on the Cisco, I decided that's not going to be needed because nobody actually looks at the in VRAM when doing forensics on Cisco. But it would be neat to have a shellcode that really does the same as ours, but additionally deletes all traces from your exploitation and stuff like that. And, you know, so the forensics guys are all happy about it. And, of course, real-time configuration modification code is, like, the next thing I'm going to do is a shellcode that goes over, removes all access list bindings, sets the passwords to something you might know, and reboots the device so you don't have to figure out which interfaces it has and stuff like that. Come on. Yeah. Summary. For the 1000, it's local export, like just invalidating in VRAM, or remote exploit. It's even simpler here. You can actually write your return address right into the exception handler for memory problems. That's pretty neat because as soon as it figures out that it screwed up the memory, it will screw up even more. The 1600, 2600, basically same issue. Fun part on the 2600, if you want to test that TFTP stuff, you have to be a bit more tricky because you have to fire up TFTP first with a valid request so the TFTP service gets loaded. I was looking for the process entry of the TFTP service for, like, ages before I figured out you have to fire it up once so it actually gets activated. But basically it's the same. The 2600 has a PowerPC processor, so you're not going to use this shellcode, but the concept is still the same. And 2500, so far we can't do remote exploits on it. That's going to change. And, yeah, it's like the loser Cisco. It's, yeah, the script kitty Cisco die thing. So what? For everyone who didn't get it yet, this is how you do exploits on 85% of bugs in iOS. So I hope someone is going to get a phone and call Cisco and tell them to fix this shit. You can do it, like, protocol-based. You can do it debug-based. You can actually do all kinds of stuff. And, I mean, who actually expects you to take over a Cisco? So it's still unprotected. I mean, really. And as I said, then VRAM still contains stuff. For the local exploitation, actually, it still contains the former config. So after you got it, you just turn it to it, get the former config down, which is a neat way to get around this no-service password recovery. You just exploit it. You get the config down. You get the passwords. You get, like, tunnel keys, IP addresses, net settings, all kinds of stuff. How to protect. I guess some of you have that question in mind right now. Basically, in general, do not rely on one type of device. If all your protection and frontline protection and firewall and IDS systems say Cisco on it, you're screwed. If it all says Checkpoint on it, you're screwed, too. So mix the two. Or better, get some different technology in there. Consider all your network equipment vulnerable and exploitable to the full extent. Someone is going to be sick enough, that's probably us, to write a check for it. Believe me. No, it is small. It is simple. It doesn't even have an LED on it or something. That doesn't mean that nobody's going to exploit it. They will. Believe me. If not, I make them do it. For the HPs, basically, use the features it has, even if they suck. Assign an admin password. Change SNMP read and write community. Do the PGA protection. Yeah, it gives you some time. Make sure, I mean, if you have a print server, the printer should only be accessed from the print server. Really. Because nobody is going to print directly to a printer if you print to the print server. Like you have that loser Windows network thing. The only server that has to talk to the printer is the print server. Get rid of this .loader. Actually use one of our elite tools to get rid of it. And consider putting your printer behind firewalls if it is really critical. Or really, if it is finance department or something, use common sense. I mean, the PCs have LPT ports for some reason. Just connect it to the PC. Actually, one thing I wanted to mention for this one. Be sure that your firewall does not allow outgoing connections from your printer to the internet. Because in the csconfig file here, you can actually put the location of the code. Not in, like, file system. Like, O, colon, backslash, mycode.class. But you can say, like, http://my.evil.server. Slash. My super evil dot class. Yeah, for the CISCOs, basically router hardening, textbook stuff. Other than that, yeah, try to convince people to have no overflows in iOS. Then it's all no issue. Keep your iOS up to date. I know it sucks, but they really just fix the stuff on the 12 series. Mostly just 12.2. Yeah. Find out which software version is fixed. Which is kinda hard sometimes. But try to find it out. Tell your IDS about it. That's basically the signature. If you really paid attention, you will see that this is like the red zone from the block we're coming from. This is the magic. There is an undocumented, thank you, debug command. That is debug sanity. It doesn't debug anything. It just makes iOS check it more often. The memory. It doesn't help. You can still exploit it, but it gets it faster. So, if some loser tries it, you will get him. The hardware. Config register. Zero. Next time the thing boots, it will sit in Realm 1. If you do that, and you forget about it, and you say reload, you have to get in your car. Yeah, and of course, logging should be not like all visible. Yeah. Yeah, your syslog host should actually be protected correctly so that people don't use your syslog host as an information base how to get the pointer straight to exploit your syscodes. That's basically it. Thanks a lot, and I hope you enjoyed it. And, yeah. I hope to see you guys around. Thanks, guys. See you guys.