Skip to content

Commit cb40726

Browse files
authored
Merge pull request #2999 from aaronmaxlevy/aaron_verkada_40_wiegand_format
Adding Verkada 40-bit format
2 parents e830267 + 8c2dd4d commit cb40726

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
99
- Added `client/resources/pm3_generic_private_key.pem` in order to self-sign a modded device (@iceman1001)
1010
- Fix `hf mfdes value --op clear` commands for clearing more than 0x80000000 values and getfilesettings mac mode (@merlokk)
1111
- Added ATR fingerprinting to `hf 14a/14b info` (@doegox)
12+
- Added `Verkada 40-bit` format (@aaronmaxlevy)
1213

1314
## [Phrack.4.20728][2025-09-11]
1415
- Changed `lf t55xx restore` - now skips writing block0 if its all zeros (@iceman1001)

client/src/wiegand_formats.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,46 @@ static bool Unpack_CasiRusco40(wiegand_message_t *packed, wiegand_card_t *card)
11251125
return true;
11261126
}
11271127

1128+
static bool Pack_Verkada40(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
1129+
memset(packed, 0, sizeof(wiegand_message_t));
1130+
1131+
if (!validate_card_limit(format_idx, card)) return false;
1132+
1133+
packed->Length = 40; // Set number of bits
1134+
1135+
set_linear_field(packed, card->FacilityCode, 1, 10);
1136+
1137+
set_linear_field(packed, card->CardNumber, 11, 28);
1138+
1139+
set_bit_by_position(packed,
1140+
evenparity32(get_linear_field(packed, 1, 10))
1141+
, 0);
1142+
1143+
set_bit_by_position(packed,
1144+
evenparity32(get_linear_field(packed, 11, 28))
1145+
, 39);
1146+
1147+
if (preamble)
1148+
return add_HID_header(packed);
1149+
return true;
1150+
}
1151+
1152+
static bool Unpack_Verkada40(wiegand_message_t *packed, wiegand_card_t *card) {
1153+
if (packed->Length != 40) return false; // Wrong length? Stop here.
1154+
1155+
memset(card, 0, sizeof(wiegand_card_t));
1156+
1157+
card->FacilityCode = get_linear_field(packed, 1, 10);
1158+
1159+
card->CardNumber = get_linear_field(packed, 11, 28);
1160+
1161+
card->ParityValid =
1162+
(get_bit_by_position(packed, 0) == evenparity32(get_linear_field(packed, 1, 10))) &&
1163+
(get_bit_by_position(packed, 39) == evenparity32(get_linear_field(packed, 11, 28)));
1164+
1165+
return true;
1166+
}
1167+
11281168
static bool Pack_Optus(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble) {
11291169

11301170
if (!validate_card_limit(format_idx, card)) return false;
@@ -1542,6 +1582,7 @@ static const cardformat_t FormatTable[] = {
15421582
{"PW39", Pack_pw39, Unpack_pw39, "Pyramid 39-bit wiegand format", 39, {1, 1, 0, 0, 1, 0x0000FFFFu, 0x00000000000FFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au
15431583
{"P10001", Pack_P10001, Unpack_P10001, "HID P10001 Honeywell 40-bit", 40, {1, 1, 0, 0, 0, 0x00000FFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au
15441584
{"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", 40, {1, 0, 0, 0, 0, 0x00000000u, 0x000000FFFFFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au
1585+
{"Verkada40", Pack_Verkada40, Unpack_Verkada40, "Verkada 40-bit", 40, {1, 1, 0, 0, 1, 0x000003FFu, 0x000000000FFFFFFFu, 0x00000000u, 0x00000000u}}, // Verkada 40-bit format
15451586
{"BC40", Pack_bc40, Unpack_bc40, "Bundy TimeClock 40-bit", 40, {1, 1, 0, 1, 1, 0x00000FFFu, 0x00000000000FFFFFu, 0x00000000u, 0x0000007Fu}}, // from
15461587
{"Defcon32", Pack_Defcon32, Unpack_Defcon32, "Custom Defcon RFCTF 42-bit", 42, {1, 1, 1, 0, 1, 0x0000FFFFu, 0x00000000000FFFFFu, 0x0000000Fu, 0x00000000u}}, // Created by (@micsen) for the CTF
15471588
{"H800002", Pack_H800002, Unpack_H800002, "HID H800002 46-bit", 46, {1, 1, 0, 0, 1, 0x00003FFFu, 0x000000003FFFFFFFu, 0x00000000u, 0x00000000u}},

tools/pm3_tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,12 @@ while true; do
450450
if ! CheckExecute "nfc decode test - signature" "$CLIENTBIN -c 'nfc decode -d 03FF010194113870696C65742E65653A656B616172743A3266195F26063132303832325904202020205F28033233335F2701316E1B5A13333038363439303039303030323636343030355304EBF2CE704103000000AC536967010200803A2448FCA7D354A654A81BD021150D1A152D1DF4D7A55D2B771F12F094EAB6E5E10F2617A2F8DAD4FD38AFF8EA39B71C19BD42618CDA86EE7E144636C8E0E7CFC4096E19C3680E09C78A0CDBC05DA2D698E551D5D709717655E56FE3676880B897D2C70DF5F06ECE07C71435255144F8EE41AF110E7B180DA0E6C22FB8FDEF61800025687474703A2F2F70696C65742E65652F6372742F33303836343930302D303030312E637274FE'" "30864900-0001.crt"; then break; fi
451451
if ! CheckExecute "wiegand decode test - raw" "$CLIENTBIN -c 'wiegand decode --raw 2006F623AE'" "FC: 123 CN: 4567 parity \( ok \)"; then break; fi
452452
if ! CheckExecute "wiegand decode test - new" "$CLIENTBIN -c 'wiegand decode --new 06BD88EB80'" "FC: 123 CN: 4567 parity \( ok \)"; then break; fi
453+
if ! CheckExecute "wiegand Verkada40 encode test 1" "$CLIENTBIN -c 'wiegand encode -w Verkada40 --fc 50 --cn 1001'" "86400007D3"; then break; fi
454+
if ! CheckExecute "wiegand Verkada40 decode test 1" "$CLIENTBIN -c 'wiegand decode --raw 86400007D3'" "Verkada40.*FC: 50 CN: 1001 parity \( ok \)"; then break; fi
455+
if ! CheckExecute "wiegand Verkada40 encode test 2" "$CLIENTBIN -c 'wiegand encode -w Verkada40 --fc 50 --cn 1004'" "86400007D9"; then break; fi
456+
if ! CheckExecute "wiegand Verkada40 decode test 2" "$CLIENTBIN -c 'wiegand decode --raw 86400007D9'" "Verkada40.*FC: 50 CN: 1004 parity \( ok \)"; then break; fi
457+
if ! CheckExecute "wiegand Verkada40 encode test 3" "$CLIENTBIN -c 'wiegand encode -w Verkada40 --fc 81 --cn 5008'" "8A20002721"; then break; fi
458+
if ! CheckExecute "wiegand Verkada40 decode test 3" "$CLIENTBIN -c 'wiegand decode --raw 8A20002721'" "Verkada40.*FC: 81 CN: 5008 parity \( ok \)"; then break; fi
453459

454460
echo -e "\n${C_BLUE}Testing LF:${C_NC}"
455461
if ! CheckExecute "lf hitag2 test" "$CLIENTBIN -c 'lf hitag test'" "Tests \( ok"; then break; fi

0 commit comments

Comments
 (0)