This commit is contained in:
iceman1001 2019-04-07 16:30:02 +02:00
parent 0ffe2a4700
commit 03b44b324b

View file

@ -61,8 +61,8 @@ int CmdHFEPACollectPACENonces(const char *Cmd) {
// perform the PACE protocol by replaying APDUs // perform the PACE protocol by replaying APDUs
int CmdHFEPAPACEReplay(const char *Cmd) { int CmdHFEPAPACEReplay(const char *Cmd) {
// the 4 APDUs which are replayed + their lengths // the 4 APDUs which are replayed + their lengths
uint8_t msesa_apdu[41], gn_apdu[8], map_apdu[75]; uint8_t msesa_apdu[41] = {0}, gn_apdu[8] = {0}, map_apdu[75] = {0};
uint8_t pka_apdu[75], ma_apdu[18], apdu_lengths[5] = {0}; uint8_t pka_apdu[75] = {0}, ma_apdu[18] = {0}, apdu_lengths[5] = {0};
// pointers to the arrays to be able to iterate // pointers to the arrays to be able to iterate
uint8_t *apdus[] = {msesa_apdu, gn_apdu, map_apdu, pka_apdu, ma_apdu}; uint8_t *apdus[] = {msesa_apdu, gn_apdu, map_apdu, pka_apdu, ma_apdu};
@ -74,15 +74,18 @@ int CmdHFEPAPACEReplay(const char *Cmd) {
// Proxmark response // Proxmark response
UsbCommand resp; UsbCommand resp;
int skip = 0, skip_add = 0, scan_return = 0; int skip = 0, skip_add = 0, scan_return;
// for each APDU // for each APDU
for (int i = 0; i < sizeof(apdu_lengths); i++) { for (int i = 0; i < sizeof(apdu_lengths); i++) {
// scan to next space or end of string // scan to next space or end of string
while (Cmd[skip] != ' ' && Cmd[skip] != '\0') { while (Cmd[skip] != ' ' && Cmd[skip] != '\0') {
// convert // convert
scan_return = sscanf(Cmd + skip, "%2X%n", scan_return = sscanf(Cmd + skip,
"%2X%n",
(unsigned int *)(apdus[i] + apdu_lengths[i]), (unsigned int *)(apdus[i] + apdu_lengths[i]),
&skip_add); &skip_add
);
if (scan_return < 1) { if (scan_return < 1) {
PrintAndLogEx(NORMAL, (char *)usage_msg); PrintAndLogEx(NORMAL, (char *)usage_msg);
PrintAndLogEx(WARNING, "Not enough APDUs! Try again!"); PrintAndLogEx(WARNING, "Not enough APDUs! Try again!");