fix: legic deobfuscate length.

This commit is contained in:
ikarus 2020-04-04 12:05:26 +02:00
commit cf44a44575

View file

@ -108,7 +108,7 @@ static int usage_legic_dump(void) {
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : this help"); PrintAndLogEx(NORMAL, " h : this help");
PrintAndLogEx(NORMAL, " f <filename> : filename w/o '.bin' to dump bytes"); PrintAndLogEx(NORMAL, " f <filename> : filename w/o '.bin' to dump bytes");
PrintAndLogEx(NORMAL, " x : deobfuscate dump data"); PrintAndLogEx(NORMAL, " x : deobfuscate dump data (xor with MCC)");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump -- uses UID as filename")); PrintAndLogEx(NORMAL, _YELLOW_(" hf legic dump -- uses UID as filename"));
@ -123,7 +123,7 @@ static int usage_legic_restore(void) {
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : this help"); PrintAndLogEx(NORMAL, " h : this help");
PrintAndLogEx(NORMAL, " f <filename> : filename w/o '.bin' to restore bytes on to card from"); PrintAndLogEx(NORMAL, " f <filename> : filename w/o '.bin' to restore bytes on to card from");
PrintAndLogEx(NORMAL, " x : obfuscate dump data"); PrintAndLogEx(NORMAL, " x : obfuscate dump data (xor with MCC)");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic restore f myfile")); PrintAndLogEx(NORMAL, _YELLOW_(" hf legic restore f myfile"));
@ -185,10 +185,10 @@ static bool legic_xor(uint8_t *data, uint16_t cardsize) {
} }
for(uint16_t i = 22; i < cardsize - 22; i++) { for(uint16_t i = 22; i < cardsize; i++) {
data[i] ^= crc; data[i] ^= crc;
} }
PrintAndLogEx(SUCCESS, "Obsfuscation done"); PrintAndLogEx(SUCCESS, "(De)Obsfuscation done");
return true; return true;
} }
@ -1007,7 +1007,9 @@ static int CmdLegicDump(const char *Cmd) {
} }
if (shall_deobsfuscate) { if (shall_deobsfuscate) {
legic_xor(data, card.cardsize); // Deobfuscate the whole dump. Unused data (after the last sector) will be MCC since
// 0x00 ^ MCC = MCC. Finding the end of used data is not part of this function.
legic_xor(data, dumplen);
} }
saveFile(filename, ".bin", data, readlen); saveFile(filename, ".bin", data, readlen);