51 #define MAX_FRAME_LEN 264
52 #define MAX_DEVICE_COUNT 2
54 static byte_t abtReaderRx[MAX_FRAME_LEN];
55 static byte_t abtReaderRxPar[MAX_FRAME_LEN];
56 static size_t szReaderRxBits;
57 static byte_t abtTagRx[MAX_FRAME_LEN];
58 static byte_t abtTagRxPar[MAX_FRAME_LEN];
59 static size_t szTagRxBits;
62 static bool quitting =
false;
67 printf (
"\nQuitting...\n");
73 print_usage (
char *argv[])
75 printf (
"Usage: %s [OPTIONS]\n", argv[0]);
76 printf (
"Options:\n");
77 printf (
"\t-h\tHelp. Print this message.\n");
78 printf (
"\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
82 main (
int argc,
char *argv[])
85 bool quiet_output =
false;
91 for (arg = 1; arg < argc; arg++) {
92 if (0 == strcmp (argv[arg],
"-h")) {
95 }
else if (0 == strcmp (argv[arg],
"-q")) {
98 ERR (
"%s is not supported option.", argv[arg]);
105 printf (
"%s use libnfc %s\n", argv[0], acLibnfcVersion);
108 signal (SIGINT, (
void (__cdecl *) (
int)) intr_hdlr);
110 signal (SIGINT, (
void (*)()) intr_hdlr);
114 if (!(pnddDevices = malloc (MAX_DEVICE_COUNT *
sizeof (*pnddDevices)))) {
115 fprintf (stderr,
"malloc() failed\n");
122 ERR (
"%zd device found but two connected devices are needed to relay NFC.", szFound);
127 if (pndTag == NULL) {
128 printf (
"Error connecting NFC emulator device\n");
132 printf (
"Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
134 printf (
"Connected to the NFC emulator device: %s\n", pndTag->
acName);
135 printf (
"[+] Try to break out the auto-emulation, this requires a second reader!\n");
136 printf (
"[+] To do this, please send any command after the anti-collision\n");
137 printf (
"[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
140 .nm.nmt = NMT_ISO14443A,
141 .nm.nbr = NBR_UNDEFINED,
142 .nti.nai.abtAtqa = { 0x04, 0x00 },
143 .nti.nai.abtUid = { 0xde, 0xad, 0xbe, 0xef },
144 .nti.nai.btSak = 0x20,
145 .nti.nai.szUidLen = 4,
146 .nti.nai.szAtsLen = 0,
150 ERR (
"%s",
"Initialization of NFC emulator failed");
154 printf (
"%s",
"Configuring emulator settings...");
160 printf (
"%s",
"Done, emulated tag is initialized");
165 printf (
"Connected to the NFC reader device: %s", pndReader->
acName);
166 printf (
"%s",
"Configuring NFC reader settings...");
174 printf (
"%s",
"Done, relaying frames now!");
180 if (szReaderRxBits == 7 && abtReaderRx[0] == 0x26) {
196 print_hex_par (abtReaderRx, szReaderRxBits, abtReaderRxPar);
200 (pndReader, abtReaderRx, szReaderRxBits, abtReaderRxPar, abtTagRx, &szTagRxBits, abtTagRxPar)) {
209 print_hex_par (abtTagRx, szTagRxBits, abtTagRxPar);