mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
commit
be08c79bbf
1 changed files with 14 additions and 19 deletions
|
@ -111,15 +111,13 @@ int madCRCCheck(uint8_t *sector, bool verbose, int MADver) {
|
||||||
if (MADver == 1) {
|
if (MADver == 1) {
|
||||||
uint8_t crc = CRC8Mad(§or[16 + 1], 15 + 16);
|
uint8_t crc = CRC8Mad(§or[16 + 1], 15 + 16);
|
||||||
if (crc != sector[16]) {
|
if (crc != sector[16]) {
|
||||||
if (verbose)
|
PrintAndLogEx(WARNING, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
|
||||||
PrintAndLogEx(WARNING, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
|
|
||||||
return 3;
|
return 3;
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
uint8_t crc = CRC8Mad(§or[1], 15 + 16 + 16);
|
uint8_t crc = CRC8Mad(§or[1], 15 + 16 + 16);
|
||||||
if (crc != sector[0]) {
|
if (crc != sector[0]) {
|
||||||
if (verbose)
|
PrintAndLogEx(WARNING, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
|
||||||
PrintAndLogEx(WARNING, "Wrong MAD%d CRC. Calculated: 0x%02x, from card: 0x%02x", MADver, crc, sector[16]);
|
|
||||||
return 3;
|
return 3;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -135,6 +133,8 @@ uint16_t madGetAID(uint8_t *sector, int MADver, int sectorNo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) {
|
int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) {
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
if (!sector0)
|
if (!sector0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -169,23 +169,21 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
||||||
if (haveMAD2)
|
if (haveMAD2)
|
||||||
*haveMAD2 = (MADVer == 2);
|
*haveMAD2 = (MADVer == 2);
|
||||||
|
|
||||||
int res = madCRCCheck(sector0, true, 1);
|
res = madCRCCheck(sector0, true, 1);
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose && !res)
|
||||||
PrintAndLogEx(NORMAL, "CRC8-MAD1 OK.");
|
PrintAndLogEx(NORMAL, "CRC8-MAD1 OK.");
|
||||||
|
|
||||||
if (MADVer == 2 && sector10) {
|
if (MADVer == 2 && sector10) {
|
||||||
int res = madCRCCheck(sector10, true, 2);
|
int res2 = madCRCCheck(sector10, true, 2);
|
||||||
if (res)
|
if (!res)
|
||||||
return res;
|
res = res2;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose & !res2)
|
||||||
PrintAndLogEx(NORMAL, "CRC8-MAD2 OK.");
|
PrintAndLogEx(NORMAL, "CRC8-MAD2 OK.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen) {
|
int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen) {
|
||||||
|
@ -216,10 +214,7 @@ int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen
|
||||||
int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
||||||
|
|
||||||
// check MAD1 only
|
// check MAD1 only
|
||||||
int res = MADCheck(sector, NULL, verbose, haveMAD2);
|
MADCheck(sector, NULL, verbose, haveMAD2);
|
||||||
|
|
||||||
if (verbose && !res)
|
|
||||||
PrintAndLogEx(NORMAL, "CRC8-MAD OK.");
|
|
||||||
|
|
||||||
// info byte
|
// info byte
|
||||||
uint8_t InfoByte = sector[16 + 1] & 0x3f;
|
uint8_t InfoByte = sector[16 + 1] & 0x3f;
|
||||||
|
@ -247,7 +242,7 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool verbose) {
|
||||||
int res = madCRCCheck(sector, true, 2);
|
int res = madCRCCheck(sector, true, 2);
|
||||||
|
|
||||||
if (verbose && !res)
|
if (verbose && !res)
|
||||||
PrintAndLogEx(NORMAL, "CRC8-MAD OK.");
|
PrintAndLogEx(NORMAL, "CRC8-MAD2 OK.");
|
||||||
|
|
||||||
uint8_t InfoByte = sector[1] & 0x3f;
|
uint8_t InfoByte = sector[1] & 0x3f;
|
||||||
PrintAndLogEx(NORMAL, "MAD2 Card publisher sector: 0x%02x", InfoByte);
|
PrintAndLogEx(NORMAL, "MAD2 Card publisher sector: 0x%02x", InfoByte);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue