+}
+
+int CmdHIDWiegand(const char *Cmd) {
+ uint32_t oem;
+ uint32_t fc, lo = 0, hi = 0;
+ uint64_t cardnum = 0;
+
+ uint8_t ctmp = param_getchar(Cmd, 0);
+ 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 ftmlen[] = {26,33,34,35,37,38,40};
+ for (uint8_t i = 0; i < sizeof(ftmlen); i++){
+ calcWiegand( ftmlen[i], fc, cardnum, &hi, &lo);
+ PrintAndLog("HID %d bit | OEM: %d FC: %d CN: %llu | Wiegand code: %08X%08X", ftmlen[i], oem, fc, cardnum, hi, lo);
+ }
+ return 0;
+}
+
+int CmdHIDBrute(const char *Cmd){
+
+ bool error = TRUE;
+ uint8_t fc = 0, fmtlen = 0;
+ uint32_t hi = 0, lo = 0;
+
+ UsbCommand c = {CMD_HID_SIM_TAG, {0, 0, 0}};
+
+ char cmdp = param_getchar(Cmd, 0);
+ if (strlen(Cmd) > 2 || strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_hid_brute();
+
+ fmtlen = param_get8(Cmd, 0);
+ uint8_t ftms[] = {26,33,34,35,37};
+ for ( uint8_t i = 0; i < sizeof(ftms); i++){
+ if ( ftms[i] == fmtlen ) {
+ error = FALSE;
+ }
+ }
+
+ if ( error ) return usage_lf_hid_brute();
+
+ fc = param_get8(Cmd, 1);
+ if ( fc == 0) return usage_lf_hid_brute();
+
+ PrintAndLog("Brute-forcing HID reader");
+ PrintAndLog("Press pm3-button to abort simulation or run another command");
+
+ for ( uint16_t cn = 1; cn < 0xFFFF; ++cn){
+ if (ukbhit()) {
+ PrintAndLog("aborted via keyboard!");
+ c.cmd = CMD_PING;
+ c.arg[0] = 0x00;
+ c.arg[1] = 0x00;
+ c.arg[2] = 0x00;
+ clearCommandBuffer();
+ SendCommand(&c);
+ return 1;
+ }
+
+ calcWiegand( fmtlen, fc, cn, &hi, &lo);
+
+ c.arg[0] = hi;
+ c.arg[1] = lo;
+ clearCommandBuffer();
+ SendCommand(&c);
+
+ PrintAndLog("Trying FC: %u; CN: %u", fc, cn);
+ // pause
+ sleep(1);
+ }