more wiegand formats, and if binary is user supplied use that length, and ignore parity faults is removed since we wanna see all decodings anyway

This commit is contained in:
iceman1001 committed 2021-04-27 15:19:34 +02:00
1 parent bbdb2d7c95
commit 10c9ea5f84
7 files changed
+213 -116

No files matched your search

+7 -10
View File
@@ -107,27 +107,24 @@ int CmdWiegandDecode(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "wiegand decode",
"Decode raw hex to wiegand format",
"Decode raw hex or binary to wiegand format",
"wiegand decode --raw 2006f623ae"
);
void *argtable[] = {
arg_param_begin,
arg_lit0("p", "parity", "ignore invalid parity"),
arg_strx0("r", "raw", "<hex>", "raw hex to be decoded"),
arg_str0("b", "bin", "<bin>", "binary string to be decoded"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
bool ignore_parity = arg_get_lit(ctx, 1);
CLIExecWithReturn(ctx, Cmd, argtable, true);
int hlen = 0;
char hex[40] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)hex, sizeof(hex), &hlen);
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)hex, sizeof(hex), &hlen);
int blen = 0;
uint8_t binarr[100] = {0x00};
int res = CLIParamBinToBuf(arg_get_str(ctx, 3), binarr, sizeof(binarr), &blen);
int res = CLIParamBinToBuf(arg_get_str(ctx, 2), binarr, sizeof(binarr), &blen);
CLIParserFree(ctx);
if (res) {
@@ -144,7 +141,7 @@ int CmdWiegandDecode(const char *Cmd) {
return PM3_EINVARG;
}
} else if (blen) {
uint16_t n = binarray_to_u96(&top, &mid, &bot, binarr, blen);
int n = binarray_to_u96(&top, &mid, &bot, binarr, blen);
if (n != blen) {
PrintAndLogEx(ERR, "Binary string contains none <0|1> chars");
return PM3_EINVARG;
@@ -153,8 +150,8 @@ int CmdWiegandDecode(const char *Cmd) {
PrintAndLogEx(ERR, "empty input");
return PM3_EINVARG;
}
wiegand_message_t packed = initialize_message_object(top, mid, bot);
HIDTryUnpack(&packed, ignore_parity);
wiegand_message_t packed = initialize_message_object(top, mid, bot, blen);
HIDTryUnpack(&packed);
return PM3_SUCCESS;
}