- UsbCommand c = {CMD_SIMULATE_TAG_ISO_14443a,{0,0,0}};
-
- // Retrieve the tag type
- uint8_t tagtype = param_get8ex(Cmd,0,0,10);
-
- // When no argument was given, just print help message
- if (tagtype == 0) {
- PrintAndLog("");
- PrintAndLog(" Emulating ISO/IEC 14443 type A tag with 4 or 7 byte UID");
- PrintAndLog("");
- PrintAndLog(" syntax: hf 14a sim <type> <uid>");
- PrintAndLog(" types: 1 = MIFARE Classic");
- PrintAndLog(" 2 = MIFARE Ultralight");
- PrintAndLog(" 3 = MIFARE DESFIRE");
- PrintAndLog(" 4 = ISO/IEC 14443-4");
- PrintAndLog(" 5 = MIFARE TNP3XXX");
- PrintAndLog("");
- return 1;
- }
-
- // Store the tag type
- c.arg[0] = tagtype;
-
- // Retrieve the full 4 or 7 byte long uid
- uint64_t long_uid = param_get64ex(Cmd,1,0,16);
-
- // Are we handling the (optional) second part uid?
- if (long_uid > 0xffffffff) {
- PrintAndLog("Emulating ISO/IEC 14443 type A tag with 7 byte UID (%014"llx")",long_uid);
- // Store the second part
- c.arg[2] = (long_uid & 0xffffffff);
- long_uid >>= 32;
- // Store the first part, ignore the first byte, it is replaced by cascade byte (0x88)
- c.arg[1] = (long_uid & 0xffffff);
- } else {
- PrintAndLog("Emulating ISO/IEC 14443 type A tag with 4 byte UID (%08x)",long_uid);
- // Only store the first part
- c.arg[1] = long_uid & 0xffffffff;
+ bool errors = FALSE;
+ uint8_t flags = 0;
+ uint8_t tagtype = 1;
+ uint64_t uid = 0;
+ uint8_t cmdp = 0;
+
+ while(param_getchar(Cmd, cmdp) != 0x00)
+ {
+ switch(param_getchar(Cmd, cmdp))
+ {
+ case 'h':
+ case 'H':
+ return usage_hf_14a_sim();
+ case 't':
+ case 'T':
+ // Retrieve the tag type
+ tagtype = param_get8ex(Cmd, cmdp+1, 0, 10);
+ if (tagtype == 0)
+ errors = true;
+ cmdp += 2;
+ break;
+ case 'u':
+ case 'U':
+ // Retrieve the full 4 or 7 byte long uid
+ uid = param_get64ex(Cmd, cmdp+1, 0, 16);
+ if (uid == 0 )
+ errors = TRUE;
+
+ if (uid > 0xffffffff) {
+ PrintAndLog("Emulating ISO/IEC 14443 type A tag with 7 byte UID (%014"llx")",uid);
+ flags |= FLAG_7B_UID_IN_DATA;
+ } else {
+ PrintAndLog("Emulating ISO/IEC 14443 type A tag with 4 byte UID (%08x)",uid);
+ flags |= FLAG_4B_UID_IN_DATA;
+ }
+ cmdp += 2;
+ break;
+ case 'x':
+ case 'X':
+ flags |= FLAG_NR_AR_ATTACK;
+ cmdp++;
+ break;
+ default:
+ PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
+ errors = true;
+ break;
+ }
+ if(errors) break;