Alright. Alright, so we finally made it. I want to give a big thanks to my mate Alex who flew over from Europe. He road-tripped the ATMs with me in an Escalade from San Jose to here. The whole time I'm thinking, please don't get pulled over, please don't get pulled over. Two ATMs in the back of an Escalade and about 6,000 notes of novelty currency. What are you boys up to, mate? We made it, we got into the casino, so we're all good. The attraction to target ATMs is fairly obvious. I mean, they're full of cash. But for myself, it's kind of part of a bigger picture and a bigger plan. And that's to explore systems that, when compromised, have direct and immediate consequences. You know, society relies on various proprietary systems, whether they be ATM machines, medical devices, smart meters, parking meters, or the computer system in a vehicle. It's important to research these systems. Particularly, they're often not designed with a secure methodology. As a result of that research, we can use that knowledge to design better and safer products in the future. So, my goal. The goal of the talk is to spark discussion on the best ways to remediate and prevent the attacks that I'm going to be demonstrating. The goal definitely isn't to give a cookbook recipe on how to hack ATMs. I find the process of finding vulnerabilities a little bit more interesting anyway. The journey, not the destination. Although, the destination is pretty cool in this one. And I hope to change the way people look at devices that, from the outside, are seemingly impenetrable. So, current attacks. The skimmer, which is certainly a fan favorite. A small overlay that slides over the card slot and the pin pads. Manufactured to blend seamlessly with whatever particular ATM it's manufactured for. Designed to both capture the track data on the cards as well as the pin numbers. And, you know, technology in some of these is no joke. Data that gets transmitted over GPS. Some even have tamper protection. They wipe themselves and find out and send the remaining data back to the attacker. Physical theft and ram raids. You may have all seen those YouTube videos where a couple of good old boys hurl through the front window of a store, attach a chain to an ATM and the other end to their pickup truck and take off with it. Not the most subtle of attacks, but that's ninja status compared to some of the other ones. And we have card trapping and card snooping. Card trapping where someone will insert a small shim, commonly known as a Lebanese loop, into a slot, traps the card, and they're designed in such a way that when the card's read, it'll be read but won't be returned to you. Often combined with shoulder surfing to get your pin, or they'll get your pin in ways that may not be quite as friendly. Then safe-cutting and frontal attacks, basically going at the ATM with a pair of pliers and a blowtorch. Explosives, which is surprisingly popular, which I find a bit odd. The attacker's literally tying a bunch of explosives to an ATM and blowing the crap out of it. Now, you'd think blowing up an ATM would be somewhat counterproductive, but this is bigger than Australia, so go figure. Sorry, Australians. And data breaches. Hacking the backend, so hacking the bank processor, harvesting the card data. An example of this would have been the compromise of the Royal Bank of Scotland's Wellpay backend. Certainly the safest and was the most technically sophisticated attack that I've seen. I think about 9 million was stolen during that attack. And then I guess we have miscellaneous. Other. So there would have been the default passcode attack from a couple of years back, where if the operator password was left unchanged on the machines, you could reprogram the ATM to think there was a lower denomination in the machine than there actually was. So you could probably think it's full of $5 notes, but it's really full of 20s. And I'll be adding some more to the other category. Practical attacks, which in my opinion blow John Connor's mind right out of order. So I've picked standalone ATMs, and there's a few reasons for that. First off, they're pretty easy to get a hold of. You jump online, and like anything on the internet, you just add to cart. Getting the ATMs delivered to your house, though, is actually quite interesting. I had the ATM delivery guy literally wheel in one of the ATMs. And he came in, he's like, why on earth do you need an ATM in your house for? And I was feeling a little bit cheeky at the time, so I just looked at him like, oh, I don't like the transaction fees, mate. And he just kind of shook his head and went on his way. But also, they're everywhere, you know, every bar, convenience store, market, and they're often in secluded areas, you know, they'll be out by the restroom, tucked away in corners. But I will be discussing attack methods for both stand-alones and hole-in-the-wall ATMs. I'll go over walk-up style attacks, but then I'll shift focus to a far more important vector, and that's remote attacks. And particularly what an attacker can leverage through a successful remote compromise. And when I say remote, I mean remote default, because that's the only way to roll, really. So just to get an idea of how popular these ATMs are, this is just one block on my street from a bit of a pub crawl. I must say my favorite is the guy who owns a Mexican restaurant here, holding his bottle of Tapatio over the top of the ATM. It doesn't exactly look chuffed to be there, though. So this is standard specs of a new model retail-style ATM. Generally Windows CE running an ARM processor. Our new models support both TCPIP and dial-up by default, optional wireless. When I say wireless, I mean CDMA, not 802.11. So no drive-by ATM attacks, unfortunately. Though it would be kind of cool to ride by and just have ATMs spit out cash. Although maybe the Grug could possibly do something with this. SSL support and a triple-desk encrypted PIN pad. So the PIN pad performs all the encryption within the device itself, has anti-tampering mechanisms, and I may talk a bit more about that beast a little later. So this is a typical ATM internals. A bit hard to see, but there's a receipt printer over to the right, a card reader, and there's a serial interface that leads down to the safe, which is wired to the dispenser. And there's various motherboard inputs, multiple USB, SD cards, the network connection, and some debugging ports. On this one, there's actually a cover in there that's protecting the circuit board. I simply just removed it for photo purposes, but I guarantee both of these ATMs are completely untouched and completely unmodified. Now, funnily enough, all the ways that an ATM could possibly be disrupted, it was actually almost my cat who took it down for me. I had a USB keyboard plugged in and he was chasing a moth or something, and he ripped out the USB port and then pulled out the processor plug-in at the same time, but luckily the only damage was the USB plug that was easily soldered back in. But anyway, bad kitty. So in my opinion, a presentation shouldn't really be a full-blown technical tutorial. So I'll be following up later with a white paper that goes into more technical details. But rather than digging deep into the ins and outs of C internals, I thought I'd sum up the security hurdles I faced with this quote. We were concerned about protection, but not about security. We weren't trying to design an airtight system like Windows NT. And this is from Thomas Fenwick, who was the creator of the Windows CE kernel. And this quote came from a book called Inside Windows CE, which is interviews with the core developers of CE. And it's an interesting read on the design approach that was taken, but essentially there were not many roadblocks. The technical information I think lends itself better to a white paper, which I'll be following up with. So before we can even think about giving that dude from Terminator 2 a run for his money and actually start devising attacks, the first step is to be able to interface with the ATM and gain access to the file system. So once we have access to the file system, we can then pull the executables and be able to do some reverse engineering. Now unfortunately, when the ATM boots, it boots directly to its own proprietary application, so there's no explorer shell. And we need a shell to be able to make things easier. Originally, I suppose naively, I thought I could just plug in a keyboard and alt-tab, but of course that wasn't to be the case. But to get a shell, we'll need to have explorer execute at boot time. So the CE application boot sequence is fairly straightforward. The kernel nkexe runs filesys.exe, filesys sets up the registry and file system, and then it executes the applications that are listed in the registry key, hklm, and that. So the trick is to patch the application we want, execute it into that boot list. So of course we want to get explorer into the boot list, and there's two approaches basically. The first approach assumes you have a copy of the CE ROM image. The registry file can then be extracted, modified, recompiled into the image. This requires a way to rewrite the flash, whether it be serial, ethernet, JTAG, or what have you. The other approach is to patch in explorer while you're debugging. And this of course requires some sort of debugging capability, JTAG, ethernet, serial, et cetera. So I decided to go with JTAG, because it's a fairly straightforward way to accomplish our goals. JTAG is a hardware debugging interface, which essentially gives you unrestricted debugging access to the processor core. Now the hardware to do this used to be pretty pricey, but these days with OpenOCD and some of the open source projects, you get the needed hardware for less than a hundred bucks. Now with JTAG access, you can remotely debug with GDB, debug the kernel, the boot loader, and so on. Now JTAG has been talked about to death, and I won't dwell on it. There's a lot of resources online with a lot more information. So here's just the hardware debugger connected to the motherboard. Now it's probably obvious, but the use of hardware debuggers and things of that nature have absolutely nothing to do with the ATM attacks that I'll be demonstrating. They're simply used to initially gain access so we can then go on to find real vulnerabilities. Speaking of JTAG, I actually learned a valuable lesson when I was messing with one of the ATMs. I had the JTAG hooked up and I was screwing around and I accidentally wiped out a massive chunk of the firmware and overwrote all the ATM files on it. Now at the time I couldn't get a hold of the software to reflash it because I wasn't an ATM distributor. So I actually had to call a licensed ATM technician to come around to my house. Now three guys arrive and of course they ask again, you know, why are these ATMs in your house? And I say, oh, I haven't moved them into my store yet and all this type of thing. But anyway, see, what happened? How did you remove all this? Oh, I had it on a card, I was trying to change a splash screen, it all just wiped out. He's like, yeah, no, they'll do that, they'll do that. You know, so he starts going to work on the ATM. I'm like, firmware, what is that, mate? Acting completely stupid. He ends up teaching me a hell of a lot about hacking ATMs. I got his business card, we kept in touch. Unfortunately, after this presentation, that relationship may be severed. Oh yeah, so the lesson is always back up the firmware first. So now that we can debug, we need a way to inject. With the debugger connected, simply set a breakpoint on create process. And the opposite was found by simply dumping the memory from the ATM and just doing a byte compare to an offline version of Core DLL. Now when working with the ARM processor, the parameters when they pass the function are passed in registers before they utilize the stack. So R0 will have the first parameter, which is the executable, what you want to execute. We simply replace that string with what would normally be the ATM executable and overwrite it with explorer.exe. Now if explorer doesn't exist on the image, then you can just put a copy of explorer on a removable drive and pass that full path to create process. And so then you get a shell on the ATM. When I first was playing around with the ATMs, I was quite excited just to have a little shell on them, so I had them playing movies and whatnot. But not really surprisingly, ATMs are pretty crap for playing movies. Slow frame rate and the 6-inch screen, so it will not be replacing the flat screen. So now with Explorer, we can plug in a USB drive and a keyboard and copy off the files for reverse engineering. Then we can modify the registry so Explorer will always boot. Now remote debugging with JTAG over GDB is not the ideal way to debug a Windows machine, so the next step is to set up a better debugging environment. And there's a way to debug Windows CE applications without having ActiveSync installed, and that's to debug with Visual Studio over Ethernet. So you simply build an empty project, overwrite the local executable with the executable from the device that you want to debug, set the correct TCP settings, copy the file over, run it under the debugger, and you have application debugging with Visual Studio. So now finally we have everything in place to be able to reverse engineer the software to locate vulnerabilities, but to also test any software that we create for the ATM. So planning an attack. There's a fairly limited attack surface really. We have the card reader, but assuming we have an overflow or some other string-based attack via the card tracks, there's a limited amount of characters and a very restricted character set. So I'm not going to say it's not possible, but I will say it would be unlikely to be practical or reliable. The keypad, another long shot, but maybe there's possible master passwords or backdoors left in by the developers. Then the network, so any open ports, an answering phone line, any options for a remote attack. And we also have the various inputs on the motherboard itself, but of course this requires access to the motherboard. So of course progress is never really made without a few failures along the way, and in my attempt to come up with a Terminator 2 SCAC, I made this little device. It's basically an electromagnet wired up to an amp which is connected to a media player, and you create a web file which is created to simulate the data on a magnetic stripe. The electromagnet, plug into the ATM, flick the switch, play the web file, and the ATM will think of magnetic stripes being read. Technically it works fine, but it was actually bugger all help. So the goal, of course, is to execute code on the ATM. So I'll talk about these walk-up attacks first. Now the cash dispenser is housed at the very least by a safe, if you take the cheapest option. If you spend a bit more, you can get even more heavy-duty protection. The motherboard, on the other hand, is protected by a one-key-fits-all lock. And this is actually standard practice across the boards, and these keys, like almost everything else on the internet, are easily available to add to cart. And, funnily enough, there used to be Diebold keys, last year when I was looking, but they've since vanished, but I'm sure with a little creativity they could be found. As you can see, most manufacturers take this approach. So, the walk-up attack. So now with your master key, you have access to the USB slots and what other inputs. So you can pop open the motherboard compartment, insert a USB key in a couple of seconds, a lot faster than installing a skimmer, right? Now, even though the attack time here is short, there's still the possibility of being detected. But, you know, I suppose that's a great thing about these retail and stand-alone type ATMs. They're out by the restrooms, they're out of sight, off by the SIGGY machine or something. And I suppose then there's that psychological aspect of using an ATM machine. It's kind of considered rude to look over someone's shoulder. Unless, of course, you're a criminal, and then he would probably learn a trick or two anyway. Now, all ATMs need a way to upgrade their firmware. And this is most often leveraged via their removable drives. So the ATM application checks the drive for a valid upgrade, the valid firmware is found, upgrades, install whatever we decide to add in there. Now, of course, the firmware is typically a proprietary format. There are checksums, encryption, and the algorithms are easily figured out by reversing the code on the ATM side. So once you can create your own firmware package that adheres to the correct format, well, then you can upgrade. But upgrade with a few modifications, of course. Now, the most important attack is the remote attack. Now, most, if not all, ATMs that run on a Windows-based OS support some form of remote monitoring or remote configuration. So this allows you to log into your ATM remotely, review or change the settings, get stats, change the splash screens, and so on. Another quite useful feature is the ability to remotely upgrade the software. Now, this is sometimes a feature, but always something you can leverage if you have a vulnerability. Now, obviously, authentication is required to be able to do anything useful. With the particular model I'll be demonstrating, both a serial number and a remote password are required, and they're both made up of a combination of numbers and letters, and a five-second delay is forced after each connection attempt. So a brute force is basically out of the question. So we require vulnerability within the authentication process, and it just so happens. So let me introduce Dillinger. Dillinger is my remote ATM attack or administration tool, whatever way you want to look at it. Dillinger named after the bank robber, of course. So we've talked about loading code on a local ATM machine with a master key and a flash drive and the correctly formed firmware, you're basically set. But the obvious drawback here is you have to interact with the machine itself. So the ultimate win would be able to execute code or load code remotely, and that's where Dillinger comes in. So Dillinger takes advantage of a fairly severe vulnerability in the ATM management capability. And interestingly, although most operators don't use the remote monitoring, it's enabled by default on this particular manufacturer, so shushing! Now, typically to log into the machine remotely we require the knowledge of the serial number and the password, but due to an awesome vulnerability, I can bypass all authentication on the device. And the remote attack is 100% reliable. So Dillinger supports TCP IP and it supports dial-up as well. And I heard through a fairly knowledgeable source that most of these stand-ups, stand-alones, about approximately 95% of them are still on a dial-up connection. Now, of course, back in the day, finding an ATM over the phone line would be a long process of nights and nights of wall dialing, but thanks to tools like H.G. Moore's Wallbox, you can map out modems on exchange in a matter of hours. Then write a custom tool to find the ATM responses and you're away. So, Dillinger features. So Dillinger will allow you to manage an unlimited amount of ATMs through its interface. You can add a group, say you add a city, under the city you add each individual ATM, either its IP address or its phone number. Now, the heart of the tool, of course, is the authentication bypass that it exploits. And this is the stepping stone to be able to do anything useful. So, one feature in Dillinger is to be able to test the bypass in a way which confirms the vulnerability but doesn't actually modify the remote ATM in any way or leave any trace. So, the obvious problem with finding a remote ATM is that you have no idea of the location. So, Dillinger can pull the ATM settings from the device which includes all the master passwords but it also includes the receipt data. And you know when you use an ATM at the bottom of the receipt, it always has the location or the name of the business. So, even if it doesn't have the exact location, it will have the name of the business. And, of course, the best feature is to upload my rootkit. Again, bypasses all authentication, initializes the software, uploads the rootkit, and then basically lets me overwrite the entire firmware of the device. So, in general, someone is going to need to be at the ATM if you want to get any sort of payout. So, again, I added a feature so it would be possible to carry out an attack without ever visiting the ATM at all. So, when someone inserts a card, the track data is captured and saved and I can then retrieve that track data remotely. And finally, the remote jackpot, which kind of speaks for itself. So, Scrooge is the ATM rootkit developed specifically for ATMs running on Windows CE. Scrooge implements the typical rootkit technology you'd expect. Hides itself and its friends by various CE system hooks. Hides itself from the process list. Hides itself from the file system by hooking syscalls and filtering the results. And there's a hidden pop-up menu which can be activated by both a special key sequence on the ATM or by inserting a card with custom track data. Now, it'll run on any ARM or XScale based ATM, Intel with a few tweaks. Originally, I was designing for both Intel and ARM, but it turns out that CE on x86 is actually pretty rare and basically non-existent in the ATM world. So, the code for interfacing the ATMs has to be customized for the different ATMs as they all use different peripherals and kind of non-standard ways of communicating. So, Scrooge's hidden menu. I just use a standard set windows hook filter to capture the side buttons on the ATM. Although set windows hook is actually undocumented in CE, it still exists and it works as expected. So, a combination of keys will trigger the hidden menu and it's varied enough not to be launched by accident, but maybe if there's a kid playing around with the ATM, he may end up scoring big, who knows. And the card reader is hooked by an inline detour style patch. So, this is where you essentially patch a branch instruction into a piece of code you'd like to intercept, the branch jumps to your code, your code executes, then returns the original function. Now, with the hook in place, there's a check on the read buffer for track data that matches gimme the loot, and if it matches, the menu is brought up in that way as well. So, the menu functions are fairly standard for what you'd expect. You can dispense from each cassette, print out stats, which include the remaining bill count, and you can exit. So, yeah, to add my own functionality, I've added a few inline patches. Essentially, you can patch a small assembler stub into the functions you want to hook. The stub then calls a function external DLL, overwrites any overwritten instructions, and then continues as normal. This could be done dynamically, but the fact that the ATM vulnerabilities allow me to replace the executables entirely, we can make these patches permanent, which is actually far more reliable. And it's also a lot easier on ARM, as every instruction is 32 bits long as well. So, I place hooks at the card reader, the pinpad, and the parser that handles remote configuration commands. So, with those hooks, I can now add my own handy features, so I can save the track data, capture the pinpad, have a few custom remote commands. So, pull the track data, sure. Remote jackpot, might as well. Alright. So, there's going to be quite a lot of demos, so I went through that a bit quick, because I think there's probably a good 25 or so minutes of demos. So, I might as well put my money where my mouth is, or the ATM's money where its mouth is, I guess. Okay, so this is Dillinger's interface. I can add a group, so we'll say blackhat. Add an ATM. Barnaby's ATM. Location, onstage at blackhat. And Dillinger supports both dial-up and TCPIP, so in this case, I'm using TCPIP of course. By the way, just to reiterate, this is by default remote functionalities enabled on all of these ATMs as they ship out. This one here at least, not the other one. Okay, so now I can right-click on my ATM, I can then test the bypass, upload the rootkit, reset to default, get the track settings, get ATM settings, etc. So, let's see, I'm trying to think if we should switch to the ATM. You know, not just yet, okay. So, I can test the bypass, connects to the ATM, testing ATM authentication bypass success, and it disconnects. Now, we'll actually blow up the ATMs in a sec, but all that shows on the ATMs is just RMS process. I have to wait till that goes away. So, it's nothing too noticeable, you know, if you're if you see this ATM. Actually, if someone close to the thing could let me know when it's gone? Okay. So, now, the most important feature, of course, is to upload the rootkit. So, we'll upload Scrooge, the final version, connects, sends a bypass successful, initiates upload, and it's uploading it to the ATM now. This is bypassing all authentication in the ATM, and by default. Now, even though it's over the network, it takes a little while, because they have their own proprietary protocol, which acknowledges each packet, and then has a small delay, and so on. Proprietary protocol, of course, has its own proprietary encryption, and you all know what happens when people implement proprietary encryption. It's fairly easy to make your own. Okay, so, when it finishes uploading, the ATM should reboot, and if we could flick to the ATM now, on the screen. Takes a little while, Windows CE, you know, it's not the fastest beast out there. Yeah, if we could just pan out just a bit, too. If we could get the screen and the dispenser. Yeah, that's cool. What's that? Oh, they'll be spitting money, don't worry about that. Okay. Let me make sure I have my little card here. So, as I said, there's two ways to get the remote menu or the hidden menu to pop up. One is with special cards with the track data. So, if we insert... Okay. I always say it's 100% reliable, and why doesn't it work? There we go. Okay, so that card now has popped up my hidden menu. You can dispense 50 bills from A, B, C, or D, which are the four cassettes in the dispenser. You can print statistics, which give you the master passwords and so on, or you can exit. So, I'll just dispense 50 from the first cassette. So, these are million dollar bills, but it will... probably not much use at the craps table. The other one will spit out a bit of currency. Okay, so now we can exit, and I said there was a key sequence, which you could also enter to pop up their menu. These buttons are a bit bugged. Let's try that again. I've obviously pressed these buttons a fair few times. There we go. So, we can exit from that too. Okay. So, can we cut back to the computer? Okay, and it would be nice to know where this ATM actually is as well. So, we can retrieve the ATM settings. It connects, retrieves the settings, and saves them to disk. Now, you can see, so up here are the passwords to the ATM itself. I don't actually live on 123 Kiwi Street, by the way, but I do live in San Jose. And then it has the phone numbers as well as the IP addresses and the receipt coupons and all that type of thing. Now, of course, one of the greatest things about this is the fact that you can retrieve track data from people who insert cards. So, would anyone like to volunteer? Is Brandon here? There he is. Brandon, I think, has a custom credit card especially for this. So, can we flick to the ATM again, please? Can we cross to the ATM? Okay, so just insert your card as you normally would use an ATM. Alright, thank you, sir. So, back to the computer, please. So, now, let's see if we can get the track data that he just inserted. Connects, retrieves the stripe card data, saves it to disk. Okay, so you can actually see from the first one was the gimme the loot where I actually had my demo card. And then the next track data, this doesn't look like a credit card, Brandon. Doctorate of the Bustacardi with the card leet-leet-leet-leet-leet-leet-leet-leet-leet. But, of course, it will capture any credit card that's entered into the machine. And finally, the remote jackpot, which is always handy. So, go back to the ATM. Issue the jackpot command. We have a winner! Now, before I... I'm not going to let the other one get off scot-free. So, I will quickly demo the walk-up style attack. Now, I'm not as fast as this as I should be, but I will try it anyway. So, remember, the walk-up attack is simply popping open the cabinet, inserting a USB, and restarting it. Right, so that's the attack done. I wouldn't be spotted if I was out by the restroom. I think, just for... just to make it look a little better on stage, I might just open the cabinet here. Not opening the safe, of course, just the cabinet. So, the other attack was somewhat practical. This one, you'd probably end up on World's Dumbest Criminals, as you'll probably see soon. Okay, so it boots. Right now, it should be reading the firmware off that USB drive. It copies the firmware over as it initializes the little BlackHat logo floating around the screen. Obviously, in the real world, it would be a rootkit, not a BlackHat logo. So, I kind of tailored this for both BlackHat and for Vegas, as you'll see. ARM 9 processes are not the fastest. ... ... ... I just want to see how long it actually takes to dump its entire dispenser. It will start with million dollar bills and it's going to switch to IOActive currency, which also doubles as invites for the party. So, I want there to be a big pile at the end. ... ... ... It still hasn't got to the IOActive currency. I should have put that first, I guess. ... There we go. ... Okay, we can probably flick back to the presentation now. ... Okay, so, countermeasures. ... ... The obvious physical... I may just disconnect the sounds really quick. ... ... ... ... So, the obvious physical countermeasure to prevent the walk-up attack is to offer upgrade options on the locks themselves. So, there's a unique key for each ATM. Now, of course, if you want to take this into your own hands, just drill a hole and throw a padlock on it. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... And finally, it's time to give these devices a rehaul. There hasn't been a secure development in methodology in from the get-go. So there's a need to play catch-up, have the code audited, have penetration tests, and implement best practices from here on out. So there's been a noticeable surge in the community of researching proprietary devices like ATMs. And the simple fact is that the companies who manufacture the devices aren't Microsoft. They haven't had 10 years of continual attacks against them. So the software that Microsoft got forced into a secure development, they've gotten where they are today. We're talking about devices that were developed without secure principles in mind. I think it's important to dig in, research these devices, find vulnerabilities, find solutions, and ultimately ensure a more secure future. So, cheers.