mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
make style and (c)
This commit is contained in:
parent
f1b81da975
commit
8ae01aa180
|
@ -4843,7 +4843,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
uint8_t trkey[250] = {0};
|
||||
int trkeylen = sizeof(trkey);
|
||||
CLIGetHexWithReturn(ctx, 23, trkey, &trkeylen);
|
||||
|
@ -4860,7 +4860,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
PrintAndLogEx(ERR, "File number range is invalid (exp 0 - 31), got %d", fnum);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
// get uid
|
||||
if (trkeylen > 0)
|
||||
DesfireGetCardUID(&dctx);
|
||||
|
@ -4947,7 +4947,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "GetFileSettings error. Can't get file type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CommitReaderID command
|
||||
bool readeridpushed = false;
|
||||
if (readeridlen > 0) {
|
||||
|
@ -4962,24 +4962,24 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
if (res == PM3_SUCCESS) {
|
||||
PrintAndLogEx(INFO, _GREEN_("Commit Reader ID: "));
|
||||
PrintAndLogEx(INFO, "Prev reader id encoded [%d]: %s", resplen, sprint_hex(resp, resplen));
|
||||
|
||||
|
||||
if (trkeylen > 0) {
|
||||
uint8_t sessionkey[16] = {0};
|
||||
uint8_t uid[7] = {0};
|
||||
memcpy(uid, dctx.uid, MAX(dctx.uidlen, 7));
|
||||
DesfireGenTransSessionKey(trkey, transactionCounter, uid, false, sessionkey);
|
||||
|
||||
|
||||
aes_decode(NULL, sessionkey, resp, resp, CRYPTO_AES_BLOCK_SIZE);
|
||||
PrintAndLogEx(INFO, "Prev reader id [%d]: %s", resplen, sprint_hex(resp, resplen));
|
||||
}
|
||||
|
||||
|
||||
readeridpushed = true;
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "CommitReaderID " _GREEN_("OK"));
|
||||
} else
|
||||
PrintAndLogEx(WARNING, "Desfire CommitReaderID command " _RED_("error") ". Result: %d", res);
|
||||
}
|
||||
|
||||
|
||||
// write
|
||||
if (op == RFTData) {
|
||||
res = DesfireWriteFile(&dctx, fnum, offset, datalen, data);
|
||||
|
@ -5061,7 +5061,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "TMC and TMV[%d]: %s", resplen, sprint_hex(resp, resplen));
|
||||
PrintAndLogEx(INFO, "Commit " _GREEN_("OK"));
|
||||
}
|
||||
|
||||
|
||||
if (resplen == 4 + 8) {
|
||||
PrintAndLogEx(INFO, _GREEN_("Commit result:"));
|
||||
uint32_t cnt = MemLeToUint4byte(&resp[0]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018 Merlok
|
||||
// Copyright (C) 2018, 2021 Merlok
|
||||
// Copyright (C) 2018 drHatson
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2018 Merlok
|
||||
// Copyright (C) 2018, 2021 Merlok
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
|
|
|
@ -2437,7 +2437,7 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len)
|
|||
PrintAndLogEx(SUCCESS, "Access rights : %04x", MemLeToUint2byte(&data[xlen]));
|
||||
DesfirePrintAccessRight(&data[xlen]);
|
||||
xlen += 2;
|
||||
|
||||
|
||||
// https://www.nxp.com/docs/en/data-sheet/MF2DLHX0.pdf
|
||||
// page 14
|
||||
// TransactionMAC file
|
||||
|
@ -2449,7 +2449,7 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len)
|
|||
DesfireDecodeFileAcessMode(&data[xlen - 2], &read, &write, &readwrite, &change);
|
||||
if (write != 0x0f)
|
||||
PrintAndLogEx(WARNING, "descr. : Write right should be set to F because write " _RED_("not allowed") ".");
|
||||
|
||||
|
||||
if (readwrite == 0x0f)
|
||||
PrintAndLogEx(SUCCESS, "descr. : ReadWrite right is %01X, CommitReaderID command disabled", readwrite);
|
||||
else if (readwrite == 0x0e)
|
||||
|
|
|
@ -623,7 +623,7 @@ int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t d
|
|||
// page 42
|
||||
void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool forMAC, uint8_t *sessionkey) {
|
||||
uint8_t xiv[CRYPTO_AES_BLOCK_SIZE] = {0};
|
||||
|
||||
|
||||
if (forMAC) {
|
||||
xiv[0] = 0x5a;
|
||||
} else {
|
||||
|
@ -633,7 +633,7 @@ void DesfireGenTransSessionKey(uint8_t *key, uint32_t trCntr, uint8_t *uid, bool
|
|||
xiv[4] = 0x80;
|
||||
Uint4byteToMemLe(&xiv[5], trCntr + 1);
|
||||
memcpy(&xiv[9], uid, 7);
|
||||
|
||||
|
||||
DesfireContext ctx = {0};
|
||||
DesfireSetKey(&ctx, 0, T_AES, key);
|
||||
DesfireCryptoCMACEx(&ctx, DCOMainKey, xiv, 16, 0, sessionkey);
|
||||
|
|
|
@ -452,11 +452,11 @@ static bool TestEV2MAC(void) {
|
|||
|
||||
static bool TestTransSessionKeys(void) {
|
||||
bool res = true;
|
||||
|
||||
|
||||
uint8_t key[] = {0x66, 0xA8, 0xCB, 0x93, 0x26, 0x9D, 0xC9, 0xBC, 0x28, 0x85, 0xB7, 0xA9, 0x1B, 0x9C, 0x69, 0x7B};
|
||||
uint8_t uid[] = {0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
|
||||
uint32_t trCntr = 8;
|
||||
|
||||
|
||||
uint8_t sessionkey[16] = {0};
|
||||
DesfireGenTransSessionKey(key, trCntr, uid, true, sessionkey);
|
||||
uint8_t keymac[] = {0x7C, 0x1A, 0xD2, 0xD9, 0xC5, 0xC0, 0x81, 0x54, 0xA0, 0xA4, 0x91, 0x4B, 0x40, 0x1A, 0x65, 0x98};
|
||||
|
@ -465,7 +465,7 @@ static bool TestTransSessionKeys(void) {
|
|||
DesfireGenTransSessionKey(key, trCntr, uid, false, sessionkey);
|
||||
uint8_t keyenc[] = {0x11, 0x9B, 0x90, 0x2A, 0x07, 0xB1, 0x8A, 0x86, 0x5B, 0x8E, 0x1B, 0x00, 0x60, 0x59, 0x47, 0x84};
|
||||
res = res && (memcmp(sessionkey, keyenc, sizeof(keyenc)) == 0);
|
||||
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "Trans session key. " _GREEN_("passed"));
|
||||
else
|
||||
|
|
|
@ -973,7 +973,7 @@
|
|||
},
|
||||
"help": {
|
||||
"command": "help",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210812.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210813.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"notes": [
|
||||
"auto"
|
||||
],
|
||||
|
@ -4241,7 +4241,9 @@
|
|||
"notes": [
|
||||
"--rawrights have priority over the separate rights settings.",
|
||||
"key/mode/etc of the authentication depends on application settings",
|
||||
"hf mfdes createmacfile --aid 123456 --fid 01 --mackey --rawrights 1f30 00112233445566778899aabbccddeeff --mackeyver 01 -> create transaction mac file with parameters. rights from default. authentication with defaults from `default` command",
|
||||
"write right should be always 0xf. read-write right should be 0xf if you not need to submit commitreaderid command each time transaction starts",
|
||||
"",
|
||||
"hf mfdes createmacfile --aid 123456 --fid 01 --rawrights 0ff0 --mackey 00112233445566778899aabbccddeeff --mackeyver 01 -> create transaction mac file with parameters. rights from default. authentication with defaults from `default` command",
|
||||
"hf mfdes createmacfile --aid 123456 --fid 01 --amode plain --rrights free --wrights deny --rwrights free --chrights key0 --mackey 00112233445566778899aabbccddeeff -> create file app=123456, file=01, with key, and mentioned rights with defaults from `default` command",
|
||||
"hf mfdes createmacfile -n 0 -t des -k 0000000000000000 -f none --aid 123456 --fid 01 -> execute with default factory setup. key and keyver == 0x00..00"
|
||||
],
|
||||
|
@ -4934,7 +4936,7 @@
|
|||
},
|
||||
"hf mfdes test": {
|
||||
"command": "hf mfdes test",
|
||||
"description": "[=] ------ desfire tests ------ [!] no space for crc. pos: 1 [=] crc16............. passed [!] no space for crc. pos: 2 [=] crc32............. passed [=] cmac subkeys...... passed [=] an10922 aes....... passed [=] an10922 2tdea..... passed [=] an10922 3tdea..... passed [=] cmac 3tdea........ passed [=] cmac 2tdea........ passed [=] cmac des.......... passed [=] ev2 session keys.. passed [=] ev2 iv calc....... passed [=] ev2 mac calc...... passed [=] --------------------------- [+] tests [ ok ] ======================================================================================= hf seos { seos rfids... } --------------------------------------------------------------------------------------- hf seos help available offline: yes help this help list list seos history --------------------------------------------------------------------------------------- hf seos info available offline: no get info from seos tags",
|
||||
"description": "[=] ------ desfire tests ------ [!] no space for crc. pos: 1 [=] crc16............. passed [!] no space for crc. pos: 2 [=] crc32............. passed [=] cmac subkeys...... passed [=] an10922 aes....... passed [=] an10922 2tdea..... passed [=] an10922 3tdea..... passed [=] cmac 3tdea........ passed [=] cmac 2tdea........ passed [=] cmac des.......... passed [=] ev2 session keys.. passed [=] ev2 iv calc....... passed [=] ev2 mac calc...... passed [=] trans session key. passed [=] --------------------------- [+] tests [ ok ] ======================================================================================= hf seos { seos rfids... } --------------------------------------------------------------------------------------- hf seos help available offline: yes help this help list list seos history --------------------------------------------------------------------------------------- hf seos info available offline: no get info from seos tags",
|
||||
"notes": [
|
||||
"hf seos info"
|
||||
],
|
||||
|
@ -4977,17 +4979,20 @@
|
|||
"command": "hf mfdes write",
|
||||
"description": "write data from file. key needs to be provided or flag --no-auth set (depend on file settings).",
|
||||
"notes": [
|
||||
"in the mode with commitreaderid to decode previous reader id command needs to read transaction counter via dump/read command and specify --trkey",
|
||||
"",
|
||||
"hf mfdes write --aid 123456 --fid 01 -d 01020304 -> write file: app=123456, file=01, offset=0, get file type from card. use default channel settings from `default` command",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type data -d 01020304 --0ffset 000100 -> write data to std file with offset 0x100",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type data -d 01020304 --commit -> write data to backup file with commit",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type value -d 00000001 -> increment value file",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type value -d 00000001 --debit -> decrement value file",
|
||||
"hf mfdes write --aid 123456 --fid 01 -d 01020304 -> write data to record file with `auto` type",
|
||||
"hf mfdes write --aid 123456 --fid 01 -d 01020304 -> write data to file with `auto` type",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type record -d 01020304 -> write data to record file",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type record -d 01020304 --updaterec 0 -> update record in the record file. record 0 - lastest record.",
|
||||
"hf mfdes write --aid 123456 --fid 01 --type record --offset 000000 -d 11223344 -> write record to record file. use default channel settings from `default` command",
|
||||
"hf mfdes write --appisoid 1234 --fileisoid 1000 --type data -c iso -d 01020304 -> write data to std/backup file via iso commandset",
|
||||
"hf mfdes write --appisoid 1234 --fileisoid 2000 --type record -c iso -d 01020304 -> aend record to record file via iso commandset"
|
||||
"hf mfdes write --appisoid 1234 --fileisoid 2000 --type record -c iso -d 01020304 -> aend record to record file via iso commandset",
|
||||
"hf mfdes write --aid 123456 --fid 01 -d 01020304 --readerid 010203 -> write data to file with commitreaderid command before write and committransaction after write"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
|
@ -5012,9 +5017,11 @@
|
|||
"--commit commit needs for backup file only. for the other file types and in the `auto` mode - command set it automatically.",
|
||||
"--updaterec <record number dec> record number for update record command. updates record instead of write. lastest record - 0",
|
||||
"--appisoid <isoid hex> application iso id (iso df id) (2 hex bytes, big endian). works only for iso read commands.",
|
||||
"--fileisoid <isoid hex> file iso id (iso df id) (2 hex bytes, big endian). works only for iso read commands."
|
||||
"--fileisoid <isoid hex> file iso id (iso df id) (2 hex bytes, big endian). works only for iso read commands.",
|
||||
"--readerid <hex> reader id for commitreaderid command. if present - the command issued before write command.",
|
||||
"--trkey <hex> key for decode previous reader id."
|
||||
],
|
||||
"usage": "hf mfdes write [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--fid <file id hex>] [--no-auth] [--type <auto/data/value/record/mac>] [-o <hex>] [-d <hex>] [--debit] [--commit] [--updaterec <record number dec>] [--appisoid <isoid hex>] [--fileisoid <isoid hex>]"
|
||||
"usage": "hf mfdes write [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--fid <file id hex>] [--no-auth] [--type <auto/data/value/record/mac>] [-o <hex>] [-d <hex>] [--debit] [--commit] [--updaterec <record number dec>] [--appisoid <isoid hex>] [--fileisoid <isoid hex>] [--readerid <hex>] [--trkey <hex>]"
|
||||
},
|
||||
"hf mfp auth": {
|
||||
"command": "hf mfp auth",
|
||||
|
@ -9952,6 +9959,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 589,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2021-08-12T13:03:40"
|
||||
"extracted_on": "2021-08-13T09:38:47"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue