From fa956e02ba7b49b4f820cbd4e83aeae159b67df4 Mon Sep 17 00:00:00 2001 From: root <4166199+EmuAGR@users.noreply.github.com> Date: Wed, 27 Sep 2017 03:42:01 +0200 Subject: [PATCH] Fixing -D output key reversal --- src/mfoc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mfoc.c b/src/mfoc.c index 6e3538b..78f7cce 100644 --- a/src/mfoc.c +++ b/src/mfoc.c @@ -443,27 +443,25 @@ int main(int argc, char *const argv[]) fprintf(stdout, "\n"); for (i = 0; i < (t.num_sectors); ++i) { - if(t.sectors[i].foundKeyA){ - fprintf(stdout, "Sector %02d - Found Key A: %012llx ", i, bytes_to_num(t.sectors[i].KeyA, sizeof(t.sectors[i].KeyA))); - memcpy(&knownKey, t.sectors[i].KeyA, 6); + if (t.sectors[i].foundKeyA) { + knownKey = bytes_to_num(t.sectors[i].KeyA, sizeof(t.sectors[i].KeyA)); + fprintf(stdout, "Sector %02d - Found Key A: %012llx ", i, knownKey); knownKeyLetter = 'A'; knownSector = i; - } - else{ + } else { fprintf(stdout, "Sector %02d - Unknown Key A ", i); - unknownSector = i; unknownKeyLetter = 'A'; + unknownSector = i; } - if(t.sectors[i].foundKeyB){ - fprintf(stdout, "Found Key B: %012llx\n", bytes_to_num(t.sectors[i].KeyB, sizeof(t.sectors[i].KeyB))); + if (t.sectors[i].foundKeyB) { + knownKey = bytes_to_num(t.sectors[i].KeyB, sizeof(t.sectors[i].KeyB)); + fprintf(stdout, "Found Key B: %012llx\n", knownKey); knownKeyLetter = 'B'; - memcpy(&knownKey, t.sectors[i].KeyB, 6); knownSector = i; - } - else{ + } else { fprintf(stdout, "Unknown Key B\n"); - unknownSector = i; unknownKeyLetter = 'B'; + unknownSector = i; } } fflush(stdout);