+int CmdIOClone(const char *Cmd) {
+
+ uint32_t blocks[3] = {T55x7_MODULATION_FSK2a | T55x7_BITRATE_RF_64 | 2 << T55x7_MAXBLOCK_SHIFT, 0, 0};
+ uint16_t cn = 0;
+ uint8_t version = 0, fc = 0;
+ uint8_t bits[64];
+ uint8_t *bs=bits;
+ memset(bs,0,sizeof(bits));
+
+ char cmdp = param_getchar(Cmd, 0);
+ if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_io_clone();
+
+ version = param_get8(Cmd, 0);
+ fc = param_get8(Cmd, 1);
+ cn = param_get32ex(Cmd, 2, 0, 10);
+
+ if ( !version | !fc || !cn) return usage_lf_io_clone();
+
+ if ((cn & 0xFFFF) != cn) {
+ cn &= 0xFFFF;
+ PrintAndLog("Card Number Truncated to 16-bits (IOProx): %u", cn);
+ }
+
+ if (param_getchar(Cmd, 3) == 'Q' || param_getchar(Cmd, 3) == 'q')
+ //t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
+ blocks[0] = T5555_MODULATION_FSK2 | T5555_INVERT_OUTPUT | ((50-2)>>1) << T5555_BITRATE_SHIFT | 2 << T5555_MAXBLOCK_SHIFT;
+
+ if ( !getIOProxBits(version, fc, cn, bs)) {
+ PrintAndLog("Error with tag bitstream generation.");
+ return 1;
+ }
+
+ blocks[1] = bytebits_to_byte(bs,32);
+ blocks[2] = bytebits_to_byte(bs+32,32);
+
+ PrintAndLog("Preparing to clone IOProx to T55x7 with Version: %u FC: %u, CN: %u", version, fc, cn);
+ PrintAndLog("Blk | Data ");
+ PrintAndLog("----+------------");
+ PrintAndLog(" 00 | 0x%08x", blocks[0]);
+ PrintAndLog(" 01 | 0x%08x", blocks[1]);
+ PrintAndLog(" 02 | 0x%08x", blocks[2]);
+ //UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}};
+ UsbCommand c = {CMD_IO_CLONE_TAG, {blocks[1],blocks[2],0}};
+ clearCommandBuffer();
+ SendCommand(&c);
+ return 0;