This commit is contained in:
iceman1001 2025-01-14 18:20:55 +01:00
commit c32ef83812

View file

@ -117,8 +117,7 @@ static int create_cmac (uint8_t* key, uint8_t* input, uint8_t* out, int input_le
if (encryption_algorithm == 0x09) { if (encryption_algorithm == 0x09) {
// Working as expected // Working as expected
aes_cmac(iv, key, input, out, input_len); aes_cmac(iv, key, input, out, input_len);
} } else if (encryption_algorithm == 0x02) {
else if (encryption_algorithm == 0x02) {
// CMAC Requires a 24 byte key, but the 2k3DES uses the 1st part for the 3rd part of the key // CMAC Requires a 24 byte key, but the 2k3DES uses the 1st part for the 3rd part of the key
memcpy(&key[16], &key[0], 8); memcpy(&key[16], &key[0], 8);
@ -184,11 +183,9 @@ static void generate_command_wrapping(uint8_t *command_Header, int command_heade
if (encryption_algorithm == 0x02) { if (encryption_algorithm == 0x02) {
block_size = 8; block_size = 8;
} } else if (encryption_algorithm == 0x09) {
else if (encryption_algorithm == 0x09) {
block_size = 16; block_size = 16;
} } else {
else {
PrintAndLogEx(ERR, _RED_("Unknown Encryption Algorithm")); PrintAndLogEx(ERR, _RED_("Unknown Encryption Algorithm"));
return; return;
} }
@ -368,8 +365,7 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
PrintAndLogEx(SUCCESS, "Response Code.................... " _YELLOW_("%s"), sprint_hex_inrow(responseCode, (ARRAYLEN(responseCode)))); PrintAndLogEx(SUCCESS, "Response Code.................... " _YELLOW_("%s"), sprint_hex_inrow(responseCode, (ARRAYLEN(responseCode))));
PrintAndLogEx(SUCCESS, "Output........................... " _YELLOW_("%s"), sprint_hex_inrow(sioOutput, getDataSize)); PrintAndLogEx(SUCCESS, "Output........................... " _YELLOW_("%s"), sprint_hex_inrow(sioOutput, getDataSize));
} } else if (resplen >= 2 && response[0] == 0x99) {
else if (resplen >= 2 && response[0] == 0x99) {
memcpy(responseCode, response + 2, 2); memcpy(responseCode, response + 2, 2);
// PrintAndLogEx(SUCCESS, "Raw Response..................... " _YELLOW_("%s"), sprint_hex_inrow(response, (resplen - 2))); // PrintAndLogEx(SUCCESS, "Raw Response..................... " _YELLOW_("%s"), sprint_hex_inrow(response, (resplen - 2)));
PrintAndLogEx(SUCCESS, "Response Code.................... " _YELLOW_("%s"), sprint_hex_inrow(responseCode, (ARRAYLEN(responseCode)))); PrintAndLogEx(SUCCESS, "Response Code.................... " _YELLOW_("%s"), sprint_hex_inrow(responseCode, (ARRAYLEN(responseCode))));
@ -435,12 +431,10 @@ static void create_mutual_auth_key(uint8_t* KEYIFD, uint8_t* KEYICC, uint8_t* RN
sha1hash(hash_in, sizeof(hash_in), hashedOutput); sha1hash(hash_in, sizeof(hash_in), hashedOutput);
memcpy(output + 20, hashedOutput, 20); memcpy(output + 20, hashedOutput, 20);
//PrintAndLogEx(SUCCESS, "key_out_temp..................... " _YELLOW_("%s"), sprint_hex_inrow(hash_in,ARRAYLEN(hash_in))); //PrintAndLogEx(SUCCESS, "key_out_temp..................... " _YELLOW_("%s"), sprint_hex_inrow(hash_in,ARRAYLEN(hash_in)));
} } else if (HashingAlgorithm == 0x07) {
else if (HashingAlgorithm == 0x07) {
sha256hash(hash_in, sizeof(hash_in), hashedOutput); sha256hash(hash_in, sizeof(hash_in), hashedOutput);
memcpy(output, hashedOutput, 32); memcpy(output, hashedOutput, 32);
} } else {
else {
// Yes they generate their encryption keys and mac keys in a weird way for no fucking reason, the 2nd cycle isn't required. // Yes they generate their encryption keys and mac keys in a weird way for no fucking reason, the 2nd cycle isn't required.
PrintAndLogEx(ERR, _RED_("Unknown Hashing Algorithm")); PrintAndLogEx(ERR, _RED_("Unknown Hashing Algorithm"));
return; return;
@ -1271,8 +1265,7 @@ static int seos_print_keys(bool verbose) {
PrintAndLogEx(INFO, "Admin Key........................ " _YELLOW_("%s"), sprint_hex(keys[i].adminKey, 16)); PrintAndLogEx(INFO, "Admin Key........................ " _YELLOW_("%s"), sprint_hex(keys[i].adminKey, 16));
PrintAndLogEx(INFO, "----------------------------"); PrintAndLogEx(INFO, "----------------------------");
} }
} } else {
else {
PrintAndLogEx(INFO, "idx| key"); PrintAndLogEx(INFO, "idx| key");
PrintAndLogEx(INFO, "---+------------------------"); PrintAndLogEx(INFO, "---+------------------------");
for (uint8_t i = 0; i < ARRAYLEN(keys); i++) { for (uint8_t i = 0; i < ARRAYLEN(keys); i++) {
@ -1560,8 +1553,7 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
if (admin_len != 0) { if (admin_len != 0) {
PrintAndLogEx(SUCCESS, "Current value for Admin Key[%d] " _GREEN_("%s"), key_index, sprint_hex_inrow(keys[key_index].adminKey, 16)); PrintAndLogEx(SUCCESS, "Current value for Admin Key[%d] " _GREEN_("%s"), key_index, sprint_hex_inrow(keys[key_index].adminKey, 16));
} }
} } else {
else {
PrintAndLogEx(ERR, "Key index is out-of-range"); PrintAndLogEx(ERR, "Key index is out-of-range");
CLIParserFree(ctx); CLIParserFree(ctx);
return PM3_EINVARG; return PM3_EINVARG;