int crc = 0;
int wrp = 0;
int wrc = 0;
- uint8_t data_buf[1052]; // receiver buffer
+ uint8_t data_buf[1053]; // receiver buffer
char out_string[3076]; // just use big buffer - bad practice
char token_type[4];
int CmdHFTopaz(const char *Cmd) {
// flush
- WaitForResponseTimeout(CMD_ACK,NULL,100);
-
+ //WaitForResponseTimeout(CMD_ACK,NULL,100);
+ clearCommandBuffer();
+
// parse
CmdsParse(CommandTable, Cmd);
return 0;
*lo |= !result;
}
-static void getParity35(uint32_t *hi, uint32_t *lo){
- *hi = *hi;
+static void getParity35(uint32_t *hi, uint32_t *lo){
}
static void getParity37S(uint32_t *hi,uint32_t *lo){
uint32_t result = 0;
- uint8_t i;
+ int i;
// even parity
for (i = 4; i >= 0; i--)
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();
+ 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);
int CmdHIDBrute(const char *Cmd){
- bool error = FALSE;
+ bool error = TRUE;
uint8_t fc = 0, fmtlen = 0;
uint32_t hi = 0, lo = 0;
if (strlen(Cmd) > 2 || strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_hid_brute();
fmtlen = param_get8(Cmd, 0);
- switch(fmtlen){
- case 26:
- case 33:
- case 34:
- case 35:
- case 37: {
+ uint8_t ftms[] = {26,33,34,35,37};
+ for ( uint8_t i = 0; i < sizeof(ftms); i++){
+ if ( ftms[i] == fmtlen ) {
error = FALSE;
- break;
- }
- default: {
- error = TRUE;
- break;
}
}
+
if ( error ) return usage_lf_hid_brute();
fc = param_get8(Cmd, 1);
getchar();\r
printf("\naborted via keyboard!\n");\r
free(keyBlock);\r
- free(p);\r
return 0;\r
}\r
\r
if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, testpwd)) {\r
PrintAndLog("Aquireing data from device failed. Quitting");\r
free(keyBlock);\r
- free(p);\r
return 0;\r
}\r
\r
if ( found ) {\r
PrintAndLog("Found valid password: [%08X]", testpwd);\r
free(keyBlock);\r
- free(p);\r
return 0;\r
} \r
}\r
PrintAndLog("Password NOT found.");\r
free(keyBlock);\r
- free(p);\r
return 0;\r
}\r
\r
res = sscanf(Cmd, "%012"llx" %012"llx" %012"llx"", &c.arg[0], &c.arg[1], &c.arg[2]);
if (res == 2) c.arg[2]=0;
- if (res < 2)
+ if (res < 2) {
PrintAndLog("Please specify the data as two hex strings, optionally the CRC as a third");
- else
- clearCommandBuffer();
- SendCommand(&c);
+ return 1;
+ }
+ clearCommandBuffer();
+ SendCommand(&c);
return 0;
}
if(!aliases->name)
return(-1);
- if(!(ukey = malloc((size_t) 1 + strlen(key))))
+ if(!(ukey = malloc((size_t) 1 + strlen(key)))) {
uerror("cannot allocate memory for comparison string");
+ return(0);
+ }
akey.name = uptr = ukey;
do
*uptr++ = toupper(*key);
void
mmatch(model_t *model, int flags) {
+
+ if(!model) return;
+
/* searches models[] for a model matching the argument, and links a name if found
* if flags & M_OVERWR, copies the found model onto the argument. */
model_t *mptr;
- if(!model) return;
mptr = bsearch(model, models, NPRESETS, sizeof(model_t), (int (*)(const void *, const void *)) &mcmp);
+
if(mptr) {
model->name = mptr->name;
if(flags & M_OVERWR)
engini(&resc, &result, guess->spoly, guess->flags, args, argpolys);
requit:
- if(!(result = realloc(result, ++resc * sizeof(model_t))))
+ if(!(result = realloc(result, ++resc * sizeof(model_t)))) {
uerror("cannot reallocate result array");
+ return NULL;
+ }
rptr = result + resc - 1;
rptr->spoly = pzero;
rptr->init = pzero;