text and style

This commit is contained in:
iceman1001 2025-03-02 16:45:01 +01:00
commit af3a16b25c
6 changed files with 34 additions and 24 deletions

View file

@ -213,7 +213,8 @@ int CmdWiegandDecode(const char *Cmd) {
} }
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "Wiegand decode"); PrintAndLogEx(INFO, "------------------------- " _CYAN_("Wiegand") " ---------------------------");
decode_wiegand(top, mid, bot, blen); decode_wiegand(top, mid, bot, blen);
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -1676,17 +1676,18 @@ int HIDDumpPACSBits(const uint8_t *const data, const uint8_t length, bool verbos
bytes_2_binstr(binstr, data + 1, n); bytes_2_binstr(binstr, data + 1, n);
PrintAndLogEx(NORMAL, ""); // PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "PACS......... " _GREEN_("%s"), sprint_hex_inrow(data, length)); PrintAndLogEx(INFO, "------------------------- " _CYAN_("Wiegand") " ---------------------------");
PrintAndLogEx(SUCCESS, "padded bin... " _GREEN_("%s") " ( %zu )", binstr, strlen(binstr)); PrintAndLogEx(SUCCESS, "PACS............. " _GREEN_("%s"), sprint_hex_inrow(data, length));
PrintAndLogEx(DEBUG, "padded bin....... " _GREEN_("%s") " ( %zu )", binstr, strlen(binstr));
binstr[strlen(binstr) - pad] = '\0'; binstr[strlen(binstr) - pad] = '\0';
PrintAndLogEx(SUCCESS, "bin.......... " _GREEN_("%s") " ( %zu )", binstr, strlen(binstr)); PrintAndLogEx(DEBUG, "bin.............. " _GREEN_("%s") " ( %zu )", binstr, strlen(binstr));
size_t hexlen = 0; size_t hexlen = 0;
uint8_t hex[16] = {0}; uint8_t hex[16] = {0};
binstr_2_bytes(hex, &hexlen, binstr); binstr_2_bytes(hex, &hexlen, binstr);
PrintAndLogEx(SUCCESS, "hex.......... " _GREEN_("%s"), sprint_hex_inrow(hex, hexlen)); PrintAndLogEx(SUCCESS, "hex.............. " _GREEN_("%s"), sprint_hex_inrow(hex, hexlen));
uint32_t top = 0, mid = 0, bot = 0; uint32_t top = 0, mid = 0, bot = 0;
if (binstring_to_u96(&top, &mid, &bot, binstr) != strlen(binstr)) { if (binstring_to_u96(&top, &mid, &bot, binstr) != strlen(binstr)) {
@ -1696,14 +1697,16 @@ int HIDDumpPACSBits(const uint8_t *const data, const uint8_t length, bool verbos
} }
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "Wiegand decode");
wiegand_message_t packed = initialize_message_object(top, mid, bot, strlen(binstr)); wiegand_message_t packed = initialize_message_object(top, mid, bot, strlen(binstr));
HIDTryUnpack(&packed); HIDTryUnpack(&packed);
PrintAndLogEx(NORMAL, "");
if (strlen(binstr) >= 26 && verbose) { if (strlen(binstr) >= 26 && verbose) {
// SEOS
// iCLASS Legacy SE
// iCLASS Legacy SR
// iCLASS Legacy // iCLASS Legacy
PrintAndLogEx(INFO, "Clone to " _YELLOW_("iCLASS Legacy")); PrintAndLogEx(INFO, "Clone to " _YELLOW_("iCLASS Legacy"));
PrintAndLogEx(SUCCESS, " hf iclass encode --ki 0 --bin %s", binstr); PrintAndLogEx(SUCCESS, " hf iclass encode --ki 0 --bin %s", binstr);
@ -1714,6 +1717,8 @@ int HIDDumpPACSBits(const uint8_t *const data, const uint8_t length, bool verbos
PrintAndLogEx(SUCCESS, " lf hid clone -w H10301 --bin %s", binstr); PrintAndLogEx(SUCCESS, " lf hid clone -w H10301 --bin %s", binstr);
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
// MIFARE DESFire
// MIFARE Classic // MIFARE Classic
char mfcbin[28] = {0}; char mfcbin[28] = {0};
mfcbin[0] = '1'; mfcbin[0] = '1';

View file

@ -128,7 +128,7 @@ bool set_nonlinear_field(wiegand_message_t *data, uint64_t value, uint8_t numBit
return result; return result;
} }
static uint8_t get_length_from_header(wiegand_message_t *data) { uint8_t get_length_from_header(wiegand_message_t *data) {
/** /**
* detect if message has "preamble" / "sentinel bit" * detect if message has "preamble" / "sentinel bit"
* Right now we just calculate the highest bit set * Right now we just calculate the highest bit set
@ -146,6 +146,7 @@ static uint8_t get_length_from_header(wiegand_message_t *data) {
* 0000 0010 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 35-bit * 0000 0010 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 35-bit
* 0000 0011 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 36-bit * 0000 0011 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 36-bit
* 0000 000x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 37-bit * 0000 000x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 37-bit
* 0000 00xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 38-bit
*/ */
uint8_t len = 0; uint8_t len = 0;
uint32_t hfmt = 0; // for calculating card length uint32_t hfmt = 0; // for calculating card length
@ -188,13 +189,15 @@ wiegand_message_t initialize_message_object(uint32_t top, uint32_t mid, uint32_t
bool add_HID_header(wiegand_message_t *data) { bool add_HID_header(wiegand_message_t *data) {
// Invalid value // Invalid value
if (data->Length > 84 || data->Length == 0) if (data->Length > 84 || data->Length == 0) {
return false; return false;
}
if (data->Length == 48) { if (data->Length == 48) {
data->Mid |= 1U << (data->Length - 32); // Example leading 1: start bit data->Mid |= 1U << (data->Length - 32); // Example leading 1: start bit
return true; return true;
} }
if (data->Length >= 64) { if (data->Length >= 64) {
data->Top |= 0x09e00000; // Extended-length header data->Top |= 0x09e00000; // Extended-length header
data->Top |= 1U << (data->Length - 64); // leading 1: start bit data->Top |= 1U << (data->Length - 64); // leading 1: start bit

View file

@ -52,6 +52,7 @@ bool set_nonlinear_field(wiegand_message_t *data, uint64_t value, uint8_t numBit
wiegand_message_t initialize_message_object(uint32_t top, uint32_t mid, uint32_t bot, int n); wiegand_message_t initialize_message_object(uint32_t top, uint32_t mid, uint32_t bot, int n);
uint8_t get_length_from_header(wiegand_message_t *data);
bool add_HID_header(wiegand_message_t *data); bool add_HID_header(wiegand_message_t *data);
#endif #endif

View file

@ -13167,8 +13167,8 @@
"command": "wiegand decode", "command": "wiegand decode",
"description": "Decode raw hex or binary to wiegand format", "description": "Decode raw hex or binary to wiegand format",
"notes": [ "notes": [
"wiegand decode --raw 2006f623ae", "wiegand decode --raw 2006F623AE",
"wiegand decode --new 04801EEF8DC0 -> 4..8 bytes, new padded format" "wiegand decode --new 06BD88EB80 -> 4..8 bytes, new padded format"
], ],
"offline": true, "offline": true,
"options": [ "options": [
@ -13214,6 +13214,6 @@
"metadata": { "metadata": {
"commands_extracted": 759, "commands_extracted": 759,
"extracted_by": "PM3Help2JSON v1.00", "extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2025-02-23T21:55:16" "extracted_on": "2025-03-02T15:43:45"
} }
} }