1 00:00:00,000 --> 00:00:06,760 So welcome to NFC Hacking the Easy Way. My name is Eddie Lee. I'm fighting a cold right now so 2 00:00:06,760 --> 00:00:12,500 I've got a sore throat and if I start hacking or if you hear me sniffling, bear with me, please. 3 00:00:14,720 --> 00:00:24,740 Louder? All right. I'll get closer to the mic. All right. So I'm a researcher at Blackwing 4 00:00:24,740 --> 00:00:31,600 Intelligence. We recently rebranded ourselves from Praetorian Global. We're a pretty small 5 00:00:31,600 --> 00:00:36,840 boutique security firm. And we just relaunched our website this week. So it's at 6 00:00:36,840 --> 00:00:41,660 BlackwingHQ.com. We're always looking for interesting security projects so if you guys want 7 00:00:41,660 --> 00:00:50,140 to contact us and have us break stuff for you, feel free to contact us. So I'm also a member of 8 00:00:50,140 --> 00:00:54,720 Digital Revelation. We are a two-time DEF CON CTF championship team. We've been working 9 00:00:54,740 --> 00:00:59,740 together for a long time. We won one of the first black badges at DEF CON 10. I don't know if 10 00:00:59,740 --> 00:01:03,760 DT remembers this or not, but I think it was me that gave him the idea of giving free membership, 11 00:01:03,980 --> 00:01:08,200 lifetime membership to anyone with a black badge. So if anyone out there has a black badge, you 12 00:01:08,200 --> 00:01:17,460 can thank me for that. And then finally, I am not an RFID or NFC expert. One of the reasons for 13 00:01:17,460 --> 00:01:22,380 me writing this tool is for me to actually learn about this stuff. If you want to talk about 14 00:01:23,000 --> 00:01:24,720 waveform analysis or other things like that, you can find me on the web site. I'm going to talk 15 00:01:24,720 --> 00:01:30,900 about ISO protocols and things like that. I'm not the person to talk to. So just a little 16 00:01:30,900 --> 00:01:37,080 primer information before we get started. So RFID, it operates in a broad range of frequencies from 17 00:01:37,080 --> 00:01:44,040 the low kilohertz range all the way to the high gigahertz range. NFC in particular, it runs in 18 00:01:44,040 --> 00:01:51,320 the 13.56 megahertz range. The applications that typically you find running in this spectrum are 19 00:01:51,320 --> 00:01:54,700 payment cards, library systems, e-passports, smart cards, things like that. And then we also have 20 00:01:54,700 --> 00:02:02,460 the standard read distance range is about 3 to 10 centimeters. Of course, there's been research out 21 00:02:02,460 --> 00:02:08,280 there where people have been able to increase the range. RFID works on magnetic induction. So the 22 00:02:08,900 --> 00:02:15,060 reader will power a passive tag. So there actually is a finite distance probably in terms of 23 00:02:15,060 --> 00:02:19,980 read distance. Probably limited to something about 50, 60 feet. I don't know. Other people have 24 00:02:19,980 --> 00:02:24,680 done research on that. There are a lot of new Android phones coming out. There are a lot of new 25 00:02:24,700 --> 00:02:32,040 NFC. So NFC isn't as prolific ‑‑ isn't as abundant over here in the U.S., but you can find it in 26 00:02:32,040 --> 00:02:40,980 places like Japan. It's a lot more common over there. Now, an RFID tag basically consists of a 27 00:02:40,980 --> 00:02:48,720 transceiver, which is a transmitter and receiver, an antenna, and memory or a chip processor. So 28 00:02:48,720 --> 00:02:53,360 when you scan an RFID tag, it will either spit out what's in memory or do some processing and then 29 00:02:53,360 --> 00:02:54,060 spit out some information. 30 00:02:55,920 --> 00:03:02,180 Now, for this talk, the RFID tags that we're interested in particular are the RFID tags that are in 31 00:03:02,180 --> 00:03:07,760 credit cards. Visa, MasterCard, all these credit card companies, they have their own proprietary 32 00:03:07,760 --> 00:03:13,000 name for the technology they use. But really the underlying technology is all the same. It's the 33 00:03:13,000 --> 00:03:22,280 same basic RFID stuff. Some terminology here. Proximity coupling devices is another name just for 34 00:03:22,280 --> 00:03:24,680 credit card readers or RFID reader. It's a little bit more complicated. It's a little bit more 35 00:03:24,700 --> 00:03:30,560 complex. The credit card ones in particular are called point of sale terminals. I'll be randomly using 36 00:03:30,560 --> 00:03:37,520 these terms interchangeably throughout the talk. Now, the communication protocol that's used to 37 00:03:38,040 --> 00:03:42,700 communicate between a credit card and a credit card reader is called the EMV standard. This is 38 00:03:42,700 --> 00:03:48,920 basically MasterCard, EuroPay, Visa. They got together in Europe and decided they wanted to come 39 00:03:48,920 --> 00:03:54,620 up with a standard for smart credit cards. So this standard is used for both contact based chip 40 00:03:54,700 --> 00:04:07,740 and PIN credit cards and RFID based credit cards. The protocol is based on ISO 14443 and 7816. The 41 00:04:07,740 --> 00:04:14,800 EMV books themselves are about 750 pages long. It consists of four separate books. Book three is 42 00:04:14,800 --> 00:04:20,860 probably the most interesting one in terms of protocol. And then the technical term that's used 43 00:04:21,220 --> 00:04:24,680 for the communication that happens between an RFID card and a credit card is called the EMV standard. 44 00:04:24,680 --> 00:04:28,220 And then the technical term that happens between an RFID tag and the reader is APDU. So they pass 45 00:04:28,220 --> 00:04:37,160 back basically these byte level commands and responses and those are called APDUs. Okay. So why 46 00:04:37,160 --> 00:04:42,660 create NFC proxy? Well, first and foremost, it's because I'm lazy. I don't like to read specs and I 47 00:04:42,660 --> 00:04:50,500 didn't want to learn this EMV protocol by reading 750 pages or 150 pages of book three. So really, I 48 00:04:51,020 --> 00:04:54,660 just wanted to get into NFC hacking and RFID hacking. I just wanted to jump in. I wanted to get 49 00:04:54,660 --> 00:05:02,540 in right away without reading the spec. So NFC proxy will so what it's designed to do is help with 50 00:05:02,540 --> 00:05:08,980 protocol analysis. So we're proxying communication between an RFID tag and a reader. So we're able 51 00:05:08,980 --> 00:05:14,580 to capture the communication, the byte level communication between those two devices. And you 52 00:05:14,580 --> 00:05:22,360 can go back after the fact, after you scan something and look at the protocol. In doing the 53 00:05:22,360 --> 00:05:24,640 research for this project, I realized there wasn't really a lot of information in there. So I 54 00:05:24,660 --> 00:05:28,720 think there wasn't really all that much information out there in terms of Android and card 55 00:05:28,720 --> 00:05:34,380 emulation. We'll talk about that later. And in terms of abusing RFID-enabled credit cards, there 56 00:05:34,380 --> 00:05:39,480 wasn't all that information out there either. We've known for years where you can ‑‑ it's pretty 57 00:05:39,480 --> 00:05:45,600 trivial to skim an RFID credit card. But to actually abuse the information after you've skimmed 58 00:05:45,600 --> 00:05:50,960 it, there really aren't good tools out there to abuse that and to actually spend those credit 59 00:05:50,960 --> 00:05:54,640 cards. So hopefully, in the future, we'll be able to do that. But I think it's really important to 60 00:05:54,640 --> 00:05:57,020 have a tool that can help you with that. And in the spirit of freeing information and getting 61 00:05:57,020 --> 00:06:02,020 stuff out there, people will start using this tool and maybe it will give the credit card companies 62 00:06:02,020 --> 00:06:12,580 an incentive to fix the stuff that's in my wallet. So previous work. So you guys here probably 63 00:06:12,580 --> 00:06:19,100 know MajorMalfunction and his work with RFID. It's basically a Swiss Army toolkit that allows 64 00:06:19,100 --> 00:06:24,620 you to explore RFID tags in devices and things like that. In particular, we're going to be 65 00:06:24,620 --> 00:06:29,020 looking at the script that would be pertinent to this stuff here, would be the chip and pin, the 66 00:06:29,020 --> 00:06:36,100 CHAP.py script in his toolkit. Now, there's Pablo Holdman as well. He's just famous for having this 67 00:06:36,100 --> 00:06:41,100 boing, boing video out there on the web where he's talking to a reporter and showing how easy it is 68 00:06:41,100 --> 00:06:47,920 to skim an RFID credit card just by tapping a reader to somebody's wallet. And then there's Eric 69 00:06:47,920 --> 00:06:53,060 Johansen's PwnPass. This is basically the Python script that interfaces with a credit card reader 70 00:06:53,760 --> 00:06:54,600 and ‑‑ you know, it's a little bit more complicated. But I think it's going to be really, 71 00:06:54,620 --> 00:06:59,640 really useful. And let you read off that information through a serial port. And then Kristen 72 00:06:59,640 --> 00:07:04,840 Padgett. Kristen Padgett has done a lot of work in the RFID space. Most recently she presented at 73 00:07:04,840 --> 00:07:10,700 SmooCon and showed how after skimming an RFID credit card, she took that data and encoded it to a 74 00:07:10,700 --> 00:07:17,020 mag stripe card, basically a swipeable card, and used that swipeable card in a real transaction. 75 00:07:18,780 --> 00:07:24,600 And then there's all these tag reading apps out there in the marketplace. They'll read random RFID 76 00:07:24,620 --> 00:07:32,560 tags. Though there really hasn't been credit card reading apps out there until recently. I think I saw a 77 00:07:32,560 --> 00:07:37,920 couple months ago in the news there was a headline where they actually had a credit card reading app 78 00:07:37,920 --> 00:07:42,480 in the marketplace. So I guess it's relatively new. But really that type of thing is pretty 79 00:07:42,480 --> 00:07:50,500 trivial to do. Now, in order to use some of the scripts and software on that previous slide, 80 00:07:50,680 --> 00:07:54,140 here's some of the hardware that you would need. Contactless credit card reader, 81 00:07:54,300 --> 00:07:54,600 Procter & Gamble, and a few other things that you would need. There's a lot of things that you would need. 82 00:07:54,620 --> 00:07:58,420 Some of the popular brands are Vivopay and Verifone. If you want to buy at retail, they start 83 00:07:58,420 --> 00:08:05,300 probably around $150. You can get them off eBay for about $10 to $30 if you find them at the right 84 00:08:05,300 --> 00:08:12,440 time. There aren't actually that many on eBay. You can get a card reader, like an OmniKey. 85 00:08:13,680 --> 00:08:18,520 There's a good list of different credit card readers on the RFIDiots site. Then there's 86 00:08:18,520 --> 00:08:24,060 Proxmark. I've never actually used the Proxmark tool, but supposedly it's pretty 87 00:08:24,060 --> 00:08:24,600 sophisticated. I've never actually used the Proxmark tool, but supposedly it's pretty 88 00:08:24,600 --> 00:08:27,600 sophisticated. It allows you to do sniffing and things like that. But it's a little bit more 89 00:08:27,600 --> 00:08:33,680 expensive. And then the MagStripe encoder, about two to 300 bucks. I've never used that myself 90 00:08:33,680 --> 00:08:46,060 either. So what exactly is NFC proxy? Well, it's an open source tool. It's a tool that I created to 91 00:08:46,060 --> 00:08:53,880 basically allow people to get into NFC and RFID and just try to figure out how that stuff works. 92 00:08:53,880 --> 00:08:58,700 So this tool should help hopefully make it easy for you to start learning about the protocols and 93 00:08:58,700 --> 00:09:04,120 things like that that happen in between the RFID tag and the reader. And that's done through 94 00:09:04,120 --> 00:09:14,580 protocol analysis. The hardware that's required to use NFC proxy are two NFC capable phones. My 95 00:09:14,580 --> 00:09:23,720 favorite would be the Nexus S. You can get one relatively cheaply off eBay for about 70 to 90 bucks. There's the LG Optimus if you're for some reason a 96 00:09:23,720 --> 00:09:31,280 against getting a used phone. You can get an LG Optimus Elite that just came out. You can get one for 130 bucks without a contract. But 97 00:09:31,280 --> 00:09:38,700 that phone is relatively new and there's no custom ROMs for it. So you can only use that on one side of the NFC proxy tool and it's 98 00:09:38,700 --> 00:09:45,620 really not that interesting. So I wouldn't recommend that phone if you want to use NFC proxy. The Nexus S is the one to get. And 99 00:09:45,620 --> 00:09:53,440 then Galaxy Nexus, Galaxy S, there's a lot of new phones that are coming out. You can go to that website to see if, to see any new phones that are available. 100 00:09:54,740 --> 00:10:02,760 So the software that's required, one phone can be just running stock Android, either gingerbread, anything that supports NFC or ice cream 101 00:10:02,760 --> 00:10:09,740 sandwich and above. I've only tested on gingerbread and ice cream sandwich. Haven't tested jelly bean yet so I don't know how that's going to 102 00:10:09,740 --> 00:10:23,420 respond. Should work just fine though. And then at least one phone needs a specific build of Cyanogen Mod. Specifically Cyanogen Mod 9 and the nightly build between January 20th and March 103 00:10:23,720 --> 00:10:34,960 22nd of this year. So you're probably wondering why do I need such a specific version of Cyanogen Mod. So if you take a look at this GitHub code commit, 104 00:10:35,140 --> 00:10:43,420 you'll see on January 20th, Doug Yeager checked in some code to Cyanogen Mod. It says added NFC reader support for two new tag types. 105 00:10:43,640 --> 00:10:53,620 ISO PCDA type A and type B. So what that did is it actually enabled the Android phone to detect a credit card reader. So out of the box, 106 00:10:53,720 --> 00:11:03,320 the Android SDK doesn't allow you to, doesn't provide a simple way or I don't know if it's even possible to do card emulation mode. So you can't detect a reader. 107 00:11:03,440 --> 00:11:12,480 You can't pretend to be a credit card out of the box. So Doug added some custom code to Cyanogen Mod to enable this card reading ability. 108 00:11:13,340 --> 00:11:23,120 However, on February 25th, you see there, that AP, so the code that he added also included a Java API. And on February 25th, that Java API was hidden. 109 00:11:23,120 --> 00:11:31,840 And if you wanted to write an app for it, it was much harder to kind of use that API. You could still get work around it, but basically it wasn't that straightforward. 110 00:11:32,180 --> 00:11:42,960 And all this stuff is found in the Ice Cream Sandwich ICS branch of Cyanogen Mod. Then on March 22nd, Doug submitted another commit, which said 111 00:11:42,960 --> 00:11:53,100 enable Google Wallet secure emulation. So Google Wallet needs to detect a card reader as well, right? But the code that Doug submitted detects a card reader. 112 00:11:53,120 --> 00:12:05,320 In a different method that Google Wallet did. And that was incompatible. So in enabling Google Wallet secure element emulation, he disabled his prior code commits. 113 00:12:05,740 --> 00:12:16,640 So that's why anything after March 22nd, any version of Cyanogen Mod won't be able to detect a credit card reader. And that's in the NFC.APK package. 114 00:12:18,980 --> 00:12:23,100 Let me just step back a little bit. So what I'm going to do is I'm going to go ahead and show you a little bit of the code that we've been working on. 115 00:12:23,120 --> 00:12:30,580 So when I started to get into this project, it was about beginning of February, I figured, oh, I want to do some NFC research. 116 00:12:30,940 --> 00:12:38,700 So I bought a Nexus S off of eBay. And the first thing I did was root it and install the latest nightly build of Cyanogen Mod. 117 00:12:41,020 --> 00:12:48,580 So right away, I had that code on my phone. But then I got busy with work and I put the phone down, didn't touch it at all. 118 00:12:49,100 --> 00:12:53,100 And then three months later, I had some free time. And this was some time in the middle of the year. So I had some free time. 119 00:12:53,100 --> 00:12:57,720 You know, from the beginning of the year until late July and then in May, I came back and I'm like, okay, let's start my NFC research. 120 00:12:58,240 --> 00:13:05,680 So one of the first things I did was to write a quick app to see what kind of RFID tags I could detect. 121 00:13:05,900 --> 00:13:12,000 I held the phone up to NFC card reader or to a credit card reader, and it actually beeped. 122 00:13:12,380 --> 00:13:19,380 And then I was like, okay. I can go ahead and start using, or start creating this NFC proxy tool that I had in mind. 123 00:13:23,100 --> 00:13:26,760 the type of tag that popped up on my phone was ISO PCDA. So I 124 00:13:26,760 --> 00:13:30,480 went in Google ISO PCDA trying to look for the API docs and 125 00:13:30,480 --> 00:13:33,980 things like that. But all I found was an obscure code commit 126 00:13:33,980 --> 00:13:38,620 into the code name Android CyanogenMod or the code name 127 00:13:38,620 --> 00:13:44,260 Android custom ROM which wasn't even in the CyanogenMod code 128 00:13:44,260 --> 00:13:51,880 tree. So it was pretty serendipitous in that I was able 129 00:13:51,880 --> 00:13:56,460 to get this stuff working on my phone and if I had installed the 130 00:13:56,460 --> 00:14:00,540 software, any time outside of this one to two month window, I 131 00:14:00,540 --> 00:14:03,640 wouldn't be here talking to you and presenting my stuff on NNC 132 00:14:03,640 --> 00:14:08,400 proxy. So all of my work relies on this underlying code. So all 133 00:14:08,400 --> 00:14:15,600 credit goes, should go to Doug Yeager as well. So a lot of you 134 00:14:15,600 --> 00:14:17,980 guys that are out there that are familiar with NFC and card 135 00:14:17,980 --> 00:14:20,460 emulation and stuff like that, here are the actual code 136 00:14:20,460 --> 00:14:21,860 commits for Android CyanogenMod. So I'm going to 137 00:14:21,860 --> 00:14:23,760 show you some of the code commits that Doug submitted. The 138 00:14:23,760 --> 00:14:28,120 first one is basically the Java API frameworks.jar. The second 139 00:14:28,120 --> 00:14:31,220 one is in the native library. This is all the C code and stuff 140 00:14:31,220 --> 00:14:35,360 like that. Basically lib NFC and most of that was 141 00:14:35,360 --> 00:14:40,260 contributed by the company NXP. And then the NFC service. This 142 00:14:40,260 --> 00:14:44,400 is basically NFC.APK. So if you want to see how Doug actually 143 00:14:44,400 --> 00:14:47,140 implemented his card emulation stuff, you can take a look at 144 00:14:47,140 --> 00:14:51,580 these code commits. Now if you want the latest CyanogenMod code 145 00:14:51,860 --> 00:14:54,960 and you're willing to build your own custom ROM, you can just 146 00:14:56,020 --> 00:15:01,200 revert this last commit right here and recompile everything and 147 00:15:01,200 --> 00:15:07,400 you should be able to have ISO PCDA tag support. If you're not 148 00:15:07,400 --> 00:15:10,320 willing to compile your own custom ROM, you can check out 149 00:15:11,020 --> 00:15:14,600 the goo.im site. It's basically a repository for old nightly 150 00:15:14,600 --> 00:15:18,280 builds of CyanogenMod. That one here is specifically for the 151 00:15:18,280 --> 00:15:18,880 Nexus S. 152 00:15:22,380 --> 00:15:26,680 All right. So here is a picture of NFC architecture, at least 153 00:15:26,680 --> 00:15:29,580 conceptually. I don't necessarily know if this is entirely 154 00:15:29,580 --> 00:15:33,700 accurate. But from my understanding, it looks 155 00:15:33,700 --> 00:15:36,180 something like this. So you have the host, which is 156 00:15:36,180 --> 00:15:40,380 basically the Android phone OS and hardware. And the way that 157 00:15:40,380 --> 00:15:42,380 Google Wallet works is it communicates with the secure 158 00:15:42,380 --> 00:15:45,780 element and the secure element contains supposedly encrypts all 159 00:15:45,780 --> 00:15:49,820 your account information and then the secure element communicates 160 00:15:49,820 --> 00:15:51,640 directly with the credit card reader. 161 00:15:51,860 --> 00:15:55,380 And the host never actually needs to see the credit card 162 00:15:55,380 --> 00:16:00,460 information. So what Doug's code does, I believe, it follows the 163 00:16:00,460 --> 00:16:04,140 green path here and uses the host controller interface to 164 00:16:04,140 --> 00:16:06,560 actually communicate directly with the NFC chip and 165 00:16:06,560 --> 00:16:10,680 communicate with the reader. So in doing so, he's able to, we're 166 00:16:10,680 --> 00:16:15,280 able to capture the entire byte level transaction between an NFC 167 00:16:15,280 --> 00:16:21,840 phone and a reader. So here is just a pretty basic example of 168 00:16:21,860 --> 00:16:25,420 how an RFID transaction works with a credit card. You have a 169 00:16:25,420 --> 00:16:29,360 credit card, communicates over RFID between the reader. The 170 00:16:29,360 --> 00:16:31,620 reader sends an APDU to the credit card. The credit card 171 00:16:31,620 --> 00:16:36,840 responds and this goes back and forth a few times. So what NFC 172 00:16:36,840 --> 00:16:39,160 proxy allows you to do is it allows you to proxy that 173 00:16:39,160 --> 00:16:42,280 transaction, allows you to save that transaction, allows you to 174 00:16:42,280 --> 00:16:45,720 export that transaction. You can replay all of the requests that 175 00:16:45,720 --> 00:16:49,720 the PCD made. And then you can replay all of the responses that 176 00:16:49,720 --> 00:16:51,840 the credit card gave. Now, that feature represents the 177 00:16:51,860 --> 00:16:56,680 special signage code. One thing to note, if you're saving and 178 00:16:56,680 --> 00:17:00,020 exporting data, none of that stuff is encrypted. So store 179 00:17:00,020 --> 00:17:04,980 credit card information at your own risk. So right away, what 180 00:17:04,980 --> 00:17:08,120 this tool allows you to do is it allows you to query RFID tags 181 00:17:08,120 --> 00:17:13,440 without needing to know the right APDU. So as a new getting 182 00:17:13,440 --> 00:17:17,460 into RFID, all you need to do is have a reader and a tag and 183 00:17:17,460 --> 00:17:21,480 you're able to kind of do a reverse, reverse engineer the 184 00:17:21,860 --> 00:17:23,840 call and figure out what's going on by looking at the 185 00:17:23,840 --> 00:17:28,200 transaction after it's been stored. So replaying is easy. 186 00:17:28,280 --> 00:17:32,960 That's why I think this is the easy way of doing NFC, getting 187 00:17:32,960 --> 00:17:39,780 into NFC. So here is a visual representation of how NFC proxy 188 00:17:39,780 --> 00:17:43,880 works in the proxy mode. So we have a phone on the left here 189 00:17:43,880 --> 00:17:48,480 and a credit card. That communicates via NFC. And then 190 00:17:48,480 --> 00:17:51,600 over, and then it communicates with the other phone via 191 00:17:51,860 --> 00:17:57,040 Wi-Fi or IP if you can set it up somehow. And then that phone, 192 00:17:57,220 --> 00:18:00,200 what you do is swipe it across the reader and the reader will 193 00:18:00,200 --> 00:18:04,820 start sending an APDU back through the chain. So it sends 194 00:18:04,820 --> 00:18:06,880 an APDU to the phones, the phones forward it to the credit 195 00:18:06,880 --> 00:18:11,900 card, the credit card forwards it back in like fashion and it 196 00:18:11,900 --> 00:18:14,320 goes back to the reader. Pretty simple, straightforward stuff. I 197 00:18:14,320 --> 00:18:16,880 think everyone here at DEF CON is pretty familiar with what a 198 00:18:16,880 --> 00:18:21,840 proxy is and this is pretty standard stuff. So what this 199 00:18:21,860 --> 00:18:25,260 proxy allows you to do is it allows you to do a protocol 200 00:18:25,260 --> 00:18:27,980 analysis. Because we're sitting in between the transaction, we 201 00:18:27,980 --> 00:18:31,520 can record all that stuff and then go back after the fact and 202 00:18:31,520 --> 00:18:34,380 look at that, look at all the byte level, bytes that were sent 203 00:18:34,380 --> 00:18:38,000 between the reader and the card. And what this also 204 00:18:38,000 --> 00:18:41,980 facilitates is immediate skim and use. So if you set this up 205 00:18:41,980 --> 00:18:45,880 properly, you can take a phone, put it next to someone's credit 206 00:18:45,880 --> 00:18:50,220 card and then somewhere across the world even, if the phones 207 00:18:50,220 --> 00:18:51,840 are communicating over IP, you can take a phone, put it next to 208 00:18:51,860 --> 00:18:53,100 someone's credit card. You can take that phone and swipe it 209 00:18:53,100 --> 00:18:55,300 across the reader and you'll be able to skim their credit card. 210 00:18:56,340 --> 00:19:05,320 Completely just right over IP in another part of the world. So 211 00:19:05,320 --> 00:19:08,880 just some terminology before going on. The phone on the left 212 00:19:08,880 --> 00:19:13,720 that sits on the credit card, I call that phone in relay mode. I 213 00:19:13,720 --> 00:19:16,660 say that's in relay mode. The phone on the right, I say that 214 00:19:16,660 --> 00:19:19,800 is in proxy mode. And that's the phone that needs the CyanogenMod 215 00:19:19,800 --> 00:19:21,840 code because it needs to detect the credit card reader. So you 216 00:19:25,140 --> 00:19:28,520 start up mode. So when you start up the NFC proxy for the 217 00:19:28,520 --> 00:19:31,420 first time, it will ask you which mode you want to be in. You 218 00:19:31,420 --> 00:19:34,700 can choose either relay mode or proxy mode. In relay mode, again, 219 00:19:35,060 --> 00:19:38,300 you place the phone next to a credit card. And what that phone 220 00:19:38,300 --> 00:19:40,440 does, it opens up a network socket and waits for a 221 00:19:40,440 --> 00:19:43,880 connection from the proxy. So with the proxy phone, you take 222 00:19:43,880 --> 00:19:46,720 that and swipe it across the reader. And what that does is it 223 00:19:46,720 --> 00:19:51,840 forwards all the APDUs from the reader to the relay phone. So 224 00:19:52,440 --> 00:19:56,200 all of the transactions, all of those APDUs are displayed on the 225 00:19:56,870 --> 00:20:00,720 screen of the proxy mode phone. If you long click on those 226 00:20:00,720 --> 00:20:04,420 transactions, you can actually export, save, replay, and delete 227 00:20:04,420 --> 00:20:07,820 those transactions. Now, by default, the communication 228 00:20:07,820 --> 00:20:10,500 between the two phones is encrypted. So if you're on an 229 00:20:10,500 --> 00:20:14,740 unencrypted wireless network for some reason, you'll be somewhat 230 00:20:14,740 --> 00:20:17,880 safe there. However, when you're encrypting 231 00:20:17,880 --> 00:20:21,180 communications, it slows down the transaction between the 232 00:20:22,420 --> 00:20:25,780 entire NFC transaction. So you can disable that. I typically 233 00:20:25,780 --> 00:20:29,320 disable that because I run on a private encrypted Wi-Fi network. 234 00:20:30,620 --> 00:20:33,220 So if you disable encryption, it will speed up the transaction, 235 00:20:34,340 --> 00:20:36,900 but you'll also lose authentication. So that phone 236 00:20:36,900 --> 00:20:39,480 that's running in relay mode, anyone can connect to it and 237 00:20:39,480 --> 00:20:47,160 query that credit card. So replay mode. So replay mode 238 00:20:47,160 --> 00:20:51,440 doesn't require that whole proxy setup. So if you want to replay a 239 00:20:51,860 --> 00:20:54,100 IP and you have a store transaction on the phone, you 240 00:20:54,100 --> 00:20:56,860 can just take all those APDUs and replay them against a credit 241 00:20:56,860 --> 00:21:00,780 card. So if you have all of those APDU requests that are 242 00:21:02,560 --> 00:21:05,140 needed to query a credit card, you just replay that next to a 243 00:21:05,140 --> 00:21:07,200 credit card and you'll get all the credit card data out of the 244 00:21:07,700 --> 00:21:10,600 RFID-enabled credit card. That's nothing, again, nothing 245 00:21:10,600 --> 00:21:14,140 special going on here. This is what would be called skimming 246 00:21:14,140 --> 00:21:18,440 mode. It's pretty, it's been known for several years that you 247 00:21:18,440 --> 00:21:21,680 can skim RFID credit cards easily. Hopefully in the future, 248 00:21:21,680 --> 00:21:25,860 I can add a special RFID or a special skimming mode that allows 249 00:21:25,860 --> 00:21:29,520 you to skim credit cards without needing to replay specific 250 00:21:29,520 --> 00:21:35,800 transactions. That's because when you actually scan 251 00:21:35,800 --> 00:21:38,300 different credit card types, Visa, MasterCard, Amex, 252 00:21:38,340 --> 00:21:41,000 Discover, they'll elicit different responses from the 253 00:21:41,000 --> 00:21:46,340 credit card reader. So if you replay the PCD responses or 254 00:21:46,340 --> 00:21:51,080 requests from a Visa scan, they won't work against a MasterCard. 255 00:21:51,680 --> 00:21:53,600 They won't be able to extract the credit card information from 256 00:21:53,600 --> 00:21:58,420 a MasterCard. Now there's tag replay mode. This is probably 257 00:21:58,420 --> 00:22:01,360 the most exciting feature of the tool. This is also called 258 00:22:01,360 --> 00:22:04,700 spending mode. So you take the phone, you swipe it across the 259 00:22:04,700 --> 00:22:09,240 reader, and basically you can start spending someone's credit 260 00:22:09,240 --> 00:22:13,640 card. You use it just the same way you use Google Wallet. This 261 00:22:13,640 --> 00:22:16,720 one, again, is the phone that requires signage and not code. 262 00:22:16,980 --> 00:22:20,640 So you can use this basically as a virtual wallet. So if you scan 263 00:22:20,640 --> 00:22:23,820 your own credit card several times, you can use your own 264 00:22:23,820 --> 00:22:26,740 credit card and replay it at a real live point-of-sale 265 00:22:26,740 --> 00:22:30,060 terminal. However, there's one caveat, though. Every time you 266 00:22:30,060 --> 00:22:32,800 scan a credit card, that credit card has an internal counter. 267 00:22:33,120 --> 00:22:35,940 And every time you scan a credit card, that counter plus 268 00:22:35,940 --> 00:22:40,260 a couple random bytes of data will be sent along to the reader 269 00:22:40,260 --> 00:22:42,820 and then the reader will forward that information to the central 270 00:22:42,820 --> 00:22:44,920 processing station, whatever that's called, whoever 271 00:22:44,920 --> 00:22:47,460 processes the credit cards. And they keep track of that 272 00:22:47,460 --> 00:22:50,620 counter. So if that central processing station has an 273 00:22:50,640 --> 00:22:51,380 internal counter that the central processing station ever 274 00:22:51,380 --> 00:22:54,540 sees a counter that's lower, less than or equal to a counter 275 00:22:54,540 --> 00:22:58,320 that's already seen, it's going to lock your credit card. So if 276 00:22:58,320 --> 00:23:01,580 you're skimming credit cards, you need to replay them in the 277 00:23:01,580 --> 00:23:06,920 order in which they were scanned. Personally, I've tested 278 00:23:06,920 --> 00:23:12,300 the replay of credit cards at live point-of-sale terminals. 279 00:23:12,600 --> 00:23:16,980 I've tested Visa and MasterCard. I haven't tested the Discover or 280 00:23:16,980 --> 00:23:18,460 Amex, but I think they should work. 281 00:23:21,880 --> 00:23:28,620 Just a word about NFC antennas before moving on. The different 282 00:23:28,620 --> 00:23:31,620 phones respond differently and they'll read NFC tags 283 00:23:31,620 --> 00:23:35,420 differently. The antenna on the Galaxy Nexus is just pure shit. 284 00:23:35,640 --> 00:23:39,940 It takes 10 minutes or so or 5 to 10 minutes for me to get it to 285 00:23:39,940 --> 00:23:42,840 read a credit card, depending on the credit card type as well. So 286 00:23:42,840 --> 00:23:50,380 I would not recommend the Galaxy Nexus for this tool. The Nexus S is 287 00:23:50,640 --> 00:23:54,680 actually pretty good. The Optimus Elite is good as well. So you 288 00:23:54,680 --> 00:23:56,900 may try a bunch of different phones to try to figure out which 289 00:23:56,900 --> 00:24:01,120 phone works best for you. So this brings me to the next point. 290 00:24:01,760 --> 00:24:05,600 NFC proxy or communication is often incomplete. So when you're 291 00:24:05,600 --> 00:24:09,520 using this tool or if you've ever used the NFC feature on your 292 00:24:09,520 --> 00:24:13,380 phone to try to scan a tag, you'll find out that you'll get a 293 00:24:13,380 --> 00:24:16,780 lot of partial transactions. So which all you'll need to do is 294 00:24:16,780 --> 00:24:20,400 just kind of take the phone and try to rescan the tag or try to 295 00:24:20,640 --> 00:24:28,960 get the reader to reacquire your credit card or your phone. So 296 00:24:28,960 --> 00:24:33,820 here's a screen shot of the actual tool. What we have here is 297 00:24:33,820 --> 00:24:36,960 the data tab, the status tab, and the save tab. The data tab 298 00:24:36,960 --> 00:24:40,560 basically contains all your live transactions. All those hex 299 00:24:40,560 --> 00:24:43,980 bytes you see there are the actual APDUs that were sent from 300 00:24:43,980 --> 00:24:48,100 the tag and to the PCD and the responses from the PCD and stuff 301 00:24:48,100 --> 00:24:50,440 like that. At the bottom there, 302 00:24:50,640 --> 00:24:54,920 there's a human readable format of the credit card information. 303 00:24:55,680 --> 00:24:58,380 That human readable format is kind of a hack in the tool right 304 00:24:58,380 --> 00:25:01,480 now. So if it's not working for your credit card, don't worry. 305 00:25:01,580 --> 00:25:04,440 It's just a visual representation. The replay stuff 306 00:25:04,440 --> 00:25:10,420 should all work decently well. So this contains things like the 307 00:25:10,420 --> 00:25:14,280 service code and ICVV. So the service code basically tells, 308 00:25:14,500 --> 00:25:19,080 indicates how the credit card can be used. Can it be used 309 00:25:19,080 --> 00:25:20,620 internationally? Does it require an IP address? Does it require a 310 00:25:20,640 --> 00:25:25,200 pin? Stuff like that. The ICVV basically, so on the back of 311 00:25:25,200 --> 00:25:30,200 your credit card there is a CVV. And that's basically a fixed CVV 312 00:25:30,200 --> 00:25:34,700 number. When you scan with RFID enabled credit cards, you'll get 313 00:25:34,700 --> 00:25:38,740 a dynamic CVV. So basically in this case for this Visa card, it 314 00:25:38,740 --> 00:25:41,340 will consist of the counter, which is the last two bytes 315 00:25:41,340 --> 00:25:46,080 there, and the first two bytes are just random bytes. It's 316 00:25:46,080 --> 00:25:50,620 probably only a thousand decimal worth of random bytes. So it's 317 00:25:50,640 --> 00:25:56,800 random data, though. It's not all that random. If you want to 318 00:25:56,800 --> 00:26:00,220 learn more about the actual communication protocols between 319 00:26:00,220 --> 00:26:04,500 credit cards and readers, you can check out the EMV book three 320 00:26:04,500 --> 00:26:08,740 specifically. RFID also, you can check out the chip and PIN 321 00:26:08,740 --> 00:26:12,220 script and you can check out POMPASS to see how that uses, 322 00:26:12,400 --> 00:26:17,300 what kind of APDUs are used to query credit card readers. If 323 00:26:17,300 --> 00:26:19,400 you want to check out more, find out more information about 324 00:26:19,400 --> 00:26:20,620 the service code and ICVV, you can go to the website at the 325 00:26:20,640 --> 00:26:26,960 ICVV. You can check out ISO 7813-2006, or you can check out 326 00:26:26,960 --> 00:26:29,480 the blog at Open Security Research. I think that's 327 00:26:29,480 --> 00:26:33,560 sponsored by Foundstone. That has some good information on the 328 00:26:33,560 --> 00:26:39,200 service code as well. So let's take a look at it in action. 329 00:26:39,380 --> 00:26:40,280 Let's see a demo. 330 00:26:51,000 --> 00:26:54,900 Part of this relies on Wi-Fi, so it may not work if someone's 331 00:26:54,900 --> 00:26:57,140 messing with my Wi-Fi. So bear with me. 332 00:27:15,060 --> 00:27:20,480 Start up NFC proxy here. So the first thing I'm going to show you is, 333 00:27:20,640 --> 00:27:26,900 the replay mode. So if I go to the save tab, I can see there's 334 00:27:26,900 --> 00:27:30,720 actually a bunch of built-in card reader transactions. So I'm 335 00:27:30,720 --> 00:27:35,200 going to select the VivoPay 4000 MasterCard transaction right 336 00:27:35,200 --> 00:27:38,860 here. Just click on it. And then at the top there, you'll see 337 00:27:38,860 --> 00:27:41,440 that there's a P, and that indicates that we're in PCD 338 00:27:41,440 --> 00:27:46,480 replay mode. So now the phone is pretending that it's going to be 339 00:27:46,480 --> 00:27:50,440 a credit card reader. So if I take my credit card and I hold a 340 00:27:50,640 --> 00:27:53,400 card near the phone, hopefully it will read the information right 341 00:27:53,400 --> 00:27:59,340 off of it. There. So as you can see, it's all the same information 342 00:27:59,340 --> 00:28:03,760 you saw on that slide before, name, cardholder, et cetera. The 343 00:28:03,760 --> 00:28:07,620 stuff at the bottom, the track 3 stuff, that is MasterCard 344 00:28:07,620 --> 00:28:13,820 specific. So now, so what I've just done now is I've skimmed 345 00:28:13,820 --> 00:28:16,860 someone's credit card. As you saw, it was really easy. 346 00:28:20,640 --> 00:28:26,820 Thank you. So I mean, so that's pretty trivial. Everyone, like, 347 00:28:26,860 --> 00:28:30,120 that's been done before. So now let's take a look at how you can 348 00:28:30,120 --> 00:28:33,060 actually abuse that information. So if I long click on this 349 00:28:33,060 --> 00:28:40,640 transaction, okay, and then I select replay tag, you'll see at 350 00:28:40,640 --> 00:28:43,780 the top here now it says T. This indicates we're in tag replay 351 00:28:43,780 --> 00:28:47,400 mode. So we're going to replay the actual credit card for this 352 00:28:47,400 --> 00:28:50,620 reader now. So everyone, if you look up front here, you'll see a 353 00:28:50,640 --> 00:28:54,880 system icon. Hopefully this will, the LEDs on this reader will 354 00:28:54,880 --> 00:29:01,300 light up and it will beep. There. So now, I've just skimmed, and 355 00:29:02,500 --> 00:29:10,240 Thank you. Right. So I've just skimmed and abused and spent 356 00:29:10,240 --> 00:29:13,340 someone's credit card within a couple minutes right there. So 357 00:29:13,340 --> 00:29:16,420 it's really simple to do. And all I'm doing is replaying 358 00:29:16,420 --> 00:29:19,080 transactions. I don't need to know the protocol whatsoever. 359 00:29:19,080 --> 00:29:23,560 whatsoever. However, if I want to learn about the protocol, I can go back and look at the 360 00:29:23,560 --> 00:29:30,460 actual bytes here and you can export all this stuff to a file or the local database for later 361 00:29:30,460 --> 00:29:38,420 analysis. So let's set this up now in replay mode. So let's say you come across a reader or a 362 00:29:38,420 --> 00:29:43,380 credit card type that doesn't quite work for you. The built in transactions aren't working for 363 00:29:43,380 --> 00:29:47,380 you. You can't skim a credit card. So what you want to do is set up your phones in relay 364 00:29:47,380 --> 00:29:57,360 mode. So you take the relay phone and you put it on the credit card. It detects the credit card. 365 00:29:58,420 --> 00:30:07,320 Really not much goes on on that phone. And then we put the, let me exit out of here. And we go 366 00:30:07,320 --> 00:30:13,200 back and we take the phone, hopefully my, let me double check my network communication is 367 00:30:13,200 --> 00:30:13,460 working. 368 00:30:19,500 --> 00:30:30,400 Yeah, good thing I checked. Well, there we go. So now if we take the phone and place it near the 369 00:30:30,400 --> 00:30:45,400 reader. Not connected. So we lost connection there. There we go. So it beeped. So if we go back to 370 00:30:45,400 --> 00:30:47,360 the actual data screen, we can see that it's not working. So we're going to go back and see if we can 371 00:30:47,380 --> 00:30:53,120 see that we got the transaction. So basically that transaction was proxied through Wi-Fi and it 372 00:30:53,800 --> 00:30:59,240 saved to the screen here. So all the data that's on the screen here, this is transitory. If you hit 373 00:30:59,240 --> 00:31:04,800 the back button, the data disappears. You need to actually explicitly save this data to database or 374 00:31:04,800 --> 00:31:11,280 file in order for you to keep it around. So let me just show you some more features. Again, if you 375 00:31:11,280 --> 00:31:16,660 long click on the transaction, you'll see that you can delete, save, or export the files. Again, 376 00:31:16,660 --> 00:31:26,760 saving this stuff is not encrypted. So save credit card information at your own risk. Let's see. 377 00:31:27,200 --> 00:31:35,080 There's some settings that you can take a look at. So you can choose relay mode. You'll need to 378 00:31:35,080 --> 00:31:40,860 set the IP of the relay phone, set the port, password. So to use encryption, you need to set a 379 00:31:40,860 --> 00:31:46,640 password on both phones. You can keep the screen on and debug logging. So debug logging is going to 380 00:31:46,660 --> 00:31:51,480 actually log credit card numbers to the logcat feature of Android. So just be aware of that as 381 00:31:51,480 --> 00:32:11,360 well. Okay. Okay. So what's next? Well, hopefully I can turn this into a generic framework. 382 00:32:12,600 --> 00:32:16,640 And this will work with other technologies, not just credit cards. Hopefully I'll be able to 383 00:32:16,660 --> 00:32:22,260 work with other things like metro payment systems, like the Clipper card in the Bay Area or access 384 00:32:22,260 --> 00:32:28,840 cards and other cards like RFID and technology like that. So in the RFID space, there's actually not 385 00:32:28,840 --> 00:32:34,860 much standardization between verticals. So access cards and payment systems versus metro systems, 386 00:32:35,160 --> 00:32:40,580 they'll use different communication protocols, which really means that a tool like NFC proxy would 387 00:32:40,580 --> 00:32:44,320 be really useful in being able to analyze the different protocols if you don't have access to the 388 00:32:44,320 --> 00:32:44,600 specs. 389 00:32:46,860 --> 00:32:52,560 And also hopefully I can add pluggable modules in the future. Because we are being a proxy, 390 00:32:52,800 --> 00:32:56,480 we're sitting in the middle and it might be possible to launch man in the middle of attacks. 391 00:32:57,960 --> 00:33:02,860 And again, since we are in the middle, it should facilitate protocol fuzzing, should make it 392 00:33:02,860 --> 00:33:10,940 pretty easy to do protocol fuzzing. And it is now available for download and contribution. You can 393 00:33:10,940 --> 00:33:16,100 find it at SourceForge. I believe it's public right now and you should be able to download the code. 394 00:33:16,660 --> 00:33:21,800 And install it on your phones. Though, again, you will need the CyanogenMod to do tag replay. 395 00:33:24,340 --> 00:33:27,900 And oh, that went quick. So I am done. Any questions? 396 00:33:32,220 --> 00:33:34,760 Can you read Google Wallet credit cards? 397 00:33:34,960 --> 00:33:40,600 No. So the question was can I read Google Wallet credit cards. So Google Wallet, when you 398 00:33:40,600 --> 00:33:46,640 place two Android phones together, they actually go into peer-to-peer mode. So that is actually the 399 00:33:46,640 --> 00:33:49,600 best way to do it. And also, right now with the code that Doug Yeager submitted, it doesn't 400 00:33:49,600 --> 00:33:54,060 detect that as a reader or credit card. They won't detect each other correctly. 401 00:33:54,340 --> 00:33:59,340 All right. Thanks.