Hello everyone, thank you very much for coming. Uh, my name's uh, Christopher Wade. I'm a pen tester with a company called Pentest Partners. Um, you should see my slides in a second I think. Um, and today I'm gonna talk about um, tag side attacks against NFC. Now, what really I'm going to talk about is how you can take very rudimentary components, like those that are not generally used for creating NFC based technologies and use them in order to create attack tools that can be used to um, basically attack NFC readers rather than do things like um, attack NFC tags themselves in order to uh, get their contents. Now, um, this is, I think my slides aren't coming up yet. Um. And that's my talk about PowerPoint. Thank you very much. So, yeah, we're talking about um, tag side attacks against NFC. So, basically we're gonna talk about how you can take some very, very basic components in order to make um, NFC analysis and attack tools. So, firstly, what is NFC? Well, we all know what it is. It's contactless communication between usually a card and some kind of reader that um, illuminates the card in order to power it and communicate with it in order to do things like pay for things, open doors, or other applications that are quite useful. So, um, I don't know why I've got a picture of uh, some gates there, but it's pretty much the main purpose of this. Um, we're gonna show you some techniques for attacking things, mainly, uh, you're gonna see a bit to do with door control access systems. So, first we're gonna talk about, um, some ISO numbers. So, we're gonna talk about ISO 1443, um, which focuses on 13.56 megahertz NFC communication. It defines the characteristics of the communication, basically, how it works, how the protocol works, and it's split out into two sections, A and B, which are used for different purposes and have different protocols on both, uh, higher and lower level. Um, the most common of these is ISO 14443A, um, which is, uh, mainly used for MIFARE Classic, MIFARE Ultra-Light, and other MIFARE systems. Um, and, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, systems. Um, so, low level communication basically works on ISO 414443A, which I'm gonna try and stop saying, um, by powering the, uh, tags with electromagnetic induction, literally powering the device with the same mechanism it's using to communicate with it. So, communication is performed by basically cutting power to the tag every so often in a fast enough manner that it doesn't turn off the tag, but allows it to receive data back. Now, the responses are performed by the tag by modulating the amount of power being drawn from the reader to the tag. Essentially, uh, modulating on that in order to send responses. It's sort of a one way communication by, uh, receiving more power from it. Um, they use two different coding schemes. Modified Miller Coding, which is designed specifically in order to, um, uh, produce the amount of power, um, loss that's gonna happen. And Manchester Coding, cause it's good because of, uh, timing issues that may occur. So, Modified Miller Coding basically, yep, minimizes the power loss. Um, it has a very strange, um, like, um, protocol basically. Zero after zero bit. Means that it's low for the first quarter of the transmission, and then high again. Zero after one bit, high for the entire transmission. And one, uh, one bit is high for the first half of the transmission, followed by a low for one quarter of the transmission, and high again. Basically, this is done in order to, no matter what the communication is, not have a small space between the off, um, sections of the communication. In order to prevent there to be glitches or problems with the power as it goes along. As those can cause problems with the readout protection. Manchester Coding is, uh, done in order to prevent timing issues. Basically, this is used among all other kinds of radio technologies, including ADSB, which you may know if you like RTL-SDR technologies. Um, and basically, uh, how they use it is to modulate the amount of power being received in order to, um, communicate either a one or a zero by basically, uh, modifying the, uh, phase of the signal. So, the basic enumeration of the, uh, NFC we're gonna look at today is basically a re- it starts with a request or a wake up command, which basically requests any tags that haven't spoken or are ready to speak. An ATQA, which responds the initial part of what the tag does. A SELECT, which, uh, requests the unique identifier from the tag. And a further SELECT in order to select that specific tag, depending if there's more than one on the reader. And then a final SAC, um, value, which basically says the final information about what this tag does. And then contu- continued enumeration and communication based on what's happened there. Now, this could be extended unique identifiers or more cryptography. A big thing that I found when it came to this was, uh, a feature called anti-collision, which basically exists when there are two, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, two tags within a reader that haven't spoken yet. Causing issues which, um, uh, could, uh, stop the reader from being able to, uh, decide which tags are on the thing. So, for instance, if we look at the requests that are being made, the first thing that happens is the tag sends an ATQA response. Now, because both tags don't know that they've spoken yet, both will send a tag, uh, response at the same time. Basically causing, uh, corrupted communication from both. Now, how it's- this is resolved is by the reader specifically, um, requesting specific bits from the tag in order to find ones that don't match, as these identifiers are meant to be unique. So, there's a couple of different ways of, um, encrypting and authenticating depending on what the tags are. So, there's MyFeralShlight, which is extremely simple. You send a password to the tag and it says either yes or no. Now, this can often increase the counter, which basically locks the chip and stops it from being used again. This is a common technology in things like Amiibos that you find on, uh, Nintendo products. Um, there are other ways of doing it. There's, uh, having no communication whatsoever, just reading and writing data. Or, newer versions, like MyFeralShlight C, allow you to, um, use, uh, more stringent encryption and authentication methods. Uh, MyFare Classic, which we're gonna focus on quite a lot today because it's an old technology, but a technology that's used everywhere, um, uses the, uh, CryptoOne algorithm that's often called the CraptoOne algorithm for the fact that it's got very, very, very weak encryption, weak keying. Um, basically, the reader requests authentication, the tag responds to the 4 byte nonce, the reader responds to the random value followed by an encrypted number that's generated from that original nonce, and then the tag responds to another encrypted number from that data. Basically, it's a mutual authentication scheme where both the tag and the reader know that they both have the same key they're working with. All the further communication after this is encrypted in order to prevent an attacker from basically being able to read or write a tag even when they're not allowed to. There's MyFare Desfire, which is probably one of the later technologies and one that's used in all sorts of things. I live in London, so it uses, it's been used in Oyster Cards in order to, um, work with the transit systems and that's, it's got much stronger encryption authentication. If you use DES, TRIPLE, DES or AES, um, and can do it based on very specific sectors of the data. Um, multiple keys can be used on each section and it, some, it's authenticated similarly to MyFare Classic. Now, Crypto One has a lot of issues with known plaintext attacks due to the fact that it's a stream cipher, but when you're using things like DES, TRIPLE, DES and AES, um, plain, known plaintext becomes not very useful and it's not really been broken in a meaningful manner via cryptal analytics techniques. So we're gonna talk about creating the analysis tools that I worked with for this project. So, obviously there's a few we know about. There's the Proxmark 3 and the Chameleon Mini, which are probably the most well known of these, uh, uh, NFC attack tools that people see. There's Hydra NFC, which is something more of a hobbyist product, but is very, very useful and uses some of the similar technologies we're using today. Simple NFC, which has some similar hardware to what I'm working with and is a very interesting project in of itself. And EmuTag, which also has some, uh, benefits to it. So, let's start off with absolute basics. If you take an LED and a coil of wire and solder them together, you can detect an NFC field. That's all you need to see that NFC is working. It will literally light that LED as soon as you put it within the field's reach and show that it's working. But, if you want to go higher level and get more details about the communication, you can create a passive sniffer. Now I did this with an RTL SDR, which we all know is a very, very basic, very cheap SDR tool that's definitely not meant to be an SDR tool. Uh, this is a device that is basically reverse engineered from, uh, uh, TV tuners that people use via USB. Um, but it has some very great libraries that basically allow you to work with it as an SDR tool. There are some problems with it, that it can't tune down to the exact frequency that's being worked with for NFC. It can't run at the low sample rate required for NFC. And it's bundled with a really weak antenna, so it's not really useful for many purposes. It's also not built for purpose for being an SDR in the first place. It's built as a TV tuner, meaning anything we do to it is gonna be very, uh, difficult to work with. So, what I ended up doing is, because I couldn't tune down to 13.56 megahertz, because of the, uh, the, uh, the, uh, range was 25 megahertz to 1700 megahertz, I tuned to 27.12 megahertz, which is a harmonic value of 13.56. Um, as long as I had a coil within the, uh, uh, vicinity of the reader, or a tag within the vicinity of the reader, the power throughput was enough that I could analyze the, uh, communication from the reader using this, uh, methodology. And by setting the sample rate to, uh, double what it should be, I could still get the correct sampling for what I was trying to communicate with. I didn't require any antenna mod- modifications because of this. I used a traditional antenna and a coil of wire wrapped around the, uh, the, uh, the, uh, the, uh, the wire wrapped around it. Nothing else. Um, the problem was, I couldn't actually get any responses from tags to the readers because the harmonic values and the nature of the, uh, um, the, uh, uh, antennas I was using just weren't capable of it. So, here's some, uh, basic output of how this came. So, this is, uh, output from the tool I made with the RTL-SDR, showing, um, a request, um, message, a select message, a, uh, halt message, and another request message. Now, this is done in order to, um, find any tags in the field, that haven't spoken yet, without waking up the ones that already have, basically to prevent the anti-collision from happening. There is then, uh, the wake up command, which wakes up every tag in the field so that it can communicate with them again. So, amazing analysis tools, I wanted to make a tag myself out of components that you wouldn't traditionally use. Now, some people use things like PN532 boards and other NFC boards, which are great, but you're not getting down to the raw level. You're basically communicating with something that's meant to be a tag. Um, so, I wanted to use no NFC chipsets, but obviously I'd need to use a microcontroller. But I wanted to build it with as minimal components as possible. If I could do it with, like, a wire- piece of wire and a microcontroller, I would have. Unfortunately, what- that wasn't possible. Um, I had to implement the full crypto one authentication, um, which would add quite a lot of complexity to projects, and mean that I need a microcontroller with sufficient power to do it. Um, by fully implementing this, I hope to find some weaknesses that other people haven't found, or introduce ones that people have found, but haven't fully implemented yet. So, there's a few things that happen when you need to, uh, work with the, uh, NFC field. The first is inductive coupling. Now, this is for, um, producing power, and for transmitting the commun- communications back and forth. So, it needs to be de- demodulated by the amplitude, because, uh, basically, power and- powering off the, uh, field in order to communicate with it is essentially the same as on-off keying used in traditional radios. Because of this, I would need to, um, use, uh, some amplitude, um, detection technologies. Um, I'd need to have a decently fast microcontroller with enough power to do, um, uh, encryption calculations, and enough storage in order to do encryption calculations. And I would need enough sufficient memory on the device to store any tags that I'd made. So, we're gonna go from the basics of how this circuit would work. So, the first thing we'd need is an LC circuit. Now, this is for inductive coupling with, uh, a, uh, NFC reader. It's made of an induction as a capacitor, so that's why it's called an LC circuit. L for inductor and C for capacitor. And, basically, the, uh, inductor was a coil of wire, and then now I just use a 10 pico farad capacitor in order to, uh, tune with that. The resonance can be checked with a logic sensor, rather than a, um, uh, uh, scope, which you would usually use. Even though it's digital information, you could at least check that the frequency was correct, 13.56 megahertz. I then need to demodulate this, so I basically took, uh, made an envelope detector. Now, these are traditionally used in, um, AM radios and that kind of technology. Um, can be made from a diode, a resistor, and a capacitor. This will rectify the signal, and then, um, basically smooth it in order to get the actual signal that's trying to be transmitted. Basically, instead of having the, uh, AM wave as it wa- as it was. I, via trial and error, worked out that I wanted to use a 1K resistor and a 220 pico farad capacitor, and that seemed to work very well. Again, I just took the circuit and plugged it into a logic analyzer, and I got exactly what I wanted. Now, that communication there is a wake up command, um, basically modulated via the modified Miller, uh, protocol and encoding schemes. So, that's the full circuit that you need to use in order to connect a microcontroller onto the NFC technologies that are being used. Now, I don't often draw circuits, so it's not perfect, but it does seem to work. I would- then tie one pin to a GPIO input, um, and then that same pin to a GPIO output in order to, um, uh, modulate on the power, um, being received, and then just to the ground on the other one. I'd- while I said that I wanted to use a- a microcontroller with sufficient power, I actually went for the ATtiny84, which is a very, very, very small, very weak chip. It's got an 8 kilobyte program space and 512 bytes of RAM, which is nothing. That's one and a half tweets. So, not much to work with. It can be used for, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh. It can be programmed with an Arduino or an ISP programmer, though this makes it very difficult to debug with. And it can use external crystals basically in order to get it to tune it to the frequency you want. It's also in DIP package, so I could build this on a breadboard, test it, and then solder something together as I needed. I could literally just attach the circuit that I made before to the GPIO pins and receive the data. The interrupts and timings on it were very good, but the debugging capabilities were quite lackluster. And because it was, um, an 8-bit architecture being used, uh, encryption calculations were very, very, uh, unusable on it. So I took a 13.56 megahertz crystal and the matching capacity it should require in order to um work with it on this microcontroller and soldered them up. Now I could set all the um fuses in order to make sure the ATtiny was performing at the exact frequency we wanted. I then took the receiving circuit and connected it to an input and output pin ground and due to the lack of UARTs I set up some GPIOs to basically make a software based SPI master in order to uh print out any debug strings that I required which was very slow but was good in the early stages of this in order to see how the communication was working. I then added an LED just so I knew when the thing was working and not crashing. Uh the state machine that uh was used for enumeration, authentication and everything else was implemented and allowed the device to behave as a tag as needed. One of the big problems I had was that uh the timing issues. A 13.56 megahertz crystal um with an ATtiny is gonna have a lot of clock drift just because it's a very non-standard frequency and it's not one traditionally used. Um basically what I was trying to do was at predefined intervals 847 and a half kilohertz which is the uh data rate of the communication I read the value of the GPIO. Now this worked about 50% of the time to get an accurate read of the communication that was going on but eventually it just got out of sync and it just wouldn't work anymore. So what I did was I um took all of the times that the power was um taken down and um checked the timings between each one. And this was the only time that I was able to check the timings of the communication. So this basically helped me build up communication just by timers and interrupts and made it possible to be very vague about the uh timings between these things. And it basically by doing this I got a 99% accuracy which was enough to keep the tag and the reader happy and communicating fully. So uh crypto one it was meant to be a proprietary library and people have reverse engineered it and created the crapto one library which is an excellent name for any github project. Um there were lots of papers involved with this that made it very easy to understand what was going on. And it's really easy to understand what was going on and it's really not a good encryption algorithm even from the get go. It uses a 48 bit key scheme with separating these 48 bit keys into 24 bit keys that are cycled between as authentication goes on. Um which also made um the ATtiny have to do some very strange um calculations in order to work with it. Um the big problem was that um when you have a microcontroller like a 32 bit one when you're working with things like 16, 24 and 32 bit calculations these can be done very quickly. There are some problems that mean that an 8 bit um calculation will take at least 3 to 4 times in order to perform the same calculations. Um especially this happened with the bit shifts that happen. Most things like ARM microcontrollers can do multiple bit shifts in one operation whereas the AVR um microcontroller set can only do one bit shift at a time which is very slow. The problem with this is that um most readers want a response within 70 microseconds when you uh let's send a request. And so I had to make sure I did this very quickly. I identified that the big problem was in the filter function of crypto one which has a lot of uh calculations going on. So I identified all the parts of this where the everything was going to be slow and all the communication wouldn't work and I calculated these and took them in order to uh work out how I could improve their speed using assembly rather than C. So all the crypto one code was converted to C from C to assembly by hand in order to make sure that I could uh speed up anything I needed to. Now we all know that if you write uh of assembly by hand rather than letting the compiler do it things become a lot more efficient. I'll use the SIMO VR uh uh emulator which basically allows you to um pretend you've got an AVR microcontroller apart from the important hardware parts to print out data as it was going along so I could test and do unit testing against keys from the C version and the assembly version. I took all the calculations that would have been treated as 32 bit when they could have been 24 or 16 bit and converted them to 24 bit operations. Basically this meant I could use one register or two registers where I usually they would be using four. Um all bit shifts were converted as needed so a 16 bit shift operations, 8 bit shifts one move instruction, 4 bit shifts the AVR uh microcontroller has the swap command which stops the upper nibble and lower nibble of a byte. Um the 2 bit shifts could just be done with traditional shift um bit shift operations and 1 bit shifts just a shift operation. Uh basically I managed to make the thing 10 times faster by doing this. Here's some of the assembly code that was used it's uh not pre but it was very effective as as needed. Um here are the uh prototype boards I made. Now the top one um has a uh a little bit more of a programming header and a button to switch between tag versions and tag data. And the bottom has everything you'd need to emulate a Myfair classic tag using this platform. You don't need anything more than those 5 or 6 components that are on the board. Um these worked very effectively and allowed me to basically emulate anything I needed to. So I could take an NFC reader. Now this is the NFC reader that I took to Defcon China recently and discovered that that's the same one they use in Beijing airport which was very fun to get through customs believe me. Um they did question it but they let me through anyway. So I took the NFC reader anyway. Um I basically could make it print out UIDs by um uh putting uh any NFC tag on top of it and I took my device and laid it over it and got responses. Now I'm gonna do a quick uh demonstration video of this for everyone. Um hopefully. Oh. Oh. One second sorry. So literally I could wave the thing on top and the NFC reader would print that out and that allowed me to know that it was communicating effectively and that the reader was working. Um so there are some hardware limitations to this. Obviously I've made something that can emulate a tag fully but I couldn't now make an attack tool out of it. Basically it was too slow and didn't have enough memory to do it. I used 400 bytes of the RAM and 7,000 bytes of the RAM and I used 1,000 bytes of the flash which seems like a lot but I would only have about 100 bytes of RAM left and 1K of flash left to work with which wouldn't be enough to make any real attack from this. Also the EEPROM on the device just didn't have enough to store an entire NFC tag. So a Myfair Classic tag um uses 1K of uh data uh except in very specific um uh instances and because of this I wouldn't be able to store a whole tag but I could perform some attacks on it. So I was in a sort of catch 22 with this thing. Complex functionality on an AVI microcontroller a specially debugging it's just not possible uh unless you're got a much more expensive setup than I did. I was using the most basic and cheap tools I could find. And the number of pins on the thing which was a total of 14 just wasn't enough to add any extra functionality I'd want to. Uh the slow responses from the uh the tag were just making it very difficult to work with very specific readers which meant I couldn't make it work in all instances. So I decided to build a better device with something a lot more powerful. I used the STM32L496ZG which is a development board um and an uh microcontroller which has a huge amount of power and a huge amount of capabilities for a very small price. Um it's about 18 pounds on Amazon and nowadays that means it's about 18 dollars as well. Um it has 1 megabyte of flash and 320 kilobytes of RAM. That's 640 times more than the ATtiny which is really crazy when you think about it. The clock speed could go all the way up to 80 megahertz which would allow me to uh basically not have to use an external clock if I was clever about it. And the 32 bit architecture meant that I could implement all the encryption authentication without having to do anything too clever like write assembly. Um it has USB and UART capabilities meaning I could make it a proper attack tool with commands being received and sent. And it's got proper print after debugging. So if you plug into the ST link at the top you can debug this thing fully extremely easily. The pin configurations on it can be set using the STM32Cube software suite which basically allows you to click on the chip, decide which one you're gonna work with and set what each pin does. Like if you want to be a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, a timer, an external GPIO and set the clock right. Uh now the clock right was very important because this thing wouldn't be able to synchronise with a strange uh speed like 13.56 megahertz. So because of this I decided to find a the clock speed that it would support that was closest to what I wanted. Um when this occurred I basically um decided I didn't wanna use an external crystal. The thing that already had one and it would involved some SMD soldiering and it could have broken the device. Because of this I wanted to uh look at all the range of frequencies and the frequency that I could develop and frequencies that um it could run out which was a huge amount and find the one that had the most suitable candidate. Now this was important because um My Fair Classic and all other NFC in this area uses uh Manchester coding for the responses which means it's inherently got this ability to uh keep track of the timing and the frequency that's going on so that if you get out of sync with it eventually it can pick it back up again. So I looked through all the possible values it can be and found that 72 megahertz was the fastest and the least um problematic um value I could use. So it was only um gonna be about um what 50% hour um speed. So this is the device I made again extremely simple. Big coil of wire, capacitor, diode, resistor and another capacitor and that's all I need to needed to convert this device into an NFC tag that we use to perform attacks in this platform. It's extremely simple but effective and I really didn't want to do anything far too complex because it just wouldn't be necessary. I wanted to add a lot of different features to this especially ones that weren't present in a makes in a commercial devices like the Proxmark and Chameleon not because these devises aren't excellent but because if I'm just covering their work it's just not fun anymore. So I made it so it like more that one tag at once. Now this is a very useless uh ability but it would mean that I could put it on the reader and the reader would think there was two tags. This could've caused authentication issues, communication issues and make the thing just get very confused. So this could be handled this by just taking the same state machine that's been created and making sure that the responses uh matched what'd happened if there were two tags in the ein either forcing anti-collision by sending randomised data when selections were made or by cascading requests so one tag was selected, wait for it to be selected and then bring up the other one in it. There was not a huge amount of weaknesses I could find with this but I thought it was quite interesting. Dynamic Crypto 1 key generation was another one. Now this would allow me to uh make a number of different UIDs and basically cycle through them while also changing the encryption keys being used. This allowed me to quickly work out how the uh authentication was working and help me more easily generate tags based on what I wanted to do from random data but also change the keys to match. This is because a large number of these devices um authenticate using keys generated from the unique identifiers so that it's not the same for every single uh tag that's being put in the field. Now this is very useful but um it can cause some problems with authentication in general. I wanted to implement Desifier which has been implemented on a few um uh forked versions of Proxmox. So I wanted to implement Proxmox and Chameleon Mini but not in the mainline versions as far as I know. Now you can make the thing pretend to be one of these just by modifying the SAK and ATQA values that the tag would present and make sure the response values matched as needed. Um I basically uh wanted to replay any legitimate responses I get from a reader so I took a Desifier tag, put it against my phone and see how- saw how it read and sort of replicated that as I went along as it um basically just went through each part- section of this. Um the authentication functionality is well documented and as there's source code about now to work with this it makes things a lot easier to work with. I took the Myfair Desi- Desifier tool which uh is um an Android application you get in Google Play and basically taped my phone to the STM32 device and basically ran it every so often to see how I could me- mess with the responses in order to get the thing to work. Literally taking my phone and sticking it on top of the device. Now let's talk about security weaknesses a bit. So we've gone through how we build these attack tools. Let's talk about some interesting security weaknesses on this platform. Um so CryptoOne, um I've been using CryptoOne for a while. CryptoOne which is still used everywhere in Myfair Classic Tags has been well known to be absolutely useless. It has little to no fun- um security in the same way that WEP keys no longer do. And it's important that people still know why they're weak for the same reason that we should still know why WEP is weak. So it utilizes a 48 bit key split into two 20 or 4 bit keys that cycle between as authentication and encryption is happening. Making things a lot uh stranger than you'd see in a traditional keying scheme. Um it's vulnerable to replay attacks if the same requests are made from the reader you can respond to them in the same way as you would in a normal system in the same way. But there are weaknesses in the nonce authentication mechanism that allows you to recover 32 bits of the key stream and use that key stream to generate the keys eventually. So key recovery for a sector can be achieved basically by allowing the authentication to get to the point where the reader has sent it's response to the nonce during the authentication. Uh you then take this value and and generate that encryptor value yourself because you know what the nonce is and you know the amount of cycles you need to go through the PRNG. XOR it with the um um um um um um um um um um um um um um um um um um um um um um um um um um uh values being sent by the reader and this allows you to have this key stream you can work with. You then take the two 24 bit keys or all the 24 bits of keys you can think of. This is only 16 million which isn't a huge amount and for each alternating section that's 16 bits out of the 32 um you try and find all those keys that would potentially match that authenti- that stream. Now this will create about 200,000 if you do it one way and about 33- 30,000 the other way and this um basically can be used to get you enough of the 24 bit keys to reduce from a 48 bit key uh user in trying to search through to something like a 48- 40 million keys to search through which is a lot quicker. Um then you can roll back through the initial authentication cause you know how that works and get to the point of the state of the key stream where the keys are what they would be when the things start and that makes the- gives you the keys. So authentication is requested. A simple nonce is sent back. Um the randomized data and the um encrypted nonce is uh sent by the reader and that's all you need in order to get on to the key stream. So that's how you get on to this and start attacking the keys. Oh okay. I've not got to the good part yet you know. Believe me. Um so this can be used for offline cracking so rather than having to stand next to an NFC reader you can go up, wave a device in front of the reader, get this authentication, go away, not for very long even about 10 minutes and get the keys back. Um it's a bit more complex than that but that's the long and short of it really. Um this is more efficient than reader based attacks which often have very uh weird scientific and stati- statistical approaches and is more like traditionally kept cracking in the same way again as you would crack a web key just attacking the stream cipher that's being used. Um this functionality is already available and well known but it's never used because it's really really not very efficient to work with. I decided to implement this with a bit of a demo with um a few toys I had around my flat from my uh recent visits to Japan. So I had a uh MyFair Classic Reader from a Japanese video game uh based on the Carmen So I had a MyFair Classic Reader from a Japanese video game uh based on the Carmen Rider series which I'd never heard of before. Uh this was basically a USB device you'd plug into your Playstation and it would um communicate by you putting tags on top of it which were shaped like toys giving you access to those characters in the game. The reader was identified to use the USB and allowed me to uh use uh man in the middle attacks using my BeagleBone Black and the Uzi- USB proxy toolchain which allows you to basically um man in the middle USB communications between a uh host device usually a black box host device and the uh USB device itself. Analyze the entire protocol allowing you to reverse engineer it and make your own uh libUSB based tools to attack this. Um I did that and took my um STM32 and just laid it on top of the board so that I could then send authentication requests to it by using the reverse engineered USB protocol. Um so I made it print out section numbers, information basically from the STM32 based on what's being requested by that USB reader from what I told it to. This allowed me to um reverse engineer more about how the key generation works. So I made it print out section numbers, information basically from the browser and this allowed me to uh um refract but also very quickly brute for us a huge number of keys based on a huge number of new IDs which I could use to basically emulate anything it wanted to. Purely for the purposes to showing these uh uh encryption keys are just weakness and ate to a terrible extent. And yet, if you go to most places in England which have door access controls you'll still see this technology being used. It's very surprising. So um so here's uh how it works, it got the authentication, uh ran through all the uh um authentication and um encryption data and got a test sent. When we sent it we were uh surprisingly no 나오는 of, uh key out in under 10 minutes which is incredibly fast and that was on a 1 core i5 laptop. Um improvements that could have been made to this uh algorithm include increasing the key size significantly. Even bringing it to 64 bits which wouldn't be hugely stringent would have made this a lot harder to do which would make things more secure and make some of these attacks just not possible. Using a single large key rather than 2 keys that are played off against each other would mean I'd have to brute force every single one of the keys in that bit um bit range rather than 2 24 bit keys which is just 16 million values and very quick to do. And an improved PRN PRNG would prevent the replay attacks that could occur from occurring. Removing any known plain text from authentication removed the opportunity for exploitation as well. Now this is important especially when you look at things that are newer like DES fire which have somewhat similar uh known plain text issues basically based on how the tag works but because AES triple DES and DES really aren't vulnerable to uh known plain text attacks in the same way. There's no real problem there. So let's talk about some raw protocol weaknesses. Now the raw protocol weaknesses are important because even with like traditional NFC chips that are dedicated for that purpose you can attack things like NDEF and other more high level issues but you can't attack the enumeration level because if they hadn't implemented that then there wouldn't be very much point in having NFC chip chipset in the first place. Um the big thing is that initial enumeration that's sending requests to identify unique identifiers uh is performed by all tag types of this range meaning that if I found an attack there that was viable on the readers that would be very useful in a lot of places. Um a big thing as well that I noticed was I could send a lot of uh data basically fuzzing responses to requests in order to see if the uh device would crash or get confused. This sometimes happened but it wasn't really a viable attack. I found that the greatest weaknesses lie in the anti-collision procedures myself. Now I like this bit of the documentation of Texas Instruments uh pseudo code for tag detection. Uh the note is extremely important. Uh I found that the greatest weaknesses lie in the anti-collision algorithm. Due to the highly recursive nature of the anti-collision algor- algorithm there's a risk of stack overflow. It is highly recommended that the user implement the stack overflow check. Which is not very good cause they never bloody do. What they often do is just ignore this technology entirely and don't use anti-collision. But when they do they've never done it properly and it's always got problems. So what I ended up doing was making my tool respond over and over and over again to any authentication that happened pretending that there was an infinite number of tags on the reader at that time by basically every time it uh uh trying to use anti-collision on it forcing it to just send garbage data. By doing this over and over and over again eventually the reader would just keep asking for more and more data past the maximum size for a unique identifier. Eventually allowing the device to crash and I'm fairly sure if I tried harder I could have got some real cool buffer overflow weaknesses from this. Um as I said before there's high level weaknesses that are basically um usable on traditional chipsets um even some Android phones including NDEF data which has some uh issues with memory corruption and authentication mechanisms which can be worked with on all sides. Um the big problem that I found was that most tags just haven't got enough power in them to do proper authentication or anything like that in them. Even if they were dedicated for that purpose. So I made this. It's a sonic screwdriver. A toy one which is now full with all the tools that I've just talked about. And I've got it with me. It's got four modes so far. It's got traditional NFC tag, fuzzing, transmission of um ASK uh data basically it's got an ASK transmitter in the handle which transmits any authentication being sent from a reader to the device allowing someone with a laptop and an SDR far away from me to get the authentication keys back and um dump the data. Now I decided to use a much smaller but still quite powerful chip for this. An STM32F070 which is a very small TSOP chip but has Wayne more power than even the ATtiny which was a lot larger. So I had 32k of flash and 6k of RAM. Um it had a recommended clock speed of uh 48 megahertz but it had been pushed a lot further like 72 megahertz. So I could basically copy and paste a lot of the code I'd done tradition- before and make it still work. And by drag soldering onto a breakout board I could literally load it into the sonic screwdriver and get it working. Um I decided to um basically uh make it programmable from the top so I could add extra features as I go along. I've added more features since these slides were made so there it says three now it has four. But because it's got three LEDs on it I could get up to seven if I really wanted to. Um I managed to use the internal clock on the device rather than having to use an external one keeping the amount of um uh hardware inside it very low which was necessary because there wasn't a lot of room in the case. It's using a uh lithium ion battery um in order to power it in order to keep the power high. And what's interesting about it at the moment is it's using the battery from my Nintendo DS because at the last minute the battery I had in it exploded. Um I'm gonna talk about some future work. I'm gonna release all the source code for this hopefully uh soon. And I'm gonna design some boards to go along with it to make it a lot easier for people to work with um because if I can make a simple DIP package um board that people can solder themselves it'd be a lot more fun for people to work with. I'm gonna work with Desfire more and try and implement it fully and try and find attacks on it and see if I can find any tag types that I haven't yet worked with. Um I'll take some questions now but um I'm also gonna be in the hardware hacking village at 5 o'clock to answer any questions and do a follow up talk where I'll go through the really really really low date um low low level details of what I did to develop this project. Um thank you very much. Any questions? Oh. Ok so did you investigate any hidden NFC in the software? Um I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. I haven't. No. Now libNFC is a great tool that's used by most people for um that makes their NFC communication. I just haven't had a chance to look at it yet unfortunately. Anyone else? Fine. Thank you very much.