mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
make style
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "legicrf.h"
|
||||
#include "legicrfsim.h"
|
||||
#include "legic.h" // legic_card_select_t struct
|
||||
#include "spiffs.h" // flashmem
|
||||
#include "spiffs.h" // flashmem
|
||||
|
||||
|
||||
/*
|
||||
@@ -47,7 +47,7 @@
|
||||
void DownloadLogInstructions() {
|
||||
Dbprintf("");
|
||||
Dbprintf("[=] List all dumps from flash:");
|
||||
Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree");
|
||||
Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree");
|
||||
Dbprintf("");
|
||||
Dbprintf("[=] To save a dump file from flash to client:");
|
||||
Dbprintf("[=] " _YELLOW_("-") "mem spiffs dump o hf-legic-UID-dump.bin f hf-legic-UID-dump.bin");
|
||||
@@ -60,15 +60,15 @@ void save_dump_to_file(legic_card_select_t *p_card) {
|
||||
// legic functions puts it memory in Emulator reserved memory.
|
||||
uint8_t *mem = BigBuf_get_EM_addr();
|
||||
|
||||
char *preferredName = (char*)BigBuf_malloc(30);
|
||||
char *preferredName = (char *)BigBuf_malloc(30);
|
||||
if (preferredName == NULL) {
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
||||
sprintf(preferredName, "hf-legic-%02X%02X%02X%02X-dump", p_card->uid[0], p_card->uid[1], p_card->uid[2], p_card->uid[3]);
|
||||
uint16_t preferredNameLen = strlen(preferredName);
|
||||
|
||||
char *filename = (char*)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
|
||||
char *filename = (char *)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
|
||||
if (filename == NULL) {
|
||||
goto OUT;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void RunMod() {
|
||||
DbpString("[=] press and HOLD button to exit standalone mode");
|
||||
for (;;) {
|
||||
WDT_HIT();
|
||||
|
||||
|
||||
//exit from hf_legic, send usbcommand
|
||||
if (data_available()) break;
|
||||
|
||||
@@ -136,18 +136,18 @@ void RunMod() {
|
||||
|
||||
//simulate if read successfully
|
||||
if (read_success != PM3_ESOFT) {
|
||||
|
||||
|
||||
legic_card_select_t *p_card;
|
||||
p_card = getLegicCardInfo();
|
||||
if (p_card->cardsize == 0)
|
||||
if (p_card->cardsize == 0)
|
||||
continue;
|
||||
|
||||
|
||||
save_dump_to_file(p_card);
|
||||
|
||||
LED_D_ON();
|
||||
uint8_t ct;
|
||||
switch(p_card->tagtype) {
|
||||
case 0x0D:
|
||||
switch (p_card->tagtype) {
|
||||
case 0x0D:
|
||||
ct = 0;
|
||||
break;
|
||||
case 0x1D:
|
||||
@@ -156,7 +156,7 @@ void RunMod() {
|
||||
case 0x3D:
|
||||
ct = 2;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void RunMod() {
|
||||
StandAloneMode();
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
Dbprintf("[=] >> LF EM4100 simulator started <<");
|
||||
|
||||
|
||||
int selected = 0; //selected slot after start
|
||||
slots_count = sizeof(low) / sizeof(low[0]);
|
||||
bba = BigBuf_get_addr();
|
||||
|
||||
@@ -122,7 +122,7 @@ void RunMod() {
|
||||
StandAloneMode();
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
Dbprintf("[=] >> LF EM4100 read/write/clone started <<");
|
||||
|
||||
|
||||
int selected = 0;
|
||||
//state 0 - select slot
|
||||
// 1 - read tag to selected slot,
|
||||
|
||||
+1
-1
@@ -524,7 +524,7 @@ int EPA_Setup() {
|
||||
}
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
||||
|
||||
// if we're here, there is no type A card, so we look for type B
|
||||
// power up the field
|
||||
iso14443b_setup();
|
||||
|
||||
+4
-4
@@ -52,8 +52,8 @@ size_t blocknr;
|
||||
bool end = false;
|
||||
//#define SENDBIT_TEST
|
||||
|
||||
/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3
|
||||
// UID is 0 1 2 3 // tag.uid is 3210
|
||||
/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3
|
||||
// UID is 0 1 2 3 // tag.uid is 3210
|
||||
// datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0
|
||||
|
||||
#db# UID: 5F C2 11 84
|
||||
@@ -977,7 +977,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
|
||||
// TC1: Capture mode, default timer source = MCK/2 (TIMER_CLOCK1), TIOA is external trigger,
|
||||
// external trigger rising edge, load RA on rising edge of TIOA.
|
||||
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK
|
||||
| AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING;
|
||||
| AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING;
|
||||
|
||||
// Enable and reset counter
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
@@ -1051,7 +1051,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
|
||||
|
||||
// Enable and reset external trigger in timer for capturing future frames
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||
|
||||
|
||||
// Reset the received frame and response timing info
|
||||
memset(rx, 0x00, sizeof(rx));
|
||||
response = 0;
|
||||
|
||||
+3
-3
@@ -404,7 +404,7 @@ bool write_byte(uint16_t index, uint8_t byte, uint8_t addr_sz) {
|
||||
//
|
||||
// Only this functions are public / called from appmain.c
|
||||
//-----------------------------------------------------------------------------
|
||||
legic_card_select_t* getLegicCardInfo(void) {
|
||||
legic_card_select_t *getLegicCardInfo(void) {
|
||||
return &card;
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv) {
|
||||
goto OUT;
|
||||
}
|
||||
legic_mem[i] = byte;
|
||||
|
||||
|
||||
if (i < 4) {
|
||||
card.uid[i] = byte;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
||||
goto OUT;
|
||||
}
|
||||
legic_mem[i] = byte;
|
||||
|
||||
|
||||
if (i < 4) {
|
||||
card.uid[i] = byte;
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv);
|
||||
void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv);
|
||||
void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data);
|
||||
|
||||
legic_card_select_t* getLegicCardInfo(void);
|
||||
legic_card_select_t *getLegicCardInfo(void);
|
||||
#endif /* __LEGICRF_H */
|
||||
|
||||
+1
-1
@@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) {
|
||||
WaitUS(32 * 8);
|
||||
} else {
|
||||
TurnReadLF_off(23 * 8);
|
||||
TurnReadLFOn((32-23) * 8);
|
||||
TurnReadLFOn((32 - 23) * 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,16 +334,16 @@ void MifareDES_Auth1(uint8_t *datain) {
|
||||
return;
|
||||
}
|
||||
|
||||
int rndlen=8;
|
||||
int rndlen = 8;
|
||||
int expectedlen = 1 + 8 + 2 + 2;
|
||||
if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) {
|
||||
expectedlen = 1 + 16 + 2 + 2;
|
||||
rndlen=16;
|
||||
rndlen = 16;
|
||||
}
|
||||
|
||||
if (payload->mode == MFDES_AUTH_PICC) {
|
||||
expectedlen = 1 + 1 + 8 + 2;
|
||||
rndlen=8;
|
||||
rndlen = 8;
|
||||
}
|
||||
|
||||
if (len != expectedlen) {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
// PRIx64 definition missing with gcc-arm-none-eabi v8?
|
||||
#ifndef PRIx64
|
||||
#define PRIx64 "llx"
|
||||
#define PRIx64 "llx"
|
||||
#endif
|
||||
|
||||
// Basic macros
|
||||
|
||||
@@ -165,7 +165,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
|
||||
if (ibuf == 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) {
|
||||
case 1:
|
||||
printf("Parameter error: Invalid HEX value.\n");
|
||||
|
||||
@@ -140,7 +140,7 @@ static int CmdFlashMemSpiFFSRemove(const char *Cmd) {
|
||||
|
||||
static int CmdFlashMemSpiFFSRename(const char *Cmd) {
|
||||
|
||||
int len = strlen(Cmd);
|
||||
int len = strlen(Cmd);
|
||||
if (len < 1) {
|
||||
return usage_flashmemspiffs_rename();
|
||||
}
|
||||
@@ -149,7 +149,7 @@ static int CmdFlashMemSpiFFSRename(const char *Cmd) {
|
||||
if (len == 1 && ctmp == 'h') {
|
||||
return usage_flashmemspiffs_rename();
|
||||
}
|
||||
|
||||
|
||||
char srcfilename[32] = {0};
|
||||
char destfilename[32] = {0};
|
||||
bool errors = false;
|
||||
@@ -195,7 +195,7 @@ static int CmdFlashMemSpiFFSCopy(const char *Cmd) {
|
||||
return usage_flashmemspiffs_copy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
char srcfilename[32] = {0};
|
||||
char destfilename[32] = {0};
|
||||
bool errors = false;
|
||||
@@ -457,7 +457,8 @@ static int CmdFlashMemSpiFFSLoad(const char *Cmd) {
|
||||
static command_t CommandTable[] = {
|
||||
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
|
||||
{
|
||||
"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
|
||||
"Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)"
|
||||
},
|
||||
{"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"},
|
||||
|
||||
+12
-12
@@ -86,8 +86,8 @@ int CmdHFSearch(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_search();
|
||||
|
||||
int res = PM3_ESOFT;
|
||||
|
||||
int res = PM3_ESOFT;
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for ThinFilm tag...");
|
||||
if (IfPm3NfcBarcode()) {
|
||||
@@ -150,17 +150,17 @@ int CmdHFSearch(const char *Cmd) {
|
||||
res = PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
// 14b and iclass is the longest test (put last)
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
|
||||
if (IfPm3Iso14443b()) {
|
||||
if (readHFCryptoRF(false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n");
|
||||
res = PM3_SUCCESS;
|
||||
/*
|
||||
// 14b and iclass is the longest test (put last)
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
|
||||
if (IfPm3Iso14443b()) {
|
||||
if (readHFCryptoRF(false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n");
|
||||
res = PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
// 14b and iclass is the longest test (put last)
|
||||
PROMPT_CLEARLINE;
|
||||
|
||||
+5
-5
@@ -1419,12 +1419,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
// Double & triple sized UID, can be mapped to a manufacturer.
|
||||
if (card.uidlen <= 4) {
|
||||
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
||||
|
||||
|
||||
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
||||
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
||||
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
||||
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
||||
|
||||
|
||||
if ((nxptype & MTOTHER) == MTOTHER)
|
||||
isMifareClassic = true;
|
||||
}
|
||||
@@ -1433,13 +1433,13 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
switch (card.uid[0]) {
|
||||
case 0x04: // NXP
|
||||
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
||||
|
||||
|
||||
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
||||
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
||||
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
||||
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
||||
|
||||
if ((nxptype & MTOTHER) == MTOTHER)
|
||||
|
||||
if ((nxptype & MTOTHER) == MTOTHER)
|
||||
isMifareClassic = true;
|
||||
|
||||
break;
|
||||
|
||||
+53
-53
@@ -212,8 +212,8 @@ static int CmdHF15Help(const char *Cmd);
|
||||
|
||||
static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||
|
||||
#define PUBLIC_ECDA_KEYLEN 33
|
||||
const ecdsa_publickey_t nxp_15693_public_keys[] = {
|
||||
#define PUBLIC_ECDA_KEYLEN 33
|
||||
const ecdsa_publickey_t nxp_15693_public_keys[] = {
|
||||
{"NXP Mifare Classic MFC1C14_x", "044F6D3F294DEA5737F0F46FFEE88A356EED95695DD7E0C27A591E6F6F65962BAF"},
|
||||
{"Manufacturer Mifare Classic MFC1C14_x", "046F70AC557F5461CE5052C8E4A7838C11C7A236797E8A0730A101837C004039C2"},
|
||||
{"NXP ICODE DNA, ICODE SLIX2", "048878A2A2D3EEC336B4F261A082BD71F9BE11C4E2E896648B32EFA59CEA6E59F0"},
|
||||
@@ -222,55 +222,55 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||
{"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"},
|
||||
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
||||
};
|
||||
/*
|
||||
uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = {
|
||||
// ICODE SLIX2 / DNA
|
||||
{
|
||||
0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3,
|
||||
0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71,
|
||||
0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64,
|
||||
0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||
},
|
||||
// manufacturer public key
|
||||
{
|
||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||
},
|
||||
// MIKRON public key.
|
||||
{
|
||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||
}
|
||||
};
|
||||
*/
|
||||
/*
|
||||
uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = {
|
||||
// ICODE SLIX2 / DNA
|
||||
{
|
||||
0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3,
|
||||
0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71,
|
||||
0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64,
|
||||
0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||
},
|
||||
// manufacturer public key
|
||||
{
|
||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||
},
|
||||
// MIKRON public key.
|
||||
{
|
||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
uint8_t i;
|
||||
int res;
|
||||
bool is_valid = false;
|
||||
for (i = 0; i< ARRAYLEN(nxp_15693_public_keys); i++) {
|
||||
for (i = 0; i < ARRAYLEN(nxp_15693_public_keys); i++) {
|
||||
|
||||
int dl = 0;
|
||||
uint8_t key[PUBLIC_ECDA_KEYLEN];
|
||||
param_gethex_to_eol(nxp_15693_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl);
|
||||
|
||||
param_gethex_to_eol(nxp_15693_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl);
|
||||
|
||||
res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 8, signature, 32, false);
|
||||
is_valid = (res == 0);
|
||||
if (is_valid)
|
||||
@@ -589,7 +589,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
|
||||
return false;
|
||||
}
|
||||
memcpy(&req[tmpreqlen], uid, sizeof(uid));
|
||||
PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
tmpreqlen += sizeof(uid);
|
||||
break;
|
||||
default:
|
||||
@@ -602,7 +602,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
|
||||
uid[7 - i] = temp & 0xff;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
memcpy(&req[tmpreqlen], uid, sizeof(uid));
|
||||
tmpreqlen += sizeof(uid);
|
||||
break;
|
||||
@@ -931,7 +931,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") "---------");
|
||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||
PrintAndLogEx(SUCCESS, " TYPE: " _YELLOW_("%s"), getTagInfo_15(recv + 2));
|
||||
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
PrintAndLogEx(SUCCESS, " SYSINFO: %s", sprint_hex(recv, status - 2));
|
||||
|
||||
// DSFID
|
||||
@@ -1003,7 +1003,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_ISO15693_SIMULATE, 0, 0, 0, uid, 8);
|
||||
@@ -1201,7 +1201,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
}
|
||||
// detect blocksize from card :)
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
|
||||
int blocknum = 0;
|
||||
uint8_t *recv = NULL;
|
||||
@@ -1271,7 +1271,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
size_t datalen = blocknum * 4;
|
||||
saveFile(filename, ".bin", data, datalen);
|
||||
saveFile(filename, ".bin", data, datalen);
|
||||
saveFileEML(filename, data, datalen, 4);
|
||||
saveFileJSON(filename, jsf15, data, datalen);
|
||||
return PM3_SUCCESS;
|
||||
@@ -1446,7 +1446,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||
}
|
||||
|
||||
// skip status byte
|
||||
int start = 1;
|
||||
int start = 1;
|
||||
int stop = (pagecount + 1) * 5;
|
||||
int currblock = pagenum;
|
||||
// print response
|
||||
@@ -1680,7 +1680,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||
}
|
||||
|
||||
if ((f = fopen(filename, "rb")) == NULL) {
|
||||
|
||||
|
||||
PrintAndLogEx(WARNING, "Could not find file %s", filename);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
@@ -1762,7 +1762,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
|
||||
PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
|
||||
|
||||
if (!getUID(oldUid)) {
|
||||
PrintAndLogEx(FAILED, "Can't get old/current UID.");
|
||||
|
||||
+77
-77
@@ -25,86 +25,86 @@ static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int usage_hf_cryptorf_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf cryptorf info [h] [v]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" v verbose\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf info")
|
||||
);
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" v verbose\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf info")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_reader(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf cryptorf reader [h] [v]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" v verbose\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf reader")
|
||||
);
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" v verbose\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf reader")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_sniff(void) {
|
||||
PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer\n"
|
||||
"Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n"
|
||||
"Usage: hf cryptorf sniff [h]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf sniff")
|
||||
);
|
||||
"Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n"
|
||||
"Usage: hf cryptorf sniff [h]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf sniff")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_sim(void) {
|
||||
PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with 4 UID / PUPI\n"
|
||||
"Usage: hf cryptorf sim [h] [u <uid>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" u 4byte UID/PUPI\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf sim")
|
||||
);
|
||||
"Usage: hf cryptorf sim [h] [u <uid>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" u 4byte UID/PUPI\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
_YELLOW_(" hf cryptorf sim")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "This command dumps the contents of a ISO-14443-B tag and save it to file\n"
|
||||
"\n"
|
||||
"Usage: hf cryptorf dump [h] [card memory] <f filname> \n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
"\thf cryptorf dump\n"
|
||||
"\thf cryptorf dump f mydump");
|
||||
"\n"
|
||||
"Usage: hf cryptorf dump [h] [card memory] <f filname> \n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
"\thf cryptorf dump\n"
|
||||
"\thf cryptorf dump f mydump");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_eload(void) {
|
||||
PrintAndLogEx(NORMAL, "It loads a binary dump into emulator memory\n"
|
||||
"Usage: hf cryptorf eload [f <file name w/o `.eml`>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
_YELLOW_(" hf cryptorf eload f filename")
|
||||
);
|
||||
"Usage: hf cryptorf eload [f <file name w/o `.eml`>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
_YELLOW_(" hf cryptorf eload f filename")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_cryptorf_esave(void) {
|
||||
PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n"
|
||||
" Usage: hf cryptorf esave [f <file name w/o `.eml`>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
_YELLOW_(" hf cryptorf esave ")
|
||||
_YELLOW_(" hf cryptorf esave f filename")
|
||||
);
|
||||
" Usage: hf cryptorf esave [f <file name w/o `.eml`>]\n"
|
||||
"Options:\n"
|
||||
" h this help\n"
|
||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
_YELLOW_(" hf cryptorf esave ")
|
||||
_YELLOW_(" hf cryptorf esave f filename")
|
||||
);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
|
||||
case 'h' :
|
||||
return usage_hf_cryptorf_eload();
|
||||
case 'f' :
|
||||
if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) {
|
||||
if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) {
|
||||
PrintAndLogEx(FAILED, "Filename too long");
|
||||
errors = true;
|
||||
break;
|
||||
@@ -414,26 +414,26 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Uploading to emulator memory");
|
||||
|
||||
/*
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
/*
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
|
||||
//Send to device
|
||||
uint32_t bytes_sent = 0;
|
||||
uint32_t bytes_remaining = bytes_read;
|
||||
//Send to device
|
||||
uint32_t bytes_sent = 0;
|
||||
uint32_t bytes_remaining = bytes_read;
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||
if (bytes_in_packet == bytes_remaining) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||
if (bytes_in_packet == bytes_remaining) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_CRYPTORF_EML_MEMSET, bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet);
|
||||
bytes_remaining -= bytes_in_packet;
|
||||
bytes_sent += bytes_in_packet;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_CRYPTORF_EML_MEMSET, bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet);
|
||||
bytes_remaining -= bytes_in_packet;
|
||||
bytes_sent += bytes_in_packet;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
free(data);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "Done");
|
||||
@@ -524,10 +524,10 @@ int CmdHFCryptoRF(const char *Cmd) {
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
// Print extented information about tag.
|
||||
// Print extented information about tag.
|
||||
int infoHFCryptoRF(bool verbose) {
|
||||
|
||||
int res = PM3_ESOFT;
|
||||
|
||||
int res = PM3_ESOFT;
|
||||
|
||||
// 14b get and print UID only (general info)
|
||||
clearCommandBuffer();
|
||||
|
||||
@@ -580,7 +580,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
}
|
||||
uint8_t num_mac = resp.oldarg[1];
|
||||
bool success = (NUM_CSNS == num_mac);
|
||||
PrintAndLogEx( (success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL");
|
||||
PrintAndLogEx((success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL");
|
||||
|
||||
if (num_mac == 0)
|
||||
break;
|
||||
@@ -939,7 +939,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
|
||||
if (aa1_encryption == RFU || aa1_encryption == None)
|
||||
continue;
|
||||
|
||||
|
||||
// Decrypted block 7,8,9 if configured.
|
||||
if (blocknum > 6 && blocknum <= 6 + numblocks4userid && memcmp(enc_data, empty, 8) != 0) {
|
||||
if (use_sc) {
|
||||
@@ -1329,7 +1329,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||
break;
|
||||
}
|
||||
// dump cmd switch off at device when finised.
|
||||
|
||||
|
||||
uint32_t blocksRead = resp.oldarg[1];
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (!isOK && !blocksRead) {
|
||||
@@ -2009,11 +2009,11 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
|
||||
case 'e':
|
||||
endblock = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp += 2;
|
||||
break;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = true;
|
||||
cmdp++;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
@@ -2047,7 +2047,7 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
|
||||
}
|
||||
size_t bytes_read = fread(dump, 1, fsize, f);
|
||||
fclose(f);
|
||||
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "File: " _YELLOW_("%s"), filename);
|
||||
PrintAndLogEx(INFO, "File size %zu bytes, file blocks %d (0x%x)", bytes_read, (uint16_t)(bytes_read >> 3), (uint16_t)(bytes_read >> 3));
|
||||
|
||||
+4
-4
@@ -185,7 +185,7 @@ static bool legic_xor(uint8_t *data, uint16_t cardsize) {
|
||||
}
|
||||
|
||||
|
||||
for(uint16_t i = 22; i < cardsize; i++) {
|
||||
for (uint16_t i = 22; i < cardsize; i++) {
|
||||
data[i] ^= crc;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "(De)Obsfuscation done");
|
||||
@@ -241,7 +241,7 @@ static int CmdLegicInfo(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "------------------------------------------------------");
|
||||
PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)",
|
||||
data[0],
|
||||
sprint_hex(data +1, 3),
|
||||
sprint_hex(data + 1, 3),
|
||||
data[4],
|
||||
(calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail")
|
||||
);
|
||||
@@ -667,7 +667,7 @@ static int CmdLegicWrbl(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "Out-of-bounds, bytes 0-1-2-3-4 can't be written to. Offset = %d", offset);
|
||||
return PM3_EOUTOFBOUND;
|
||||
}
|
||||
|
||||
|
||||
//Validations
|
||||
if (errors || cmdp == 0) {
|
||||
if (data)
|
||||
@@ -1088,7 +1088,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
if (shall_obsfuscate){
|
||||
if (shall_obsfuscate) {
|
||||
legic_xor(data, card.cardsize);
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -72,7 +72,7 @@ static char *getProtocolStr(uint8_t id, bool hw) {
|
||||
if (id == 0x04) {
|
||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3 MIFARE, 14443-4") ")", id);
|
||||
} else if (id == 0x05) {
|
||||
if (hw)
|
||||
if (hw)
|
||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-2, 14443-3") ")", id);
|
||||
else
|
||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3, 14443-4") ")", id);
|
||||
@@ -109,9 +109,9 @@ static char *getTypeStr(uint8_t type) {
|
||||
|
||||
static char buf[40] = {0x00};
|
||||
char *retStr = buf;
|
||||
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
case 1:
|
||||
sprintf(retStr, "0x%02X ( " _YELLOW_("DESFire") ")", type);
|
||||
break;
|
||||
case 2:
|
||||
@@ -130,17 +130,17 @@ static char *getTypeStr(uint8_t type) {
|
||||
}
|
||||
|
||||
static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||
|
||||
|
||||
// DESFire MF3ICD40
|
||||
if (major == 0x00 && minor == 0x00 )
|
||||
if (major == 0x00 && minor == 0x00)
|
||||
return DESFIRE_MF3ICD40;
|
||||
|
||||
|
||||
// DESFire EV1
|
||||
if (major == 0x01 && minor == 0x00 )
|
||||
if (major == 0x01 && minor == 0x00)
|
||||
return DESFIRE_EV1;
|
||||
|
||||
// DESFire EV2
|
||||
if (major == 0x12 && minor == 0x00 )
|
||||
if (major == 0x12 && minor == 0x00)
|
||||
return DESFIRE_EV2;
|
||||
|
||||
// DESFire EV3
|
||||
@@ -148,11 +148,11 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||
// return DESFIRE_EV3;
|
||||
|
||||
// DESFire Light
|
||||
if (major == 0x30 && minor == 0x00 )
|
||||
if (major == 0x30 && minor == 0x00)
|
||||
return DESFIRE_LIGHT;
|
||||
|
||||
// Plus EV1
|
||||
if (major == 0x11 && minor == 0x00 )
|
||||
if (major == 0x11 && minor == 0x00)
|
||||
return PLUS_EV1;
|
||||
|
||||
return MFP_UNKNOWN;
|
||||
@@ -162,7 +162,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||
static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) {
|
||||
|
||||
// ref: MIFARE Plus EV1 Originality Signature Validation
|
||||
#define PUBLIC_PLUS_ECDA_KEYLEN 57
|
||||
#define PUBLIC_PLUS_ECDA_KEYLEN 57
|
||||
const ecdsa_publickey_t nxp_plus_public_keys[] = {
|
||||
{"Mifare Plus EV1", "044409ADC42F91A8394066BA83D872FB1D16803734E911170412DDF8BAD1A4DADFD0416291AFE1C748253925DA39A5F39A1C557FFACD34C62E"}
|
||||
};
|
||||
@@ -185,7 +185,7 @@ static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Signature"));
|
||||
|
||||
|
||||
if (is_valid == false) {
|
||||
PrintAndLogEx(SUCCESS, "Signature verification " _RED_("failed"));
|
||||
return PM3_ESOFT;
|
||||
@@ -212,7 +212,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) {
|
||||
uint8_t data[59] = {0};
|
||||
int resplen = 0, retval = PM3_SUCCESS;
|
||||
MFPGetSignature(true, false, data, sizeof(data), &resplen);
|
||||
|
||||
|
||||
if (resplen == 59) {
|
||||
memcpy(signature, data + 1, 56);
|
||||
*signature_len = 56;
|
||||
@@ -227,7 +227,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) {
|
||||
static int plus_print_version(uint8_t *version) {
|
||||
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(version + 14, 7));
|
||||
PrintAndLogEx(SUCCESS, " Batch number: " _GREEN_("%s"), sprint_hex(version + 21, 5));
|
||||
PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7+7+7+5], version[7+7+7+5+1]);
|
||||
PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7 + 7 + 7 + 5], version[7 + 7 + 7 + 5 + 1]);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information"));
|
||||
PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(version[0]));
|
||||
@@ -247,7 +247,7 @@ static int plus_print_version(uint8_t *version) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int get_plus_version(uint8_t *version, int *version_len) {
|
||||
|
||||
|
||||
int resplen = 0, retval = PM3_SUCCESS;
|
||||
mfpSetVerboseMode(false);
|
||||
MFPGetVersion(true, false, version, *version_len, &resplen);
|
||||
@@ -282,7 +282,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
// info about 14a part
|
||||
infoHF14A(false, false, false);
|
||||
}
|
||||
|
||||
|
||||
// Mifare Plus info
|
||||
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
@@ -310,7 +310,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
if (supportVersion) {
|
||||
|
||||
int cardtype = getCardType(version[3], version[4]);
|
||||
|
||||
|
||||
if (cardtype == 6) {
|
||||
if (supportSignature) {
|
||||
PrintAndLogEx(INFO, " Tech: " _GREEN_("MIFARE Plus EV1"));
|
||||
@@ -319,7 +319,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
}
|
||||
isPlus = true;
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "ICEE: %s", sprint_hex(data, datalen));
|
||||
|
||||
if (memcmp(data, "\x67\x00", 2) == 0) {
|
||||
PrintAndLogEx(INFO, "\tMost likely a MIFARE DESFire tag");
|
||||
PrintAndLogEx(INFO, "\tMost likely a MIFARE DESFire tag");
|
||||
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`hf mfdes info`"));
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
@@ -390,11 +390,11 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||
// How do we detect SL0 / SL1 / SL2 / SL3 modes?!?
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Security Level (SL)"));
|
||||
|
||||
if (SLmode != 0xFF )
|
||||
if (SLmode != 0xFF)
|
||||
PrintAndLogEx(SUCCESS, " SL mode: " _YELLOW_("SL%d"), SLmode);
|
||||
else
|
||||
PrintAndLogEx(WARNING, " SL mode: " _YELLOW_("unknown"));
|
||||
switch(SLmode) {
|
||||
switch (SLmode) {
|
||||
case 0:
|
||||
PrintAndLogEx(INFO, " SL 0: initial delivery configuration, used for card personalization");
|
||||
break;
|
||||
|
||||
+67
-67
@@ -64,7 +64,7 @@ static int usage_hf_mfu_info(void) {
|
||||
static int usage_hf_mfu_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Reads all pages from Ultralight, Ultralight-C, Ultralight EV1");
|
||||
PrintAndLogEx(NORMAL, "NTAG 203, NTAG 210, NTAG 212, NTAG 213, NTAG 215, NTAG 216");
|
||||
PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`") );
|
||||
PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`"));
|
||||
PrintAndLogEx(NORMAL, "It autodetects card type.\n");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf mfu dump k <key> l f <filename w/o .bin> p <page#> q <#pages>");
|
||||
PrintAndLogEx(NORMAL, " Options :");
|
||||
@@ -89,8 +89,8 @@ static int usage_hf_mfu_restore(void) {
|
||||
PrintAndLogEx(NORMAL, " Options :");
|
||||
PrintAndLogEx(NORMAL, " k <key> : (optional) key for authentication [UL-C 16bytes, EV1/NTAG 4bytes]");
|
||||
PrintAndLogEx(NORMAL, " l : (optional) swap entered key's endianness");
|
||||
PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-") );
|
||||
PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-") );
|
||||
PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-"));
|
||||
PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-"));
|
||||
PrintAndLogEx(NORMAL, " r : (optional) use the password found in dumpfile to configure tag. requires " _YELLOW_("'e'") "parameter to work");
|
||||
PrintAndLogEx(NORMAL, " f <fn> : " _YELLOW_("filename w .bin") "to restore");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -135,7 +135,7 @@ static int usage_hf_mfu_wrbl(void) {
|
||||
}
|
||||
|
||||
static int usage_hf_mfu_eload(void) {
|
||||
PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`") );
|
||||
PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`"));
|
||||
PrintAndLogEx(NORMAL, "Hint: See " _YELLOW_("`script run dumptoemul-mfu`") "to convert the .bin to the eml");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf mfu eload u <file name w/o `.eml`> [numblocks]");
|
||||
PrintAndLogEx(NORMAL, " Options:");
|
||||
@@ -526,7 +526,7 @@ static int ul_print_default(uint8_t *data) {
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " BCC1: %02X, crc should be %02X", data[8], crc1);
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default") );
|
||||
PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default"));
|
||||
|
||||
PrintAndLogEx(SUCCESS, " Lock: %s - %s",
|
||||
sprint_hex(data + 10, 2),
|
||||
@@ -545,7 +545,7 @@ static int ndef_get_maxsize(uint8_t *data) {
|
||||
// no NDEF message
|
||||
if (data[0] != 0xE1)
|
||||
return 0;
|
||||
|
||||
|
||||
if (data[2] == 0x06)
|
||||
return 48;
|
||||
else if (data[2] == 0x12)
|
||||
@@ -865,7 +865,7 @@ static int ulev1_print_counters() {
|
||||
|
||||
static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *signature, size_t signature_len) {
|
||||
|
||||
#define PUBLIC_ECDA_KEYLEN 33
|
||||
#define PUBLIC_ECDA_KEYLEN 33
|
||||
// known public keys for the originality check (source: https://github.com/alexbatalov/node-nxp-originality-verifier)
|
||||
// ref: AN11350 NTAG 21x Originality Signature Validation
|
||||
// ref: AN11341 MIFARE Ultralight EV1 Originality Signature Validation
|
||||
@@ -878,64 +878,64 @@ static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *sig
|
||||
{"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"},
|
||||
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
||||
};
|
||||
|
||||
/*
|
||||
uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = {
|
||||
// UL, NTAG21x and NDEF
|
||||
{
|
||||
0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c,
|
||||
0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49,
|
||||
0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39,
|
||||
0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61
|
||||
},
|
||||
// UL EV1
|
||||
{
|
||||
0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b,
|
||||
0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8,
|
||||
0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72,
|
||||
0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||
},
|
||||
// manufacturer public key
|
||||
{
|
||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||
},
|
||||
// MIKRON public key.
|
||||
{
|
||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
/*
|
||||
uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = {
|
||||
// UL, NTAG21x and NDEF
|
||||
{
|
||||
0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c,
|
||||
0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49,
|
||||
0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39,
|
||||
0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61
|
||||
},
|
||||
// UL EV1
|
||||
{
|
||||
0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b,
|
||||
0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8,
|
||||
0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72,
|
||||
0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||
},
|
||||
// unknown. Needs identification
|
||||
{
|
||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||
},
|
||||
// manufacturer public key
|
||||
{
|
||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||
},
|
||||
// MIKRON public key.
|
||||
{
|
||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||
}
|
||||
};
|
||||
*/
|
||||
uint8_t i;
|
||||
int res;
|
||||
bool is_valid = false;
|
||||
for (i = 0; i< ARRAYLEN(nxp_mfu_public_keys); i++) {
|
||||
for (i = 0; i < ARRAYLEN(nxp_mfu_public_keys); i++) {
|
||||
|
||||
int dl = 0;
|
||||
uint8_t key[PUBLIC_ECDA_KEYLEN];
|
||||
param_gethex_to_eol(nxp_mfu_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl);
|
||||
|
||||
|
||||
res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 7, signature, signature_len, false);
|
||||
|
||||
|
||||
is_valid = (res == 0);
|
||||
if (is_valid)
|
||||
break;
|
||||
@@ -2721,7 +2721,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||
uint8_t key[16] = {0x00};
|
||||
uint8_t *p_key = key;
|
||||
uint8_t pack[4] = {0, 0, 0, 0};
|
||||
|
||||
|
||||
CLIParserInit("hf mfu ndef",
|
||||
"Prints NFC Data Exchange Format (NDEF)",
|
||||
"Usage:\n\thf mfu ndef -> shows NDEF data\n"
|
||||
@@ -2737,8 +2737,8 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||
CLIGetHexWithReturn(1, key, &keylen);
|
||||
swapEndian = arg_get_lit(2);
|
||||
CLIParserFree();
|
||||
|
||||
switch(keylen) {
|
||||
|
||||
switch (keylen) {
|
||||
case 0:
|
||||
break;
|
||||
case 4:
|
||||
@@ -2758,13 +2758,13 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||
}
|
||||
|
||||
// Is tag UL/NTAG?
|
||||
|
||||
|
||||
// Swap endianness
|
||||
if (swapEndian && hasAuthKey) p_key = SwapEndian64(key, keylen, (keylen == 16) ? 8 : 4);
|
||||
|
||||
// Select and Auth
|
||||
if (ul_auth_select(&card, tagtype, hasAuthKey, p_key, pack, sizeof(pack)) == PM3_ESOFT) return PM3_ESOFT;
|
||||
|
||||
|
||||
// read pages 0,1,2,3 (should read 4pages)
|
||||
status = ul_read(0, data, sizeof(data));
|
||||
if (status == -1) {
|
||||
@@ -2783,20 +2783,20 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||
// max datasize;
|
||||
maxsize = ndef_get_maxsize(data + 12);
|
||||
}
|
||||
|
||||
|
||||
// iceman: maybe always take MIN of tag identified size vs NDEF reported size?
|
||||
// fix: UL_EV1 48bytes != NDEF reported size
|
||||
for (uint8_t i = 0; i < ARRAYLEN(UL_TYPES_ARRAY); i++) {
|
||||
if (tagtype & UL_TYPES_ARRAY[i]) {
|
||||
|
||||
if (maxsize != (UL_MEMORY_ARRAY[i] * 4) ) {
|
||||
|
||||
if (maxsize != (UL_MEMORY_ARRAY[i] * 4)) {
|
||||
PrintAndLogEx(INFO, "Tag reported size vs NDEF reported size mismatch. Using smallest value");
|
||||
}
|
||||
maxsize = MIN(maxsize, (UL_MEMORY_ARRAY[i] * 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// allocate mem
|
||||
uint8_t *records = calloc(maxsize, sizeof(uint8_t));
|
||||
if (records == NULL) {
|
||||
@@ -2805,7 +2805,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||
}
|
||||
|
||||
// read NDEF records.
|
||||
for(uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) {
|
||||
for (uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) {
|
||||
status = ul_read(4 + j, records + i, 16);
|
||||
if (status == -1) {
|
||||
DropField();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user