This commit is contained in:
iceman1001 committed 2024-01-25 01:55:07 +01:00
1 parent 9f015ad964
commit 414275802d
11 files changed
+93 -73

No files matched your search

+20 -20
View File
@@ -86,25 +86,25 @@ bool nfc3d_amiibo_unpack(const nfc3d_amiibo_keys_t *amiiboKeys, const uint8_t *t
nfc3d_amiibo_cipher(&dataKeys, internal, plain);
// Regenerate tag HMAC. Note: order matters, data HMAC depends on tag HMAC!
mbedtls_md_hmac( mbedtls_md_info_from_type(MBEDTLS_MD_SHA256)
, tagKeys.hmacKey
, sizeof(tagKeys.hmacKey)
, plain + 0x1D4
, 0x34
, plain + HMAC_POS_TAG
);
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256)
, tagKeys.hmacKey
, sizeof(tagKeys.hmacKey)
, plain + 0x1D4
, 0x34
, plain + HMAC_POS_TAG
);
// Regenerate data HMAC
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256)
, dataKeys.hmacKey
, sizeof(dataKeys.hmacKey)
, plain + 0x029
, 0x1DF
, plain + HMAC_POS_DATA
);
, dataKeys.hmacKey
, sizeof(dataKeys.hmacKey)
, plain + 0x029
, 0x1DF
, plain + HMAC_POS_DATA
);
return ((memcmp(plain + HMAC_POS_DATA, internal + HMAC_POS_DATA, 32) == 0) &&
(memcmp(plain + HMAC_POS_TAG, internal + HMAC_POS_TAG, 32) == 0));
(memcmp(plain + HMAC_POS_TAG, internal + HMAC_POS_TAG, 32) == 0));
}
void nfc3d_amiibo_pack(const nfc3d_amiibo_keys_t *amiiboKeys, const uint8_t *plain, uint8_t *tag) {
@@ -118,12 +118,12 @@ void nfc3d_amiibo_pack(const nfc3d_amiibo_keys_t *amiiboKeys, const uint8_t *pla
// Generate tag HMAC
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256)
, tagKeys.hmacKey
, sizeof(tagKeys.hmacKey)
, plain + 0x1D4
, 0x34
, cipher + HMAC_POS_TAG
);
, tagKeys.hmacKey
, sizeof(tagKeys.hmacKey)
, plain + 0x1D4
, 0x34
, cipher + HMAC_POS_TAG
);
// Init mbedtls HMAC context
mbedtls_md_context_t ctx;
+1 -1
View File
@@ -20,7 +20,7 @@ static void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys_t *baseKeys,
// 1: Copy whole type string
// output = (uint8_t *)strcpy((char *)output, baseKeys->typeString);
output = memccpy(output, baseKeys->typeString, '\0', sizeof(baseKeys->typeString));
output = memccpy(output, baseKeys->typeString, '\0', sizeof(baseKeys->typeString));
// 2: Append (16 - magicBytesSize) from the input seed
size_t leadingSeedBytes = 16 - baseKeys->magicBytesSize;
+8 -8
View File
@@ -1309,11 +1309,11 @@ static int mfu_dump_tag(uint16_t pages, void **pdata, uint16_t *len) {
}
// UL_EV1/NTAG auth
uint8_t keytype = 2;
uint8_t keytype = 2;
// generate PWD
uint8_t key[4] = {0};
num_to_bytes(ul_ev1_pwdgenB(card.uid), 4, key);
clearCommandBuffer();
SendCommandMIX(CMD_HF_MIFAREU_READCARD, 0, pages, keytype, key, 4);
PacketResponseNG resp;
@@ -4834,7 +4834,7 @@ static int CmdHF14AMfuList(const char *Cmd) {
return CmdTraceListAlias(Cmd, "hf 14a", "14a -c");
}
static int CmdHF14AAmiibo(const char *Cmd){
static int CmdHF14AAmiibo(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mfu amiibo",
@@ -4888,7 +4888,7 @@ static int CmdHF14AAmiibo(const char *Cmd){
// load dump file if available
if (infnlen > 0) {
uint8_t *dump = NULL;
size_t dumplen = 0;
size_t dumplen = 0;
res = loadFile_safe(infilename, "", (void **)&dump, &dumplen);
if (res != PM3_SUCCESS) {
free(dump);
@@ -4914,7 +4914,7 @@ static int CmdHF14AAmiibo(const char *Cmd){
} else {
uint16_t dlen = 0;
uint8_t *dump = NULL;
res = mfu_dump_tag( MAX_NTAG_215, (void **)&dump, &dlen);
res = mfu_dump_tag(MAX_NTAG_215, (void **)&dump, &dlen);
if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed to dump memory from tag");
free(dump);
@@ -4925,7 +4925,7 @@ static int CmdHF14AAmiibo(const char *Cmd){
}
uint8_t decrypted[NFC3D_AMIIBO_SIZE] = {0};
uint8_t decrypted[NFC3D_AMIIBO_SIZE] = {0};
if (shall_decrypt) {
if (nfc3d_amiibo_unpack(&amiibo_keys, original, decrypted) == false) {
PrintAndLogEx(INFO, "Tag signature ( " _RED_("fail") " )");
@@ -4933,7 +4933,7 @@ static int CmdHF14AAmiibo(const char *Cmd){
}
// print
if (verbose) {
for (uint8_t i = 0; i < (NFC3D_AMIIBO_SIZE / 16); i++ ) {
for (uint8_t i = 0; i < (NFC3D_AMIIBO_SIZE / 16); i++) {
PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex_ascii(decrypted + (i * 16), 16));
}
}
@@ -4944,7 +4944,7 @@ static int CmdHF14AAmiibo(const char *Cmd){
nfc3d_amiibo_pack(&amiibo_keys, decrypted, encrypted);
// print
if (verbose) {
for (uint8_t i = 0; i < (NFC3D_AMIIBO_SIZE / 16); i++ ) {
for (uint8_t i = 0; i < (NFC3D_AMIIBO_SIZE / 16); i++) {
PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex_ascii(encrypted + (i * 16), 16));
}
}
+18 -18
View File
@@ -544,10 +544,10 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
snprintf(path, sizeof(path), "$.blocks.%u", i);
JsonSaveBufAsHexCompact(root
, path
, &tag->data[i * tag->bytesPerPage]
, tag->bytesPerPage
);
, path
, &tag->data[i * tag->bytesPerPage]
, tag->bytesPerPage
);
}
break;
}
@@ -1691,13 +1691,13 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (sptr + 8 > maxdatalen) {
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen"
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
retval = PM3_EMALLOC;
goto out;
@@ -1735,13 +1735,13 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) {
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen"
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
retval = PM3_EMALLOC;
goto out;
+1
View File
@@ -423,6 +423,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf mfu sim" },
{ 0, "hf mfu setpwd" },
{ 0, "hf mfu setuid" },
{ 0, "hf mfu amiibo" },
{ 1, "hf mfdes help" },
{ 0, "hf mfdes info" },
{ 0, "hf mfdes getuid" },