This commit is contained in:
Chris 2019-02-25 22:34:30 +01:00
commit 8f05aa6fcf
5 changed files with 25 additions and 14 deletions

View file

@ -758,14 +758,14 @@ int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph
// //
int hi = 0, idx = 0; int hi = 0, idx = 0;
int distance = 0, hi_1 = 0, idx_1 = 0; int distance = 0, hi_1 = 0, idx_1 = 0;
for (int i=0; i<=len; ++i){ for (int i = 0; i <= len; ++i){
if ( CorrelBuffer[i] > hi) { if ( CorrelBuffer[i] > hi) {
hi = CorrelBuffer[i]; hi = CorrelBuffer[i];
idx = i; idx = i;
} }
} }
for (int i=idx+1; i<=window; ++i){ for (int i = idx+1; i <= window; ++i){
if ( CorrelBuffer[i] > hi_1 ) { if ( CorrelBuffer[i] > hi_1 ) {
hi_1 = CorrelBuffer[i]; hi_1 = CorrelBuffer[i];
idx_1 = i; idx_1 = i;
@ -773,7 +773,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph
} }
int foo = ABS(hi-hi_1); int foo = ABS(hi-hi_1);
int bar = ((int)(((hi+hi_1) / 2) * 0.03)); int bar = (int)(((hi+hi_1) / 2) * 0.03);
if ( verbose && foo < bar ) { if ( verbose && foo < bar ) {
distance = idx_1 - idx; distance = idx_1 - idx;
PrintAndLogEx(SUCCESS, "possible 3% visible correlation %4d samples", distance); PrintAndLogEx(SUCCESS, "possible 3% visible correlation %4d samples", distance);

View file

@ -277,7 +277,8 @@ uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t tracelen) {
uint32_t regB = trace[7] | trace[8] << 8 | trace[9] << 16 | trace[10] << 24; uint32_t regB = trace[7] | trace[8] << 8 | trace[9] << 16 | trace[10] << 24;
line[0] = 0; line[0] = 0;
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
snprintf(line+( j * 2), sizeof(line)-1-(j*2), "%02x", trace[j+11]); snprintf(line + (j*2), sizeof(line)-1-(j*2), "%02x", trace[j+11]);
PrintAndLogEx(NORMAL, "REG: regA: %d regB: %d regC: %s ", regA, regB, line); PrintAndLogEx(NORMAL, "REG: regA: %d regB: %d regC: %s ", regA, regB, line);
} }
break; break;
@ -287,10 +288,10 @@ uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t tracelen) {
char idd[20]; char idd[20];
char idm[20]; char idm[20];
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
snprintf(idd + (j * 2), sizeof(idd) - 1 - (j*2), "%02x", trace[j+3]); snprintf(idd + (j*2), sizeof(idd)-1-(j*2), "%02x", trace[j+3]);
for (int j = 0; j < 6; j++) for (int j = 0; j < 6; j++)
snprintf(idm + (j * 2), sizeof(idm) - 1 - (j*2), "%02x", trace[j+13]); snprintf(idm + (j*2), sizeof(idm)-1-(j*2), "%02x", trace[j+13]);
PrintAndLogEx(NORMAL, "ID Block, IDd: 0x%s DFC: 0x%02x%02x Arb: %s ", idd, trace[11], trace [12], idm); PrintAndLogEx(NORMAL, "ID Block, IDd: 0x%s DFC: 0x%02x%02x Arb: %s ", idd, trace[11], trace [12], idm);
} }
@ -299,10 +300,10 @@ uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t tracelen) {
char idm[20]; char idm[20];
char pmm[20]; char pmm[20];
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
snprintf(idm + (j * 2), 20, "%02x", trace[j+3]); snprintf(idm + (j*2), sizeof(idm)-1-(j*2), "%02x", trace[j+3]);
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
snprintf(pmm + (j * 2), 20, "%02x", trace[j+11]); snprintf(pmm + (j*2), sizeof(pmm)-1-(j*2), "%02x", trace[j+11]);
PrintAndLogEx(NORMAL, "DeviceId: IDm: 0x%s PMm: 0x%s ", idm, pmm); PrintAndLogEx(NORMAL, "DeviceId: IDm: 0x%s PMm: 0x%s ", idm, pmm);
} }

View file

@ -8,3 +8,4 @@ AEA684A6DAB23278 -- AA1
5b7c62c491c11b39 -- from loclass demo file. 5b7c62c491c11b39 -- from loclass demo file.
F0E1D2C3B4A59687 -- Kd from PicoPass 2k documentation F0E1D2C3B4A59687 -- Kd from PicoPass 2k documentation
5CBCF1DA45D5FB4F -- PicoPass Default Exchange Key 5CBCF1DA45D5FB4F -- PicoPass Default Exchange Key
31ad7ebd2f282168 -- From HID multiclassSE reader

View file

@ -253,6 +253,7 @@ int CmdEMVGPO(const char *cmd) {
// calc PDOL // calc PDOL
struct tlv *pdol_data_tlv = NULL; struct tlv *pdol_data_tlv = NULL;
struct tlvdb *tmp_ext = NULL;
struct tlv data_tlv = { struct tlv data_tlv = {
.tag = 0x83, .tag = 0x83,
.len = datalen, .len = datalen,
@ -266,7 +267,7 @@ int CmdEMVGPO(const char *cmd) {
ParamLoadFromJson(tlvRoot); ParamLoadFromJson(tlvRoot);
}; };
struct tlvdb *tmp_ext = tlvdb_external(0x9f38, datalen, data); tmp_ext = tlvdb_external(0x9f38, datalen, data);
pdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x83); pdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x83);
if (!pdol_data_tlv){ if (!pdol_data_tlv){
PrintAndLogEx(ERR, "Can't create PDOL TLV."); PrintAndLogEx(ERR, "Can't create PDOL TLV.");
@ -285,8 +286,8 @@ int CmdEMVGPO(const char *cmd) {
unsigned char *pdol_data_tlv_data = tlv_encode(pdol_data_tlv, &pdol_data_tlv_data_len); unsigned char *pdol_data_tlv_data = tlv_encode(pdol_data_tlv, &pdol_data_tlv_data_len);
if (!pdol_data_tlv_data) { if (!pdol_data_tlv_data) {
PrintAndLogEx(ERR, "Can't create PDOL data."); PrintAndLogEx(ERR, "Can't create PDOL data.");
tlvdb_free(tmp_ext);
tlvdb_free(tlvRoot); tlvdb_free(tlvRoot);
free(pdol_data_tlv);
return 4; return 4;
} }
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len)); PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
@ -299,7 +300,8 @@ int CmdEMVGPO(const char *cmd) {
if (pdol_data_tlv != &data_tlv) if (pdol_data_tlv != &data_tlv)
free(pdol_data_tlv); free(pdol_data_tlv);
tlvdb_free(tmp_ext);
tlvdb_free(tlvRoot); tlvdb_free(tlvRoot);
if (sw) if (sw)
@ -434,6 +436,7 @@ int CmdEMVAC(const char *cmd) {
// calc CDOL // calc CDOL
struct tlv *cdol_data_tlv = NULL; struct tlv *cdol_data_tlv = NULL;
struct tlvdb *tmp_ext = NULL;
struct tlv data_tlv = { struct tlv data_tlv = {
.tag = 0x01, .tag = 0x01,
.len = datalen, .len = datalen,
@ -448,7 +451,7 @@ int CmdEMVAC(const char *cmd) {
ParamLoadFromJson(tlvRoot); ParamLoadFromJson(tlvRoot);
}; };
struct tlvdb *tmp_ext = tlvdb_external(0x8c, datalen, data); tmp_ext = tlvdb_external(0x8c, datalen, data);
cdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag cdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
if (!cdol_data_tlv){ if (!cdol_data_tlv){
PrintAndLogEx(ERR, "Can't create CDOL TLV."); PrintAndLogEx(ERR, "Can't create CDOL TLV.");
@ -473,6 +476,8 @@ int CmdEMVAC(const char *cmd) {
if (cdol_data_tlv != &data_tlv) if (cdol_data_tlv != &data_tlv)
free(cdol_data_tlv); free(cdol_data_tlv);
tlvdb_free(tmp_ext);
tlvdb_free(tlvRoot); tlvdb_free(tlvRoot);
if (sw) if (sw)
@ -578,6 +583,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
// calc DDOL // calc DDOL
struct tlv *ddol_data_tlv = NULL; struct tlv *ddol_data_tlv = NULL;
struct tlvdb *tmp_ext = NULL;
struct tlv data_tlv = { struct tlv data_tlv = {
.tag = 0x01, .tag = 0x01,
.len = datalen, .len = datalen,
@ -592,7 +598,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
ParamLoadFromJson(tlvRoot); ParamLoadFromJson(tlvRoot);
}; };
struct tlvdb *tmp_ext = tlvdb_external(0x9f49, datalen, data); tmp_ext = tlvdb_external(0x9f49, datalen, data);
ddol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag ddol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
if (!ddol_data_tlv){ if (!ddol_data_tlv){
PrintAndLogEx(ERR, "Can't create DDOL TLV."); PrintAndLogEx(ERR, "Can't create DDOL TLV.");
@ -617,6 +623,8 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
if (ddol_data_tlv != &data_tlv) if (ddol_data_tlv != &data_tlv)
free(ddol_data_tlv); free(ddol_data_tlv);
tlvdb_free(tmp_ext);
tlvdb_free(tlvRoot); tlvdb_free(tlvRoot);
if (sw) if (sw)

View file

@ -259,7 +259,8 @@ bool HexToBuffer(const char *errormsg, const char *hexvalue, uint8_t * buffer, s
return false; return false;
} }
*bufferlen = buflen; if ( bufferlen )
*bufferlen = buflen;
return true; return true;
} }