+ //The line start with # is comment, skip
+ if( buf[0]=='#' ) continue;
+
+ if (param_gethex(buf, 0, uid, 10)) {
+ PrintAndLog("UIDs must include 10 HEX symbols");
+ free(uidBlock);
+ fclose(f);
+ return 1;
+ }
+
+ buf[10] = 0;
+
+ if ( stUidBlock - uidcnt < 2) {
+ p = realloc(uidBlock, 5*(stUidBlock+=10));
+ if (!p) {
+ PrintAndLog("Cannot allocate memory for UIDs");
+ free(uidBlock);
+ fclose(f);
+ return 1;
+ }
+ uidBlock = p;
+ }
+ memset(uidBlock + 5 * uidcnt, 0, 5);
+ num_to_bytes(strtoll(buf, NULL, 16), 5, uidBlock + 5*uidcnt);
+ uidcnt++;
+ memset(buf, 0, sizeof(buf));
+ }
+ fclose(f);
+
+ if (uidcnt == 0) {
+ PrintAndLog("No UIDs found in file");
+ free(uidBlock);
+ return 1;
+ }
+ PrintAndLog("Loaded %d UIDs from %s, pause delay: %d ms", uidcnt, filename, delay);
+
+ // loop
+ for(uint32_t c = 0; c < uidcnt; ++c ) {
+ char testuid[11];
+ testuid[10] = 0;
+
+ if (ukbhit()) {
+ ch = getchar();
+ (void)ch;
+ printf("\nAborted via keyboard!\n");
+ free(uidBlock);
+ return 0;
+ }
+
+ sprintf(testuid, "%010lX", bytes_to_num(uidBlock + 5*c, 5));
+ PrintAndLog("Bruteforce %d / %d: simulating UID %s, clock %d", c + 1, uidcnt, testuid, clock);
+
+ ConstructEM410xEmulGraph(testuid, clock);
+
+ CmdLFSim("0"); //240 start_gap.
+
+ msleep(delay);
+ }
+
+ free(uidBlock);