mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 23:36:31 +08:00
make style
This commit is contained in:
parent
7a7d9c818b
commit
f63cf02178
|
@ -129,14 +129,14 @@ uint8_t *BigBuf_malloc(uint16_t chunksize) {
|
||||||
return (uint8_t *)BigBuf + s_bigbuf_hi;
|
return (uint8_t *)BigBuf + s_bigbuf_hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate a chunk of memory from BigBuf, and returns a pointer to it.
|
// allocate a chunk of memory from BigBuf, and returns a pointer to it.
|
||||||
// sets the memory to zero
|
// sets the memory to zero
|
||||||
uint8_t *BigBuf_calloc(uint16_t chunksize) {
|
uint8_t *BigBuf_calloc(uint16_t chunksize) {
|
||||||
uint8_t *mem = BigBuf_malloc(chunksize);
|
uint8_t *mem = BigBuf_malloc(chunksize);
|
||||||
if (mem != NULL) {
|
if (mem != NULL) {
|
||||||
memset(mem, 0x00, chunksize);
|
memset(mem, 0x00, chunksize);
|
||||||
}
|
}
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// free ALL allocated chunks. The whole BigBuf is available for traces or samples again.
|
// free ALL allocated chunks. The whole BigBuf is available for traces or samples again.
|
||||||
|
|
62
armsrc/epa.c
62
armsrc/epa.c
|
@ -541,44 +541,44 @@ void EPA_PACE_Replay(PacketCommandNG *c) {
|
||||||
int EPA_Setup(void) {
|
int EPA_Setup(void) {
|
||||||
|
|
||||||
#ifdef WITH_ISO14443a
|
#ifdef WITH_ISO14443a
|
||||||
{
|
{
|
||||||
// first, look for type A cards
|
// first, look for type A cards
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
// power up the field
|
// power up the field
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_MOD);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_MOD);
|
||||||
iso14a_card_select_t card_a_info;
|
iso14a_card_select_t card_a_info;
|
||||||
int return_code = iso14443a_select_card(NULL, &card_a_info, NULL, true, 0, false);
|
int return_code = iso14443a_select_card(NULL, &card_a_info, NULL, true, 0, false);
|
||||||
|
|
||||||
if (return_code == 1) {
|
if (return_code == 1) {
|
||||||
uint8_t pps_response[3];
|
uint8_t pps_response[3];
|
||||||
uint8_t pps_response_par[1];
|
uint8_t pps_response_par[1];
|
||||||
// send the PPS request
|
// send the PPS request
|
||||||
ReaderTransmit((uint8_t *)pps, sizeof(pps), NULL);
|
ReaderTransmit((uint8_t *)pps, sizeof(pps), NULL);
|
||||||
return_code = ReaderReceive(pps_response, pps_response_par);
|
return_code = ReaderReceive(pps_response, pps_response_par);
|
||||||
if (return_code != 3 || pps_response[0] != 0xD0) {
|
if (return_code != 3 || pps_response[0] != 0xD0) {
|
||||||
return return_code == 0 ? 2 : return_code;
|
return return_code == 0 ? 2 : return_code;
|
||||||
|
}
|
||||||
|
Dbprintf("ISO 14443 Type A");
|
||||||
|
iso_type = 'a';
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
Dbprintf("ISO 14443 Type A");
|
|
||||||
iso_type = 'a';
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_ISO14443b
|
#ifdef WITH_ISO14443b
|
||||||
{
|
{
|
||||||
// if we're here, there is no type A card, so we look for type B
|
// if we're here, there is no type A card, so we look for type B
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
// power up the field
|
// power up the field
|
||||||
iso14443b_setup();
|
iso14443b_setup();
|
||||||
iso14b_card_select_t card_b_info;
|
iso14b_card_select_t card_b_info;
|
||||||
int return_code = iso14443b_select_card(&card_b_info);
|
int return_code = iso14443b_select_card(&card_b_info);
|
||||||
|
|
||||||
if (return_code == 0) {
|
if (return_code == 0) {
|
||||||
Dbprintf("ISO 14443 Type B");
|
Dbprintf("ISO 14443 Type B");
|
||||||
iso_type = 'b';
|
iso_type = 'b';
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
Dbprintf("No card found");
|
Dbprintf("No card found");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -722,15 +722,15 @@ void Simulate_iso14443b_srx_tag(uint8_t *uid) {
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
/ SRI512
|
/ SRI512
|
||||||
|
|
||||||
> initiate 06 00 ISO14443B_INITIATE
|
> initiate 06 00 ISO14443B_INITIATE
|
||||||
< xx crc crc
|
< xx crc crc
|
||||||
> select 0e xx ISO14443B_SELECT
|
> select 0e xx ISO14443B_SELECT
|
||||||
< xx nn nn
|
< xx nn nn
|
||||||
|
|
||||||
> readblock 08 blck_no ISO14443B_READ_BLK
|
> readblock 08 blck_no ISO14443B_READ_BLK
|
||||||
< d0 d1 d2 d3 2byte crc
|
< d0 d1 d2 d3 2byte crc
|
||||||
|
|
||||||
> get uid ISO14443B_GET_UID
|
> get uid ISO14443B_GET_UID
|
||||||
< 81 93 99 20 92 11 02 (8byte UID in MSB D002 199220 999381)
|
< 81 93 99 20 92 11 02 (8byte UID in MSB D002 199220 999381)
|
||||||
|
|
||||||
|
|
|
@ -2420,7 +2420,7 @@ void MifareHasStaticNonce(void) {
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
CHK_TIMEOUT();
|
CHK_TIMEOUT();
|
||||||
|
|
||||||
memset(rec, 0x00, sizeof(rec));
|
memset(rec, 0x00, sizeof(rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2736,10 +2736,10 @@ void MifareU_Otp_Tearoff(uint8_t arg0, uint32_t tearoff_time, uint8_t *datain) {
|
||||||
// write cmd to send, include CRC
|
// write cmd to send, include CRC
|
||||||
// 1b write, 1b block, 4b data, 2 crc
|
// 1b write, 1b block, 4b data, 2 crc
|
||||||
uint8_t cmd[] = {
|
uint8_t cmd[] = {
|
||||||
MIFARE_ULC_WRITE, blockNo,
|
MIFARE_ULC_WRITE, blockNo,
|
||||||
data_testwrite[0], data_testwrite[1], data_testwrite[2], data_testwrite[3],
|
data_testwrite[0], data_testwrite[1], data_testwrite[2], data_testwrite[3],
|
||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
AddCrc14A(cmd, sizeof(cmd) - 2);
|
AddCrc14A(cmd, sizeof(cmd) - 2);
|
||||||
|
|
||||||
// anticollision / select card
|
// anticollision / select card
|
||||||
|
@ -2778,10 +2778,10 @@ void MifareU_Counter_Tearoff(uint8_t counter, uint32_t tearoff_time, uint8_t *da
|
||||||
uint8_t cmd[] = {
|
uint8_t cmd[] = {
|
||||||
MIFARE_ULEV1_INCR_CNT,
|
MIFARE_ULEV1_INCR_CNT,
|
||||||
counter,
|
counter,
|
||||||
datain[0], // lsb
|
datain[0], // lsb
|
||||||
datain[1],
|
datain[1],
|
||||||
datain[2], // msb
|
datain[2], // msb
|
||||||
datain[3], // rfu
|
datain[3], // rfu
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -406,7 +406,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
|
|
||||||
if (strip_leading) {
|
if (strip_leading) {
|
||||||
buf = (DemodBuffer + offset);
|
buf = (DemodBuffer + offset);
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
||||||
if (len > 512) {
|
if (len > 512) {
|
||||||
len = 512;
|
len = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invert) {
|
if (invert) {
|
||||||
buf = (DemodBuffer + offset);
|
buf = (DemodBuffer + offset);
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
@ -439,11 +439,11 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_hex) {
|
if (print_hex) {
|
||||||
buf = (DemodBuffer + offset);
|
buf = (DemodBuffer + offset);
|
||||||
char hex[512] = {0x00};
|
char hex[512] = {0x00};
|
||||||
int num_bits = binarraytohex(hex, sizeof(hex), (char*)buf, len);
|
int num_bits = binarraytohex(hex, sizeof(hex), (char *)buf, len);
|
||||||
if (num_bits == 0) {
|
if (num_bits == 0) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1839,7 +1839,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
|
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "-------------------------- " _CYAN_("ATS") " --------------------------");
|
PrintAndLogEx(INFO, "-------------------------- " _CYAN_("ATS") " --------------------------");
|
||||||
bool ta1 = 0, tb1 = 0, tc1 = 0;
|
bool ta1 = 0, tb1 = 0, tc1 = 0;
|
||||||
|
|
||||||
|
@ -1851,7 +1851,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
PrintAndLogEx(WARNING, "ATS may be corrupted. Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len);
|
PrintAndLogEx(WARNING, "ATS may be corrupted. Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02x %02x ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 1], card.ats[card.ats_len] );
|
PrintAndLogEx(SUCCESS, "ATS: " _YELLOW_("%s")"[ %02x %02x ]", sprint_hex(card.ats, card.ats_len - 2), card.ats[card.ats_len - 1], card.ats[card.ats_len]);
|
||||||
PrintAndLogEx(INFO, " " _YELLOW_("%02x") "............... TL length is " _GREEN_("%d") " bytes", card.ats[0], card.ats[0]);
|
PrintAndLogEx(INFO, " " _YELLOW_("%02x") "............... TL length is " _GREEN_("%d") " bytes", card.ats[0], card.ats[0]);
|
||||||
|
|
||||||
if (card.ats[0] > 1) { // there is a format byte (T0)
|
if (card.ats[0] > 1) { // there is a format byte (T0)
|
||||||
|
@ -1913,7 +1913,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
card.ats[pos],
|
card.ats[pos],
|
||||||
(card.ats[pos] & 0x01) ? "" : _RED_(" NOT"),
|
(card.ats[pos] & 0x01) ? "" : _RED_(" NOT"),
|
||||||
(card.ats[pos] & 0x02) ? "" : _RED_(" NOT")
|
(card.ats[pos] & 0x02) ? "" : _RED_(" NOT")
|
||||||
);
|
);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1923,13 +1923,13 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
tip[0] = '\0';
|
tip[0] = '\0';
|
||||||
if (card.ats[0] - pos >= 7) {
|
if (card.ats[0] - pos >= 7) {
|
||||||
|
|
||||||
snprintf(tip, sizeof(tip)," ");
|
snprintf(tip, sizeof(tip), " ");
|
||||||
|
|
||||||
if ((card.sak & 0x70) == 0x40) { // and no GetVersion()..
|
if ((card.sak & 0x70) == 0x40) { // and no GetVersion()..
|
||||||
|
|
||||||
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
|
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
|
||||||
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus X 2K/4K (SL3)");
|
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus X 2K/4K (SL3)");
|
||||||
|
|
||||||
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
|
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
|
||||||
|
|
||||||
if ((card.atqa[0] & 0x02) == 0x02)
|
if ((card.atqa[0] & 0x02) == 0x02)
|
||||||
|
@ -1939,7 +1939,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
|
|
||||||
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) {
|
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) {
|
||||||
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (17pF)");
|
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (17pF)");
|
||||||
|
|
||||||
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) {
|
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) {
|
||||||
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (70pF)");
|
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (70pF)");
|
||||||
}
|
}
|
||||||
|
@ -1973,7 +1973,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
PrintAndLogEx(INFO, "-------------------- " _CYAN_("Historical bytes") " --------------------");
|
PrintAndLogEx(INFO, "-------------------- " _CYAN_("Historical bytes") " --------------------");
|
||||||
|
|
||||||
if (card.ats[pos] == 0xC1) {
|
if (card.ats[pos] == 0xC1) {
|
||||||
PrintAndLogEx(INFO, " %s%s", sprint_hex(card.ats + pos, calen), tip);
|
PrintAndLogEx(INFO, " %s%s", sprint_hex(card.ats + pos, calen), tip);
|
||||||
PrintAndLogEx(SUCCESS, " C1..................... Mifare or (multiple) virtual cards of various type");
|
PrintAndLogEx(SUCCESS, " C1..................... Mifare or (multiple) virtual cards of various type");
|
||||||
PrintAndLogEx(SUCCESS, " %02x.................. length is " _YELLOW_("%d") " bytes", card.ats[pos + 1], card.ats[pos + 1]);
|
PrintAndLogEx(SUCCESS, " %02x.................. length is " _YELLOW_("%d") " bytes", card.ats[pos + 1], card.ats[pos + 1]);
|
||||||
switch (card.ats[pos + 2] & 0xf0) {
|
switch (card.ats[pos + 2] & 0xf0) {
|
||||||
|
|
|
@ -878,16 +878,16 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DumpFileType_t dftype = BIN;
|
DumpFileType_t dftype = BIN;
|
||||||
|
|
||||||
bool use_json = arg_get_lit(ctx, 2);
|
bool use_json = arg_get_lit(ctx, 2);
|
||||||
bool use_eml = arg_get_lit(ctx, 3);
|
bool use_eml = arg_get_lit(ctx, 3);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (use_json && use_eml) {
|
if (use_json && use_eml) {
|
||||||
PrintAndLogEx(ERR, "Error: can't specify both JSON & EML");
|
PrintAndLogEx(ERR, "Error: can't specify both JSON & EML");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
dftype = JSON;
|
dftype = JSON;
|
||||||
} else if (use_eml) {
|
} else if (use_eml) {
|
||||||
|
@ -2325,7 +2325,7 @@ static int CmdHFiClass_loclass(const char *Cmd) {
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
|
|
||||||
bool test = arg_get_lit(ctx, 2);
|
bool test = arg_get_lit(ctx, 2);
|
||||||
bool longtest = arg_get_lit(ctx, 3);
|
bool longtest = arg_get_lit(ctx, 3);
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ typedef struct {
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static const char *getEncryptionAlgoStr(uint8_t algo) {
|
static const char *getEncryptionAlgoStr(uint8_t algo) {
|
||||||
switch(algo) {
|
switch (algo) {
|
||||||
case MFDES_ALGO_AES :
|
case MFDES_ALGO_AES :
|
||||||
return "AES";
|
return "AES";
|
||||||
case MFDES_ALGO_3DES :
|
case MFDES_ALGO_3DES :
|
||||||
|
@ -1133,7 +1133,7 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AID == 000000 6bits LSB needs to be 0
|
// AID == 000000 6bits LSB needs to be 0
|
||||||
key_no &= 0x0F;
|
key_no &= 0x0F;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1141,10 +1141,10 @@ static int mifare_desfire_change_key(uint8_t key_no, uint8_t *new_key, uint8_t n
|
||||||
* changing the card master key to one of them require a key_no tweak.
|
* changing the card master key to one of them require a key_no tweak.
|
||||||
*/
|
*/
|
||||||
if (0x000000 == tag->selected_application) {
|
if (0x000000 == tag->selected_application) {
|
||||||
|
|
||||||
// PICC master key, 6bits LSB needs to be 0
|
// PICC master key, 6bits LSB needs to be 0
|
||||||
key_no = 0x00;
|
key_no = 0x00;
|
||||||
|
|
||||||
// PICC master key, keyalgo specific 2bit MSB
|
// PICC master key, keyalgo specific 2bit MSB
|
||||||
switch (new_algo) {
|
switch (new_algo) {
|
||||||
case MFDES_ALGO_DES:
|
case MFDES_ALGO_DES:
|
||||||
|
@ -3938,11 +3938,11 @@ static int CmdHF14ADesChangeKey(const char *Cmd) {
|
||||||
PrintAndLogEx(WARNING, "New key must include %d HEX symbols", keylength);
|
PrintAndLogEx(WARNING, "New key must include %d HEX symbols", keylength);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "changing key number 0x%02x", cmdKeyNo);
|
PrintAndLogEx(INFO, "changing key number 0x%02x", cmdKeyNo);
|
||||||
PrintAndLogEx(INFO, "old key: %s (%s)", sprint_hex_inrow(key, keylen), getEncryptionAlgoStr(cmdAuthAlgo));
|
PrintAndLogEx(INFO, "old key: %s (%s)", sprint_hex_inrow(key, keylen), getEncryptionAlgoStr(cmdAuthAlgo));
|
||||||
PrintAndLogEx(INFO, "new key: %s (%s)", sprint_hex_inrow(newkey, newkeylen), getEncryptionAlgoStr(newcmdAuthAlgo));
|
PrintAndLogEx(INFO, "new key: %s (%s)", sprint_hex_inrow(newkey, newkeylen), getEncryptionAlgoStr(newcmdAuthAlgo));
|
||||||
|
|
||||||
int error = mifare_desfire_change_key(cmdKeyNo, newkey, newcmdAuthAlgo, key, cmdAuthAlgo, aesversion);
|
int error = mifare_desfire_change_key(cmdKeyNo, newkey, newcmdAuthAlgo, key, cmdAuthAlgo, aesversion);
|
||||||
if (error == PM3_SUCCESS) {
|
if (error == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(SUCCESS, " Successfully changed key.");
|
PrintAndLogEx(SUCCESS, " Successfully changed key.");
|
||||||
|
@ -4660,7 +4660,7 @@ static int CmdHF14aDesNDEF(const char *Cmd) {
|
||||||
bool keyB = arg_get_lit(ctx, 4);
|
bool keyB = arg_get_lit(ctx, 4);
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
uint16_t ndefAID = 0xe103;
|
uint16_t ndefAID = 0xe103;
|
||||||
if (aidlen == 2)
|
if (aidlen == 2)
|
||||||
ndefAID = (aid[0] << 8) + aid[1];
|
ndefAID = (aid[0] << 8) + aid[1];
|
||||||
|
@ -4752,7 +4752,7 @@ static int CmdHF14aDesMAD(const char *Cmd) {
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes mad -v`") " for more details");
|
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfdes mad -v`") " for more details");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,7 +137,7 @@ int demodHID(bool verbose) {
|
||||||
}
|
}
|
||||||
|
|
||||||
wiegand_message_t packed = initialize_message_object(hi2, hi, lo);
|
wiegand_message_t packed = initialize_message_object(hi2, hi, lo);
|
||||||
if ( HIDTryUnpack(&packed, false) == false) {
|
if (HIDTryUnpack(&packed, false) == false) {
|
||||||
PrintAndLogEx(INFO, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
PrintAndLogEx(INFO, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
||||||
printDemodBuff(0, false, false, true);
|
printDemodBuff(0, false, false, true);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ int demodHID(bool verbose) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer: ", idx, size);
|
PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %zu, Printing Demod Buffer: ", idx, size);
|
||||||
if (g_debugMode) {
|
if (g_debugMode) {
|
||||||
PrintAndLogEx(DEBUG, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
PrintAndLogEx(DEBUG, "raw: " _GREEN_("%08x%08x%08x"), hi2, hi, lo);
|
||||||
|
|
||||||
printDemodBuff(0, false, false, false);
|
printDemodBuff(0, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -527,11 +527,11 @@ void SAPDUPrint(sAPDU apdu, size_t maxdatalen) {
|
||||||
apdu.Lc,
|
apdu.Lc,
|
||||||
apdu.Lc
|
apdu.Lc
|
||||||
);
|
);
|
||||||
|
|
||||||
size_t len = apdu.Lc;
|
size_t len = apdu.Lc;
|
||||||
if (maxdatalen > 0)
|
if (maxdatalen > 0)
|
||||||
len = MIN(apdu.Lc, maxdatalen);
|
len = MIN(apdu.Lc, maxdatalen);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "data { %s%s }", sprint_hex(apdu.data, len), apdu.Lc > len ? "..." : "");
|
PrintAndLogEx(INFO, "data { %s%s }", sprint_hex(apdu.data, len), apdu.Lc > len ? "..." : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ static bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed) {
|
||||||
|
|
||||||
set_linear_field(packed, card->FacilityCode, 1, 16);
|
set_linear_field(packed, card->FacilityCode, 1, 16);
|
||||||
set_linear_field(packed, card->CardNumber, 17, 19);
|
set_linear_field(packed, card->CardNumber, 17, 19);
|
||||||
|
|
||||||
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
|
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
|
||||||
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
|
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
|
||||||
return add_HID_header(packed);
|
return add_HID_header(packed);
|
||||||
|
@ -545,30 +545,30 @@ static bool Pack_HGeneric37(wiegand_card_t *card, wiegand_message_t *packed) {
|
||||||
packed->Length = 37; // Set number of bits
|
packed->Length = 37; // Set number of bits
|
||||||
|
|
||||||
set_linear_field(packed, card->CardNumber, 4, 32);
|
set_linear_field(packed, card->CardNumber, 4, 32);
|
||||||
|
|
||||||
set_bit_by_position(packed, 1, 36); // Always 1
|
set_bit_by_position(packed, 1, 36); // Always 1
|
||||||
|
|
||||||
// even1
|
// even1
|
||||||
set_bit_by_position(packed,
|
set_bit_by_position(packed,
|
||||||
evenparity32(
|
evenparity32(
|
||||||
get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32})
|
get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32})
|
||||||
)
|
)
|
||||||
, 0
|
, 0
|
||||||
);
|
);
|
||||||
// odd1
|
// odd1
|
||||||
set_bit_by_position(packed,
|
set_bit_by_position(packed,
|
||||||
oddparity32(
|
oddparity32(
|
||||||
get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 26, 30, 34})
|
get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 26, 30, 34})
|
||||||
)
|
)
|
||||||
, 2
|
, 2
|
||||||
);
|
);
|
||||||
// even2
|
// even2
|
||||||
set_bit_by_position(packed,
|
set_bit_by_position(packed,
|
||||||
evenparity32(
|
evenparity32(
|
||||||
get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})
|
get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})
|
||||||
)
|
)
|
||||||
, 3
|
, 3
|
||||||
);
|
);
|
||||||
return add_HID_header(packed);
|
return add_HID_header(packed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,10 +580,10 @@ static bool Unpack_HGeneric37(wiegand_message_t *packed, wiegand_card_t *card) {
|
||||||
|
|
||||||
card->CardNumber = get_linear_field(packed, 4, 32);
|
card->CardNumber = get_linear_field(packed, 4, 32);
|
||||||
card->ParityValid =
|
card->ParityValid =
|
||||||
(get_bit_by_position(packed, 0) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))) &&
|
(get_bit_by_position(packed, 0) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))) &&
|
||||||
(get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 28, 30, 34}))) &&
|
(get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 28, 30, 34}))) &&
|
||||||
(get_bit_by_position(packed, 3) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})))
|
(get_bit_by_position(packed, 3) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35})))
|
||||||
;
|
;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ static bool Pack_MDI37(wiegand_card_t *card, wiegand_message_t *packed) {
|
||||||
|
|
||||||
set_linear_field(packed, card->FacilityCode, 3, 4);
|
set_linear_field(packed, card->FacilityCode, 3, 4);
|
||||||
set_linear_field(packed, card->CardNumber, 7, 29);
|
set_linear_field(packed, card->CardNumber, 7, 29);
|
||||||
|
|
||||||
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
|
set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0);
|
||||||
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
|
set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36);
|
||||||
return add_HID_header(packed);
|
return add_HID_header(packed);
|
||||||
|
@ -612,7 +612,7 @@ static bool Unpack_MDI37(wiegand_message_t *packed, wiegand_card_t *card) {
|
||||||
|
|
||||||
card->FacilityCode = get_linear_field(packed, 3, 4);;
|
card->FacilityCode = get_linear_field(packed, 3, 4);;
|
||||||
card->CardNumber = get_linear_field(packed, 7, 29);
|
card->CardNumber = get_linear_field(packed, 7, 29);
|
||||||
|
|
||||||
card->ParityValid =
|
card->ParityValid =
|
||||||
(get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) &&
|
(get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) &&
|
||||||
(get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18)))
|
(get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18)))
|
||||||
|
@ -830,7 +830,7 @@ static const cardformat_t FormatTable[] = {
|
||||||
{"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums
|
{"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums
|
||||||
{"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums
|
{"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums
|
||||||
{"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
{"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
||||||
{"HGeneric37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
{"HGeneric37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
||||||
{"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
{"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au
|
||||||
{"P10001", Pack_P10001, Unpack_P10001, "HID P10001 Honeywell 40-bit", {1, 1, 0, 1, 0}}, // from cardinfo.barkweb.com.au
|
{"P10001", Pack_P10001, Unpack_P10001, "HID P10001 Honeywell 40-bit", {1, 1, 0, 1, 0}}, // from cardinfo.barkweb.com.au
|
||||||
{"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", {1, 0, 0, 0, 0}}, // from cardinfo.barkweb.com.au
|
{"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", {1, 0, 0, 0, 0}}, // from cardinfo.barkweb.com.au
|
||||||
|
|
|
@ -410,27 +410,27 @@ Check column "offline" for their availability.
|
||||||
|command |offline |description
|
|command |offline |description
|
||||||
|------- |------- |-----------
|
|------- |------- |-----------
|
||||||
|`hf mfdes help `|Y |`This help`
|
|`hf mfdes help `|Y |`This help`
|
||||||
|
|`hf mfdes auth `|N |`Tries a MIFARE DesFire Authentication`
|
||||||
|
|`hf mfdes changekey `|N |`Change Key`
|
||||||
|
|`hf mfdes chk `|N |`Check keys`
|
||||||
|
|`hf mfdes enum `|N |`Tries enumerate all applications`
|
||||||
|
|`hf mfdes formatpicc `|N |`Format PICC`
|
||||||
|
|`hf mfdes getuid `|N |`Get random uid`
|
||||||
|`hf mfdes info `|N |`Tag information`
|
|`hf mfdes info `|N |`Tag information`
|
||||||
|`hf mfdes list `|Y |`List DESFire (ISO 14443A) history`
|
|`hf mfdes list `|Y |`List DESFire (ISO 14443A) history`
|
||||||
|`hf mfdes enum `|N |`Tries enumerate all applications`
|
|
||||||
|`hf mfdes auth `|N |`Tries a MIFARE DesFire Authentication`
|
|
||||||
|`hf mfdes getuid `|N |`Get random uid`
|
|
||||||
|`hf mfdes selectaid `|N |`Select Application ID`
|
|
||||||
|`hf mfdes createaid `|N |`Create Application ID`
|
|`hf mfdes createaid `|N |`Create Application ID`
|
||||||
|`hf mfdes deleteaid `|N |`Delete Application ID`
|
|`hf mfdes deleteaid `|N |`Delete Application ID`
|
||||||
|
|`hf mfdes selectaid `|N |`Select Application ID`
|
||||||
|
|`hf mfdes changevalue `|N |`Write value of a value file (credit/debit/clear)`
|
||||||
|
|`hf mfdes clearfile `|N |`Clear record File`
|
||||||
|`hf mfdes createfile `|N |`Create Standard/Backup File`
|
|`hf mfdes createfile `|N |`Create Standard/Backup File`
|
||||||
|`hf mfdes createvaluefile`|N |`Create Value File`
|
|`hf mfdes createvaluefile`|N |`Create Value File`
|
||||||
|`hf mfdes createrecordfile`|N |`Create Linear/Cyclic Record File`
|
|`hf mfdes createrecordfile`|N |`Create Linear/Cyclic Record File`
|
||||||
|`hf mfdes deletefile `|N |`Create Delete File`
|
|`hf mfdes deletefile `|N |`Create Delete File`
|
||||||
|`hf mfdes clearfile `|N |`Clear record File`
|
|`hf mfdes dump `|N |`Dump all files`
|
||||||
|
|`hf mfdes getvalue `|N |`Get value of file`
|
||||||
|`hf mfdes readdata `|N |`Read data from standard/backup/record file`
|
|`hf mfdes readdata `|N |`Read data from standard/backup/record file`
|
||||||
|`hf mfdes writedata `|N |`Write data to standard/backup/record file`
|
|`hf mfdes writedata `|N |`Write data to standard/backup/record file`
|
||||||
|`hf mfdes getvalue `|N |`Get value of file`
|
|
||||||
|`hf mfdes changevalue `|N |`Write value of a value file (credit/debit/clear)`
|
|
||||||
|`hf mfdes changekey `|N |`Change Key`
|
|
||||||
|`hf mfdes formatpicc `|N |`Format PICC`
|
|
||||||
|`hf mfdes dump `|N |`Dump all files`
|
|
||||||
|`hf mfdes chk `|N |`Check keys`
|
|
||||||
|
|
||||||
|
|
||||||
### hf st
|
### hf st
|
||||||
|
|
Loading…
Reference in a new issue