\r
for (i=0 ; i<16 ; i++) {\r
for (j=0 ; j<4 ; j++) {\r
- \r
if (j == 3){\r
UsbCommand c = {CMD_MIFARE_READBL, {i*4 + j, 0, 0}};\r
memcpy(c.d.asBytes, keyA[i], 6);\r
if (resp != NULL) {\r
uint8_t isOK = resp->arg[0] & 0xff;\r
uint8_t *data = resp->d.asBytes;\r
+ if (j == 3) {\r
+ data[0] = (keyA[i][0]);\r
+ data[1] = (keyA[i][1]);\r
+ data[2] = (keyA[i][2]);\r
+ data[3] = (keyA[i][3]);\r
+ data[4] = (keyA[i][4]);\r
+ data[5] = (keyA[i][5]);\r
+ data[10] = (keyB[i][0]);\r
+ data[11] = (keyB[i][1]);\r
+ data[12] = (keyB[i][2]);\r
+ data[13] = (keyB[i][3]);\r
+ data[14] = (keyB[i][4]);\r
+ data[15] = (keyB[i][5]);\r
+ }\r
if (isOK) {\r
fwrite ( data, 1, 16, fout );\r
}\r
\r
int createDumpFile = 0;\r
FILE *fkeys;\r
+ uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
+ uint8_t tempkey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
\r
char cmdp, ctmp;\r
\r
}\r
\r
ctmp = param_getchar(Cmd, 4);\r
- if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
+ if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
+ else if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;\r
+ \r
ctmp = param_getchar(Cmd, 6);\r
transferToEml |= (ctmp == 't' || ctmp == 'T');\r
- createDumpFile |= (ctmp == 'd' || ctmp == 'D');\r
+ transferToEml |= (ctmp == 'd' || ctmp == 'D');\r
\r
PrintAndLog("--block no:%02x key type:%02x key:%s etrans:%d", blockNo, keyType, sprint_hex(key, 6), transferToEml);\r
if (cmdp == 'o')\r
} else {\r
PrintAndLog("No valid key found");\r
}\r
- } else // ------------------------------------ multiple sectors working\r
- {\r
+ }\r
+ else { // ------------------------------------ multiple sectors working\r
blDiff = blockNo % 4;\r
PrintAndLog("Block shift=%d", blDiff);\r
e_sector = calloc(SectorsCnt, sizeof(sector));\r
}\r
} \r
\r
- \r
// nested sectors\r
iterations = 0;\r
PrintAndLog("nested...");\r
} \r
}\r
\r
+ // Create dump file\r
if (createDumpFile) {\r
if ((fkeys = fopen("dumpkeys.bin","wb")) == NULL) { \r
PrintAndLog("Could not create file keys.bin");\r
free(e_sector);\r
return 1;\r
}\r
+ PrintAndLog("Printing keys to bynary file dumpkeys.bin...");\r
for(i=0; i<16; i++) {\r
- fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[0]), 1, fkeys );\r
+ if (e_sector[i].foundKey[0]){\r
+ num_to_bytes(e_sector[i].Key[0], 6, tempkey);\r
+ fwrite ( tempkey, 1, 6, fkeys );\r
+ }\r
+ else{\r
+ fwrite ( &standart, 1, 6, fkeys );\r
+ }\r
}\r
for(i=0; i<16; i++) {\r
- fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[1]), 1, fkeys );\r
+ if (e_sector[i].foundKey[1]){\r
+ num_to_bytes(e_sector[i].Key[1], 6, tempkey);\r
+ fwrite ( tempkey, 1, 6, fkeys );\r
+ }\r
+ else{\r
+ fwrite ( &standart, 1, 6, fkeys );\r
+ }\r
}\r
fclose(fkeys);\r
}\r