mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
style on hf mf rdsc , hf mf rdbl, to match the MF commands
This commit is contained in:
parent
f462e6bd02
commit
8ac04b2d21
3 changed files with 25 additions and 27 deletions
|
@ -207,7 +207,7 @@ static char GetFormatFromSector(uint8_t sectors) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool mfc_value(const uint8_t *d, int32_t *val) {
|
||||
bool mfc_value(const uint8_t *d, int32_t *val) {
|
||||
// values
|
||||
int32_t a = (int32_t)MemLeToUint4byte(d);
|
||||
uint32_t a_inv = MemLeToUint4byte(d + 4);
|
||||
|
@ -225,7 +225,7 @@ static bool mfc_value(const uint8_t *d, int32_t *val) {
|
|||
return val_checks;
|
||||
}
|
||||
|
||||
static void mf_print_block_one(uint8_t blockno, uint8_t *d, bool verbose) {
|
||||
void mf_print_block_one(uint8_t blockno, uint8_t *d, bool verbose) {
|
||||
if (blockno == 0) {
|
||||
PrintAndLogEx(INFO, "%3d | " _RED_("%s"), blockno, sprint_hex_ascii(d, MFBLOCK_SIZE));
|
||||
} else if (mfIsSectorTrailer(blockno)) {
|
||||
|
@ -389,7 +389,7 @@ static void mf_print_values(uint16_t n, uint8_t *d) {
|
|||
}
|
||||
*/
|
||||
|
||||
static void mf_print_sector_hdr(uint8_t sector) {
|
||||
void mf_print_sector_hdr(uint8_t sector) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, " # | sector " _GREEN_("%02d") " / " _GREEN_("0x%02X") " | ascii", sector, sector);
|
||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||
|
|
|
@ -33,7 +33,11 @@ int CmdHFMFNDEFWrite(const char *Cmd); // used by "nfc mf cwrite"
|
|||
void showSectorTable(sector_t *k_sector, size_t k_sectors_cnt);
|
||||
void readerAttack(sector_t *k_sector, size_t k_sectors_cnt, nonces_t data, bool setEmulatorMem, bool verbose);
|
||||
void printKeyTable(size_t sectorscnt, sector_t *e_sector);
|
||||
void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector);
|
||||
void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector, bool singel_sector);
|
||||
|
||||
bool mfc_value(const uint8_t *d, int32_t *val);
|
||||
void mf_print_sector_hdr(uint8_t sector);
|
||||
void mf_print_block_one(uint8_t blockno, uint8_t *d, bool verbose);
|
||||
|
||||
int mfc_ev1_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len);
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "fileutils.h"
|
||||
#include "protocols.h"
|
||||
#include "crypto/libpcrypto.h"
|
||||
#include "cmdhfmf.h" // printblock, header
|
||||
|
||||
static const uint8_t DefaultKey[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
static uint16_t CardAddresses[] = {0x9000, 0x9001, 0x9002, 0x9003, 0x9004, 0xA000, 0xA001, 0xA080, 0xA081, 0xC000, 0xC001};
|
||||
|
@ -766,25 +767,25 @@ static int CmdHFMFPRdbl(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
uint8_t sector = mfSectorNum(blockn);
|
||||
mf_print_sector_hdr(sector);
|
||||
|
||||
int indx = blockn;
|
||||
for (int i = 0; i < blocksCount; i++) {
|
||||
PrintAndLogEx(INFO, "data[%03d]: %s", indx, sprint_hex(&data[1 + i * 16], 16));
|
||||
mf_print_block_one(indx, data + 1 + (i * MFBLOCK_SIZE), verbose);
|
||||
indx++;
|
||||
if (mfIsSectorTrailer(indx) && i != blocksCount - 1) {
|
||||
PrintAndLogEx(INFO, "data[%03d]: ------------------- trailer -------------------", indx);
|
||||
indx++;
|
||||
}
|
||||
|
||||
if (memcmp(&data[(blocksCount * 16) + 1], mac, 8)) {
|
||||
PrintAndLogEx(WARNING, "WARNING: mac not equal...");
|
||||
PrintAndLogEx(WARNING, "MAC card... " _YELLOW_("%s"), sprint_hex_inrow(&data[1 + (blocksCount * MFBLOCK_SIZE)], 8));
|
||||
PrintAndLogEx(WARNING, "MAC reader... " _YELLOW_("%s"), sprint_hex_inrow(mac, sizeof(mac)));
|
||||
} else {
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "MAC... " _YELLOW_("%s"), sprint_hex_inrow(&data[1 + (blocksCount * MFBLOCK_SIZE)], 8));
|
||||
}
|
||||
}
|
||||
|
||||
if (memcmp(&data[blocksCount * 16 + 1], mac, 8)) {
|
||||
PrintAndLogEx(WARNING, "WARNING: mac not equal...");
|
||||
PrintAndLogEx(WARNING, "MAC card: %s", sprint_hex(&data[blocksCount * 16 + 1], 8));
|
||||
PrintAndLogEx(WARNING, "MAC reader: %s", sprint_hex(mac, 8));
|
||||
} else {
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "MAC: %s", sprint_hex(&data[blocksCount * 16 + 1], 8));
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -850,9 +851,7 @@ static int CmdHFMFPRdsc(const char *Cmd) {
|
|||
int datalen = 0;
|
||||
uint8_t mac[8] = {0};
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, " # | sector " _GREEN_("%02d") " / " _GREEN_("0x%02X") " | ascii", sectorNum, sectorNum);
|
||||
PrintAndLogEx(INFO, "----+-------------------------------------------------+-----------------");
|
||||
mf_print_sector_hdr(sectorNum);
|
||||
|
||||
for (int blockno = mfFirstBlockOfSector(sectorNum); blockno < mfFirstBlockOfSector(sectorNum) + mfNumBlocksPerSector(sectorNum); blockno++) {
|
||||
|
||||
|
@ -875,12 +874,7 @@ static int CmdHFMFPRdsc(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// PrintAndLogEx(INFO, "data[%03d]: %s", n, sprint_hex(&data[1], 16));
|
||||
if (blockno == 0) {
|
||||
PrintAndLogEx(INFO, "%3d | " _RED_("%s"), blockno, sprint_hex_ascii(data + 1, MFBLOCK_SIZE));
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "%3d | %s ", blockno, sprint_hex_ascii(data + 1, MFBLOCK_SIZE));
|
||||
}
|
||||
mf_print_block_one(blockno, data + 1, verbose);
|
||||
|
||||
if (memcmp(&data[1 + 16], mac, 8)) {
|
||||
PrintAndLogEx(WARNING, "WARNING: mac on block %d not equal...", blockno);
|
||||
|
|
Loading…
Reference in a new issue