Merge branch 'master' into dev_em4x50_info_write
merge conflict
This commit is contained in:
@@ -1593,6 +1593,16 @@ static uint8_t getByte(uint8_t bits_per_sample, BitstreamOut *b) {
|
||||
}
|
||||
|
||||
int getSamples(uint32_t n, bool verbose) {
|
||||
return getSamplesEx(0, n, verbose);
|
||||
}
|
||||
|
||||
int getSamplesEx(uint32_t start, uint32_t end, bool verbose) {
|
||||
|
||||
if (end < start) {
|
||||
PrintAndLogEx(WARNING, "error, end (%u) is smaller than start (%u)", end, start);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
//If we get all but the last byte in bigbuf,
|
||||
// we don't have to worry about remaining trash
|
||||
// in the last byte in case the bits-per-sample
|
||||
@@ -1600,13 +1610,16 @@ int getSamples(uint32_t n, bool verbose) {
|
||||
uint8_t got[pm3_capabilities.bigbuf_size - 1];
|
||||
memset(got, 0x00, sizeof(got));
|
||||
|
||||
if (n == 0 || n > pm3_capabilities.bigbuf_size - 1)
|
||||
uint32_t n = end - start;
|
||||
|
||||
if (n <= 0 || n > pm3_capabilities.bigbuf_size - 1)
|
||||
n = pm3_capabilities.bigbuf_size - 1;
|
||||
|
||||
if (verbose) PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
||||
|
||||
PacketResponseNG response;
|
||||
if (!GetFromDevice(BIG_BUF, got, n, 0, NULL, 0, &response, 10000, true)) {
|
||||
if (!GetFromDevice(BIG_BUF, got, n, start, NULL, 0, &response, 10000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
@@ -2297,25 +2310,35 @@ static int CmdDataNDEF(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "data ndef",
|
||||
"Prints NFC Data Exchange Format (NDEF)",
|
||||
"Usage:\n\tdata ndef -d 9101085402656e48656c6c6f5101085402656e576f726c64\n");
|
||||
"Decode and print NFC Data Exchange Format (NDEF)",
|
||||
"Samples:\n"
|
||||
_YELLOW_("\tdata ndef -d 9101085402656e48656c6c6f5101085402656e576f726c64\n")
|
||||
_YELLOW_("\tdata ndef -d 0103d020240203e02c040300fe\n")
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_strx0("dD", "data", "<hex>", "NDEF data to decode"),
|
||||
arg_lit0("vV", "verbose", "verbose mode"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
int datalen = 0;
|
||||
uint8_t data[MAX_NDEF_LEN] = {0};
|
||||
CLIGetHexWithReturn(ctx, 1, data, &datalen);
|
||||
bool verbose = arg_get_lit(ctx, 2);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
if (datalen == 0)
|
||||
return PM3_EINVARG;
|
||||
|
||||
PrintAndLogEx(INFO, "Parsed NDEF Records");
|
||||
return NDEFRecordsDecodeAndPrint(data, datalen);
|
||||
int res = NDEFDecodeAndPrint(data, datalen, verbose);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
|
||||
res = NDEFRecordsDecodeAndPrint(data, datalen);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
|
||||
@@ -72,7 +72,10 @@ void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx);
|
||||
bool getDemodBuff(uint8_t *buff, size_t *size);
|
||||
void save_restoreDB(uint8_t saveOpt);// option '1' to save DemodBuffer any other to restore
|
||||
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
|
||||
|
||||
int getSamples(uint32_t n, bool verbose);
|
||||
int getSamplesEx(uint32_t start, uint32_t end, bool verbose);
|
||||
|
||||
void setClockGrid(uint32_t clk, int offset);
|
||||
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);
|
||||
int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||
|
||||
@@ -46,7 +46,8 @@ static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int usage_hf_search(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf search");
|
||||
PrintAndLogEx(NORMAL, "Will try to find a HF read out of the unknown tag. Stops when found.");
|
||||
PrintAndLogEx(NORMAL, "Will try to find a HF read out of the unknown tag.");
|
||||
PrintAndLogEx(NORMAL, "Continues to search for all different HF protocols");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - This help");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -64,18 +65,21 @@ static int usage_hf_sniff(void) {
|
||||
PrintAndLogEx(NORMAL, " <skip triggers> - skip number of triggers");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " hf sniff");
|
||||
PrintAndLogEx(NORMAL, " hf sniff 1000 0");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf sniff"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf sniff 1000 0"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_tune(void) {
|
||||
PrintAndLogEx(NORMAL, "Continuously measure HF antenna tuning.");
|
||||
PrintAndLogEx(NORMAL, "Press button or Enter to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Press button or `enter` to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf tune [h] [<iter>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - This help");
|
||||
PrintAndLogEx(NORMAL, " <iter> - number of iterations (default: 0=infinite)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf tune 1"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -195,7 +199,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
int CmdHFTune(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_tune();
|
||||
int iter = param_get32ex(Cmd, 0, 0, 10);
|
||||
int iter = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
PrintAndLogEx(INFO, "Measuring HF antenna, click " _GREEN_("pm3 button") " or press " _GREEN_("Enter") " to exit");
|
||||
PacketResponseNG resp;
|
||||
@@ -241,15 +245,68 @@ int CmdHFTune(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Collects pars of u8,
|
||||
// uses 16bit transfers from FPGA for speed
|
||||
// Takes all available bigbuff memory
|
||||
// data sample to download? Not sure what we can do with the data.
|
||||
int CmdHFSniff(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_sniff();
|
||||
|
||||
int skippairs = param_get32ex(Cmd, 0, 0, 10);
|
||||
int skiptriggers = param_get32ex(Cmd, 1, 0, 10);
|
||||
struct {
|
||||
uint32_t samplesToSkip;
|
||||
uint32_t triggersToSkip;
|
||||
} PACKED params;
|
||||
|
||||
params.samplesToSkip = param_get32ex(Cmd, 0, 0, 10);
|
||||
params.triggersToSkip = param_get32ex(Cmd, 1, 0, 10);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_SNIFF, skippairs, skiptriggers, 0, NULL, 0);
|
||||
SendCommandNG(CMD_HF_SNIFF, (uint8_t *)¶ms, sizeof(params));
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (kbd_enter_pressed()) {
|
||||
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
||||
PrintAndLogEx(INFO, "User aborted");
|
||||
break;
|
||||
}
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_HF_SNIFF, &resp, 1000)) {
|
||||
|
||||
if (resp.status == PM3_EOPABORTED) {
|
||||
PrintAndLogEx(INFO, "Button pressed, user aborted");
|
||||
break;
|
||||
}
|
||||
if (resp.status == PM3_SUCCESS) {
|
||||
|
||||
struct r {
|
||||
uint16_t len;
|
||||
} PACKED;
|
||||
struct r *retval = (struct r *)resp.data.asBytes;
|
||||
|
||||
PrintAndLogEx(INFO, "HF sniff (%u samples)", retval->len);
|
||||
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data hpf") "` to remove offset");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data plot") "` to view");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data save") "` to save");
|
||||
|
||||
// download bigbuf_malloc:d.
|
||||
// it reserve memory from the higher end.
|
||||
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
||||
// we can't start from beginning idx 0 but from that hi-to-start-of-allocated.
|
||||
uint32_t start = pm3_capabilities.bigbuf_size - retval->len;
|
||||
int res = getSamplesEx(start, start, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "failed to download samples to client");
|
||||
return res;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(INFO, "Done.");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -4545,7 +4545,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
||||
// copy default NDEF key
|
||||
uint8_t akey[6] = {0};
|
||||
memcpy(akey, g_mifare_ndef_key, 6);
|
||||
|
||||
|
||||
// user specified key
|
||||
if (keylen == 6) {
|
||||
memcpy(akey, key, 6);
|
||||
@@ -4584,7 +4584,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
||||
|
||||
for (int i = 0; i < madlen; i++) {
|
||||
if (aaid == mad[i]) {
|
||||
|
||||
|
||||
uint8_t vsector[16 * 4] = {0};
|
||||
if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector)) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -4611,7 +4611,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
||||
for (int i = 0; i < 4; i ++)
|
||||
PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex(§or0[i * 16], 16));
|
||||
}
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4669,7 +4669,7 @@ static int CmdHFMFNDEF(const char *Cmd) {
|
||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -k `") " with your custom key");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
bool haveMAD2 = false;
|
||||
int res = MADCheck(sector0, NULL, verbose, &haveMAD2);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
||||
@@ -1400,7 +1400,7 @@ static int CmdHFMFPMAD(const char *Cmd) {
|
||||
|
||||
for (int i = 0; i < madlen; i++) {
|
||||
if (aaid == mad[i]) {
|
||||
|
||||
|
||||
uint8_t vsector[16 * 4] = {0};
|
||||
if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector)) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -1472,7 +1472,7 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "reading MAD v1 sector");
|
||||
|
||||
|
||||
if (mfpReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector0, verbose)) {
|
||||
PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys");
|
||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndef -k `") " with your custom key");
|
||||
@@ -1487,7 +1487,7 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (haveMAD2) {
|
||||
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "reading MAD v2 sector");
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static int usage_lf_awid_watch(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf awid watch");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf awid watch");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid watch"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ static int usage_lf_awid_sim(void) {
|
||||
PrintAndLogEx(NORMAL, " <card number> : 16|32-bit value card number");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf awid sim 26 224 1337");
|
||||
PrintAndLogEx(NORMAL, " lf awid sim 50 2001 13371337");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid sim 26 224 1337"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid sim 50 2001 13371337"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ static int usage_lf_awid_clone(void) {
|
||||
PrintAndLogEx(NORMAL, " Q5 : optional - clone to Q5 (T5555) instead of T55x7 chip");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf awid clone 26 224 1337");
|
||||
PrintAndLogEx(NORMAL, " lf awid clone 50 2001 13371337");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid clone 26 224 1337"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid clone 50 2001 13371337"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ static int usage_lf_awid_brute(void) {
|
||||
PrintAndLogEx(NORMAL, " v : verbose logging, show all tries");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf awid brute a 26 f 224");
|
||||
PrintAndLogEx(NORMAL, " lf awid brute a 50 f 2001 d 2000");
|
||||
PrintAndLogEx(NORMAL, " lf awid brute v a 50 f 2001 c 200 d 2000");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid brute a 26 f 224"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid brute a 50 f 2001 d 2000"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf awid brute v a 50 f 2001 c 200 d 2000"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -180,11 +180,17 @@ static void verify_values(uint8_t *fmtlen, uint32_t *fc, uint32_t *cn) {
|
||||
// this read loops on device side.
|
||||
// uses the demod in lfops.c
|
||||
static int CmdAWIDWatch(const char *Cmd) {
|
||||
uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_lf_awid_watch();
|
||||
uint8_t c = tolower(param_getchar(Cmd, 0));
|
||||
if (c == 'h') return usage_lf_awid_watch();
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Watching for AWID cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_AWID_DEMOD, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
SendCommandNG(CMD_LF_AWID_WATCH, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_AWID_WATCH, &resp);
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
|
||||
@@ -45,13 +45,24 @@ static int usage_lf_em410x_demod(void) {
|
||||
PrintAndLogEx(NORMAL, " maxerror - set maximum allowed errors, default = 100.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod = demod an EM410x Tag ID from GraphBuffer");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 32 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/32");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 32 1 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/32 and inverting data");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 1 = demod an EM410x Tag ID from GraphBuffer while inverting data");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_demod 64 1 0 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/64 and inverting data and allowing 0 demod errors");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_demod") " = demod an EM410x Tag ID from GraphBuffer");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_demod 32") " = demod an EM410x Tag ID from GraphBuffer using a clock of RF/32");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_demod 32 1") " = demod an EM410x Tag ID from GraphBuffer using a clock of RF/32 and inverting data");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_demod 1") " = demod an EM410x Tag ID from GraphBuffer while inverting data");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_demod 64 1 0") " = demod an EM410x Tag ID from GraphBuffer using a clock of RF/64 and inverting data and allowing 0 demod errors");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_watch(void) {
|
||||
PrintAndLogEx(NORMAL, "Enables IOProx compatible reader mode printing details of scanned tags.");
|
||||
PrintAndLogEx(NORMAL, "By default, values are printed and logged until the button is pressed or another USB command is issued.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf em 410x_watch");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_watch"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_em410x_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Writes EM410x ID to a T55x7 / T5555 (Q5) tag");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
@@ -62,7 +73,7 @@ static int usage_lf_em410x_write(void) {
|
||||
PrintAndLogEx(NORMAL, " <card> - 0|1 T5555 (Q5) / T55x7");
|
||||
PrintAndLogEx(NORMAL, " <clock> - 16|32|40|64, optional, set R/F clock rate, defaults to 64");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_write 0F0368568B 1 = write ID to t55x7 card");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_write 0F0368568B 1") " = write ID to t55x7 card");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_ws(void) {
|
||||
@@ -72,7 +83,7 @@ static int usage_lf_em410x_ws(void) {
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - this help");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_spoof");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_spoof"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_sim(void) {
|
||||
@@ -84,8 +95,8 @@ static int usage_lf_em410x_sim(void) {
|
||||
PrintAndLogEx(NORMAL, " uid - uid (10 HEX symbols)");
|
||||
PrintAndLogEx(NORMAL, " clock - clock (32|64) (optional)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_sim 0F0368568B");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_sim 0F0368568B 32");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_sim 0F0368568B"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_sim 0F0368568B 32"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_lf_em410x_brute(void) {
|
||||
@@ -98,10 +109,10 @@ static int usage_lf_em410x_brute(void) {
|
||||
PrintAndLogEx(NORMAL, " d (2000) - pause delay in milliseconds between UIDs simulation, default 1000 ms (optional)");
|
||||
PrintAndLogEx(NORMAL, " c (32) - clock (32|64), default 64 (optional)");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt c 32");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt d 3000");
|
||||
PrintAndLogEx(NORMAL, " lf em 410x_brute ids.txt d 3000 c 32");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt c 32"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_( " lf em 410x_brute ids.txt d 3000"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf em 410x_brute ids.txt d 3000 c 32"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -426,16 +437,23 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
|
||||
return PM3_ESOFT;
|
||||
return AskEm410xDecode(verbose, hi, lo);
|
||||
}
|
||||
/*
|
||||
|
||||
// this read loops on device side.
|
||||
// uses the demod in lfops.c
|
||||
static int CmdEM410xRead_device(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
uint8_t findone = (cmdp == '1') ? 1 : 0;
|
||||
SendCommandMIX(CMD_LF_EM410X_DEMOD, findone, 0, 0, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
static int CmdEM410xWatch(const char *Cmd) {
|
||||
uint8_t c = tolower(param_getchar(Cmd, 0));
|
||||
if (c == 'h') return usage_lf_em410x_watch();
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Watching for EM410x cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM410X_WATCH, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_EM410X_WATCH, &resp);
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
return resp.status;
|
||||
}
|
||||
*/
|
||||
|
||||
//by marshmellow
|
||||
//takes 3 arguments - clock, invert and maxErr as integers
|
||||
//attempts to demodulate ask while decoding manchester
|
||||
@@ -595,30 +613,6 @@ static int CmdEM410xBrute(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/* Function is equivalent of lf read + data samples + em410xread
|
||||
* looped until an EM410x tag is detected
|
||||
*
|
||||
* Why is CmdSamples("16000")?
|
||||
* TBD: Auto-grow sample size based on detected sample rate. IE: If the
|
||||
* rate gets lower, then grow the number of samples
|
||||
* Changed by martin, 4000 x 4 = 16000,
|
||||
* see http://www.proxmark.org/forum/viewtopic.php?pid=7235#p7235
|
||||
*
|
||||
* EDIT -- capture enough to get 2 complete preambles at the slowest data rate known to be used (rf/64) (64*64*2+9 = 8201) marshmellow
|
||||
*/
|
||||
static int CmdEM410xWatch(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
do {
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(WARNING, "\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
lf_read(false, 12288);
|
||||
|
||||
} while (CmdEM410xRead("") != PM3_SUCCESS);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//currently only supports manchester modulations
|
||||
static int CmdEM410xWatchnSpoof(const char *Cmd) {
|
||||
|
||||
@@ -636,29 +630,26 @@ static int CmdEM410xWrite(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 0x00 || cmdp == 'h') return usage_lf_em410x_write();
|
||||
|
||||
uint64_t id = 0xFFFFFFFFFFFFFFFF; // invalid id value
|
||||
int card = 0xFF; // invalid card value
|
||||
uint32_t clock1 = 0; // invalid clock value
|
||||
|
||||
sscanf(Cmd, "%" SCNx64 " %d %d", &id, &card, &clock1);
|
||||
uint64_t id = param_get64ex(Cmd, 0, -1, 16);
|
||||
uint8_t card = param_get8ex(Cmd, 1, 0xFF, 10);
|
||||
uint8_t clock1 = param_get8ex(Cmd, 2, 0, 10);
|
||||
|
||||
// Check ID
|
||||
if (id == 0xFFFFFFFFFFFFFFFF) {
|
||||
PrintAndLogEx(ERR, "Error! ID is required.\n");
|
||||
PrintAndLogEx(ERR, "error, ID is required\n");
|
||||
usage_lf_em410x_write();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (id >= 0x10000000000) {
|
||||
PrintAndLogEx(ERR, "Error! Given EM410x ID is longer than 40 bits.\n");
|
||||
PrintAndLogEx(ERR, "error, given EM410x ID is longer than 40 bits\n");
|
||||
usage_lf_em410x_write();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
// Check Card
|
||||
if (card == 0xFF) {
|
||||
PrintAndLogEx(ERR, "Error! Card type required.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
if (card < 0) {
|
||||
PrintAndLogEx(ERR, "Error! Bad card type selected.\n");
|
||||
if (card > 1) {
|
||||
PrintAndLogEx(FAILED, "error, bad card type selected\n");
|
||||
usage_lf_em410x_write();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -668,29 +659,51 @@ 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" _YELLOW_("%d")" not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock1);
|
||||
PrintAndLogEx(ERR, "error, clock rate" _RED_("%d")" not valid");
|
||||
PrintAndLogEx(INFO, "supported clock rates: " _YELLOW_("16, 32, 40, 60") "\n", clock1);
|
||||
usage_lf_em410x_write();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (card == 1) {
|
||||
PrintAndLogEx(SUCCESS, "Writing %s tag with UID 0x%010" PRIx64 " (clock rate: %d)", "T55x7", id, clock1);
|
||||
PrintAndLogEx(SUCCESS, "Writing %s tag with UID 0x%010" PRIx64 " (clock rate: %d)", _GREEN_("T55x7"), id, clock1);
|
||||
// NOTE: We really should pass the clock in as a separate argument, but to
|
||||
// provide for backwards-compatibility for older firmware, and to avoid
|
||||
// having to add another argument to CMD_LF_EM410X_WRITE, we just store
|
||||
// the clock rate in bits 8-15 of the card value
|
||||
card = (card & 0xFF) | ((clock1 << 8) & 0xFF00);
|
||||
} else if (card == 0) {
|
||||
PrintAndLogEx(SUCCESS, "Writing %s tag with UID 0x%010" PRIx64 "(clock rate: %d)", "T5555", id, clock1);
|
||||
card = (card & 0xFF) | ((clock1 << 8) & 0xFF00);
|
||||
} else {
|
||||
PrintAndLogEx(FAILED, "Error! Bad card type selected.\n");
|
||||
return PM3_ESOFT;
|
||||
PrintAndLogEx(SUCCESS, "Writing %s tag with UID 0x%010" PRIx64 "(clock rate: %d)", _GREEN_("T5555"), id, clock1);
|
||||
}
|
||||
|
||||
struct {
|
||||
uint8_t card;
|
||||
uint8_t clock;
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
} PACKED params;
|
||||
|
||||
SendCommandMIX(CMD_LF_EM410X_WRITE, card, (uint32_t)(id >> 32), (uint32_t)id, NULL, 0);
|
||||
PrintAndLogEx(SUCCESS, "Done");
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf em 410x_read`") " to verify");
|
||||
return PM3_SUCCESS;
|
||||
params.card = card;
|
||||
params.clock = clock1;
|
||||
params.high = (uint32_t)(id >> 32);
|
||||
params.low = (uint32_t)id;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_EM410X_WRITE, (uint8_t *)¶ms, sizeof(params));
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_EM410X_WRITE, &resp);
|
||||
switch(resp.status) {
|
||||
case PM3_SUCCESS: {
|
||||
PrintAndLogEx(SUCCESS, "Done");
|
||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf em 410x_read`") " to verify");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(WARNING, "Something went wrong");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
//**************** Start of EM4x50 Code ************************
|
||||
@@ -1001,7 +1014,7 @@ int EM4x50Read(const char *Cmd, bool verbose) {
|
||||
PrintAndLogEx(INFO, "%03d | %08x", block, Code[block]);
|
||||
}
|
||||
PrintAndLogEx(INFO, "----+--------------");
|
||||
PrintAndLogEx( (AllPTest) ? SUCCESS : WARNING, "Parities checks | %s", (AllPTest) ? _GREEN_("Passed") : _RED_("Fail"));
|
||||
PrintAndLogEx((AllPTest) ? SUCCESS : WARNING, "Parities checks | %s", (AllPTest) ? _GREEN_("Passed") : _RED_("Fail"));
|
||||
|
||||
if (AllPTest == false) {
|
||||
PrintAndLogEx(HINT, "Try cleaning the read samples with " _YELLOW_("'data askedge'"));
|
||||
|
||||
@@ -264,13 +264,17 @@ static int CmdHIDRead(const char *Cmd) {
|
||||
// this read loops on device side.
|
||||
// uses the demod in lfops.c
|
||||
static int CmdHIDWatch(const char *Cmd) {
|
||||
uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_lf_hid_watch();
|
||||
uint8_t c = tolower(param_getchar(Cmd, 0));
|
||||
if (c == 'h') return usage_lf_hid_watch();
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Watching for HID Prox cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_HID_DEMOD, NULL, 0);
|
||||
PrintAndLogEx(SUCCESS, "Watching for new HID cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading new cards");
|
||||
return PM3_SUCCESS;
|
||||
SendCommandNG(CMD_LF_HID_WATCH, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_HID_WATCH, &resp);
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
static int CmdHIDSim(const char *Cmd) {
|
||||
|
||||
@@ -36,7 +36,7 @@ static int usage_lf_io_watch(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf io watch");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf io watch");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf io watch"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ static int usage_lf_io_sim(void) {
|
||||
PrintAndLogEx(NORMAL, " <card number> : 16bit value card number (decimal)");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf io sim 26 101 1337");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf io sim 26 101 1337"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -69,18 +69,24 @@ static int usage_lf_io_clone(void) {
|
||||
PrintAndLogEx(NORMAL, " Q5 : optional - clone to Q5 (T5555) instead of T55x7 chip");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf io clone 26 101 1337");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf io clone 26 101 1337"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// this read loops on device side.
|
||||
// uses the demod in lfops.c
|
||||
static int CmdIOProxWatch(const char *Cmd) {
|
||||
uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_lf_io_watch();
|
||||
uint8_t c = tolower(param_getchar(Cmd, 0));
|
||||
if (c == 'h') return usage_lf_io_watch();
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Watching for IO Prox cards - place tag on antenna");
|
||||
PrintAndLogEx(INFO, "Press pm3-button to stop reading cards");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_LF_IO_DEMOD, NULL, 0);
|
||||
return PM3_SUCCESS;
|
||||
SendCommandNG(CMD_LF_IO_WATCH, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_LF_IO_WATCH, &resp);
|
||||
PrintAndLogEx(INFO, "Done");
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// by marshmellow
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
@@ -62,11 +64,14 @@ static int usage_lf_pyramid_sim(void) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
//Pyramid Prox demod - FSK RF/50 with preamble of 0000000000000001 (always a 128 bit data stream)
|
||||
//print full Farpointe Data/Pyramid Prox ID and some bit format details if found
|
||||
static int CmdPyramidDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodPyramid();
|
||||
}
|
||||
|
||||
//Pyramid Prox demod - FSK RF/50 with preamble of 0000000000000001 (always a 128 bit data stream)
|
||||
//print full Farpointe Data/Pyramid Prox ID and some bit format details if found
|
||||
int demodPyramid(void) {
|
||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
@@ -350,11 +355,6 @@ int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int demodPyramid(void) {
|
||||
return CmdPyramidDemod("");
|
||||
}
|
||||
|
||||
// by marshmellow
|
||||
// FSK Demod then try to locate a Farpointe Data (pyramid) ID
|
||||
int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
||||
//make sure buffer has data
|
||||
|
||||
@@ -34,13 +34,17 @@ static int usage_lf_securakey_clone(void) {
|
||||
PrintAndLogEx(NORMAL, " b <raw hex> : raw hex data. 12 bytes max");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf securakey clone 7FCB400001ADEA5344300000");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf securakey clone b 7FCB400001ADEA5344300000"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//see ASKDemod for what args are accepted
|
||||
static int CmdSecurakeyDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodSecurakey();
|
||||
}
|
||||
|
||||
//see ASKDemod for what args are accepted
|
||||
int demodSecurakey(void) {
|
||||
|
||||
//ASK / Manchester
|
||||
bool st = false;
|
||||
@@ -212,7 +216,3 @@ int detectSecurakey(uint8_t *dest, size_t *size) {
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
int demodSecurakey(void) {
|
||||
return CmdSecurakeyDemod("");
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ static int usage_lf_visa2k_clone(void) {
|
||||
PrintAndLogEx(NORMAL, " <Q5> : specify write to Q5 (t5555 instead of t55x7)");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf visa2000 clone 112233");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf visa2000 clone 112233"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ static int usage_lf_visa2k_sim(void) {
|
||||
PrintAndLogEx(NORMAL, " <card ID> : Visa2k card ID");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf visa2000 sim 112233");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" lf visa2000 sim 112233"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,10 @@ static uint8_t visa_parity(uint32_t id) {
|
||||
return par;
|
||||
}
|
||||
|
||||
static int CmdVisa2kDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
return demodVisa2k();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* 56495332 00096ebd 00000077 —> tag id 618173
|
||||
@@ -98,9 +102,7 @@ static uint8_t visa_parity(uint32_t id) {
|
||||
*
|
||||
**/
|
||||
//see ASKDemod for what args are accepted
|
||||
static int CmdVisa2kDemod(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
|
||||
int demodVisa2k(void) {
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
|
||||
//CmdAskEdgeDetect("");
|
||||
@@ -153,7 +155,7 @@ static int CmdVisa2kDemod(const char *Cmd) {
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Visa2000 Tag Found: Card ID %u, Raw: %08X%08X%08X", raw2, raw1, raw2, raw3);
|
||||
PrintAndLogEx(SUCCESS, "Visa2000 Tag Found: Card ID " _GREEN_("%u") " Raw: %08X%08X%08X", raw2, raw1, raw2, raw3);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -260,7 +262,4 @@ int detectVisa2k(uint8_t *dest, size_t *size) {
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
int demodVisa2k(void) {
|
||||
return CmdVisa2kDemod("");
|
||||
}
|
||||
|
||||
|
||||
@@ -248,8 +248,9 @@ static int CmdPref(const char *Cmd) {
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use '<command> help' for details of a particular command."},
|
||||
{"auto", CmdAuto, IfPm3Present, "Automated detection process for unknown tags"},
|
||||
|
||||
{"--------",CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("sub") " -----------------------"},
|
||||
|
||||
{"analyse", CmdAnalyse, AlwaysAvailable, "{ Analyse utils... }"},
|
||||
{"data", CmdData, AlwaysAvailable, "{ Plot window / data buffer manipulation... }"},
|
||||
{"emv", CmdEMV, AlwaysAvailable, "{ EMV ISO-14443 / ISO-7816... }"},
|
||||
@@ -258,15 +259,17 @@ static command_t CommandTable[] = {
|
||||
{"lf", CmdLF, AlwaysAvailable, "{ Low frequency commands... }"},
|
||||
{"mem", CmdFlashMem, IfPm3Flash, "{ Flash Memory manipulation... }"},
|
||||
{"reveng", CmdRev, AlwaysAvailable, "{ CRC calculations from RevEng software }"},
|
||||
{"sc", CmdSmartcard, AlwaysAvailable, "{ Smart card ISO-7816 commands... }"},
|
||||
{"smart", CmdSmartcard, AlwaysAvailable, "{ Smart card ISO-7816 commands... }"},
|
||||
{"script", CmdScript, AlwaysAvailable, "{ Scripting commands }"},
|
||||
{"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},
|
||||
{"usart", CmdUsart, IfPm3FpcUsartFromUsb, "{ USART commands... }"},
|
||||
{"wiegand", CmdWiegand, AlwaysAvailable, "{ Wiegand format manipulation... }"},
|
||||
{"", CmdHelp, AlwaysAvailable, ""},
|
||||
{"--------",CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("sub") " -----------------------"},
|
||||
{"auto", CmdAuto, IfPm3Present, "Automated detection process for unknown tags"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use " _YELLOW_("'<command> help'") " for details of a particular command."},
|
||||
{"hints", CmdHints, AlwaysAvailable, "Turn hints on / off"},
|
||||
{"pref", CmdPref, AlwaysAvailable, "Edit preferences"},
|
||||
{"msleep", CmdMsleep, AlwaysAvailable, "Add a pause in milliseconds"},
|
||||
{"pref", CmdPref, AlwaysAvailable, "Edit preferences"},
|
||||
{"rem", CmdRem, AlwaysAvailable, "Add a text line in log file"},
|
||||
{"quit", CmdQuit, AlwaysAvailable, ""},
|
||||
{"exit", CmdQuit, AlwaysAvailable, "Exit program"},
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
// Partly ripped from PyRun_SimpleFileExFlags
|
||||
// but does not terminate client on sys.exit
|
||||
// and print exit code only if != 0
|
||||
static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename)
|
||||
{
|
||||
static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename) {
|
||||
PyObject *m, *d, *v;
|
||||
int set_file_name = 0, ret = -1;
|
||||
m = PyImport_AddModule("__main__");
|
||||
@@ -86,7 +85,7 @@ static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename)
|
||||
}
|
||||
Py_DECREF(v);
|
||||
ret = 0;
|
||||
done:
|
||||
done:
|
||||
if (set_file_name && PyDict_DelItemString(d, "__file__"))
|
||||
PyErr_Clear();
|
||||
Py_XDECREF(m);
|
||||
|
||||
@@ -349,7 +349,7 @@ __attribute__((force_align_arg_pointer))
|
||||
// main thread will kill and restart this thread.
|
||||
if (commfailed) {
|
||||
if (conn.last_command != CMD_HARDWARE_RESET) {
|
||||
PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed"));
|
||||
PrintAndLogEx(WARNING, "\nCommunicating with Proxmark3 device " _RED_("failed"));
|
||||
}
|
||||
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
break;
|
||||
|
||||
@@ -1455,7 +1455,7 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
// current path + file name
|
||||
if (MergeJSON) {
|
||||
|
||||
root = json_load_file( (char*)filename, 0, &error);
|
||||
root = json_load_file((char *)filename, 0, &error);
|
||||
if (!root) {
|
||||
PrintAndLogEx(ERR, "Json error on line %d: %s", error.line, error.text);
|
||||
return PM3_EFILE;
|
||||
@@ -1750,15 +1750,15 @@ static int CmdEMVScan(const char *Cmd) {
|
||||
|
||||
if (MergeJSON == false) {
|
||||
// create unique new name
|
||||
char *fname = newfilenamemcopy((char*)filename, ".json");
|
||||
char *fname = newfilenamemcopy((char *)filename, ".json");
|
||||
if (fname == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
strcpy((char*)filename, fname);
|
||||
strcpy((char *)filename, fname);
|
||||
free(fname);
|
||||
}
|
||||
|
||||
res = json_dump_file(root, (char*)filename, JSON_INDENT(2));
|
||||
res = json_dump_file(root, (char *)filename, JSON_INDENT(2));
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Can't save the file: %s", filename);
|
||||
return PM3_EFILE;
|
||||
|
||||
@@ -504,19 +504,19 @@ struct emv_pk *emv_pk_get_ca_pk(const unsigned char *rid, unsigned char idx) {
|
||||
bool isok = emv_pk_verify(pk);
|
||||
|
||||
PrintAndLogEx(INFO, "Verifying CA PK for %02hhx:%02hhx:%02hhx:%02hhx:%02hhx IDX %02hhx %zu bits. ( %s )",
|
||||
pk->rid[0],
|
||||
pk->rid[1],
|
||||
pk->rid[2],
|
||||
pk->rid[3],
|
||||
pk->rid[4],
|
||||
pk->index,
|
||||
pk->mlen * 8,
|
||||
(isok) ? _GREEN_("ok") : _RED_("failed")
|
||||
);
|
||||
pk->rid[0],
|
||||
pk->rid[1],
|
||||
pk->rid[2],
|
||||
pk->rid[3],
|
||||
pk->rid[4],
|
||||
pk->index,
|
||||
pk->mlen * 8,
|
||||
(isok) ? _GREEN_("ok") : _RED_("failed")
|
||||
);
|
||||
|
||||
if (isok) {
|
||||
return pk;
|
||||
}
|
||||
}
|
||||
|
||||
emv_pk_free(pk);
|
||||
return NULL;
|
||||
|
||||
@@ -1369,17 +1369,17 @@ static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose)
|
||||
}
|
||||
|
||||
static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
/* For reference
|
||||
typedef struct {
|
||||
uint8_t version[8];
|
||||
uint8_t tbo[2];
|
||||
uint8_t tearing[3];
|
||||
uint8_t pack[2];
|
||||
uint8_t tbo1[1];
|
||||
uint8_t signature[32];
|
||||
uint8_t data[1024];
|
||||
} PACKED old_mfu_dump_t;
|
||||
*/
|
||||
/* For reference
|
||||
typedef struct {
|
||||
uint8_t version[8];
|
||||
uint8_t tbo[2];
|
||||
uint8_t tearing[3];
|
||||
uint8_t pack[2];
|
||||
uint8_t tbo1[1];
|
||||
uint8_t signature[32];
|
||||
uint8_t data[1024];
|
||||
} PACKED old_mfu_dump_t;
|
||||
*/
|
||||
|
||||
// convert old format
|
||||
old_mfu_dump_t *old_mfu_dump = (old_mfu_dump_t *)*dump;
|
||||
@@ -1404,8 +1404,8 @@ typedef struct {
|
||||
|
||||
memcpy(mfu_dump->data, old_mfu_dump->data, sizeof(mfu_dump->data));
|
||||
mfu_dump->pages = old_data_len / 4 - 1;
|
||||
|
||||
// Add PACK to last block of memory.
|
||||
|
||||
// Add PACK to last block of memory.
|
||||
memcpy(mfu_dump->data + (mfu_dump->pages * 4 + MFU_DUMP_PREFIX_LENGTH), old_mfu_dump->pack, 2);
|
||||
|
||||
if (verbose) {
|
||||
|
||||
@@ -882,7 +882,7 @@ void mifare_cypher_blocks_chained(desfiretag_t tag, desfirekey_t key, uint8_t *i
|
||||
}
|
||||
|
||||
void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc) {
|
||||
crc32_ex(data,len,crc);
|
||||
crc32_ex(data, len, crc);
|
||||
}
|
||||
|
||||
void desfire_crc32_append(uint8_t *data, const size_t len) {
|
||||
|
||||
@@ -173,7 +173,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
||||
if (sector0 == NULL)
|
||||
return PM3_EINVARG;
|
||||
|
||||
uint8_t GPB = sector0[3 * 16 + 9];
|
||||
uint8_t GPB = sector0[3 * 16 + 9];
|
||||
if (verbose)
|
||||
PrintAndLogEx(SUCCESS, "%14s " _GREEN_("0x%02x"), "GPB", GPB);
|
||||
|
||||
@@ -304,7 +304,7 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMA
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------------- " _CYAN_("Listing") " ----------------");
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " 00 MAD v1");
|
||||
uint32_t prev_aid = 0xFFFFFFFF;
|
||||
for (int i = 1; i < 16; i++) {
|
||||
@@ -326,10 +326,10 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMA
|
||||
|
||||
int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) {
|
||||
open_mad_file(&mad_known_aids, verbose);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "------------ " _CYAN_("MAD v2 details") " -------------");
|
||||
|
||||
|
||||
int res = madCRCCheck(sector, true, 2);
|
||||
if (verbose) {
|
||||
if (res == PM3_SUCCESS)
|
||||
@@ -347,7 +347,7 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------------- " _CYAN_("Listing") " ----------------");
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " 16 MAD v2");
|
||||
|
||||
uint32_t prev_aid = 0xFFFFFFFF;
|
||||
|
||||
@@ -418,7 +418,7 @@ int NDEFRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "Record " _YELLOW_("%zu"), counter);
|
||||
PrintAndLogEx(SUCCESS, _CYAN_("Record") " " _YELLOW_("%zu"), counter);
|
||||
PrintAndLogEx(INFO, "-----------------------------------------------------");
|
||||
ndefRecordDecodeAndPrint(&ndefRecord[len], NDEFHeader.RecLen);
|
||||
|
||||
@@ -436,7 +436,7 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
|
||||
size_t indx = 0;
|
||||
|
||||
PrintAndLogEx(INFO, "");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("NDEF parsing") " ----------------");
|
||||
while (indx < ndefLen) {
|
||||
|
||||
@@ -445,7 +445,7 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
case 0x00: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(SUCCESS, "-- NDEF NULL block.");
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " ---");
|
||||
if (len)
|
||||
PrintAndLogEx(WARNING, "NDEF NULL block size must be 0, got %d bytes", len);
|
||||
indx += len;
|
||||
@@ -454,20 +454,21 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
case 0x01: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(INFO, "-- NDEF Lock Control.");
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Lock Control") " ---");
|
||||
if (len != 3) {
|
||||
PrintAndLogEx(WARNING, "NDEF Lock Control block size must be 3 instead of %d.", len);
|
||||
} else {
|
||||
uint8_t PagesAddr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t ByteOffset = ndef[indx] & 0x0f;
|
||||
uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t byte_offset = ndef[indx] & 0x0f;
|
||||
uint8_t Size = ndef[indx + 1];
|
||||
uint8_t BytesLockedPerLockBit = (ndef[indx + 2] >> 4) & 0x0f;
|
||||
uint8_t BytesPerPage = ndef[indx + 2] & 0x0f;
|
||||
PrintAndLogEx(SUCCESS, "PagesAddr. number of pages: %d", PagesAddr);
|
||||
PrintAndLogEx(SUCCESS, "ByteOffset. number of bytes: %d", ByteOffset);
|
||||
PrintAndLogEx(SUCCESS, "Size. size in bits of the lock area: %d. bytes approx: %d", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, "BytesPerPage. number of bytes per page: %d", BytesPerPage);
|
||||
PrintAndLogEx(SUCCESS, "BytesLockedPerLockBit. number of bytes that each dynamic lock bit is able to lock: %d", BytesLockedPerLockBit);
|
||||
uint8_t bytes_per_page = ndef[indx + 2] & 0x0f;
|
||||
PrintAndLogEx(SUCCESS, " Pages addr (number of pages) : %d", pages_addr);
|
||||
PrintAndLogEx(SUCCESS, "Byte offset (number of bytes) : %d", byte_offset);
|
||||
PrintAndLogEx(SUCCESS, "Size in bits of the lock area : %d. bytes approx: %d", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, " Number of bytes / page : %d", bytes_per_page);
|
||||
PrintAndLogEx(SUCCESS, "Bytes Locked Per LockBit.");
|
||||
PrintAndLogEx(SUCCESS, " number of bytes that each dynamic lock bit is able to lock: %d", BytesLockedPerLockBit);
|
||||
}
|
||||
indx += len;
|
||||
break;
|
||||
@@ -475,18 +476,18 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
case 0x02: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(INFO, "-- NDEF Memory Control.");
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Memory Control") " ---");
|
||||
if (len != 3) {
|
||||
PrintAndLogEx(WARNING, "NDEF Memory Control block size must be 3 instead of %d.", len);
|
||||
} else {
|
||||
uint8_t PagesAddr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t ByteOffset = ndef[indx] & 0x0f;
|
||||
uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f;
|
||||
uint8_t byte_offset = ndef[indx] & 0x0f;
|
||||
uint8_t Size = ndef[indx + 1];
|
||||
uint8_t BytesPerPage = ndef[indx + 2] & 0x0f;
|
||||
PrintAndLogEx(SUCCESS, "PagesAddr. number of pages: %d", PagesAddr);
|
||||
PrintAndLogEx(SUCCESS, "ByteOffset. number of bytes: %d", ByteOffset);
|
||||
PrintAndLogEx(SUCCESS, "Size. size in bits of the reserved area: %d. bytes approx: %d", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, "BytesPerPage. number of bytes per page: %d", BytesPerPage);
|
||||
uint8_t bytes_per_page = ndef[indx + 2] & 0x0f;
|
||||
PrintAndLogEx(SUCCESS, " Pages addr (number of pages) : %d", pages_addr);
|
||||
PrintAndLogEx(SUCCESS, "Byte offset (number of bytes) : %d", byte_offset);
|
||||
PrintAndLogEx(SUCCESS, "Size in bits of the reserved area : %d. bytes approx: %d", Size, Size / 8);
|
||||
PrintAndLogEx(SUCCESS, " Number of bytes / page : %d", bytes_per_page);
|
||||
}
|
||||
indx += len;
|
||||
break;
|
||||
@@ -494,28 +495,36 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||
case 0x03: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message (%d bytes)", len);
|
||||
|
||||
int res = NDEFRecordsDecodeAndPrint(&ndef[indx], len);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF Message") " ---");
|
||||
if (len == 0) {
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message w zero length");
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Found NDEF message (%d bytes)", len);
|
||||
|
||||
int res = NDEFRecordsDecodeAndPrint(&ndef[indx], len);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
}
|
||||
|
||||
indx += len;
|
||||
break;
|
||||
}
|
||||
case 0xfd: {
|
||||
indx++;
|
||||
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||
PrintAndLogEx(SUCCESS, "-- NDEF proprietary info. Skipped %d bytes.", len);
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("Proprietary info") " ---");
|
||||
PrintAndLogEx(SUCCESS, " Can't decode, skipping %d bytes", len);
|
||||
indx += len;
|
||||
break;
|
||||
}
|
||||
case 0xfe: {
|
||||
PrintAndLogEx(SUCCESS, "-- NDEF Terminator. Done.");
|
||||
PrintAndLogEx(SUCCESS, "NDEF Terminator detected");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(ERR, "unknown tag 0x%02x", ndef[indx]);
|
||||
if (verbose)
|
||||
PrintAndLogEx(ERR, "unknown tag 0x%02x", ndef[indx]);
|
||||
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,23 +117,23 @@ static void prompt_compose(char *buf, size_t buflen, const char *promptctx, cons
|
||||
snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, promptdev, promptctx);
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
static int check_comm(void) {
|
||||
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
||||
if (IsCommunicationThreadDead() && session.pm3_present) {
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n");
|
||||
prompt_dev = PROXPROMPT_DEV_OFFLINE;
|
||||
#ifdef HAVE_READLINE
|
||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors);
|
||||
rl_set_prompt(prompt_filtered);
|
||||
rl_forced_update_display();
|
||||
#endif
|
||||
CloseProxmark();
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// first slot is always NULL, indicating absence of script when idx=0
|
||||
static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
||||
@@ -293,13 +293,17 @@ check_script:
|
||||
printprompt = true;
|
||||
|
||||
} else {
|
||||
#ifdef HAVE_READLINE
|
||||
rl_event_hook = check_comm;
|
||||
#else
|
||||
check_comm();
|
||||
#endif
|
||||
prompt_ctx = PROXPROMPT_CTX_INTERACTIVE;
|
||||
char prompt[PROXPROMPT_MAX_SIZE] = {0};
|
||||
prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev);
|
||||
char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0};
|
||||
memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors);
|
||||
#ifdef HAVE_READLINE
|
||||
rl_event_hook = check_comm;
|
||||
cmd = readline(prompt_filtered);
|
||||
#else
|
||||
printf("%s", prompt_filtered);
|
||||
@@ -477,7 +481,6 @@ static void set_my_user_directory(void) {
|
||||
free(cwd_buffer);
|
||||
return;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "Len... %d", pathLen);
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
#include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
#include <complex.h>
|
||||
#include "util.h"
|
||||
#include "proxmark3.h" // PROXLOG
|
||||
|
||||
Reference in New Issue
Block a user