int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {\r
UsbCommand c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, blockBtWidth}};\r
memcpy(c.d.asBytes, data, blocksCount * blockBtWidth); \r
-\r
clearCommandBuffer();\r
SendCommand(&c);\r
return 0;\r
}\r
\r
// "MAGIC" CARD\r
-\r
int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_t wipecard) {\r
\r
uint8_t params = MAGIC_SINGLE;\r
}\r
\r
// SNIFFER\r
+// [iceman] so many global variables....\r
\r
// constants\r
static uint8_t trailerAccessBytes[4] = {0x08, 0x77, 0x8F, 0x00};\r
static uint8_t traceCurKey = 0;\r
\r
struct Crypto1State *traceCrypto1 = NULL;\r
-\r
struct Crypto1State *revstate = NULL;\r
\r
uint64_t key = 0;\r
int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {\r
\r
uint8_t data[64];\r
-\r
+ memset(data, 0x00, sizeof(data));\r
+ \r
if (traceState == TRACE_ERROR) return 1;\r
\r
if (len > 64) {\r
}\r
\r
// AUTHENTICATION\r
- if ((len == 4) && ((data[0] == 0x60) || (data[0] == 0x61))) {\r
+ if ((len == 4) && ((data[0] == MIFARE_AUTH_KEYA) || (data[0] == MIFARE_AUTH_KEYB))) {\r
traceState = TRACE_AUTH1;\r
traceCurBlock = data[1];\r
traceCurKey = data[0] == 60 ? 1:0;\r
}\r
\r
// READ\r
- if ((len ==4) && ((data[0] == 0x30))) {\r
+ if ((len ==4) && ((data[0] == ISO14443A_CMD_READBLOCK))) {\r
traceState = TRACE_READ_DATA;\r
traceCurBlock = data[1];\r
return 0;\r
}\r
\r
// WRITE\r
- if ((len ==4) && ((data[0] == 0xA0))) {\r
+ if ((len ==4) && ((data[0] == ISO14443A_CMD_WRITEBLOCK))) {\r
traceState = TRACE_WRITE_OK;\r
traceCurBlock = data[1];\r
return 0;\r
}\r
\r
// HALT\r
- if ((len ==4) && ((data[0] == 0x50) && (data[1] == 0x00))) {\r
+ if ((len ==4) && ((data[0] == ISO14443A_CMD_HALT) && (data[1] == 0x00))) {\r
traceState = TRACE_ERROR; // do not decrypt the next commands\r
return 0;\r
}\r