mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-13 00:23:17 -07:00
make style
This commit is contained in:
parent
588f7e98f5
commit
94192d0976
44 changed files with 674 additions and 656 deletions
|
@ -20,7 +20,7 @@
|
||||||
#include "legicrf.h"
|
#include "legicrf.h"
|
||||||
#include "legicrfsim.h"
|
#include "legicrfsim.h"
|
||||||
#include "legic.h" // legic_card_select_t struct
|
#include "legic.h" // legic_card_select_t struct
|
||||||
#include "spiffs.h" // flashmem
|
#include "spiffs.h" // flashmem
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
void DownloadLogInstructions() {
|
void DownloadLogInstructions() {
|
||||||
Dbprintf("");
|
Dbprintf("");
|
||||||
Dbprintf("[=] List all dumps from flash:");
|
Dbprintf("[=] List all dumps from flash:");
|
||||||
Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree");
|
Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree");
|
||||||
Dbprintf("");
|
Dbprintf("");
|
||||||
Dbprintf("[=] To save a dump file from flash to client:");
|
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");
|
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.
|
// legic functions puts it memory in Emulator reserved memory.
|
||||||
uint8_t *mem = BigBuf_get_EM_addr();
|
uint8_t *mem = BigBuf_get_EM_addr();
|
||||||
|
|
||||||
char *preferredName = (char*)BigBuf_malloc(30);
|
char *preferredName = (char *)BigBuf_malloc(30);
|
||||||
if (preferredName == NULL) {
|
if (preferredName == NULL) {
|
||||||
goto OUT;
|
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]);
|
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);
|
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) {
|
if (filename == NULL) {
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ void RunMod() {
|
||||||
DbpString("[=] press and HOLD button to exit standalone mode");
|
DbpString("[=] press and HOLD button to exit standalone mode");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
//exit from hf_legic, send usbcommand
|
//exit from hf_legic, send usbcommand
|
||||||
if (data_available()) break;
|
if (data_available()) break;
|
||||||
|
|
||||||
|
@ -136,18 +136,18 @@ void RunMod() {
|
||||||
|
|
||||||
//simulate if read successfully
|
//simulate if read successfully
|
||||||
if (read_success != PM3_ESOFT) {
|
if (read_success != PM3_ESOFT) {
|
||||||
|
|
||||||
legic_card_select_t *p_card;
|
legic_card_select_t *p_card;
|
||||||
p_card = getLegicCardInfo();
|
p_card = getLegicCardInfo();
|
||||||
if (p_card->cardsize == 0)
|
if (p_card->cardsize == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
save_dump_to_file(p_card);
|
save_dump_to_file(p_card);
|
||||||
|
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
uint8_t ct;
|
uint8_t ct;
|
||||||
switch(p_card->tagtype) {
|
switch (p_card->tagtype) {
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
ct = 0;
|
ct = 0;
|
||||||
break;
|
break;
|
||||||
case 0x1D:
|
case 0x1D:
|
||||||
|
@ -156,7 +156,7 @@ void RunMod() {
|
||||||
case 0x3D:
|
case 0x3D:
|
||||||
ct = 2;
|
ct = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ void RunMod() {
|
||||||
StandAloneMode();
|
StandAloneMode();
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||||
Dbprintf("[=] >> LF EM4100 simulator started <<");
|
Dbprintf("[=] >> LF EM4100 simulator started <<");
|
||||||
|
|
||||||
int selected = 0; //selected slot after start
|
int selected = 0; //selected slot after start
|
||||||
slots_count = sizeof(low) / sizeof(low[0]);
|
slots_count = sizeof(low) / sizeof(low[0]);
|
||||||
bba = BigBuf_get_addr();
|
bba = BigBuf_get_addr();
|
||||||
|
|
|
@ -122,7 +122,7 @@ void RunMod() {
|
||||||
StandAloneMode();
|
StandAloneMode();
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||||
Dbprintf("[=] >> LF EM4100 read/write/clone started <<");
|
Dbprintf("[=] >> LF EM4100 read/write/clone started <<");
|
||||||
|
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
//state 0 - select slot
|
//state 0 - select slot
|
||||||
// 1 - read tag to selected slot,
|
// 1 - read tag to selected slot,
|
||||||
|
|
|
@ -524,7 +524,7 @@ int EPA_Setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
|
||||||
// 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
|
||||||
// power up the field
|
// power up the field
|
||||||
iso14443b_setup();
|
iso14443b_setup();
|
||||||
|
|
|
@ -52,8 +52,8 @@ size_t blocknr;
|
||||||
bool end = false;
|
bool end = false;
|
||||||
//#define SENDBIT_TEST
|
//#define SENDBIT_TEST
|
||||||
|
|
||||||
/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3
|
/* 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
|
// UID is 0 1 2 3 // tag.uid is 3210
|
||||||
// datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0
|
// datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0
|
||||||
|
|
||||||
#db# UID: 5F C2 11 84
|
#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,
|
// 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.
|
// external trigger rising edge, load RA on rising edge of TIOA.
|
||||||
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK
|
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
|
// Enable and reset counter
|
||||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
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
|
// Enable and reset external trigger in timer for capturing future frames
|
||||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
|
||||||
|
|
||||||
// Reset the received frame and response timing info
|
// Reset the received frame and response timing info
|
||||||
memset(rx, 0x00, sizeof(rx));
|
memset(rx, 0x00, sizeof(rx));
|
||||||
response = 0;
|
response = 0;
|
||||||
|
|
|
@ -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
|
// Only this functions are public / called from appmain.c
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
legic_card_select_t* getLegicCardInfo(void) {
|
legic_card_select_t *getLegicCardInfo(void) {
|
||||||
return &card;
|
return &card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv) {
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
legic_mem[i] = byte;
|
legic_mem[i] = byte;
|
||||||
|
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
card.uid[i] = byte;
|
card.uid[i] = byte;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
legic_mem[i] = byte;
|
legic_mem[i] = byte;
|
||||||
|
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
card.uid[i] = byte;
|
card.uid[i] = byte;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv);
|
||||||
void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data);
|
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 */
|
#endif /* __LEGICRF_H */
|
||||||
|
|
|
@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) {
|
||||||
WaitUS(32 * 8);
|
WaitUS(32 * 8);
|
||||||
} else {
|
} else {
|
||||||
TurnReadLF_off(23 * 8);
|
TurnReadLF_off(23 * 8);
|
||||||
TurnReadLFOn((32-23) * 8);
|
TurnReadLFOn((32 - 23) * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,16 +334,16 @@ void MifareDES_Auth1(uint8_t *datain) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rndlen=8;
|
int rndlen = 8;
|
||||||
int expectedlen = 1 + 8 + 2 + 2;
|
int expectedlen = 1 + 8 + 2 + 2;
|
||||||
if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) {
|
if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) {
|
||||||
expectedlen = 1 + 16 + 2 + 2;
|
expectedlen = 1 + 16 + 2 + 2;
|
||||||
rndlen=16;
|
rndlen = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload->mode == MFDES_AUTH_PICC) {
|
if (payload->mode == MFDES_AUTH_PICC) {
|
||||||
expectedlen = 1 + 1 + 8 + 2;
|
expectedlen = 1 + 1 + 8 + 2;
|
||||||
rndlen=8;
|
rndlen = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len != expectedlen) {
|
if (len != expectedlen) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
// PRIx64 definition missing with gcc-arm-none-eabi v8?
|
// PRIx64 definition missing with gcc-arm-none-eabi v8?
|
||||||
#ifndef PRIx64
|
#ifndef PRIx64
|
||||||
#define PRIx64 "llx"
|
#define PRIx64 "llx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Basic macros
|
// Basic macros
|
||||||
|
|
|
@ -165,7 +165,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
|
||||||
if (ibuf == 0) {
|
if (ibuf == 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) {
|
switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) {
|
||||||
case 1:
|
case 1:
|
||||||
printf("Parameter error: Invalid HEX value.\n");
|
printf("Parameter error: Invalid HEX value.\n");
|
||||||
|
|
|
@ -140,7 +140,7 @@ static int CmdFlashMemSpiFFSRemove(const char *Cmd) {
|
||||||
|
|
||||||
static int CmdFlashMemSpiFFSRename(const char *Cmd) {
|
static int CmdFlashMemSpiFFSRename(const char *Cmd) {
|
||||||
|
|
||||||
int len = strlen(Cmd);
|
int len = strlen(Cmd);
|
||||||
if (len < 1) {
|
if (len < 1) {
|
||||||
return usage_flashmemspiffs_rename();
|
return usage_flashmemspiffs_rename();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ static int CmdFlashMemSpiFFSRename(const char *Cmd) {
|
||||||
if (len == 1 && ctmp == 'h') {
|
if (len == 1 && ctmp == 'h') {
|
||||||
return usage_flashmemspiffs_rename();
|
return usage_flashmemspiffs_rename();
|
||||||
}
|
}
|
||||||
|
|
||||||
char srcfilename[32] = {0};
|
char srcfilename[32] = {0};
|
||||||
char destfilename[32] = {0};
|
char destfilename[32] = {0};
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
|
@ -195,7 +195,7 @@ static int CmdFlashMemSpiFFSCopy(const char *Cmd) {
|
||||||
return usage_flashmemspiffs_copy();
|
return usage_flashmemspiffs_copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char srcfilename[32] = {0};
|
char srcfilename[32] = {0};
|
||||||
char destfilename[32] = {0};
|
char destfilename[32] = {0};
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
|
@ -457,7 +457,8 @@ static int CmdFlashMemSpiFFSLoad(const char *Cmd) {
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
|
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
|
{
|
||||||
|
"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
|
||||||
"Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)"
|
"Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)"
|
||||||
},
|
},
|
||||||
{"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"},
|
{"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"},
|
||||||
|
|
|
@ -86,8 +86,8 @@ int CmdHFSearch(const char *Cmd) {
|
||||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||||
if (cmdp == 'h') return usage_hf_search();
|
if (cmdp == 'h') return usage_hf_search();
|
||||||
|
|
||||||
int res = PM3_ESOFT;
|
int res = PM3_ESOFT;
|
||||||
|
|
||||||
PROMPT_CLEARLINE;
|
PROMPT_CLEARLINE;
|
||||||
PrintAndLogEx(INPLACE, "Searching for ThinFilm tag...");
|
PrintAndLogEx(INPLACE, "Searching for ThinFilm tag...");
|
||||||
if (IfPm3NfcBarcode()) {
|
if (IfPm3NfcBarcode()) {
|
||||||
|
@ -150,17 +150,17 @@ int CmdHFSearch(const char *Cmd) {
|
||||||
res = PM3_SUCCESS;
|
res = PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// 14b and iclass is the longest test (put last)
|
// 14b and iclass is the longest test (put last)
|
||||||
PROMPT_CLEARLINE;
|
PROMPT_CLEARLINE;
|
||||||
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
|
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
|
||||||
if (IfPm3Iso14443b()) {
|
if (IfPm3Iso14443b()) {
|
||||||
if (readHFCryptoRF(false) == PM3_SUCCESS) {
|
if (readHFCryptoRF(false) == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n");
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") "found\n");
|
||||||
res = PM3_SUCCESS;
|
res = PM3_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
// 14b and iclass is the longest test (put last)
|
// 14b and iclass is the longest test (put last)
|
||||||
PROMPT_CLEARLINE;
|
PROMPT_CLEARLINE;
|
||||||
|
|
|
@ -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.
|
// Double & triple sized UID, can be mapped to a manufacturer.
|
||||||
if (card.uidlen <= 4) {
|
if (card.uidlen <= 4) {
|
||||||
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
||||||
|
|
||||||
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
||||||
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
||||||
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
||||||
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
||||||
|
|
||||||
if ((nxptype & MTOTHER) == MTOTHER)
|
if ((nxptype & MTOTHER) == MTOTHER)
|
||||||
isMifareClassic = true;
|
isMifareClassic = true;
|
||||||
}
|
}
|
||||||
|
@ -1433,13 +1433,13 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
switch (card.uid[0]) {
|
switch (card.uid[0]) {
|
||||||
case 0x04: // NXP
|
case 0x04: // NXP
|
||||||
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
nxptype = detect_nxp_card(card.sak, ((card.atqa[1] << 8) + card.atqa[0]));
|
||||||
|
|
||||||
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
isMifareClassic = ((nxptype & MTCLASSIC) == MTCLASSIC);
|
||||||
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
isMifareDESFire = ((nxptype & MTDESFIRE) == MTDESFIRE);
|
||||||
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
isMifarePlus = ((nxptype & MTPLUS) == MTPLUS);
|
||||||
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
isMifareUltralight = ((nxptype & MTULTRALIGHT) == MTULTRALIGHT);
|
||||||
|
|
||||||
if ((nxptype & MTOTHER) == MTOTHER)
|
if ((nxptype & MTOTHER) == MTOTHER)
|
||||||
isMifareClassic = true;
|
isMifareClassic = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
106
client/cmdhf15.c
106
client/cmdhf15.c
|
@ -212,8 +212,8 @@ static int CmdHF15Help(const char *Cmd);
|
||||||
|
|
||||||
static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
|
||||||
|
|
||||||
#define PUBLIC_ECDA_KEYLEN 33
|
#define PUBLIC_ECDA_KEYLEN 33
|
||||||
const ecdsa_publickey_t nxp_15693_public_keys[] = {
|
const ecdsa_publickey_t nxp_15693_public_keys[] = {
|
||||||
{"NXP Mifare Classic MFC1C14_x", "044F6D3F294DEA5737F0F46FFEE88A356EED95695DD7E0C27A591E6F6F65962BAF"},
|
{"NXP Mifare Classic MFC1C14_x", "044F6D3F294DEA5737F0F46FFEE88A356EED95695DD7E0C27A591E6F6F65962BAF"},
|
||||||
{"Manufacturer Mifare Classic MFC1C14_x", "046F70AC557F5461CE5052C8E4A7838C11C7A236797E8A0730A101837C004039C2"},
|
{"Manufacturer Mifare Classic MFC1C14_x", "046F70AC557F5461CE5052C8E4A7838C11C7A236797E8A0730A101837C004039C2"},
|
||||||
{"NXP ICODE DNA, ICODE SLIX2", "048878A2A2D3EEC336B4F261A082BD71F9BE11C4E2E896648B32EFA59CEA6E59F0"},
|
{"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"},
|
{"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"},
|
||||||
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = {
|
uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = {
|
||||||
// ICODE SLIX2 / DNA
|
// ICODE SLIX2 / DNA
|
||||||
{
|
{
|
||||||
0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3,
|
0x04, 0x88, 0x78, 0xA2, 0xA2, 0xD3, 0xEE, 0xC3,
|
||||||
0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71,
|
0x36, 0xB4, 0xF2, 0x61, 0xA0, 0x82, 0xBD, 0x71,
|
||||||
0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64,
|
0xF9, 0xBE, 0x11, 0xC4, 0xE2, 0xE8, 0x96, 0x64,
|
||||||
0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0
|
0x8B, 0x32, 0xEF, 0xA5, 0x9C, 0xEA, 0x6E, 0x59, 0xF0
|
||||||
},
|
},
|
||||||
// unknown. Needs identification
|
// unknown. Needs identification
|
||||||
{
|
{
|
||||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||||
},
|
},
|
||||||
// unknown. Needs identification
|
// unknown. Needs identification
|
||||||
{
|
{
|
||||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||||
},
|
},
|
||||||
// manufacturer public key
|
// manufacturer public key
|
||||||
{
|
{
|
||||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||||
},
|
},
|
||||||
// MIKRON public key.
|
// MIKRON public key.
|
||||||
{
|
{
|
||||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
int res;
|
int res;
|
||||||
bool is_valid = false;
|
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;
|
int dl = 0;
|
||||||
uint8_t key[PUBLIC_ECDA_KEYLEN];
|
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);
|
res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 8, signature, 32, false);
|
||||||
is_valid = (res == 0);
|
is_valid = (res == 0);
|
||||||
if (is_valid)
|
if (is_valid)
|
||||||
|
@ -589,7 +589,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memcpy(&req[tmpreqlen], uid, sizeof(uid));
|
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);
|
tmpreqlen += sizeof(uid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -602,7 +602,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
|
||||||
uid[7 - i] = temp & 0xff;
|
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));
|
memcpy(&req[tmpreqlen], uid, sizeof(uid));
|
||||||
tmpreqlen += sizeof(uid);
|
tmpreqlen += sizeof(uid);
|
||||||
break;
|
break;
|
||||||
|
@ -931,7 +931,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") "---------");
|
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") "---------");
|
||||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||||
PrintAndLogEx(SUCCESS, " TYPE: " _YELLOW_("%s"), getTagInfo_15(recv + 2));
|
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));
|
PrintAndLogEx(SUCCESS, " SYSINFO: %s", sprint_hex(recv, status - 2));
|
||||||
|
|
||||||
// DSFID
|
// DSFID
|
||||||
|
@ -1003,7 +1003,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
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();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_HF_ISO15693_SIMULATE, 0, 0, 0, uid, 8);
|
SendCommandOLD(CMD_HF_ISO15693_SIMULATE, 0, 0, 0, uid, 8);
|
||||||
|
@ -1201,7 +1201,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||||
}
|
}
|
||||||
// detect blocksize from card :)
|
// 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;
|
int blocknum = 0;
|
||||||
uint8_t *recv = NULL;
|
uint8_t *recv = NULL;
|
||||||
|
@ -1271,7 +1271,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "\n");
|
PrintAndLogEx(NORMAL, "\n");
|
||||||
|
|
||||||
size_t datalen = blocknum * 4;
|
size_t datalen = blocknum * 4;
|
||||||
saveFile(filename, ".bin", data, datalen);
|
saveFile(filename, ".bin", data, datalen);
|
||||||
saveFileEML(filename, data, datalen, 4);
|
saveFileEML(filename, data, datalen, 4);
|
||||||
saveFileJSON(filename, jsf15, data, datalen);
|
saveFileJSON(filename, jsf15, data, datalen);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -1446,7 +1446,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip status byte
|
// skip status byte
|
||||||
int start = 1;
|
int start = 1;
|
||||||
int stop = (pagecount + 1) * 5;
|
int stop = (pagecount + 1) * 5;
|
||||||
int currblock = pagenum;
|
int currblock = pagenum;
|
||||||
// print response
|
// print response
|
||||||
|
@ -1680,7 +1680,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = fopen(filename, "rb")) == NULL) {
|
if ((f = fopen(filename, "rb")) == NULL) {
|
||||||
|
|
||||||
PrintAndLogEx(WARNING, "Could not find file %s", filename);
|
PrintAndLogEx(WARNING, "Could not find file %s", filename);
|
||||||
return PM3_EFILE;
|
return PM3_EFILE;
|
||||||
}
|
}
|
||||||
|
@ -1762,7 +1762,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
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)) {
|
if (!getUID(oldUid)) {
|
||||||
PrintAndLogEx(FAILED, "Can't get old/current UID.");
|
PrintAndLogEx(FAILED, "Can't get old/current UID.");
|
||||||
|
|
|
@ -25,86 +25,86 @@ static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_hf_cryptorf_info(void) {
|
static int usage_hf_cryptorf_info(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf cryptorf info [h] [v]\n"
|
PrintAndLogEx(NORMAL, "Usage: hf cryptorf info [h] [v]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" v verbose\n"
|
" v verbose\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_(" hf cryptorf info")
|
_YELLOW_(" hf cryptorf info")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_reader(void) {
|
static int usage_hf_cryptorf_reader(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf cryptorf reader [h] [v]\n"
|
PrintAndLogEx(NORMAL, "Usage: hf cryptorf reader [h] [v]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" v verbose\n"
|
" v verbose\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_(" hf cryptorf reader")
|
_YELLOW_(" hf cryptorf reader")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_sniff(void) {
|
static int usage_hf_cryptorf_sniff(void) {
|
||||||
PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer\n"
|
PrintAndLogEx(NORMAL, "It get data from the field and saves it into command buffer\n"
|
||||||
"Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n"
|
"Buffer accessible from command " _YELLOW_("'hf list cryptorf'") "\n"
|
||||||
"Usage: hf cryptorf sniff [h]\n"
|
"Usage: hf cryptorf sniff [h]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_(" hf cryptorf sniff")
|
_YELLOW_(" hf cryptorf sniff")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_sim(void) {
|
static int usage_hf_cryptorf_sim(void) {
|
||||||
PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with 4 UID / PUPI\n"
|
PrintAndLogEx(NORMAL, "Emulating CryptoRF tag with 4 UID / PUPI\n"
|
||||||
"Usage: hf cryptorf sim [h] [u <uid>]\n"
|
"Usage: hf cryptorf sim [h] [u <uid>]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" u 4byte UID/PUPI\n"
|
" u 4byte UID/PUPI\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example:\n"
|
"Example:\n"
|
||||||
_YELLOW_(" hf cryptorf sim")
|
_YELLOW_(" hf cryptorf sim")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_dump(void) {
|
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"
|
PrintAndLogEx(NORMAL, "This command dumps the contents of a ISO-14443-B tag and save it to file\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: hf cryptorf dump [h] [card memory] <f filname> \n"
|
"Usage: hf cryptorf dump [h] [card memory] <f filname> \n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Examples:\n"
|
"Examples:\n"
|
||||||
"\thf cryptorf dump\n"
|
"\thf cryptorf dump\n"
|
||||||
"\thf cryptorf dump f mydump");
|
"\thf cryptorf dump f mydump");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_eload(void) {
|
static int usage_hf_cryptorf_eload(void) {
|
||||||
PrintAndLogEx(NORMAL, "It loads a binary dump into emulator memory\n"
|
PrintAndLogEx(NORMAL, "It loads a binary dump into emulator memory\n"
|
||||||
"Usage: hf cryptorf eload [f <file name w/o `.eml`>]\n"
|
"Usage: hf cryptorf eload [f <file name w/o `.eml`>]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Examples:\n"
|
"Examples:\n"
|
||||||
_YELLOW_(" hf cryptorf eload f filename")
|
_YELLOW_(" hf cryptorf eload f filename")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_hf_cryptorf_esave(void) {
|
static int usage_hf_cryptorf_esave(void) {
|
||||||
PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n"
|
PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n"
|
||||||
" Usage: hf cryptorf esave [f <file name w/o `.eml`>]\n"
|
" Usage: hf cryptorf esave [f <file name w/o `.eml`>]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" h this help\n"
|
" h this help\n"
|
||||||
" f <name> filename, if no <name> UID will be used as filename\n"
|
" f <name> filename, if no <name> UID will be used as filename\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Examples:\n"
|
"Examples:\n"
|
||||||
_YELLOW_(" hf cryptorf esave ")
|
_YELLOW_(" hf cryptorf esave ")
|
||||||
_YELLOW_(" hf cryptorf esave f filename")
|
_YELLOW_(" hf cryptorf esave f filename")
|
||||||
);
|
);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
|
||||||
case 'h' :
|
case 'h' :
|
||||||
return usage_hf_cryptorf_eload();
|
return usage_hf_cryptorf_eload();
|
||||||
case 'f' :
|
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");
|
PrintAndLogEx(FAILED, "Filename too long");
|
||||||
errors = true;
|
errors = true;
|
||||||
break;
|
break;
|
||||||
|
@ -414,26 +414,26 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Uploading to emulator memory");
|
PrintAndLogEx(SUCCESS, "Uploading to emulator memory");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// fast push mode
|
// fast push mode
|
||||||
conn.block_after_ACK = true;
|
conn.block_after_ACK = true;
|
||||||
|
|
||||||
//Send to device
|
//Send to device
|
||||||
uint32_t bytes_sent = 0;
|
uint32_t bytes_sent = 0;
|
||||||
uint32_t bytes_remaining = bytes_read;
|
uint32_t bytes_remaining = bytes_read;
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||||
if (bytes_in_packet == bytes_remaining) {
|
if (bytes_in_packet == bytes_remaining) {
|
||||||
// Disable fast mode on last packet
|
// Disable fast mode on last packet
|
||||||
conn.block_after_ACK = false;
|
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);
|
free(data);
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, "Done");
|
PrintAndLogEx(SUCCESS, "Done");
|
||||||
|
@ -524,10 +524,10 @@ int CmdHFCryptoRF(const char *Cmd) {
|
||||||
return CmdsParse(CommandTable, Cmd);
|
return CmdsParse(CommandTable, Cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print extented information about tag.
|
// Print extented information about tag.
|
||||||
int infoHFCryptoRF(bool verbose) {
|
int infoHFCryptoRF(bool verbose) {
|
||||||
|
|
||||||
int res = PM3_ESOFT;
|
int res = PM3_ESOFT;
|
||||||
|
|
||||||
// 14b get and print UID only (general info)
|
// 14b get and print UID only (general info)
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
|
@ -580,7 +580,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
}
|
}
|
||||||
uint8_t num_mac = resp.oldarg[1];
|
uint8_t num_mac = resp.oldarg[1];
|
||||||
bool success = (NUM_CSNS == num_mac);
|
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)
|
if (num_mac == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -939,7 +939,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||||
|
|
||||||
if (aa1_encryption == RFU || aa1_encryption == None)
|
if (aa1_encryption == RFU || aa1_encryption == None)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Decrypted block 7,8,9 if configured.
|
// Decrypted block 7,8,9 if configured.
|
||||||
if (blocknum > 6 && blocknum <= 6 + numblocks4userid && memcmp(enc_data, empty, 8) != 0) {
|
if (blocknum > 6 && blocknum <= 6 + numblocks4userid && memcmp(enc_data, empty, 8) != 0) {
|
||||||
if (use_sc) {
|
if (use_sc) {
|
||||||
|
@ -1329,7 +1329,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// dump cmd switch off at device when finised.
|
// dump cmd switch off at device when finised.
|
||||||
|
|
||||||
uint32_t blocksRead = resp.oldarg[1];
|
uint32_t blocksRead = resp.oldarg[1];
|
||||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||||
if (!isOK && !blocksRead) {
|
if (!isOK && !blocksRead) {
|
||||||
|
@ -2009,11 +2009,11 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
|
||||||
case 'e':
|
case 'e':
|
||||||
endblock = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
endblock = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
||||||
cmdp += 2;
|
cmdp += 2;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = true;
|
verbose = true;
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, cmdp));
|
||||||
errors = true;
|
errors = true;
|
||||||
|
@ -2047,7 +2047,7 @@ static int CmdHFiClassReadTagFile(const char *Cmd) {
|
||||||
}
|
}
|
||||||
size_t bytes_read = fread(dump, 1, fsize, f);
|
size_t bytes_read = fread(dump, 1, fsize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "File: " _YELLOW_("%s"), filename);
|
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));
|
PrintAndLogEx(INFO, "File size %zu bytes, file blocks %d (0x%x)", bytes_read, (uint16_t)(bytes_read >> 3), (uint16_t)(bytes_read >> 3));
|
||||||
|
|
|
@ -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;
|
data[i] ^= crc;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(SUCCESS, "(De)Obsfuscation done");
|
PrintAndLogEx(SUCCESS, "(De)Obsfuscation done");
|
||||||
|
@ -241,7 +241,7 @@ static int CmdLegicInfo(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "------------------------------------------------------");
|
PrintAndLogEx(NORMAL, "------------------------------------------------------");
|
||||||
PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)",
|
PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)",
|
||||||
data[0],
|
data[0],
|
||||||
sprint_hex(data +1, 3),
|
sprint_hex(data + 1, 3),
|
||||||
data[4],
|
data[4],
|
||||||
(calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail")
|
(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);
|
PrintAndLogEx(WARNING, "Out-of-bounds, bytes 0-1-2-3-4 can't be written to. Offset = %d", offset);
|
||||||
return PM3_EOUTOFBOUND;
|
return PM3_EOUTOFBOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors || cmdp == 0) {
|
if (errors || cmdp == 0) {
|
||||||
if (data)
|
if (data)
|
||||||
|
@ -1088,7 +1088,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||||
return PM3_EFILE;
|
return PM3_EFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shall_obsfuscate){
|
if (shall_obsfuscate) {
|
||||||
legic_xor(data, card.cardsize);
|
legic_xor(data, card.cardsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ static char *getProtocolStr(uint8_t id, bool hw) {
|
||||||
if (id == 0x04) {
|
if (id == 0x04) {
|
||||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3 MIFARE, 14443-4") ")", id);
|
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3 MIFARE, 14443-4") ")", id);
|
||||||
} else if (id == 0x05) {
|
} else if (id == 0x05) {
|
||||||
if (hw)
|
if (hw)
|
||||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-2, 14443-3") ")", id);
|
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-2, 14443-3") ")", id);
|
||||||
else
|
else
|
||||||
sprintf(retStr, "0x%02X ( " _YELLOW_("ISO 14443-3, 14443-4") ")", id);
|
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};
|
static char buf[40] = {0x00};
|
||||||
char *retStr = buf;
|
char *retStr = buf;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1:
|
case 1:
|
||||||
sprintf(retStr, "0x%02X ( " _YELLOW_("DESFire") ")", type);
|
sprintf(retStr, "0x%02X ( " _YELLOW_("DESFire") ")", type);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -130,17 +130,17 @@ static char *getTypeStr(uint8_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||||
|
|
||||||
// DESFire MF3ICD40
|
// DESFire MF3ICD40
|
||||||
if (major == 0x00 && minor == 0x00 )
|
if (major == 0x00 && minor == 0x00)
|
||||||
return DESFIRE_MF3ICD40;
|
return DESFIRE_MF3ICD40;
|
||||||
|
|
||||||
// DESFire EV1
|
// DESFire EV1
|
||||||
if (major == 0x01 && minor == 0x00 )
|
if (major == 0x01 && minor == 0x00)
|
||||||
return DESFIRE_EV1;
|
return DESFIRE_EV1;
|
||||||
|
|
||||||
// DESFire EV2
|
// DESFire EV2
|
||||||
if (major == 0x12 && minor == 0x00 )
|
if (major == 0x12 && minor == 0x00)
|
||||||
return DESFIRE_EV2;
|
return DESFIRE_EV2;
|
||||||
|
|
||||||
// DESFire EV3
|
// DESFire EV3
|
||||||
|
@ -148,11 +148,11 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
||||||
// return DESFIRE_EV3;
|
// return DESFIRE_EV3;
|
||||||
|
|
||||||
// DESFire Light
|
// DESFire Light
|
||||||
if (major == 0x30 && minor == 0x00 )
|
if (major == 0x30 && minor == 0x00)
|
||||||
return DESFIRE_LIGHT;
|
return DESFIRE_LIGHT;
|
||||||
|
|
||||||
// Plus EV1
|
// Plus EV1
|
||||||
if (major == 0x11 && minor == 0x00 )
|
if (major == 0x11 && minor == 0x00)
|
||||||
return PLUS_EV1;
|
return PLUS_EV1;
|
||||||
|
|
||||||
return MFP_UNKNOWN;
|
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) {
|
static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) {
|
||||||
|
|
||||||
// ref: MIFARE Plus EV1 Originality Signature Validation
|
// 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[] = {
|
const ecdsa_publickey_t nxp_plus_public_keys[] = {
|
||||||
{"Mifare Plus EV1", "044409ADC42F91A8394066BA83D872FB1D16803734E911170412DDF8BAD1A4DADFD0416291AFE1C748253925DA39A5F39A1C557FFACD34C62E"}
|
{"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(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Signature"));
|
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Signature"));
|
||||||
|
|
||||||
if (is_valid == false) {
|
if (is_valid == false) {
|
||||||
PrintAndLogEx(SUCCESS, "Signature verification " _RED_("failed"));
|
PrintAndLogEx(SUCCESS, "Signature verification " _RED_("failed"));
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -212,7 +212,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) {
|
||||||
uint8_t data[59] = {0};
|
uint8_t data[59] = {0};
|
||||||
int resplen = 0, retval = PM3_SUCCESS;
|
int resplen = 0, retval = PM3_SUCCESS;
|
||||||
MFPGetSignature(true, false, data, sizeof(data), &resplen);
|
MFPGetSignature(true, false, data, sizeof(data), &resplen);
|
||||||
|
|
||||||
if (resplen == 59) {
|
if (resplen == 59) {
|
||||||
memcpy(signature, data + 1, 56);
|
memcpy(signature, data + 1, 56);
|
||||||
*signature_len = 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) {
|
static int plus_print_version(uint8_t *version) {
|
||||||
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(version + 14, 7));
|
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(version + 14, 7));
|
||||||
PrintAndLogEx(SUCCESS, " Batch number: " _GREEN_("%s"), sprint_hex(version + 21, 5));
|
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(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information"));
|
PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information"));
|
||||||
PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(version[0]));
|
PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(version[0]));
|
||||||
|
@ -247,7 +247,7 @@ static int plus_print_version(uint8_t *version) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int get_plus_version(uint8_t *version, int *version_len) {
|
static int get_plus_version(uint8_t *version, int *version_len) {
|
||||||
|
|
||||||
int resplen = 0, retval = PM3_SUCCESS;
|
int resplen = 0, retval = PM3_SUCCESS;
|
||||||
mfpSetVerboseMode(false);
|
mfpSetVerboseMode(false);
|
||||||
MFPGetVersion(true, false, version, *version_len, &resplen);
|
MFPGetVersion(true, false, version, *version_len, &resplen);
|
||||||
|
@ -282,7 +282,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||||
// info about 14a part
|
// info about 14a part
|
||||||
infoHF14A(false, false, false);
|
infoHF14A(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mifare Plus info
|
// Mifare Plus info
|
||||||
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
|
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
@ -310,7 +310,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||||
if (supportVersion) {
|
if (supportVersion) {
|
||||||
|
|
||||||
int cardtype = getCardType(version[3], version[4]);
|
int cardtype = getCardType(version[3], version[4]);
|
||||||
|
|
||||||
if (cardtype == 6) {
|
if (cardtype == 6) {
|
||||||
if (supportSignature) {
|
if (supportSignature) {
|
||||||
PrintAndLogEx(INFO, " Tech: " _GREEN_("MIFARE Plus EV1"));
|
PrintAndLogEx(INFO, " Tech: " _GREEN_("MIFARE Plus EV1"));
|
||||||
|
@ -319,7 +319,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||||
}
|
}
|
||||||
isPlus = true;
|
isPlus = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "ICEE: %s", sprint_hex(data, datalen));
|
PrintAndLogEx(INFO, "ICEE: %s", sprint_hex(data, datalen));
|
||||||
|
|
||||||
if (memcmp(data, "\x67\x00", 2) == 0) {
|
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`"));
|
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`hf mfdes info`"));
|
||||||
DropField();
|
DropField();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -390,11 +390,11 @@ static int CmdHFMFPInfo(const char *Cmd) {
|
||||||
// How do we detect SL0 / SL1 / SL2 / SL3 modes?!?
|
// How do we detect SL0 / SL1 / SL2 / SL3 modes?!?
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("Security Level (SL)"));
|
PrintAndLogEx(INFO, "--- " _CYAN_("Security Level (SL)"));
|
||||||
|
|
||||||
if (SLmode != 0xFF )
|
if (SLmode != 0xFF)
|
||||||
PrintAndLogEx(SUCCESS, " SL mode: " _YELLOW_("SL%d"), SLmode);
|
PrintAndLogEx(SUCCESS, " SL mode: " _YELLOW_("SL%d"), SLmode);
|
||||||
else
|
else
|
||||||
PrintAndLogEx(WARNING, " SL mode: " _YELLOW_("unknown"));
|
PrintAndLogEx(WARNING, " SL mode: " _YELLOW_("unknown"));
|
||||||
switch(SLmode) {
|
switch (SLmode) {
|
||||||
case 0:
|
case 0:
|
||||||
PrintAndLogEx(INFO, " SL 0: initial delivery configuration, used for card personalization");
|
PrintAndLogEx(INFO, " SL 0: initial delivery configuration, used for card personalization");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -64,7 +64,7 @@ static int usage_hf_mfu_info(void) {
|
||||||
static int usage_hf_mfu_dump(void) {
|
static int usage_hf_mfu_dump(void) {
|
||||||
PrintAndLogEx(NORMAL, "Reads all pages from Ultralight, Ultralight-C, Ultralight EV1");
|
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, "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, "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, "Usage: hf mfu dump k <key> l f <filename w/o .bin> p <page#> q <#pages>");
|
||||||
PrintAndLogEx(NORMAL, " Options :");
|
PrintAndLogEx(NORMAL, " Options :");
|
||||||
|
@ -89,8 +89,8 @@ static int usage_hf_mfu_restore(void) {
|
||||||
PrintAndLogEx(NORMAL, " Options :");
|
PrintAndLogEx(NORMAL, " Options :");
|
||||||
PrintAndLogEx(NORMAL, " k <key> : (optional) key for authentication [UL-C 16bytes, EV1/NTAG 4bytes]");
|
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, " l : (optional) swap entered key's endianness");
|
||||||
PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG 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, " 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, " 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, " f <fn> : " _YELLOW_("filename w .bin") "to restore");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
@ -135,7 +135,7 @@ static int usage_hf_mfu_wrbl(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usage_hf_mfu_eload(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, "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, "Usage: hf mfu eload u <file name w/o `.eml`> [numblocks]");
|
||||||
PrintAndLogEx(NORMAL, " Options:");
|
PrintAndLogEx(NORMAL, " Options:");
|
||||||
|
@ -526,7 +526,7 @@ static int ul_print_default(uint8_t *data) {
|
||||||
else
|
else
|
||||||
PrintAndLogEx(NORMAL, " BCC1: %02X, crc should be %02X", data[8], crc1);
|
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",
|
PrintAndLogEx(SUCCESS, " Lock: %s - %s",
|
||||||
sprint_hex(data + 10, 2),
|
sprint_hex(data + 10, 2),
|
||||||
|
@ -545,7 +545,7 @@ static int ndef_get_maxsize(uint8_t *data) {
|
||||||
// no NDEF message
|
// no NDEF message
|
||||||
if (data[0] != 0xE1)
|
if (data[0] != 0xE1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data[2] == 0x06)
|
if (data[2] == 0x06)
|
||||||
return 48;
|
return 48;
|
||||||
else if (data[2] == 0x12)
|
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) {
|
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)
|
// known public keys for the originality check (source: https://github.com/alexbatalov/node-nxp-originality-verifier)
|
||||||
// ref: AN11350 NTAG 21x Originality Signature Validation
|
// ref: AN11350 NTAG 21x Originality Signature Validation
|
||||||
// ref: AN11341 MIFARE Ultralight EV1 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"},
|
{"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"},
|
||||||
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = {
|
uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = {
|
||||||
// UL, NTAG21x and NDEF
|
// UL, NTAG21x and NDEF
|
||||||
{
|
{
|
||||||
0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c,
|
0x04, 0x49, 0x4e, 0x1a, 0x38, 0x6d, 0x3d, 0x3c,
|
||||||
0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49,
|
0xfe, 0x3d, 0xc1, 0x0e, 0x5d, 0xe6, 0x8a, 0x49,
|
||||||
0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39,
|
0x9b, 0x1c, 0x20, 0x2d, 0xb5, 0xb1, 0x32, 0x39,
|
||||||
0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61
|
0x3e, 0x89, 0xed, 0x19, 0xfe, 0x5b, 0xe8, 0xbc, 0x61
|
||||||
},
|
},
|
||||||
// UL EV1
|
// UL EV1
|
||||||
{
|
{
|
||||||
0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b,
|
0x04, 0x90, 0x93, 0x3b, 0xdc, 0xd6, 0xe9, 0x9b,
|
||||||
0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8,
|
0x4e, 0x25, 0x5e, 0x3d, 0xa5, 0x53, 0x89, 0xa8,
|
||||||
0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72,
|
0x27, 0x56, 0x4e, 0x11, 0x71, 0x8e, 0x01, 0x72,
|
||||||
0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8
|
0x92, 0xfa, 0xf2, 0x32, 0x26, 0xa9, 0x66, 0x14, 0xb8
|
||||||
},
|
},
|
||||||
// unknown. Needs identification
|
// unknown. Needs identification
|
||||||
{
|
{
|
||||||
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
0x04, 0x4F, 0x6D, 0x3F, 0x29, 0x4D, 0xEA, 0x57,
|
||||||
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
0x37, 0xF0, 0xF4, 0x6F, 0xFE, 0xE8, 0x8A, 0x35,
|
||||||
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
0x6E, 0xED, 0x95, 0x69, 0x5D, 0xD7, 0xE0, 0xC2,
|
||||||
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
0x7A, 0x59, 0x1E, 0x6F, 0x6F, 0x65, 0x96, 0x2B, 0xAF
|
||||||
},
|
},
|
||||||
// unknown. Needs identification
|
// unknown. Needs identification
|
||||||
{
|
{
|
||||||
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
0x04, 0xA7, 0x48, 0xB6, 0xA6, 0x32, 0xFB, 0xEE,
|
||||||
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
0x2C, 0x08, 0x97, 0x70, 0x2B, 0x33, 0xBE, 0xA1,
|
||||||
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
0xC0, 0x74, 0x99, 0x8E, 0x17, 0xB8, 0x4A, 0xCA,
|
||||||
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
0x04, 0xFF, 0x26, 0x7E, 0x5D, 0x2C, 0x91, 0xF6, 0xDC
|
||||||
},
|
},
|
||||||
// manufacturer public key
|
// manufacturer public key
|
||||||
{
|
{
|
||||||
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
0x04, 0x6F, 0x70, 0xAC, 0x55, 0x7F, 0x54, 0x61,
|
||||||
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
0xCE, 0x50, 0x52, 0xC8, 0xE4, 0xA7, 0x83, 0x8C,
|
||||||
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
0x11, 0xC7, 0xA2, 0x36, 0x79, 0x7E, 0x8A, 0x07,
|
||||||
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
0x30, 0xA1, 0x01, 0x83, 0x7C, 0x00, 0x40, 0x39, 0xC2
|
||||||
},
|
},
|
||||||
// MIKRON public key.
|
// MIKRON public key.
|
||||||
{
|
{
|
||||||
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
0x04, 0xf9, 0x71, 0xed, 0xa7, 0x42, 0xa4, 0xa8,
|
||||||
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
0x0d, 0x32, 0xdc, 0xf6, 0xa8, 0x14, 0xa7, 0x07,
|
||||||
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
0xcc, 0x3d, 0xc3, 0x96, 0xd3, 0x59, 0x02, 0xf7,
|
||||||
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
int res;
|
int res;
|
||||||
bool is_valid = false;
|
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;
|
int dl = 0;
|
||||||
uint8_t key[PUBLIC_ECDA_KEYLEN];
|
uint8_t key[PUBLIC_ECDA_KEYLEN];
|
||||||
param_gethex_to_eol(nxp_mfu_public_keys[i].value, 0, key, PUBLIC_ECDA_KEYLEN, &dl);
|
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);
|
res = ecdsa_signature_r_s_verify(MBEDTLS_ECP_DP_SECP128R1, key, uid, 7, signature, signature_len, false);
|
||||||
|
|
||||||
is_valid = (res == 0);
|
is_valid = (res == 0);
|
||||||
if (is_valid)
|
if (is_valid)
|
||||||
break;
|
break;
|
||||||
|
@ -2721,7 +2721,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||||
uint8_t key[16] = {0x00};
|
uint8_t key[16] = {0x00};
|
||||||
uint8_t *p_key = key;
|
uint8_t *p_key = key;
|
||||||
uint8_t pack[4] = {0, 0, 0, 0};
|
uint8_t pack[4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
CLIParserInit("hf mfu ndef",
|
CLIParserInit("hf mfu ndef",
|
||||||
"Prints NFC Data Exchange Format (NDEF)",
|
"Prints NFC Data Exchange Format (NDEF)",
|
||||||
"Usage:\n\thf mfu ndef -> shows NDEF data\n"
|
"Usage:\n\thf mfu ndef -> shows NDEF data\n"
|
||||||
|
@ -2737,8 +2737,8 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||||
CLIGetHexWithReturn(1, key, &keylen);
|
CLIGetHexWithReturn(1, key, &keylen);
|
||||||
swapEndian = arg_get_lit(2);
|
swapEndian = arg_get_lit(2);
|
||||||
CLIParserFree();
|
CLIParserFree();
|
||||||
|
|
||||||
switch(keylen) {
|
switch (keylen) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -2758,13 +2758,13 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is tag UL/NTAG?
|
// Is tag UL/NTAG?
|
||||||
|
|
||||||
// Swap endianness
|
// Swap endianness
|
||||||
if (swapEndian && hasAuthKey) p_key = SwapEndian64(key, keylen, (keylen == 16) ? 8 : 4);
|
if (swapEndian && hasAuthKey) p_key = SwapEndian64(key, keylen, (keylen == 16) ? 8 : 4);
|
||||||
|
|
||||||
// Select and Auth
|
// Select and Auth
|
||||||
if (ul_auth_select(&card, tagtype, hasAuthKey, p_key, pack, sizeof(pack)) == PM3_ESOFT) return PM3_ESOFT;
|
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)
|
// read pages 0,1,2,3 (should read 4pages)
|
||||||
status = ul_read(0, data, sizeof(data));
|
status = ul_read(0, data, sizeof(data));
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
|
@ -2783,20 +2783,20 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||||
// max datasize;
|
// max datasize;
|
||||||
maxsize = ndef_get_maxsize(data + 12);
|
maxsize = ndef_get_maxsize(data + 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
// iceman: maybe always take MIN of tag identified size vs NDEF reported size?
|
// iceman: maybe always take MIN of tag identified size vs NDEF reported size?
|
||||||
// fix: UL_EV1 48bytes != NDEF reported size
|
// fix: UL_EV1 48bytes != NDEF reported size
|
||||||
for (uint8_t i = 0; i < ARRAYLEN(UL_TYPES_ARRAY); i++) {
|
for (uint8_t i = 0; i < ARRAYLEN(UL_TYPES_ARRAY); i++) {
|
||||||
if (tagtype & 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");
|
PrintAndLogEx(INFO, "Tag reported size vs NDEF reported size mismatch. Using smallest value");
|
||||||
}
|
}
|
||||||
maxsize = MIN(maxsize, (UL_MEMORY_ARRAY[i] * 4));
|
maxsize = MIN(maxsize, (UL_MEMORY_ARRAY[i] * 4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate mem
|
// allocate mem
|
||||||
uint8_t *records = calloc(maxsize, sizeof(uint8_t));
|
uint8_t *records = calloc(maxsize, sizeof(uint8_t));
|
||||||
if (records == NULL) {
|
if (records == NULL) {
|
||||||
|
@ -2805,7 +2805,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// read NDEF records.
|
// 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);
|
status = ul_read(4 + j, records + i, 16);
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
DropField();
|
DropField();
|
||||||
|
|
|
@ -514,7 +514,7 @@ int readTopazUid(bool verbose) {
|
||||||
uint8_t rid_response[8];
|
uint8_t rid_response[8];
|
||||||
uint8_t *uid_echo = &rid_response[2];
|
uint8_t *uid_echo = &rid_response[2];
|
||||||
uint8_t rall_response[124];
|
uint8_t rall_response[124];
|
||||||
|
|
||||||
int status = topaz_select(atqa, sizeof(atqa), rid_response, sizeof(rid_response), verbose);
|
int status = topaz_select(atqa, sizeof(atqa), rid_response, sizeof(rid_response), verbose);
|
||||||
if (status == PM3_ESOFT) {
|
if (status == PM3_ESOFT) {
|
||||||
if (verbose) PrintAndLogEx(ERR, "Error: couldn't receive ATQA");
|
if (verbose) PrintAndLogEx(ERR, "Error: couldn't receive ATQA");
|
||||||
|
@ -543,7 +543,7 @@ int readTopazUid(bool verbose) {
|
||||||
memcpy(topaz_tag.uid, rall_response + 2, 7);
|
memcpy(topaz_tag.uid, rall_response + 2, 7);
|
||||||
memcpy(topaz_tag.data_blocks, rall_response + 2, 0x0f * 8);
|
memcpy(topaz_tag.data_blocks, rall_response + 2, 0x0f * 8);
|
||||||
|
|
||||||
// printing
|
// printing
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, "UID : %02x %02x %02x %02x %02x %02x %02x",
|
PrintAndLogEx(SUCCESS, "UID : %02x %02x %02x %02x %02x %02x %02x",
|
||||||
topaz_tag.uid[6],
|
topaz_tag.uid[6],
|
||||||
|
@ -557,7 +557,7 @@ int readTopazUid(bool verbose) {
|
||||||
PrintAndLogEx(SUCCESS, " UID[6] (Manufacturer Byte) = " _YELLOW_("%02x")", Manufacturer: " _YELLOW_("%s"),
|
PrintAndLogEx(SUCCESS, " UID[6] (Manufacturer Byte) = " _YELLOW_("%02x")", Manufacturer: " _YELLOW_("%s"),
|
||||||
topaz_tag.uid[6],
|
topaz_tag.uid[6],
|
||||||
getTagInfo(topaz_tag.uid[6])
|
getTagInfo(topaz_tag.uid[6])
|
||||||
);
|
);
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "ATQA : %02x %02x", atqa[1], atqa[0]);
|
PrintAndLogEx(SUCCESS, "ATQA : %02x %02x", atqa[1], atqa[0]);
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
||||||
PrintAndLogEx(SUCCESS, " UID: " _YELLOW_("%08x"), id);
|
PrintAndLogEx(SUCCESS, " UID: " _YELLOW_("%08x"), id);
|
||||||
|
|
||||||
if (htf != RHT2F_UID_ONLY) {
|
if (htf != RHT2F_UID_ONLY) {
|
||||||
|
|
||||||
// block3, 1 byte
|
// block3, 1 byte
|
||||||
printHitagConfiguration(data[4 * 3]);
|
printHitagConfiguration(data[4 * 3]);
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||||
if (ctmp == 'h') return 0; // usage_hitag_dump();
|
if (ctmp == 'h') return 0; // usage_hitag_dump();
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
|
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
|
||||||
uint8_t *data = resp.data.asBytes;
|
uint8_t *data = resp.data.asBytes;
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||||
|
|
||||||
|
|
||||||
// Annotate HITAG protocol
|
// Annotate HITAG protocol
|
||||||
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ static int usage_lf_keri_clone(void) {
|
||||||
PrintAndLogEx(NORMAL, " lf keri clone 112233");
|
PrintAndLogEx(NORMAL, " lf keri clone 112233");
|
||||||
PrintAndLogEx(NORMAL, " lf keri clone type ms fc 6 cn 12345");
|
PrintAndLogEx(NORMAL, " lf keri clone type ms fc 6 cn 12345");
|
||||||
PrintAndLogEx(NORMAL, " lf keri clone t m f 6 c 12345");
|
PrintAndLogEx(NORMAL, " lf keri clone t m f 6 c 12345");
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,16 +62,17 @@ static int usage_lf_keri_sim(void) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {Scramble = 0,Descramble = 1} KeriMSScramble_t;
|
typedef enum {Scramble = 0, Descramble = 1} KeriMSScramble_t;
|
||||||
|
|
||||||
static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID)
|
static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) {
|
||||||
{
|
|
||||||
// 255 = Not used/Unknown other values are the bit offset in the ID/FC values
|
// 255 = Not used/Unknown other values are the bit offset in the ID/FC values
|
||||||
uint8_t CardToID [] = { 255,255,255,255, 13, 12, 20, 5, 16, 6, 21, 17, 8,255, 0, 7,
|
uint8_t CardToID [] = { 255, 255, 255, 255, 13, 12, 20, 5, 16, 6, 21, 17, 8, 255, 0, 7,
|
||||||
10, 15,255, 11, 4, 1,255, 18,255, 19, 2, 14, 3, 9,255,255 };
|
10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255
|
||||||
|
};
|
||||||
|
|
||||||
uint8_t CardToFC [] = { 255,255,255,255,255,255,255,255,255,255,255,255,255, 0,255,255,
|
uint8_t CardToFC [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255,
|
||||||
255,255, 2,255,255,255, 3,255, 4,255,255,255,255,255, 1,255 };
|
255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255
|
||||||
|
};
|
||||||
|
|
||||||
uint8_t CardIdx; // 0 - 31
|
uint8_t CardIdx; // 0 - 31
|
||||||
bool BitState;
|
bool BitState;
|
||||||
|
@ -93,13 +94,11 @@ static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Action == Scramble)
|
if (Action == Scramble) {
|
||||||
{
|
|
||||||
*CardID = 0; // set to 0
|
*CardID = 0; // set to 0
|
||||||
|
|
||||||
for (CardIdx = 0; CardIdx < 32; CardIdx++)
|
for (CardIdx = 0; CardIdx < 32; CardIdx++) {
|
||||||
{
|
// Card ID
|
||||||
// Card ID
|
|
||||||
if (CardToID[CardIdx] < 32) {
|
if (CardToID[CardIdx] < 32) {
|
||||||
if ((*ID & (1 << CardToID[CardIdx])) > 0)
|
if ((*ID & (1 << CardToID[CardIdx])) > 0)
|
||||||
*CardID |= (1 << CardIdx);
|
*CardID |= (1 << CardIdx);
|
||||||
|
@ -130,7 +129,7 @@ static int CmdKeriMSScramble (KeriMSScramble_t Action, uint32_t *FC, uint32_t *I
|
||||||
// Bit 31 was fixed but not in check/parity bits
|
// Bit 31 was fixed but not in check/parity bits
|
||||||
*CardID |= 1UL << 31;
|
*CardID |= 1UL << 31;
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Scrambled MS : FC %d - CN %d to RAW : E0000000%08X",*FC,*ID,*CardID);
|
PrintAndLogEx(SUCCESS, "Scrambled MS : FC %d - CN %d to RAW : E0000000%08X", *FC, *ID, *CardID);
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -187,16 +186,16 @@ static int CmdKeriDemod(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "KERI Tag Found -- Internal ID: %u", ID);
|
PrintAndLogEx(SUCCESS, "KERI Tag Found -- Internal ID: %u", ID);
|
||||||
PrintAndLogEx(SUCCESS, "Raw: %08X%08X", raw1, raw2);
|
PrintAndLogEx(SUCCESS, "Raw: %08X%08X", raw1, raw2);
|
||||||
/*
|
/*
|
||||||
Descramble Data.
|
Descramble Data.
|
||||||
*/
|
*/
|
||||||
uint32_t fc = 0;
|
uint32_t fc = 0;
|
||||||
uint32_t cardid = 0;
|
uint32_t cardid = 0;
|
||||||
|
|
||||||
// Just need to the low 32 bits without the 111 trailer
|
// Just need to the low 32 bits without the 111 trailer
|
||||||
CmdKeriMSScramble (Descramble,&fc,&cardid,&raw2);
|
CmdKeriMSScramble(Descramble, &fc, &cardid, &raw2);
|
||||||
|
|
||||||
PrintAndLogEx (SUCCESS,"Descrambled MS : FC %d - CN %d\n",fc,cardid);
|
PrintAndLogEx(SUCCESS, "Descrambled MS : FC %d - CN %d\n", fc, cardid);
|
||||||
|
|
||||||
if (invert) {
|
if (invert) {
|
||||||
PrintAndLogEx(INFO, "Had to Invert - probably KERI");
|
PrintAndLogEx(INFO, "Had to Invert - probably KERI");
|
||||||
|
@ -245,26 +244,26 @@ static int CmdKeriClone(const char *Cmd) {
|
||||||
case 'h': // help
|
case 'h': // help
|
||||||
return usage_lf_keri_clone();
|
return usage_lf_keri_clone();
|
||||||
case 't': // format type
|
case 't': // format type
|
||||||
keritype = tolower(param_getchar(Cmd,cmdidx+1));
|
keritype = tolower(param_getchar(Cmd, cmdidx + 1));
|
||||||
cmdidx += 2;
|
cmdidx += 2;
|
||||||
break;
|
break;
|
||||||
case 'f': // fc
|
case 'f': // fc
|
||||||
fc = param_get32ex(Cmd,cmdidx+1,0,10);
|
fc = param_get32ex(Cmd, cmdidx + 1, 0, 10);
|
||||||
cmdidx += 2;
|
cmdidx += 2;
|
||||||
break;
|
break;
|
||||||
case 'c': // cardid
|
case 'c': // cardid
|
||||||
cid = param_get32ex(Cmd,cmdidx+1,0,10);
|
cid = param_get32ex(Cmd, cmdidx + 1, 0, 10);
|
||||||
cmdidx += 2;
|
cmdidx += 2;
|
||||||
break;
|
break;
|
||||||
case 'q': // q5
|
case 'q': // q5
|
||||||
blocks[0] =
|
blocks[0] =
|
||||||
T5555_MODULATION_PSK1 |
|
T5555_MODULATION_PSK1 |
|
||||||
T5555_SET_BITRATE(128) |
|
T5555_SET_BITRATE(128) |
|
||||||
T5555_PSK_RF_2 |
|
T5555_PSK_RF_2 |
|
||||||
2 << T5555_MAXBLOCK_SHIFT;
|
2 << T5555_MAXBLOCK_SHIFT;
|
||||||
cmdidx++;
|
cmdidx++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Skip unknown
|
// Skip unknown
|
||||||
cmdidx++;
|
cmdidx++;
|
||||||
}
|
}
|
||||||
|
@ -272,28 +271,28 @@ static int CmdKeriClone(const char *Cmd) {
|
||||||
|
|
||||||
// this is managed in above code
|
// this is managed in above code
|
||||||
// internalid = param_get32ex(Cmd, 0, 0, 10);
|
// internalid = param_get32ex(Cmd, 0, 0, 10);
|
||||||
/*
|
/*
|
||||||
// Q5 is caught in the while loop
|
// Q5 is caught in the while loop
|
||||||
//Q5
|
//Q5
|
||||||
if (tolower(param_getchar(Cmd, 1)) == 'q') {
|
if (tolower(param_getchar(Cmd, 1)) == 'q') {
|
||||||
blocks[0] =
|
blocks[0] =
|
||||||
T5555_MODULATION_PSK1 |
|
T5555_MODULATION_PSK1 |
|
||||||
T5555_SET_BITRATE(128) |
|
T5555_SET_BITRATE(128) |
|
||||||
T5555_PSK_RF_2 |
|
T5555_PSK_RF_2 |
|
||||||
2 << T5555_MAXBLOCK_SHIFT;
|
2 << T5555_MAXBLOCK_SHIFT;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Setup card data/build internal id
|
// Setup card data/build internal id
|
||||||
switch (keritype) {
|
switch (keritype) {
|
||||||
case 'i' : // Internal ID
|
case 'i' : // Internal ID
|
||||||
// MSB is ONE
|
// MSB is ONE
|
||||||
internalid = cid | 0x80000000;
|
internalid = cid | 0x80000000;
|
||||||
break;
|
break;
|
||||||
case 'm' : // MS
|
case 'm' : // MS
|
||||||
CmdKeriMSScramble (Scramble,&fc,&cid,&internalid);
|
CmdKeriMSScramble(Scramble, &fc, &cid, &internalid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare and write to card
|
// Prepare and write to card
|
||||||
// 3 LSB is ONE
|
// 3 LSB is ONE
|
||||||
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
uint64_t data = ((uint64_t)internalid << 3) + 7;
|
||||||
|
|
|
@ -197,13 +197,13 @@ static int CmdHints(const char *Cmd) {
|
||||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||||
if (ctmp == 'h') return usage_hints();
|
if (ctmp == 'h') return usage_hints();
|
||||||
|
|
||||||
if (strlen(Cmd) > 1){
|
if (strlen(Cmd) > 1) {
|
||||||
str_lower((char *)Cmd);
|
str_lower((char *)Cmd);
|
||||||
if (str_startswith(Cmd, "of")) {
|
if (str_startswith(Cmd, "of")) {
|
||||||
session.show_hints = false;
|
session.show_hints = false;
|
||||||
} else {
|
} else {
|
||||||
session.show_hints = true;
|
session.show_hints = true;
|
||||||
}
|
}
|
||||||
} else if (strlen(Cmd) == 1) {
|
} else if (strlen(Cmd) == 1) {
|
||||||
if (param_getchar(Cmd, 0) != 0x00) {
|
if (param_getchar(Cmd, 0) != 0x00) {
|
||||||
ms = param_get32ex(Cmd, 0, 0, 10);
|
ms = param_get32ex(Cmd, 0, 0, 10);
|
||||||
|
@ -214,7 +214,7 @@ static int CmdHints(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Hints are %s", (session.show_hints) ? "ON" : "OFF");
|
PrintAndLogEx(INFO, "Hints are %s", (session.show_hints) ? "ON" : "OFF");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,13 +394,13 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
break;
|
break;
|
||||||
case PROTO_HITAG1:
|
case PROTO_HITAG1:
|
||||||
annotateHitag1(explanation, sizeof(explanation), frame, data_len);
|
annotateHitag1(explanation, sizeof(explanation), frame, data_len);
|
||||||
break;
|
break;
|
||||||
case PROTO_HITAG2:
|
case PROTO_HITAG2:
|
||||||
annotateHitag2(explanation, sizeof(explanation), frame, data_len);
|
annotateHitag2(explanation, sizeof(explanation), frame, data_len);
|
||||||
break;
|
break;
|
||||||
case PROTO_HITAGS:
|
case PROTO_HITAGS:
|
||||||
annotateHitagS(explanation, sizeof(explanation), frame, data_len);
|
annotateHitagS(explanation, sizeof(explanation), frame, data_len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,7 @@ int CmdTraceList(const char *Cmd) {
|
||||||
else if (strcmp(type, "mf") == 0) protocol = PROTO_MIFARE;
|
else if (strcmp(type, "mf") == 0) protocol = PROTO_MIFARE;
|
||||||
else if (strcmp(type, "hitag1") == 0) protocol = PROTO_HITAG1;
|
else if (strcmp(type, "hitag1") == 0) protocol = PROTO_HITAG1;
|
||||||
else if (strcmp(type, "hitag2") == 0) protocol = PROTO_HITAG2;
|
else if (strcmp(type, "hitag2") == 0) protocol = PROTO_HITAG2;
|
||||||
else if (strcmp(type, "hitags") == 0) protocol = PROTO_HITAGS;
|
else if (strcmp(type, "hitags") == 0) protocol = PROTO_HITAGS;
|
||||||
else if (strcmp(type, "thinfilm") == 0) protocol = THINFILM;
|
else if (strcmp(type, "thinfilm") == 0) protocol = THINFILM;
|
||||||
else if (strcmp(type, "lto") == 0) protocol = LTO;
|
else if (strcmp(type, "lto") == 0) protocol = LTO;
|
||||||
else if (strcmp(type, "raw") == 0) protocol = -1; //No crc, no annotations
|
else if (strcmp(type, "raw") == 0) protocol = -1; //No crc, no annotations
|
||||||
|
@ -694,7 +694,7 @@ int CmdTraceList(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "Hitag1 / Hitag2 / HitagS - Timings in ETU (8us)");
|
PrintAndLogEx(INFO, "Hitag1 / Hitag2 / HitagS - Timings in ETU (8us)");
|
||||||
if (protocol == FELICA)
|
if (protocol == FELICA)
|
||||||
PrintAndLogEx(INFO, "ISO18092 / FeliCa - Timings are not as accurate");
|
PrintAndLogEx(INFO, "ISO18092 / FeliCa - Timings are not as accurate");
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");
|
PrintAndLogEx(NORMAL, " Start | End | Src | Data (! denotes parity error) | CRC | Annotation");
|
||||||
PrintAndLogEx(NORMAL, "------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------");
|
PrintAndLogEx(NORMAL, "------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------");
|
||||||
|
|
|
@ -10,7 +10,7 @@ EMOJI_JSON_URL = 'https://raw.githubusercontent.com/github/gemoji/master/db/emoj
|
||||||
|
|
||||||
def print_emoji(emoji_json):
|
def print_emoji(emoji_json):
|
||||||
for alias in emoji_json['aliases']:
|
for alias in emoji_json['aliases']:
|
||||||
print(' {{":{0}:", "{1}"}}, // {2}'.format(alias,
|
print(' {{":{0}:", "{1}"}}, // {2}'.format(alias,
|
||||||
|
|
||||||
''.join('\\x{:02x}'.format(b) for b in emoji_json['emoji'].encode('utf8')),
|
''.join('\\x{:02x}'.format(b) for b in emoji_json['emoji'].encode('utf8')),
|
||||||
|
|
||||||
|
|
|
@ -503,17 +503,17 @@ void APDUPrint(APDUStruct apdu) {
|
||||||
|
|
||||||
void APDUPrintEx(APDUStruct apdu, size_t maxdatalen) {
|
void APDUPrintEx(APDUStruct apdu, size_t maxdatalen) {
|
||||||
PrintAndLogEx(INFO, "APDU: %scase=0x%02x cla=0x%02x ins=0x%02x p1=0x%02x p2=0x%02x Lc=0x%02x(%d) Le=0x%02x(%d)",
|
PrintAndLogEx(INFO, "APDU: %scase=0x%02x cla=0x%02x ins=0x%02x p1=0x%02x p2=0x%02x Lc=0x%02x(%d) Le=0x%02x(%d)",
|
||||||
apdu.extended_apdu ? "[e]" : "",
|
apdu.extended_apdu ? "[e]" : "",
|
||||||
apdu.case_type,
|
apdu.case_type,
|
||||||
apdu.cla,
|
apdu.cla,
|
||||||
apdu.ins,
|
apdu.ins,
|
||||||
apdu.p1,
|
apdu.p1,
|
||||||
apdu.p2,
|
apdu.p2,
|
||||||
apdu.lc,
|
apdu.lc,
|
||||||
apdu.lc,
|
apdu.lc,
|
||||||
apdu.le,
|
apdu.le,
|
||||||
apdu.le
|
apdu.le
|
||||||
);
|
);
|
||||||
if (maxdatalen > 0)
|
if (maxdatalen > 0)
|
||||||
PrintAndLogEx(INFO, "data: %s%s", sprint_hex(apdu.data, MIN(apdu.lc, maxdatalen)), apdu.lc > maxdatalen ? "..." : "");
|
PrintAndLogEx(INFO, "data: %s%s", sprint_hex(apdu.data, MIN(apdu.lc, maxdatalen)), apdu.lc > maxdatalen ? "..." : "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
|
||||||
JsonSaveStr(root, "FileType", "14b");
|
JsonSaveStr(root, "FileType", "14b");
|
||||||
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case jsf15: {
|
case jsf15: {
|
||||||
JsonSaveStr(root, "FileType", "15693");
|
JsonSaveStr(root, "FileType", "15693");
|
||||||
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
||||||
|
@ -426,8 +426,8 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case jsfSettings:
|
case jsfSettings:
|
||||||
preferences_save_callback (root);
|
preferences_save_callback(root);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -867,8 +867,8 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
|
||||||
}
|
}
|
||||||
*datalen = sptr;
|
*datalen = sptr;
|
||||||
}
|
}
|
||||||
if (!strcmp(ctype,"settings")) {
|
if (!strcmp(ctype, "settings")) {
|
||||||
preferences_load_callback (root);
|
preferences_load_callback(root);
|
||||||
}
|
}
|
||||||
PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
|
PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -12,7 +12,7 @@ This script bruteforces 4 or 7 byte UID Mifare classic card numbers.
|
||||||
]]
|
]]
|
||||||
example =[[
|
example =[[
|
||||||
Bruteforce a 4 byte UID Mifare classic card number, starting at 11223344, ending at 11223346.
|
Bruteforce a 4 byte UID Mifare classic card number, starting at 11223344, ending at 11223346.
|
||||||
|
|
||||||
script run hf_bruteforce -s 0x11223344 -e 0x11223346 -t 1000 -x mfc
|
script run hf_bruteforce -s 0x11223344 -e 0x11223346 -t 1000 -x mfc
|
||||||
|
|
||||||
Bruteforce a 7 byte UID Mifare Ultralight card number, starting at 11223344556677, ending at 11223344556679.
|
Bruteforce a 7 byte UID Mifare Ultralight card number, starting at 11223344556677, ending at 11223344556679.
|
||||||
|
@ -26,9 +26,9 @@ arguments = [[
|
||||||
-h this help
|
-h this help
|
||||||
-s 0-0xFFFFFFFF start id
|
-s 0-0xFFFFFFFF start id
|
||||||
-e 0-0xFFFFFFFF end id
|
-e 0-0xFFFFFFFF end id
|
||||||
-t 0-99999, pause timeout (ms) between cards
|
-t 0-99999, pause timeout (ms) between cards
|
||||||
(use the word 'pause' to wait for user input)
|
(use the word 'pause' to wait for user input)
|
||||||
-x mfc, mfu mifare type:
|
-x mfc, mfu mifare type:
|
||||||
mfc for Mifare Classic (default)
|
mfc for Mifare Classic (default)
|
||||||
mfu for Mifare Ultralight EV1
|
mfu for Mifare Ultralight EV1
|
||||||
]]
|
]]
|
||||||
|
|
|
@ -59,7 +59,7 @@ local function main(args)
|
||||||
for o, a in getopt.getopt(args, 'h') do
|
for o, a in getopt.getopt(args, 'h') do
|
||||||
if o == 'h' then return help() end
|
if o == 'h' then return help() end
|
||||||
end
|
end
|
||||||
|
|
||||||
print("WORK IN PROGRESS - not expected to be functional yet")
|
print("WORK IN PROGRESS - not expected to be functional yet")
|
||||||
info, err = reader.waitForTag()
|
info, err = reader.waitForTag()
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ desc = [[
|
||||||
|
|
||||||
Works with both 4 and 7 bytes NXP MIFARE Classic 1K cards.
|
Works with both 4 and 7 bytes NXP MIFARE Classic 1K cards.
|
||||||
The script also has the possibility to change UID and permanent lock uid on magic Gen3 cards.
|
The script also has the possibility to change UID and permanent lock uid on magic Gen3 cards.
|
||||||
|
|
||||||
It supports the following functionality.
|
It supports the following functionality.
|
||||||
|
|
||||||
1. Write it to the same of current card UID.
|
1. Write it to the same of current card UID.
|
||||||
|
@ -33,7 +33,7 @@ desc = [[
|
||||||
3. Change uid to match dump on magic Gen3 card.
|
3. Change uid to match dump on magic Gen3 card.
|
||||||
4. Permanent lock UID on magic Gen3 card.
|
4. Permanent lock UID on magic Gen3 card.
|
||||||
5. Erase all data at the card and set the FF FF FF FF FF FF keys, and Access Conditions to 78778800.
|
5. Erase all data at the card and set the FF FF FF FF FF FF keys, and Access Conditions to 78778800.
|
||||||
|
|
||||||
Script works in a wizard styled way.
|
Script works in a wizard styled way.
|
||||||
]]
|
]]
|
||||||
example = [[
|
example = [[
|
||||||
|
@ -88,7 +88,7 @@ local function GetUID()
|
||||||
return read14a.read(true, true).uid
|
return read14a.read(true, true).uid
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
--
|
--
|
||||||
local function dropfield()
|
local function dropfield()
|
||||||
read14a.disconnect()
|
read14a.disconnect()
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
|
@ -121,25 +121,25 @@ local function main(args)
|
||||||
local length = 25
|
local length = 25
|
||||||
local e = 16
|
local e = 16
|
||||||
-- Detect 7 byte card
|
-- Detect 7 byte card
|
||||||
if string.len(GetUID()) == 14 then
|
if string.len(GetUID()) == 14 then
|
||||||
length = 31
|
length = 31
|
||||||
e = 22
|
e = 22
|
||||||
end
|
end
|
||||||
dropfield()
|
dropfield()
|
||||||
|
|
||||||
---List all EML files in /client
|
---List all EML files in /client
|
||||||
local dumpEML = "find '.' -iname '*dump.eml' -type f"
|
local dumpEML = "find '.' -iname '*dump.eml' -type f"
|
||||||
local p = assert(io.popen(dumpEML))
|
local p = assert(io.popen(dumpEML))
|
||||||
for _ in p:lines() do
|
for _ in p:lines() do
|
||||||
|
|
||||||
-- The length of eml file
|
-- The length of eml file
|
||||||
if string.len(_) == length then
|
if string.len(_) == length then
|
||||||
num_dumps = num_dumps + 1
|
num_dumps = num_dumps + 1
|
||||||
-- cut UID from eml file
|
-- cut UID from eml file
|
||||||
files[num_dumps] = string.sub(_, 9, e)
|
files[num_dumps] = string.sub(_, 9, e)
|
||||||
print(' '..num_dumps..' | '..files[num_dumps])
|
print(' '..num_dumps..' | '..files[num_dumps])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
p.close()
|
p.close()
|
||||||
|
|
||||||
if num_dumps == 0 then return oops("Didn't find any dump files") end
|
if num_dumps == 0 then return oops("Didn't find any dump files") end
|
||||||
|
@ -153,45 +153,45 @@ local function main(args)
|
||||||
|
|
||||||
local no = tonumber(io.read())
|
local no = tonumber(io.read())
|
||||||
print(tab)
|
print(tab)
|
||||||
print(' You have been selected card dump ' .. no .. ', with UID : '..files[no])
|
print(' You have been selected card dump ' .. no .. ', with UID : '..files[no])
|
||||||
|
|
||||||
--- Load eml file
|
--- Load eml file
|
||||||
local dumpfile = assert(io.open('./hf-mf-' .. files[no] .. '-dump.eml', 'r'))
|
local dumpfile = assert(io.open('./hf-mf-' .. files[no] .. '-dump.eml', 'r'))
|
||||||
for _ in dumpfile:lines() do table.insert(eml, _); end
|
for _ in dumpfile:lines() do table.insert(eml, _); end
|
||||||
dumpfile.close()
|
dumpfile.close()
|
||||||
|
|
||||||
--- Extract B key from EML file
|
--- Extract B key from EML file
|
||||||
local b = 0
|
local b = 0
|
||||||
for i = 1, #eml do
|
for i = 1, #eml do
|
||||||
if (i % 4 == 0) then
|
if (i % 4 == 0) then
|
||||||
repeat
|
repeat
|
||||||
b = b + 1
|
b = b + 1
|
||||||
-- Cut key from block
|
-- Cut key from block
|
||||||
b_keys[b] = string.sub(eml[i], (#eml[i] - 11), #eml[i])
|
b_keys[b] = string.sub(eml[i], (#eml[i] - 11), #eml[i])
|
||||||
until b % 4 == 0
|
until b % 4 == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print(tab)
|
print(tab)
|
||||||
dbg(b_keys)
|
dbg(b_keys)
|
||||||
dbg(eml)
|
dbg(eml)
|
||||||
|
|
||||||
--- Change UID on certain version of magic Gen3 card.
|
--- Change UID on certain version of magic Gen3 card.
|
||||||
if (utils.confirm(' Change UID ?') == true) then
|
if (utils.confirm(' Change UID ?') == true) then
|
||||||
wait()
|
wait()
|
||||||
--core.console('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
--core.console('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
||||||
print('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
print('hf 14a raw -s -c -t 2000 90f0cccc10'..tostring(eml[1]))
|
||||||
print(tab)
|
print(tab)
|
||||||
print(' The new card UID : ' .. GetUID())
|
print(' The new card UID : ' .. GetUID())
|
||||||
end
|
end
|
||||||
print(tab)
|
print(tab)
|
||||||
|
|
||||||
--- Lock UID
|
--- Lock UID
|
||||||
if (utils.confirm(' Permanent lock UID ? (card can never change uid again) ') == true) then
|
if (utils.confirm(' Permanent lock UID ? (card can never change uid again) ') == true) then
|
||||||
wait()
|
wait()
|
||||||
core.console('hf 14a raw -s -c -t 2000 90fd111100')
|
core.console('hf 14a raw -s -c -t 2000 90fd111100')
|
||||||
end
|
end
|
||||||
print(tab)
|
print(tab)
|
||||||
|
|
||||||
--- Writing blocks
|
--- Writing blocks
|
||||||
local default_key = 'FFFFFFFFFFFF'
|
local default_key = 'FFFFFFFFFFFF'
|
||||||
local default_key_blk = 'FFFFFFFFFFFF78778800FFFFFFFFFFFF'
|
local default_key_blk = 'FFFFFFFFFFFF78778800FFFFFFFFFFFF'
|
||||||
|
|
|
@ -16,7 +16,7 @@ local ansicolors = require('ansicolors')
|
||||||
6. calculate new crc on each segment (needs to know the new MCD & MSN0..2)
|
6. calculate new crc on each segment (needs to know the new MCD & MSN0..2)
|
||||||
|
|
||||||
simplest usage:
|
simplest usage:
|
||||||
Dump a legic tag with 'hf legic dump'
|
Dump a legic tag with 'hf legic dump'
|
||||||
place your 'empty' tag on the reader and run
|
place your 'empty' tag on the reader and run
|
||||||
'script run legic_clone -i orig.bin -w'
|
'script run legic_clone -i orig.bin -w'
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ local function displaySegments(bytes)
|
||||||
pld = ''
|
pld = ''
|
||||||
Seg = getSegmentData(bytes, start, index)
|
Seg = getSegmentData(bytes, start, index)
|
||||||
if Seg == nil then return OOps("segment is nil") end
|
if Seg == nil then return OOps("segment is nil") end
|
||||||
|
|
||||||
KGH = CheckKgh(bytes, start, (start + tonumber(Seg[4], 10)))
|
KGH = CheckKgh(bytes, start, (start + tonumber(Seg[4], 10)))
|
||||||
|
|
||||||
printSegment(Seg)
|
printSegment(Seg)
|
||||||
|
|
|
@ -449,12 +449,12 @@ int MFPGetVersion(bool activateField, bool leaveSignalON, uint8_t *dataout, int
|
||||||
*dataoutlen = 0;
|
*dataoutlen = 0;
|
||||||
// MFDES_ADDITIONAL_FRAME
|
// MFDES_ADDITIONAL_FRAME
|
||||||
if (tmp[0] == 0xAF) {
|
if (tmp[0] == 0xAF) {
|
||||||
c[0] = 0xAF;
|
c[0] = 0xAF;
|
||||||
res = intExchangeRAW14aPlus(c, sizeof(c), false, true, tmp, maxdataoutlen, dataoutlen);
|
res = intExchangeRAW14aPlus(c, sizeof(c), false, true, tmp, maxdataoutlen, dataoutlen);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
|
|
||||||
memcpy(dataout + 7, tmp + 1, (*dataoutlen - 3));
|
memcpy(dataout + 7, tmp + 1, (*dataoutlen - 3));
|
||||||
|
|
||||||
// MFDES_ADDITIONAL_FRAME
|
// MFDES_ADDITIONAL_FRAME
|
||||||
res = intExchangeRAW14aPlus(c, sizeof(c), false, false, tmp, maxdataoutlen, dataoutlen);
|
res = intExchangeRAW14aPlus(c, sizeof(c), false, false, tmp, maxdataoutlen, dataoutlen);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
|
|
|
@ -312,13 +312,13 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) {
|
||||||
uint8_t utf8 = (ndef->Payload[0] >> 7);
|
uint8_t utf8 = (ndef->Payload[0] >> 7);
|
||||||
uint8_t lc_len = ndef->Payload[0] & 0x3F;
|
uint8_t lc_len = ndef->Payload[0] & 0x3F;
|
||||||
PrintAndLogEx(INFO,
|
PrintAndLogEx(INFO,
|
||||||
"\tUTF %d\t: " _GREEN_("%.*s") ", " _GREEN_("%.*s"),
|
"\tUTF %d\t: " _GREEN_("%.*s") ", " _GREEN_("%.*s"),
|
||||||
(utf8 == 0) ? 8 : 16,
|
(utf8 == 0) ? 8 : 16,
|
||||||
lc_len,
|
lc_len,
|
||||||
ndef->Payload + 1,
|
ndef->Payload + 1,
|
||||||
(int)ndef->PayloadLen - 1 - lc_len,
|
(int)ndef->PayloadLen - 1 - lc_len,
|
||||||
ndef->Payload + 1 + lc_len
|
ndef->Payload + 1 + lc_len
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) {
|
if (!strncmp((char *)ndef->Type, "U", ndef->TypeLen)) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// Update the preferences_load_callback to load your setting into the stucture
|
// Update the preferences_load_callback to load your setting into the stucture
|
||||||
// Update the preferences_save_callback to enusre your setting gets saved when needed.
|
// Update the preferences_save_callback to enusre your setting gets saved when needed.
|
||||||
// use the preference as needed : session.<preference name>
|
// use the preference as needed : session.<preference name>
|
||||||
// Can use (session.preferences_loaded) to check if json settings file was used
|
// Can use (session.preferences_loaded) to check if json settings file was used
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
@ -40,18 +40,18 @@ static int setCmdHelp(const char *Cmd);
|
||||||
#define GetCurrentDir getcwd
|
#define GetCurrentDir getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char* prefGetFilename (void) {
|
static char *prefGetFilename(void) {
|
||||||
char *Path;
|
char *Path;
|
||||||
|
|
||||||
if (searchHomeFilePath(&Path,preferencesFilename,false) == PM3_SUCCESS)
|
if (searchHomeFilePath(&Path, preferencesFilename, false) == PM3_SUCCESS)
|
||||||
return Path;
|
return Path;
|
||||||
else
|
else
|
||||||
return preferencesFilename;
|
return preferencesFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int preferences_load (void) {
|
int preferences_load(void) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO,"Looking for preferences...");
|
PrintAndLogEx(INFO, "Looking for preferences...");
|
||||||
|
|
||||||
// Set all defaults
|
// Set all defaults
|
||||||
session.client_debug_level = OFF;
|
session.client_debug_level = OFF;
|
||||||
|
@ -61,48 +61,48 @@ int preferences_load (void) {
|
||||||
session.window_plot_hsize = 400;
|
session.window_plot_hsize = 400;
|
||||||
session.window_plot_wsize = 800;
|
session.window_plot_wsize = 800;
|
||||||
session.window_overlay_xpos = session.window_plot_xpos;
|
session.window_overlay_xpos = session.window_plot_xpos;
|
||||||
session.window_overlay_ypos = 60+session.window_plot_ypos + session.window_plot_hsize;
|
session.window_overlay_ypos = 60 + session.window_plot_ypos + session.window_plot_hsize;
|
||||||
session.window_overlay_hsize = 200;
|
session.window_overlay_hsize = 200;
|
||||||
session.window_overlay_wsize = session.window_plot_wsize;
|
session.window_overlay_wsize = session.window_plot_wsize;
|
||||||
session.emoji_mode = ALIAS;
|
session.emoji_mode = ALIAS;
|
||||||
session.show_hints = false;
|
session.show_hints = false;
|
||||||
session.supports_colors = false;
|
session.supports_colors = false;
|
||||||
|
|
||||||
|
|
||||||
// loadFileJson wants these, so pass in place holder values, though not used
|
// loadFileJson wants these, so pass in place holder values, though not used
|
||||||
// in settings load;
|
// in settings load;
|
||||||
uint8_t dummyData = 0x00;
|
uint8_t dummyData = 0x00;
|
||||||
size_t dummyDL = 0x00;
|
size_t dummyDL = 0x00;
|
||||||
|
|
||||||
if (loadFileJSON(prefGetFilename(), &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) {
|
if (loadFileJSON(prefGetFilename(), &dummyData, sizeof(dummyData), &dummyDL) == PM3_SUCCESS) {
|
||||||
session.preferences_loaded = true;
|
session.preferences_loaded = true;
|
||||||
}
|
}
|
||||||
// Note, if session.settings_loaded == false then the settings_save
|
// Note, if session.settings_loaded == false then the settings_save
|
||||||
// will be called in main () to save settings as set in defaults and main() checks.
|
// will be called in main () to save settings as set in defaults and main() checks.
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save all settings from memory (struct) to file
|
// Save all settings from memory (struct) to file
|
||||||
int preferences_save (void) {
|
int preferences_save(void) {
|
||||||
// Note sure if backup has value ?
|
// Note sure if backup has value ?
|
||||||
|
|
||||||
char backupFilename[FILENAME_MAX+sizeof(preferencesFilename)+10] = {0};
|
char backupFilename[FILENAME_MAX + sizeof(preferencesFilename) + 10] = {0};
|
||||||
|
|
||||||
PrintAndLogEx(INFO,"Saving preferences ...");
|
PrintAndLogEx(INFO, "Saving preferences ...");
|
||||||
snprintf (backupFilename,sizeof(backupFilename)-1,"%s.bak",prefGetFilename());
|
snprintf(backupFilename, sizeof(backupFilename) - 1, "%s.bak", prefGetFilename());
|
||||||
|
|
||||||
if (fileExists (backupFilename)) {
|
if (fileExists(backupFilename)) {
|
||||||
if (remove (backupFilename) != 0) {
|
if (remove(backupFilename) != 0) {
|
||||||
PrintAndLogEx (FAILED, "Error - could not delete old settings backup file \"%s\"",backupFilename);
|
PrintAndLogEx(FAILED, "Error - could not delete old settings backup file \"%s\"", backupFilename);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileExists (prefGetFilename())) {
|
if (fileExists(prefGetFilename())) {
|
||||||
if (rename (prefGetFilename(),backupFilename) != 0) {
|
if (rename(prefGetFilename(), backupFilename) != 0) {
|
||||||
PrintAndLogEx (FAILED, "Error - could not backup settings file \"%s\" to \"%s\"",prefGetFilename(),backupFilename);
|
PrintAndLogEx(FAILED, "Error - could not backup settings file \"%s\" to \"%s\"", prefGetFilename(), backupFilename);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,52 +110,66 @@ int preferences_save (void) {
|
||||||
size_t dummyDL = 0x00;
|
size_t dummyDL = 0x00;
|
||||||
|
|
||||||
if (saveFileJSON(prefGetFilename(), jsfSettings, &dummyData, dummyDL) != PM3_SUCCESS)
|
if (saveFileJSON(prefGetFilename(), jsfSettings, &dummyData, dummyDL) != PM3_SUCCESS)
|
||||||
PrintAndLogEx (ERR, "Error saving preferences to \"%s\"",prefGetFilename());
|
PrintAndLogEx(ERR, "Error saving preferences to \"%s\"", prefGetFilename());
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void preferences_save_callback (json_t *root) {
|
void preferences_save_callback(json_t *root) {
|
||||||
|
|
||||||
JsonSaveStr (root,"FileType","settings");
|
JsonSaveStr(root, "FileType", "settings");
|
||||||
|
|
||||||
// Log level, convert to text
|
// Log level, convert to text
|
||||||
switch (session.client_debug_level) {
|
switch (session.client_debug_level) {
|
||||||
case OFF: JsonSaveStr (root,"client.debug.level","off"); break;
|
case OFF:
|
||||||
case SIMPLE: JsonSaveStr (root,"client.debug.level","simple"); break;
|
JsonSaveStr(root, "client.debug.level", "off");
|
||||||
case FULL: JsonSaveStr (root,"client.debug.level","full"); break;
|
break;
|
||||||
|
case SIMPLE:
|
||||||
|
JsonSaveStr(root, "client.debug.level", "simple");
|
||||||
|
break;
|
||||||
|
case FULL:
|
||||||
|
JsonSaveStr(root, "client.debug.level", "full");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
JsonSaveStr (root,"logging.level","NORMAL");
|
JsonSaveStr(root, "logging.level", "NORMAL");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plot window
|
// Plot window
|
||||||
JsonSaveInt (root,"window.plot.xpos",session.window_plot_xpos);
|
JsonSaveInt(root, "window.plot.xpos", session.window_plot_xpos);
|
||||||
JsonSaveInt (root,"window.plot.ypos",session.window_plot_ypos);
|
JsonSaveInt(root, "window.plot.ypos", session.window_plot_ypos);
|
||||||
JsonSaveInt (root,"window.plot.hsize",session.window_plot_hsize);
|
JsonSaveInt(root, "window.plot.hsize", session.window_plot_hsize);
|
||||||
JsonSaveInt (root,"window.plot.wsize",session.window_plot_wsize);
|
JsonSaveInt(root, "window.plot.wsize", session.window_plot_wsize);
|
||||||
|
|
||||||
// Overlay/Slider window
|
// Overlay/Slider window
|
||||||
JsonSaveInt (root,"window.overlay.xpos",session.window_overlay_xpos);
|
JsonSaveInt(root, "window.overlay.xpos", session.window_overlay_xpos);
|
||||||
JsonSaveInt (root,"window.overlay.ypos",session.window_overlay_ypos);
|
JsonSaveInt(root, "window.overlay.ypos", session.window_overlay_ypos);
|
||||||
JsonSaveInt (root,"window.overlay.hsize",session.window_overlay_hsize);
|
JsonSaveInt(root, "window.overlay.hsize", session.window_overlay_hsize);
|
||||||
JsonSaveInt (root,"window.overlay.wsize",session.window_overlay_wsize);
|
JsonSaveInt(root, "window.overlay.wsize", session.window_overlay_wsize);
|
||||||
|
|
||||||
// Emoji
|
// Emoji
|
||||||
switch (session.emoji_mode) {
|
switch (session.emoji_mode) {
|
||||||
case ALIAS: JsonSaveStr (root,"show.emoji","alias"); break;
|
case ALIAS:
|
||||||
case EMOJI: JsonSaveStr (root,"show.emoji","emoji"); break;
|
JsonSaveStr(root, "show.emoji", "alias");
|
||||||
case ALTTEXT: JsonSaveStr (root,"show.emoji","alttext"); break;
|
break;
|
||||||
case ERASE: JsonSaveStr (root,"show.emoji","erase"); break;
|
case EMOJI:
|
||||||
|
JsonSaveStr(root, "show.emoji", "emoji");
|
||||||
|
break;
|
||||||
|
case ALTTEXT:
|
||||||
|
JsonSaveStr(root, "show.emoji", "alttext");
|
||||||
|
break;
|
||||||
|
case ERASE:
|
||||||
|
JsonSaveStr(root, "show.emoji", "erase");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
JsonSaveStr (root,"show.emoji","ALIAS");
|
JsonSaveStr(root, "show.emoji", "ALIAS");
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonSaveBoolean (root,"show.hints",session.show_hints);
|
JsonSaveBoolean(root, "show.hints", session.show_hints);
|
||||||
|
|
||||||
JsonSaveBoolean (root,"os.supports.colors",session.supports_colors);
|
JsonSaveBoolean(root, "os.supports.colors", session.supports_colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void preferences_load_callback (json_t *root) {
|
void preferences_load_callback(json_t *root) {
|
||||||
json_error_t up_error = {0};
|
json_error_t up_error = {0};
|
||||||
bool b1;
|
bool b1;
|
||||||
int i1;
|
int i1;
|
||||||
|
@ -163,48 +177,48 @@ void preferences_load_callback (json_t *root) {
|
||||||
char tempStr [500]; // to use str_lower() since json unpack uses const char *
|
char tempStr [500]; // to use str_lower() since json unpack uses const char *
|
||||||
|
|
||||||
// Logging Level
|
// Logging Level
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:s}","client.debug.level",&s1) == 0) {
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "client.debug.level", &s1) == 0) {
|
||||||
strncpy (tempStr,s1,sizeof(tempStr)-1);
|
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||||
str_lower (tempStr);
|
str_lower(tempStr);
|
||||||
if (strncmp (tempStr,"off",3) == 0) session.client_debug_level = OFF;
|
if (strncmp(tempStr, "off", 3) == 0) session.client_debug_level = OFF;
|
||||||
if (strncmp (tempStr,"simple",6) == 0) session.client_debug_level = SIMPLE;
|
if (strncmp(tempStr, "simple", 6) == 0) session.client_debug_level = SIMPLE;
|
||||||
if (strncmp (tempStr,"full",4) == 0) session.client_debug_level = FULL;
|
if (strncmp(tempStr, "full", 4) == 0) session.client_debug_level = FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// window plot
|
// window plot
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.xpos",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
|
||||||
session.window_plot_xpos = i1;
|
session.window_plot_xpos = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.ypos",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.ypos", &i1) == 0)
|
||||||
session.window_plot_ypos = i1;
|
session.window_plot_ypos = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.hsize",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.hsize", &i1) == 0)
|
||||||
session.window_plot_hsize = i1;
|
session.window_plot_hsize = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.plot.wsize",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.wsize", &i1) == 0)
|
||||||
session.window_plot_wsize = i1;
|
session.window_plot_wsize = i1;
|
||||||
|
|
||||||
// overlay/slider plot
|
// overlay/slider plot
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.xpos",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.xpos", &i1) == 0)
|
||||||
session.window_overlay_xpos = i1;
|
session.window_overlay_xpos = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.ypos",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.ypos", &i1) == 0)
|
||||||
session.window_overlay_ypos = i1;
|
session.window_overlay_ypos = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.hsize",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.hsize", &i1) == 0)
|
||||||
session.window_overlay_hsize = i1;
|
session.window_overlay_hsize = i1;
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:i}","window.overlay.wsize",&i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.overlay.wsize", &i1) == 0)
|
||||||
session.window_overlay_wsize = i1;
|
session.window_overlay_wsize = i1;
|
||||||
|
|
||||||
// show options
|
// show options
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:s}","show.emoji",&s1) == 0) {
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.emoji", &s1) == 0) {
|
||||||
strncpy (tempStr,s1,sizeof(tempStr)-1);
|
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||||
str_lower (tempStr);
|
str_lower(tempStr);
|
||||||
if (strncmp (tempStr,"alias",5) == 0) session.emoji_mode = ALIAS;
|
if (strncmp(tempStr, "alias", 5) == 0) session.emoji_mode = ALIAS;
|
||||||
if (strncmp (tempStr,"emoji",5) == 0) session.emoji_mode = EMOJI;
|
if (strncmp(tempStr, "emoji", 5) == 0) session.emoji_mode = EMOJI;
|
||||||
if (strncmp (tempStr,"alttext",7) == 0) session.emoji_mode = ALTTEXT;
|
if (strncmp(tempStr, "alttext", 7) == 0) session.emoji_mode = ALTTEXT;
|
||||||
if (strncmp (tempStr,"erase",5) == 0) session.emoji_mode = ERASE;
|
if (strncmp(tempStr, "erase", 5) == 0) session.emoji_mode = ERASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:b}","show.hints",&b1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "show.hints", &b1) == 0)
|
||||||
session.show_hints = b1;
|
session.show_hints = b1;
|
||||||
|
|
||||||
if (json_unpack_ex(root,&up_error, 0, "{s:b}","os.supports.colors",&b1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
||||||
session.supports_colors = b1;
|
session.supports_colors = b1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -254,83 +268,92 @@ static int usage_set_hints() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preference Processing Functions
|
// Preference Processing Functions
|
||||||
typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t;
|
typedef enum preferenceId {prefNONE, prefHELP, prefEMOJI, prefCOLOR, prefPLOT, prefOVERLAY, prefHINTS, prefCLIENTDEBUG} preferenceId_t;
|
||||||
typedef enum prefShowOpt {prefShowNone,prefShowOLD,prefShowNEW} prefShowOpt_t;
|
typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t;
|
||||||
|
|
||||||
const char *prefShowMsg (prefShowOpt_t Opt)
|
const char *prefShowMsg(prefShowOpt_t Opt) {
|
||||||
{
|
|
||||||
switch (Opt) {
|
switch (Opt) {
|
||||||
case prefShowOLD: return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break;
|
case prefShowOLD:
|
||||||
case prefShowNEW: return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break;
|
return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break;
|
||||||
case prefShowNone: return "";
|
case prefShowNEW:
|
||||||
|
return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break;
|
||||||
|
case prefShowNone:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void showEmojiState (prefShowOpt_t Opt) {
|
void showEmojiState(prefShowOpt_t Opt) {
|
||||||
|
|
||||||
switch (session.emoji_mode) {
|
switch (session.emoji_mode) {
|
||||||
case ALIAS: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alias"),prefShowMsg (Opt));
|
case ALIAS:
|
||||||
|
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alias"), prefShowMsg(Opt));
|
||||||
break;
|
break;
|
||||||
case EMOJI: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"),prefShowMsg (Opt));
|
case EMOJI:
|
||||||
|
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"), prefShowMsg(Opt));
|
||||||
break;
|
break;
|
||||||
case ALTTEXT: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"),prefShowMsg (Opt));
|
case ALTTEXT:
|
||||||
|
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"), prefShowMsg(Opt));
|
||||||
break;
|
break;
|
||||||
case ERASE: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"),prefShowMsg (Opt));
|
case ERASE:
|
||||||
|
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"), prefShowMsg(Opt));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_RED_("unknown"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s emoji.................. "_RED_("unknown"), prefShowMsg(Opt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showColorState (prefShowOpt_t Opt) {
|
void showColorState(prefShowOpt_t Opt) {
|
||||||
|
|
||||||
if (session.supports_colors)
|
if (session.supports_colors)
|
||||||
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"), prefShowMsg(Opt));
|
||||||
else
|
else
|
||||||
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("off"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("off"), prefShowMsg(Opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
void showClientDebugState (prefShowOpt_t Opt) {
|
void showClientDebugState(prefShowOpt_t Opt) {
|
||||||
|
|
||||||
switch (session.client_debug_level) {
|
switch (session.client_debug_level) {
|
||||||
case OFF: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("off"),prefShowMsg(Opt));
|
case OFF:
|
||||||
break;
|
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("off"), prefShowMsg(Opt));
|
||||||
case SIMPLE: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("simple"),prefShowMsg(Opt));
|
break;
|
||||||
break;
|
case SIMPLE:
|
||||||
case FULL: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("full"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("simple"), prefShowMsg(Opt));
|
||||||
break;
|
break;
|
||||||
|
case FULL:
|
||||||
|
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("full"), prefShowMsg(Opt));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"), prefShowMsg(Opt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPlotPosState (void){
|
void showPlotPosState(void) {
|
||||||
PrintAndLogEx (NORMAL," Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||||
session.window_plot_xpos,session.window_plot_ypos,session.window_plot_hsize,session.window_plot_wsize);
|
session.window_plot_xpos, session.window_plot_ypos, session.window_plot_hsize, session.window_plot_wsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showOverlayPosState (void){
|
void showOverlayPosState(void) {
|
||||||
PrintAndLogEx (NORMAL," Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
PrintAndLogEx(NORMAL, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||||
session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_hsize,session.window_overlay_wsize);
|
session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_hsize, session.window_overlay_wsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showHintsState (prefShowOpt_t Opt){
|
void showHintsState(prefShowOpt_t Opt) {
|
||||||
if (session.show_hints)
|
if (session.show_hints)
|
||||||
PrintAndLogEx (NORMAL," %s Hints.................. "_GREEN_("on"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s Hints.................. "_GREEN_("on"), prefShowMsg(Opt));
|
||||||
else
|
else
|
||||||
PrintAndLogEx (NORMAL," %s Hints.................. "_GREEN_("off"),prefShowMsg(Opt));
|
PrintAndLogEx(NORMAL, " %s Hints.................. "_GREEN_("off"), prefShowMsg(Opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setCmdEmoji (const char *Cmd) {
|
static int setCmdEmoji(const char *Cmd) {
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
char strOpt[50];
|
char strOpt[50];
|
||||||
emojiMode_t newValue = session.emoji_mode;
|
emojiMode_t newValue = session.emoji_mode;
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_emoji();
|
return usage_set_emoji();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -338,37 +361,37 @@ static int setCmdEmoji (const char *Cmd) {
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp (strOpt,"help",4) == 0)
|
if (strncmp(strOpt, "help", 4) == 0)
|
||||||
return usage_set_emoji();
|
return usage_set_emoji();
|
||||||
if (strncmp (strOpt,"alias",5) == 0) {
|
if (strncmp(strOpt, "alias", 5) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = ALIAS;
|
newValue = ALIAS;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"emoji",5) == 0) {
|
if (strncmp(strOpt, "emoji", 5) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = EMOJI;
|
newValue = EMOJI;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"alttext",7) == 0) {
|
if (strncmp(strOpt, "alttext", 7) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = ALTTEXT;
|
newValue = ALTTEXT;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"erase",5) == 0) {
|
if (strncmp(strOpt, "erase", 5) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = ERASE;
|
newValue = ERASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validValue) {
|
if (validValue) {
|
||||||
if (session.emoji_mode != newValue) {// changed
|
if (session.emoji_mode != newValue) {// changed
|
||||||
showEmojiState (prefShowOLD);
|
showEmojiState(prefShowOLD);
|
||||||
session.emoji_mode = newValue;
|
session.emoji_mode = newValue;
|
||||||
showEmojiState (prefShowNEW);
|
showEmojiState(prefShowNEW);
|
||||||
preferences_save ();
|
preferences_save();
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO,"nothing changed");
|
PrintAndLogEx(INFO, "nothing changed");
|
||||||
showEmojiState (prefShowNone);
|
showEmojiState(prefShowNone);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(ERR,"invalid option");
|
PrintAndLogEx(ERR, "invalid option");
|
||||||
return usage_set_emoji();
|
return usage_set_emoji();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,15 +400,14 @@ static int setCmdEmoji (const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setCmdColor (const char *Cmd)
|
static int setCmdColor(const char *Cmd) {
|
||||||
{
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
char strOpt[50];
|
char strOpt[50];
|
||||||
bool newValue = session.supports_colors;
|
bool newValue = session.supports_colors;
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_color();
|
return usage_set_color();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -393,29 +415,29 @@ static int setCmdColor (const char *Cmd)
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp (strOpt,"help",4) == 0)
|
if (strncmp(strOpt, "help", 4) == 0)
|
||||||
return usage_set_color();
|
return usage_set_color();
|
||||||
if (strncmp (strOpt,"off",3) == 0) {
|
if (strncmp(strOpt, "off", 3) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = false;
|
newValue = false;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"ansi",4) == 0) {
|
if (strncmp(strOpt, "ansi", 4) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = true;
|
newValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validValue) {
|
if (validValue) {
|
||||||
if (session.supports_colors != newValue) {// changed
|
if (session.supports_colors != newValue) {// changed
|
||||||
showColorState (prefShowOLD);
|
showColorState(prefShowOLD);
|
||||||
session.supports_colors = newValue;
|
session.supports_colors = newValue;
|
||||||
showColorState (prefShowNEW);
|
showColorState(prefShowNEW);
|
||||||
preferences_save ();
|
preferences_save();
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO,"nothing changed");
|
PrintAndLogEx(INFO, "nothing changed");
|
||||||
showColorState (prefShowNone);
|
showColorState(prefShowNone);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(ERR,"invalid option");
|
PrintAndLogEx(ERR, "invalid option");
|
||||||
return usage_set_color();
|
return usage_set_color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,15 +446,14 @@ static int setCmdColor (const char *Cmd)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setCmdDebug (const char *Cmd)
|
static int setCmdDebug(const char *Cmd) {
|
||||||
{
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
char strOpt[50];
|
char strOpt[50];
|
||||||
clientdebugLevel_t newValue = session.client_debug_level;
|
clientdebugLevel_t newValue = session.client_debug_level;
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_debug();
|
return usage_set_debug();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -440,34 +461,34 @@ static int setCmdDebug (const char *Cmd)
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp (strOpt,"help",4) == 0)
|
if (strncmp(strOpt, "help", 4) == 0)
|
||||||
return usage_set_debug();
|
return usage_set_debug();
|
||||||
if (strncmp (strOpt,"off",3) == 0) {
|
if (strncmp(strOpt, "off", 3) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = OFF;
|
newValue = OFF;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"simple",6) == 0) {
|
if (strncmp(strOpt, "simple", 6) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = SIMPLE;
|
newValue = SIMPLE;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"full",4) == 0) {
|
if (strncmp(strOpt, "full", 4) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = FULL;
|
newValue = FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validValue) {
|
if (validValue) {
|
||||||
if (session.client_debug_level != newValue) {// changed
|
if (session.client_debug_level != newValue) {// changed
|
||||||
showClientDebugState (prefShowOLD);
|
showClientDebugState(prefShowOLD);
|
||||||
session.client_debug_level = newValue;
|
session.client_debug_level = newValue;
|
||||||
g_debugMode = newValue;
|
g_debugMode = newValue;
|
||||||
showClientDebugState (prefShowNEW);
|
showClientDebugState(prefShowNEW);
|
||||||
preferences_save ();
|
preferences_save();
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO,"nothing changed");
|
PrintAndLogEx(INFO, "nothing changed");
|
||||||
showClientDebugState (prefShowNone);
|
showClientDebugState(prefShowNone);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(ERR,"invalid option");
|
PrintAndLogEx(ERR, "invalid option");
|
||||||
return usage_set_debug();
|
return usage_set_debug();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,15 +497,14 @@ static int setCmdDebug (const char *Cmd)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setCmdHint (const char *Cmd)
|
static int setCmdHint(const char *Cmd) {
|
||||||
{
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
char strOpt[50];
|
char strOpt[50];
|
||||||
bool newValue = session.show_hints;
|
bool newValue = session.show_hints;
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_hints();
|
return usage_set_hints();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -492,29 +512,29 @@ static int setCmdHint (const char *Cmd)
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp (strOpt,"help",4) == 0)
|
if (strncmp(strOpt, "help", 4) == 0)
|
||||||
return usage_set_hints();
|
return usage_set_hints();
|
||||||
if (strncmp (strOpt,"off",3) == 0) {
|
if (strncmp(strOpt, "off", 3) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = false;
|
newValue = false;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"on",2) == 0) {
|
if (strncmp(strOpt, "on", 2) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = true;
|
newValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validValue) {
|
if (validValue) {
|
||||||
if (session.show_hints != newValue) {// changed
|
if (session.show_hints != newValue) {// changed
|
||||||
showHintsState (prefShowOLD);
|
showHintsState(prefShowOLD);
|
||||||
session.show_hints = newValue;
|
session.show_hints = newValue;
|
||||||
showHintsState (prefShowNEW);
|
showHintsState(prefShowNEW);
|
||||||
preferences_save ();
|
preferences_save();
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO,"nothing changed");
|
PrintAndLogEx(INFO, "nothing changed");
|
||||||
showHintsState (prefShowNone);
|
showHintsState(prefShowNone);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(ERR,"invalid option");
|
PrintAndLogEx(ERR, "invalid option");
|
||||||
return usage_set_hints();
|
return usage_set_hints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,32 +560,31 @@ static int setCmdHelp(const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdPrefSet (const char *Cmd)
|
int CmdPrefSet(const char *Cmd) {
|
||||||
{
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
||||||
return CmdsParse(setCommandTable, Cmd);
|
return CmdsParse(setCommandTable, Cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdPrefShow (const char *Cmd) {
|
static int CmdPrefShow(const char *Cmd) {
|
||||||
|
|
||||||
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
PrintAndLogEx(NORMAL, _BLUE_("Preferences"));
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL,"");
|
|
||||||
PrintAndLogEx(NORMAL,_BLUE_("Preferences"));
|
|
||||||
|
|
||||||
if (!session. preferences_loaded) {
|
if (!session. preferences_loaded) {
|
||||||
PrintAndLogEx (ERR,"Preferneces not loaded");
|
PrintAndLogEx(ERR, "Preferneces not loaded");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL," preference file........ "_GREEN_("%s"),prefGetFilename());
|
PrintAndLogEx(NORMAL, " preference file........ "_GREEN_("%s"), prefGetFilename());
|
||||||
showEmojiState (prefShowNone);
|
showEmojiState(prefShowNone);
|
||||||
showColorState (prefShowNone);
|
showColorState(prefShowNone);
|
||||||
// showPlotPosState ();
|
// showPlotPosState ();
|
||||||
// showOverlayPosState ();
|
// showOverlayPosState ();
|
||||||
showClientDebugState(prefShowNone);
|
showClientDebugState(prefShowNone);
|
||||||
showHintsState (prefShowNone);
|
showHintsState(prefShowNone);
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL,"");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -591,9 +610,8 @@ static int CmdHelp(const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdPreferences (const char *Cmd)
|
int CmdPreferences(const char *Cmd) {
|
||||||
{
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
||||||
return CmdsParse(CommandTable, Cmd);
|
return CmdsParse(CommandTable, Cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
// Current working directory will be prepended.
|
// Current working directory will be prepended.
|
||||||
#define preferencesFilename "preferences.json"
|
#define preferencesFilename "preferences.json"
|
||||||
|
|
||||||
int CmdPreferences (const char *Cmd);
|
int CmdPreferences(const char *Cmd);
|
||||||
int preferences_load (void);
|
int preferences_load(void);
|
||||||
int preferences_save (void);
|
int preferences_save(void);
|
||||||
|
|
||||||
void preferences_save_callback (json_t *root);
|
void preferences_save_callback(json_t *root);
|
||||||
void preferences_load_callback (json_t *root);
|
void preferences_load_callback(json_t *root);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
extern "C" int preferences_save (void);
|
extern "C" int preferences_save(void);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "util_darwin.h"
|
#include "util_darwin.h"
|
||||||
|
@ -132,26 +132,26 @@ ProxGuiQT::~ProxGuiQT(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// Slider Widget form based on a class to enable
|
// Slider Widget form based on a class to enable
|
||||||
// Event override functions
|
// Event override functions
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
SliderWidget::SliderWidget() {
|
SliderWidget::SliderWidget() {
|
||||||
// Set the initail postion and size from settings
|
// Set the initail postion and size from settings
|
||||||
if (session.preferences_loaded)
|
if (session.preferences_loaded)
|
||||||
setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize);
|
setGeometry(session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_wsize, session.window_overlay_hsize);
|
||||||
else
|
else
|
||||||
resize(800, 400);
|
resize(800, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::resizeEvent (QResizeEvent *event) {
|
void SliderWidget::resizeEvent(QResizeEvent *event) {
|
||||||
session.window_overlay_hsize = event->size().height();
|
session.window_overlay_hsize = event->size().height();
|
||||||
session.window_overlay_wsize = event->size().width();
|
session.window_overlay_wsize = event->size().width();
|
||||||
session.window_changed = true;
|
session.window_changed = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::moveEvent (QMoveEvent *event) {
|
void SliderWidget::moveEvent(QMoveEvent *event) {
|
||||||
session.window_overlay_xpos = event->pos().x();
|
session.window_overlay_xpos = event->pos().x();
|
||||||
session.window_overlay_ypos = event->pos().y();
|
session.window_overlay_ypos = event->pos().y();
|
||||||
session.window_changed = true;
|
session.window_changed = true;
|
||||||
|
@ -199,12 +199,12 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||||
this->master = master;
|
this->master = master;
|
||||||
// Set the initail postion and size from settings
|
// Set the initail postion and size from settings
|
||||||
if (session.preferences_loaded)
|
if (session.preferences_loaded)
|
||||||
setGeometry (session.window_plot_xpos,session.window_plot_ypos,session.window_plot_wsize,session.window_plot_hsize);
|
setGeometry(session.window_plot_xpos, session.window_plot_ypos, session.window_plot_wsize, session.window_plot_hsize);
|
||||||
else
|
else
|
||||||
resize(800, 400);
|
resize(800, 400);
|
||||||
|
|
||||||
// Setup the controller widget
|
// Setup the controller widget
|
||||||
controlWidget = new SliderWidget ();//new QWidget();
|
controlWidget = new SliderWidget(); //new QWidget();
|
||||||
opsController = new Ui::Form();
|
opsController = new Ui::Form();
|
||||||
opsController->setupUi(controlWidget);
|
opsController->setupUi(controlWidget);
|
||||||
//Due to quirks in QT Designer, we need to fiddle a bit
|
//Due to quirks in QT Designer, we need to fiddle a bit
|
||||||
|
@ -224,7 +224,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||||
QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int)));
|
QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int)));
|
||||||
QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int)));
|
QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int)));
|
||||||
|
|
||||||
controlWidget->setGeometry (session.window_overlay_xpos,session.window_overlay_ypos,session.window_overlay_wsize,session.window_overlay_hsize);
|
controlWidget->setGeometry(session.window_overlay_xpos, session.window_overlay_ypos, session.window_overlay_wsize, session.window_overlay_hsize);
|
||||||
|
|
||||||
// Set up the plot widget, which does the actual plotting
|
// Set up the plot widget, which does the actual plotting
|
||||||
plot = new Plot(this);
|
plot = new Plot(this);
|
||||||
|
@ -240,7 +240,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||||
show();
|
show();
|
||||||
|
|
||||||
// Set Slider/Overlay position if no settings.
|
// Set Slider/Overlay position if no settings.
|
||||||
if (!session.preferences_loaded){
|
if (!session.preferences_loaded) {
|
||||||
// Move controller widget below plot
|
// Move controller widget below plot
|
||||||
controlWidget->move(x(), y() + frameSize().height());
|
controlWidget->move(x(), y() + frameSize().height());
|
||||||
controlWidget->resize(size().width(), 200);
|
controlWidget->resize(size().width(), 200);
|
||||||
|
@ -251,7 +251,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
||||||
controlWidget->setWindowTitle(ct);
|
controlWidget->setWindowTitle(ct);
|
||||||
|
|
||||||
controlWidget->show();
|
controlWidget->show();
|
||||||
|
|
||||||
// now that is up, reset pos/size change flags
|
// now that is up, reset pos/size change flags
|
||||||
session.window_changed = false;
|
session.window_changed = false;
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,10 @@ class ProxGuiQT;
|
||||||
|
|
||||||
// Added class for SliderWidget to allow move/resize event override
|
// Added class for SliderWidget to allow move/resize event override
|
||||||
class SliderWidget : public QWidget {
|
class SliderWidget : public QWidget {
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent (QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void moveEvent (QMoveEvent *event);
|
void moveEvent(QMoveEvent *event);
|
||||||
public:
|
public:
|
||||||
SliderWidget();
|
SliderWidget();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,33 +42,33 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
static void utf8_showBanner (void) {
|
static void utf8_showBanner(void) {
|
||||||
|
|
||||||
char sq[] = { 0xE2,0x96,0x88,0x00 }; // square block
|
char sq[] = { 0xE2, 0x96, 0x88, 0x00 }; // square block
|
||||||
char tr[] = { 0xE2,0x95,0x97,0x00 }; // top rigth corner
|
char tr[] = { 0xE2, 0x95, 0x97, 0x00 }; // top rigth corner
|
||||||
char tl[] = { 0xE2,0x95,0x94,0x00 }; // top left corner
|
char tl[] = { 0xE2, 0x95, 0x94, 0x00 }; // top left corner
|
||||||
char br[] = { 0xE2,0x95,0x9D,0x00 }; // bottom right corner
|
char br[] = { 0xE2, 0x95, 0x9D, 0x00 }; // bottom right corner
|
||||||
char bl[] = { 0xE2,0x95,0x9A,0x00 }; // bottom left corner
|
char bl[] = { 0xE2, 0x95, 0x9A, 0x00 }; // bottom left corner
|
||||||
char hl[] = { 0xE2,0x95,0x90,0x00 }; // horiz line
|
char hl[] = { 0xE2, 0x95, 0x90, 0x00 }; // horiz line
|
||||||
char vl[] = { 0xE2,0x95,0x91,0x00 }; // vert line
|
char vl[] = { 0xE2, 0x95, 0x91, 0x00 }; // vert line
|
||||||
char msg1 [60];
|
char msg1 [60];
|
||||||
char msg2 [60];
|
char msg2 [60];
|
||||||
char msg3 [60];
|
char msg3 [60];
|
||||||
|
|
||||||
strcpy (msg1," :snowflake: iceman@icesql.net :coffee:");
|
strcpy(msg1, " :snowflake: iceman@icesql.net :coffee:");
|
||||||
strcpy (msg2," https://github.com/rfidresearchgroup/proxmark3/");
|
strcpy(msg2, " https://github.com/rfidresearchgroup/proxmark3/");
|
||||||
strcpy (msg3,"pre-release v4.0");
|
strcpy(msg3, "pre-release v4.0");
|
||||||
|
|
||||||
g_printAndLog = PRINTANDLOG_PRINT;
|
g_printAndLog = PRINTANDLOG_PRINT;
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "\n");
|
PrintAndLogEx(NORMAL, "\n");
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s%s "),sq,sq,sq,sq,sq,sq,tr,sq,sq,sq,tr,sq,sq,sq,tr,sq,sq,sq,sq,tr);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s %s%s%s%s %s%s%s%s%s "), sq, sq, sq, sq, sq, sq, tr, sq, sq, sq, tr, sq, sq, sq, tr, sq, sq, sq, sq, tr);
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s %s%s%s%s"),sq,sq,tl,hl,hl,sq,sq,tr,sq,sq,sq,sq,tr,sq,sq,sq,sq,vl,hl,hl,sq,vl);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s %s%s%s%s"), sq, sq, tl, hl, hl, sq, sq, tr, sq, sq, sq, sq, tr, sq, sq, sq, sq, vl, hl, hl, sq, vl);
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s%s"),sq,sq,sq,sq,sq,sq,tl,br,sq,sq,tl,sq,sq,sq,sq,tl,sq,sq,vl,sq,sq,sq,sq,tl,br);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s %s%s%s%s%s%s"), sq, sq, sq, sq, sq, sq, tl, br, sq, sq, tl, sq, sq, sq, sq, tl, sq, sq, vl, sq, sq, sq, sq, tl, br);
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s%s%s%s %s%s%s%s")"%s",sq,sq,tr,hl,hl,hl,br,sq,sq,vl,bl,sq,sq,tl,br,sq,sq,vl,hl,hl,sq,vl,msg1);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s%s%s%s%s %s%s%s%s%s%s%s%s%s%s%s %s%s%s%s")"%s", sq, sq, tr, hl, hl, hl, br, sq, sq, vl, bl, sq, sq, tl, br, sq, sq, vl, hl, hl, sq, vl, msg1);
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s %s%s%s%s%s%s")"%s",sq,sq,vl,sq,sq,vl,bl,hl,br,sq,sq,vl,sq,sq,sq,sq,tl,br,msg2);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s %s%s%s%s%s%s")"%s", sq, sq, vl, sq, sq, vl, bl, hl, br, sq, sq, vl, sq, sq, sq, sq, tl, br, msg2);
|
||||||
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s%s%s ")"%s",bl,hl,br,bl,hl,br,bl,hl,br,bl,hl,hl,hl,br,msg3);
|
PrintAndLogEx(NORMAL, " " _BLUE_("%s%s%s %s%s%s %s%s%s %s%s%s%s%s ")"%s", bl, hl, br, bl, hl, br, bl, hl, br, bl, hl, hl, hl, br, msg3);
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -82,7 +82,7 @@ static void showBanner(void) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// If on windows and using UTF-8 then we need utf-8 ascii art for banner.
|
// If on windows and using UTF-8 then we need utf-8 ascii art for banner.
|
||||||
if (GetConsoleCP() == 65001) {
|
if (GetConsoleCP() == 65001) {
|
||||||
utf8_showBanner ();
|
utf8_showBanner();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -409,11 +409,11 @@ static void set_my_user_directory(void) {
|
||||||
|
|
||||||
// if not found, default to current directory
|
// if not found, default to current directory
|
||||||
if (my_user_directory == NULL) {
|
if (my_user_directory == NULL) {
|
||||||
my_user_directory = GetCurrentDir ( _cwd_Buffer,sizeof( _cwd_Buffer));
|
my_user_directory = GetCurrentDir(_cwd_Buffer, sizeof(_cwd_Buffer));
|
||||||
// change all slashs to / (windows should not care...
|
// change all slashs to / (windows should not care...
|
||||||
for (int i = 0; i < strlen(_cwd_Buffer); i++)
|
for (int i = 0; i < strlen(_cwd_Buffer); i++)
|
||||||
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
|
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
|
||||||
// my_user_directory = ".";
|
// my_user_directory = ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ int main(int argc, char *argv[]) {
|
||||||
#ifdef USE_PREFERENCE_FILE
|
#ifdef USE_PREFERENCE_FILE
|
||||||
// Load Settings and assign
|
// Load Settings and assign
|
||||||
// This will allow the command line to override the settings.json values
|
// This will allow the command line to override the settings.json values
|
||||||
preferences_load ();
|
preferences_load();
|
||||||
// Change height/width (Rows,Cols) - Testing
|
// Change height/width (Rows,Cols) - Testing
|
||||||
// printf ("\e[8;50;100t");
|
// printf ("\e[8;50;100t");
|
||||||
// printf ("\e[3;50;50t"); // x,y
|
// printf ("\e[3;50;50t"); // x,y
|
||||||
|
@ -844,7 +844,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_PREFERENCE_FILE
|
#ifndef USE_PREFERENCE_FILE
|
||||||
// comment next 2 lines to use session values set from settings_load
|
// comment next 2 lines to use session values set from settings_load
|
||||||
session.supports_colors = DetectWindowsAnsiSupport();
|
session.supports_colors = DetectWindowsAnsiSupport();
|
||||||
session.emoji_mode = ALTTEXT;
|
session.emoji_mode = ALTTEXT;
|
||||||
#endif
|
#endif
|
||||||
|
@ -859,12 +859,12 @@ int main(int argc, char *argv[]) {
|
||||||
// struct stat tmp_stat;
|
// struct stat tmp_stat;
|
||||||
// if ((fstat (STDOUT_FILENO, &tmp_stat) == 0) && (S_ISCHR (tmp_stat.st_mode)) && isatty(STDIN_FILENO))
|
// if ((fstat (STDOUT_FILENO, &tmp_stat) == 0) && (S_ISCHR (tmp_stat.st_mode)) && isatty(STDIN_FILENO))
|
||||||
#ifdef USE_PREFERENCE_FILE
|
#ifdef USE_PREFERENCE_FILE
|
||||||
if (!session.preferences_loaded) {
|
if (!session.preferences_loaded) {
|
||||||
if (session.stdinOnTTY && session.stdoutOnTTY) {
|
if (session.stdinOnTTY && session.stdoutOnTTY) {
|
||||||
session.supports_colors = true;
|
session.supports_colors = true;
|
||||||
session.emoji_mode = EMOJI;
|
session.emoji_mode = EMOJI;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (session.stdinOnTTY && session.stdoutOnTTY) {
|
if (session.stdinOnTTY && session.stdoutOnTTY) {
|
||||||
session.supports_colors = true;
|
session.supports_colors = true;
|
||||||
|
@ -932,7 +932,7 @@ int main(int argc, char *argv[]) {
|
||||||
// Doing this here will ensure other checks and updates are saved to over rule default
|
// Doing this here will ensure other checks and updates are saved to over rule default
|
||||||
// e.g. Linux color use check
|
// e.g. Linux color use check
|
||||||
if (!session.preferences_loaded) {
|
if (!session.preferences_loaded) {
|
||||||
preferences_save (); // Save defaults
|
preferences_save(); // Save defaults
|
||||||
session.preferences_loaded = true;
|
session.preferences_loaded = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -964,7 +964,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
#ifdef USE_PREFERENCE_FILE
|
#ifdef USE_PREFERENCE_FILE
|
||||||
if (session.window_changed) // Plot/Overlay moved or resized
|
if (session.window_changed) // Plot/Overlay moved or resized
|
||||||
preferences_save ();
|
preferences_save();
|
||||||
#endif
|
#endif
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0'
|
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG 0'
|
||||||
if (g_debugMode == 0 && level == DEBUG)
|
if (g_debugMode == 0 && level == DEBUG)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
||||||
if (session.show_hints == false && level == HINT)
|
if (session.show_hints == false && level == HINT)
|
||||||
return;
|
return;
|
||||||
|
@ -143,7 +143,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
FILE *stream = stdout;
|
FILE *stream = stdout;
|
||||||
const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")};
|
const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")};
|
||||||
const char *spinner_emoji[] = {" :clock1: ", " :clock2: ", " :clock3: ", " :clock4: ", " :clock5: ", " :clock6: ",
|
const char *spinner_emoji[] = {" :clock1: ", " :clock2: ", " :clock3: ", " :clock4: ", " :clock5: ", " :clock6: ",
|
||||||
" :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "};
|
" :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "
|
||||||
|
};
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case ERR:
|
case ERR:
|
||||||
if (session.emoji_mode == EMOJI)
|
if (session.emoji_mode == EMOJI)
|
||||||
|
@ -433,7 +434,7 @@ void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode
|
||||||
const char *emojified_token = NULL;
|
const char *emojified_token = NULL;
|
||||||
uint8_t emojified_token_length = 0;
|
uint8_t emojified_token_length = 0;
|
||||||
char *current_token = NULL;
|
char *current_token = NULL;
|
||||||
uint8_t current_token_length=0;
|
uint8_t current_token_length = 0;
|
||||||
char current_char;
|
char current_char;
|
||||||
char *rdest = (char *)dest;
|
char *rdest = (char *)dest;
|
||||||
char *rsrc = (char *)src;
|
char *rsrc = (char *)src;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t;
|
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t;
|
||||||
typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t;
|
typedef enum emojiMode {ALIAS, EMOJI, ALTTEXT, ERASE} emojiMode_t;
|
||||||
typedef enum clientdebugLevel {OFF,SIMPLE,FULL} clientdebugLevel_t;
|
typedef enum clientdebugLevel {OFF, SIMPLE, FULL} clientdebugLevel_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool preferences_loaded;
|
bool preferences_loaded;
|
||||||
|
|
|
@ -272,7 +272,7 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||||
char *begin;
|
char *begin;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
begin = (char*)mmap(0, offset + sizeof(p), PROT_READ, MAP_SHARED, fd, 0);
|
begin = (char *)mmap(0, offset + sizeof(p), PROT_READ, MAP_SHARED, fd, 0);
|
||||||
p = begin + offset;
|
p = begin + offset;
|
||||||
|
|
||||||
while (p >= begin) { // scan backwards
|
while (p >= begin) { // scan backwards
|
||||||
|
|
|
@ -91,4 +91,4 @@ uint8_t GetNumberBlocksForUserId(uint8_t *src) {
|
||||||
memcpy(c + 5, src, 8);
|
memcpy(c + 5, src, 8);
|
||||||
ExchangeAPDUSC(true, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
|
ExchangeAPDUSC(true, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
|
||||||
return resp[8];
|
return resp[8];
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
// XYZ 3D printing
|
// XYZ 3D printing
|
||||||
// Vinglock
|
// Vinglock
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
void transform_D(uint8_t* ru) {
|
void transform_D(uint8_t *ru) {
|
||||||
|
|
||||||
const uint32_t c_D[] = {
|
const uint32_t c_D[] = {
|
||||||
0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8,
|
0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8,
|
||||||
|
@ -44,32 +44,31 @@ void transform_D(uint8_t* ru) {
|
||||||
0x5728B869, 0x30726D5A
|
0x5728B869, 0x30726D5A
|
||||||
};
|
};
|
||||||
|
|
||||||
//Transform
|
//Transform
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t p = 0;
|
uint8_t p = 0;
|
||||||
uint32_t v1 = ((ru[3] << 24) | (ru[2] << 16) | (ru[1] << 8) | ru[0]) + c_D[p++];
|
uint32_t v1 = ((ru[3] << 24) | (ru[2] << 16) | (ru[1] << 8) | ru[0]) + c_D[p++];
|
||||||
uint32_t v2 = ((ru[7] << 24) | (ru[6] << 16) | (ru[5] << 8) | ru[4]) + c_D[p++];
|
uint32_t v2 = ((ru[7] << 24) | (ru[6] << 16) | (ru[5] << 8) | ru[4]) + c_D[p++];
|
||||||
for (i = 0; i < 12; i += 2)
|
for (i = 0; i < 12; i += 2) {
|
||||||
{
|
uint32_t tempA = v1 ^ v2;
|
||||||
uint32_t tempA = v1 ^ v2;
|
uint32_t t1 = PM3_ROTL(tempA, v2 & 0x1F) + c_D[p++];
|
||||||
uint32_t t1 = PM3_ROTL(tempA, v2 & 0x1F) + c_D[p++];
|
uint32_t tempB = v2 ^ t1;
|
||||||
uint32_t tempB = v2 ^ t1;
|
uint32_t t2 = PM3_ROTL(tempB, t1 & 0x1F) + c_D[p++];
|
||||||
uint32_t t2 = PM3_ROTL(tempB, t1 & 0x1F) + c_D[p++];
|
tempA = t1 ^ t2;
|
||||||
tempA = t1 ^ t2;
|
v1 = PM3_ROTL(tempA, t2 & 0x1F) + c_D[p++];
|
||||||
v1 = PM3_ROTL(tempA, t2 & 0x1F) + c_D[p++];
|
tempB = t2 ^ v1;
|
||||||
tempB = t2 ^ v1;
|
v2 = PM3_ROTL(tempB, v1 & 0x1F) + c_D[p++];
|
||||||
v2 = PM3_ROTL(tempB, v1 & 0x1F) + c_D[p++];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Re-use ru
|
//Re-use ru
|
||||||
ru[0] = v1 & 0xFF;
|
ru[0] = v1 & 0xFF;
|
||||||
ru[1] = (v1 >> 8) & 0xFF;
|
ru[1] = (v1 >> 8) & 0xFF;
|
||||||
ru[2] = (v1 >> 16) & 0xFF;
|
ru[2] = (v1 >> 16) & 0xFF;
|
||||||
ru[3] = (v1 >> 24) & 0xFF;
|
ru[3] = (v1 >> 24) & 0xFF;
|
||||||
ru[4] = v2 & 0xFF;
|
ru[4] = v2 & 0xFF;
|
||||||
ru[5] = (v2 >> 8) & 0xFF;
|
ru[5] = (v2 >> 8) & 0xFF;
|
||||||
ru[6] = (v2 >> 16) & 0xFF;
|
ru[6] = (v2 >> 16) & 0xFF;
|
||||||
ru[7] = (v2 >> 24) & 0xFF;
|
ru[7] = (v2 >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transport system (IT) pwd generation algo nickname A.
|
// Transport system (IT) pwd generation algo nickname A.
|
||||||
|
@ -136,16 +135,16 @@ uint32_t ul_ev1_pwdgenD(uint8_t *uid) {
|
||||||
uint8_t r = (uid[1] + uid[3] + uid[5]) & 7;
|
uint8_t r = (uid[1] + uid[3] + uid[5]) & 7;
|
||||||
|
|
||||||
// rotated UID
|
// rotated UID
|
||||||
uint8_t ru[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
uint8_t ru[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
ru[(i + r) & 7] = uid[i];
|
ru[(i + r) & 7] = uid[i];
|
||||||
|
|
||||||
transform_D(ru);
|
transform_D(ru);
|
||||||
|
|
||||||
// offset
|
// offset
|
||||||
r = (ru[0] + ru[2] + ru[4] + ru[6]) & 3;
|
r = (ru[0] + ru[2] + ru[4] + ru[6]) & 3;
|
||||||
|
|
||||||
// calc key
|
// calc key
|
||||||
uint32_t pwd = 0;
|
uint32_t pwd = 0;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
pwd = ru[i + r] + (pwd << 8);
|
pwd = ru[i + r] + (pwd << 8);
|
||||||
|
@ -429,28 +428,28 @@ int generator_selftest() {
|
||||||
uint8_t uid1[] = {0x04, 0x11, 0x12, 0x11, 0x12, 0x11, 0x10};
|
uint8_t uid1[] = {0x04, 0x11, 0x12, 0x11, 0x12, 0x11, 0x10};
|
||||||
uint32_t pwd1 = ul_ev1_pwdgenA(uid1);
|
uint32_t pwd1 = ul_ev1_pwdgenA(uid1);
|
||||||
success = (pwd1 == 0x8432EB17);
|
success = (pwd1 == 0x8432EB17);
|
||||||
if (success)
|
if (success)
|
||||||
testresult++;
|
testresult++;
|
||||||
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid1, 7), pwd1, success ? "OK" : "->8432EB17<-");
|
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid1, 7), pwd1, success ? "OK" : "->8432EB17<-");
|
||||||
|
|
||||||
uint8_t uid2[] = {0x04, 0x1f, 0x98, 0xea, 0x1e, 0x3e, 0x81};
|
uint8_t uid2[] = {0x04, 0x1f, 0x98, 0xea, 0x1e, 0x3e, 0x81};
|
||||||
uint32_t pwd2 = ul_ev1_pwdgenB(uid2);
|
uint32_t pwd2 = ul_ev1_pwdgenB(uid2);
|
||||||
success = (pwd2 == 0x5fd37eca);
|
success = (pwd2 == 0x5fd37eca);
|
||||||
if (success)
|
if (success)
|
||||||
testresult++;
|
testresult++;
|
||||||
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid2, 7), pwd2, success ? "OK" : "->5fd37eca<--");
|
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid2, 7), pwd2, success ? "OK" : "->5fd37eca<--");
|
||||||
|
|
||||||
uint8_t uid3[] = {0x04, 0x62, 0xB6, 0x8A, 0xB4, 0x42, 0x80};
|
uint8_t uid3[] = {0x04, 0x62, 0xB6, 0x8A, 0xB4, 0x42, 0x80};
|
||||||
uint32_t pwd3 = ul_ev1_pwdgenC(uid3);
|
uint32_t pwd3 = ul_ev1_pwdgenC(uid3);
|
||||||
success = (pwd3 == 0x5a349515);
|
success = (pwd3 == 0x5a349515);
|
||||||
if (success)
|
if (success)
|
||||||
testresult++;
|
testresult++;
|
||||||
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid3, 7), pwd3, success ? "OK" : "->5a349515<--");
|
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid3, 7), pwd3, success ? "OK" : "->5a349515<--");
|
||||||
|
|
||||||
uint8_t uid4[] = {0x04, 0xC5, 0xDF, 0x4A, 0x6D, 0x51, 0x80};
|
uint8_t uid4[] = {0x04, 0xC5, 0xDF, 0x4A, 0x6D, 0x51, 0x80};
|
||||||
uint32_t pwd4 = ul_ev1_pwdgenD(uid4);
|
uint32_t pwd4 = ul_ev1_pwdgenD(uid4);
|
||||||
success = (pwd4 == 0x72B1EC61);
|
success = (pwd4 == 0x72B1EC61);
|
||||||
if (success)
|
if (success)
|
||||||
testresult++;
|
testresult++;
|
||||||
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid4, 7), pwd4, success ? "OK" : "->72B1EC61<--");
|
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %08X - %s", sprint_hex(uid4, 7), pwd4, success ? "OK" : "->72B1EC61<--");
|
||||||
|
|
||||||
|
@ -463,7 +462,7 @@ int generator_selftest() {
|
||||||
uint64_t key6 = 0;
|
uint64_t key6 = 0;
|
||||||
mfc_algo_sky_one(uid6, 15, 0, &key6);
|
mfc_algo_sky_one(uid6, 15, 0, &key6);
|
||||||
success = (key6 == 0x82c7e64bc565);
|
success = (key6 == 0x82c7e64bc565);
|
||||||
if (success)
|
if (success)
|
||||||
testresult++;
|
testresult++;
|
||||||
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %"PRIx64" - %s", sprint_hex(uid6, 4), key6, success ? "OK" : "->82C7E64BC565<--");
|
PrintAndLogEx(success ? SUCCESS : WARNING, "UID | %s | %"PRIx64" - %s", sprint_hex(uid6, 4), key6, success ? "OK" : "->82C7E64BC565<--");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue