make style
This commit is contained in:
@@ -77,9 +77,9 @@ static bool wait_cmd_14b(bool verbose, bool is_select) {
|
||||
// 0: OK; -1: attrib fail; -2:crc fail
|
||||
int status = (int)resp.oldarg[0];
|
||||
if (status == 0) {
|
||||
|
||||
|
||||
if (verbose) {
|
||||
PrintAndLogEx(SUCCESS, "received " _YELLOW_("%u") " bytes", len);
|
||||
PrintAndLogEx(SUCCESS, "received " _YELLOW_("%u") " bytes", len);
|
||||
PrintAndLogEx(SUCCESS, "%s", sprint_hex(data, len));
|
||||
}
|
||||
return true;
|
||||
@@ -122,32 +122,32 @@ static int CmdHF14BList(const char *Cmd) {
|
||||
}
|
||||
|
||||
static int CmdHF14BSim(const char *Cmd) {
|
||||
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b sim",
|
||||
"Simulate a ISO/IEC 14443 type B tag with 4 byte UID / PUPI",
|
||||
"hf 14b sim\n"
|
||||
"hf 14b sim -u 11AA33BB"
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_strx0("u", "uid", "hex", "4byte UID/PUPI"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
|
||||
uint8_t pupi[4];
|
||||
int n = 0;
|
||||
int res = CLIParamHexToBuf(arg_get_str(ctx, 1), pupi, sizeof(pupi), &n);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
if (res) {
|
||||
PrintAndLogEx(FAILED, "failed to read pupi");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ISO14443B_SIMULATE, pupi, sizeof(pupi));
|
||||
SendCommandNG(CMD_HF_ISO14443B_SIMULATE, pupi, sizeof(pupi));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -157,36 +157,36 @@ static int CmdHF14BSniff(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf 14b sniff",
|
||||
"Sniff the communication reader and tag",
|
||||
"hf 14b sniff"
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ISO14443B_SNIFF, NULL, 0);
|
||||
|
||||
WaitForResponse(CMD_HF_ISO14443B_SNIFF, &resp);
|
||||
|
||||
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf 14b list") "` to view captured tracelog");
|
||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("trace save h") "` to save tracelog for later analysing");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdHF14BCmdRaw(const char *Cmd) {
|
||||
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b raw",
|
||||
"Sends raw bytes to card ",
|
||||
"hf 14b raw -cks --data 0200a40400 -> standard select\n"
|
||||
"hf 14b raw -ck --sr --data 0200a40400 -> SRx select\n"
|
||||
"hf 14b raw -ck --cts --data 0200a40400 -> C-ticket select\n"
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("k", "keep", "leave the signal field ON after receive response"),
|
||||
@@ -268,7 +268,7 @@ static int CmdHF14BCmdRaw(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
bool success = true;
|
||||
|
||||
// Select, device will send back iso14b_card_select_t, don't print it.
|
||||
if (select_std) {
|
||||
@@ -620,8 +620,8 @@ static void print_st_general_info(uint8_t *data, uint8_t len) {
|
||||
static void print_ct_general_info(void *vcard) {
|
||||
iso14b_cts_card_select_t card;
|
||||
memcpy(&card, (iso14b_cts_card_select_t *)vcard, sizeof(iso14b_cts_card_select_t));
|
||||
|
||||
uint32_t uid32 = (card.uid[0] |card.uid[1] << 8 |card.uid[2] << 16 | card.uid[3] << 24);
|
||||
|
||||
uint32_t uid32 = (card.uid[0] | card.uid[1] << 8 | card.uid[2] << 16 | card.uid[3] << 24);
|
||||
PrintAndLogEx(SUCCESS, "ASK C-Ticket");
|
||||
PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s") " ( " _YELLOW_("%010u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32);
|
||||
PrintAndLogEx(SUCCESS, " Product Code: %02X", card.pc);
|
||||
@@ -714,7 +714,7 @@ static int CmdHF14Binfo(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf 14b info",
|
||||
"Tag information for ISO/IEC 14443 type B based tags",
|
||||
"hf 14b info\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -940,7 +940,7 @@ static int CmdHF14BReader(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf 14b reader",
|
||||
"Act as a 14443B reader to identify a tag",
|
||||
"hf 14b reader\n"
|
||||
);
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -958,20 +958,20 @@ static int CmdHF14BReader(const char *Cmd) {
|
||||
* this command just dumps the contents of the memory/
|
||||
*/
|
||||
static int CmdHF14BReadSri(const char *Cmd) {
|
||||
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b sriread",
|
||||
"Read contents of a SRI512 | SRIX4K tag",
|
||||
"hf 14b sriread\n"
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
iso14b_card_select_t card;
|
||||
if (get_14b_UID(&card) == false) {
|
||||
PrintAndLogEx(WARNING, "no tag found");
|
||||
@@ -979,7 +979,7 @@ static int CmdHF14BReadSri(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (card.uidlen != 8) {
|
||||
PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags");
|
||||
PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1071,8 +1071,8 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||
"Tries to autodetect cardtype, memory size defaults to SRI4K",
|
||||
"hf 14b dump\n"
|
||||
"hf 14b dump -f myfilename\n"
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_strx0("f", "file", "<filename>", "(optional) filename, if no <name> UID will be used as filename"),
|
||||
@@ -1083,7 +1083,7 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||
int fnlen = 0;
|
||||
char filename[FILE_PATH_SIZE] = {0};
|
||||
char *fptr = filename;
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t*)filename, FILE_PATH_SIZE, &fnlen);
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
iso14b_card_select_t card;
|
||||
@@ -1091,9 +1091,9 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "no tag found");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (card.uidlen != 8) {
|
||||
PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags");
|
||||
PrintAndLogEx(FAILED, "current dump command only work with SRI4K / SRI512 tags");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1358,12 +1358,12 @@ static int select_card_14443b_4(bool disconnect, iso14b_card_select_t *card) {
|
||||
|
||||
// Anticollision + SELECT SR card
|
||||
SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0, NULL, 0);
|
||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) {
|
||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) {
|
||||
PrintAndLogEx(INFO, "Trying 14B Select CTS");
|
||||
|
||||
// Anticollision + SELECT ASK C-Ticket card
|
||||
SendCommandMIX(CMD_HF_ISO14443B_COMMAND, ISO14B_CONNECT | ISO14B_SELECT_CTS, 0, 0, NULL, 0);
|
||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) {
|
||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, TIMEOUT) == false) {
|
||||
PrintAndLogEx(ERR, "connection timeout");
|
||||
switch_off_field_14b();
|
||||
return PM3_ESOFT;
|
||||
@@ -1430,7 +1430,7 @@ static int handle_14b_apdu(bool chainingin, uint8_t *datain, int datainlen, bool
|
||||
if (dlen < 0) {
|
||||
dlen = 0;
|
||||
}
|
||||
|
||||
|
||||
*dataoutlen += dlen;
|
||||
|
||||
if (maxdataoutlen && *dataoutlen > maxdataoutlen) {
|
||||
@@ -1499,7 +1499,7 @@ static int exchange_14b_apdu(uint8_t *datain, int datainlen, bool activate_field
|
||||
// TODO check this one...
|
||||
// check R-block ACK
|
||||
// *dataoutlen!=0. 'A && (!A || B)' is equivalent to 'A && B'
|
||||
if ((*dataoutlen == 0) && (*dataoutlen != 0 || chaining != chainBlockNotLast)) {
|
||||
if ((*dataoutlen == 0) && (*dataoutlen != 0 || chaining != chainBlockNotLast)) {
|
||||
if (leave_signal_on == false) {
|
||||
switch_off_field_14b();
|
||||
}
|
||||
@@ -1638,11 +1638,11 @@ static int CmdHF14BAPDU(const char *Cmd) {
|
||||
CLIParserFree(ctx);
|
||||
|
||||
PrintAndLogEx(NORMAL, ">>>>[%s%s%s] %s",
|
||||
activate_field ? "sel" : "",
|
||||
leave_signal_on ? " keep" : "",
|
||||
decode_TLV ? " TLV" : "",
|
||||
sprint_hex(data, datalen)
|
||||
);
|
||||
activate_field ? "sel" : "",
|
||||
leave_signal_on ? " keep" : "",
|
||||
decode_TLV ? " TLV" : "",
|
||||
sprint_hex(data, datalen)
|
||||
);
|
||||
|
||||
if (decode_APDU) {
|
||||
APDUStruct apdu;
|
||||
@@ -1674,7 +1674,7 @@ static int CmdHF14BNdef(const char *Cmd) {
|
||||
CLIParserInit(&ctx, "hf 14b ndef",
|
||||
"Print NFC Data Exchange Format (NDEF)",
|
||||
"hf 14b ndef"
|
||||
);
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_param_end
|
||||
@@ -1764,7 +1764,7 @@ static int CmdHF14BNdef(const char *Cmd) {
|
||||
}
|
||||
|
||||
res = NDEFRecordsDecodeAndPrint(response + 2, resplen - 4);
|
||||
|
||||
|
||||
out:
|
||||
switch_off_field_14b();
|
||||
return res;
|
||||
@@ -1772,7 +1772,7 @@ out:
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||
{"apdu", CmdHF14BAPDU, IfPm3Iso14443b, "Send ISO 14443-4 APDU to tag"},
|
||||
{"apdu", CmdHF14BAPDU, IfPm3Iso14443b, "Send ISO 14443-4 APDU to tag"},
|
||||
{"dump", CmdHF14BDump, IfPm3Iso14443b, "Read all memory pages of an ISO14443-B tag, save to file"},
|
||||
{"info", CmdHF14Binfo, IfPm3Iso14443b, "Tag information"},
|
||||
{"list", CmdHF14BList, AlwaysAvailable, "List ISO 14443B history"},
|
||||
|
||||
@@ -253,14 +253,14 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||
session.history_path = NULL;
|
||||
} else {
|
||||
|
||||
# if defined(_WIN32)
|
||||
// SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true);
|
||||
# else
|
||||
# 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
|
||||
# endif
|
||||
rl_catch_signals = 1;
|
||||
rl_set_signals();
|
||||
read_history(session.history_path);
|
||||
|
||||
Reference in New Issue
Block a user