\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