+int CmdAWIDBrute(const char *Cmd){
+
+ uint32_t fc = 0x00;
+ uint8_t fmtlen = 0;
+ uint8_t bits[96];
+ uint8_t *bs = bits;
+ size_t size = sizeof(bits);
+ memset(bs, 0x00, size);
+
+ char cmdp = param_getchar(Cmd, 0);
+ if (strlen(Cmd) > 4 || strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_awid_brute();
+
+ fmtlen = param_get8(Cmd, 0);
+ fc = param_get32ex(Cmd, 1, 0, 10);
+ if ( !fc ) return usage_lf_awid_brute();
+
+ switch(fmtlen) {
+ case 50:
+ if ((fc & 0xFFFF) != fc) {
+ fc &= 0xFFFF;
+ PrintAndLog("Facility-Code Truncated to 16-bits (AWID50): %u", fc);
+ }
+ break;
+ default:
+ if ((fc & 0xFF) != fc) {
+ fc &= 0xFF;
+ PrintAndLog("Facility-Code Truncated to 8-bits (AWID26): %u", fc);
+ }
+ break;
+ }
+
+ PrintAndLog("Bruteforceing AWID %d Reader", fmtlen);
+ PrintAndLog("Press pm3-button to abort simulation or run another command");
+
+ uint64_t arg1 = (10<<8) + 8; // fcHigh = 10, fcLow = 8
+ uint64_t arg2 = 50; // clk RF/50 invert=0
+ UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}};
+
+ 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;
+ }
+
+ (void)getAWIDBits(fmtlen, fc, cn, bs);
+ memcpy(c.d.asBytes, bs, size);
+ clearCommandBuffer();
+ SendCommand(&c);
+
+ PrintAndLog("Trying FC: %u; CN: %u", fc, cn);
+ // pause
+ sleep(1);
+ }
+ return 0;
+}
+