From 01c9325469e0b0a7c75c8652202be17f25fa2b40 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Thu, 21 Feb 2019 20:06:53 +0200 Subject: [PATCH] check MAD crc --- client/mifare/mad.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/mifare/mad.c b/client/mifare/mad.c index 03b5b3f77..2fbc23e38 100644 --- a/client/mifare/mad.c +++ b/client/mifare/mad.c @@ -10,6 +10,7 @@ #include "mad.h" #include "ui.h" +#include "crc.h" madAIDDescr madKnownAIDs[] = { {0x0000, "free"}, @@ -48,7 +49,11 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) { if (haveMAD2) *haveMAD2 = (MADVer == 2); - + uint8_t crc = CRC8Mad(§or[16 + 1], 31); + if (crc != sector[16]) { + PrintAndLogEx(ERR, "Wrong MAD CRC. Calculated crc: 0x%02x, from sector: 0x%02x", crc, sector[16]); + return 3; + };