Squashed commit of the following:

commit 8f77179a2f
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 11:25:38 2022 +0100

    remove unused file

commit bcafc5d03c
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 11:24:04 2022 +0100

    some historical copyright adjustments, thanks @iceman1001!

commit b703bb746b
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 02:19:46 2022 +0100

    Adapting license headers, WIP

commit 8952a1f712
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 00:37:34 2022 +0100

    adapt contributing text

commit cdfb83075f
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 00:24:15 2022 +0100

    toc

commit 014817f854
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Thu Jan 6 00:15:40 2022 +0100

    Adding AUTHORS and changing licensing terms from 'GPLv2 or later' to 'GPLv3 or later' to comply with components available only under 'GPLv3 or later'. Details:

    Initial releases by Jonathan Westhues in 2005-2007 were made under GPL
    "either version 2 of the License, or (at your option) any later version"

    Since then, a number of dependencies and files were integrated to the project, but under a "GPLv3 or later" license. These components are reveng, desfire_crypto and lrpcrypto. Note that compnents cryptorf, hitag2crack and fpga-xc3s100e are also under GPLv3+ but not bound to the firmware or client source code.

    Therefore, we must mechanically upgrade the license of the whole project to GPLv3+, as made possible by the initial licensing terms and as mandated by the inclusion of GPLv3+ code.

    Still to do: update each source file header:

        Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.

        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.

commit 5561466fe8
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Wed Jan 5 18:56:56 2022 +0100

    make style

commit 2d1a1dc034
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Wed Jan 5 17:57:49 2022 +0100

    make style doc/commands.json

commit fc53665e5c
Merge: a6d22ee43 c0cc09d86
Author: Philippe Teuwen <phil@teuwen.org>
Date:   Wed Jan 5 17:52:44 2022 +0100

    Merge pull request #1552 from joswr1ght/master

    Add --no-auth support for hf mfdes createapp

commit c0cc09d86b
Author: Joshua Wright <jwright@hasborg.com>
Date:   Wed Jan 5 07:12:20 2022 -0500

    Style consistency changes for hf mfdes createapp feature addition

commit f9c96f49da
Author: Joshua Wright <jwright@hasborg.com>
Date:   Tue Jan 4 17:01:10 2022 -0500

    Update CHANGELOG with MIFARE DESFire createapp --no-auth change

commit 859b55933d
Author: Joshua Wright <jwright@hasborg.com>
Date:   Tue Jan 4 15:55:26 2022 -0500

    Add --no-auth support for hf mfdes createapp
This commit is contained in:
Matt Moran 2022-01-07 01:08:55 +13:00
commit 14b6580fcb
165 changed files with 3023 additions and 2893 deletions

View file

@ -280,7 +280,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
HFiClassCalcDivKey(cc->csn, iClass_Key_Table[0], cc->key_d, false);
} else {
PrintAndLogEx(FAILED, "failed to read a card");
PrintAndLogEx(INFO,"falling back to default config card");
PrintAndLogEx(INFO, "falling back to default config card");
}
// generate dump file
@ -338,7 +338,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
if (Encrypt(ffs, ffs) == false) {
PrintAndLogEx(WARNING, "failed to encrypt FF");
} else {
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
}
// local key copy
@ -349,7 +349,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
if (Encrypt(lkey, enckey1) == false) {
PrintAndLogEx(WARNING, "failed to encrypt key1");
} else {
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
}
PrintAndLogEx(INFO, "Copy data... " NOLF);
@ -362,7 +362,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
for (uint8_t i = 0xD; i < 0x14; i++) {
memcpy(data + (i * 8), ffs, sizeof(ffs));
}
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted partial keyroll key 14
PrintAndLogEx(INFO, "Setting encrypted partial key14... " NOLF);
@ -373,7 +373,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
PrintAndLogEx(WARNING, "failed to encrypt partial 1");
}
memcpy(data + (0x14 * 8), enckey2, sizeof(enckey2));
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted partial keyroll key 15
@ -384,14 +384,14 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
PrintAndLogEx(WARNING, "failed to encrypt partial 2");
}
memcpy(data + (0x15 * 8), enckey2, sizeof(enckey2));
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// encrypted 0xFF
PrintAndLogEx(INFO, "Setting 0xFF's... " NOLF);
for (uint8_t i = 0x16; i <= app1_limit; i++) {
memcpy(data + (i * 8), ffs, sizeof(ffs));
}
PrintAndLogEx(NORMAL,"( " _GREEN_("ok") " )");
}
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
// revert potential modified app1_limit
cc->conf.app_limit = old_limit;
@ -541,7 +541,7 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
uint8_t app_areas = 2;
uint8_t books = 1;
uint8_t pages = 1;
getMemConfig(mem, chip, &app_areas, &kb, &books, &pages);
uint8_t type = get_mem_config(hdr);
@ -558,25 +558,25 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
}
PrintAndLogEx(INFO, " %u KBits/%u App Areas ( " _YELLOW_("%u") " bytes )"
, kb
, app_areas
, ((app2_limit + 1) * 8) * books * pages);
, kb
, app_areas
, ((app2_limit + 1) * 8) * books * pages);
PrintAndLogEx(INFO, " %u books / %u pages"
, books
, pages
);
, books
, pages
);
PrintAndLogEx(INFO, " First book / first page configuration");
PrintAndLogEx(INFO, " Config | 0 - 5 ( 0x00 - 0x05 ) - 6 blocks ");
PrintAndLogEx(INFO, " AA1 | 6 - %2d ( 0x06 - 0x%02X ) - %u blocks", app1_limit + 5, app1_limit + 5, app1_limit);
if (app1_limit + 5 < app2_limit ) {
if (app1_limit + 5 < app2_limit) {
PrintAndLogEx(INFO, " AA2 | %2d - %2d ( 0x%02X - 0x%02X ) - %u blocks", app1_limit + 5 + 1, app2_limit, app1_limit + 5 + 1, app2_limit, app2_limit - app1_limit);
}
/*
[=] 32 KBits/3 App Areas ( 2048 bytes )
[=] AA1 blocks 250 { 0x06 - 0xFF (06 - 255) }
[=] AA2 blocks 5 { 0x100 - 0xFF (256 - 255) }
*/
/*
[=] 32 KBits/3 App Areas ( 2048 bytes )
[=] AA1 blocks 250 { 0x06 - 0xFF (06 - 255) }
[=] AA2 blocks 5 { 0x100 - 0xFF (256 - 255) }
*/
PrintAndLogEx(INFO, "------------------------- " _CYAN_("KeyAccess") " ------------------------");
PrintAndLogEx(INFO, " * Kd, Debit key, AA1 Kc, Credit key, AA2 *");
@ -898,7 +898,7 @@ static int CmdHFiClassInfo(const char *Cmd) {
int read_iclass_csn(bool loop, bool verbose) {
iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
};
int res = PM3_SUCCESS;
@ -906,11 +906,11 @@ int read_iclass_csn(bool loop, bool verbose) {
do {
clearCommandBuffer();
PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t));
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000)) {
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes;
iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
if (loop) {
if (resp.status == PM3_ERFTRANS) {
continue;
@ -1537,7 +1537,7 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
} else {
iclass_encrypt_block_data(blk_data, key);
}
PrintAndLogEx(SUCCESS, "encrypted... " _YELLOW_("%s"), sprint_hex_inrow(blk_data, sizeof(blk_data)));
return PM3_SUCCESS;
}
@ -1545,19 +1545,19 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool verbose) {
iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
};
clearCommandBuffer();
PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t));
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
PrintAndLogEx(WARNING, "command execute timeout");
return false;
}
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes;
iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
picopass_hdr_t *hdr = &r->header.hdr;
// no tag found or button pressed
@ -1700,11 +1700,11 @@ static int CmdHFiClassDump(const char *Cmd) {
iclass_card_select_t payload_rdr = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
};
clearCommandBuffer();
PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload_rdr, sizeof(iclass_card_select_t));
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload_rdr, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
PrintAndLogEx(WARNING, "command execute timeout");
@ -1719,7 +1719,7 @@ static int CmdHFiClassDump(const char *Cmd) {
return PM3_ESOFT;
}
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes;
iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
if (r->status == FLAG_ICLASS_NULL) {
PrintAndLogEx(FAILED, "failed to read block 0,1,2");
return PM3_ESOFT;
@ -4038,11 +4038,11 @@ int CmdHFiClass(const char *Cmd) {
int info_iclass(void) {
iclass_card_select_t payload = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
};
clearCommandBuffer();
PacketResponseNG resp;
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t*)&payload, sizeof(iclass_card_select_t));
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload, sizeof(iclass_card_select_t));
if (WaitForResponseTimeout(CMD_HF_ICLASS_READER, &resp, 2000) == false) {
DropField();
@ -4050,7 +4050,7 @@ int info_iclass(void) {
}
DropField();
iclass_card_select_resp_t *r = (iclass_card_select_resp_t*)resp.data.asBytes;
iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
// no tag found or button pressed
if (r->status == FLAG_ICLASS_NULL || resp.status == PM3_ERFTRANS) {
@ -4093,7 +4093,7 @@ int info_iclass(void) {
} else {
PrintAndLogEx(SUCCESS, " Kc: %s credit key ( hidden )", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
}
if ((r->status & FLAG_ICLASS_AIA) == FLAG_ICLASS_AIA) {
PrintAndLogEx(SUCCESS, " AIA: %s application issuer area", sprint_hex(hdr->app_issuer_area, sizeof(hdr->app_issuer_area)));

View file

@ -2369,6 +2369,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
arg_str0(NULL, "ks2", "<key settings HEX>", "Key settings 2 (HEX 1 byte). default 0x0e"),
arg_str0(NULL, "dstalgo", "<DES/2TDEA/3TDEA/AES>", "Application key crypt algo: DES, 2TDEA, 3TDEA, AES. default DES"),
arg_int0(NULL, "numkeys", "<number of keys>", "Keys count. 0x00..0x0e. default 0x0e"),
arg_lit0(NULL, "no-auth", "execute without authentication"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -2420,6 +2421,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
}
int keycount = arg_get_int_def(ctx, 18, 0x0e);
bool noauth = arg_get_lit(ctx, 19);
SetAPDULogging(APDULogging);
CLIParserFree(ctx);
@ -2444,7 +2446,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) {
return PM3_EINVARG;
}
res = DesfireSelectAndAuthenticate(&dctx, securechann, 0x000000, verbose);
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, 0x000000, noauth, verbose);
if (res != PM3_SUCCESS) {
DropField();
return res;

View file

@ -30,12 +30,12 @@ typedef enum {Scramble = 0, Descramble = 1} KeriMSScramble_t;
static int CmdKeriMSScramble(KeriMSScramble_t Action, uint32_t *FC, uint32_t *ID, uint32_t *CardID) {
// 255 = Not used/Unknown other values are the bit offset in the ID/FC values
const uint8_t CardToID [] = { 255, 255, 255, 255, 13, 12, 20, 5, 16, 6, 21, 17, 8, 255, 0, 7,
10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255
};
10, 15, 255, 11, 4, 1, 255, 18, 255, 19, 2, 14, 3, 9, 255, 255
};
const uint8_t CardToFC [] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255,
255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255
};
255, 255, 2, 255, 255, 255, 3, 255, 4, 255, 255, 255, 255, 255, 1, 255
};
uint8_t card_idx; // 0 - 31