From 239a8646b221b33c262fa32c9929f4627414cfaf Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 22 Jan 2023 15:38:09 +0000 Subject: [PATCH 01/30] Fix the wrong sample count when bps!=8 --- armsrc/lfsampling.c | 4 +++- client/src/cmddata.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index a1ff37356..3844976e1 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -296,7 +296,9 @@ void LFSetupFPGAForADC(int divisor, bool reader_field) { uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, int16_t trigger_threshold, bool verbose, uint32_t sample_size, uint32_t cancel_after, int32_t samples_to_skip, bool ledcontrol) { - initSampleBuffer(&sample_size); + initSampleBuffer(&sample_size); // sample size in bytes + sample_size <<= 3; // sample size in bits + sample_size /= bits_per_sample; // sample count if (g_dbglevel >= DBG_DEBUG) { printSamples(); diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 647c062a4..1ebd4b432 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -1779,7 +1779,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose, bool ignore_lf_conf BitstreamOut_t bout = { got, bits_per_sample * n, 0}; uint32_t j = 0; - for (j = 0; j * bits_per_sample < n * 8 && j < n; j++) { + for (j = 0; j * bits_per_sample < n * 8 && j * bits_per_sample < MAX_GRAPH_TRACE_LEN * 8; j++) { uint8_t sample = getByte(bits_per_sample, &bout); g_GraphBuffer[j] = ((int) sample) - 127; } From f4879fdc172f43bf965a29f2420f7c42030e895c Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 22 Jan 2023 15:41:07 +0000 Subject: [PATCH 02/30] Bypass some functions if bps is not 8 --- armsrc/lfsampling.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index 3844976e1..e716fa248 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -370,8 +370,12 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in } // Ensure that DC offset removal and noise check is performed for any device-side processing - removeSignalOffset(data.buffer, samples.total_saved); - computeSignalProperties(data.buffer, samples.total_saved); + if (bits_per_sample == 8) + { + // these functions only consider bps==8 + removeSignalOffset(data.buffer, samples.total_saved); + computeSignalProperties(data.buffer, samples.total_saved); + } return data.numbits; } /** From 8218762e86fa9774bd6d4190f350d0f8bea5c5c3 Mon Sep 17 00:00:00 2001 From: Self Not Found Date: Mon, 23 Jan 2023 00:16:29 +0800 Subject: [PATCH 03/30] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97fa48f5d..978caa8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `trace list -c` - annotation of CRC bytes now is colored or squared if no ansi colors is supported (@iceman1001) - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - Fixed `make accessrights` on Fedora (@mooey5775) + - Fixed the lf sampling when bits_per_sample is less than 8 (@wh201906) ## [Radium.4.15864][2022-10-29] - Changed `lf indala sim` - now accepts fc / cn (@iceman1001) From 37ec19fdbf63e197af5214825537d460a540c8e4 Mon Sep 17 00:00:00 2001 From: mjacksn Date: Sun, 22 Jan 2023 23:27:09 -0600 Subject: [PATCH 04/30] Correct some parsing of the "get nxp system information" data. I believe that these changes bring it in line with the SLIX "GET NXP SYSTEM INFOMATION" data format (as retrieved from SLIX2 datasheet page 33) --- client/src/cmdhf15.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index c35df7238..d6d933b4b 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -700,14 +700,14 @@ static int NxpSysInfo(uint8_t *uid) { } bool support_signature = (recv[5] & 0x01); - bool support_easmode = (recv[4] & 0x03); + bool support_easmode = (recv[4] & 0x04); PrintAndLogEx(INFO, "--------- " _CYAN_("NXP Sysinfo") " ---------"); PrintAndLogEx(INFO, " raw : %s", sprint_hex(recv, 8)); PrintAndLogEx(INFO, " Password protection configuration:"); PrintAndLogEx(INFO, " * Page L read%s password protected", ((recv[2] & 0x01) ? "" : " not")); PrintAndLogEx(INFO, " * Page L write%s password protected", ((recv[2] & 0x02) ? "" : " not")); - PrintAndLogEx(INFO, " * Page H read%s password protected", ((recv[2] & 0x08) ? "" : " not")); + PrintAndLogEx(INFO, " * Page H read%s password protected", ((recv[2] & 0x10) ? "" : " not")); PrintAndLogEx(INFO, " * Page H write%s password protected", ((recv[2] & 0x20) ? "" : " not")); PrintAndLogEx(INFO, " Lock bits:"); @@ -720,16 +720,16 @@ static int NxpSysInfo(uint8_t *uid) { PrintAndLogEx(INFO, " * User memory password protection%s supported", ((recv[4] & 0x01) ? "" : " not")); PrintAndLogEx(INFO, " * Counter feature%s supported", ((recv[4] & 0x02) ? "" : " not")); PrintAndLogEx(INFO, " * EAS ID%s supported by EAS ALARM command", support_easmode ? "" : " not"); - PrintAndLogEx(INFO, " * EAS password protection%s supported", ((recv[4] & 0x04) ? "" : " not")); + PrintAndLogEx(INFO, " * EAS password protection%s supported", ((recv[4] & 0x08) ? "" : " not")); PrintAndLogEx(INFO, " * AFI password protection%s supported", ((recv[4] & 0x10) ? "" : " not")); PrintAndLogEx(INFO, " * Extended mode%s supported by INVENTORY READ command", ((recv[4] & 0x20) ? "" : " not")); PrintAndLogEx(INFO, " * EAS selection%s supported by extended mode in INVENTORY READ command", ((recv[4] & 0x40) ? "" : " not")); PrintAndLogEx(INFO, " * READ SIGNATURE command%s supported", support_signature ? "" : " not"); PrintAndLogEx(INFO, " * Password protection for READ SIGNATURE command%s supported", ((recv[5] & 0x02) ? "" : " not")); - PrintAndLogEx(INFO, " * STAY QUIET PERSISTENT command%s supported", ((recv[5] & 0x03) ? "" : " not")); + PrintAndLogEx(INFO, " * STAY QUIET PERSISTENT command%s supported", ((recv[5] & 0x04) ? "" : " not")); PrintAndLogEx(INFO, " * ENABLE PRIVACY command%s supported", ((recv[5] & 0x10) ? "" : " not")); PrintAndLogEx(INFO, " * DESTROY command%s supported", ((recv[5] & 0x20) ? "" : " not")); - PrintAndLogEx(INFO, " * Additional 32 bits feature flags are%s transmitted", ((recv[5] & 0x80) ? "" : " not")); + PrintAndLogEx(INFO, " * Additional 32 bits feature flags are%s transmitted", ((recv[7] & 0x80) ? "" : " not")); if (support_easmode) { reqlen = 0; From c33ce8f3936dd5f00a960e772ecb474a0b8c1698 Mon Sep 17 00:00:00 2001 From: mjacksn Date: Mon, 23 Jan 2023 10:52:47 -0600 Subject: [PATCH 05/30] changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cde2d93..c046f0094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1363,6 +1363,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Mifare simulation, `hf mf sim` (was broken a long time) (@pwpiwi) - Major improvements in LF area and data operations. (@marshmellow42, @iceman1001) - Issues regarding LF simulation (@pwpiwi) + - Issue interpreting NXP "get sys info" command return value for icode tags. (@mjacksn) ### Added - iClass functionality: full simulation of iclass tags, so tags can be simulated with data (not only CSN). Not yet support for write/update, but readers do not seem to enforce update. (@holiman). From da84eb62064db6387d7424f4974d2d8e46934ed5 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 23 Jan 2023 20:41:00 +0100 Subject: [PATCH 06/30] proper way --- Makefile.platform.sample | 2 +- client/src/cmdhw.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.platform.sample b/Makefile.platform.sample index 5dc19e8f0..bfcb5b749 100644 --- a/Makefile.platform.sample +++ b/Makefile.platform.sample @@ -5,7 +5,7 @@ PLATFORM=PM3RDV4 #PLATFORM=PM3GENERIC # If you want more than one PLATFORM_EXTRAS option, separate them by spaces: #PLATFORM_EXTRAS=BTADDON -#STANDALONE=LF_SAMYRUN +STANDALONE=HF_BOG # To accelerate repetitive compilations: # Install package "ccache" -> Debian/Ubuntu: /usr/lib/ccache, Fedora/CentOS/RHEL: /usr/lib64/ccache diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 0efa5eafe..b3f80e218 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -1202,7 +1202,7 @@ void pm3_version_short(void) { } } - PrintAndLogEx(NORMAL, " Target.... %s", (is_genuine_rdv4) ? _YELLOW_("RDV4") : _RED_("device / fw mismatch")); + PrintAndLogEx(NORMAL, " Target.... %s", (is_genuine_rdv4) ? _YELLOW_("RDV4") : _YELLOW_("PM3 GENERIC")); } else { PrintAndLogEx(NORMAL, " Target.... %s", _YELLOW_("PM3 GENERIC")); } @@ -1291,8 +1291,8 @@ void pm3_version(bool verbose, bool oneliner) { } } - PrintAndLogEx(NORMAL, " device.................... %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _RED_("device / fw mismatch")); - PrintAndLogEx(NORMAL, " firmware.................. %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _YELLOW_("RDV4")); + PrintAndLogEx(NORMAL, " device.................... %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _GREEN_("PM3 GENERIC")); + PrintAndLogEx(NORMAL, " firmware.................. %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _GREEN_("PM3 GENERIC")); PrintAndLogEx(NORMAL, " external flash............ %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent")); PrintAndLogEx(NORMAL, " smartcard reader.......... %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent")); PrintAndLogEx(NORMAL, " FPC USART for BT add-on... %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent")); From 474aaed4b7a527f61a28012b271aa577e3e92b21 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Tue, 24 Jan 2023 23:01:28 +0100 Subject: [PATCH 07/30] Added a proper way to check if it is rdv4 fw --- armsrc/appmain.c | 6 ++++++ client/src/cmdhw.c | 10 +++++++--- client/src/cmdparser.c | 2 +- common_arm/Makefile.hal | 1 + include/pm3_cmd.h | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 76d9ac3c0..80b85e93b 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -453,6 +453,12 @@ static void SendCapabilities(void) { capabilities.baudrate = g_usart_baudrate; #endif +#ifdef RDV4 + capabilities.is_rdv4 = true; +#else + capabilities.is_rdv4 = false; +#endif + #ifdef WITH_FLASH capabilities.compiled_with_flash = true; capabilities.hw_available_flash = FlashInit(); diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index b3f80e218..67f404bc9 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -1202,7 +1202,7 @@ void pm3_version_short(void) { } } - PrintAndLogEx(NORMAL, " Target.... %s", (is_genuine_rdv4) ? _YELLOW_("RDV4") : _YELLOW_("PM3 GENERIC")); + PrintAndLogEx(NORMAL, " Target.... %s", (is_genuine_rdv4) ? _YELLOW_("RDV4") : _RED_("device / fw mismatch")); } else { PrintAndLogEx(NORMAL, " Target.... %s", _YELLOW_("PM3 GENERIC")); } @@ -1291,13 +1291,17 @@ void pm3_version(bool verbose, bool oneliner) { } } - PrintAndLogEx(NORMAL, " device.................... %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _GREEN_("PM3 GENERIC")); - PrintAndLogEx(NORMAL, " firmware.................. %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _GREEN_("PM3 GENERIC")); + PrintAndLogEx(NORMAL, " device.................... %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _RED_("device / fw mismatch")); + PrintAndLogEx(NORMAL, " firmware.................. %s", (is_genuine_rdv4) ? _GREEN_("RDV4") : _YELLOW_("RDV4")); PrintAndLogEx(NORMAL, " external flash............ %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent")); PrintAndLogEx(NORMAL, " smartcard reader.......... %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent")); PrintAndLogEx(NORMAL, " FPC USART for BT add-on... %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent")); } else { PrintAndLogEx(NORMAL, " firmware.................. %s", _YELLOW_("PM3 GENERIC")); + if (IfPm3Flash()) { + PrintAndLogEx(NORMAL, " external flash............ %s", _GREEN_("present")); + } + if (IfPm3FpcUsartHost()) { PrintAndLogEx(NORMAL, " FPC USART for BT add-on... %s", _GREEN_("present")); } diff --git a/client/src/cmdparser.c b/client/src/cmdparser.c index 96c5f0fb3..1c360e832 100644 --- a/client/src/cmdparser.c +++ b/client/src/cmdparser.c @@ -38,7 +38,7 @@ bool IfPm3Present(void) { bool IfPm3Rdv4Fw(void) { if (!IfPm3Present()) return false; - return (g_pm3_capabilities.compiled_with_flash) || (g_pm3_capabilities.compiled_with_smartcard); + return (g_pm3_capabilities.is_rdv4); } bool IfPm3Flash(void) { diff --git a/common_arm/Makefile.hal b/common_arm/Makefile.hal index 68417eb60..0e9dd455b 100644 --- a/common_arm/Makefile.hal +++ b/common_arm/Makefile.hal @@ -95,6 +95,7 @@ ifeq ($(PLATFORM),PM3RDV4) PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH -DRDV4 PLTNAME = Proxmark3 RDV4 PLATFORM_FPGA = xc2s30 + RDV4 = yes else ifeq ($(PLATFORM),PM3OTHER) $(warning PLATFORM=PM3OTHER is deprecated, please use PLATFORM=PM3GENERIC) PLTNAME = Proxmark3 generic target diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 95750b9b7..83db2f05d 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -205,6 +205,7 @@ typedef struct { // rdv4 bool hw_available_flash : 1; bool hw_available_smartcard : 1; + bool is_rdv4 : 1; } PACKED capabilities_t; #define CAPABILITIES_VERSION 6 extern capabilities_t g_pm3_capabilities; From 571b763f5c290892264a8207aef39e6c3b1c2a7d Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 27 Jan 2023 15:04:08 +0100 Subject: [PATCH 08/30] Makefile.platform.sample reverted --- Makefile.platform.sample | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.platform.sample b/Makefile.platform.sample index bfcb5b749..4f8f86cd4 100644 --- a/Makefile.platform.sample +++ b/Makefile.platform.sample @@ -5,7 +5,7 @@ PLATFORM=PM3RDV4 #PLATFORM=PM3GENERIC # If you want more than one PLATFORM_EXTRAS option, separate them by spaces: #PLATFORM_EXTRAS=BTADDON -STANDALONE=HF_BOG +#STANDALONE=LF_SAMYRUN # To accelerate repetitive compilations: # Install package "ccache" -> Debian/Ubuntu: /usr/lib/ccache, Fedora/CentOS/RHEL: /usr/lib64/ccache @@ -13,4 +13,4 @@ STANDALONE=HF_BOG #export PATH := /usr/lib64/ccache:/usr/lib/ccache:${PATH} # To install with sudo: -INSTALLSUDO=sudo +INSTALLSUDO=sudo \ No newline at end of file From db01a3b360ab3eb371a33a5a93e6603b2aef64e4 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 27 Jan 2023 11:23:00 -0600 Subject: [PATCH 09/30] Detect 50 pF version of NTAG 210u (micro) --- client/src/cmdhfmfu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index bc8c10859..a59859394 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -1472,6 +1472,7 @@ uint32_t GetHF14AMfU_Type(void) { else if (memcmp(version, "\x00\x34\x21\x01\x01\x00\x0E", 7) == 0) { tagtype = UL_EV1_128; break; } // Mikron JSC Russia EV1 41 pages tag else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0B", 7) == 0) { tagtype = NTAG_210; break; } else if (memcmp(version, "\x00\x04\x04\x01\x02\x00\x0B", 7) == 0) { tagtype = NTAG_210u; break; } + else if (memcmp(version, "\x00\x04\x04\x02\x02\x00\x0B", 7) == 0) { tagtype = NTAG_210u; break; } else if (memcmp(version, "\x00\x04\x04\x01\x01\x00\x0E", 7) == 0) { tagtype = NTAG_212; break; } else if (memcmp(version, "\x00\x04\x04\x02\x01\x00\x0F", 7) == 0) { tagtype = NTAG_213; break; } else if (memcmp(version, "\x00\x53\x04\x02\x01\x00\x0F", 7) == 0) { tagtype = NTAG_213; break; } //Shanghai Feiju Microelectronics Co. Ltd. China (Xiaomi Air Purifier filter) From 5a49beb83a6fdaf294630170c5de10f15e106580 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 27 Jan 2023 19:22:48 -0600 Subject: [PATCH 10/30] added CHANGELOG.md entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 942100d85..f31361d9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `trace list -c` - annotation of CRC bytes now is colored or squared if no ansi colors is supported (@iceman1001) - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - Fixed `make accessrights` on Fedora (@mooey5775) + - Fixed `hf mfu info` - can now identify the 50 pF version of NTAG 210u(micro) (@mjacksn) ## [Radium.4.15864][2022-10-29] - Changed `lf indala sim` - now accepts fc / cn (@iceman1001) From 9041627ae55676003e5023507a2da3122d816012 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 27 Jan 2023 22:46:40 -0600 Subject: [PATCH 11/30] Add `hf 15` sub-commands for EAS, AFI, privacy mode, and passwords on SLIX tags --- CHANGELOG.md | 2 + armsrc/appmain.c | 68 +++- armsrc/iso15693.c | 391 +++++++++++++++++-- armsrc/iso15693.h | 10 +- client/src/cmdhf15.c | 639 +++++++++++++++++++++++++++----- client/src/pm3line_vocabulory.h | 8 +- include/pm3_cmd.h | 10 +- 7 files changed, 993 insertions(+), 135 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f31361d9d..3a6e2f72c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - Fixed `make accessrights` on Fedora (@mooey5775) - Fixed `hf mfu info` - can now identify the 50 pF version of NTAG 210u(micro) (@mjacksn) + - Added `hf 15` sub-commands for controlling EAS, AFI, privacy mode, and the setting of passwords on SLIX tags (@mjacksn) + ## [Radium.4.15864][2022-10-29] - Changed `lf indala sim` - now accepts fc / cn (@iceman1001) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 76d9ac3c0..b26225ccf 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1287,23 +1287,79 @@ static void PacketReceived(PacketCommandNG *packet) { SetTag15693Uid(payload->uid); break; } - case CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY: { + case CMD_HF_ISO15693_SLIX_DISABLE_EAS: { + struct p { + uint8_t pwd[4]; + bool usepwd; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; + DisableEAS_AFISlixIso15693(payload->pwd, payload->usepwd); + break; + } + case CMD_HF_ISO15693_SLIX_ENABLE_EAS: { + struct p { + uint8_t pwd[4]; + bool usepwd; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; + EnableEAS_AFISlixIso15693(payload->pwd, payload->usepwd); + break; + } + case CMD_HF_ISO15693_SLIX_WRITE_PWD: { + struct p { + uint8_t old_pwd[4]; + uint8_t new_pwd[4]; + uint8_t pwd_id; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; + WritePasswordSlixIso15693(payload->old_pwd, payload->new_pwd, payload->pwd_id); + break; + } + case CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY: { struct p { uint8_t pwd[4]; } PACKED; struct p *payload = (struct p *) packet->data.asBytes; - DisablePrivacySlixLIso15693(payload->pwd); + DisablePrivacySlixIso15693(payload->pwd); break; } - case CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI: { + case CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY: { struct p { uint8_t pwd[4]; } PACKED; - struct p *payload = (struct p *) packet->data.asBytes; - DisableEAS_AFISlixLIso15693(payload->pwd); + struct p* payload = (struct p*)packet->data.asBytes; + EnablePrivacySlixIso15693(payload->pwd); break; } - + case CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI: { + struct p { + uint8_t pwd[4]; + } PACKED; + struct p* payload = (struct p*)packet->data.asBytes; + PassProtectAFISlixIso15693(payload->pwd); + break; + } + case CMD_HF_ISO15693_WRITE_AFI: { + struct p { + uint8_t pwd[4]; + bool use_pwd; + uint8_t uid[8]; + bool use_uid; + uint8_t afi; + } PACKED; + struct p* payload = (struct p*)packet->data.asBytes; + WriteAFIIso15693(payload->pwd, payload->use_pwd, payload->uid, payload->use_uid, payload->afi); + break; + } + case CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS: { + struct p { + uint8_t pwd[4]; + } PACKED; + struct p* payload = (struct p*)packet->data.asBytes; + PassProtextEASSlixIso15693(payload->pwd); + break; + } + #endif #ifdef WITH_LEGICRF diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index ab650da8f..3ca186305 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -177,6 +177,37 @@ static void CodeIso15693AsReaderEOF(void) { } +static int get_uid_slix(uint32_t start_time, uint32_t* eof_time, uint8_t* uid) { + + uint8_t *answer = BigBuf_malloc(ISO15693_MAX_RESPONSE_LENGTH); + memset(answer, 0x00, ISO15693_MAX_RESPONSE_LENGTH); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + + uint8_t cmd[5] = {0}; + BuildIdentifyRequest(cmd); + uint16_t recvlen = 0; + SendDataTag(cmd, sizeof(cmd), false, true, answer, ISO15693_MAX_RESPONSE_LENGTH, start_time, ISO15693_READER_TIMEOUT, eof_time, &recvlen); + + if(recvlen != 12) + { + return PM3_ETIMEOUT; + } + + uid[0] = answer[2]; + uid[1] = answer[3]; + uid[2] = answer[4]; + uid[3] = answer[5]; + uid[4] = answer[6]; + uid[5] = answer[7]; + uid[6] = answer[8]; + uid[7] = answer[9]; + + BigBuf_free(); + return PM3_SUCCESS; +} + + // encode data using "1 out of 256" scheme // data rate is 1,66 kbit/s (fc/8192) // is designed for more robust communication over longer distances @@ -2431,6 +2462,8 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint case ISO15693_WRITE_AFI: case ISO15693_LOCK_AFI: case ISO15693_WRITE_DSFID: + case ISO15693_WRITE_PASSWORD: + case ISO15693_PASSWORD_PROTECT_EAS: case ISO15693_LOCK_DSFID: timeout = ISO15693_READER_TIMEOUT_WRITE; request_answer = data[0] & ISO15_REQ_OPTION; @@ -2640,7 +2673,7 @@ void SetTag15693Uid(const uint8_t *uid) { switch_off(); } -static void init_password_15693_slixl(uint8_t *buffer, uint8_t *pwd, const uint8_t *rnd) { +static void init_password_15693_Slix(uint8_t *buffer, uint8_t *pwd, const uint8_t *rnd) { memcpy(buffer, pwd, 4); if (rnd) { buffer[0] ^= rnd[0]; @@ -2650,14 +2683,14 @@ static void init_password_15693_slixl(uint8_t *buffer, uint8_t *pwd, const uint8 } } -static bool get_rnd_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t *rnd) { +static bool get_rnd_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *rnd) { // 0x04, == NXP from manufacture id list. uint8_t c[] = {ISO15_REQ_DATARATE_HIGH, ISO15693_GET_RANDOM_NUMBER, 0x04, 0x00, 0x00 }; AddCrc15(c, 3); uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; uint16_t recvlen = 0; - int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + int res = SendDataTag(c, sizeof(c), true, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); if (res != PM3_SUCCESS && recvlen != 5) { return false; } @@ -2668,15 +2701,16 @@ static bool get_rnd_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t return true; } -static uint32_t set_pass_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t pass_id, uint8_t *password) { +static uint32_t disable_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t pass_id, uint8_t* password) { + uint8_t rnd[2]; - if (get_rnd_15693_slixl(start_time, eof_time, rnd) == false) { + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } // 0x04, == NXP from manufacture id list. - uint8_t c[] = {ISO15_REQ_DATARATE_HIGH, ISO15693_SET_PASSWORD, 0x04, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - init_password_15693_slixl(&c[4], password, rnd); + uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, ISO15693_SET_PASSWORD, 0x04, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + init_password_15693_Slix(&c[4], password, rnd); AddCrc15(c, 8); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; @@ -2689,16 +2723,236 @@ static uint32_t set_pass_15693_slixl(uint32_t start_time, uint32_t *eof_time, ui return PM3_SUCCESS; } -/* -static uint32_t enable_privacy_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t pass_id, uint8_t *password) { +static uint32_t set_pass_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t pass_id, uint8_t* password, uint8_t* uid) { + + uint8_t rnd[2]; - if (get_rnd_15693_slixl(start_time, eof_time, rnd) == false) { + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + // 0x04, == NXP from manufacture id list. + uint8_t c[] = { (ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS), ISO15693_SET_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + init_password_15693_Slix(&c[12], password, rnd); + + memcpy(&c[3], uid, 8); + AddCrc15(c, 16); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + return PM3_SUCCESS; +} + +static uint32_t set_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password) { + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + // 0x04, == NXP from manufacture id list. + uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, 0xBA, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + init_password_15693_Slix(&c[3], password, rnd); + AddCrc15(c, 7); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + return PM3_SUCCESS; +} + +static uint32_t disable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password, bool usepwd) { + + uint8_t uid[8]; + get_uid_slix(start_time, eof_time, uid); + + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + if(usepwd) + { + + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if(res_setpass != PM3_SUCCESS) + { + return PM3_EWRONGANSWER; + } + } + + // 0x04, == NXP from manufacture id list. + uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, 0xA3, 0x04, 0x00, 0x00}; + AddCrc15(c, 3); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + return PM3_SUCCESS; +} + + +static uint32_t enable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password, bool usepwd) { + + uint8_t uid[8]; + get_uid_slix(start_time, eof_time, uid); + + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + if(usepwd) + { + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if(res_setpass != PM3_SUCCESS) + { + return PM3_EWRONGANSWER; + } + } + // 0x04, == NXP from manufacture id list. + uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, 0xA2, 0x04, 0x00, 0x00}; + //init_password_15693_Slix(&c[3], password, rnd); + AddCrc15(c, 3); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + return PM3_SUCCESS; +} + +static uint32_t write_password_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t pwd_id, uint8_t *password, uint8_t* uid) { + + uint8_t new_pwd_cmd[] = { (ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS), ISO15693_WRITE_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, pwd_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + memcpy(&new_pwd_cmd[3], uid, 8); + memcpy(&new_pwd_cmd[12], password, 4); + + AddCrc15(new_pwd_cmd, 16); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res_wrp = SendDataTag(new_pwd_cmd, sizeof(new_pwd_cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res_wrp != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + + return PM3_SUCCESS; +} + +static uint32_t pass_protect_EASAFI_15693_Slix(uint32_t start_time, uint32_t *eof_time, bool set_option_flag, uint8_t* password) { + + uint8_t flags; + + if(set_option_flag) + flags = ISO15_REQ_DATARATE_HIGH | ISO15_REQ_OPTION; + else + flags = ISO15_REQ_DATARATE_HIGH; + + + uint8_t uid[8]; + get_uid_slix(start_time, eof_time, uid); + + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if(res_setpass != PM3_SUCCESS) + { + return PM3_EWRONGANSWER; + } + + uint8_t new_pass_protect_cmd[] = { flags, ISO15693_PASSWORD_PROTECT_EAS, 0x04, 0x00, 0x00}; + AddCrc15(new_pass_protect_cmd, 3); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res = SendDataTag(new_pass_protect_cmd, sizeof(new_pass_protect_cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + + return PM3_SUCCESS; +} + +static uint32_t write_afi_15693(uint32_t start_time, uint32_t *eof_time, uint8_t *password, bool usepwd, uint8_t *uid, bool use_uid, uint8_t afi) +{ + + if(!use_uid) + { + int res_getuid = get_uid_slix(start_time, eof_time, uid); + + if(res_getuid != PM3_SUCCESS) + { + return res_getuid; + } + } + + if(usepwd) + { + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if(res_setpass != PM3_SUCCESS) + { + return PM3_EWRONGANSWER; + } + } + + uint8_t cmd[] = { ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_WRITE_AFI, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + memcpy(&cmd[2], uid, 8); + cmd[10] = afi; + AddCrc15(cmd, 11); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res = SendDataTag(cmd, sizeof(cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS || recvlen != 3) { + return PM3_EWRONGANSWER; + } + + return PM3_SUCCESS; +} + +/* +static uint32_t enable_privacy_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t pass_id, uint8_t *password) { + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } uint8_t c[] = {ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_ENABLE_PRIVACY, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(&c[3], uid, 8); - init_password_15693_slixl(&c[11], password, rnd); + init_password_15693_Slix(&c[11], password, rnd); AddCrc15(c, 15); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; @@ -2711,16 +2965,16 @@ static uint32_t enable_privacy_15693_slixl(uint32_t start_time, uint32_t *eof_ti return PM3_SUCCESS; } -static uint32_t write_password_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t pass_id, uint8_t *password) { +static uint32_t write_password_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t pass_id, uint8_t *password) { uint8_t rnd[2]; - if (get_rnd_15693_slixl(start_time, eof_time, rnd) == false) { + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } uint8_t c[] = {ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_WRITE_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(&c[3], uid, 8); c[11] = pass_id; - init_password_15693_slixl(&c[12], password, NULL); + init_password_15693_Slix(&c[12], password, NULL); AddCrc15(c, 16); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; @@ -2734,16 +2988,16 @@ static uint32_t write_password_15693_slixl(uint32_t start_time, uint32_t *eof_ti return PM3_SUCCESS; } -static uint32_t destroy_15693_slixl(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t *password) { +static uint32_t destroy_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid, uint8_t *password) { uint8_t rnd[2]; - if (get_rnd_15693_slixl(start_time, eof_time, rnd) == false) { + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } uint8_t c[] = {ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_DESTROY, ISO15693_ENABLE_PRIVACY, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(&c[3], uid, 8); - init_password_15693_slixl(&c[11], password, rnd); + init_password_15693_Slix(&c[11], password, rnd); AddCrc15(c, 15); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; @@ -2758,8 +3012,33 @@ static uint32_t destroy_15693_slixl(uint32_t start_time, uint32_t *eof_time, uin */ -// Sets a PRIVACY password to all ZEROS -void DisablePrivacySlixLIso15693(uint8_t *password) { +void WritePasswordSlixIso15693(uint8_t *old_password, uint8_t *new_password, uint8_t pwd_id) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + int res = PM3_EFAILED; + + uint8_t uid[8]; + get_uid_slix(start_time, &eof_time, uid); + + res = set_pass_15693_Slix(start_time, &eof_time, pwd_id, old_password, uid); + if(res != PM3_SUCCESS) + { + reply_ng(CMD_HF_ISO15693_SLIX_WRITE_PWD, res, NULL, 0); + switch_off(); + return; + } + + res = write_password_15693_Slix(start_time, &eof_time, pwd_id, new_password, uid); + + reply_ng(CMD_HF_ISO15693_SLIX_WRITE_PWD, res, NULL, 0); + + switch_off(); + +} + +void DisablePrivacySlixIso15693(uint8_t *password) { LED_D_ON(); Iso15693InitReader(); StartCountSspClk(); @@ -2769,13 +3048,12 @@ void DisablePrivacySlixLIso15693(uint8_t *password) { // 0x04 Privacy // 0x08 Destroy SLIX-L // 0x10 EAS/AFI - int res = set_pass_15693_slixl(start_time, &eof_time, 0x04, password); - reply_ng(CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY, res, NULL, 0); + int res = disable_privacy_15693_Slix(start_time, &eof_time, 0x04, password); + reply_ng(CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY, res, NULL, 0); switch_off(); } -// Sets a EAS/AFI password to all ZEROS -void DisableEAS_AFISlixLIso15693(uint8_t *password) { +void EnablePrivacySlixIso15693(uint8_t* password) { LED_D_ON(); Iso15693InitReader(); StartCountSspClk(); @@ -2785,8 +3063,71 @@ void DisableEAS_AFISlixLIso15693(uint8_t *password) { // 0x04 Privacy // 0x08 Destroy SLIX-L // 0x10 EAS/AFI - int res = set_pass_15693_slixl(start_time, &eof_time, 0x10, password); - reply_ng(CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI, res, NULL, 0); + int res = set_privacy_15693_Slix(start_time, &eof_time, password); + reply_ng(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, res, NULL, 0); switch_off(); } + +void DisableEAS_AFISlixIso15693(uint8_t *password, bool usepwd) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + + // Password identifier Password byte + // 0x04 Privacy + // 0x08 Destroy SLIX-L + // 0x10 EAS/AFI + int res = disable_eas_15693_Slix(start_time, &eof_time, password, usepwd); + + + + reply_ng(CMD_HF_ISO15693_SLIX_DISABLE_EAS, res, NULL, 0); + switch_off(); +} + +void EnableEAS_AFISlixIso15693(uint8_t *password, bool usepwd) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + + // Password identifier Password byte + // 0x04 Privacy + // 0x08 Destroy SLIX-L + // 0x10 EAS/AFI + int res = enable_eas_15693_Slix(start_time, &eof_time, password, usepwd); + reply_ng(CMD_HF_ISO15693_SLIX_ENABLE_EAS, res, NULL, 0); + switch_off(); +} + +void PassProtextEASSlixIso15693(uint8_t *password) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + int res = pass_protect_EASAFI_15693_Slix(start_time, &eof_time, false, password); + reply_ng(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, res, NULL, 0); + switch_off(); +} +void PassProtectAFISlixIso15693(uint8_t *password) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + int res = pass_protect_EASAFI_15693_Slix(start_time, &eof_time, true, password); + reply_ng(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, res, NULL, 0); + switch_off(); +} + +void WriteAFIIso15693(uint8_t *password, bool use_pwd, uint8_t *uid, bool use_uid, uint8_t afi) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + int res = write_afi_15693(start_time, &eof_time, password, use_pwd, uid, use_uid, afi); + //int res = PM3_SUCCESS; + reply_ng(CMD_HF_ISO15693_WRITE_AFI, res, NULL, 0); + switch_off(); +} \ No newline at end of file diff --git a/armsrc/iso15693.h b/armsrc/iso15693.h index 2097b3769..c0ff44929 100644 --- a/armsrc/iso15693.h +++ b/armsrc/iso15693.h @@ -62,6 +62,12 @@ int SendDataTagEOF(uint8_t *recv, uint16_t max_recv_len, uint32_t start_time, ui void SetTag15693Uid(const uint8_t *uid); -void DisablePrivacySlixLIso15693(uint8_t *password); -void DisableEAS_AFISlixLIso15693(uint8_t *password); +void WritePasswordSlixIso15693(uint8_t *old_password, uint8_t *new_password, uint8_t pwd_id); +void DisablePrivacySlixIso15693(uint8_t *password); +void EnablePrivacySlixIso15693(uint8_t* password); +void DisableEAS_AFISlixIso15693(uint8_t *password, bool usepwd); +void EnableEAS_AFISlixIso15693(uint8_t *password, bool usepwd); +void PassProtextEASSlixIso15693(uint8_t *password); +void PassProtectAFISlixIso15693(uint8_t *password); +void WriteAFIIso15693(uint8_t *password, bool usepwd, uint8_t *uid, bool use_uid, uint8_t afi); #endif diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 035a2218e..46a89a0c9 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -698,7 +698,7 @@ static int NxpCheckSig(uint8_t *uid) { PacketResponseNG resp; uint16_t reqlen = 0; uint8_t req[PM3_CMD_DATA_SIZE] = {0}; - + // Check if we can also read the signature req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS; req[reqlen++] = ISO15693_READ_SIGNATURE; @@ -736,7 +736,7 @@ static int NxpCheckSig(uint8_t *uid) { memcpy(signature, recv + 1, 32); nxp_15693_print_signature(uid, signature); - + return PM3_SUCCESS; } @@ -1352,94 +1352,83 @@ static int CmdHF15WriteAfi(const char *Cmd) { CLIParserInit(&ctx, "hf 15 writeafi", "Write AFI on card", "hf 15 writeafi -* --afi 12\n" - "hf 15 writeafi -u E011223344556677 --afi 12" + "hf 15 writeafi -u E011223344556677 --afi 12 -p 0F0F0F0F" ); - void *argtable[6 + 2] = {}; - uint8_t arglen = arg_add_default(argtable); - argtable[arglen++] = arg_int1(NULL, "afi", "", "AFI number (0-255)"); - argtable[arglen++] = arg_param_end; + void *argtable[5] = {}; + argtable[0] = arg_param_begin; + argtable[1] = arg_str0("u", "uid", "", "full UID, 8 bytes"); + argtable[2] = arg_int1(NULL, "afi", "", "AFI number (0-255)"); + argtable[3] = arg_str0("p", "pwd", "", "optional AFI/EAS password"); + argtable[4] = arg_param_end; - CLIExecWithReturn(ctx, Cmd, argtable, false); + CLIExecWithReturn(ctx, Cmd, argtable, true); + + struct { + uint8_t pwd[4]; + bool use_pwd; + uint8_t uid[8]; + bool use_uid; + uint8_t afi; + } PACKED payload; - uint8_t uid[8]; int uidlen = 0; - CLIGetHexWithReturn(ctx, 1, uid, &uidlen); - bool unaddressed = arg_get_lit(ctx, 2); - bool scan = arg_get_lit(ctx, 3); - int fast = (arg_get_lit(ctx, 4) == false); - bool add_option = arg_get_lit(ctx, 5); + CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); - int afi = arg_get_int_def(ctx, 6, 0); + payload.afi = arg_get_int_def(ctx, 2, 0); + + int pwdlen; + + CLIGetHexWithReturn(ctx, 3, payload.pwd, &pwdlen); + CLIParserFree(ctx); + + if(pwdlen == 4) + { + payload.use_pwd = true; + } + + if(uidlen == 8) + { + payload.use_uid = true; + } // sanity checks - if ((scan + unaddressed + uidlen) > 1) { - PrintAndLogEx(WARNING, "Select only one option /scan/unaddress/uid"); + if (uidlen != 0 && uidlen != 8) { + PrintAndLogEx(WARNING, "uid must be 8 hex bytes if provided"); return PM3_EINVARG; } - - // request to be sent to device/card - uint16_t flags = arg_get_raw_flag(uidlen, unaddressed, scan, add_option); - uint8_t req[16] = {flags, ISO15693_WRITE_AFI}; - uint16_t reqlen = 2; - - if (unaddressed == false) { - if (scan) { - if (getUID(false, uid) != PM3_SUCCESS) { - PrintAndLogEx(WARNING, "no tag found"); - return PM3_EINVARG; - } - uidlen = 8; - } - - if (uidlen == 8) { - // add UID (scan, uid) - memcpy(req + reqlen, uid, sizeof(uid)); - reqlen += sizeof(uid); - } - PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid)); + + if(pwdlen > 0 && pwdlen != 4) + { + PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); + return PM3_ESOFT; } - // enforce, since we are writing - req[0] |= ISO15_REQ_OPTION; - - req[reqlen++] = (uint8_t)afi; - - AddCrc15(req, reqlen); - reqlen += 2; - - // arg: len, speed, recv? - // arg0 (datalen, cmd len? .arg0 == crc?) - // arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 ) - // arg2 (recv == 1 == expect a response) - uint8_t read_response = 1; - PacketResponseNG resp; clearCommandBuffer(); - SendCommandMIX(CMD_HF_ISO15693_COMMAND, reqlen, fast, read_response, req, reqlen); - - if (WaitForResponseTimeout(CMD_HF_ISO15693_COMMAND, &resp, 2000) == false) { - PrintAndLogEx(ERR, "iso15693 timeout"); + SendCommandNG(CMD_HF_ISO15693_WRITE_AFI, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_WRITE_AFI, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); DropField(); - return PM3_ETIMEOUT; - } - DropField(); - - if (resp.status == PM3_ETEAROFF) { - return resp.status; + return PM3_ESOFT; } - uint8_t *data = resp.data.asBytes; - - if ((data[0] & ISO15_RES_ERROR) == ISO15_RES_ERROR) { - PrintAndLogEx(ERR, "iso15693 card returned error %i: %s", data[0], TagErrorStr(data[0])); - return PM3_EWRONGANSWER; + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "error writing AFI"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "Wrote AFI 0x%02X", payload.afi); + break; + } } - - PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(SUCCESS, "Wrote AFI 0x%02X", afi); - return PM3_SUCCESS; + return resp.status; } // Writes the DSFID (Data Storage Format Identifier) of a card @@ -2378,10 +2367,164 @@ static int CmdHF15CSetUID(const char *Cmd) { } } +static int CmdHF15SlixEASEnable(const char *Cmd) { + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 slixeasenable", + "Enable EAS mode on SLIX ISO-15693 tag", + "hf 15 slixeasenable -p 0F0F0F0F"); + + void *argtable[] = { + arg_param_begin, + arg_str0("p", "pwd", "", "optional password, 8 hex bytes"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + struct { + uint8_t pwd[4]; + bool usepwd; + } PACKED payload; + int pwdlen = 0; + + int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); + if((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) + { + PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); + return PM3_ESOFT; + } + + //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + CLIParserFree(ctx); + + + if(pwdlen > 0 ) + { + PrintAndLogEx(INFO, "Trying to enable EAS mode using password " _GREEN_("%s") + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); + payload.usepwd = true; + } + else + { + PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); + payload.usepwd = false; + } + + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_ENABLE_EAS, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_ENABLE_EAS, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + if(pwdlen > 0 ) + { + PrintAndLogEx(WARNING, "the password provided was not accepted"); + } + else + { + PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); + } + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "EAS mode is now enabled ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; +} + +static int CmdHF15SlixEASDisable(const char *Cmd) { + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 slixeasdisable", + "Disable EAS mode on SLIX ISO-15693 tag", + "hf 15 slixeasdisable -p 0F0F0F0F"); + + void *argtable[] = { + arg_param_begin, + arg_str0("p", "pwd", "", "optional password, 8 hex bytes"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + struct { + uint8_t pwd[4]; + bool usepwd; + + } PACKED payload; + int pwdlen = 0; + + int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); + if((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) + { + PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); + return PM3_ESOFT; + } + + //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + CLIParserFree(ctx); + + + if(pwdlen > 0 ) + { + PrintAndLogEx(INFO, "Trying to disable EAS mode using password " _GREEN_("%s") + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); + payload.usepwd = true; + } + else + { + PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); + payload.usepwd = false; + } + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_DISABLE_EAS, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_DISABLE_EAS, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + if(pwdlen > 0 ) + { + PrintAndLogEx(WARNING, "the password provided was not accepted"); + } + else + { + PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); + } + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "EAS mode is now disabled ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; +} + static int CmdHF15SlixDisable(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "hf 15 slixdisable", + CLIParserInit(&ctx, "hf 15 slixprivacydisable", "Disable privacy mode on SLIX ISO-15693 tag", "hf 15 slixdisable -p 0F0F0F0F"); @@ -2404,8 +2547,8 @@ static int CmdHF15SlixDisable(const char *Cmd) { PacketResponseNG resp; clearCommandBuffer(); - SendCommandNG(CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY, (uint8_t *)&payload, sizeof(payload)); - if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY, &resp, 2000) == false) { + SendCommandNG(CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY, &resp, 2000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply"); DropField(); return PM3_ESOFT; @@ -2428,32 +2571,330 @@ static int CmdHF15SlixDisable(const char *Cmd) { return resp.status; } +static int CmdHF15SlixEnable(const char* Cmd) { + + CLIParserContext* ctx; + CLIParserInit(&ctx, "hf 15 slixprivacyenable", + "Enable privacy mode on SLIX ISO-15693 tag", + "hf 15 slixenable -p 0F0F0F0F"); + + void* argtable[] = { + arg_param_begin, + arg_str1("p", "pwd", "", "password, 8 hex bytes"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + struct { + uint8_t pwd[4]; + } PACKED payload; + int pwdlen = 0; + CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + CLIParserFree(ctx); + + PrintAndLogEx(INFO, "Trying to enable privacy mode using password " _GREEN_("%s") + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, (uint8_t*)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "password was not accepted"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "privacy mode is now enabled ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; +} + +static int CmdHF15SlixWritePassword(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 slixwritepwd", + "Write a password on a SLIX family ISO-15693 tag", + "hf 15 slixwritepwd -t READ -o 00000000 -n 12131415"); + + void *argtable[] = { + arg_param_begin, + arg_str1("t", "type", "", "which password field to write to (some tags do not support all password types)"), + arg_str0("o", "old", "", "old password (if present), 8 hex bytes"), + arg_str1("n", "new", "", "new password, 8 hex bytes"), + arg_param_end + }; + + CLIExecWithReturn(ctx, Cmd, argtable, false); + + struct { + uint8_t old_pwd[4]; + uint8_t new_pwd[4]; + uint8_t pwd_id; + } PACKED payload; + int pwdlen = 0; + + + + CLIGetHexWithReturn(ctx, 2, payload.old_pwd, &pwdlen); + + if(pwdlen > 0 && pwdlen != 4) + { + PrintAndLogEx(WARNING, "old password must be 4 hex bytes if provided"); + return PM3_ESOFT; + } + + CLIGetHexWithReturn(ctx, 3, payload.new_pwd, &pwdlen); + + if(pwdlen != 4) + { + PrintAndLogEx(WARNING, "new password must be 4 hex bytes"); + return PM3_ESOFT; + } + + int vlen = 0; + char value[10]; + CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)value, sizeof(value), &vlen); + + if (vlen > 0) { + if (strcmp(value, "read") == 0) + { + PrintAndLogEx(SUCCESS, "Selected read pass"); + payload.pwd_id = 0x01; + } + else if (strcmp(value, "write") == 0) + { + PrintAndLogEx(SUCCESS, "Selected write pass"); + payload.pwd_id = 0x02; + } + else if (strcmp(value, "privacy") == 0) + { + PrintAndLogEx(SUCCESS, "Selected privacy pass"); + payload.pwd_id = 0x04; + } + else if (strcmp(value, "destroy") == 0) + { + PrintAndLogEx(SUCCESS, "Selected destroy pass"); + payload.pwd_id = 0x08; + } + else if (strcmp(value, "easafi") == 0) + { + PrintAndLogEx(SUCCESS, "Selected easafi pass"); + payload.pwd_id = 0x10; + } + else + { + PrintAndLogEx(ERR, "t argument must be 'read', 'write', 'privacy', 'destroy', or 'easafi'"); + return PM3_EINVARG; + } + } + + CLIParserFree(ctx); + + + PrintAndLogEx(INFO, "Trying to write " _YELLOW_("%s") " as " _YELLOW_("%s") " password" + , sprint_hex_inrow(payload.new_pwd, sizeof(payload.new_pwd)), value); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_WRITE_PWD, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_WRITE_PWD, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "password was not accepted"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "password written ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; +} + +static int CmdHF15AFIPassProtect(const char *Cmd) { + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 passprotectafi", + "Password protect AFI. Cannot be undone.", + "hf 15 passprotectafi -p 00000000 -c"); + + void *argtable[] = { + arg_param_begin, + arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), + arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), + arg_param_end + }; + + CLIExecWithReturn(ctx, Cmd, argtable, true); + + struct { + uint8_t pwd[4]; + } PACKED payload; + int pwdlen = 0; + + CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + + bool confirmation = arg_get_lit(ctx, 2); + + if(pwdlen != 4) + { + PrintAndLogEx(WARNING, "password must be 4 hex bytes"); + return PM3_ESOFT; + } + + if(confirmation == 0) + { + PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + return PM3_ESOFT; + } + + + PrintAndLogEx(INFO, "Trying to enable AFI password protection"); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, (uint8_t*)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "error enabling AFI password protection"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "AFI password protected ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; + +} + +static int CmdHF15EASPassProtect(const char *Cmd) { + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 passprotecteas", + "Password protect EAS. Cannot be undone.", + "hf 15 passprotecteas -p 00000000 -c"); + + void *argtable[] = { + arg_param_begin, + arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), + arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), + arg_param_end + }; + + CLIExecWithReturn(ctx, Cmd, argtable, true); + + struct { + uint8_t pwd[4]; + } PACKED payload; + int pwdlen = 0; + + CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + + bool confirmation = arg_get_lit(ctx, 2); + + if(pwdlen != 4) + { + PrintAndLogEx(WARNING, "password must be 4 hex bytes"); + return PM3_ESOFT; + } + + if(confirmation == 0) + { + PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + return PM3_ESOFT; + } + + PrintAndLogEx(INFO, "Trying to enable EAS password protection"); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, (uint8_t*)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "error enabling EAS password protection"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "EAS password protected ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; +} + static command_t CommandTable[] = { - {"-----------", CmdHF15Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, - {"help", CmdHF15Help, AlwaysAvailable, "This help"}, - {"list", CmdHF15List, AlwaysAvailable, "List ISO-15693 history"}, - {"demod", CmdHF15Demod, AlwaysAvailable, "Demodulate ISO-15693 from tag"}, - {"dump", CmdHF15Dump, IfPm3Iso15693, "Read all memory pages of an ISO-15693 tag, save to file"}, - {"info", CmdHF15Info, IfPm3Iso15693, "Tag information"}, - {"sniff", CmdHF15Sniff, IfPm3Iso15693, "Sniff ISO-15693 traffic"}, - {"raw", CmdHF15Raw, IfPm3Iso15693, "Send raw hex data to tag"}, - {"rdbl", CmdHF15Readblock, IfPm3Iso15693, "Read a block"}, - {"rdmulti", CmdHF15Readmulti, IfPm3Iso15693, "Reads multiple blocks"}, - {"reader", CmdHF15Reader, IfPm3Iso15693, "Act like an ISO-15693 reader"}, - {"restore", CmdHF15Restore, IfPm3Iso15693, "Restore from file to all memory pages of an ISO-15693 tag"}, - {"samples", CmdHF15Samples, IfPm3Iso15693, "Acquire samples as reader (enables carrier, sends inquiry)"}, - {"eload", CmdHF15ELoad, IfPm3Iso15693, "Load image file into emulator to be used by 'sim' command"}, - {"esave", CmdHF15ESave, IfPm3Iso15693, "Save emulator memory into image file"}, - {"eview", CmdHF15EView, IfPm3Iso15693, "View emulator memory"}, - {"sim", CmdHF15Sim, IfPm3Iso15693, "Fake an ISO-15693 tag"}, - {"slixdisable", CmdHF15SlixDisable, IfPm3Iso15693, "Disable privacy mode on SLIX ISO-15693 tag"}, - {"wrbl", CmdHF15Write, IfPm3Iso15693, "Write a block"}, - {"-----------", CmdHF15Help, IfPm3Iso15693, "----------------------- " _CYAN_("afi") " -----------------------"}, - {"findafi", CmdHF15FindAfi, IfPm3Iso15693, "Brute force AFI of an ISO-15693 tag"}, - {"writeafi", CmdHF15WriteAfi, IfPm3Iso15693, "Writes the AFI on an ISO-15693 tag"}, - {"writedsfid", CmdHF15WriteDsfid, IfPm3Iso15693, "Writes the DSFID on an ISO-15693 tag"}, - {"-----------", CmdHF15Help, IfPm3Iso15693, "----------------------- " _CYAN_("magic") " -----------------------"}, - {"csetuid", CmdHF15CSetUID, IfPm3Iso15693, "Set UID for magic card"}, + {"-----------", CmdHF15Help, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"}, + {"help", CmdHF15Help, AlwaysAvailable, "This help"}, + {"list", CmdHF15List, AlwaysAvailable, "List ISO-15693 history"}, + {"demod", CmdHF15Demod, AlwaysAvailable, "Demodulate ISO-15693 from tag"}, + {"dump", CmdHF15Dump, IfPm3Iso15693, "Read all memory pages of an ISO-15693 tag, save to file"}, + {"info", CmdHF15Info, IfPm3Iso15693, "Tag information"}, + {"sniff", CmdHF15Sniff, IfPm3Iso15693, "Sniff ISO-15693 traffic"}, + {"raw", CmdHF15Raw, IfPm3Iso15693, "Send raw hex data to tag"}, + {"rdbl", CmdHF15Readblock, IfPm3Iso15693, "Read a block"}, + {"rdmulti", CmdHF15Readmulti, IfPm3Iso15693, "Reads multiple blocks"}, + {"reader", CmdHF15Reader, IfPm3Iso15693, "Act like an ISO-15693 reader"}, + {"restore", CmdHF15Restore, IfPm3Iso15693, "Restore from file to all memory pages of an ISO-15693 tag"}, + {"samples", CmdHF15Samples, IfPm3Iso15693, "Acquire samples as reader (enables carrier, sends inquiry)"}, + {"eload", CmdHF15ELoad, IfPm3Iso15693, "Load image file into emulator to be used by 'sim' command"}, + {"esave", CmdHF15ESave, IfPm3Iso15693, "Save emulator memory into image file"}, + {"eview", CmdHF15EView, IfPm3Iso15693, "View emulator memory"}, + {"sim", CmdHF15Sim, IfPm3Iso15693, "Fake an ISO-15693 tag"}, + {"slixwritepwd", CmdHF15SlixWritePassword, IfPm3Iso15693, "Writes a password on a SLIX ISO-15693 tag"}, + {"slixeasdisable", CmdHF15SlixEASDisable, IfPm3Iso15693, "Disable EAS mode on SLIX ISO-15693 tag"}, + {"slixeasenable", CmdHF15SlixEASEnable, IfPm3Iso15693, "Enable EAS mode on SLIX ISO-15693 tag"}, + {"slixprivacydisable", CmdHF15SlixDisable, IfPm3Iso15693, "Disable privacy mode on SLIX ISO-15693 tag"}, + {"slixprivacyenable", CmdHF15SlixEnable, IfPm3Iso15693, "Enable privacy mode on SLIX ISO-15693 tag"}, + {"passprotectafi", CmdHF15AFIPassProtect, IfPm3Iso15693, "Password protect AFI - Cannot be undone"}, + {"passprotecteas", CmdHF15EASPassProtect, IfPm3Iso15693, "Password protect EAS - Cannot be undone"}, + {"wrbl", CmdHF15Write, IfPm3Iso15693, "Write a block"}, + {"-----------", CmdHF15Help, IfPm3Iso15693, "----------------------- " _CYAN_("afi") " -----------------------"}, + {"findafi", CmdHF15FindAfi, IfPm3Iso15693, "Brute force AFI of an ISO-15693 tag"}, + {"writeafi", CmdHF15WriteAfi, IfPm3Iso15693, "Writes the AFI on an ISO-15693 tag"}, + {"writedsfid", CmdHF15WriteDsfid, IfPm3Iso15693, "Writes the DSFID on an ISO-15693 tag"}, + {"-----------", CmdHF15Help, IfPm3Iso15693, "----------------------- " _CYAN_("magic") " -----------------------"}, + {"csetuid", CmdHF15CSetUID, IfPm3Iso15693, "Set UID for magic card"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/pm3line_vocabulory.h b/client/src/pm3line_vocabulory.h index 4cd9457b5..ee94f7ec0 100644 --- a/client/src/pm3line_vocabulory.h +++ b/client/src/pm3line_vocabulory.h @@ -177,7 +177,13 @@ const static vocabulory_t vocabulory[] = { { 0, "hf 15 esave" }, { 0, "hf 15 eview" }, { 0, "hf 15 sim" }, - { 0, "hf 15 slixdisable" }, + { 0, "hf 15 slixwritepwd" }, + { 0, "hf 15 slixeasdisable" }, + { 0, "hf 15 slixeasenable" }, + { 0, "hf 15 slixprivacydisable" }, + { 0, "hf 15 slixprivacyenable" }, + { 0, "hf 15 passprotectafi" }, + { 0, "hf 15 passprotecteas" }, { 0, "hf 15 wrbl" }, { 0, "hf 15 findafi" }, { 0, "hf 15 writeafi" }, diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 95750b9b7..43fd44ac0 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -519,8 +519,14 @@ typedef struct { #define CMD_HF_ISO15693_COMMAND 0x0313 #define CMD_HF_ISO15693_FINDAFI 0x0315 #define CMD_HF_ISO15693_CSETUID 0x0316 -#define CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY 0x0317 -#define CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI 0x0318 +#define CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY 0xA317 +#define CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY 0x0317 +#define CMD_HF_ISO15693_SLIX_DISABLE_EAS 0x0318 +#define CMD_HF_ISO15693_SLIX_ENABLE_EAS 0x0862 +#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI 0x0863 +#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS 0x0864 +#define CMD_HF_ISO15693_SLIX_WRITE_PWD 0x0865 +#define CMD_HF_ISO15693_WRITE_AFI 0x0866 #define CMD_HF_TEXKOM_SIMULATE 0x0320 #define CMD_HF_ISO15693_EML_CLEAR 0x0330 #define CMD_HF_ISO15693_EML_SETMEM 0x0331 From 126beb976c81f40b2613a4163ef91efe9f5d512c Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Sat, 28 Jan 2023 13:11:51 -0600 Subject: [PATCH 12/30] fix tabs --- include/pm3_cmd.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 43fd44ac0..4c4eff049 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -519,12 +519,12 @@ typedef struct { #define CMD_HF_ISO15693_COMMAND 0x0313 #define CMD_HF_ISO15693_FINDAFI 0x0315 #define CMD_HF_ISO15693_CSETUID 0x0316 -#define CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY 0xA317 -#define CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY 0x0317 -#define CMD_HF_ISO15693_SLIX_DISABLE_EAS 0x0318 -#define CMD_HF_ISO15693_SLIX_ENABLE_EAS 0x0862 -#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI 0x0863 -#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS 0x0864 +#define CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY 0xA317 +#define CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY 0x0317 +#define CMD_HF_ISO15693_SLIX_DISABLE_EAS 0x0318 +#define CMD_HF_ISO15693_SLIX_ENABLE_EAS 0x0862 +#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI 0x0863 +#define CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS 0x0864 #define CMD_HF_ISO15693_SLIX_WRITE_PWD 0x0865 #define CMD_HF_ISO15693_WRITE_AFI 0x0866 #define CMD_HF_TEXKOM_SIMULATE 0x0320 From 60f49175e827793c1faed90d8dd2c2a6136ddc9b Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Sat, 28 Jan 2023 13:46:11 -0600 Subject: [PATCH 13/30] change constant value so it follows others --- include/pm3_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 4c4eff049..464aaf0c8 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -519,7 +519,7 @@ typedef struct { #define CMD_HF_ISO15693_COMMAND 0x0313 #define CMD_HF_ISO15693_FINDAFI 0x0315 #define CMD_HF_ISO15693_CSETUID 0x0316 -#define CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY 0xA317 +#define CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY 0x0867 #define CMD_HF_ISO15693_SLIX_DISABLE_PRIVACY 0x0317 #define CMD_HF_ISO15693_SLIX_DISABLE_EAS 0x0318 #define CMD_HF_ISO15693_SLIX_ENABLE_EAS 0x0862 From 104028bd1e2d6600fba0cf7f76111823eb2a9b87 Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sun, 29 Jan 2023 11:35:49 +1100 Subject: [PATCH 14/30] Update T5577_Guide.md --- doc/T5577_Guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/T5577_Guide.md b/doc/T5577_Guide.md index deab49d53..6c4eceaf5 100644 --- a/doc/T5577_Guide.md +++ b/doc/T5577_Guide.md @@ -393,8 +393,8 @@ required, please do not proceed. | Hex Data | Binary Data | |:--------:|:---------------------------------------| - | 00088040 | 000000000000100010000000111***0***0000 | - | 00088050 | 000000000000100010000000111***1***0000 | + | 000880E0 | 000000000000100010000000111***0***0000 | + | 000880F0 | 000000000000100010000000111***1***0000 | See how in the above we changed the bit in location 28 from a 0 to 1 0 = No Password, 1 = Use Password @@ -533,7 +533,7 @@ required, please do not proceed. [=] Downlink mode..... default/fixed bit length [=] Password set...... No ``` - Yes we can! We can see Block 0 is the correct config 00088040 + Yes we can! We can see Block 0 is the correct config 000880E0 # Part 2 – Configuration Blocks ^[Top](#top) From 9bd7e41d39c0961cc2e624e7bb3c54730ea1098d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 04:58:29 +0100 Subject: [PATCH 15/30] add dummy length to pass savejson sanity check. Thanks @mwalker33 --- client/src/preferences.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/preferences.c b/client/src/preferences.c index 28ae4d44f..99fb20d30 100644 --- a/client/src/preferences.c +++ b/client/src/preferences.c @@ -152,7 +152,7 @@ int preferences_save(void) { } uint8_t dummyData = 0x00; - size_t dummyDL = 0x00; + size_t dummyDL = 0x01; if (saveFileJSON(fn, jsfCustom, &dummyData, dummyDL, &preferences_save_callback) != PM3_SUCCESS) PrintAndLogEx(ERR, "Error saving preferences to \"%s\"", fn); From 09f2bf9f02910d4c075221784b0b0b0e4af8a1bb Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 04:59:50 +0100 Subject: [PATCH 16/30] style --- armsrc/appmain.c | 16 +- armsrc/iso15693.c | 290 ++++++++++----------- armsrc/iso15693.h | 2 +- client/src/cmdhf15.c | 442 +++++++++++++++----------------- client/src/cmdhw.c | 2 +- client/src/pm3line_vocabulory.h | 6 +- doc/commands.json | 105 +++++++- doc/commands.md | 8 +- 8 files changed, 455 insertions(+), 416 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 734ee85ee..1687767cc 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -455,7 +455,7 @@ static void SendCapabilities(void) { #ifdef RDV4 capabilities.is_rdv4 = true; -#else +#else capabilities.is_rdv4 = false; #endif @@ -1296,7 +1296,7 @@ static void PacketReceived(PacketCommandNG *packet) { case CMD_HF_ISO15693_SLIX_DISABLE_EAS: { struct p { uint8_t pwd[4]; - bool usepwd; + bool usepwd; } PACKED; struct p *payload = (struct p *) packet->data.asBytes; DisableEAS_AFISlixIso15693(payload->pwd, payload->usepwd); @@ -1305,7 +1305,7 @@ static void PacketReceived(PacketCommandNG *packet) { case CMD_HF_ISO15693_SLIX_ENABLE_EAS: { struct p { uint8_t pwd[4]; - bool usepwd; + bool usepwd; } PACKED; struct p *payload = (struct p *) packet->data.asBytes; EnableEAS_AFISlixIso15693(payload->pwd, payload->usepwd); @@ -1333,7 +1333,7 @@ static void PacketReceived(PacketCommandNG *packet) { struct p { uint8_t pwd[4]; } PACKED; - struct p* payload = (struct p*)packet->data.asBytes; + struct p *payload = (struct p *)packet->data.asBytes; EnablePrivacySlixIso15693(payload->pwd); break; } @@ -1341,7 +1341,7 @@ static void PacketReceived(PacketCommandNG *packet) { struct p { uint8_t pwd[4]; } PACKED; - struct p* payload = (struct p*)packet->data.asBytes; + struct p *payload = (struct p *)packet->data.asBytes; PassProtectAFISlixIso15693(payload->pwd); break; } @@ -1353,7 +1353,7 @@ static void PacketReceived(PacketCommandNG *packet) { bool use_uid; uint8_t afi; } PACKED; - struct p* payload = (struct p*)packet->data.asBytes; + struct p *payload = (struct p *)packet->data.asBytes; WriteAFIIso15693(payload->pwd, payload->use_pwd, payload->uid, payload->use_uid, payload->afi); break; } @@ -1361,11 +1361,11 @@ static void PacketReceived(PacketCommandNG *packet) { struct p { uint8_t pwd[4]; } PACKED; - struct p* payload = (struct p*)packet->data.asBytes; + struct p *payload = (struct p *)packet->data.asBytes; PassProtextEASSlixIso15693(payload->pwd); break; } - + #endif #ifdef WITH_LEGICRF diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index 3ca186305..daa84f886 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -177,31 +177,30 @@ static void CodeIso15693AsReaderEOF(void) { } -static int get_uid_slix(uint32_t start_time, uint32_t* eof_time, uint8_t* uid) { +static int get_uid_slix(uint32_t start_time, uint32_t *eof_time, uint8_t *uid) { uint8_t *answer = BigBuf_malloc(ISO15693_MAX_RESPONSE_LENGTH); memset(answer, 0x00, ISO15693_MAX_RESPONSE_LENGTH); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; - + uint8_t cmd[5] = {0}; BuildIdentifyRequest(cmd); uint16_t recvlen = 0; SendDataTag(cmd, sizeof(cmd), false, true, answer, ISO15693_MAX_RESPONSE_LENGTH, start_time, ISO15693_READER_TIMEOUT, eof_time, &recvlen); - - if(recvlen != 12) - { - return PM3_ETIMEOUT; + + if (recvlen != 12) { + return PM3_ETIMEOUT; } - - uid[0] = answer[2]; - uid[1] = answer[3]; + + uid[0] = answer[2]; + uid[1] = answer[3]; uid[2] = answer[4]; uid[3] = answer[5]; uid[4] = answer[6]; uid[5] = answer[7]; uid[6] = answer[8]; - uid[7] = answer[9]; + uid[7] = answer[9]; BigBuf_free(); return PM3_SUCCESS; @@ -2701,7 +2700,7 @@ static bool get_rnd_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t return true; } -static uint32_t disable_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t pass_id, uint8_t* password) { +static uint32_t disable_privacy_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t pass_id, uint8_t *password) { uint8_t rnd[2]; if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { @@ -2723,26 +2722,26 @@ static uint32_t disable_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_ti return PM3_SUCCESS; } -static uint32_t set_pass_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t pass_id, uint8_t* password, uint8_t* uid) { +static uint32_t set_pass_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t pass_id, uint8_t *password, uint8_t *uid) { + - uint8_t rnd[2]; if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } - + // 0x04, == NXP from manufacture id list. - uint8_t c[] = { (ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS), ISO15693_SET_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - + uint8_t c[] = { (ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS), ISO15693_SET_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, pass_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + init_password_15693_Slix(&c[12], password, rnd); - + memcpy(&c[3], uid, 8); AddCrc15(c, 16); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; uint16_t recvlen = 0; - + int res = SendDataTag(c, sizeof(c), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); if (res != PM3_SUCCESS && recvlen != 3) { return PM3_EWRONGANSWER; @@ -2750,7 +2749,7 @@ static uint32_t set_pass_15693_Slix(uint32_t start_time, uint32_t* eof_time, uin return PM3_SUCCESS; } -static uint32_t set_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password) { +static uint32_t set_privacy_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *password) { uint8_t rnd[2]; if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; @@ -2771,28 +2770,26 @@ static uint32_t set_privacy_15693_Slix(uint32_t start_time, uint32_t* eof_time, return PM3_SUCCESS; } -static uint32_t disable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password, bool usepwd) { - +static uint32_t disable_eas_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *password, bool usepwd) { + uint8_t uid[8]; get_uid_slix(start_time, eof_time, uid); - + uint8_t rnd[2]; if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } - - if(usepwd) - { - - int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); - - if(res_setpass != PM3_SUCCESS) - { - return PM3_EWRONGANSWER; - } - } - - // 0x04, == NXP from manufacture id list. + + if (usepwd) { + + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if (res_setpass != PM3_SUCCESS) { + return PM3_EWRONGANSWER; + } + } + + // 0x04, == NXP from manufacture id list. uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, 0xA3, 0x04, 0x00, 0x00}; AddCrc15(c, 3); @@ -2807,24 +2804,22 @@ static uint32_t disable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, } -static uint32_t enable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, uint8_t* password, bool usepwd) { - +static uint32_t enable_eas_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t *password, bool usepwd) { + uint8_t uid[8]; get_uid_slix(start_time, eof_time, uid); - + uint8_t rnd[2]; if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { return PM3_ETIMEOUT; } - - if(usepwd) - { - int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); - - if(res_setpass != PM3_SUCCESS) - { - return PM3_EWRONGANSWER; - } + + if (usepwd) { + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if (res_setpass != PM3_SUCCESS) { + return PM3_EWRONGANSWER; + } } // 0x04, == NXP from manufacture id list. uint8_t c[] = { ISO15_REQ_DATARATE_HIGH, 0xA2, 0x04, 0x00, 0x00}; @@ -2841,106 +2836,100 @@ static uint32_t enable_eas_15693_Slix(uint32_t start_time, uint32_t* eof_time, u return PM3_SUCCESS; } -static uint32_t write_password_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t pwd_id, uint8_t *password, uint8_t* uid) { - +static uint32_t write_password_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint8_t pwd_id, uint8_t *password, uint8_t *uid) { + uint8_t new_pwd_cmd[] = { (ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS), ISO15693_WRITE_PASSWORD, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, pwd_id, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - + memcpy(&new_pwd_cmd[3], uid, 8); memcpy(&new_pwd_cmd[12], password, 4); - + AddCrc15(new_pwd_cmd, 16); start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; uint16_t recvlen = 0; - + int res_wrp = SendDataTag(new_pwd_cmd, sizeof(new_pwd_cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); if (res_wrp != PM3_SUCCESS && recvlen != 3) { return PM3_EWRONGANSWER; } - + return PM3_SUCCESS; } - -static uint32_t pass_protect_EASAFI_15693_Slix(uint32_t start_time, uint32_t *eof_time, bool set_option_flag, uint8_t* password) { - - uint8_t flags; - - if(set_option_flag) - flags = ISO15_REQ_DATARATE_HIGH | ISO15_REQ_OPTION; - else - flags = ISO15_REQ_DATARATE_HIGH; - - - uint8_t uid[8]; - get_uid_slix(start_time, eof_time, uid); - uint8_t rnd[2]; - if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { - return PM3_ETIMEOUT; - } - - int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); - - if(res_setpass != PM3_SUCCESS) - { - return PM3_EWRONGANSWER; - } +static uint32_t pass_protect_EASAFI_15693_Slix(uint32_t start_time, uint32_t *eof_time, bool set_option_flag, uint8_t *password) { - uint8_t new_pass_protect_cmd[] = { flags, ISO15693_PASSWORD_PROTECT_EAS, 0x04, 0x00, 0x00}; - AddCrc15(new_pass_protect_cmd, 3); - - start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; - uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; - uint16_t recvlen = 0; + uint8_t flags; - int res = SendDataTag(new_pass_protect_cmd, sizeof(new_pass_protect_cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); - if (res != PM3_SUCCESS && recvlen != 3) { - return PM3_EWRONGANSWER; - } - - return PM3_SUCCESS; + if (set_option_flag) + flags = ISO15_REQ_DATARATE_HIGH | ISO15_REQ_OPTION; + else + flags = ISO15_REQ_DATARATE_HIGH; + + + uint8_t uid[8]; + get_uid_slix(start_time, eof_time, uid); + + uint8_t rnd[2]; + if (get_rnd_15693_Slix(start_time, eof_time, rnd) == false) { + return PM3_ETIMEOUT; + } + + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if (res_setpass != PM3_SUCCESS) { + return PM3_EWRONGANSWER; + } + + uint8_t new_pass_protect_cmd[] = { flags, ISO15693_PASSWORD_PROTECT_EAS, 0x04, 0x00, 0x00}; + AddCrc15(new_pass_protect_cmd, 3); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res = SendDataTag(new_pass_protect_cmd, sizeof(new_pass_protect_cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS && recvlen != 3) { + return PM3_EWRONGANSWER; + } + + return PM3_SUCCESS; } -static uint32_t write_afi_15693(uint32_t start_time, uint32_t *eof_time, uint8_t *password, bool usepwd, uint8_t *uid, bool use_uid, uint8_t afi) -{ - - if(!use_uid) - { - int res_getuid = get_uid_slix(start_time, eof_time, uid); - - if(res_getuid != PM3_SUCCESS) - { - return res_getuid; - } - } - - if(usepwd) - { - int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); - - if(res_setpass != PM3_SUCCESS) - { - return PM3_EWRONGANSWER; - } - } - - uint8_t cmd[] = { ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_WRITE_AFI, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - memcpy(&cmd[2], uid, 8); - cmd[10] = afi; - AddCrc15(cmd, 11); - - start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; - uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; - uint16_t recvlen = 0; +static uint32_t write_afi_15693(uint32_t start_time, uint32_t *eof_time, uint8_t *password, bool usepwd, uint8_t *uid, bool use_uid, uint8_t afi) { - int res = SendDataTag(cmd, sizeof(cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); - if (res != PM3_SUCCESS || recvlen != 3) { - return PM3_EWRONGANSWER; - } + if (!use_uid) { + int res_getuid = get_uid_slix(start_time, eof_time, uid); - return PM3_SUCCESS; + if (res_getuid != PM3_SUCCESS) { + return res_getuid; + } + } + + if (usepwd) { + int res_setpass = set_pass_15693_Slix(start_time, eof_time, 0x10, password, uid); + + if (res_setpass != PM3_SUCCESS) { + return PM3_EWRONGANSWER; + } + } + + uint8_t cmd[] = { ISO15_REQ_DATARATE_HIGH | ISO15_REQ_ADDRESS, ISO15693_WRITE_AFI, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + memcpy(&cmd[2], uid, 8); + cmd[10] = afi; + AddCrc15(cmd, 11); + + start_time = *eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; + uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH]; + uint16_t recvlen = 0; + + int res = SendDataTag(cmd, sizeof(cmd), false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, eof_time, &recvlen); + if (res != PM3_SUCCESS || recvlen != 3) { + return PM3_EWRONGANSWER; + } + + return PM3_SUCCESS; } /* @@ -3013,29 +3002,28 @@ static uint32_t destroy_15693_Slix(uint32_t start_time, uint32_t *eof_time, uint */ void WritePasswordSlixIso15693(uint8_t *old_password, uint8_t *new_password, uint8_t pwd_id) { - LED_D_ON(); - Iso15693InitReader(); - StartCountSspClk(); - uint32_t start_time = 0, eof_time = 0; - int res = PM3_EFAILED; - - uint8_t uid[8]; - get_uid_slix(start_time, &eof_time, uid); + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + int res = PM3_EFAILED; + + uint8_t uid[8]; + get_uid_slix(start_time, &eof_time, uid); + + res = set_pass_15693_Slix(start_time, &eof_time, pwd_id, old_password, uid); + if (res != PM3_SUCCESS) { + reply_ng(CMD_HF_ISO15693_SLIX_WRITE_PWD, res, NULL, 0); + switch_off(); + return; + } + + res = write_password_15693_Slix(start_time, &eof_time, pwd_id, new_password, uid); - res = set_pass_15693_Slix(start_time, &eof_time, pwd_id, old_password, uid); - if(res != PM3_SUCCESS) - { reply_ng(CMD_HF_ISO15693_SLIX_WRITE_PWD, res, NULL, 0); - switch_off(); - return; - } - res = write_password_15693_Slix(start_time, &eof_time, pwd_id, new_password, uid); - - reply_ng(CMD_HF_ISO15693_SLIX_WRITE_PWD, res, NULL, 0); - - switch_off(); - + switch_off(); + } void DisablePrivacySlixIso15693(uint8_t *password) { @@ -3053,7 +3041,7 @@ void DisablePrivacySlixIso15693(uint8_t *password) { switch_off(); } -void EnablePrivacySlixIso15693(uint8_t* password) { +void EnablePrivacySlixIso15693(uint8_t *password) { LED_D_ON(); Iso15693InitReader(); StartCountSspClk(); @@ -3080,9 +3068,9 @@ void DisableEAS_AFISlixIso15693(uint8_t *password, bool usepwd) { // 0x08 Destroy SLIX-L // 0x10 EAS/AFI int res = disable_eas_15693_Slix(start_time, &eof_time, password, usepwd); - - - + + + reply_ng(CMD_HF_ISO15693_SLIX_DISABLE_EAS, res, NULL, 0); switch_off(); } @@ -3130,4 +3118,4 @@ void WriteAFIIso15693(uint8_t *password, bool use_pwd, uint8_t *uid, bool use_ui //int res = PM3_SUCCESS; reply_ng(CMD_HF_ISO15693_WRITE_AFI, res, NULL, 0); switch_off(); -} \ No newline at end of file +} diff --git a/armsrc/iso15693.h b/armsrc/iso15693.h index c0ff44929..b087edd2e 100644 --- a/armsrc/iso15693.h +++ b/armsrc/iso15693.h @@ -64,7 +64,7 @@ void SetTag15693Uid(const uint8_t *uid); void WritePasswordSlixIso15693(uint8_t *old_password, uint8_t *new_password, uint8_t pwd_id); void DisablePrivacySlixIso15693(uint8_t *password); -void EnablePrivacySlixIso15693(uint8_t* password); +void EnablePrivacySlixIso15693(uint8_t *password); void DisableEAS_AFISlixIso15693(uint8_t *password, bool usepwd); void EnableEAS_AFISlixIso15693(uint8_t *password, bool usepwd); void PassProtextEASSlixIso15693(uint8_t *password); diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 590393c61..9c7f1528d 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -698,7 +698,7 @@ static int NxpCheckSig(uint8_t *uid) { PacketResponseNG resp; uint16_t reqlen = 0; uint8_t req[PM3_CMD_DATA_SIZE] = {0}; - + // Check if we can also read the signature req[reqlen++] |= ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS; req[reqlen++] = ISO15693_READ_SIGNATURE; @@ -736,7 +736,7 @@ static int NxpCheckSig(uint8_t *uid) { memcpy(signature, recv + 1, 32); nxp_15693_print_signature(uid, signature); - + return PM3_SUCCESS; } @@ -1363,7 +1363,7 @@ static int CmdHF15WriteAfi(const char *Cmd) { argtable[4] = arg_param_end; CLIExecWithReturn(ctx, Cmd, argtable, true); - + struct { uint8_t pwd[4]; bool use_pwd; @@ -1376,21 +1376,19 @@ static int CmdHF15WriteAfi(const char *Cmd) { CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); payload.afi = arg_get_int_def(ctx, 2, 0); - + int pwdlen; - + CLIGetHexWithReturn(ctx, 3, payload.pwd, &pwdlen); - + CLIParserFree(ctx); - - if(pwdlen == 4) - { + + if (pwdlen == 4) { payload.use_pwd = true; } - - if(uidlen == 8) - { - payload.use_uid = true; + + if (uidlen == 8) { + payload.use_uid = true; } // sanity checks @@ -1398,11 +1396,10 @@ static int CmdHF15WriteAfi(const char *Cmd) { PrintAndLogEx(WARNING, "uid must be 8 hex bytes if provided"); return PM3_EINVARG; } - - if(pwdlen > 0 && pwdlen != 4) - { + + if (pwdlen > 0 && pwdlen != 4) { PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); - return PM3_ESOFT; + return PM3_ESOFT; } PacketResponseNG resp; @@ -1420,11 +1417,11 @@ static int CmdHF15WriteAfi(const char *Cmd) { break; } case PM3_EWRONGANSWER: { - PrintAndLogEx(WARNING, "error writing AFI"); + PrintAndLogEx(WARNING, "error writing AFI"); break; } case PM3_SUCCESS: { - PrintAndLogEx(SUCCESS, "Wrote AFI 0x%02X", payload.afi); + PrintAndLogEx(SUCCESS, "Wrote AFI 0x%02X", payload.afi); break; } } @@ -2385,29 +2382,25 @@ static int CmdHF15SlixEASEnable(const char *Cmd) { bool usepwd; } PACKED payload; int pwdlen = 0; - + int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); - if((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) - { + if ((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) { PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); - return PM3_ESOFT; + return PM3_ESOFT; } - + //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); CLIParserFree(ctx); - - - if(pwdlen > 0 ) - { - PrintAndLogEx(INFO, "Trying to enable EAS mode using password " _GREEN_("%s") - , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) - ); - payload.usepwd = true; - } - else - { - PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); - payload.usepwd = false; + + + if (pwdlen > 0) { + PrintAndLogEx(INFO, "Trying to enable EAS mode using password " _GREEN_("%s") + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); + payload.usepwd = true; + } else { + PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); + payload.usepwd = false; } @@ -2426,13 +2419,10 @@ static int CmdHF15SlixEASEnable(const char *Cmd) { break; } case PM3_EWRONGANSWER: { - if(pwdlen > 0 ) - { - PrintAndLogEx(WARNING, "the password provided was not accepted"); - } - else - { - PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); + if (pwdlen > 0) { + PrintAndLogEx(WARNING, "the password provided was not accepted"); + } else { + PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); } break; } @@ -2451,7 +2441,7 @@ static int CmdHF15SlixEASDisable(const char *Cmd) { "Disable EAS mode on SLIX ISO-15693 tag", "hf 15 slixeasdisable -p 0F0F0F0F"); - void *argtable[] = { + void *argtable[] = { arg_param_begin, arg_str0("p", "pwd", "", "optional password, 8 hex bytes"), arg_param_end @@ -2460,32 +2450,28 @@ static int CmdHF15SlixEASDisable(const char *Cmd) { struct { uint8_t pwd[4]; bool usepwd; - + } PACKED payload; int pwdlen = 0; - + int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); - if((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) - { + if ((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) { PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); - return PM3_ESOFT; + return PM3_ESOFT; } - + //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); CLIParserFree(ctx); - - - if(pwdlen > 0 ) - { - PrintAndLogEx(INFO, "Trying to disable EAS mode using password " _GREEN_("%s") - , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) - ); - payload.usepwd = true; - } - else - { - PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); - payload.usepwd = false; + + + if (pwdlen > 0) { + PrintAndLogEx(INFO, "Trying to disable EAS mode using password " _GREEN_("%s") + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); + payload.usepwd = true; + } else { + PrintAndLogEx(INFO, "Trying to enable EAS mode without using a password"); + payload.usepwd = false; } PacketResponseNG resp; @@ -2503,13 +2489,10 @@ static int CmdHF15SlixEASDisable(const char *Cmd) { break; } case PM3_EWRONGANSWER: { - if(pwdlen > 0 ) - { - PrintAndLogEx(WARNING, "the password provided was not accepted"); - } - else - { - PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); + if (pwdlen > 0) { + PrintAndLogEx(WARNING, "the password provided was not accepted"); + } else { + PrintAndLogEx(WARNING, "either a password is required or EAS mode is locked"); } break; } @@ -2571,14 +2554,14 @@ static int CmdHF15SlixDisable(const char *Cmd) { return resp.status; } -static int CmdHF15SlixEnable(const char* Cmd) { +static int CmdHF15SlixEnable(const char *Cmd) { - CLIParserContext* ctx; + CLIParserContext *ctx; CLIParserInit(&ctx, "hf 15 slixprivacyenable", - "Enable privacy mode on SLIX ISO-15693 tag", - "hf 15 slixenable -p 0F0F0F0F"); + "Enable privacy mode on SLIX ISO-15693 tag", + "hf 15 slixenable -p 0F0F0F0F"); - void* argtable[] = { + void *argtable[] = { arg_param_begin, arg_str1("p", "pwd", "", "password, 8 hex bytes"), arg_param_end @@ -2592,12 +2575,12 @@ static int CmdHF15SlixEnable(const char* Cmd) { CLIParserFree(ctx); PrintAndLogEx(INFO, "Trying to enable privacy mode using password " _GREEN_("%s") - , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) - ); + , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) + ); PacketResponseNG resp; clearCommandBuffer(); - SendCommandNG(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, (uint8_t*)&payload, sizeof(payload)); + SendCommandNG(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, (uint8_t *)&payload, sizeof(payload)); if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_ENABLE_PRIVACY, &resp, 2000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply"); DropField(); @@ -2605,18 +2588,18 @@ static int CmdHF15SlixEnable(const char* Cmd) { } switch (resp.status) { - case PM3_ETIMEOUT: { - PrintAndLogEx(WARNING, "no tag found"); - break; - } - case PM3_EWRONGANSWER: { - PrintAndLogEx(WARNING, "password was not accepted"); - break; - } - case PM3_SUCCESS: { - PrintAndLogEx(SUCCESS, "privacy mode is now enabled ( " _GREEN_("ok") " ) "); - break; - } + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "password was not accepted"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "privacy mode is now enabled ( " _GREEN_("ok") " ) "); + break; + } } return resp.status; } @@ -2634,73 +2617,60 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { arg_str1("n", "new", "", "new password, 8 hex bytes"), arg_param_end }; - + CLIExecWithReturn(ctx, Cmd, argtable, false); - + struct { uint8_t old_pwd[4]; uint8_t new_pwd[4]; uint8_t pwd_id; } PACKED payload; int pwdlen = 0; - - - + + + CLIGetHexWithReturn(ctx, 2, payload.old_pwd, &pwdlen); - - if(pwdlen > 0 && pwdlen != 4) - { + + if (pwdlen > 0 && pwdlen != 4) { PrintAndLogEx(WARNING, "old password must be 4 hex bytes if provided"); - return PM3_ESOFT; + return PM3_ESOFT; } - + CLIGetHexWithReturn(ctx, 3, payload.new_pwd, &pwdlen); - - if(pwdlen != 4) - { + + if (pwdlen != 4) { PrintAndLogEx(WARNING, "new password must be 4 hex bytes"); - return PM3_ESOFT; + return PM3_ESOFT; } - + int vlen = 0; char value[10]; CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)value, sizeof(value), &vlen); - + if (vlen > 0) { - if (strcmp(value, "read") == 0) - { + if (strcmp(value, "read") == 0) { PrintAndLogEx(SUCCESS, "Selected read pass"); payload.pwd_id = 0x01; - } - else if (strcmp(value, "write") == 0) - { + } else if (strcmp(value, "write") == 0) { PrintAndLogEx(SUCCESS, "Selected write pass"); payload.pwd_id = 0x02; - } - else if (strcmp(value, "privacy") == 0) - { + } else if (strcmp(value, "privacy") == 0) { PrintAndLogEx(SUCCESS, "Selected privacy pass"); payload.pwd_id = 0x04; - } - else if (strcmp(value, "destroy") == 0) - { + } else if (strcmp(value, "destroy") == 0) { PrintAndLogEx(SUCCESS, "Selected destroy pass"); payload.pwd_id = 0x08; - } - else if (strcmp(value, "easafi") == 0) - { + } else if (strcmp(value, "easafi") == 0) { PrintAndLogEx(SUCCESS, "Selected easafi pass"); payload.pwd_id = 0x10; - } - else - { + } else { PrintAndLogEx(ERR, "t argument must be 'read', 'write', 'privacy', 'destroy', or 'easafi'"); return PM3_EINVARG; } } - + CLIParserFree(ctx); - + PrintAndLogEx(INFO, "Trying to write " _YELLOW_("%s") " as " _YELLOW_("%s") " password" , sprint_hex_inrow(payload.new_pwd, sizeof(payload.new_pwd)), value); @@ -2732,135 +2702,131 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { } static int CmdHF15AFIPassProtect(const char *Cmd) { - - CLIParserContext *ctx; - CLIParserInit(&ctx, "hf 15 passprotectafi", - "Password protect AFI. Cannot be undone.", - "hf 15 passprotectafi -p 00000000 -c"); - void *argtable[] = { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 passprotectafi", + "Password protect AFI. Cannot be undone.", + "hf 15 passprotectafi -p 00000000 -c"); + + void *argtable[] = { arg_param_begin, arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), arg_param_end }; - - CLIExecWithReturn(ctx, Cmd, argtable, true); - - struct { - uint8_t pwd[4]; - } PACKED payload; - int pwdlen = 0; - - CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); - - bool confirmation = arg_get_lit(ctx, 2); - - if(pwdlen != 4) - { - PrintAndLogEx(WARNING, "password must be 4 hex bytes"); - return PM3_ESOFT; - } - - if(confirmation == 0) - { - PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); - return PM3_ESOFT; - } - - - PrintAndLogEx(INFO, "Trying to enable AFI password protection"); - - PacketResponseNG resp; - clearCommandBuffer(); - SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, (uint8_t*)&payload, sizeof(payload)); - if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, &resp, 2000) == false) { - PrintAndLogEx(WARNING, "timeout while waiting for reply"); - DropField(); - return PM3_ESOFT; - } - switch (resp.status) { - case PM3_ETIMEOUT: { - PrintAndLogEx(WARNING, "no tag found"); - break; - } - case PM3_EWRONGANSWER: { - PrintAndLogEx(WARNING, "error enabling AFI password protection"); - break; - } - case PM3_SUCCESS: { - PrintAndLogEx(SUCCESS, "AFI password protected ( " _GREEN_("ok") " ) "); - break; - } - } - return resp.status; - + CLIExecWithReturn(ctx, Cmd, argtable, true); + + struct { + uint8_t pwd[4]; + } PACKED payload; + int pwdlen = 0; + + CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + + bool confirmation = arg_get_lit(ctx, 2); + + if (pwdlen != 4) { + PrintAndLogEx(WARNING, "password must be 4 hex bytes"); + return PM3_ESOFT; + } + + if (confirmation == 0) { + PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + return PM3_ESOFT; + } + + + PrintAndLogEx(INFO, "Trying to enable AFI password protection"); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_AFI, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "error enabling AFI password protection"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "AFI password protected ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; + } static int CmdHF15EASPassProtect(const char *Cmd) { - - CLIParserContext *ctx; - CLIParserInit(&ctx, "hf 15 passprotecteas", - "Password protect EAS. Cannot be undone.", - "hf 15 passprotecteas -p 00000000 -c"); - - void *argtable[] = { + + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf 15 passprotecteas", + "Password protect EAS. Cannot be undone.", + "hf 15 passprotecteas -p 00000000 -c"); + + void *argtable[] = { arg_param_begin, arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), arg_param_end }; - CLIExecWithReturn(ctx, Cmd, argtable, true); - - struct { - uint8_t pwd[4]; - } PACKED payload; - int pwdlen = 0; - - CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); - - bool confirmation = arg_get_lit(ctx, 2); - - if(pwdlen != 4) - { - PrintAndLogEx(WARNING, "password must be 4 hex bytes"); - return PM3_ESOFT; - } - - if(confirmation == 0) - { - PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); - return PM3_ESOFT; - } - - PrintAndLogEx(INFO, "Trying to enable EAS password protection"); - - PacketResponseNG resp; - clearCommandBuffer(); - SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, (uint8_t*)&payload, sizeof(payload)); - if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, &resp, 2000) == false) { - PrintAndLogEx(WARNING, "timeout while waiting for reply"); - DropField(); - return PM3_ESOFT; - } + CLIExecWithReturn(ctx, Cmd, argtable, true); - switch (resp.status) { - case PM3_ETIMEOUT: { - PrintAndLogEx(WARNING, "no tag found"); - break; - } - case PM3_EWRONGANSWER: { - PrintAndLogEx(WARNING, "error enabling EAS password protection"); - break; - } - case PM3_SUCCESS: { - PrintAndLogEx(SUCCESS, "EAS password protected ( " _GREEN_("ok") " ) "); - break; - } - } - return resp.status; + struct { + uint8_t pwd[4]; + } PACKED payload; + int pwdlen = 0; + + CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); + + bool confirmation = arg_get_lit(ctx, 2); + + if (pwdlen != 4) { + PrintAndLogEx(WARNING, "password must be 4 hex bytes"); + return PM3_ESOFT; + } + + if (confirmation == 0) { + PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + return PM3_ESOFT; + } + + PrintAndLogEx(INFO, "Trying to enable EAS password protection"); + + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, (uint8_t *)&payload, sizeof(payload)); + if (WaitForResponseTimeout(CMD_HF_ISO15693_SLIX_PASS_PROTECT_EAS, &resp, 2000) == false) { + PrintAndLogEx(WARNING, "timeout while waiting for reply"); + DropField(); + return PM3_ESOFT; + } + + switch (resp.status) { + case PM3_ETIMEOUT: { + PrintAndLogEx(WARNING, "no tag found"); + break; + } + case PM3_EWRONGANSWER: { + PrintAndLogEx(WARNING, "error enabling EAS password protection"); + break; + } + case PM3_SUCCESS: { + PrintAndLogEx(SUCCESS, "EAS password protected ( " _GREEN_("ok") " ) "); + break; + } + } + return resp.status; } static command_t CommandTable[] = { diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 67f404bc9..ed208b5f5 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -1301,7 +1301,7 @@ void pm3_version(bool verbose, bool oneliner) { if (IfPm3Flash()) { PrintAndLogEx(NORMAL, " external flash............ %s", _GREEN_("present")); } - + if (IfPm3FpcUsartHost()) { PrintAndLogEx(NORMAL, " FPC USART for BT add-on... %s", _GREEN_("present")); } diff --git a/client/src/pm3line_vocabulory.h b/client/src/pm3line_vocabulory.h index ee94f7ec0..bcf196fe9 100644 --- a/client/src/pm3line_vocabulory.h +++ b/client/src/pm3line_vocabulory.h @@ -181,9 +181,9 @@ const static vocabulory_t vocabulory[] = { { 0, "hf 15 slixeasdisable" }, { 0, "hf 15 slixeasenable" }, { 0, "hf 15 slixprivacydisable" }, - { 0, "hf 15 slixprivacyenable" }, - { 0, "hf 15 passprotectafi" }, - { 0, "hf 15 passprotecteas" }, + { 0, "hf 15 slixprivacyenable" }, + { 0, "hf 15 passprotectafi" }, + { 0, "hf 15 passprotecteas" }, { 0, "hf 15 wrbl" }, { 0, "hf 15 findafi" }, { 0, "hf 15 writeafi" }, diff --git a/doc/commands.json b/doc/commands.json index bb781adb7..8d028d9e9 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1656,6 +1656,34 @@ ], "usage": "hf 15 list [-h1crux] [--frame] [-f ]" }, + "hf 15 passprotectafi": { + "command": "hf 15 passprotectafi", + "description": "Password protect AFI. Cannot be undone.", + "notes": [ + "hf 15 passprotectafi -p 00000000 -c" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-p, --password EAS/AFI password, 8 hex bytes", + "-c, --confirm confirm the execution of this irreversible command" + ], + "usage": "hf 15 passprotectafi [-hc] -p " + }, + "hf 15 passprotecteas": { + "command": "hf 15 passprotecteas", + "description": "Password protect EAS. Cannot be undone.", + "notes": [ + "hf 15 passprotecteas -p 00000000 -c" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-p, --password EAS/AFI password, 8 hex bytes", + "-c, --confirm confirm the execution of this irreversible command" + ], + "usage": "hf 15 passprotecteas [-hc] -p " + }, "hf 15 raw": { "command": "hf 15 raw", "description": "Sends raw bytes over ISO-15693 to card", @@ -1776,8 +1804,34 @@ ], "usage": "hf 15 sim [-h] -u <8b hex> [-b ]" }, - "hf 15 slixdisable": { - "command": "hf 15 slixdisable", + "hf 15 slixeasdisable": { + "command": "hf 15 slixeasdisable", + "description": "Disable EAS mode on SLIX ISO-15693 tag", + "notes": [ + "hf 15 slixeasdisable -p 0F0F0F0F" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-p, --pwd optional password, 8 hex bytes" + ], + "usage": "hf 15 slixeasdisable [-h] [-p ]" + }, + "hf 15 slixeasenable": { + "command": "hf 15 slixeasenable", + "description": "Enable EAS mode on SLIX ISO-15693 tag", + "notes": [ + "hf 15 slixeasenable -p 0F0F0F0F" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-p, --pwd optional password, 8 hex bytes" + ], + "usage": "hf 15 slixeasenable [-h] [-p ]" + }, + "hf 15 slixprivacydisable": { + "command": "hf 15 slixprivacydisable", "description": "Disable privacy mode on SLIX ISO-15693 tag", "notes": [ "hf 15 slixdisable -p 0F0F0F0F" @@ -1787,7 +1841,35 @@ "-h, --help This help", "-p, --pwd password, 8 hex bytes" ], - "usage": "hf 15 slixdisable [-h] -p " + "usage": "hf 15 slixprivacydisable [-h] -p " + }, + "hf 15 slixprivacyenable": { + "command": "hf 15 slixprivacyenable", + "description": "Enable privacy mode on SLIX ISO-15693 tag", + "notes": [ + "hf 15 slixenable -p 0F0F0F0F" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-p, --pwd password, 8 hex bytes" + ], + "usage": "hf 15 slixprivacyenable [-h] -p " + }, + "hf 15 slixwritepwd": { + "command": "hf 15 slixwritepwd", + "description": "Write a password on a SLIX family ISO-15693 tag", + "notes": [ + "hf 15 slixwritepwd -t READ -o 00000000 -n 12131415" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-t, --type which password field to write to (some tags do not support all password types)", + "-o, --old old password (if present), 8 hex bytes", + "-n, --new new password, 8 hex bytes" + ], + "usage": "hf 15 slixwritepwd [-h] -t [-o ] -n " }, "hf 15 sniff": { "command": "hf 15 sniff", @@ -1827,19 +1909,16 @@ "description": "Write AFI on card", "notes": [ "hf 15 writeafi -* --afi 12", - "hf 15 writeafi -u E011223344556677 --afi 12" + "hf 15 writeafi -u E011223344556677 --afi 12 -p 0F0F0F0F" ], "offline": false, "options": [ "-h, --help This help", "-u, --uid full UID, 8 bytes", - "--ua unaddressed mode", - "-* scan for tag", - "-2 use slower '1 out of 256' mode", - "-o, --opt set OPTION Flag (needed for TI)", - "--afi AFI number (0-255)" + "--afi AFI number (0-255)", + "-p, --pwd optional AFI/EAS password" ], - "usage": "hf 15 writeafi [-h*2o] [-u ] [--ua] --afi " + "usage": "hf 15 writeafi [-h] [-u ] --afi [-p ]" }, "hf 15 writedsfid": { "command": "hf 15 writedsfid", @@ -11408,7 +11487,7 @@ }, "script help": { "command": "script help", - "description": "This is a feature to run Lua/Cmd/Python scripts. You can place scripts within the luascripts/cmdscripts/pyscripts folders. --------------------------------------------------------------------------------------- script list available offline: yes", + "description": "This is a feature to run Lua/Cmd scripts. You can place scripts within the luascripts/cmdscripts folders. --------------------------------------------------------------------------------------- script list available offline: yes", "notes": [], "offline": true, "options": [], @@ -11803,8 +11882,8 @@ } }, "metadata": { - "commands_extracted": 742, + "commands_extracted": 748, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2023-01-27T01:57:37" + "extracted_on": "2023-01-29T03:58:53" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index 79499915b..382c98b58 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -236,7 +236,13 @@ Check column "offline" for their availability. |`hf 15 esave `|N |`Save emulator memory into image file` |`hf 15 eview `|N |`View emulator memory` |`hf 15 sim `|N |`Fake an ISO-15693 tag` -|`hf 15 slixdisable `|N |`Disable privacy mode on SLIX ISO-15693 tag` +|`hf 15 slixwritepwd `|N |`Writes a password on a SLIX ISO-15693 tag` +|`hf 15 slixeasdisable `|N |`Disable EAS mode on SLIX ISO-15693 tag` +|`hf 15 slixeasenable `|N |`Enable EAS mode on SLIX ISO-15693 tag` +|`hf 15 slixprivacydisable`|N |`Disable privacy mode on SLIX ISO-15693 tag` +|`hf 15 slixprivacyenable`|N |`Enable privacy mode on SLIX ISO-15693 tag` +|`hf 15 passprotectafi `|N |`Password protect AFI - Cannot be undone` +|`hf 15 passprotecteas `|N |`Password protect EAS - Cannot be undone` |`hf 15 wrbl `|N |`Write a block` |`hf 15 findafi `|N |`Brute force AFI of an ISO-15693 tag` |`hf 15 writeafi `|N |`Writes the AFI on an ISO-15693 tag` From cd96fbfcc9daaeb4d154e962c348ef456f7a90ce Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 06:35:31 +0100 Subject: [PATCH 17/30] text --- client/src/proxmark3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 9ca38a2a1..378b9f0dc 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -41,7 +41,7 @@ static int mainret = PM3_ESOFT; #ifndef LIBPM3 #define BANNERMSG1 "" -#define BANNERMSG2 " [ :snowflake: ]" +#define BANNERMSG2 " [ :coffee: ]" #define BANNERMSG3 "" typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode; From 2633a54e11670a0144bcf11ce308b3eba644773c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 29 Jan 2023 15:16:38 +0100 Subject: [PATCH 18/30] build_all_firmwares.sh: skip NFCBARCODE support for 256kb builds --- tools/build_all_firmwares.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_all_firmwares.sh b/tools/build_all_firmwares.sh index b76f7a45a..a0253e789 100755 --- a/tools/build_all_firmwares.sh +++ b/tools/build_all_firmwares.sh @@ -22,7 +22,7 @@ echo "Destination: ${DEST:=firmware}" echo "Produce stats?: ${STATS:=false}" # Which parts to skip for the 256kb version? -SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1" +SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1 SKIP_NFCBARCODE=1" make $MKFLAGS bootrom || exit 1 chmod 644 bootrom/obj/bootrom.elf From db6a0ab5efb90f76c7933b29901e03247331932c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:02:45 +0100 Subject: [PATCH 19/30] coverity fix #40581, #404580, #40579... --- client/src/cmdhf15.c | 46 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 9c7f1528d..5a58162bc 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1378,15 +1378,16 @@ static int CmdHF15WriteAfi(const char *Cmd) { payload.afi = arg_get_int_def(ctx, 2, 0); int pwdlen; - CLIGetHexWithReturn(ctx, 3, payload.pwd, &pwdlen); CLIParserFree(ctx); + payload.use_pwd = false; if (pwdlen == 4) { payload.use_pwd = true; } + payload.use_uid = false; if (uidlen == 8) { payload.use_uid = true; } @@ -2386,13 +2387,12 @@ static int CmdHF15SlixEASEnable(const char *Cmd) { int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); if ((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) { PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); + CLIParserFree(ctx); return PM3_ESOFT; } - //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); CLIParserFree(ctx); - if (pwdlen > 0) { PrintAndLogEx(INFO, "Trying to enable EAS mode using password " _GREEN_("%s") , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) @@ -2627,12 +2627,11 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { } PACKED payload; int pwdlen = 0; - - CLIGetHexWithReturn(ctx, 2, payload.old_pwd, &pwdlen); if (pwdlen > 0 && pwdlen != 4) { PrintAndLogEx(WARNING, "old password must be 4 hex bytes if provided"); + CLIParserFree(ctx); return PM3_ESOFT; } @@ -2640,6 +2639,7 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { if (pwdlen != 4) { PrintAndLogEx(WARNING, "new password must be 4 hex bytes"); + CLIParserFree(ctx); return PM3_ESOFT; } @@ -2671,7 +2671,6 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { CLIParserFree(ctx); - PrintAndLogEx(INFO, "Trying to write " _YELLOW_("%s") " as " _YELLOW_("%s") " password" , sprint_hex_inrow(payload.new_pwd, sizeof(payload.new_pwd)), value); @@ -2705,13 +2704,14 @@ static int CmdHF15AFIPassProtect(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 15 passprotectafi", - "Password protect AFI. Cannot be undone.", - "hf 15 passprotectafi -p 00000000 -c"); + "This command enables the password protect of AFI.\n" + "*** OBS! This action can not be undone! ***", + "hf 15 passprotectafi -p 00000000 --force"); void *argtable[] = { arg_param_begin, - arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), - arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), + arg_str1("p", "pwd", "", "EAS/AFI password, 8 hex bytes"), + arg_lit0(NULL, "force", "Force execution of command (irreversible) "), arg_param_end }; @@ -2724,20 +2724,20 @@ static int CmdHF15AFIPassProtect(const char *Cmd) { CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); - bool confirmation = arg_get_lit(ctx, 2); + bool force = arg_get_lit(ctx, 2); + CLIParserFree(ctx); if (pwdlen != 4) { PrintAndLogEx(WARNING, "password must be 4 hex bytes"); return PM3_ESOFT; } - if (confirmation == 0) { - PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + if (force == false) { + PrintAndLogEx(WARNING, "Use `--force` flag to override. OBS! Irreversable command"); return PM3_ESOFT; } - - PrintAndLogEx(INFO, "Trying to enable AFI password protection"); + PrintAndLogEx(INFO, "Trying to enable AFI password protection..."); PacketResponseNG resp; clearCommandBuffer(); @@ -2770,13 +2770,14 @@ static int CmdHF15EASPassProtect(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 15 passprotecteas", - "Password protect EAS. Cannot be undone.", - "hf 15 passprotecteas -p 00000000 -c"); + "This command enables the password protect of EAS.\n" + "*** OBS! This action can not be undone! ***", + "hf 15 passprotecteas -p 00000000 --force"); void *argtable[] = { arg_param_begin, arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), - arg_lit0("c", "confirm", "confirm the execution of this irreversible command"), + arg_lit0(NULL, "force", "Force execution of command (irreversible) "), arg_param_end }; @@ -2789,19 +2790,20 @@ static int CmdHF15EASPassProtect(const char *Cmd) { CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); - bool confirmation = arg_get_lit(ctx, 2); + bool force = arg_get_lit(ctx, 2); + CLIParserFree(ctx); if (pwdlen != 4) { PrintAndLogEx(WARNING, "password must be 4 hex bytes"); return PM3_ESOFT; } - if (confirmation == 0) { - PrintAndLogEx(WARNING, "This irreversible command must be confirmed with the -c flag"); + if (force == false) { + PrintAndLogEx(WARNING, "Use `--force` flag to override. OBS! Irreversable command"); return PM3_ESOFT; } - PrintAndLogEx(INFO, "Trying to enable EAS password protection"); + PrintAndLogEx(INFO, "Trying to enable EAS password protection..."); PacketResponseNG resp; clearCommandBuffer(); From 30538c20ae5a839a0869e161ee60cd0e1e9b94b6 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:05:47 +0100 Subject: [PATCH 20/30] coverity fix #404575 --- client/src/cmdhf15.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 5a58162bc..92e42d717 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -2447,6 +2447,7 @@ static int CmdHF15SlixEASDisable(const char *Cmd) { arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); + struct { uint8_t pwd[4]; bool usepwd; @@ -2455,15 +2456,13 @@ static int CmdHF15SlixEASDisable(const char *Cmd) { int pwdlen = 0; int ret_pwdparse = CLIParamHexToBuf(arg_get_str(ctx, 1), payload.pwd, 4, &pwdlen); + CLIParserFree(ctx); + if ((pwdlen > 0 && pwdlen != 4) || ret_pwdparse != 0) { PrintAndLogEx(WARNING, "password must be 4 hex bytes if provided"); return PM3_ESOFT; } - //CLIGetHexWithReturn(ctx, 1, payload.pwd, &pwdlen); - CLIParserFree(ctx); - - if (pwdlen > 0) { PrintAndLogEx(INFO, "Trying to disable EAS mode using password " _GREEN_("%s") , sprint_hex_inrow(payload.pwd, sizeof(payload.pwd)) @@ -2776,7 +2775,7 @@ static int CmdHF15EASPassProtect(const char *Cmd) { void *argtable[] = { arg_param_begin, - arg_str1("p", "password", "", "EAS/AFI password, 8 hex bytes"), + arg_str1("p", "pwd", "", "EAS/AFI password, 8 hex bytes"), arg_lit0(NULL, "force", "Force execution of command (irreversible) "), arg_param_end }; From b217b4e39d0bed09f3600c59f3db48d514a1674c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:07:59 +0100 Subject: [PATCH 21/30] fix coverity #404576 --- client/src/cmdhf14a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index d0ba31cd0..2c6bc740a 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1460,8 +1460,9 @@ static int CmdHF14AChaining(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 14a chaining", "Enable/Disable ISO14443a input chaining. Maximum input length goes from ATS.", + "hf 14a chaining -> show chaining enable/disable state\n" "hf 14a chaining --off -> disable chaining\n" - "hf 14a chaining -> show chaining enable/disable state\n"); + ); void *argtable[] = { arg_param_begin, @@ -1473,6 +1474,7 @@ static int CmdHF14AChaining(const char *Cmd) { bool on = arg_get_lit(ctx, 1); bool off = arg_get_lit(ctx, 2); + CLIParserFree(ctx); if ((on + off) > 1) { PrintAndLogEx(INFO, "Select only one option"); @@ -1485,8 +1487,6 @@ static int CmdHF14AChaining(const char *Cmd) { if (off) Set_apdu_in_framing(false); - CLIParserFree(ctx); - PrintAndLogEx(INFO, "\nISO 14443-4 input chaining %s.\n", g_apdu_in_framing_enable ? "enabled" : "disabled"); return PM3_SUCCESS; } From b24d7736c59157640edb036e0dcf132b49acba53 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:14:49 +0100 Subject: [PATCH 22/30] fix coverity #322661 --- client/src/cmdflashmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/cmdflashmem.c b/client/src/cmdflashmem.c index f01531d55..7bbdf74c9 100644 --- a/client/src/cmdflashmem.c +++ b/client/src/cmdflashmem.c @@ -641,6 +641,10 @@ static int CmdFlashMemInfo(const char *Cmd) { // Verify (public key) bool is_verified = (mbedtls_rsa_pkcs1_verify(rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA1, 20, sha_hash, from_device) == 0); + if (got_private == false) { + mbedtls_rsa_free(rsa); + } + mbedtls_pk_free(&pkctx); PrintAndLogEx(NORMAL, ""); From 568e35ca84f54a831a66eba1bd42b61cfe6d314d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:32:15 +0100 Subject: [PATCH 23/30] style --- CHANGELOG.md | 12 ++++++++---- client/src/cmdhf14a.c | 2 +- client/src/cmdhf15.c | 6 +++--- doc/commands.json | 26 +++++++++++++------------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 936e087f5..285cd6bf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + +## [Nitride][2023-01-29] + - Changed `build_all_firmwares.sh` to fit GENERIC 256kb firmware images (@doegox) + - Fixed some coverity fixes (@iceman1001) + - Fixed `make accessrights` on Fedora (@mooey5775) + - Fixed `hf mfu info` - can now identify the 50 pF version of NTAG 210u(micro) (@mjacksn) + - Added `hf 15` sub-commands for controlling EAS, AFI, privacy mode, and the setting of passwords on SLIX tags (@mjacksn) - Added new magic gen4 cards command in docs (@McEloff) - Added `hf tesla info` - intital information command to read TESLA cards (@iceman1001) - Changed `hf emrtd info` - looking for lower case .bin extensions (@iceman1001) @@ -41,9 +48,6 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `pm3` shell script now automatically detects WSL2 with USBIPD serial ports (@iceman1001) - Fixed `trace list -c` - annotation of CRC bytes now is colored or squared if no ansi colors is supported (@iceman1001) - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - - Fixed `make accessrights` on Fedora (@mooey5775) - - Fixed `hf mfu info` - can now identify the 50 pF version of NTAG 210u(micro) (@mjacksn) - - Added `hf 15` sub-commands for controlling EAS, AFI, privacy mode, and the setting of passwords on SLIX tags (@mjacksn) ## [Radium.4.15864][2022-10-29] @@ -1373,4 +1377,4 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - iClass functionality: full simulation of iclass tags, so tags can be simulated with data (not only CSN). Not yet support for write/update, but readers do not seem to enforce update. (@holiman). - iClass decryption. Proxmark can now decrypt data on an iclass tag, but requires you to have the HID decryption key locally on your computer, as this is not bundled with the sourcecode. - `hf 15 info` can detect NTAG 5 tags - - `hf 15 info` include an EAS status check on more of the icode tags which support EAS (SLI, SLIX, SLIX-L, and SLIX-S) \ No newline at end of file + - `hf 15 info` include an EAS status check on more of the icode tags which support EAS (SLI, SLIX, SLIX-L, and SLIX-S) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 2c6bc740a..e1453be3b 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1462,7 +1462,7 @@ static int CmdHF14AChaining(const char *Cmd) { "Enable/Disable ISO14443a input chaining. Maximum input length goes from ATS.", "hf 14a chaining -> show chaining enable/disable state\n" "hf 14a chaining --off -> disable chaining\n" - ); + ); void *argtable[] = { arg_param_begin, diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 92e42d717..3b92e309b 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -2769,9 +2769,9 @@ static int CmdHF15EASPassProtect(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 15 passprotecteas", - "This command enables the password protect of EAS.\n" - "*** OBS! This action can not be undone! ***", - "hf 15 passprotecteas -p 00000000 --force"); + "This command enables the password protect of EAS.\n" + "*** OBS! This action can not be undone! ***", + "hf 15 passprotecteas -p 00000000 --force"); void *argtable[] = { arg_param_begin, diff --git a/doc/commands.json b/doc/commands.json index 8d028d9e9..6f18da380 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1101,8 +1101,8 @@ "command": "hf 14a chaining", "description": "Enable/Disable ISO14443a input chaining. Maximum input length goes from ATS.", "notes": [ - "hf 14a chaining --off -> disable chaining", - "hf 14a chaining -> show chaining enable/disable state" + "hf 14a chaining -> show chaining enable/disable state", + "hf 14a chaining --off -> disable chaining" ], "offline": false, "options": [ @@ -1658,31 +1658,31 @@ }, "hf 15 passprotectafi": { "command": "hf 15 passprotectafi", - "description": "Password protect AFI. Cannot be undone.", + "description": "This command enables the password protect of AFI. *** OBS! This action can not be undone! ***", "notes": [ - "hf 15 passprotectafi -p 00000000 -c" + "hf 15 passprotectafi -p 00000000 --force" ], "offline": false, "options": [ "-h, --help This help", - "-p, --password EAS/AFI password, 8 hex bytes", - "-c, --confirm confirm the execution of this irreversible command" + "-p, --pwd EAS/AFI password, 8 hex bytes", + "--force Force execution of command (irreversible)" ], - "usage": "hf 15 passprotectafi [-hc] -p " + "usage": "hf 15 passprotectafi [-h] -p [--force]" }, "hf 15 passprotecteas": { "command": "hf 15 passprotecteas", - "description": "Password protect EAS. Cannot be undone.", + "description": "This command enables the password protect of EAS. *** OBS! This action can not be undone! ***", "notes": [ - "hf 15 passprotecteas -p 00000000 -c" + "hf 15 passprotecteas -p 00000000 --force" ], "offline": false, "options": [ "-h, --help This help", - "-p, --password EAS/AFI password, 8 hex bytes", - "-c, --confirm confirm the execution of this irreversible command" + "-p, --pwd EAS/AFI password, 8 hex bytes", + "--force Force execution of command (irreversible)" ], - "usage": "hf 15 passprotecteas [-hc] -p " + "usage": "hf 15 passprotecteas [-h] -p [--force]" }, "hf 15 raw": { "command": "hf 15 raw", @@ -11884,6 +11884,6 @@ "metadata": { "commands_extracted": 748, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2023-01-29T03:58:53" + "extracted_on": "2023-01-29T17:29:14" } } \ No newline at end of file From d8b286e5f50219642f6f97a1ec373861b542758b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:31:39 +0100 Subject: [PATCH 24/30] adapt to fit GENRIC 256kb firmware images --- tools/build_all_firmwares.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build_all_firmwares.sh b/tools/build_all_firmwares.sh index a0253e789..644438032 100755 --- a/tools/build_all_firmwares.sh +++ b/tools/build_all_firmwares.sh @@ -22,7 +22,8 @@ echo "Destination: ${DEST:=firmware}" echo "Produce stats?: ${STATS:=false}" # Which parts to skip for the 256kb version? -SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1 SKIP_NFCBARCODE=1" +SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1 SKIP_NFCBARCODE=1 SKIP_ZX8211=1" + make $MKFLAGS bootrom || exit 1 chmod 644 bootrom/obj/bootrom.elf From 715ae09e7e536e859212ebfe178042be4afe6467 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:37:28 +0100 Subject: [PATCH 25/30] fix coverity #404579 --- client/src/cmdhf15.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 3b92e309b..10d239b94 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -2606,12 +2606,13 @@ static int CmdHF15SlixEnable(const char *Cmd) { static int CmdHF15SlixWritePassword(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 15 slixwritepwd", - "Write a password on a SLIX family ISO-15693 tag", + "Write a password on a SLIX family ISO-15693 tag.n" + "Some tags do not support all different password types.", "hf 15 slixwritepwd -t READ -o 00000000 -n 12131415"); void *argtable[] = { arg_param_begin, - arg_str1("t", "type", "", "which password field to write to (some tags do not support all password types)"), + arg_str1("t", "type", "", "which password field to write to"), arg_str0("o", "old", "", "old password (if present), 8 hex bytes"), arg_str1("n", "new", "", "new password, 8 hex bytes"), arg_param_end @@ -2645,6 +2646,7 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { int vlen = 0; char value[10]; CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)value, sizeof(value), &vlen); + CLIParserFree(ctx); if (vlen > 0) { if (strcmp(value, "read") == 0) { @@ -2668,8 +2670,6 @@ static int CmdHF15SlixWritePassword(const char *Cmd) { } } - CLIParserFree(ctx); - PrintAndLogEx(INFO, "Trying to write " _YELLOW_("%s") " as " _YELLOW_("%s") " password" , sprint_hex_inrow(payload.new_pwd, sizeof(payload.new_pwd)), value); From 5ac42add1a7a590e028d1bfa30de1f0dad290cc8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 18:39:42 +0100 Subject: [PATCH 26/30] make style --- doc/commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/commands.json b/doc/commands.json index 6f18da380..3545a9b78 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -11884,6 +11884,6 @@ "metadata": { "commands_extracted": 748, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2023-01-29T17:29:14" + "extracted_on": "2023-01-29T17:39:28" } } \ No newline at end of file From bec61e9185778afdb08cd4334cc4272f1425a74f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 20:35:17 +0100 Subject: [PATCH 27/30] Release v4.16191 - Nitride --- Makefile.defs | 4 ++-- armsrc/Makefile | 2 +- bootrom/Makefile | 2 +- client/CMakeLists.txt | 4 ++-- client/Makefile | 4 ++-- client/deps/amiibo.cmake | 2 +- client/deps/cliparser.cmake | 2 +- client/deps/hardnested.cmake | 18 +++++++++--------- client/deps/jansson.cmake | 2 +- client/deps/lua.cmake | 2 +- client/deps/mbedtls.cmake | 2 +- client/deps/reveng.cmake | 2 +- client/deps/tinycbor.cmake | 2 +- client/deps/whereami.cmake | 2 +- client/src/proxmark3.c | 2 +- common/default_version_pm3.c | 27 +++++++-------------------- common_arm/Makefile.common | 2 +- 17 files changed, 34 insertions(+), 47 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index bcbbaa67e..b203ebeae 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -104,8 +104,8 @@ ifeq ($(DEBUG),1) DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe DEFLDFLAGS = else - DEFCXXFLAGS = -Wall -Werror -O3 -pipe - DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe + DEFCXXFLAGS = -Wall -O3 -pipe + DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe DEFLDFLAGS = endif diff --git a/armsrc/Makefile b/armsrc/Makefile index 5024aa1de..5c3bb03dc 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -187,7 +187,7 @@ showinfo: # version_pm3.c should be remade on every time fullimage.stage1.elf should be remade version_pm3.c: default_version_pm3.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ) .FORCE $(info [-] GEN $@) - $(Q)$(SH) ../tools/mkversion.sh > $@ || $(CP) $< $@ + $(Q)$(CP) $< $@ fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR) $(info [-] GEN $@) diff --git a/bootrom/Makefile b/bootrom/Makefile index edb0cc990..8a8a6d360 100644 --- a/bootrom/Makefile +++ b/bootrom/Makefile @@ -50,7 +50,7 @@ OBJS = $(OBJDIR)/bootrom.s19 # version_pm3.c should be remade on every compilation version_pm3.c: default_version_pm3.c .FORCE $(info [=] GEN $@) - $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $< $@ + $(Q)$(CP) $< $@ all: showinfo $(OBJS) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 5bd3ebddd..6836e9114 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -364,7 +364,7 @@ set (TARGET_SOURCES add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c - COMMAND sh ${PM3_ROOT}/tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version_pm3.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c + COMMAND ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c DEPENDS ${PM3_ROOT}/common/default_version_pm3.c ) @@ -565,7 +565,7 @@ add_executable(proxmark3 ${ADDITIONAL_SRC} ) -target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3) +target_compile_options(proxmark3 PUBLIC -Wall -O3) if (EMBED_READLINE) if (NOT SKIPREADLINE EQUAL 1) add_dependencies(proxmark3 ncurses readline) diff --git a/client/Makefile b/client/Makefile index b08eb0acb..218d19d08 100644 --- a/client/Makefile +++ b/client/Makefile @@ -408,7 +408,7 @@ endif PM3CFLAGS += -DHAVE_SNPRINTF -CXXFLAGS ?= -Wall -Werror -O3 +CXXFLAGS ?= -Wall -O3 CXXFLAGS += $(MYDEFS) $(MYCXXFLAGS) $(MYINCLUDES) PM3CXXFLAGS = $(CXXFLAGS) @@ -902,7 +902,7 @@ src/pm3_pywrap.c: pm3.i # version_pm3.c should be remade on every compilation src/version_pm3.c: default_version_pm3.c .FORCE $(info [=] GEN $@) - $(Q)$(SH) ../tools/mkversion.sh > $@ || $(CP) $< $@ + $(Q)$(CP) $< $@ # easy printing of MAKE VARIABLES print-%: ; @echo $* = $($*) diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake index c946c0682..8c524c170 100644 --- a/client/deps/amiibo.cmake +++ b/client/deps/amiibo.cmake @@ -19,7 +19,7 @@ target_link_libraries(pm3rrg_rdv4_amiibo PRIVATE m pm3rrg_rdv4_mbedtls) -target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_amiibo PRIVATE amiitool diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake index fccae33b7..a85cc2374 100644 --- a/client/deps/cliparser.cmake +++ b/client/deps/cliparser.cmake @@ -9,5 +9,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE ../../include ../src) target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser) -target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake index 524d4c939..290415173 100644 --- a/client/deps/hardnested.cmake +++ b/client/deps/hardnested.cmake @@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) -target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE @@ -32,7 +32,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE -mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -47,7 +47,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE -mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -62,7 +62,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE -mmmx -msse2 -mavx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -77,7 +77,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE -mmmx -msse2 -mavx -mavx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -92,7 +92,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE -mmmx -msse2 -mavx -mavx2 -mavx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -116,7 +116,7 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM64_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested_neon PRIVATE @@ -134,7 +134,7 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM32_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3) + target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -O3) target_compile_options(pm3rrg_rdv4_hardnested_neon BEFORE PRIVATE -mfpu=neon) set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -155,7 +155,7 @@ add_library(pm3rrg_rdv4_hardnested STATIC hardnested/hardnested_bruteforce.c $ ${SIMD_TARGETS}) -target_compile_options(pm3rrg_rdv4_hardnested PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_hardnested PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_hardnested PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested PRIVATE ../../common diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake index c91a47047..42c701d5e 100644 --- a/client/deps/jansson.cmake +++ b/client/deps/jansson.cmake @@ -14,5 +14,5 @@ add_library(pm3rrg_rdv4_jansson STATIC target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H) target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson) -target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3) +target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3) set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake index 12870342e..5cf33d724 100644 --- a/client/deps/lua.cmake +++ b/client/deps/lua.cmake @@ -52,5 +52,5 @@ if (NOT MINGW) endif (NOT MINGW) target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua) -target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake index 40929e1ea..c726ddeba 100644 --- a/client/deps/mbedtls.cmake +++ b/client/deps/mbedtls.cmake @@ -44,5 +44,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common) target_include_directories(pm3rrg_rdv4_mbedtls INTERFACE ../../common/mbedtls) -target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake index d7e3cfd8a..1040730f1 100644 --- a/client/deps/reveng.cmake +++ b/client/deps/reveng.cmake @@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE ../src ../../include) target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng) -target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake index 5a6abda25..c74618149 100644 --- a/client/deps/tinycbor.cmake +++ b/client/deps/tinycbor.cmake @@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor) # Strange errors on Mingw when compiling with -O3 -target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2) +target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2) set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake index d2d6a5b2a..721873066 100644 --- a/client/deps/whereami.cmake +++ b/client/deps/whereami.cmake @@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c) target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED) target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami) -target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3) +target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3) set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 378b9f0dc..6c77bfad3 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -42,7 +42,7 @@ static int mainret = PM3_ESOFT; #ifndef LIBPM3 #define BANNERMSG1 "" #define BANNERMSG2 " [ :coffee: ]" -#define BANNERMSG3 "" +#define BANNERMSG3 "Release v4.16191 - Nitride" typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode; diff --git a/common/default_version_pm3.c b/common/default_version_pm3.c index 46eac57c9..26ba654b1 100644 --- a/common/default_version_pm3.c +++ b/common/default_version_pm3.c @@ -1,20 +1,5 @@ -//----------------------------------------------------------------------------- -// 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. -// -// See LICENSE.txt for the text of the license. -//----------------------------------------------------------------------------- #include "common.h" -/* This is the default version_pm3.c file that Makefile.common falls back to if sh is not available */ +/* Generated file, do not edit */ #ifndef ON_DEVICE #define SECTVERSINFO #else @@ -23,8 +8,10 @@ const struct version_information_t SECTVERSINFO g_version_information = { VERSION_INFORMATION_MAGIC, - 1, /* version 1 */ - 0, /* version information not present */ - 2, /* cleanliness couldn't be determined */ - /* Remaining fields: zero */ + 1, + 1, + 1, + "Iceman/master/v4.16191", + "2023-01-29 20:35:17", + "3545f4f98" }; diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common index 99f4d9ecd..e40d998a6 100644 --- a/common_arm/Makefile.common +++ b/common_arm/Makefile.common @@ -49,7 +49,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/ INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h ARMCFLAGS = -mthumb-interwork -fno-builtin -DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe +DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe # Some more warnings we want as errors: DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits From 2bd404b496109857d8bb40668924974f807ce62b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 20:35:17 +0100 Subject: [PATCH 28/30] Revert "Release v4.16191 - Nitride" This reverts commit bec61e9185778afdb08cd4334cc4272f1425a74f. --- Makefile.defs | 4 ++-- armsrc/Makefile | 2 +- bootrom/Makefile | 2 +- client/CMakeLists.txt | 4 ++-- client/Makefile | 4 ++-- client/deps/amiibo.cmake | 2 +- client/deps/cliparser.cmake | 2 +- client/deps/hardnested.cmake | 18 +++++++++--------- client/deps/jansson.cmake | 2 +- client/deps/lua.cmake | 2 +- client/deps/mbedtls.cmake | 2 +- client/deps/reveng.cmake | 2 +- client/deps/tinycbor.cmake | 2 +- client/deps/whereami.cmake | 2 +- client/src/proxmark3.c | 2 +- common/default_version_pm3.c | 27 ++++++++++++++++++++------- common_arm/Makefile.common | 2 +- 17 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Makefile.defs b/Makefile.defs index b203ebeae..bcbbaa67e 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -104,8 +104,8 @@ ifeq ($(DEBUG),1) DEFCFLAGS = -g -O0 -fstrict-aliasing -pipe DEFLDFLAGS = else - DEFCXXFLAGS = -Wall -O3 -pipe - DEFCFLAGS = -Wall -O3 -fstrict-aliasing -pipe + DEFCXXFLAGS = -Wall -Werror -O3 -pipe + DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe DEFLDFLAGS = endif diff --git a/armsrc/Makefile b/armsrc/Makefile index 5c3bb03dc..5024aa1de 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -187,7 +187,7 @@ showinfo: # version_pm3.c should be remade on every time fullimage.stage1.elf should be remade version_pm3.c: default_version_pm3.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ) .FORCE $(info [-] GEN $@) - $(Q)$(CP) $< $@ + $(Q)$(SH) ../tools/mkversion.sh > $@ || $(CP) $< $@ fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR) $(info [-] GEN $@) diff --git a/bootrom/Makefile b/bootrom/Makefile index 8a8a6d360..edb0cc990 100644 --- a/bootrom/Makefile +++ b/bootrom/Makefile @@ -50,7 +50,7 @@ OBJS = $(OBJDIR)/bootrom.s19 # version_pm3.c should be remade on every compilation version_pm3.c: default_version_pm3.c .FORCE $(info [=] GEN $@) - $(Q)$(CP) $< $@ + $(Q)$(SH) ../tools/mkversion.sh > $@ || $(PERL) ../tools/mkversion.pl > $@ || $(CP) $< $@ all: showinfo $(OBJS) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6836e9114..5bd3ebddd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -364,7 +364,7 @@ set (TARGET_SOURCES add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c - COMMAND ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c + COMMAND sh ${PM3_ROOT}/tools/mkversion.sh > ${CMAKE_BINARY_DIR}/version_pm3.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c DEPENDS ${PM3_ROOT}/common/default_version_pm3.c ) @@ -565,7 +565,7 @@ add_executable(proxmark3 ${ADDITIONAL_SRC} ) -target_compile_options(proxmark3 PUBLIC -Wall -O3) +target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3) if (EMBED_READLINE) if (NOT SKIPREADLINE EQUAL 1) add_dependencies(proxmark3 ncurses readline) diff --git a/client/Makefile b/client/Makefile index 218d19d08..b08eb0acb 100644 --- a/client/Makefile +++ b/client/Makefile @@ -408,7 +408,7 @@ endif PM3CFLAGS += -DHAVE_SNPRINTF -CXXFLAGS ?= -Wall -O3 +CXXFLAGS ?= -Wall -Werror -O3 CXXFLAGS += $(MYDEFS) $(MYCXXFLAGS) $(MYINCLUDES) PM3CXXFLAGS = $(CXXFLAGS) @@ -902,7 +902,7 @@ src/pm3_pywrap.c: pm3.i # version_pm3.c should be remade on every compilation src/version_pm3.c: default_version_pm3.c .FORCE $(info [=] GEN $@) - $(Q)$(CP) $< $@ + $(Q)$(SH) ../tools/mkversion.sh > $@ || $(CP) $< $@ # easy printing of MAKE VARIABLES print-%: ; @echo $* = $($*) diff --git a/client/deps/amiibo.cmake b/client/deps/amiibo.cmake index 8c524c170..c946c0682 100644 --- a/client/deps/amiibo.cmake +++ b/client/deps/amiibo.cmake @@ -19,7 +19,7 @@ target_link_libraries(pm3rrg_rdv4_amiibo PRIVATE m pm3rrg_rdv4_mbedtls) -target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_amiibo PRIVATE amiitool diff --git a/client/deps/cliparser.cmake b/client/deps/cliparser.cmake index a85cc2374..fccae33b7 100644 --- a/client/deps/cliparser.cmake +++ b/client/deps/cliparser.cmake @@ -9,5 +9,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE ../../include ../src) target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser) -target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/hardnested.cmake b/client/deps/hardnested.cmake index 290415173..524d4c939 100644 --- a/client/deps/hardnested.cmake +++ b/client/deps/hardnested.cmake @@ -2,7 +2,7 @@ add_library(pm3rrg_rdv4_hardnested_nosimd OBJECT hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) -target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_hardnested_nosimd PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_hardnested_nosimd PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested_nosimd PRIVATE @@ -32,7 +32,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_mmx PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_mmx BEFORE PRIVATE -mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_mmx PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -47,7 +47,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_sse2 PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_sse2 BEFORE PRIVATE -mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_sse2 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -62,7 +62,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx BEFORE PRIVATE -mmmx -msse2 -mavx -mno-avx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -77,7 +77,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx2 PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx2 BEFORE PRIVATE -mmmx -msse2 -mavx -mavx2 -mno-avx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx2 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -92,7 +92,7 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST X86_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_avx512 PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_avx512 BEFORE PRIVATE -mmmx -msse2 -mavx -mavx2 -mavx512f) set_property(TARGET pm3rrg_rdv4_hardnested_avx512 PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -116,7 +116,7 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM64_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested_neon PRIVATE @@ -134,7 +134,7 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" IN_LIST ARM32_CPUS) hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c) - target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -O3) + target_compile_options(pm3rrg_rdv4_hardnested_neon PRIVATE -Wall -Werror -O3) target_compile_options(pm3rrg_rdv4_hardnested_neon BEFORE PRIVATE -mfpu=neon) set_property(TARGET pm3rrg_rdv4_hardnested_neon PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -155,7 +155,7 @@ add_library(pm3rrg_rdv4_hardnested STATIC hardnested/hardnested_bruteforce.c $ ${SIMD_TARGETS}) -target_compile_options(pm3rrg_rdv4_hardnested PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_hardnested PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_hardnested PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(pm3rrg_rdv4_hardnested PRIVATE ../../common diff --git a/client/deps/jansson.cmake b/client/deps/jansson.cmake index 42c701d5e..c91a47047 100644 --- a/client/deps/jansson.cmake +++ b/client/deps/jansson.cmake @@ -14,5 +14,5 @@ add_library(pm3rrg_rdv4_jansson STATIC target_compile_definitions(pm3rrg_rdv4_jansson PRIVATE HAVE_STDINT_H) target_include_directories(pm3rrg_rdv4_jansson INTERFACE jansson) -target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Wno-unused-function -O3) +target_compile_options(pm3rrg_rdv4_jansson PRIVATE -Wall -Werror -Wno-unused-function -O3) set_property(TARGET pm3rrg_rdv4_jansson PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/lua.cmake b/client/deps/lua.cmake index 5cf33d724..12870342e 100644 --- a/client/deps/lua.cmake +++ b/client/deps/lua.cmake @@ -52,5 +52,5 @@ if (NOT MINGW) endif (NOT MINGW) target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua) -target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/mbedtls.cmake b/client/deps/mbedtls.cmake index c726ddeba..40929e1ea 100644 --- a/client/deps/mbedtls.cmake +++ b/client/deps/mbedtls.cmake @@ -44,5 +44,5 @@ add_library(pm3rrg_rdv4_mbedtls STATIC target_include_directories(pm3rrg_rdv4_mbedtls PRIVATE ../../common) target_include_directories(pm3rrg_rdv4_mbedtls INTERFACE ../../common/mbedtls) -target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_mbedtls PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/reveng.cmake b/client/deps/reveng.cmake index 1040730f1..d7e3cfd8a 100644 --- a/client/deps/reveng.cmake +++ b/client/deps/reveng.cmake @@ -13,5 +13,5 @@ target_include_directories(pm3rrg_rdv4_reveng PRIVATE ../src ../../include) target_include_directories(pm3rrg_rdv4_reveng INTERFACE reveng) -target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_reveng PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_reveng PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/tinycbor.cmake b/client/deps/tinycbor.cmake index c74618149..5a6abda25 100644 --- a/client/deps/tinycbor.cmake +++ b/client/deps/tinycbor.cmake @@ -11,5 +11,5 @@ add_library(pm3rrg_rdv4_tinycbor STATIC target_include_directories(pm3rrg_rdv4_tinycbor INTERFACE tinycbor) # Strange errors on Mingw when compiling with -O3 -target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -O2) +target_compile_options(pm3rrg_rdv4_tinycbor PRIVATE -Wall -Werror -O2) set_property(TARGET pm3rrg_rdv4_tinycbor PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/deps/whereami.cmake b/client/deps/whereami.cmake index 721873066..d2d6a5b2a 100644 --- a/client/deps/whereami.cmake +++ b/client/deps/whereami.cmake @@ -2,5 +2,5 @@ add_library(pm3rrg_rdv4_whereami STATIC whereami/whereami.c) target_compile_definitions(pm3rrg_rdv4_whereami PRIVATE WAI_PM3_TUNED) target_include_directories(pm3rrg_rdv4_whereami INTERFACE whereami) -target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -O3) +target_compile_options(pm3rrg_rdv4_whereami PRIVATE -Wall -Werror -O3) set_property(TARGET pm3rrg_rdv4_whereami PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 6c77bfad3..378b9f0dc 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -42,7 +42,7 @@ static int mainret = PM3_ESOFT; #ifndef LIBPM3 #define BANNERMSG1 "" #define BANNERMSG2 " [ :coffee: ]" -#define BANNERMSG3 "Release v4.16191 - Nitride" +#define BANNERMSG3 "" typedef enum LogoMode { UTF8, ANSI, ASCII } LogoMode; diff --git a/common/default_version_pm3.c b/common/default_version_pm3.c index 26ba654b1..46eac57c9 100644 --- a/common/default_version_pm3.c +++ b/common/default_version_pm3.c @@ -1,5 +1,20 @@ +//----------------------------------------------------------------------------- +// 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. +// +// See LICENSE.txt for the text of the license. +//----------------------------------------------------------------------------- #include "common.h" -/* Generated file, do not edit */ +/* This is the default version_pm3.c file that Makefile.common falls back to if sh is not available */ #ifndef ON_DEVICE #define SECTVERSINFO #else @@ -8,10 +23,8 @@ const struct version_information_t SECTVERSINFO g_version_information = { VERSION_INFORMATION_MAGIC, - 1, - 1, - 1, - "Iceman/master/v4.16191", - "2023-01-29 20:35:17", - "3545f4f98" + 1, /* version 1 */ + 0, /* version information not present */ + 2, /* cleanliness couldn't be determined */ + /* Remaining fields: zero */ }; diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common index e40d998a6..99f4d9ecd 100644 --- a/common_arm/Makefile.common +++ b/common_arm/Makefile.common @@ -49,7 +49,7 @@ VPATH = . ../common_arm ../common ../common/crapto1 ../common/mbedtls ../common/ INCLUDES = ../include/proxmark3_arm.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h ARMCFLAGS = -mthumb-interwork -fno-builtin -DEFCFLAGS = -Wall -Os -pedantic -fstrict-aliasing -pipe +DEFCFLAGS = -Wall -Werror -Os -pedantic -fstrict-aliasing -pipe # Some more warnings we want as errors: DEFCFLAGS += -Wbad-function-cast -Wchar-subscripts -Wundef -Wunused -Wuninitialized -Wpointer-arith -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wtype-limits From 0a5b0d0746b393ef6a888ff76cd3311e157b7a8b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Jan 2023 20:38:33 +0100 Subject: [PATCH 29/30] text --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 285cd6bf7..880ca0998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac ## [unreleased][unreleased] -## [Nitride][2023-01-29] +## [Nitride.4.16191][2023-01-29] - Changed `build_all_firmwares.sh` to fit GENERIC 256kb firmware images (@doegox) - Fixed some coverity fixes (@iceman1001) - Fixed `make accessrights` on Fedora (@mooey5775) From 8be70ea5607820a2022b3e0153fac3ea77186990 Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod Date: Mon, 30 Jan 2023 23:27:17 +0100 Subject: [PATCH 30/30] Fix minor bugs in `hf tesla info` --- client/src/cmdhftesla.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/client/src/cmdhftesla.c b/client/src/cmdhftesla.c index 58f51f4c5..940687cb4 100644 --- a/client/src/cmdhftesla.c +++ b/client/src/cmdhftesla.c @@ -147,7 +147,7 @@ static int info_hf_tesla(void) { // --------------- CERT reading ---------------- Set_apdu_in_framing(true); - for (uint8_t i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 5; i++) { uint8_t aSELECT_CERT[PM3_CMD_DATA_SIZE] = {0x80, 0x06, i, 0x00, 0x00, 0x00, 0xFF}; int aSELECT_CERT_n = 7; @@ -160,7 +160,7 @@ static int info_hf_tesla(void) { sw = get_sw(response, resplen); if (sw == ISO7816_OK) { - // save CETT for later + // save CERT for later uint8_t cert[515] = {0}; memcpy(cert, response, resplen - 2); @@ -201,10 +201,21 @@ static int info_hf_tesla(void) { for (int i = 0; i < 3; i++) { PrintAndLogEx(INFO, "%d - %s", i, sprint_hex_inrow(pk[i], 65)); } - if (form_factor[1] == 1) { - PrintAndLogEx(INFO, "Form factor... %s (card)", sprint_hex_inrow(form_factor, sizeof(form_factor))); - } else if (form_factor[1] == 2) { - PrintAndLogEx(INFO, "Form factor... %s (phone app)", sprint_hex_inrow(form_factor, sizeof(form_factor))); + PrintAndLogEx(INFO, "Form factor... %s " NOLF, sprint_hex_inrow(form_factor, sizeof(form_factor))); + uint16_t form_factor_value = form_factor[0] << 8 | form_factor[1]; + switch (form_factor_value) { + case 0x0001: + PrintAndLogEx(NORMAL, "(card)"); + break; + case 0x0022: + PrintAndLogEx(NORMAL, "(fob)"); + break; + case 0x0031: + PrintAndLogEx(NORMAL, "(phone app)"); + break; + default: + PrintAndLogEx(NORMAL, "(unknown)"); + break; } if (sizeof(version) > 0) {