mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
added some checks into madcheck
This commit is contained in:
parent
05f5fb3e47
commit
cfcdbcdcee
1 changed files with 12 additions and 15 deletions
|
@ -133,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;
|
||||||
|
|
||||||
|
@ -167,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) {
|
||||||
|
@ -214,11 +214,8 @@ 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;
|
||||||
if (InfoByte) {
|
if (InfoByte) {
|
||||||
|
@ -245,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