mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 12:59:44 -07:00
hf emv select
This commit is contained in:
parent
6d31653c44
commit
3668df05ec
2 changed files with 25 additions and 72 deletions
|
@ -19,6 +19,7 @@
|
||||||
#define arg_get_lit(n)(((struct arg_lit*)argtable[n])->count)
|
#define arg_get_lit(n)(((struct arg_lit*)argtable[n])->count)
|
||||||
#define arg_get_int(n)(((struct arg_int*)argtable[n])->ival[0])
|
#define arg_get_int(n)(((struct arg_int*)argtable[n])->ival[0])
|
||||||
#define arg_get_str(n)((struct arg_str*)argtable[n])
|
#define arg_get_str(n)((struct arg_str*)argtable[n])
|
||||||
|
#define arg_get_str_len(n)(strlen(((struct arg_int*)argtable[n])->ival[0]))
|
||||||
|
|
||||||
#define CLIExecWithReturn(cmd, atbl, ifempty) if (CLIParserParseString(cmd, atbl, arg_getsize(atbl), ifempty)){CLIParserFree();return 0;}
|
#define CLIExecWithReturn(cmd, atbl, ifempty) if (CLIParserParseString(cmd, atbl, arg_getsize(atbl), ifempty)){CLIParserFree();return 0;}
|
||||||
#define CLIGetStrBLessWithReturn(paramnum, data, datalen, delta) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data) - (delta), datalen)) {CLIParserFree();return 1;}
|
#define CLIGetStrBLessWithReturn(paramnum, data, datalen, delta) if (CLIParamHexToBuf(arg_get_str(paramnum), data, sizeof(data) - (delta), datalen)) {CLIParserFree();return 1;}
|
||||||
|
|
|
@ -30,67 +30,32 @@ int UsageCmdHFEMVSelect(void) {
|
||||||
int CmdHFEMVSelect(const char *cmd) {
|
int CmdHFEMVSelect(const char *cmd) {
|
||||||
uint8_t data[APDU_AID_LEN] = {0};
|
uint8_t data[APDU_AID_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
bool activateField = false;
|
|
||||||
bool leaveSignalON = false;
|
|
||||||
bool decodeTLV = false;
|
|
||||||
|
|
||||||
if (strlen(cmd) < 1) {
|
|
||||||
UsageCmdHFEMVSelect();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAPDULogging(false);
|
|
||||||
|
|
||||||
int cmdp = 0;
|
|
||||||
while(param_getchar(cmd, cmdp) != 0x00) {
|
|
||||||
char c = param_getchar(cmd, cmdp);
|
|
||||||
if ((c == '-') && (param_getlength(cmd, cmdp) == 2))
|
|
||||||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
|
||||||
case 'h':
|
|
||||||
case 'H':
|
|
||||||
UsageCmdHFEMVSelect();
|
|
||||||
return 0;
|
|
||||||
case 's':
|
|
||||||
case 'S':
|
|
||||||
activateField = true;
|
|
||||||
break;
|
|
||||||
case 'k':
|
|
||||||
case 'K':
|
|
||||||
leaveSignalON = true;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
case 'A':
|
|
||||||
SetAPDULogging(true);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
case 'T':
|
|
||||||
decodeTLV = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PrintAndLog("Unknown parameter '%c'", param_getchar_indx(cmd, 1, cmdp));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isxdigit((unsigned char)c)) {
|
|
||||||
switch(param_gethex_to_eol(cmd, cmdp, data, sizeof(data), &datalen)) {
|
|
||||||
case 1:
|
|
||||||
PrintAndLog("Invalid HEX value.");
|
|
||||||
return 1;
|
|
||||||
case 2:
|
|
||||||
PrintAndLog("AID too large.");
|
|
||||||
return 1;
|
|
||||||
case 3:
|
|
||||||
PrintAndLog("Hex must have even number of digits.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we get all the hex to end of line with spaces
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cmdp++;
|
CLIParserInit("hf 14a select",
|
||||||
}
|
"Executes select applet command",
|
||||||
|
"Usage:\n\thf emv select -s a00000000101 -> select card, select applet\n\thf emv select -s -t a00000000101 -> select card, select applet, show result in TLV\n");
|
||||||
|
|
||||||
|
void* argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_lit0("sS", "select", "activate field and select card"),
|
||||||
|
arg_lit0("kK", "keep", "keep field for next command"),
|
||||||
|
arg_lit0("aA", "apdu", "show APDU reqests and responses"),
|
||||||
|
arg_lit0("tT", "tlv", "TLV decode results"),
|
||||||
|
arg_str0(NULL, NULL, "<HEX applet AID>", NULL),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(cmd, argtable, true);
|
||||||
|
|
||||||
|
bool activateField = arg_get_lit(1);
|
||||||
|
bool leaveSignalON = arg_get_lit(2);
|
||||||
|
bool APDULogging = arg_get_lit(3);
|
||||||
|
bool decodeTLV = arg_get_lit(4);
|
||||||
|
if (arg_get_str_len(5))
|
||||||
|
CLIGetStrBLessWithReturn(5, data, &datalen, 0);
|
||||||
|
CLIParserFree();
|
||||||
|
|
||||||
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RES_LEN] = {0};
|
||||||
|
@ -110,20 +75,6 @@ int CmdHFEMVSelect(const char *cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UsageCmdHFEMVSearch(void) {
|
|
||||||
PrintAndLog("HELP : Tries to select all applets from applet list:\n");
|
|
||||||
PrintAndLog("Usage: hf emv search [-s][-k][-a][-t]\n");
|
|
||||||
PrintAndLog(" Options:");
|
|
||||||
PrintAndLog(" -s : select card");
|
|
||||||
PrintAndLog(" -k : keep field for next command");
|
|
||||||
PrintAndLog(" -a : show APDU reqests and responses\n");
|
|
||||||
PrintAndLog(" -t : TLV decode results of selected applets\n");
|
|
||||||
PrintAndLog("Samples:");
|
|
||||||
PrintAndLog(" hf emv search -s -> select card and search");
|
|
||||||
PrintAndLog(" hf emv search -s -t -> select card, search and show result in TLV");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CmdHFEMVSearch(const char *cmd) {
|
int CmdHFEMVSearch(const char *cmd) {
|
||||||
|
|
||||||
CLIParserInit("hf 14a select",
|
CLIParserInit("hf 14a select",
|
||||||
|
@ -144,6 +95,7 @@ int CmdHFEMVSearch(const char *cmd) {
|
||||||
bool leaveSignalON = arg_get_lit(2);
|
bool leaveSignalON = arg_get_lit(2);
|
||||||
bool APDULogging = arg_get_lit(3);
|
bool APDULogging = arg_get_lit(3);
|
||||||
bool decodeTLV = arg_get_lit(4);
|
bool decodeTLV = arg_get_lit(4);
|
||||||
|
CLIParserFree();
|
||||||
|
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue