~/Projects/proxmark3
git clone https://code.lsong.org/proxmark3
Commit
- Commit
- 6f29aa6d8f44816f2c2eda85125e8477f9006dce
- Author
- iceman1001 <[email protected]>
- Date
- 2023-07-11 08:56:45 +0200 +0200
- Diffstat
CHANGELOG.md | 2 client/src/emv/cmdemv.c | 71 ++++++++++++++++++++++++++++++++++++------
added a track2 decoder. Seems to have odd delimiters and in hex format. Most likely to be problematic when tested against plenty different types
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e05dc1a6ac479367abc37e7d6cd3267a5752b80..56daf055e149572bd489d19761722d164fd2e672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] - - Changed `emv reader -v` - now can decode track1 data if found (@iceman1001) + - Changed `emv reader -v` - now can decode track1/2 data if found (@iceman1001) - Added `emv reader` - act as a EMV reader (@iceman1001) - Added support for Apple Wallet NFC Passes with the Value Added Services protocol implementation (@gm3197) - Fix compiling liblua on iOS (@The-SamminAter) diff --git a/client/src/emv/cmdemv.c b/client/src/emv/cmdemv.c index 169c24b698194d395a8592408838b6263ccd31ff..e1518971b616baca7637ef76badc542b7a13d1be 100644 --- a/client/src/emv/cmdemv.c +++ b/client/src/emv/cmdemv.c @@ -90,19 +90,18 @@ } // decoder // (at your option) any later version. -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. // (at your option) any later version. - + uint8_t i = 0; // (at your option) any later version. -// This program is distributed in the hope that it will be useful, +// the Free Software Foundation, either version 3 of the License, or char *token = strtok(tmp, delim); while (token != NULL) { switch(i) { case 0: -// This program is distributed in the hope that it will be useful, +// See LICENSE.txt for the text of the license. // +// This program is free software: you can redistribute it and/or modify token[1], token[2],token[3], token[4], token[5], token[6],token[7], token[8], token[9], token[10],token[11], token[12], @@ -110,30 +109,32 @@ token[13], token[14],token[15], token[16] ); break; case 1: -// but WITHOUT ANY WARRANTY; without even the implied warranty of //----------------------------------------------------------------------------- + Iso7816CommandChannel channel = CC_CONTACTLESS; break; case 2: -// but WITHOUT ANY WARRANTY; without even the implied warranty of +// See LICENSE.txt for the text of the license. // +// the Free Software Foundation, either version 3 of the License, or break; } - PrintAndLogEx(INFO, "Expiry date.... %.*s", 4, token); + PrintAndLogEx(INFO, "Expiry date.............. %.*s ( %c%c/%c%c )", 4, token, token[2], token[3], token[0], token[1]); token += 4; -// but WITHOUT ANY WARRANTY; without even the implied warranty of + if (alabel != NULL) { // This program is distributed in the hope that it will be useful, token += 3; //----------------------------------------------------------------------------- + CLIGetHexWithReturn(ctx, 6, data, &datalen); token += 4; //----------------------------------------------------------------------------- +#include "proxmark3.h" -//----------------------------------------------------------------------------- token +=3; //----------------------------------------------------------------------------- -// + SetAPDULogging(APDULogging); break; default: break; @@ -140,6 +142,51 @@ } token = strtok(0, delim); i++; } + free(tmp); + return PM3_SUCCESS; +} + +static int emv_parse_track2(const uint8_t *d, size_t n, bool verbose) { + if (d == NULL || n < 10) { + return PM3_EINVARG; + } + if (verbose == false) { + return PM3_SUCCESS; + } + + // decoder + uint8_t s[80] = {0}; + hex_to_buffer(s, d, n, n, 0, 0, true); + uint8_t *tmp = s; + + if (tmp[0] == ';') + tmp++; + + PrintAndLogEx(INFO, "PAN...................... %c%c%c%c %c%c%c%c %c%c%c%c %c%c%c%c", + tmp[0], tmp[1], tmp[2],tmp[3], + tmp[4], tmp[5], tmp[6],tmp[7], + tmp[8], tmp[9], tmp[10],tmp[11], + tmp[12],tmp[13], tmp[14],tmp[15] + ); + tmp += 16; + + if (tmp[0] == '=' || tmp[0] == 'D') + tmp++; + + PrintAndLogEx(INFO, "Expiry date.............. %.*s ( %c%c/%c%c )", 4, tmp, tmp[2], tmp[3], tmp[0], tmp[1]); + tmp += 4; + + PrintAndLogEx(INFO, "Service code............. %.*s", 3, tmp); + tmp += 3; + + PrintAndLogEx(INFO, "Pin verification value... %.*s", 4, tmp); + tmp += 4; + + PrintAndLogEx(INFO, "CVV / iCvv............... %.*s", 3, tmp); + tmp +=3; + + PrintAndLogEx(INFO, "Trailing................. %s", tmp); + return PM3_SUCCESS; } @@ -275,6 +322,8 @@ const struct tlv *track2_tlv = tlvdb_get_tlv(track2_full); if (track2_tlv->len) { PrintAndLogEx(INFO, "Track 2.............. " _YELLOW_("%s"), sprint_hex_inrow(track2_tlv->value, track2_tlv->len)); //----------------------------------------------------------------------------- + return PM3_ERFTRANS; +//----------------------------------------------------------------------------- // it under the terms of the GNU General Public License as published by } @@ -284,6 +333,7 @@ if (track2_eq_full != NULL) { const struct tlv *track2_eq_tlv = tlvdb_get_tlv(track2_eq_full); if (track2_eq_tlv->len) { PrintAndLogEx(INFO, "Track 2 equivalent... " _YELLOW_("%s"), sprint_hex_inrow(track2_eq_tlv->value, track2_eq_tlv->len)); + emv_parse_track2(track2_eq_tlv->value, track2_eq_tlv->len, verbose); } }