make style

This commit is contained in:
Philippe Teuwen 2020-04-16 09:01:14 +02:00
parent 588f7e98f5
commit 94192d0976
44 changed files with 674 additions and 656 deletions

View file

@ -60,7 +60,7 @@ 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;
} }
@ -68,7 +68,7 @@ void save_dump_to_file(legic_card_select_t *p_card) {
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;
} }
@ -146,8 +146,8 @@ void RunMod() {
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:

View file

@ -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;

View file

@ -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;
} }

View file

@ -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 */

View file

@ -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);
} }
} }
} }

View file

@ -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) {

View file

@ -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

View file

@ -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"},

View file

@ -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;

View file

@ -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,50 +222,50 @@ 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];
@ -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;
@ -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.");

View file

@ -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");
@ -527,7 +527,7 @@ int CmdHFCryptoRF(const char *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();

View file

@ -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;

View file

@ -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")
); );
@ -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);
} }

View file

@ -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);
@ -132,15 +132,15 @@ 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"}
}; };
@ -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]));
@ -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;

View file

@ -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),
@ -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
@ -879,56 +879,56 @@ static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *sig
{"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];
@ -2738,7 +2738,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
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:
@ -2789,7 +2789,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
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));
@ -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();

View file

@ -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]);

View file

@ -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,12 +94,10 @@ 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)
@ -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,24 +244,24 @@ 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
@ -272,17 +271,17 @@ 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
@ -290,7 +289,7 @@ static int CmdKeriClone(const char *Cmd) {
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;
} }

View file

@ -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);

View file

@ -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 ? "..." : "");
} }

View file

@ -427,7 +427,7 @@ 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:

View file

@ -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)) {

View file

@ -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,7 +61,7 @@ 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;
@ -80,28 +80,28 @@ int preferences_load (void) {
// 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,76 +268,85 @@ 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;
@ -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,8 +400,7 @@ 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;
@ -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,8 +446,7 @@ 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;
@ -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,8 +497,7 @@ 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;
@ -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, "");
PrintAndLogEx(NORMAL,_BLUE_("Preferences")); 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,8 +610,7 @@ 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);

View file

@ -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

View file

@ -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"
@ -139,19 +139,19 @@ ProxGuiQT::~ProxGuiQT(void) {
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);

View file

@ -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();
}; };

View file

@ -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);
} }

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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.