From c57e3b2b0ddbb9fa4039f198da0c377cb6002d93 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 18:45:21 -0500 Subject: [PATCH 01/13] Update wiegand_formats.c --- client/src/wiegand_formats.c | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index d7818661c..d43e46964 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -770,6 +770,69 @@ static bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) { return true; } + + + + + + + + + + + + + +static bool Pack_P10003(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { + memset(packed, 0, sizeof(wiegand_message_t)); + + if (card->FacilityCode > 0x0000FFFF) return false; // Can't encode FC. + if (card->CardNumber > 0x0007FFFF) return false; // Can't encode CN. + if (card->IssueLevel > 0) return false; // Not used in this format + if (card->OEM > 0) return false; // Not used in this format + + packed->Length = 37; // Set number of bits + + set_linear_field(packed, card->FacilityCode, 2, 13); + set_linear_field(packed, card->CardNumber, 15, 18); + + set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0); + set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36); + if (preamble) + return add_HID_header(packed); + return true; +} + +static bool Unpack_P10003(wiegand_message_t *packed, wiegand_card_t *card) { + memset(card, 0, sizeof(wiegand_card_t)); + + if (packed->Length != 37) return false; // Wrong length? Stop here. + + card->FacilityCode = get_linear_field(packed, 2, 13); + card->CardNumber = get_linear_field(packed, 15, 18); + card->ParityValid = + (get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) && + (get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18))); + return true; +} + + + + + + + + + + + + + + + + + + static bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { memset(packed, 0, sizeof(wiegand_message_t)); From 734076af27fca1d9ab57d154ae7854288c38d156 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 19:04:38 -0500 Subject: [PATCH 02/13] Update wiegand_formats.c --- client/src/wiegand_formats.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index d43e46964..2329c4e12 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -1433,6 +1433,7 @@ static const cardformat_t FormatTable[] = { {"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au + {"P1003", Pack_P1003, Unpack_P10003, "HID P10003 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", {1, 1, 1, 0, 1}}, // from cardinfo.barkweb.com.au From e25297a9673cb61fd3c4155d8bac3deac88b1d8b Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 19:08:58 -0500 Subject: [PATCH 03/13] Update wiegand_formats.c --- client/src/wiegand_formats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 2329c4e12..a7b047993 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -1433,7 +1433,7 @@ static const cardformat_t FormatTable[] = { {"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au - {"P1003", Pack_P1003, Unpack_P10003, "HID P10003 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT + {"P10003", Pack_P10003, Unpack_P10003, "HID P10003 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", {1, 1, 1, 0, 1}}, // from cardinfo.barkweb.com.au From a2d74f488856418ad39a5588c191b1dfe7af0fa6 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 19:34:03 -0500 Subject: [PATCH 04/13] Update wiegand_formats.c --- client/src/wiegand_formats.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index a7b047993..b8247fd34 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -783,7 +783,7 @@ static bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) { -static bool Pack_P10003(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { +static bool Pack_P10004(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { memset(packed, 0, sizeof(wiegand_message_t)); if (card->FacilityCode > 0x0000FFFF) return false; // Can't encode FC. @@ -793,8 +793,8 @@ static bool Pack_P10003(wiegand_card_t *card, wiegand_message_t *packed, bool pr packed->Length = 37; // Set number of bits - set_linear_field(packed, card->FacilityCode, 2, 13); - set_linear_field(packed, card->CardNumber, 15, 18); + set_linear_field(packed, card->FacilityCode, 1, 13); + set_linear_field(packed, card->CardNumber, 14, 18); set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0); set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36); @@ -1433,7 +1433,7 @@ static const cardformat_t FormatTable[] = { {"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au - {"P10003", Pack_P10003, Unpack_P10003, "HID P10003 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT + {"P10003", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", {1, 1, 1, 0, 1}}, // from cardinfo.barkweb.com.au From 5b830ac0866a6968ff1c784ae3f3ab389e909c3a Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 19:37:10 -0500 Subject: [PATCH 05/13] Update wiegand_formats.c --- client/src/wiegand_formats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index b8247fd34..452f23878 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -1433,7 +1433,7 @@ static const cardformat_t FormatTable[] = { {"H10320", Pack_H10320, Unpack_H10320, "HID H10320 36-bit BCD", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", {1, 0, 0, 0, 1}}, // from Proxmark forums {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au - {"P10003", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT + {"P10004", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", {1, 1, 0, 0, 1}}, // from BT {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", {1, 0, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", {1, 1, 0, 0, 1}}, // from cardinfo.barkweb.com.au {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", {1, 1, 1, 0, 1}}, // from cardinfo.barkweb.com.au From 72339f6ab4658dd2fe89850ed696f3b7b9534ac5 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 19:41:40 -0500 Subject: [PATCH 06/13] Upload Make.Platform --- Makefile.platform | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Makefile.platform diff --git a/Makefile.platform b/Makefile.platform new file mode 100644 index 000000000..f20740afa --- /dev/null +++ b/Makefile.platform @@ -0,0 +1,13 @@ +# If you want to use it, copy this file as Makefile.platform and adjust it to your needs +# Run 'make PLATFORM=' to get an exhaustive list of possible parameters for this file. + +#PLATFORM=PM3RDV4 +PLATFORM=PM3GENERIC +# If you want more than one PLATFORM_EXTRAS option, separate them by spaces: +#PLATFORM_EXTRAS=BTADDON +#STANDALONE=LF_SAMYRUN + +# To accelerate repetitive compilations: +# Install package "ccache" -> Debian/Ubuntu: /usr/lib/ccache, Fedora/CentOS/RHEL: /usr/lib64/ccache +# And uncomment the following line +#export PATH := /usr/lib64/ccache:/usr/lib/ccache:${PATH} From 66935bdd5a6831bf2f6b3bb4be2d9887e4c53a9c Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 20:28:00 -0500 Subject: [PATCH 07/13] Fix 37bit PCSC --- client/src/wiegand_formats.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 452f23878..4f89bf262 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -803,13 +803,13 @@ static bool Pack_P10004(wiegand_card_t *card, wiegand_message_t *packed, bool pr return true; } -static bool Unpack_P10003(wiegand_message_t *packed, wiegand_card_t *card) { +static bool Unpack_P10004(wiegand_message_t *packed, wiegand_card_t *card) { memset(card, 0, sizeof(wiegand_card_t)); if (packed->Length != 37) return false; // Wrong length? Stop here. - card->FacilityCode = get_linear_field(packed, 2, 13); - card->CardNumber = get_linear_field(packed, 15, 18); + card->FacilityCode = get_linear_field(packed, 1, 13); + card->CardNumber = get_linear_field(packed, 14, 18); card->ParityValid = (get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) && (get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18))); From 6a617f8d4ad041d398c66c29754392dca28756c0 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 21:02:43 -0500 Subject: [PATCH 08/13] Fix 37bit PCSC --- client/src/wiegand_formats.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 4f89bf262..08e77b9a1 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -770,19 +770,6 @@ static bool Unpack_H10302(wiegand_message_t *packed, wiegand_card_t *card) { return true; } - - - - - - - - - - - - - static bool Pack_P10004(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { memset(packed, 0, sizeof(wiegand_message_t)); @@ -816,23 +803,6 @@ static bool Unpack_P10004(wiegand_message_t *packed, wiegand_card_t *card) { return true; } - - - - - - - - - - - - - - - - - static bool Pack_H10304(wiegand_card_t *card, wiegand_message_t *packed, bool preamble) { memset(packed, 0, sizeof(wiegand_message_t)); From 468199ffc9176af32e7b889347bd23ba7a881ce6 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Sun, 16 Jan 2022 21:35:15 -0500 Subject: [PATCH 09/13] Delete Makefile.platform --- Makefile.platform | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Makefile.platform diff --git a/Makefile.platform b/Makefile.platform deleted file mode 100644 index f20740afa..000000000 --- a/Makefile.platform +++ /dev/null @@ -1,13 +0,0 @@ -# If you want to use it, copy this file as Makefile.platform and adjust it to your needs -# Run 'make PLATFORM=' to get an exhaustive list of possible parameters for this file. - -#PLATFORM=PM3RDV4 -PLATFORM=PM3GENERIC -# If you want more than one PLATFORM_EXTRAS option, separate them by spaces: -#PLATFORM_EXTRAS=BTADDON -#STANDALONE=LF_SAMYRUN - -# To accelerate repetitive compilations: -# Install package "ccache" -> Debian/Ubuntu: /usr/lib/ccache, Fedora/CentOS/RHEL: /usr/lib64/ccache -# And uncomment the following line -#export PATH := /usr/lib64/ccache:/usr/lib/ccache:${PATH} From 42eddf1798fc1e44c8eeff24f4fcad8a669c8e29 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Mon, 17 Jan 2022 17:48:53 -0500 Subject: [PATCH 10/13] Fix 37bit PCSC --- client/src/wiegand_formats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 08e77b9a1..b4c7376f6 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -780,8 +780,8 @@ static bool Pack_P10004(wiegand_card_t *card, wiegand_message_t *packed, bool pr packed->Length = 37; // Set number of bits - set_linear_field(packed, card->FacilityCode, 1, 13); - set_linear_field(packed, card->CardNumber, 14, 18); + set_linear_field(packed, card->FacilityCode, 2, 13); + set_linear_field(packed, card->CardNumber, 15, 18); set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0); set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36); From f43e5f0de799299825ee8628c49c4401524e9701 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Mon, 17 Jan 2022 17:52:21 -0500 Subject: [PATCH 11/13] Update CHANGELOG.md Adds support for PCSC's proprietary HID 37bit format P10004 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e86025fb..268aa2df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac ## [unreleased][unreleased] - Add `nfc decode` - now NDEF vCard messages with a PHOTO in base64 format is shown (@iceman1001) - Remove AID limitations when using Gallagher key diversification (@DarkMatterMatt) + - Adds support for PCSC's proprietary HID 37bit format P10004 (@bthedorff) ## [Frostbit.4.14831] [2022-01-11] - Changed Wiegand format lookup - now case-insensitive (@iceman1001) From c9fe8d33e2fd7094320b49c8454784992a7b0c51 Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Mon, 17 Jan 2022 20:54:04 -0500 Subject: [PATCH 12/13] Update wiegand_formats.c I swear it'll get it right --- client/src/wiegand_formats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index b4c7376f6..0b65e5860 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -795,8 +795,8 @@ static bool Unpack_P10004(wiegand_message_t *packed, wiegand_card_t *card) { if (packed->Length != 37) return false; // Wrong length? Stop here. - card->FacilityCode = get_linear_field(packed, 1, 13); - card->CardNumber = get_linear_field(packed, 14, 18); + card->FacilityCode = get_linear_field(packed, 2, 13); + card->CardNumber = get_linear_field(packed, 15, 18); card->ParityValid = (get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) && (get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18))); From 83a40b370a40117783fbcb1fdf90974f2ad1547a Mon Sep 17 00:00:00 2001 From: bthedorff <32941719+bthedorff@users.noreply.github.com> Date: Mon, 17 Jan 2022 22:29:26 -0500 Subject: [PATCH 13/13] Update wiegand_formats.c I swear I tested it after my last change and it worked.... but now it isn't so I must have made an error somewhere. It is back to sites programming and is working --- client/src/wiegand_formats.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 0b65e5860..08e77b9a1 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -780,8 +780,8 @@ static bool Pack_P10004(wiegand_card_t *card, wiegand_message_t *packed, bool pr packed->Length = 37; // Set number of bits - set_linear_field(packed, card->FacilityCode, 2, 13); - set_linear_field(packed, card->CardNumber, 15, 18); + set_linear_field(packed, card->FacilityCode, 1, 13); + set_linear_field(packed, card->CardNumber, 14, 18); set_bit_by_position(packed, evenparity32(get_linear_field(packed, 1, 18)), 0); set_bit_by_position(packed, oddparity32(get_linear_field(packed, 18, 18)), 36); @@ -795,8 +795,8 @@ static bool Unpack_P10004(wiegand_message_t *packed, wiegand_card_t *card) { if (packed->Length != 37) return false; // Wrong length? Stop here. - card->FacilityCode = get_linear_field(packed, 2, 13); - card->CardNumber = get_linear_field(packed, 15, 18); + card->FacilityCode = get_linear_field(packed, 1, 13); + card->CardNumber = get_linear_field(packed, 14, 18); card->ParityValid = (get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 18))) && (get_bit_by_position(packed, 36) == oddparity32(get_linear_field(packed, 18, 18)));