- if ( strlen(Cmd) < 0 || strlen(Cmd) < 4 || ctmp == 'H' || ctmp == 'h' ) return usage_hid_wiegand();
-
- fmtlen = param_get8(Cmd, 0);
- oem = param_get8(Cmd, 1);
- fc = param_get32ex(Cmd, 2, 0, 10);
- cn = param_get64ex(Cmd, 3, 0, 10);
-
- switch ( fmtlen ) {
- case 26 : {
- cardnum = (cn & 0xFFFFFFFF);
- calc26(fc, cardnum, &hi, &lo);
- getParity26(&hi, &lo);
+ if ( strlen(Cmd) == 0 || strlen(Cmd) < 3 || ctmp == 'H' || ctmp == 'h' ) return usage_lf_hid_wiegand();
+
+ oem = param_get8(Cmd, 0);
+ fc = param_get32ex(Cmd, 1, 0, 10);
+ cardnum = param_get64ex(Cmd, 2, 0, 10);
+
+ uint8_t fmtlen[] = {26,33,34,35,37,38,40};
+
+ PrintAndLog("HID | OEM | FC | CN | Wiegand | HID Formatted");
+ PrintAndLog("----+-----+------+---------+-----------+--------------------");
+ for (uint8_t i = 0; i < sizeof(fmtlen); i++){
+ memset(bits, 0x00, sizeof(bits));
+ calcWiegand( fmtlen[i], fc, cardnum, bs);
+ printf("ice:: %s", sprint_bin(bs, fmtlen[i]));
+ wiegand = (uint64_t)bytebits_to_byte(bs, 32) << 32 | bytebits_to_byte(bs+32, 32);
+
+ addHIDMarker(fmtlen[i], bs);
+ printf("ice:: %s", sprint_bin(bs, 37));
+ blocks = (uint64_t)bytebits_to_byte(bs, 32) << 32 | bytebits_to_byte(bs+32, 32);
+ uint8_t shifts = 64-fmtlen[i];
+ wiegand >>= shifts;
+
+ PrintAndLog(" %u | %03u | %03u | %llu | %llX | %llX",
+ fmtlen[i],
+ oem,
+ fc,
+ cardnum,
+ wiegand,
+ blocks
+ );
+ }
+ PrintAndLog("----+-----+-----+-------+-----------+--------------------");
+ return 0;
+}
+
+int CmdHIDBrute(const char *Cmd){
+
+ bool errors = false;
+ uint32_t fc = 0, cn = 0, delay = 1000;
+ uint8_t fmtlen = 0;
+ uint8_t bits[96];
+ uint8_t *bs = bits;
+ memset(bs, 0, sizeof(bits));
+ uint8_t cmdp = 0;
+
+ while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
+ switch(param_getchar(Cmd, cmdp)) {
+ case 'h':
+ case 'H':
+ return usage_lf_hid_brute();
+ case 'f':
+ case 'F':
+ fc = param_get32ex(Cmd ,cmdp+1, 0, 10);
+ if ( !fc )
+ errors = true;
+ cmdp += 2;