mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Merge branch 'master' into dav-tmp
solved merge conflict
This commit is contained in:
+10
-7
@@ -1276,8 +1276,7 @@ int PSKDemod(const char *Cmd, bool verbose) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdIdteckDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
int demodIdteck(void) {
|
||||
|
||||
if (PSKDemod("", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
@@ -1337,10 +1336,12 @@ static int CmdIdteckDemod(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int demodIdteck(void) {
|
||||
return CmdIdteckDemod("");
|
||||
/*
|
||||
static int CmdIdteckDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodIdteck();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// by marshmellow
|
||||
// takes 3 arguments - clock, invert, maxErr as integers
|
||||
@@ -1710,6 +1711,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------- " _CYAN_("LF Antenna") " ----------");
|
||||
// in mVolt
|
||||
struct p {
|
||||
uint32_t v_lf134;
|
||||
@@ -1746,8 +1748,9 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
else
|
||||
sprintf(judgement, _GREEN_("OK"));
|
||||
|
||||
PrintAndLogEx((package->peak_v < LF_UNUSABLE_V) ? WARNING : SUCCESS, "LF antenna is %s \n", judgement);
|
||||
PrintAndLogEx((package->peak_v < LF_UNUSABLE_V) ? WARNING : SUCCESS, "LF antenna is %s", judgement);
|
||||
|
||||
PrintAndLogEx(INFO, "---------- " _CYAN_("HF Antenna") " ----------");
|
||||
// HF evaluation
|
||||
if (package->v_hf > NON_VOLTAGE)
|
||||
PrintAndLogEx(SUCCESS, "HF antenna: %5.2f V - 13.56 MHz", (package->v_hf * ANTENNA_ERROR) / 1000.0);
|
||||
@@ -1761,7 +1764,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
else
|
||||
sprintf(judgement, _GREEN_("OK"));
|
||||
|
||||
PrintAndLogEx((package->v_hf < HF_UNUSABLE_V) ? WARNING : SUCCESS, "HF antenna is %s \n", judgement);
|
||||
PrintAndLogEx((package->v_hf < HF_UNUSABLE_V) ? WARNING : SUCCESS, "HF antenna is %s", judgement);
|
||||
|
||||
// graph LF measurements
|
||||
// even here, these values has 3% error.
|
||||
|
||||
+19
-11
@@ -1693,7 +1693,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint8_t trgkey[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint8_t cmdp = 0;
|
||||
char filename[FILE_PATH_SIZE] = {0}, *fptr;
|
||||
char filename[FILE_PATH_SIZE] = {0};
|
||||
char szTemp[FILE_PATH_SIZE - 20];
|
||||
char ctmp;
|
||||
|
||||
@@ -1706,19 +1706,21 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_hf14_hardnested();
|
||||
case 'r':
|
||||
fptr = GenerateFilename("hf-mf-", "-nonces.bin");
|
||||
case 'r': {
|
||||
char *fptr = GenerateFilename("hf-mf-", "-nonces.bin");
|
||||
if (fptr == NULL)
|
||||
strncpy(filename, "nonces.bin", FILE_PATH_SIZE - 1);
|
||||
else
|
||||
strncpy(filename, fptr, FILE_PATH_SIZE - 1);
|
||||
|
||||
free(fptr);
|
||||
nonce_file_read = true;
|
||||
if (!param_gethex(Cmd, cmdp + 1, trgkey, 12)) {
|
||||
know_target_key = true;
|
||||
}
|
||||
cmdp++;
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
tests = param_get32ex(Cmd, cmdp + 1, 100, 10);
|
||||
if (!param_gethex(Cmd, cmdp + 2, trgkey, 12)) {
|
||||
@@ -1729,9 +1731,9 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
default:
|
||||
if (param_getchar(Cmd, cmdp) == 0x00) {
|
||||
PrintAndLogEx(WARNING, "Block number is missing");
|
||||
return 1;
|
||||
|
||||
return usage_hf14_hardnested();
|
||||
}
|
||||
|
||||
blockNo = param_get8(Cmd, cmdp);
|
||||
ctmp = tolower(param_getchar(Cmd, cmdp + 1));
|
||||
if (ctmp != 'a' && ctmp != 'b') {
|
||||
@@ -1775,13 +1777,15 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
case 's':
|
||||
slow = true;
|
||||
break;
|
||||
case 'w':
|
||||
case 'w': {
|
||||
nonce_file_write = true;
|
||||
fptr = GenerateFilename("hf-mf-", "-nonces.bin");
|
||||
char *fptr = GenerateFilename("hf-mf-", "-nonces.bin");
|
||||
if (fptr == NULL)
|
||||
return 1;
|
||||
strncpy(filename, fptr, FILE_PATH_SIZE - 1);
|
||||
free(fptr);
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
param_getstr(Cmd, cmdp + 1, szTemp, FILE_PATH_SIZE - 20);
|
||||
snprintf(filename, FILE_PATH_SIZE, "hf-mf-%s-nonces.bin", szTemp);
|
||||
@@ -1837,7 +1841,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
// check if tag doesn't have static nonce
|
||||
if (detect_classic_static_nonce() == 1) {
|
||||
PrintAndLogEx(WARNING, "Static nonce detected. Quitting...");
|
||||
PrintAndLogEx(INFO, "\t Try use `" _YELLOW_("hf mf staticnested") "`");
|
||||
PrintAndLogEx(HINT, "\tTry use `" _YELLOW_("hf mf staticnested") "`");
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
|
||||
@@ -1849,11 +1853,13 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "--target block no:%3d, target key type:%c, known target key: 0x%02x%02x%02x%02x%02x%02x%s, file action: %s, Slow: %s, Tests: %d ",
|
||||
PrintAndLogEx(INFO, "Target block no:%3d, target key type:%c, known target key: 0x%02x%02x%02x%02x%02x%02x%s",
|
||||
trgBlockNo,
|
||||
trgKeyType ? 'B' : 'A',
|
||||
trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5],
|
||||
know_target_key ? "" : " (not set)",
|
||||
know_target_key ? "" : " (not set)"
|
||||
);
|
||||
PrintAndLogEx(INFO , "File action: %s, Slow: %s, Tests: %d ",
|
||||
nonce_file_write ? "write" : nonce_file_read ? "read" : "none",
|
||||
slow ? "Yes" : "No",
|
||||
tests);
|
||||
@@ -1861,7 +1867,9 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||
uint64_t foundkey = 0;
|
||||
int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key ? trgkey : NULL, nonce_file_read, nonce_file_write, slow, tests, &foundkey, filename);
|
||||
|
||||
if (tests == 0) DropField();
|
||||
if (tests == 0)
|
||||
DropField();
|
||||
|
||||
if (isOK) {
|
||||
switch (isOK) {
|
||||
case 1 :
|
||||
|
||||
+178
-86
File diff suppressed because it is too large
Load Diff
@@ -1429,9 +1429,9 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf mfp ndef",
|
||||
"Prints NFC Data Exchange Format (NDEF)",
|
||||
"Usage:\n"
|
||||
"\thf mfp ndef -> shows NDEF data\n"
|
||||
"\thf mfp ndef -vv -> shows NDEF parsed and raw data\n"
|
||||
"\thf mfp ndef -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> shows NDEF data with custom AID and key\n");
|
||||
_YELLOW_("\thf mfp ndef") " -> shows NDEF data\n"
|
||||
_YELLOW_("\thf mfp ndef -vv") " -> shows NDEF parsed and raw data\n"
|
||||
_YELLOW_("\thf mfp ndef -a e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7") " -> shows NDEF data with custom AID and key\n");
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -1530,12 +1530,12 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
||||
|
||||
if (verbose2) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("MFC NDEF raw") " ----------------");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("MF Plus NDEF raw") " ----------------");
|
||||
dump_buffer(data, datalen, stdout, 1);
|
||||
}
|
||||
|
||||
NDEFDecodeAndPrint(data, datalen, verbose);
|
||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -vv`") " for more details");
|
||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndef -vv`") " for more details");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -624,8 +624,8 @@ static int CmdEM410xWrite(const char *Cmd) {
|
||||
|
||||
// Allowed clock rates: 16, 32, 40 and 64
|
||||
if ((clock1 != 16) && (clock1 != 32) && (clock1 != 64) && (clock1 != 40)) {
|
||||
PrintAndLogEx(ERR, "error, clock rate" _RED_("%d")" not valid");
|
||||
PrintAndLogEx(INFO, "supported clock rates: " _YELLOW_("16, 32, 40, 60") "\n", clock1);
|
||||
PrintAndLogEx(FAILED, "error, clock rate" _RED_("%d")" not valid", clock1);
|
||||
PrintAndLogEx(INFO, "supported clock rates: " _YELLOW_("16, 32, 40, 60") "\n");
|
||||
usage_lf_em410x_write();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ static void print_result(const em4x50_word_t *words, int fwr, int lwr, bool verb
|
||||
}
|
||||
}
|
||||
|
||||
static void print_info_result(PacketResponseNG *resp, const em4x50_data_t *etd, bool bverbose) {
|
||||
static void print_info_result(PacketResponseNG *resp, const em4x50_data_t *etd, bool verbose) {
|
||||
|
||||
// display all information of info result in structured format
|
||||
|
||||
@@ -265,7 +265,7 @@ static void print_info_result(PacketResponseNG *resp, const em4x50_data_t *etd,
|
||||
// data section
|
||||
PrintAndLogEx(NORMAL, _YELLOW_("\n em4x50 data:"));
|
||||
|
||||
if (bverbose) {
|
||||
if (verbose) {
|
||||
|
||||
// detailed data section
|
||||
print_result(words, 0, EM4X50_NO_WORDS - 1, true);
|
||||
@@ -459,7 +459,7 @@ static void print_write_result(PacketResponseNG *resp, const em4x50_data_t *etd)
|
||||
bool login = resp->status & STATUS_LOGIN;
|
||||
uint8_t *data = resp->data.asBytes;
|
||||
char string[NO_CHARS_MAX] = {0}, pstring[NO_CHARS_MAX] = {0};
|
||||
em4x50_word_t word;
|
||||
em4x50_word_t words[EM4X50_NO_WORDS];
|
||||
|
||||
prepare_result(data, etd->address, etd->address, &word);
|
||||
print_result(&word, etd->address, etd->address, true);
|
||||
@@ -654,7 +654,7 @@ static void print_read_result(PacketResponseNG *resp, const em4x50_data_t *etd,
|
||||
int now = (resp->status & STATUS_NO_WORDS) >> 2;
|
||||
char string[NO_CHARS_MAX] = {0}, pstring[NO_CHARS_MAX] = {0};
|
||||
uint8_t *data = resp->data.asBytes;
|
||||
em4x50_word_t word;
|
||||
em4x50_word_t words[EM4X50_NO_WORDS];
|
||||
|
||||
if (addr_given) {
|
||||
|
||||
@@ -666,7 +666,7 @@ static void print_read_result(PacketResponseNG *resp, const em4x50_data_t *etd,
|
||||
string[0] = '\0';
|
||||
sprintf(pstring, "\n reading " _GREEN_("ok "));
|
||||
strcat(string, pstring);
|
||||
|
||||
|
||||
if (pwd_given) {
|
||||
if (login) {
|
||||
sprintf(pstring, "(login with password 0x%02x%02x%02x%02x)",
|
||||
|
||||
@@ -169,7 +169,7 @@ static int CmdIOProxDemod(const char *Cmd) {
|
||||
calccrc &= 0xff;
|
||||
calccrc = 0xff - calccrc;
|
||||
|
||||
char crc_str[30] = {0};
|
||||
char crc_str[36] = {0};
|
||||
|
||||
if (crc == calccrc) {
|
||||
snprintf(crc_str, sizeof(crc_str), "(" _GREEN_("ok") ")" );
|
||||
|
||||
@@ -119,8 +119,8 @@ int demodMotorola(void) {
|
||||
checksum |= DemodBuffer[63] << 0; // b1
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Motorola - len: " _GREEN_("26") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u") ", Raw: %08X%08X", fc, csn, raw1, raw2);
|
||||
PrintAndLogEx(DEBUG, "checksum: " _GREEN_("%1d%1d"), fc, csn, checksum >> 1 & 0x01, checksum & 0x01);
|
||||
PrintAndLogEx(SUCCESS, "Motorola - fmt: " _GREEN_("26") " FC: " _GREEN_("%u") " Card: " _GREEN_("%u") ", Raw: %08X%08X", fc, csn, raw1, raw2);
|
||||
PrintAndLogEx(DEBUG, "checksum: " _GREEN_("%1d%1d"), checksum >> 1 & 0x01, checksum & 0x01);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||
return data;
|
||||
|
||||
switch (communication_settings & MDCM_MASK) {
|
||||
case MDCM_PLAIN:
|
||||
case MDCM_PLAIN: {
|
||||
if (AS_LEGACY == DESFIRE(tag)->authentication_scheme)
|
||||
break;
|
||||
|
||||
@@ -404,9 +404,9 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||
*/
|
||||
|
||||
append_mac = false;
|
||||
|
||||
}
|
||||
/* pass through */
|
||||
case MDCM_MACED:
|
||||
case MDCM_MACED: {
|
||||
communication_settings |= NO_CRC;
|
||||
|
||||
switch (DESFIRE(tag)->authentication_scheme) {
|
||||
@@ -455,7 +455,8 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||
}
|
||||
|
||||
break;
|
||||
case MDCM_ENCIPHERED:
|
||||
}
|
||||
case MDCM_ENCIPHERED: {
|
||||
/* |<-------------- data -------------->|
|
||||
* |<--- offset -->| |
|
||||
* +---------------+--------------------+-----+---------+
|
||||
@@ -473,21 +474,25 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||
|
||||
if (!(communication_settings & ENC_COMMAND))
|
||||
break;
|
||||
|
||||
edl = enciphered_data_length(tag, *nbytes - offset, communication_settings) + offset;
|
||||
|
||||
// Fill in the crypto buffer with data ...
|
||||
memcpy(res, data, *nbytes);
|
||||
|
||||
if (!(communication_settings & NO_CRC)) {
|
||||
// ... CRC ...
|
||||
switch (DESFIRE(tag)->authentication_scheme) {
|
||||
case AS_LEGACY:
|
||||
case AS_LEGACY: {
|
||||
AddCrc14A(res + offset, *nbytes - offset);
|
||||
*nbytes += 2;
|
||||
break;
|
||||
case AS_NEW:
|
||||
}
|
||||
case AS_NEW: {
|
||||
crc32_append(res, *nbytes);
|
||||
*nbytes += 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ... and padding
|
||||
@@ -497,11 +502,12 @@ void *mifare_cryto_preprocess_data(desfiretag_t tag, void *data, size_t *nbytes,
|
||||
|
||||
mifare_cypher_blocks_chained(tag, NULL, NULL, res + offset, *nbytes - offset, MCD_SEND, (AS_NEW == DESFIRE(tag)->authentication_scheme) ? MCO_ENCYPHER : MCO_DECYPHER);
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
default: {
|
||||
*nbytes = -1;
|
||||
res = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -121,9 +121,13 @@ static int print_aid_description(json_t *root, uint16_t aid, char *fmt, bool ver
|
||||
const char *company = mad_json_get_str(elm, "company");
|
||||
const char *provider = mad_json_get_str(elm, "service_provider");
|
||||
const char *integrator = mad_json_get_str(elm, "system_integrator");
|
||||
char result[4 + strlen(application) + strlen(company)];
|
||||
sprintf(result, " %s [%s]", application, company);
|
||||
PrintAndLogEx(INFO, fmt, result);
|
||||
|
||||
if (application && company) {
|
||||
char result[4 + strlen(application) + strlen(company)];
|
||||
sprintf(result, " %s [%s]", application, company);
|
||||
PrintAndLogEx(INFO, fmt, result);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(SUCCESS, " MAD: %s", vmad);
|
||||
if (application)
|
||||
|
||||
+33
-31
@@ -86,7 +86,6 @@ int preferences_load(void) {
|
||||
// to better control json cant find file error msg.
|
||||
char *fn = prefGetFilename();
|
||||
if (fileExists(fn)) {
|
||||
PrintAndLogEx(INFO, "Loading preferences...");
|
||||
if (loadFileJSON(fn, &dummyData, sizeof(dummyData), &dummyDL, &preferences_load_callback) == PM3_SUCCESS) {
|
||||
session.preferences_loaded = true;
|
||||
}
|
||||
@@ -384,75 +383,75 @@ static const char *prefShowMsg(prefShowOpt_t Opt) {
|
||||
return "";
|
||||
}
|
||||
|
||||
static void showEmojiState(prefShowOpt_t Opt) {
|
||||
static void showEmojiState(prefShowOpt_t opt) {
|
||||
|
||||
switch (session.emoji_mode) {
|
||||
case ALIAS:
|
||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alias"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_GREEN_("alias"), prefShowMsg(opt));
|
||||
break;
|
||||
case EMOJI:
|
||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("emoji"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_GREEN_("emoji"), prefShowMsg(opt));
|
||||
break;
|
||||
case ALTTEXT:
|
||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("alttext"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_GREEN_("alttext"), prefShowMsg(opt));
|
||||
break;
|
||||
case ERASE:
|
||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_GREEN_("erase"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_GREEN_("erase"), prefShowMsg(opt));
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(NORMAL, " %s emoji.................. "_RED_("unknown"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s emoji.................. "_RED_("unknown"), prefShowMsg(opt));
|
||||
}
|
||||
}
|
||||
|
||||
static void showColorState(prefShowOpt_t Opt) {
|
||||
static void showColorState(prefShowOpt_t opt) {
|
||||
|
||||
if (session.supports_colors)
|
||||
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s color.................. "_GREEN_("ansi"), prefShowMsg(opt));
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " %s color.................. "_WHITE_("off"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s color.................. "_WHITE_("off"), prefShowMsg(opt));
|
||||
}
|
||||
|
||||
static void showClientDebugState(prefShowOpt_t Opt) {
|
||||
static void showClientDebugState(prefShowOpt_t opt) {
|
||||
|
||||
switch (session.client_debug_level) {
|
||||
case cdbOFF:
|
||||
PrintAndLogEx(NORMAL, " %s client debug........... "_WHITE_("off"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s client debug........... "_WHITE_("off"), prefShowMsg(opt));
|
||||
break;
|
||||
case cdbSIMPLE:
|
||||
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("simple"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s client debug........... "_GREEN_("simple"), prefShowMsg(opt));
|
||||
break;
|
||||
case cdbFULL:
|
||||
PrintAndLogEx(NORMAL, " %s client debug........... "_GREEN_("full"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s client debug........... "_GREEN_("full"), prefShowMsg(opt));
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(NORMAL, " %s client debug........... "_RED_("unknown"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s client debug........... "_RED_("unknown"), prefShowMsg(opt));
|
||||
}
|
||||
}
|
||||
/*
|
||||
static void showDeviceDebugState(prefShowOpt_t Opt) {
|
||||
static void showDeviceDebugState(prefShowOpt_t opt) {
|
||||
switch (session.device_debug_level) {
|
||||
case ddbOFF:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_WHITE_("off"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_WHITE_("off"), prefShowMsg(opt));
|
||||
break;
|
||||
case ddbERROR:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_GREEN_("error"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_GREEN_("error"), prefShowMsg(opt));
|
||||
break;
|
||||
case ddbINFO:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_GREEN_("info"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_GREEN_("info"), prefShowMsg(opt));
|
||||
break;
|
||||
case ddbDEBUG:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_GREEN_("debug"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_GREEN_("debug"), prefShowMsg(opt));
|
||||
break;
|
||||
case ddbEXTENDED:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_GREEN_("extended"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_GREEN_("extended"), prefShowMsg(opt));
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_RED_("unknown"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s device debug........... "_RED_("unknown"), prefShowMsg(opt));
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
static void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||
static void showSavePathState(savePaths_t pathIndex, prefShowOpt_t opt) {
|
||||
|
||||
char tempStr[50];
|
||||
|
||||
@@ -470,29 +469,30 @@ static void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||
strcpy (tempStr,_RED_("unknown")" save path......");
|
||||
}
|
||||
if ((session.defaultPaths[pathIndex] == NULL) || (strcmp(session.defaultPaths[pathIndex],"") == 0))
|
||||
PrintAndLogEx(NORMAL, " %s %s "_WHITE_("not set"), prefShowMsg(Opt),tempStr);
|
||||
PrintAndLogEx(INFO, " %s %s "_WHITE_("not set"), prefShowMsg(opt),tempStr);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " %s %s "_GREEN_("%s"), prefShowMsg(Opt), tempStr, session.defaultPaths[pathIndex]);
|
||||
PrintAndLogEx(INFO, " %s %s "_GREEN_("%s"), prefShowMsg(opt), tempStr, session.defaultPaths[pathIndex]);
|
||||
}
|
||||
|
||||
static void showPlotPosState(void) {
|
||||
PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
PrintAndLogEx(INFO, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.plot.x, session.plot.y, session.plot.h, session.plot.w);
|
||||
}
|
||||
|
||||
static void showOverlayPosState(void) {
|
||||
PrintAndLogEx(NORMAL, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
PrintAndLogEx(INFO, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.overlay.x, session.overlay.y, session.overlay.h, session.overlay.w);
|
||||
}
|
||||
*/
|
||||
|
||||
static void showHintsState(prefShowOpt_t Opt) {
|
||||
static void showHintsState(prefShowOpt_t opt) {
|
||||
if (session.show_hints)
|
||||
PrintAndLogEx(NORMAL, " %s hints.................. "_GREEN_("on"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s hints.................. "_GREEN_("on"), prefShowMsg(opt));
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " %s hints.................. "_WHITE_("off"), prefShowMsg(Opt));
|
||||
PrintAndLogEx(INFO, " %s hints.................. "_WHITE_("off"), prefShowMsg(opt));
|
||||
}
|
||||
|
||||
|
||||
static int setCmdEmoji(const char *Cmd) {
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
@@ -909,13 +909,14 @@ static int CmdPrefShow(const char *Cmd) {
|
||||
if (session.preferences_loaded) {
|
||||
char *fn = prefGetFilename();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, _CYAN_("Preferences loaded from " _YELLOW_("%s")), fn);
|
||||
PrintAndLogEx(INFO, "Using "_YELLOW_("%s"), fn);
|
||||
free(fn);
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Preferences not loaded");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "Current settings");
|
||||
showEmojiState(prefShowNone);
|
||||
showHintsState(prefShowNone);
|
||||
showColorState(prefShowNone);
|
||||
@@ -927,6 +928,7 @@ static int CmdPrefShow(const char *Cmd) {
|
||||
|
||||
showClientDebugState(prefShowNone);
|
||||
// showDeviceDebugState(prefShowNone);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
/*
|
||||
|
||||
+53
-9
@@ -18,8 +18,10 @@
|
||||
#ifdef HAVE_READLINE
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#include "usart_defs.h"
|
||||
#include "util_posix.h"
|
||||
#include "proxgui.h"
|
||||
@@ -134,6 +136,37 @@ static int check_comm(void) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void flush_history(void) {
|
||||
#ifdef HAVE_READLINE
|
||||
if (session.history_path) {
|
||||
write_history(session.history_path);
|
||||
free(session.history_path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
|
||||
# if defined(_WIN32)
|
||||
/*
|
||||
static bool WINAPI terminate_handler(DWORD t) {
|
||||
if (t == CTRL_C_EVENT) {
|
||||
flush_history();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
# else
|
||||
struct sigaction old_action;
|
||||
static void terminate_handler(int signum) {
|
||||
sigaction(SIGINT, &old_action, NULL);
|
||||
flush_history();
|
||||
kill(0, SIGINT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// first slot is always NULL, indicating absence of script when idx=0
|
||||
static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
||||
@@ -211,16 +244,29 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
char *my_history_path = NULL;
|
||||
if (searchHomeFilePath(&my_history_path, NULL, PROXHISTORY, true) != PM3_SUCCESS) {
|
||||
session.history_path = NULL;
|
||||
if (searchHomeFilePath(&session.history_path, NULL, PROXHISTORY, true) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "No history will be recorded");
|
||||
my_history_path = NULL;
|
||||
session.history_path = NULL;
|
||||
} else {
|
||||
read_history(my_history_path);
|
||||
|
||||
# if defined(_WIN32)
|
||||
// SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true);
|
||||
# else
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = &terminate_handler;
|
||||
sigaction(SIGINT, &action, &old_action);
|
||||
# endif
|
||||
rl_catch_signals = 1;
|
||||
rl_set_signals();
|
||||
read_history(session.history_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
// loops every time enter is pressed...
|
||||
while (1) {
|
||||
|
||||
bool printprompt = false;
|
||||
if (session.pm3_present) {
|
||||
if (conn.send_via_fpc_usart == false)
|
||||
@@ -391,11 +437,9 @@ check_script:
|
||||
pop_cmdscriptfile();
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
if (my_history_path) {
|
||||
write_history(my_history_path);
|
||||
free(my_history_path);
|
||||
}
|
||||
flush_history();
|
||||
#endif
|
||||
|
||||
if (cmd) {
|
||||
free(cmd);
|
||||
cmd = NULL;
|
||||
@@ -1027,7 +1071,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
#ifdef HAVE_GUI
|
||||
|
||||
# ifdef _WIN32
|
||||
# if defined(_WIN32)
|
||||
InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
MainGraphics();
|
||||
# else
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef struct {
|
||||
// char *defaultPaths[spItemCount]; // Array should allow loop searching for files
|
||||
clientdebugLevel_t client_debug_level;
|
||||
// uint8_t device_debug_level;
|
||||
char *history_path;
|
||||
} session_arg_t;
|
||||
|
||||
extern session_arg_t session;
|
||||
|
||||
Reference in New Issue
Block a user