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.
uint8_t *mem = BigBuf_get_EM_addr();
char *preferredName = (char*)BigBuf_malloc(30);
char *preferredName = (char *)BigBuf_malloc(30);
if (preferredName == NULL) {
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]);
uint16_t preferredNameLen = strlen(preferredName);
char *filename = (char*)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
char *filename = (char *)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
if (filename == NULL) {
goto OUT;
}
@ -146,7 +146,7 @@ void RunMod() {
LED_D_ON();
uint8_t ct;
switch(p_card->tagtype) {
switch (p_card->tagtype) {
case 0x0D:
ct = 0;
break;

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
//-----------------------------------------------------------------------------
legic_card_select_t* getLegicCardInfo(void) {
legic_card_select_t *getLegicCardInfo(void) {
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 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 */

View file

@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) {
WaitUS(32 * 8);
} else {
TurnReadLF_off(23 * 8);
TurnReadLFOn((32-23) * 8);
TurnReadLFOn((32 - 23) * 8);
}
}
}

View file

@ -334,16 +334,16 @@ void MifareDES_Auth1(uint8_t *datain) {
return;
}
int rndlen=8;
int rndlen = 8;
int expectedlen = 1 + 8 + 2 + 2;
if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) {
expectedlen = 1 + 16 + 2 + 2;
rndlen=16;
rndlen = 16;
}
if (payload->mode == MFDES_AUTH_PICC) {
expectedlen = 1 + 1 + 8 + 2;
rndlen=8;
rndlen = 8;
}
if (len != expectedlen) {

View file

@ -15,7 +15,7 @@
// PRIx64 definition missing with gcc-arm-none-eabi v8?
#ifndef PRIx64
#define PRIx64 "llx"
#define PRIx64 "llx"
#endif
// Basic macros

View file

@ -457,7 +457,8 @@ static int CmdFlashMemSpiFFSLoad(const char *Cmd) {
static command_t CommandTable[] = {
{"help", CmdHelp, AlwaysAvailable, "This help"},
{"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
{
"copy", CmdFlashMemSpiFFSCopy, IfPm3Flash,
"Copy a file to another (destructively) in SPIFFS FileSystem in FlashMEM (spiffs)"
},
{"check", CmdFlashMemSpiFFSCheck, IfPm3Flash, "Check/try to defrag faulty/fragmented Filesystem"},

View file

@ -150,7 +150,7 @@ int CmdHFSearch(const char *Cmd) {
res = PM3_SUCCESS;
}
}
/*
/*
// 14b and iclass is the longest test (put last)
PROMPT_CLEARLINE;
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
@ -160,7 +160,7 @@ int CmdHFSearch(const char *Cmd) {
res = PM3_SUCCESS;
}
}
*/
*/
// 14b and iclass is the longest test (put last)
PROMPT_CLEARLINE;

View file

@ -212,7 +212,7 @@ static int CmdHF15Help(const char *Cmd);
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[] = {
{"NXP Mifare Classic MFC1C14_x", "044F6D3F294DEA5737F0F46FFEE88A356EED95695DD7E0C27A591E6F6F65962BAF"},
{"Manufacturer Mifare Classic MFC1C14_x", "046F70AC557F5461CE5052C8E4A7838C11C7A236797E8A0730A101837C004039C2"},
@ -222,7 +222,7 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
{"NXP NTAG21x (2013)", "04494E1A386D3D3CFE3DC10E5DE68A499B1C202DB5B132393E89ED19FE5BE8BC61"},
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
};
/*
/*
uint8_t nxp_15693_public_keys[][PUBLIC_ECDA_KEYLEN] = {
// ICODE SLIX2 / DNA
{
@ -260,12 +260,12 @@ static int nxp_15693_print_signature(uint8_t *uid, uint8_t *signature) {
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
}
};
*/
*/
uint8_t i;
int res;
bool is_valid = false;
for (i = 0; i< ARRAYLEN(nxp_15693_public_keys); i++) {
for (i = 0; i < ARRAYLEN(nxp_15693_public_keys); i++) {
int dl = 0;
uint8_t key[PUBLIC_ECDA_KEYLEN];
@ -589,7 +589,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
return false;
}
memcpy(&req[tmpreqlen], uid, sizeof(uid));
PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, "Detected UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
tmpreqlen += sizeof(uid);
break;
default:
@ -602,7 +602,7 @@ static bool prepareHF15Cmd(char **cmd, uint16_t *reqlen, uint8_t *arg1, uint8_t
uid[7 - i] = temp & 0xff;
}
PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, "Using UID " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
memcpy(&req[tmpreqlen], uid, sizeof(uid));
tmpreqlen += sizeof(uid);
break;
@ -931,7 +931,7 @@ static int CmdHF15Info(const char *Cmd) {
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") "---------");
PrintAndLogEx(INFO, "-------------------------------------------------------------");
PrintAndLogEx(SUCCESS, " TYPE: " _YELLOW_("%s"), getTagInfo_15(recv + 2));
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, " SYSINFO: %s", sprint_hex(recv, status - 2));
// DSFID
@ -1003,7 +1003,7 @@ static int CmdHF15Sim(const char *Cmd) {
return PM3_EINVARG;
}
PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, "Starting simulating UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
clearCommandBuffer();
SendCommandOLD(CMD_HF_ISO15693_SIMULATE, 0, 0, 0, uid, 8);
@ -1201,7 +1201,7 @@ static int CmdHF15Dump(const char *Cmd) {
}
// detect blocksize from card :)
PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, "Reading memory from tag UID " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
int blocknum = 0;
uint8_t *recv = NULL;
@ -1762,7 +1762,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
return PM3_EINVARG;
}
PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL,uid));
PrintAndLogEx(SUCCESS, "Input new UID | " _YELLOW_("%s"), iso15693_sprintUID(NULL, uid));
if (!getUID(oldUid)) {
PrintAndLogEx(FAILED, "Can't get old/current UID.");

View file

@ -414,7 +414,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Uploading to emulator memory");
/*
/*
// fast push mode
conn.block_after_ACK = true;
@ -433,7 +433,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
bytes_remaining -= bytes_in_packet;
bytes_sent += bytes_in_packet;
}
*/
*/
free(data);
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "Done");

View file

@ -580,7 +580,7 @@ static int CmdHFiClassSim(const char *Cmd) {
}
uint8_t num_mac = resp.oldarg[1];
bool success = (NUM_CSNS == num_mac);
PrintAndLogEx( (success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL");
PrintAndLogEx((success) ? SUCCESS : WARNING, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL");
if (num_mac == 0)
break;

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;
}
PrintAndLogEx(SUCCESS, "(De)Obsfuscation done");
@ -241,7 +241,7 @@ static int CmdLegicInfo(const char *Cmd) {
PrintAndLogEx(NORMAL, "------------------------------------------------------");
PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s)",
data[0],
sprint_hex(data +1, 3),
sprint_hex(data + 1, 3),
data[4],
(calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail")
);
@ -1088,7 +1088,7 @@ static int CmdLegicRestore(const char *Cmd) {
return PM3_EFILE;
}
if (shall_obsfuscate){
if (shall_obsfuscate) {
legic_xor(data, card.cardsize);
}

View file

@ -132,15 +132,15 @@ static char *getTypeStr(uint8_t type) {
static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
// DESFire MF3ICD40
if (major == 0x00 && minor == 0x00 )
if (major == 0x00 && minor == 0x00)
return DESFIRE_MF3ICD40;
// DESFire EV1
if (major == 0x01 && minor == 0x00 )
if (major == 0x01 && minor == 0x00)
return DESFIRE_EV1;
// DESFire EV2
if (major == 0x12 && minor == 0x00 )
if (major == 0x12 && minor == 0x00)
return DESFIRE_EV2;
// DESFire EV3
@ -148,11 +148,11 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
// return DESFIRE_EV3;
// DESFire Light
if (major == 0x30 && minor == 0x00 )
if (major == 0x30 && minor == 0x00)
return DESFIRE_LIGHT;
// Plus EV1
if (major == 0x11 && minor == 0x00 )
if (major == 0x11 && minor == 0x00)
return PLUS_EV1;
return MFP_UNKNOWN;
@ -162,7 +162,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
static int plus_print_signature(uint8_t *uid, uint8_t uidlen, uint8_t *signature, int signature_len) {
// ref: MIFARE Plus EV1 Originality Signature Validation
#define PUBLIC_PLUS_ECDA_KEYLEN 57
#define PUBLIC_PLUS_ECDA_KEYLEN 57
const ecdsa_publickey_t nxp_plus_public_keys[] = {
{"Mifare Plus EV1", "044409ADC42F91A8394066BA83D872FB1D16803734E911170412DDF8BAD1A4DADFD0416291AFE1C748253925DA39A5F39A1C557FFACD34C62E"}
};
@ -227,7 +227,7 @@ static int get_plus_signature(uint8_t *signature, int *signature_len) {
static int plus_print_version(uint8_t *version) {
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(version + 14, 7));
PrintAndLogEx(SUCCESS, " Batch number: " _GREEN_("%s"), sprint_hex(version + 21, 5));
PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7+7+7+5], version[7+7+7+5+1]);
PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") "/ " _GREEN_("20%02x"), version[7 + 7 + 7 + 5], version[7 + 7 + 7 + 5 + 1]);
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Hardware Information"));
PrintAndLogEx(INFO, " Vendor Id: " _YELLOW_("%s"), getTagInfo(version[0]));
@ -390,11 +390,11 @@ static int CmdHFMFPInfo(const char *Cmd) {
// How do we detect SL0 / SL1 / SL2 / SL3 modes?!?
PrintAndLogEx(INFO, "--- " _CYAN_("Security Level (SL)"));
if (SLmode != 0xFF )
if (SLmode != 0xFF)
PrintAndLogEx(SUCCESS, " SL mode: " _YELLOW_("SL%d"), SLmode);
else
PrintAndLogEx(WARNING, " SL mode: " _YELLOW_("unknown"));
switch(SLmode) {
switch (SLmode) {
case 0:
PrintAndLogEx(INFO, " SL 0: initial delivery configuration, used for card personalization");
break;

View file

@ -64,7 +64,7 @@ static int usage_hf_mfu_info(void) {
static int usage_hf_mfu_dump(void) {
PrintAndLogEx(NORMAL, "Reads all pages from Ultralight, Ultralight-C, Ultralight EV1");
PrintAndLogEx(NORMAL, "NTAG 203, NTAG 210, NTAG 212, NTAG 213, NTAG 215, NTAG 216");
PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`") );
PrintAndLogEx(NORMAL, "and saves binary dump into the file " _YELLOW_("`filename.bin`") "or " _YELLOW_("`cardUID.bin`"));
PrintAndLogEx(NORMAL, "It autodetects card type.\n");
PrintAndLogEx(NORMAL, "Usage: hf mfu dump k <key> l f <filename w/o .bin> p <page#> q <#pages>");
PrintAndLogEx(NORMAL, " Options :");
@ -89,8 +89,8 @@ static int usage_hf_mfu_restore(void) {
PrintAndLogEx(NORMAL, " Options :");
PrintAndLogEx(NORMAL, " k <key> : (optional) key for authentication [UL-C 16bytes, EV1/NTAG 4bytes]");
PrintAndLogEx(NORMAL, " l : (optional) swap entered key's endianness");
PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-") );
PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-") );
PrintAndLogEx(NORMAL, " s : (optional) enable special write UID " _BLUE_("-MAGIC TAG ONLY-"));
PrintAndLogEx(NORMAL, " e : (optional) enable special write version/signature " _BLUE_("-MAGIC NTAG 21* ONLY-"));
PrintAndLogEx(NORMAL, " r : (optional) use the password found in dumpfile to configure tag. requires " _YELLOW_("'e'") "parameter to work");
PrintAndLogEx(NORMAL, " f <fn> : " _YELLOW_("filename w .bin") "to restore");
PrintAndLogEx(NORMAL, "");
@ -135,7 +135,7 @@ static int usage_hf_mfu_wrbl(void) {
}
static int usage_hf_mfu_eload(void) {
PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`") );
PrintAndLogEx(NORMAL, "It loads emul dump from the file " _YELLOW_("`filename.eml`"));
PrintAndLogEx(NORMAL, "Hint: See " _YELLOW_("`script run dumptoemul-mfu`") "to convert the .bin to the eml");
PrintAndLogEx(NORMAL, "Usage: hf mfu eload u <file name w/o `.eml`> [numblocks]");
PrintAndLogEx(NORMAL, " Options:");
@ -526,7 +526,7 @@ static int ul_print_default(uint8_t *data) {
else
PrintAndLogEx(NORMAL, " BCC1: %02X, crc should be %02X", data[8], crc1);
PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default") );
PrintAndLogEx(SUCCESS, " Internal: %02X ( %s)", data[9], (data[9] == 0x48) ? _GREEN_("default") : _RED_("not default"));
PrintAndLogEx(SUCCESS, " Lock: %s - %s",
sprint_hex(data + 10, 2),
@ -865,7 +865,7 @@ static int ulev1_print_counters() {
static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *signature, size_t signature_len) {
#define PUBLIC_ECDA_KEYLEN 33
#define PUBLIC_ECDA_KEYLEN 33
// known public keys for the originality check (source: https://github.com/alexbatalov/node-nxp-originality-verifier)
// ref: AN11350 NTAG 21x Originality Signature Validation
// ref: AN11341 MIFARE Ultralight EV1 Originality Signature Validation
@ -879,7 +879,7 @@ static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *sig
{"MICRON Public key", "04f971eda742a4a80d32dcf6a814a707cc3dc396d35902f72929fdcd698b3468f2"},
};
/*
/*
uint8_t nxp_mfu_public_keys[6][PUBLIC_ECDA_KEYLEN] = {
// UL, NTAG21x and NDEF
{
@ -924,11 +924,11 @@ static int ulev1_print_signature(TagTypeUL_t tagtype, uint8_t *uid, uint8_t *sig
0x29, 0x29, 0xfd, 0xcd, 0x69, 0x8b, 0x34, 0x68, 0xf2
}
};
*/
*/
uint8_t i;
int res;
bool is_valid = false;
for (i = 0; i< ARRAYLEN(nxp_mfu_public_keys); i++) {
for (i = 0; i < ARRAYLEN(nxp_mfu_public_keys); i++) {
int dl = 0;
uint8_t key[PUBLIC_ECDA_KEYLEN];
@ -2738,7 +2738,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
swapEndian = arg_get_lit(2);
CLIParserFree();
switch(keylen) {
switch (keylen) {
case 0:
break;
case 4:
@ -2789,7 +2789,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
for (uint8_t i = 0; i < ARRAYLEN(UL_TYPES_ARRAY); i++) {
if (tagtype & UL_TYPES_ARRAY[i]) {
if (maxsize != (UL_MEMORY_ARRAY[i] * 4) ) {
if (maxsize != (UL_MEMORY_ARRAY[i] * 4)) {
PrintAndLogEx(INFO, "Tag reported size vs NDEF reported size mismatch. Using smallest value");
}
maxsize = MIN(maxsize, (UL_MEMORY_ARRAY[i] * 4));
@ -2805,7 +2805,7 @@ static int CmdHF14MfuNDEF(const char *Cmd) {
}
// read NDEF records.
for(uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) {
for (uint16_t i = 0, j = 0; i < maxsize; i += 16, j += 4) {
status = ul_read(4 + j, records + i, 16);
if (status == -1) {
DropField();

View file

@ -62,16 +62,17 @@ static int usage_lf_keri_sim(void) {
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
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 };
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
};
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 };
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
};
uint8_t CardIdx; // 0 - 31
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
for (CardIdx = 0; CardIdx < 32; CardIdx++)
{
for (CardIdx = 0; CardIdx < 32; CardIdx++) {
// Card ID
if (CardToID[CardIdx] < 32) {
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
*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;
}
@ -187,16 +186,16 @@ static int CmdKeriDemod(const char *Cmd) {
PrintAndLogEx(SUCCESS, "KERI Tag Found -- Internal ID: %u", ID);
PrintAndLogEx(SUCCESS, "Raw: %08X%08X", raw1, raw2);
/*
/*
Descramble Data.
*/
*/
uint32_t fc = 0;
uint32_t cardid = 0;
// 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) {
PrintAndLogEx(INFO, "Had to Invert - probably KERI");
@ -245,15 +244,15 @@ static int CmdKeriClone(const char *Cmd) {
case 'h': // help
return usage_lf_keri_clone();
case 't': // format type
keritype = tolower(param_getchar(Cmd,cmdidx+1));
keritype = tolower(param_getchar(Cmd, cmdidx + 1));
cmdidx += 2;
break;
case 'f': // fc
fc = param_get32ex(Cmd,cmdidx+1,0,10);
fc = param_get32ex(Cmd, cmdidx + 1, 0, 10);
cmdidx += 2;
break;
case 'c': // cardid
cid = param_get32ex(Cmd,cmdidx+1,0,10);
cid = param_get32ex(Cmd, cmdidx + 1, 0, 10);
cmdidx += 2;
break;
case 'q': // q5
@ -272,7 +271,7 @@ static int CmdKeriClone(const char *Cmd) {
// this is managed in above code
// internalid = param_get32ex(Cmd, 0, 0, 10);
/*
/*
// Q5 is caught in the while loop
//Q5
if (tolower(param_getchar(Cmd, 1)) == 'q') {
@ -282,7 +281,7 @@ static int CmdKeriClone(const char *Cmd) {
T5555_PSK_RF_2 |
2 << T5555_MAXBLOCK_SHIFT;
}
*/
*/
// Setup card data/build internal id
switch (keritype) {
case 'i' : // Internal ID
@ -290,7 +289,7 @@ static int CmdKeriClone(const char *Cmd) {
internalid = cid | 0x80000000;
break;
case 'm' : // MS
CmdKeriMSScramble (Scramble,&fc,&cid,&internalid);
CmdKeriMSScramble(Scramble, &fc, &cid, &internalid);
break;
}

View file

@ -197,7 +197,7 @@ static int CmdHints(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hints();
if (strlen(Cmd) > 1){
if (strlen(Cmd) > 1) {
str_lower((char *)Cmd);
if (str_startswith(Cmd, "of")) {
session.show_hints = false;

View file

@ -427,7 +427,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
}
break;
case jsfSettings:
preferences_save_callback (root);
preferences_save_callback(root);
break;
default:
break;
@ -867,8 +867,8 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
}
*datalen = sptr;
}
if (!strcmp(ctype,"settings")) {
preferences_load_callback (root);
if (!strcmp(ctype, "settings")) {
preferences_load_callback(root);
}
PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
out:

View file

@ -40,18 +40,18 @@ static int setCmdHelp(const char *Cmd);
#define GetCurrentDir getcwd
#endif
static char* prefGetFilename (void) {
static char *prefGetFilename(void) {
char *Path;
if (searchHomeFilePath(&Path,preferencesFilename,false) == PM3_SUCCESS)
if (searchHomeFilePath(&Path, preferencesFilename, false) == PM3_SUCCESS)
return Path;
else
return preferencesFilename;
}
int preferences_load (void) {
int preferences_load(void) {
PrintAndLogEx(INFO,"Looking for preferences...");
PrintAndLogEx(INFO, "Looking for preferences...");
// Set all defaults
session.client_debug_level = OFF;
@ -61,7 +61,7 @@ int preferences_load (void) {
session.window_plot_hsize = 400;
session.window_plot_wsize = 800;
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_wsize = session.window_plot_wsize;
session.emoji_mode = ALIAS;
@ -84,24 +84,24 @@ int preferences_load (void) {
}
// Save all settings from memory (struct) to file
int preferences_save (void) {
int preferences_save(void) {
// 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 ...");
snprintf (backupFilename,sizeof(backupFilename)-1,"%s.bak",prefGetFilename());
PrintAndLogEx(INFO, "Saving preferences ...");
snprintf(backupFilename, sizeof(backupFilename) - 1, "%s.bak", prefGetFilename());
if (fileExists (backupFilename)) {
if (remove (backupFilename) != 0) {
PrintAndLogEx (FAILED, "Error - could not delete old settings backup file \"%s\"",backupFilename);
if (fileExists(backupFilename)) {
if (remove(backupFilename) != 0) {
PrintAndLogEx(FAILED, "Error - could not delete old settings backup file \"%s\"", backupFilename);
return PM3_ESOFT;
}
}
if (fileExists (prefGetFilename())) {
if (rename (prefGetFilename(),backupFilename) != 0) {
PrintAndLogEx (FAILED, "Error - could not backup settings file \"%s\" to \"%s\"",prefGetFilename(),backupFilename);
if (fileExists(prefGetFilename())) {
if (rename(prefGetFilename(), backupFilename) != 0) {
PrintAndLogEx(FAILED, "Error - could not backup settings file \"%s\" to \"%s\"", prefGetFilename(), backupFilename);
return PM3_ESOFT;
}
}
@ -110,52 +110,66 @@ int preferences_save (void) {
size_t dummyDL = 0x00;
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;
}
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
switch (session.client_debug_level) {
case OFF: JsonSaveStr (root,"client.debug.level","off"); break;
case SIMPLE: JsonSaveStr (root,"client.debug.level","simple"); break;
case FULL: JsonSaveStr (root,"client.debug.level","full"); break;
case OFF:
JsonSaveStr(root, "client.debug.level", "off");
break;
case SIMPLE:
JsonSaveStr(root, "client.debug.level", "simple");
break;
case FULL:
JsonSaveStr(root, "client.debug.level", "full");
break;
default:
JsonSaveStr (root,"logging.level","NORMAL");
JsonSaveStr(root, "logging.level", "NORMAL");
}
// Plot window
JsonSaveInt (root,"window.plot.xpos",session.window_plot_xpos);
JsonSaveInt (root,"window.plot.ypos",session.window_plot_ypos);
JsonSaveInt (root,"window.plot.hsize",session.window_plot_hsize);
JsonSaveInt (root,"window.plot.wsize",session.window_plot_wsize);
JsonSaveInt(root, "window.plot.xpos", session.window_plot_xpos);
JsonSaveInt(root, "window.plot.ypos", session.window_plot_ypos);
JsonSaveInt(root, "window.plot.hsize", session.window_plot_hsize);
JsonSaveInt(root, "window.plot.wsize", session.window_plot_wsize);
// Overlay/Slider window
JsonSaveInt (root,"window.overlay.xpos",session.window_overlay_xpos);
JsonSaveInt (root,"window.overlay.ypos",session.window_overlay_ypos);
JsonSaveInt (root,"window.overlay.hsize",session.window_overlay_hsize);
JsonSaveInt (root,"window.overlay.wsize",session.window_overlay_wsize);
JsonSaveInt(root, "window.overlay.xpos", session.window_overlay_xpos);
JsonSaveInt(root, "window.overlay.ypos", session.window_overlay_ypos);
JsonSaveInt(root, "window.overlay.hsize", session.window_overlay_hsize);
JsonSaveInt(root, "window.overlay.wsize", session.window_overlay_wsize);
// Emoji
switch (session.emoji_mode) {
case ALIAS: JsonSaveStr (root,"show.emoji","alias"); 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;
case ALIAS:
JsonSaveStr(root, "show.emoji", "alias");
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:
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};
bool b1;
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 *
// Logging Level
if (json_unpack_ex(root,&up_error, 0, "{s:s}","client.debug.level",&s1) == 0) {
strncpy (tempStr,s1,sizeof(tempStr)-1);
str_lower (tempStr);
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,"full",4) == 0) session.client_debug_level = FULL;
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "client.debug.level", &s1) == 0) {
strncpy(tempStr, s1, sizeof(tempStr) - 1);
str_lower(tempStr);
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, "full", 4) == 0) session.client_debug_level = FULL;
}
// 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;
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;
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;
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;
// 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;
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;
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;
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;
// show options
if (json_unpack_ex(root,&up_error, 0, "{s:s}","show.emoji",&s1) == 0) {
strncpy (tempStr,s1,sizeof(tempStr)-1);
str_lower (tempStr);
if (strncmp (tempStr,"alias",5) == 0) session.emoji_mode = ALIAS;
if (strncmp (tempStr,"emoji",5) == 0) session.emoji_mode = EMOJI;
if (strncmp (tempStr,"alttext",7) == 0) session.emoji_mode = ALTTEXT;
if (strncmp (tempStr,"erase",5) == 0) session.emoji_mode = ERASE;
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.emoji", &s1) == 0) {
strncpy(tempStr, s1, sizeof(tempStr) - 1);
str_lower(tempStr);
if (strncmp(tempStr, "alias", 5) == 0) session.emoji_mode = ALIAS;
if (strncmp(tempStr, "emoji", 5) == 0) session.emoji_mode = EMOJI;
if (strncmp(tempStr, "alttext", 7) == 0) session.emoji_mode = ALTTEXT;
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;
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;
}
@ -254,76 +268,85 @@ static int usage_set_hints() {
}
// Preference Processing Functions
typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t;
typedef enum prefShowOpt {prefShowNone,prefShowOLD,prefShowNEW} prefShowOpt_t;
typedef enum preferenceId {prefNONE, prefHELP, prefEMOJI, prefCOLOR, prefPLOT, prefOVERLAY, prefHINTS, prefCLIENTDEBUG} preferenceId_t;
typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t;
const char *prefShowMsg (prefShowOpt_t Opt)
{
const char *prefShowMsg(prefShowOpt_t Opt) {
switch (Opt) {
case prefShowOLD: return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break;
case prefShowNEW: return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break;
case prefShowNone: return "";
case prefShowOLD:
return _YELLOW_("[old]"); //strncpy(Msg,"Before ",sizeof(Msg)-1); break;
case prefShowNEW:
return _GREEN_("[new]"); // strncpy(Msg,"After ",sizeof(Msg)-1); break;
case prefShowNone:
return "";
}
return "";
}
void showEmojiState (prefShowOpt_t Opt) {
void showEmojiState(prefShowOpt_t Opt) {
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;
case EMOJI: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"),prefShowMsg (Opt));
case EMOJI:
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"), prefShowMsg(Opt));
break;
case ALTTEXT: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"),prefShowMsg (Opt));
case ALTTEXT:
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"), prefShowMsg(Opt));
break;
case ERASE: PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"),prefShowMsg (Opt));
case ERASE:
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"), prefShowMsg(Opt));
break;
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)
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"),prefShowMsg(Opt));
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"), prefShowMsg(Opt));
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) {
case OFF: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("off"),prefShowMsg(Opt));
case OFF:
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("off"), prefShowMsg(Opt));
break;
case SIMPLE: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("simple"),prefShowMsg(Opt));
case SIMPLE:
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("simple"), prefShowMsg(Opt));
break;
case FULL: PrintAndLogEx (NORMAL," %s client debug........... "_GREEN_("full"),prefShowMsg(Opt));
case FULL:
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("full"), prefShowMsg(Opt));
break;
default:
PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"),prefShowMsg(Opt));
PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"), prefShowMsg(Opt));
}
}
void showPlotPosState (void){
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);
void showPlotPosState(void) {
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);
}
void showOverlayPosState (void){
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);
void showOverlayPosState(void) {
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);
}
void showHintsState (prefShowOpt_t Opt){
void showHintsState(prefShowOpt_t Opt) {
if (session.show_hints)
PrintAndLogEx (NORMAL," %s Hints.................. "_GREEN_("on"),prefShowMsg(Opt));
PrintAndLogEx(NORMAL, " %s Hints.................. "_GREEN_("on"), prefShowMsg(Opt));
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;
bool errors = false;
bool validValue = false;
@ -338,37 +361,37 @@ static int setCmdEmoji (const char *Cmd) {
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
str_lower(strOpt); // convert to lowercase
if (strncmp (strOpt,"help",4) == 0)
if (strncmp(strOpt, "help", 4) == 0)
return usage_set_emoji();
if (strncmp (strOpt,"alias",5) == 0) {
if (strncmp(strOpt, "alias", 5) == 0) {
validValue = true;
newValue = ALIAS;
}
if (strncmp (strOpt,"emoji",5) == 0) {
if (strncmp(strOpt, "emoji", 5) == 0) {
validValue = true;
newValue = EMOJI;
}
if (strncmp (strOpt,"alttext",7) == 0) {
if (strncmp(strOpt, "alttext", 7) == 0) {
validValue = true;
newValue = ALTTEXT;
}
if (strncmp (strOpt,"erase",5) == 0) {
if (strncmp(strOpt, "erase", 5) == 0) {
validValue = true;
newValue = ERASE;
}
if (validValue) {
if (session.emoji_mode != newValue) {// changed
showEmojiState (prefShowOLD);
showEmojiState(prefShowOLD);
session.emoji_mode = newValue;
showEmojiState (prefShowNEW);
preferences_save ();
showEmojiState(prefShowNEW);
preferences_save();
} else {
PrintAndLogEx(INFO,"nothing changed");
showEmojiState (prefShowNone);
PrintAndLogEx(INFO, "nothing changed");
showEmojiState(prefShowNone);
}
} else {
PrintAndLogEx(ERR,"invalid option");
PrintAndLogEx(ERR, "invalid option");
return usage_set_emoji();
}
}
@ -377,8 +400,7 @@ static int setCmdEmoji (const char *Cmd) {
return PM3_SUCCESS;
}
static int setCmdColor (const char *Cmd)
{
static int setCmdColor(const char *Cmd) {
uint8_t cmdp = 0;
bool errors = false;
bool validValue = false;
@ -393,29 +415,29 @@ static int setCmdColor (const char *Cmd)
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
str_lower(strOpt); // convert to lowercase
if (strncmp (strOpt,"help",4) == 0)
if (strncmp(strOpt, "help", 4) == 0)
return usage_set_color();
if (strncmp (strOpt,"off",3) == 0) {
if (strncmp(strOpt, "off", 3) == 0) {
validValue = true;
newValue = false;
}
if (strncmp (strOpt,"ansi",4) == 0) {
if (strncmp(strOpt, "ansi", 4) == 0) {
validValue = true;
newValue = true;
}
if (validValue) {
if (session.supports_colors != newValue) {// changed
showColorState (prefShowOLD);
showColorState(prefShowOLD);
session.supports_colors = newValue;
showColorState (prefShowNEW);
preferences_save ();
showColorState(prefShowNEW);
preferences_save();
} else {
PrintAndLogEx(INFO,"nothing changed");
showColorState (prefShowNone);
PrintAndLogEx(INFO, "nothing changed");
showColorState(prefShowNone);
}
} else {
PrintAndLogEx(ERR,"invalid option");
PrintAndLogEx(ERR, "invalid option");
return usage_set_color();
}
}
@ -424,8 +446,7 @@ static int setCmdColor (const char *Cmd)
return PM3_SUCCESS;
}
static int setCmdDebug (const char *Cmd)
{
static int setCmdDebug(const char *Cmd) {
uint8_t cmdp = 0;
bool errors = false;
bool validValue = false;
@ -440,34 +461,34 @@ static int setCmdDebug (const char *Cmd)
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
str_lower(strOpt); // convert to lowercase
if (strncmp (strOpt,"help",4) == 0)
if (strncmp(strOpt, "help", 4) == 0)
return usage_set_debug();
if (strncmp (strOpt,"off",3) == 0) {
if (strncmp(strOpt, "off", 3) == 0) {
validValue = true;
newValue = OFF;
}
if (strncmp (strOpt,"simple",6) == 0) {
if (strncmp(strOpt, "simple", 6) == 0) {
validValue = true;
newValue = SIMPLE;
}
if (strncmp (strOpt,"full",4) == 0) {
if (strncmp(strOpt, "full", 4) == 0) {
validValue = true;
newValue = FULL;
}
if (validValue) {
if (session.client_debug_level != newValue) {// changed
showClientDebugState (prefShowOLD);
showClientDebugState(prefShowOLD);
session.client_debug_level = newValue;
g_debugMode = newValue;
showClientDebugState (prefShowNEW);
preferences_save ();
showClientDebugState(prefShowNEW);
preferences_save();
} else {
PrintAndLogEx(INFO,"nothing changed");
showClientDebugState (prefShowNone);
PrintAndLogEx(INFO, "nothing changed");
showClientDebugState(prefShowNone);
}
} else {
PrintAndLogEx(ERR,"invalid option");
PrintAndLogEx(ERR, "invalid option");
return usage_set_debug();
}
}
@ -476,8 +497,7 @@ static int setCmdDebug (const char *Cmd)
return PM3_SUCCESS;
}
static int setCmdHint (const char *Cmd)
{
static int setCmdHint(const char *Cmd) {
uint8_t cmdp = 0;
bool errors = false;
bool validValue = false;
@ -492,29 +512,29 @@ static int setCmdHint (const char *Cmd)
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
str_lower(strOpt); // convert to lowercase
if (strncmp (strOpt,"help",4) == 0)
if (strncmp(strOpt, "help", 4) == 0)
return usage_set_hints();
if (strncmp (strOpt,"off",3) == 0) {
if (strncmp(strOpt, "off", 3) == 0) {
validValue = true;
newValue = false;
}
if (strncmp (strOpt,"on",2) == 0) {
if (strncmp(strOpt, "on", 2) == 0) {
validValue = true;
newValue = true;
}
if (validValue) {
if (session.show_hints != newValue) {// changed
showHintsState (prefShowOLD);
showHintsState(prefShowOLD);
session.show_hints = newValue;
showHintsState (prefShowNEW);
preferences_save ();
showHintsState(prefShowNEW);
preferences_save();
} else {
PrintAndLogEx(INFO,"nothing changed");
showHintsState (prefShowNone);
PrintAndLogEx(INFO, "nothing changed");
showHintsState(prefShowNone);
}
} else {
PrintAndLogEx(ERR,"invalid option");
PrintAndLogEx(ERR, "invalid option");
return usage_set_hints();
}
}
@ -540,32 +560,31 @@ static int setCmdHelp(const char *Cmd) {
return PM3_SUCCESS;
}
int CmdPrefSet (const char *Cmd)
{
int CmdPrefSet(const char *Cmd) {
clearCommandBuffer();
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) {
PrintAndLogEx (ERR,"Preferneces not loaded");
PrintAndLogEx(ERR, "Preferneces not loaded");
return PM3_ESOFT;
}
PrintAndLogEx(NORMAL," preference file........ "_GREEN_("%s"),prefGetFilename());
showEmojiState (prefShowNone);
showColorState (prefShowNone);
PrintAndLogEx(NORMAL, " preference file........ "_GREEN_("%s"), prefGetFilename());
showEmojiState(prefShowNone);
showColorState(prefShowNone);
// showPlotPosState ();
// showOverlayPosState ();
showClientDebugState(prefShowNone);
showHintsState (prefShowNone);
showHintsState(prefShowNone);
PrintAndLogEx(NORMAL,"");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}
@ -591,8 +610,7 @@ static int CmdHelp(const char *Cmd) {
return PM3_SUCCESS;
}
int CmdPreferences (const char *Cmd)
{
int CmdPreferences(const char *Cmd) {
clearCommandBuffer();
return CmdsParse(CommandTable, Cmd);

View file

@ -13,11 +13,11 @@
// Current working directory will be prepended.
#define preferencesFilename "preferences.json"
int CmdPreferences (const char *Cmd);
int preferences_load (void);
int preferences_save (void);
int CmdPreferences(const char *Cmd);
int preferences_load(void);
int preferences_save(void);
void preferences_save_callback (json_t *root);
void preferences_load_callback (json_t *root);
void preferences_save_callback(json_t *root);
void preferences_load_callback(json_t *root);
#endif

View file

@ -28,7 +28,7 @@
#include <QtGui>
#include "ui.h"
extern "C" int preferences_save (void);
extern "C" int preferences_save(void);
extern "C" {
#include "util_darwin.h"
@ -139,19 +139,19 @@ ProxGuiQT::~ProxGuiQT(void) {
SliderWidget::SliderWidget() {
// Set the initail postion and size from settings
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
resize(800, 400);
}
void SliderWidget::resizeEvent (QResizeEvent *event) {
void SliderWidget::resizeEvent(QResizeEvent *event) {
session.window_overlay_hsize = event->size().height();
session.window_overlay_wsize = event->size().width();
session.window_changed = true;
}
void SliderWidget::moveEvent (QMoveEvent *event) {
void SliderWidget::moveEvent(QMoveEvent *event) {
session.window_overlay_xpos = event->pos().x();
session.window_overlay_ypos = event->pos().y();
session.window_changed = true;
@ -199,12 +199,12 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
this->master = master;
// Set the initail postion and size from settings
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
resize(800, 400);
// Setup the controller widget
controlWidget = new SliderWidget ();//new QWidget();
controlWidget = new SliderWidget(); //new QWidget();
opsController = new Ui::Form();
opsController->setupUi(controlWidget);
//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_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
plot = new Plot(this);
@ -240,7 +240,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
show();
// Set Slider/Overlay position if no settings.
if (!session.preferences_loaded){
if (!session.preferences_loaded) {
// Move controller widget below plot
controlWidget->move(x(), y() + frameSize().height());
controlWidget->resize(size().width(), 200);

View file

@ -58,10 +58,10 @@ class ProxGuiQT;
// Added class for SliderWidget to allow move/resize event override
class SliderWidget : public QWidget {
protected:
void resizeEvent (QResizeEvent *event);
void moveEvent (QMoveEvent *event);
public:
protected:
void resizeEvent(QResizeEvent *event);
void moveEvent(QMoveEvent *event);
public:
SliderWidget();
};

View file

@ -42,33 +42,33 @@
#ifdef _WIN32
static void utf8_showBanner (void) {
static void utf8_showBanner(void) {
char sq[] = { 0xE2,0x96,0x88,0x00 }; // square block
char tr[] = { 0xE2,0x95,0x97,0x00 }; // top rigth corner
char tl[] = { 0xE2,0x95,0x94,0x00 }; // top left corner
char br[] = { 0xE2,0x95,0x9D,0x00 }; // bottom right corner
char bl[] = { 0xE2,0x95,0x9A,0x00 }; // bottom left corner
char hl[] = { 0xE2,0x95,0x90,0x00 }; // horiz line
char vl[] = { 0xE2,0x95,0x91,0x00 }; // vert line
char sq[] = { 0xE2, 0x96, 0x88, 0x00 }; // square block
char tr[] = { 0xE2, 0x95, 0x97, 0x00 }; // top rigth corner
char tl[] = { 0xE2, 0x95, 0x94, 0x00 }; // top left corner
char br[] = { 0xE2, 0x95, 0x9D, 0x00 }; // bottom right corner
char bl[] = { 0xE2, 0x95, 0x9A, 0x00 }; // bottom left corner
char hl[] = { 0xE2, 0x95, 0x90, 0x00 }; // horiz line
char vl[] = { 0xE2, 0x95, 0x91, 0x00 }; // vert line
char msg1 [60];
char msg2 [60];
char msg3 [60];
strcpy (msg1," :snowflake: iceman@icesql.net :coffee:");
strcpy (msg2," https://github.com/rfidresearchgroup/proxmark3/");
strcpy (msg3,"pre-release v4.0");
strcpy(msg1, " :snowflake: iceman@icesql.net :coffee:");
strcpy(msg2, " https://github.com/rfidresearchgroup/proxmark3/");
strcpy(msg3, "pre-release v4.0");
g_printAndLog = PRINTANDLOG_PRINT;
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%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",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",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 %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%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", 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, "");
fflush(stdout);
@ -82,7 +82,7 @@ static void showBanner(void) {
#ifdef _WIN32
// If on windows and using UTF-8 then we need utf-8 ascii art for banner.
if (GetConsoleCP() == 65001) {
utf8_showBanner ();
utf8_showBanner();
return;
}
#endif
@ -409,7 +409,7 @@ static void set_my_user_directory(void) {
// if not found, default to current directory
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...
for (int i = 0; i < strlen(_cwd_Buffer); i++)
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
@ -654,7 +654,7 @@ int main(int argc, char *argv[]) {
#ifdef USE_PREFERENCE_FILE
// Load Settings and assign
// This will allow the command line to override the settings.json values
preferences_load ();
preferences_load();
// Change height/width (Rows,Cols) - Testing
// printf ("\e[8;50;100t");
// printf ("\e[3;50;50t"); // x,y
@ -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
// e.g. Linux color use check
if (!session.preferences_loaded) {
preferences_save (); // Save defaults
preferences_save(); // Save defaults
session.preferences_loaded = true;
}
#endif
@ -964,7 +964,7 @@ int main(int argc, char *argv[]) {
#ifdef USE_PREFERENCE_FILE
if (session.window_changed) // Plot/Overlay moved or resized
preferences_save ();
preferences_save();
#endif
exit(EXIT_SUCCESS);
}

View file

@ -143,7 +143,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
FILE *stream = stdout;
const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")};
const char *spinner_emoji[] = {" :clock1: ", " :clock2: ", " :clock3: ", " :clock4: ", " :clock5: ", " :clock6: ",
" :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "};
" :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "
};
switch (level) {
case ERR:
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;
uint8_t emojified_token_length = 0;
char *current_token = NULL;
uint8_t current_token_length=0;
uint8_t current_token_length = 0;
char current_char;
char *rdest = (char *)dest;
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 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 {
bool preferences_loaded;

View file

@ -272,7 +272,7 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
char *begin;
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;
while (p >= begin) { // scan backwards

View file

@ -34,7 +34,7 @@
// XYZ 3D printing
// Vinglock
//------------------------------------
void transform_D(uint8_t* ru) {
void transform_D(uint8_t *ru) {
const uint32_t c_D[] = {
0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8,
@ -49,8 +49,7 @@ void transform_D(uint8_t* ru) {
uint8_t p = 0;
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++];
for (i = 0; i < 12; i += 2)
{
for (i = 0; i < 12; i += 2) {
uint32_t tempA = v1 ^ v2;
uint32_t t1 = PM3_ROTL(tempA, v2 & 0x1F) + c_D[p++];
uint32_t tempB = v2 ^ t1;