mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
hf mfp mad
read contents by aid
This commit is contained in:
parent
dcdb2ee218
commit
2c07bb790c
4 changed files with 128 additions and 20 deletions
|
@ -134,10 +134,13 @@ uint16_t madGetAID(uint8_t *sector, int MADver, int sectorNo) {
|
|||
return (sector[2 + (sectorNo - 1) * 2] << 8) + (sector[2 + (sectorNo - 1) * 2 + 1]);
|
||||
}
|
||||
|
||||
int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
||||
int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) {
|
||||
if (!sector0)
|
||||
return 1;
|
||||
|
||||
uint8_t GPB = sector[3 * 16 + 9];
|
||||
PrintAndLogEx(NORMAL, "GPB: 0x%02x", GPB);
|
||||
uint8_t GPB = sector0[3 * 16 + 9];
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "GPB: 0x%02x", GPB);
|
||||
|
||||
// DA (MAD available)
|
||||
if (!(GPB & 0x80)) {
|
||||
|
@ -146,13 +149,16 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
|||
}
|
||||
|
||||
// MA (multi-application card)
|
||||
if (GPB & 0x40)
|
||||
PrintAndLogEx(NORMAL, "Multi application card.");
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "Single application card.");
|
||||
if (verbose) {
|
||||
if (GPB & 0x40)
|
||||
PrintAndLogEx(NORMAL, "Multi application card.");
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "Single application card.");
|
||||
}
|
||||
|
||||
uint8_t MADVer = GPB & 0x03;
|
||||
PrintAndLogEx(NORMAL, "MAD version: %d", MADVer);
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "MAD version: %d", MADVer);
|
||||
|
||||
// MAD version
|
||||
if ((MADVer != 0x01) && (MADVer != 0x02)) {
|
||||
|
@ -163,7 +169,56 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
|||
if (haveMAD2)
|
||||
*haveMAD2 = (MADVer == 2);
|
||||
|
||||
int res = madCRCCheck(sector, true, 1);
|
||||
int res = madCRCCheck(sector0, true, 1);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "CRC8-MAD1 OK.");
|
||||
|
||||
if (MADVer == 2 && sector10) {
|
||||
int res = madCRCCheck(sector10, true, 2);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "CRC8-MAD2 OK.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen) {
|
||||
*madlen = 0;
|
||||
bool haveMAD2 = false;
|
||||
int res = MADCheck(sector0, sector10, false, &haveMAD2);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
for (int i = 1; i < 16; i++) {
|
||||
mad[*madlen] = madGetAID(sector0, 1, i);
|
||||
(*madlen)++;
|
||||
}
|
||||
|
||||
if (haveMAD2) {
|
||||
// mad2 sector (0x10 == 16dec) here
|
||||
mad[*madlen] = 0x0005;
|
||||
(*madlen)++;
|
||||
|
||||
for (int i = 1; i < 24; i++) {
|
||||
mad[*madlen] = madGetAID(sector10, 2, i);
|
||||
(*madlen)++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) {
|
||||
|
||||
// check MAD1 only
|
||||
int res = MADCheck(sector, NULL, verbose, haveMAD2);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ typedef struct {
|
|||
const char *Description;
|
||||
} madAIDDescr;
|
||||
|
||||
int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2);
|
||||
int MAD2DecodeAndPrint(uint8_t *sector, bool verbose);
|
||||
extern int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2);
|
||||
extern int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen);
|
||||
extern int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2);
|
||||
extern int MAD2DecodeAndPrint(uint8_t *sector, bool verbose);
|
||||
|
||||
|
||||
#endif // _MAD_H_
|
||||
|
|
|
@ -42,8 +42,9 @@ static const uint64_t g_mifare_default_keys[] =
|
|||
0x96a301bce267
|
||||
};
|
||||
|
||||
static const uint8_t g_mifare_mad_key[] = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5};
|
||||
static const uint8_t g_mifare_mad_key[] = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5};
|
||||
static const uint8_t g_mifare_ndef_key[] = {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7};
|
||||
static const uint8_t g_mifarep_mad_key[] = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7};
|
||||
static const uint8_t g_mifarep_mad_key[] = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7};
|
||||
static const uint8_t g_mifarep_ndef_key[] = {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue