This commit is contained in:
iceman1001 2024-01-16 13:52:25 +01:00
parent 5b31211971
commit 13b74dd817
3 changed files with 75 additions and 58 deletions

View file

@ -1391,35 +1391,35 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_lit0("a", NULL, "active signal field ON without select"),
arg_int0("b", NULL, "<dec>", "number of bits to send. Useful for send partial byte"),
arg_lit0("c", NULL, "calculate and append CRC"),
arg_lit0("k", NULL, "keep signal field ON after receive"),
arg_lit0("3", NULL, "ISO14443-3 select only (skip RATS)"),
arg_lit0("r", NULL, "do not read response"),
arg_lit0("s", NULL, "active signal field ON with select"),
arg_int0("t", "timeout", "<ms>", "timeout in milliseconds"),
arg_lit0("v", "verbose", "Verbose output"),
arg_lit0(NULL, "topaz", "use Topaz protocol to send command"),
arg_lit0(NULL, "ecp", "use enhanced contactless polling"),
arg_lit0(NULL, "mag", "use Apple magsafe polling"),
arg_strx1(NULL, NULL, "<hex>", "raw bytes to send"),
arg_lit0("a", NULL, "Active signal field ON without select"),
arg_lit0("c", NULL, "Calculate and append CRC"),
arg_lit0("k", NULL, "Keep signal field ON after receive"),
arg_lit0("3", NULL, "ISO14443-3 select only (skip RATS)"),
arg_lit0("r", NULL, "Do not read response"),
arg_lit0("s", NULL, "Active signal field ON with select"),
arg_int0("t", "timeout", "<ms>", "Timeout in milliseconds"),
arg_int0("b", NULL, "<dec>","Number of bits to send. Useful for send partial byte"),
arg_lit0("v", "verbose", "Verbose output"),
arg_lit0(NULL, "ecp", "Use enhanced contactless polling"),
arg_lit0(NULL, "mag", "Use Apple magsafe polling"),
arg_lit0(NULL, "topaz", "Use Topaz protocol to send command"),
arg_strx1(NULL, NULL, "<hex>","Raw bytes to send"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
bool active = arg_get_lit(ctx, 1);
uint16_t numbits = (uint16_t)arg_get_int_def(ctx, 2, 0);
bool crc = arg_get_lit(ctx, 3);
bool keep_field_on = arg_get_lit(ctx, 4);
bool no_rats = arg_get_lit(ctx, 5);
bool reply = (arg_get_lit(ctx, 6) == false);
bool active_select = arg_get_lit(ctx, 7);
uint32_t timeout = (uint32_t)arg_get_int_def(ctx, 8, 0);
bool crc = arg_get_lit(ctx, 2);
bool keep_field_on = arg_get_lit(ctx, 3);
bool no_rats = arg_get_lit(ctx, 4);
bool reply = (arg_get_lit(ctx, 5) == false);
bool active_select = arg_get_lit(ctx, 6);
uint32_t timeout = (uint32_t)arg_get_int_def(ctx, 7, 0);
uint16_t numbits = (uint16_t)arg_get_int_def(ctx, 8, 0);
bool verbose = arg_get_lit(ctx, 9);
bool topazmode = arg_get_lit(ctx, 10);
bool use_ecp = arg_get_lit(ctx, 11);
bool use_magsafe = arg_get_lit(ctx, 12);
bool use_ecp = arg_get_lit(ctx, 10);
bool use_magsafe = arg_get_lit(ctx, 11);
bool topazmode = arg_get_lit(ctx, 12);
int datalen = 0;
uint8_t data[PM3_CMD_DATA_SIZE_MIX] = {0};

View file

@ -255,8 +255,14 @@ static bool wait_cmd_14b(bool verbose, bool is_select, uint32_t timeout) {
}
if (is_select) {
if (resp.status == PM3_ECARDEXCHANGE) {
PrintAndLogEx(INFO, "no response from tag");
return false;
}
if (resp.status != PM3_SUCCESS) {
PrintAndLogEx(INFO, "failed status value... %d", resp.status);
if (verbose) {
PrintAndLogEx(INFO, "failed status value... %d", resp.status);
}
return false;
}
}
@ -659,6 +665,7 @@ static uint8_t get_st_cardsize(const uint8_t *uid) {
}
/*
static uint8_t get_st25_cardsize(const uint8_t *uid) {
uint8_t chipid = get_st25_chipid(uid);
switch (chipid) {
@ -845,7 +852,7 @@ static int CmdHF14BSniff(const char *Cmd) {
static int CmdHF14BCmdRaw(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 14b raw",
"Sends raw bytes to card",
"Sends raw bytes to card. Activates field by default",
"hf 14b raw -cks --data 0200a40400 -> standard select, apdu 0200a4000 (7816)\n"
"hf 14b raw -ck --sr --data 0200a40400 -> SRx select\n"
"hf 14b raw -ck --cts --data 0200a40400 -> C-ticket select\n"
@ -853,61 +860,71 @@ static int CmdHF14BCmdRaw(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_lit0("k", "keep", "leave the signal field ON after receive response"),
arg_lit0("s", "std", "activate field, use ISO14B select"),
arg_lit0(NULL, "sr", "activate field, use SRx ST select"),
arg_lit0(NULL, "cts", "activate field, use ASK C-ticket select"),
arg_lit0(NULL, "xrx", "activate field, use Fuji/Xerox select"),
arg_lit0("a", NULL, "active signal field ON without select"),
arg_lit0("c", "crc", "calculate and append CRC"),
arg_lit0("k", "keep", "leave the signal field ON after receive response"),
arg_str0("d", "data", "<hex>", "data, bytes to send"),
arg_lit0("r", NULL, "do not read response from card"),
arg_int0("t", "timeout", "<dec>", "timeout in ms"),
arg_lit0("s", "std", "use ISO14B select"),
arg_lit0(NULL, "sr", "use SRx ST select"),
arg_lit0(NULL, "cts", "use ASK C-ticket select"),
arg_lit0(NULL, "xrx", "use Fuji/Xerox select"),
arg_lit0("v", "verbose", "verbose output"),
arg_str0("d", "data", "<hex>", "data, bytes to send"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
bool keep_field_on = arg_get_lit(ctx, 1);
bool select_std = arg_get_lit(ctx, 2);
bool select_sr = arg_get_lit(ctx, 3);
bool select_cts = arg_get_lit(ctx, 4);
bool select_xrx = arg_get_lit(ctx, 5);
bool add_crc = arg_get_lit(ctx, 6);
bool read_reply = (arg_get_lit(ctx, 7) == false);
int user_timeout = arg_get_int_def(ctx, 8, -1);
bool verbose = arg_get_lit(ctx, 9);
bool activate_field = arg_get_lit(ctx, 1);
bool add_crc = arg_get_lit(ctx, 2);
bool keep_field_on = arg_get_lit(ctx, 3);
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
int datalen = 0;
int res = CLIParamHexToBuf(arg_get_str(ctx, 10), data, sizeof(data), &datalen);
if (res && verbose) {
PrintAndLogEx(INFO, "called with no raw bytes");
}
CLIParamHexToBuf(arg_get_str(ctx, 4), data, sizeof(data), &datalen);
bool read_reply = (arg_get_lit(ctx, 5) == false);
int user_timeout = arg_get_int_def(ctx, 6, -1);
bool select_std = arg_get_lit(ctx, 7);
bool select_sr = arg_get_lit(ctx, 8);
bool select_cts = arg_get_lit(ctx, 9);
bool select_xrx = arg_get_lit(ctx, 10);
bool verbose = arg_get_lit(ctx, 11);
CLIParserFree(ctx);
// FLAGS for device side
uint32_t flags = ISO14B_CONNECT;
uint32_t flags = 0;
if (activate_field) {
flags |= ISO14B_CONNECT;
}
if (add_crc) {
flags |= ISO14B_APPEND_CRC;
}
if (select_std) {
flags |= (ISO14B_SELECT_STD | ISO14B_CLEARTRACE);
flags |= (ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_CLEARTRACE);
if (verbose) {
PrintAndLogEx(INFO, "using ISO14443-B select");
}
} else if (select_sr) {
flags |= (ISO14B_SELECT_SR | ISO14B_CLEARTRACE);
flags |= (ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_CLEARTRACE);
if (verbose) {
PrintAndLogEx(INFO, "using ST/SRx select");
}
} else if (select_cts) {
flags |= (ISO14B_SELECT_CTS | ISO14B_CLEARTRACE);
flags |= (ISO14B_CONNECT | ISO14B_SELECT_CTS | ISO14B_CLEARTRACE);
if (verbose) {
PrintAndLogEx(INFO, "using ASK/C-ticket select");
}
} else if (select_xrx) {
flags |= (ISO14B_SELECT_XRX | ISO14B_CLEARTRACE);
flags |= (ISO14B_CONNECT | ISO14B_SELECT_XRX | ISO14B_CLEARTRACE);
if (verbose) {
PrintAndLogEx(INFO, "using Fuji/Xerox select");
}

View file

@ -1919,35 +1919,35 @@ static int CmdHF15Raw(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 raw",
"Sends raw bytes over ISO-15693 to card",
"hf 15 raw -sc -d 260100 --> add crc\n"
"hf 15 raw -skrc -d 260100 --> add crc, keep field on, skip response"
"hf 15 raw -ac -d 260100 --> activate, add crc\n"
"hf 15 raw -akrc -d 260100 --> activate, add crc, keep field on, skip response"
);
void *argtable[] = {
arg_param_begin,
arg_lit0("2", NULL, "use slower '1 out of 256' mode"),
arg_lit0("a", NULL, "activate field"),
arg_lit0("c", "crc", "calculate and append CRC"),
arg_lit0("k", NULL, "keep signal field ON after receive"),
arg_lit0("2", NULL, "use slower '1 out of 256' mode"),
arg_lit0("r", NULL, "do not read response"),
arg_str1("d", "data", "<hex>", "raw bytes to send"),
arg_lit0("w", "wait", "wait longer for response. For writes etc."),
arg_lit0("a", NULL, "activate field"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
bool fast = (arg_get_lit(ctx, 1) == false);
bool activate = arg_get_lit(ctx, 1);
bool crc = arg_get_lit(ctx, 2);
bool keep_field_on = arg_get_lit(ctx, 3);
bool read_respone = (arg_get_lit(ctx, 4) == false);
bool fast = (arg_get_lit(ctx, 4) == false);
bool read_respone = (arg_get_lit(ctx, 5) == false);
int datalen = 0;
uint8_t data[PM3_CMD_DATA_SIZE] = { 0x00 };
CLIGetHexWithReturn(ctx, 5, data, &datalen);
CLIGetHexWithReturn(ctx, 6, data, &datalen);
bool wait = arg_get_lit(ctx, 6);
bool activate = arg_get_lit(ctx, 7);
bool wait = arg_get_lit(ctx, 7);
CLIParserFree(ctx);
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;