Hello, Habr.

Recently, I had the opportunity to test a payment terminal with the possibility of contactless payment. Well, since the payment is contactless, it means that the signal is transmitted by radio, and of course, I could not give up the temptation to look with the SDR receiver what kind of data is transmitted and received during the payment.

ITKarma picture
Photo (s) Verifone

For those who are interested in how this works, a few details are under the cat.

It should be noted right away that I have no official description of the protocol for exchanging a terminal with a card, such data is usually distributed only to partner companies after signing the NDA, but no one forbids us to listen to the air and make any assumptions.

So let's get started.

Signal spectrum


Let's start with the simplest thing - start the receiver, turn on the terminal, make payment and see what is on the air. The signal search turns out to be elementary, a huge peak at a frequency of 13.56 MHz is visible:

ITKarma picture

The signal level is not surprising, because it should be enough for inductive communication with a card that does not have its own power source. As Google suggests, 13.56MHz is the standard frequency for RFID devices. The symmetry of the signal suggests the possible use of AM modulation.

Now that the signal has been found, it’s easy to look at it in more detail and see the different phases of payment:

ITKarma picture

Let's consider them in more detail.

1. Idle Mode


In this mode, the terminal does not emit anything, only the logo of the bank or store is displayed on the screen.

2. Payment request and card pending


The cashier initiates a payment for a certain amount. At this point, the terminal enters the standby mode of payment. Payment by card can be made either using a magnetic strip, or by inserting a card, or by the contactless method that interests us. To determine when the card was brought to the terminal, a request is sent every 0.12s. Short parcels in the form of vertical lines on the spectrum, in an enlarged form, look like this:

ITKarma picture

It is clearly seen that the data is repeated. The data block (“by eye”, 24 or 32 bits) most likely contains a bitmask containing the card formats supported by this reader. At least to other cards (for example, transport), the reader does not “respond”.

3. Data exchange with the card


When a card is detected, its controller in response sends its data - probably the card number and service information. There is no power supply in the card itself, so the response from it is very weak in power. As you can see, the card sends its answer to each terminal request, the “radio exchange” between them is quite active:

ITKarma picture

The enlarged signal received from the card looks something like this:

ITKarma picture

4. Card Verification


When the card data is received, the terminal probably checks the encryption keys on the card, the process takes about 0.6s. The RFID module is currently disabled. Perhaps the terminal is requesting card status online.

5. Awaiting Card Withdrawal


At that moment when the terminal read all the data and checked the card, the message “remove the card” is displayed on the screen, every 5ms the terminal checks whether the card is in place:

ITKarma picture

We see the same messages, the response of the card is also visible.In an enlarged view, you can show the moment the card stopped responding:

ITKarma picture

The answer from the card itself, by the way, is quite simple and short, "by eye", no more than 24 bits:

ITKarma picture

This ends the radio exchange, and with all the data received, the terminal sends a request for payment to the bank. A response comes from the bank, and if the payment is successful, we receive our goods.

Conclusion


As you can see, at the binary level, everything is quite simple. The RFID protocol uses conventional amplitude modulation, no rocket science. But of course, the main work is done at a logical level, checking the card and making a payment is a rather complicated process, which also involves encryption. For those who want to study the topic in more detail, you can find useful comments from users rizorko and lil_Toady , where you can find links to standards.

Finally, you can answer the question that many are probably interested in: is it possible to covertly withdraw money from someone else's card at a great distance. Judging by the analysis of the radio signal, we can say that this is very unlikely. Firstly, the card itself does not have a built-in power supply - for its processor to work, the field strength must be very large. The normal reading distance of the card is 2-3 cm, in order to increase it to at least 100 cm, the field strength should be in the third degree greater than this difference. The second point is receiving a response from the card - its signal is very weak, and it is also not easy to receive it at a great distance (plus do not forget that the wavelength with a frequency of 13 MHz is about 20 meters, and short antennas at such wavelengths are inefficient). Finally, do not forget about the organizational aspects - each payment terminal is linked to the bank account of a legal entity, and if there are complaints about debiting funds, this account can simply be blocked. The terminal itself, by the way, has a unique ID, and if it is constantly tied to different accounts, this will also be suspicious. In general, although a theoretically remote reading of RFID may be possible, judging by this article , there have been no real cases of such withdrawals. And finally, the limit of contactless payments is very small, so the “profit” probably will not correspond to the risk and cost of the equipment.

Source