mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 11:39:14 -07:00
style
This commit is contained in:
parent
9f015ad964
commit
414275802d
11 changed files with 93 additions and 73 deletions
|
@ -2168,9 +2168,9 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
}
|
||||
|
||||
if ((tag->pagesCount > ISO15693_TAG_MAX_PAGES) ||
|
||||
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
|
||||
(tag->pagesCount == 0) ||
|
||||
(tag->bytesPerPage == 0)) {
|
||||
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
|
||||
(tag->pagesCount == 0) ||
|
||||
(tag->bytesPerPage == 0)) {
|
||||
Dbprintf("Tag size error: pagesCount = %d, bytesPerPage=%d", tag->pagesCount, tag->bytesPerPage);
|
||||
reply_ng(CMD_HF_ISO15693_SIMULATE, PM3_EOPABORTED, NULL, 0);
|
||||
return;
|
||||
|
@ -2182,17 +2182,17 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
|||
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("ISO-15963 Simulating uid: %02X%02X%02X%02X%02X%02X%02X%02X, %u bytes/blocks x %u blocks"
|
||||
, tag->uid[7]
|
||||
, tag->uid[6]
|
||||
, tag->uid[5]
|
||||
, tag->uid[4]
|
||||
, tag->uid[3]
|
||||
, tag->uid[2]
|
||||
, tag->uid[1]
|
||||
, tag->uid[0]
|
||||
, tag->bytesPerPage
|
||||
, tag->pagesCount
|
||||
);
|
||||
, tag->uid[7]
|
||||
, tag->uid[6]
|
||||
, tag->uid[5]
|
||||
, tag->uid[4]
|
||||
, tag->uid[3]
|
||||
, tag->uid[2]
|
||||
, tag->uid[1]
|
||||
, tag->uid[0]
|
||||
, tag->bytesPerPage
|
||||
, tag->pagesCount
|
||||
);
|
||||
}
|
||||
|
||||
LED_C_ON();
|
||||
|
|
|
@ -637,11 +637,11 @@ bool emlCheckValBl(int blockNum) {
|
|||
uint8_t *d = mem + (blockNum * 16);
|
||||
|
||||
if ((d[0] != (d[4] ^ 0xff)) || (d[0] != d[8]) ||
|
||||
(d[1] != (d[5] ^ 0xff)) || (d[1] != d[9]) ||
|
||||
(d[2] != (d[6] ^ 0xff)) || (d[2] != d[10]) ||
|
||||
(d[3] != (d[7] ^ 0xff)) || (d[3] != d[11]) ||
|
||||
(d[12] != (d[13] ^ 0xff)) || (d[12] != d[14]) ||
|
||||
(d[12] != (d[15] ^ 0xff))) {
|
||||
(d[1] != (d[5] ^ 0xff)) || (d[1] != d[9]) ||
|
||||
(d[2] != (d[6] ^ 0xff)) || (d[2] != d[10]) ||
|
||||
(d[3] != (d[7] ^ 0xff)) || (d[3] != d[11]) ||
|
||||
(d[12] != (d[13] ^ 0xff)) || (d[12] != d[14]) ||
|
||||
(d[12] != (d[15] ^ 0xff))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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" },
|
||||
|
|
|
@ -6668,6 +6668,24 @@
|
|||
],
|
||||
"usage": "hf mfp wrp [-hv] -a <hex> [-d <hex>]"
|
||||
},
|
||||
"hf mfu amiibo": {
|
||||
"command": "hf mfu amiibo",
|
||||
"description": "Tries to read all memory from amiibo tag and decrypt it",
|
||||
"notes": [
|
||||
"hf mfu amiiboo --dec -f hf-mfu-04579DB27C4880-dump.bin -> decrypt file",
|
||||
"hf mfu amiiboo -v --dec -> decrypt tag"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help This help",
|
||||
"--dec Decrypt memory",
|
||||
"--enc Encrypt memory",
|
||||
"-i, --in <fn> Specify a filename for input dump file",
|
||||
"-o, --out <fn> Specify a filename for output dump file",
|
||||
"-v, --verbose Verbose output"
|
||||
],
|
||||
"usage": "hf mfu amiibo [-hv] [--dec] [--enc] [-i <fn>] [-o <fn>]"
|
||||
},
|
||||
"hf mfu cauth": {
|
||||
"command": "hf mfu cauth",
|
||||
"description": "Tests 3DES password on Mifare Ultralight-C tag. If password is not specified, a set of known defaults will be tested.",
|
||||
|
@ -12336,8 +12354,8 @@
|
|||
}
|
||||
},
|
||||
"metadata": {
|
||||
"commands_extracted": 711,
|
||||
"commands_extracted": 712,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2024-01-24T17:12:09"
|
||||
"extracted_on": "2024-01-25T00:53:56"
|
||||
}
|
||||
}
|
|
@ -602,6 +602,7 @@ Check column "offline" for their availability.
|
|||
|`hf mfu sim `|N |`Simulate MIFARE Ultralight from emulator memory`
|
||||
|`hf mfu setpwd `|N |`Set 3DES key - Ultralight-C`
|
||||
|`hf mfu setuid `|N |`Set UID - MAGIC tags only`
|
||||
|`hf mfu amiibo `|N |`Amiibo tag operations`
|
||||
|
||||
|
||||
### hf mfdes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue