- while(! WaitForResponseTimeout(CMD_ACK,&resp,1500)) {\r
- //We're waiting only 1.5 s at a time, otherwise we get the\r
- // annoying message about "Waiting for a response... "\r
+ \r
+ uint8_t data[40];\r
+ uint8_t key[6];\r
+\r
+ UsbCommand resp; \r
+ while(!ukbhit() ){\r
+ if ( WaitForResponseTimeout(CMD_ACK,&resp,1500) ) {\r
+ if ( (resp.arg[0] & 0xffff) == CMD_SIMULATE_MIFARE_CARD ){\r
+ memset(data, 0x00, sizeof(data));\r
+ memset(key, 0x00, sizeof(key));\r
+ int len = (resp.arg[1] > sizeof(data)) ? sizeof(data) : resp.arg[1];\r
+ \r
+ memcpy(data, resp.d.asBytes, len);\r
+ \r
+ uint64_t corr_uid = 0;\r
+ if ( memcmp(data, "\x00\x00\x00\x00", 4) == 0 ) {\r
+ corr_uid = (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | data[0];\r
+ }\r
+ else {\r
+ corr_uid |= (uint64_t)data[2] << 48; \r
+ corr_uid |= (uint64_t)data[1] << 40; \r
+ corr_uid |= (uint64_t)data[0] << 32;\r
+ corr_uid |= data[7] << 24;\r
+ corr_uid |= data[6] << 16;\r
+ corr_uid |= data[5] << 8;\r
+ corr_uid |= data[4];\r
+ }\r
+ tryMfk32(corr_uid, data, key);\r
+ //tryMfk64(corr_uid, data, key);\r
+ PrintAndLog("--");\r
+ }\r
+ }\r