44 #endif // HAVE_CONFIG_H
58 #define MAX_FRAME_LEN 264
60 static byte_t abtRecv[MAX_FRAME_LEN];
61 static size_t szRecvBits;
65 byte_t abtAtqa[2] = { 0x04, 0x00 };
66 byte_t abtUidBcc[5] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x62 };
67 byte_t abtSak[9] = { 0x08, 0xb6, 0xdd };
72 printf (
"\nQuitting...\n");
80 print_usage (
char *argv[])
82 printf (
"Usage: %s [OPTIONS] [UID]\n", argv[0]);
83 printf (
"Options:\n");
84 printf (
"\t-h\tHelp. Print this message.\n");
85 printf (
"\t-q\tQuiet mode. Silent output: received and sent frames will not be shown (improves timing).\n");
87 printf (
"\t[UID]\tUID to emulate, specified as 8 HEX digits (default is DEADBEEF).\n");
91 main (
int argc,
char *argv[])
95 bool quiet_output =
false;
101 for (arg = 1; arg < argc; arg++) {
102 if (0 == strcmp (argv[arg],
"-h")) {
105 }
else if (0 == strcmp (argv[arg],
"-q")) {
106 printf (
"Quiet mode.\n");
108 }
else if ((arg == argc - 1) && (strlen (argv[arg]) == 8)) {
109 byte_t abtTmp[3] = { 0x00, 0x00, 0x00 };
110 printf (
"[+] Using UID: %s\n", argv[arg]);
112 for (i = 0; i < 4; ++i) {
113 memcpy (abtTmp, argv[arg] + i * 2, 2);
114 abtUidBcc[i] = (byte_t) strtol ((
char *) abtTmp, NULL, 16);
115 abtUidBcc[4] ^= abtUidBcc[i];
118 ERR (
"%s is not supported option.", argv[arg]);
125 signal (SIGINT, (
void (__cdecl *) (
int)) intr_hdlr);
127 signal (SIGINT, (
void (*)()) intr_hdlr);
134 printf (
"Unable to connect to NFC device\n");
139 printf (
"Connected to NFC device: %s\n", pnd->
acName);
140 printf (
"[+] Try to break out the auto-emulation, this requires a second NFC device!\n");
141 printf (
"[+] To do this, please send any command after the anti-collision\n");
142 printf (
"[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n");
146 .nm.nmt = NMT_ISO14443A,
147 .nm.nbr = NBR_UNDEFINED,
148 .nti.nai.abtAtqa = { 0x04, 0x00 },
149 .nti.nai.abtUid = { 0x08, 0xad, 0xbe, 0xef },
150 .nti.nai.btSak = 0x20,
151 .nti.nai.szUidLen = 4,
152 .nti.nai.szAtsLen = 0,
156 ERR (
"Could not come out of auto-emulation, no command was received");
159 printf (
"[+] Received initiator command: ");
160 print_hex_bits (abtRecv, szRecvBits);
161 printf (
"[+] Configuring communication\n");
166 printf (
"[+] Done, the emulated tag is initialized with UID: %02X%02X%02X%02X\n\n", abtUidBcc[0], abtUidBcc[1],
167 abtUidBcc[2], abtUidBcc[3]);
173 switch (szRecvBits) {
199 print_hex_bits (abtRecv, szRecvBits);
210 print_hex_bits (pbtTx, szTxBits);