k[0] = csn[0]^csn[1]^csn[2]^csn[3]^csn[4]^csn[5]^csn[6]^csn[7];
k[1] = csn[0]+csn[1]+csn[2]+csn[3]+csn[4]+csn[5]+csn[6]+csn[7];
k[2] = rr(swap( csn[2]+k[1] ));
- k[3] = rr(swap( csn[3]+k[0] ));
- k[4] = ~rr(swap( csn[4]+k[2] ))+1;
- k[5] = ~rr(swap( csn[5]+k[3] ))+1;
+ k[3] = rl(swap( csn[3]+k[0] ));
+ k[4] = ~rr( csn[4]+k[2] )+1;
+ k[5] = ~rl( csn[5]+k[3] )+1;
k[6] = rr( csn[6]+(k[4]^0x3c) );
k[7] = rl( csn[7]+(k[5]^0xc3) );
int i;
*/
int bruteforceFile(const char *filename, uint16_t keytable[])
{
-
FILE *f = fopen(filename, "rb");
if(!f) {
prnlog("Failed to read from file '%s'", filename);
fseek(f, 0, SEEK_SET);
uint8_t *dump = malloc(fsize);
- fread(dump, fsize, 1, f);
- fclose(f);
+ size_t bytes_read = fread(dump, 1, fsize, f);
+ fclose(f);
+ if (bytes_read < fsize)
+ {
+ prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
+ }
return bruteforceDump(dump,fsize,keytable);
}
/**
**** The 64-bit HS Custom Key Value = 5B7C62C491C11B39 ****
**/
uint16_t keytable[128] = {0};
- //save some time...
- startvalue = 0x7B0000;
+
+ //Test a few variants
+ if(fileExists("iclass_dump.bin"))
+ {
errors |= bruteforceFile("iclass_dump.bin",keytable);
+ }else if(fileExists("loclass/iclass_dump.bin")){
+ errors |= bruteforceFile("loclass/iclass_dump.bin",keytable);
+ }else if(fileExists("client/loclass/iclass_dump.bin")){
+ errors |= bruteforceFile("client/loclass/iclass_dump.bin",keytable);
+ }else{
+ prnlog("Error: The file iclass_dump.bin was not found!");
+ }
}
return errors;
}