mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
chg:
This commit is contained in:
parent
c0f91ddd09
commit
5f87b24493
2 changed files with 83 additions and 66 deletions
|
@ -1,6 +1,6 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2017 Merlok
|
||||
//
|
||||
// modified 2017 iceman
|
||||
// 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.
|
||||
|
@ -12,8 +12,8 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
int UsageCmdHFEMVSelect(void) {
|
||||
PrintAndLog("HELP : Executes select applet command:\n");
|
||||
int usage_emv_select(void) {
|
||||
PrintAndLog("Executes select applet command:\n");
|
||||
PrintAndLog("Usage: hf emv select [-s][-k][-a][-t] <HEX applet AID>\n");
|
||||
PrintAndLog(" Options:");
|
||||
PrintAndLog(" -s : select card");
|
||||
|
@ -33,10 +33,8 @@ int CmdHFEMVSelect(const char *cmd) {
|
|||
bool leaveSignalON = false;
|
||||
bool decodeTLV = false;
|
||||
|
||||
if (strlen(cmd) < 1) {
|
||||
UsageCmdHFEMVSelect();
|
||||
return 0;
|
||||
}
|
||||
if (strlen(cmd) < 1)
|
||||
return usage_emv_select();
|
||||
|
||||
SetAPDULogging(false);
|
||||
|
||||
|
@ -47,8 +45,7 @@ int CmdHFEMVSelect(const char *cmd) {
|
|||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
UsageCmdHFEMVSelect();
|
||||
return 0;
|
||||
return usage_emv_select();
|
||||
case 's':
|
||||
case 'S':
|
||||
activateField = true;
|
||||
|
@ -86,8 +83,6 @@ int CmdHFEMVSelect(const char *cmd) {
|
|||
// we get all the hex to end of line with spaces
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
cmdp++;
|
||||
}
|
||||
|
||||
|
@ -109,8 +104,8 @@ int CmdHFEMVSelect(const char *cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int UsageCmdHFEMVSearch(void) {
|
||||
PrintAndLog("HELP : Tries to select all applets from applet list:\n");
|
||||
int usage_emv_search(void) {
|
||||
PrintAndLog("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");
|
||||
|
@ -129,10 +124,8 @@ int CmdHFEMVSearch(const char *cmd) {
|
|||
bool leaveSignalON = false;
|
||||
bool decodeTLV = false;
|
||||
|
||||
if (strlen(cmd) < 1) {
|
||||
UsageCmdHFEMVSearch();
|
||||
return 0;
|
||||
}
|
||||
if (strlen(cmd) < 1)
|
||||
return usage_emv_search();
|
||||
|
||||
SetAPDULogging(false);
|
||||
|
||||
|
@ -143,8 +136,7 @@ int CmdHFEMVSearch(const char *cmd) {
|
|||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
UsageCmdHFEMVSearch();
|
||||
return 0;
|
||||
return usage_emv_search();
|
||||
case 's':
|
||||
case 'S':
|
||||
activateField = true;
|
||||
|
@ -189,8 +181,8 @@ int CmdHFEMVSearch(const char *cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int UsageCmdHFEMVPPSE(void) {
|
||||
PrintAndLog("HELP : Executes PSE/PPSE select command. It returns list of applet on the card:\n");
|
||||
int usage_emv_ppse(void) {
|
||||
PrintAndLog("Executes PSE/PPSE select command. It returns list of applet on the card:\n");
|
||||
PrintAndLog("Usage: hf emv pse [-s][-k][-1][-2][-a][-t]\n");
|
||||
PrintAndLog(" Options:");
|
||||
PrintAndLog(" -s : select card");
|
||||
|
@ -213,10 +205,8 @@ int CmdHFEMVPPSE(const char *cmd) {
|
|||
bool leaveSignalON = false;
|
||||
bool decodeTLV = false;
|
||||
|
||||
if (strlen(cmd) < 1) {
|
||||
UsageCmdHFEMVPPSE();
|
||||
return 0;
|
||||
}
|
||||
if (strlen(cmd) < 1)
|
||||
return usage_emv_ppse();
|
||||
|
||||
SetAPDULogging(false);
|
||||
|
||||
|
@ -227,8 +217,7 @@ int CmdHFEMVPPSE(const char *cmd) {
|
|||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
UsageCmdHFEMVPPSE();
|
||||
return 0;
|
||||
return usage_emv_ppse();
|
||||
case 's':
|
||||
case 'S':
|
||||
activateField = true;
|
||||
|
@ -270,15 +259,14 @@ int CmdHFEMVPPSE(const char *cmd) {
|
|||
if (res)
|
||||
return res;
|
||||
|
||||
|
||||
if (decodeTLV)
|
||||
TLVPrintFromBuffer(buf, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UsageCmdHFEMVExec(void) {
|
||||
PrintAndLog("HELP : Executes EMV contactless transaction:\n");
|
||||
int usage_emv_exec(void) {
|
||||
PrintAndLog("Executes EMV contactless transaction:\n");
|
||||
PrintAndLog("Usage: hf emv exec [-s][-a][-t]\n");
|
||||
PrintAndLog(" Options:");
|
||||
PrintAndLog(" -s : select card");
|
||||
|
@ -310,10 +298,8 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
|
||||
int res;
|
||||
|
||||
if (strlen(cmd) < 1) {
|
||||
UsageCmdHFEMVExec();
|
||||
return 0;
|
||||
}
|
||||
if (strlen(cmd) < 1)
|
||||
return usage_emv_exec();
|
||||
|
||||
int cmdp = 0;
|
||||
while(param_getchar(cmd, cmdp) != 0x00) {
|
||||
|
@ -322,8 +308,7 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
UsageCmdHFEMVExec();
|
||||
return 0;
|
||||
return usage_emv_exec();
|
||||
case 's':
|
||||
case 'S':
|
||||
activateField = true;
|
||||
|
@ -359,7 +344,6 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
cmdp++;
|
||||
}
|
||||
|
||||
|
||||
// init applets list tree
|
||||
struct tlvdb *tlvSelect = NULL;
|
||||
const char *al = "Applets list";
|
||||
|
@ -417,8 +401,8 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
|
||||
if (decodeTLV)
|
||||
TLVPrintFromBuffer(buf, len);
|
||||
PrintAndLog("* Selected.");
|
||||
|
||||
PrintAndLog("* Selected.");
|
||||
PrintAndLog("\n* Init transaction parameters.");
|
||||
|
||||
//9F66:(Terminal Transaction Qualifiers (TTQ)) len:4
|
||||
|
@ -531,9 +515,9 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
|
||||
PrintAndLog("\n* Read records from AFL.");
|
||||
const struct tlv *AFL = tlvdb_get(tlvRoot, 0x94, NULL);
|
||||
if (!AFL || !AFL->len) {
|
||||
|
||||
if (!AFL || !AFL->len)
|
||||
PrintAndLog("WARNING: AFL not found.");
|
||||
}
|
||||
|
||||
while (AFL && AFL->len) {
|
||||
if (AFL->len % 4) {
|
||||
|
@ -573,7 +557,6 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -591,9 +574,7 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
// DDA
|
||||
if (AIP & 0x0020) {
|
||||
PrintAndLog("\n* DDA");
|
||||
|
||||
}
|
||||
|
||||
// transaction check
|
||||
|
||||
// qVSDC
|
||||
|
@ -760,14 +741,12 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
TLVPrintFromBuffer(buf, len);
|
||||
PrintAndLog("");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("ERROR MSD: Track2 data not found.");
|
||||
}
|
||||
}
|
||||
|
||||
// DropField
|
||||
DropField();
|
||||
|
||||
// Destroy TLV's
|
||||
|
@ -775,16 +754,47 @@ int CmdHFEMVExec(const char *cmd) {
|
|||
tlvdb_free(tlvRoot);
|
||||
|
||||
PrintAndLog("\n* Transaction completed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usage_emv_getrnd(void){
|
||||
PrintAndLog("retrieve the UN number from a terminal");
|
||||
PrintAndLog("Usage: hf emv getrnd [h]");
|
||||
PrintAndLog("Options:");
|
||||
PrintAndLog(" h : this help");
|
||||
PrintAndLog("");
|
||||
PrintAndLog("Samples:");
|
||||
PrintAndLog(" hf emv getrnd");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//retrieve the UN number from a terminal
|
||||
int CmdHfEMVGetrng(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if ( cmdp == 'h' || cmdp == 'H') return usage_emv_getrnd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHfEMVList(const char *Cmd) {
|
||||
return CmdHFList("7816");
|
||||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"exec", CmdHFEMVExec, 0, "Executes EMV contactless transaction."},
|
||||
{"pse", CmdHFEMVPPSE, 0, "Execute PPSE. It selects 2PAY.SYS.DDF01 or 1PAY.SYS.DDF01 directory."},
|
||||
{"search", CmdHFEMVSearch, 0, "Try to select all applets from applets list and print installed applets."},
|
||||
{"select", CmdHFEMVSelect, 0, "Select applet."},
|
||||
|
||||
/*
|
||||
{"getrng", CmdHfEMVGetrng, 0, "get random number from terminal"},
|
||||
{"eload", CmdHfEmvELoad, 0, "load EMV tag into device"},
|
||||
{"dump", CmdHfEmvDump, 0, "dump EMV tag values"},
|
||||
{"sim", CmdHfEmvSim, 0, "simulate EMV tag"},
|
||||
{"clone", CmdHfEmvClone, 0, "clone an EMV tag"},
|
||||
*/
|
||||
{"list", CmdHfEMVList, 0, "[Deprecated] List ISO7816 history"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2017 Merlok
|
||||
//
|
||||
// modified 2017 iceman
|
||||
// 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.
|
||||
|
@ -26,8 +26,15 @@
|
|||
#include "emvcore.h"
|
||||
#include "apduinfo.h"
|
||||
|
||||
int CmdHFEMV(const char *Cmd);
|
||||
|
||||
#define TLV_ADD(tag, value)( tlvdb_add(tlvRoot, tlvdb_fixed(tag, sizeof(value) - 1, (const unsigned char *)value)) )
|
||||
|
||||
int CmdHFEMV(const char *Cmd);
|
||||
|
||||
extern int CmdHFEMVSelect(const char *cmd);
|
||||
extern int CmdHFEMVSearch(const char *cmd);
|
||||
extern int CmdHFEMVPPSE(const char *cmd);
|
||||
extern int CmdHFEMVExec(const char *cmd);
|
||||
extern int CmdHfEMVGetrng(const char *Cmd);
|
||||
extern int CmdHfEMVList(const char *Cmd);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue