Inorder to implement a RFID reader as card emulator, we should be able to program the hardware using specific configuration commands to initialize it in that specific mode. Those commands could be Pseudo APDUs or Native orders. You can learn more about that from my first post about NFC.
To mimic a contactless card behavior, an emulation is required. Some users could implement a RFID device as contactless card to make transactions, validate an individual entrance or to access certain building or hotel. The idea of emulating is not very well documented for many different reasons. The first could be that it is difficult to implement a native language to talk to the card reader, and it changes depending of the native chip.
Moreover, the main reason to learn how to emulate a contactless card is to be prepared and aware about the dangerous scenarios and limitations of the NFC payment technology. How to test these methodologies or how to create a new NFC penetration testing tool are essential. Some of these realistic attacks using emulation were presented at DEF CON 25, for example, the Man in the NFC talk.
Of course, security by obscurity should not be implemented, instead of that, companies have to applied, in a correct way, established protocols such as distance bounding to avoid any NFC technology exploitation by relay attacks; Also a better tokenization design to protect the NFC technology against replay attacks.
The ACR122u is a special device. It could be implemented in different ways. I personally use it as RFID reader or emulator. To understand more about the hardware, I recommend to take a look a its datasheet.
One thing to have in mind is that we are talking directly to the hardware, so we can access special places to extract data, even we can change behaviors in the ACR122u hardware components. This is important because with the right command, we may change the light, mode or buzzer configuration.
As usual, I will start with a list of components to understand the process of emulation. These code examples were tested in a Mac OS 10.13.1 and Python 2.7. The Smartcard library that I am implementing with Python is pyscard to control the communication with the reader. The RFID is the USB ACR122u.
The next thing is to select what type of protocol we will use to communicate to the RFID. There are two protocols: T0 or T1. The T0 is byte-oriented half duplex transmission protocol, and the T1 is a block-oriented half duplex protocol. The T0 has a low memory capacity while the T1 has a error detection by the end of the blocks. Note: half duplex means that it can send OR transmit data only, not both tasks at the same time.
We can do it manually and create the arrays or lists with all the commands from the datasheet, but we do not have to. Why? because Adam Laurie made that difficult task for us. In his RFIDIOt repository, we can find a complete framework with all the structures necessary to make a smooth communication to the reader. If we take a quick look at his code, we can find all the important commands from the ACR122u datasheet:
Here is the tricky part. Instead of sending normal APDUs using the connection that we just created, we have to initialize the reader as emulator sending Pseudo APDU and Native commands. If we take a closer look at the Adam Laurie repository, we can find that he also has a skeleton emulation example for the PN532 chip. That code in specific is in the pn532emulate.py file.
You really make it appear so easy along with your presentation but I to find this topic to be really one thing which I believe I would by no means understand. It kind of feels too complex and very broad for me. I am taking a look ahead in your subsequent put up, I will attempt to get the dangle of it!
I want to create applications based on using contactless technology. I worked for over thirty years for my father in his company that built and sold its own communications concentrating server. As such, writing device driver support was an everyday thing. Your blog is SO KOOL! Thanks.
You can see that the board includes an etched coil to interact with an RFID reader. This is the sole source of power for the device, letting it pick up enough induced current from the reader to power the PIC 12F683 seen on the upper left of the board. The underside of the PCB hosts just three components: an LED and two switches. One of the switches puts the device in learning mode. Just hold down that button as you move the board into the magnetic field of the reader. While in learning mode a second RFID tag is held up to the reader. It will identify itself and the emulator will capture the code sent during that interaction. This is all shown of in the video after the break. We wonder how hard it would be to make a version that can store several different codes selected by holding down a different button as the emulator is held up to the reader?
To be honest you would have to have the targets tag to do the copy, because it would be painfully obvious that your are up to no good if you put the cloner up to the reader at the same time your targets card is presented.
3a8082e126