hf telsa info - better text, also added detection of the gauss key applet

This commit is contained in:
iceman1001 2023-01-23 03:26:51 +01:00
commit 6d12f0281a

View file

@ -64,26 +64,36 @@ static int info_hf_tesla(void) {
param_gethex_to_eol("00a404000a7465736c614c6f676963", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n); param_gethex_to_eol("00a404000a7465736c614c6f676963", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n);
int res = ExchangeAPDU14a(aSELECT_AID, aSELECT_AID_n, activate_field, keep_field_on, response, sizeof(response), &resplen); int res = ExchangeAPDU14a(aSELECT_AID, aSELECT_AID_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
DropField();
return res;
}
if (resplen < 2) {
DropField();
return PM3_ESOFT;
}
uint16_t sw = get_sw(response, resplen);
if (sw != ISO7816_OK) {
PrintAndLogEx(ERR, "Selecting TESLA aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
DropField(); DropField();
return PM3_ESOFT; return PM3_ESOFT;
} }
activate_field = false; activate_field = false;
uint16_t sw = get_sw(response, resplen);
if ((resplen < 2) || (sw != ISO7816_OK)) {
param_gethex_to_eol("00a404000af465736c614c6f676963", 0, aSELECT_AID, sizeof(aSELECT_AID), &aSELECT_AID_n);
res = ExchangeAPDU14a(aSELECT_AID, aSELECT_AID_n, activate_field, keep_field_on, response, sizeof(response), &resplen);
if (res != PM3_SUCCESS) {
DropField();
return res;
}
}
if ((resplen < 2) || (sw != ISO7816_OK)) {
PrintAndLogEx(ERR, "Selecting TESLA aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff));
// DropField();
// return PM3_ESOFT;
}
keep_field_on = true; keep_field_on = true;
// --------------- ECDH public key file reading ---------------- // --------------- ECDH public key file reading ----------------
uint8_t pk[3][65] = {{0}};
for (uint8_t i = 0; i < 3; i++) { for (uint8_t i = 0; i < 3; i++) {
uint8_t aSELECT_PK[5] = {0x80, 0x04, i, 0x00, 0x00}; uint8_t aSELECT_PK[5] = {0x80, 0x04, i, 0x00, 0x00};
@ -94,12 +104,7 @@ static int info_hf_tesla(void) {
sw = get_sw(response, resplen); sw = get_sw(response, resplen);
if (sw == ISO7816_OK) { if (sw == ISO7816_OK) {
// save PK for later memcpy(pk[i], response, resplen - 2);
uint8_t pk[65] = {0};
memcpy(pk, response, resplen - 2);
PrintAndLogEx(INFO, "PUBLIC KEY # %i", i);
PrintAndLogEx(INFO, "%s", sprint_hex_inrow(pk, sizeof(pk)));
} }
} }
@ -194,13 +199,16 @@ static int info_hf_tesla(void) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ---------------------------"); PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ---------------------------");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
// PrintAndLogEx(INFO, "PUBLIC KEY"); PrintAndLogEx(INFO, "PUBLIC KEY");
// PrintAndLogEx(INFO, "%zu - %s", sizeof(pk), sprint_hex_inrow(pk, sizeof(pk))); for (int i=0; i < 3; i++) {
PrintAndLogEx(INFO, "Form factor"); PrintAndLogEx(INFO, "%d - %s", i, sprint_hex_inrow(pk[i], 65));
PrintAndLogEx(INFO, "%zu - %s", sizeof(form_factor), sprint_hex_inrow(form_factor, sizeof(form_factor))); }
PrintAndLogEx(INFO, "VERSION"); PrintAndLogEx(INFO, "Form factor... %s", sprint_hex_inrow(form_factor, sizeof(form_factor)));
PrintAndLogEx(INFO, "%zu - %s", sizeof(version), sprint_hex_inrow(version, sizeof(version))); PrintAndLogEx(INFO, "Version....... %s", sprint_hex_inrow(version, sizeof(version)));
if ((memcmp(pk[0], pk[1], 65) == 0)) {
PrintAndLogEx(INFO, "GaussKey detected");
}
return PM3_SUCCESS; return PM3_SUCCESS;
} }