diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index d8ea0e29c..f7cf7dead 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -626,14 +626,14 @@ int CmdHFiClassELoad(const char *Cmd) { fseek(f, 0, SEEK_SET); if (fsize < 0) { - prnlog("[-] error, when getting filesize"); + PrintfAndLog("[-] error, when getting filesize"); fclose(f); return 1; } uint8_t *dump = malloc(fsize); if (!dump) { - prnlog("[-] error, cannot allocate memory "); + PrintfAndLog("[-] error, cannot allocate memory "); fclose(f); return 1; } @@ -645,7 +645,7 @@ int CmdHFiClassELoad(const char *Cmd) { //Validate if (bytes_read < fsize) { - prnlog("[-] error, could only read %d bytes (should be %d)", bytes_read, fsize ); + PrintfAndLog("[-] error, could only read %d bytes (should be %d)", bytes_read, fsize ); free(dump); return 1; } @@ -1545,7 +1545,7 @@ int CmdHFiClass_loclass(const char *Cmd) { errors += testMAC(); errors += doKeyTests(0); errors += testElite(); - if (errors) prnlog("[!] There were errors!!!"); + if (errors) PrintfAndLog("[!] There were errors!!!"); return errors; } return 0; diff --git a/client/loclass/cipher.c b/client/loclass/cipher.c index 862345cce..5a5868db4 100644 --- a/client/loclass/cipher.c +++ b/client/loclass/cipher.c @@ -264,7 +264,7 @@ void doMAC_N(uint8_t *address_data_p, uint8_t address_data_size, uint8_t *div_ke #ifndef ON_DEVICE int testMAC() { - prnlog("[+] Testing MAC calculation..."); + PrintfAndLog("[+] Testing MAC calculation..."); //From the "dismantling.IClass" paper: uint8_t cc_nr[] = {0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0,0,0,0}; @@ -277,11 +277,11 @@ int testMAC() if(memcmp(calculated_mac, correct_MAC,4) == 0) { - prnlog("[+] MAC calculation OK!"); + PrintfAndLog("[+] MAC calculation OK!"); }else { - prnlog("[+] FAILED: MAC calculation failed:"); + PrintfAndLog("[+] FAILED: MAC calculation failed:"); printarr(" Calculated_MAC", calculated_mac, 4); printarr(" Correct_MAC ", correct_MAC, 4); return 1; diff --git a/client/loclass/cipherutils.c b/client/loclass/cipherutils.c index b5e365bf4..9115e284b 100644 --- a/client/loclass/cipherutils.c +++ b/client/loclass/cipherutils.c @@ -169,7 +169,7 @@ void printarr(char * name, uint8_t* arr, int len) cx += snprintf(output+cx,outsize-cx,"0x%02x,",*(arr+i));//5 bytes per byte } cx += snprintf(output+cx,outsize-cx,"};"); - prnlog(output); + PrintfAndLog(output); free(output); } @@ -187,7 +187,7 @@ void printvar(char * name, uint8_t* arr, int len) cx += snprintf(output+cx,outsize-cx,"%02x",*(arr+i));//2 bytes per byte } - prnlog(output); + PrintfAndLog(output); free(output); } @@ -207,7 +207,7 @@ void printarr_human_readable(char * title, uint8_t* arr, int len) cx += snprintf(output+cx,outsize-cx,"\n%02x| ", i ); cx += snprintf(output+cx,outsize-cx, "%02x ",*(arr+i)); } - prnlog(output); + PrintfAndLog(output); free(output); } @@ -231,14 +231,14 @@ int testBitStream() } if(memcmp(input, output, sizeof(input)) == 0) { - prnlog(" Bitstream test 1 ok"); + PrintfAndLog(" Bitstream test 1 ok"); }else { - prnlog(" Bitstream test 1 failed"); + PrintfAndLog(" Bitstream test 1 failed"); uint8_t i; for(i = 0 ; i < sizeof(input) ; i++) { - prnlog(" IN %02x, OUT %02x", input[i], output[i]); + PrintfAndLog(" IN %02x, OUT %02x", input[i], output[i]); } return 1; } @@ -265,14 +265,14 @@ int testReversedBitstream() } if(memcmp(input, output, sizeof(input)) == 0) { - prnlog(" Bitstream test 2 ok"); + PrintfAndLog(" Bitstream test 2 ok"); }else { - prnlog(" Bitstream test 2 failed"); + PrintfAndLog(" Bitstream test 2 failed"); uint8_t i; for(i = 0 ; i < sizeof(input) ; i++) { - prnlog(" IN %02x, MIDDLE: %02x, OUT %02x", input[i],reverse[i], output[i]); + PrintfAndLog(" IN %02x, MIDDLE: %02x, OUT %02x", input[i],reverse[i], output[i]); } return 1; } @@ -282,7 +282,7 @@ int testReversedBitstream() int testCipherUtils(void) { - prnlog("[+] Testing some internals..."); + PrintfAndLog("[+] Testing some internals..."); int retval = 0; retval |= testBitStream(); retval |= testReversedBitstream(); diff --git a/client/loclass/elite_crack.c b/client/loclass/elite_crack.c index a8aa82521..e79d5c107 100644 --- a/client/loclass/elite_crack.c +++ b/client/loclass/elite_crack.c @@ -221,7 +221,7 @@ void hash2(uint8_t *key64, uint8_t *outp_keytable) { // Once again, key is on iclass-format desencrypt_iclass(key64, key64_negated, z[0]); -// prnlog("\nHigh security custom key (Kcus):"); +// PrintfAndLog("\nHigh security custom key (Kcus):"); // printvar("z0 ", z[0],8); uint8_t y[8][8]={{0},{0}}; @@ -324,10 +324,10 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) { keytable[key_index[i]] |= BEING_CRACKED; if (numbytes_to_recover > 3) { - prnlog("[-] The CSN requires > 3 byte bruteforce, not supported"); + PrintfAndLog("[-] The CSN requires > 3 byte bruteforce, not supported"); printvar("[-] CSN", item.csn, 8); printvar("[-] HASH1", key_index, 8); - prnlog(""); + PrintfAndLog(""); //Before we exit, reset the 'BEING_CRACKED' to zero keytable[bytes_to_recover[0]] &= ~BEING_CRACKED; keytable[bytes_to_recover[1]] &= ~BEING_CRACKED; @@ -350,9 +350,9 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) { */ uint32_t endmask = 1 << 8*numbytes_to_recover; - prnlog("----------------------------"); + PrintfAndLog("----------------------------"); for (i =0 ; i < numbytes_to_recover && numbytes_to_recover > 1; i++) - prnlog("[+] Bruteforcing byte %d", bytes_to_recover[i]); + PrintfAndLog("[+] Bruteforcing byte %d", bytes_to_recover[i]); while (!found && !(brute & endmask)) { @@ -383,7 +383,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) { if (memcmp(calculated_MAC, item.mac, 4) == 0) { printf("\r\n"); for (i =0 ; i < numbytes_to_recover; i++) { - prnlog("[=] %d: 0x%02x", bytes_to_recover[i], 0xFF & keytable[bytes_to_recover[i]]); + PrintfAndLog("[=] %d: 0x%02x", bytes_to_recover[i], 0xFF & keytable[bytes_to_recover[i]]); } found = true; break; @@ -399,7 +399,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) { } if (!found) { - prnlog("\n[!] Failed to recover %d bytes using the following CSN", numbytes_to_recover); + PrintfAndLog("\n[!] Failed to recover %d bytes using the following CSN", numbytes_to_recover); printvar("[!] CSN", item.csn, 8); errors++; @@ -409,7 +409,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) { keytable[bytes_to_recover[i]] |= CRACK_FAILED; } } else { - //prnlog("[+] DES calcs: %u", brute); + //PrintfAndLog("[+] DES calcs: %u", brute); for (i=0; i < numbytes_to_recover; i++){ keytable[bytes_to_recover[i]] &= 0xFF; keytable[bytes_to_recover[i]] |= CRACKED; @@ -464,7 +464,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] ){ des_setkey_enc( &ctx_e, key64_stdformat ); des_crypt_ecb(&ctx_e, key64_negated, result); - prnlog("\n[+] -- High security custom key (Kcus) --"); + PrintfAndLog("\n[+] -- High security custom key (Kcus) --"); printvar("[+] Standard format ", key64_stdformat, 8); printvar("[+] iClass format ", key64, 8); @@ -472,10 +472,10 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[] ){ memcpy(master_key, key64, 8); if (memcmp(z_0,result,4) != 0) { - prnlog("[!] Failed to verify calculated master key (k_cus)! Something is wrong."); + PrintfAndLog("[!] Failed to verify calculated master key (k_cus)! Something is wrong."); return 1; } else { - prnlog("\n[+] Key verified ok!\n"); + PrintfAndLog("\n[+] Key verified ok!\n"); } return 0; } @@ -501,7 +501,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) { } free(attack); - prnlog("[+] time: %" PRIu64 " seconds", (msclock()-t1)/1000); + PrintfAndLog("[+] time: %" PRIu64 " seconds", (msclock()-t1)/1000); // Pick out the first 16 bytes of the keytable. // The keytable is now in 16-bit ints, where the upper 8 bits @@ -513,7 +513,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) { first16bytes[i] = keytable[i] & 0xFF; if (!(keytable[i] & CRACKED)) - prnlog("[!] error, we are missing byte %d, custom key calculation will fail...", i); + PrintfAndLog("[!] error, we are missing byte %d, custom key calculation will fail...", i); } errors += calculateMasterKey(first16bytes, NULL); return errors; @@ -528,7 +528,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) { int bruteforceFile(const char *filename, uint16_t keytable[]) { FILE *f = fopen(filename, "rb"); if (!f) { - prnlog("[!] Failed to read from file '%s'", filename); + PrintfAndLog("[!] Failed to read from file '%s'", filename); return 1; } @@ -537,7 +537,7 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) { fseek(f, 0, SEEK_SET); if (fsize < 0) { - prnlog("[!] Error, when getting filesize"); + PrintfAndLog("[!] Error, when getting filesize"); if (f) fclose(f); return 1; } @@ -548,7 +548,7 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) { if (f) fclose(f); if (bytes_read < fsize) { - prnlog("[!] Error, could only read %d bytes (should be %d)", bytes_read, fsize ); + PrintfAndLog("[!] Error, could only read %d bytes (should be %d)", bytes_read, fsize ); } uint8_t res = bruteforceDump(dump, fsize, keytable); @@ -576,7 +576,7 @@ int _testBruteforce() { int errors = 0; if (true) { // First test - prnlog("[+] Testing crack from dumpfile..."); + PrintfAndLog("[+] Testing crack from dumpfile..."); /** Expected values for the dumpfile: @@ -603,7 +603,7 @@ int _testBruteforce() { } 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!"); + PrintfAndLog("[!] Error: The file iclass_dump.bin was not found!"); } } return errors; @@ -618,20 +618,20 @@ int _test_iclass_key_permutation() { permutekey_rev(testcase_output, testcase_output_rev); if (memcmp(testcase_output, testcase_output_correct,8) != 0) { - prnlog("[!] Error with iclass key permute!"); + PrintfAndLog("[!] Error with iclass key permute!"); printarr("testcase_output", testcase_output, 8); printarr("testcase_output_correct", testcase_output_correct, 8); return 1; } if (memcmp(testcase, testcase_output_rev, 8) != 0) { - prnlog("[!] Error with reverse iclass key permute"); + PrintfAndLog("[!] Error with reverse iclass key permute"); printarr("testcase", testcase, 8); printarr("testcase_output_rev", testcase_output_rev, 8); return 1; } - prnlog("[+] Iclass key permutation OK!"); + PrintfAndLog("[+] Iclass key permutation OK!"); return 0; } @@ -642,7 +642,7 @@ int _testHash1() { hash1(csn, k); if (memcmp(k,expected,8) != 0) { - prnlog("[!] Error with hash1!"); + PrintfAndLog("[!] Error with hash1!"); printarr("calculated", k, 8); printarr("expected", expected, 8); return 1; @@ -651,8 +651,8 @@ int _testHash1() { } int testElite() { - prnlog("[+] Testing iClass Elite functinality..."); - prnlog("[+] Testing hash2"); + PrintfAndLog("[+] Testing iClass Elite functinality..."); + PrintfAndLog("[+] Testing hash2"); uint8_t k_cus[8] = {0x5B,0x7C,0x62,0xC4,0x91,0xC1,0x1B,0x39}; /** @@ -676,13 +676,13 @@ int testElite() { hash2(k_cus, keytable); printarr_human_readable("Hash2", keytable, 128); if (keytable[3] == 0xA1 && keytable[0x30] == 0xA3 && keytable[0x6F] == 0x95) { - prnlog("[+] Hash2 looks fine..."); + PrintfAndLog("[+] Hash2 looks fine..."); } int errors = 0 ; - prnlog("[+] Testing hash1..."); + PrintfAndLog("[+] Testing hash1..."); errors += _testHash1(); - prnlog("[+] Testing key diversification ..."); + PrintfAndLog("[+] Testing key diversification ..."); errors +=_test_iclass_key_permutation(); errors += _testBruteforce(); return errors; diff --git a/client/loclass/fileutils.c b/client/loclass/fileutils.c index a45d9edd8..d4e159de9 100644 --- a/client/loclass/fileutils.c +++ b/client/loclass/fileutils.c @@ -77,14 +77,14 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si /*Opening file for writing in binary mode*/ FILE *f = fopen(fileName, "wb"); if (!f) { - prnlog("[!] file not found or locked. '%s'", fileName); + PrintfAndLog("[!] file not found or locked. '%s'", fileName); free(fileName); return 1; } fwrite(data, 1, datalen, f); fflush(f); fclose(f); - prnlog("[+] saved %u bytes to binary file %s", datalen, fileName); + PrintfAndLog("[+] saved %u bytes to binary file %s", datalen, fileName); free(fileName); return 0; } @@ -113,7 +113,7 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si /*Opening file for writing in text mode*/ FILE *f = fopen(fileName, "w+"); if (!f) { - prnlog("[!] file not found or locked. '%s'", fileName); + PrintfAndLog("[!] file not found or locked. '%s'", fileName); retval = 1; goto out; } @@ -132,7 +132,7 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si } fflush(f); fclose(f); - prnlog("[+] saved %d blocks to text file %s", blocks, fileName); + PrintfAndLog("[+] saved %d blocks to text file %s", blocks, fileName); out: free(fileName); @@ -147,7 +147,7 @@ out: * write also to a logfile. When doing so, just delete this function. * @param fmt */ -void prnlog(char *fmt, ...) +void PrintfAndLog(char *fmt, ...) { char buffer[2048] = {0}; va_list args; @@ -157,7 +157,7 @@ void prnlog(char *fmt, ...) PrintAndLog(buffer); } #else //if we're on ARM -void prnlog(char *fmt,...) +void PrintfAndLog(char *fmt,...) { return; } diff --git a/client/loclass/ikeys.c b/client/loclass/ikeys.c index d11d9cbd8..04c3c9d15 100644 --- a/client/loclass/ikeys.c +++ b/client/loclass/ikeys.c @@ -227,7 +227,7 @@ void printbegin() { if (debug_print < 2) return; - prnlog(" | x| y|z0|z1|z2|z3|z4|z5|z6|z7|"); + PrintfAndLog(" | x| y|z0|z1|z2|z3|z4|z5|z6|z7|"); } void printState(char* desc, uint64_t c) @@ -295,7 +295,7 @@ void hash0(uint64_t c, uint8_t k[8]) if(x & 1) //Check if x7 is 1 p = ~p; - if(debug_print >= 2) prnlog("p:%02x", p); + if(debug_print >= 2) PrintfAndLog("p:%02x", p); BitstreamIn p_in = { &p, 8,0 }; uint8_t outbuffer[] = {0,0,0,0,0,0,0,0}; @@ -448,7 +448,7 @@ int testDES(Testcase testcase, des_context ctx_enc, des_context ctx_dec) if(memcmp(testcase.uid,decrypted,8) != 0) { //Decryption fail - prnlog("Encryption <-> Decryption FAIL"); + PrintfAndLog("Encryption <-> Decryption FAIL"); printarr("Input", testcase.uid, 8); printarr("Decrypted", decrypted, 8); retval = 1; @@ -457,7 +457,7 @@ int testDES(Testcase testcase, des_context ctx_enc, des_context ctx_dec) if(memcmp(des_encrypted_csn,testcase.t_key,8) != 0) { //Encryption fail - prnlog("Encryption != Expected result"); + PrintfAndLog("Encryption != Expected result"); printarr("Output", des_encrypted_csn, 8); printarr("Expected", testcase.t_key, 8); retval = 1; @@ -468,7 +468,7 @@ int testDES(Testcase testcase, des_context ctx_enc, des_context ctx_dec) if(memcmp(div_key, testcase.div_key ,8) != 0) { //Key diversification fail - prnlog("Div key != expected result"); + PrintfAndLog("Div key != expected result"); printarr(" csn ", testcase.uid,8); printarr("{csn} ", des_encrypted_csn,8); printarr("hash0 ", div_key, 8); @@ -493,13 +493,13 @@ void des_checkParity(uint8_t* key) { bool parity = des_getParityBitFromKey(key[i]); if (parity != (key[i] & 0x1)) { fails++; - prnlog("[+] parity1 fail, byte %d [%02x] was %d, should be %d", i, key[i], (key[i] & 0x1), parity); + PrintfAndLog("[+] parity1 fail, byte %d [%02x] was %d, should be %d", i, key[i], (key[i] & 0x1), parity); } } if(fails) - prnlog("[+] parity fails: %d", fails); + PrintfAndLog("[+] parity fails: %d", fails); else - prnlog("[+] Key syntax is with parity bits inside each byte"); + PrintfAndLog("[+] Key syntax is with parity bits inside each byte"); } Testcase testcases[] ={ @@ -578,15 +578,15 @@ int testKeyDiversificationWithMasterkeyTestcases() { int i; uint8_t empty[8]={0}; - prnlog("[+} Testing encryption/decryption"); + PrintfAndLog("[+} Testing encryption/decryption"); for (i = 0; memcmp(testcases+i, empty, 8); i++) error += testDES(testcases[i], ctx_enc, ctx_dec); if (error) - prnlog("[+] %d errors occurred (%d testcases)", error, i); + PrintfAndLog("[+] %d errors occurred (%d testcases)", error, i); else - prnlog("[+] Hashing seems to work (%d testcases)", i); + PrintfAndLog("[+] Hashing seems to work (%d testcases)", i); return error; } @@ -598,7 +598,7 @@ uint64_t testCryptedCSN(uint64_t crypted_csn, uint64_t expected) { int retval = 0; uint8_t result[8] = {0}; - if(debug_print) prnlog("debug_print %d", debug_print); + if(debug_print) PrintfAndLog("debug_print %d", debug_print); if(debug_print) print64bits(" {csn} ", crypted_csn ); uint64_t crypted_csn_swapped = swapZvalues(crypted_csn); @@ -611,12 +611,12 @@ uint64_t testCryptedCSN(uint64_t crypted_csn, uint64_t expected) if(resultbyte != expected ) { if(debug_print) { - prnlog("\n[+] FAIL!"); + PrintfAndLog("\n[+] FAIL!"); print64bits(" expected " , expected ); } retval = 1; } else { - if (debug_print) prnlog(" [OK]"); + if (debug_print) PrintfAndLog(" [OK]"); } return retval; } @@ -635,7 +635,7 @@ int testDES2(uint64_t csn, uint64_t expected) { print64bits(" expected ", expected ); if( expected == crypt_csn ) { - prnlog("[+] OK"); + PrintfAndLog("[+] OK"); return 0; } else { return 1; @@ -650,13 +650,13 @@ int testDES2(uint64_t csn, uint64_t expected) { int doTestsWithKnownInputs() { // KSel from http://www.proxmark.org/forum/viewtopic.php?pid=10977#p10977 int errors = 0; - prnlog("[+] Testing DES encryption"); + PrintfAndLog("[+] Testing DES encryption"); uint8_t key[8] = {0x6c,0x8d,0x44,0xf9,0x2a,0x2d,0x01,0xbf}; des_setkey_enc( &ctx_enc, key); testDES2(0xbbbbaaaabbbbeeee,0xd6ad3ca619659e6b); - prnlog("[+] Testing hashing algorithm"); + PrintfAndLog("[+] Testing hashing algorithm"); errors += testCryptedCSN(0x0102030405060708,0x0bdd6512073c460a); errors += testCryptedCSN(0x1020304050607080,0x0208211405f3381f); @@ -669,9 +669,9 @@ int doTestsWithKnownInputs() { errors += testCryptedCSN(0x14e2adfc5bb7e134,0x6ac90c6508bd9ea3); if (errors) - prnlog("[+] %d errors occurred (9 testcases)", errors); + PrintfAndLog("[+] %d errors occurred (9 testcases)", errors); else - prnlog("[+] Hashing seems to work (9 testcases)" ); + PrintfAndLog("[+] Hashing seems to work (9 testcases)" ); return errors; } @@ -693,10 +693,10 @@ static bool readKeyFile(uint8_t key[8]) { int doKeyTests(uint8_t debuglevel) { debug_print = debuglevel; - prnlog("[+] Checking if the master key is present (iclass_key.bin)..."); + PrintfAndLog("[+] Checking if the master key is present (iclass_key.bin)..."); uint8_t key[8] = {0}; if (readKeyFile(key)) { - prnlog("[+] Master key not present, will not be able to do all testcases"); + PrintfAndLog("[+] Master key not present, will not be able to do all testcases"); } else { //Test if it's the right key... @@ -706,19 +706,19 @@ int doKeyTests(uint8_t debuglevel) { j += key[i]; if (j != 185) { - prnlog("[+] A key was loaded, but it does not seem to be the correct one. Aborting these tests"); + PrintfAndLog("[+] A key was loaded, but it does not seem to be the correct one. Aborting these tests"); } else { - prnlog("[+] Key present"); - prnlog("[+] Checking key parity..."); + PrintfAndLog("[+] Key present"); + PrintfAndLog("[+] Checking key parity..."); des_checkParity(key); des_setkey_enc( &ctx_enc, key); des_setkey_dec( &ctx_dec, key); // Test hashing functions - prnlog("[+] The following tests require the correct 8-byte master key"); + PrintfAndLog("[+] The following tests require the correct 8-byte master key"); testKeyDiversificationWithMasterkeyTestcases(); } } - prnlog("[+] Testing key diversification with non-sensitive keys..."); + PrintfAndLog("[+] Testing key diversification with non-sensitive keys..."); doTestsWithKnownInputs(); return 0; } diff --git a/client/loclass/main.c b/client/loclass/main.c index fa9886ee9..91bcb5fc5 100644 --- a/client/loclass/main.c +++ b/client/loclass/main.c @@ -56,42 +56,42 @@ int unitTests() errors += testElite(); if(errors) { - prnlog("OBS! There were errors!!!"); + PrintfAndLog("OBS! There were errors!!!"); } return errors; } int showHelp() { - prnlog("Usage: loclass [options]"); - prnlog("Options:"); - prnlog("-t Perform self-test"); - prnlog("-h Show this help"); - prnlog("-f Bruteforce iclass dumpfile"); - prnlog(" An iclass dumpfile is assumed to consist of an arbitrary number of malicious CSNs, and their protocol responses"); - prnlog(" The binary format of the file is expected to be as follows: "); - prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); - prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); - prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); - prnlog(" ... totalling N*24 bytes"); - prnlog(" Check iclass_dump.bin for an example"); + PrintfAndLog("Usage: loclass [options]"); + PrintfAndLog("Options:"); + PrintfAndLog("-t Perform self-test"); + PrintfAndLog("-h Show this help"); + PrintfAndLog("-f Bruteforce iclass dumpfile"); + PrintfAndLog(" An iclass dumpfile is assumed to consist of an arbitrary number of malicious CSNs, and their protocol responses"); + PrintfAndLog(" The binary format of the file is expected to be as follows: "); + PrintfAndLog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); + PrintfAndLog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); + PrintfAndLog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>"); + PrintfAndLog(" ... totalling N*24 bytes"); + PrintfAndLog(" Check iclass_dump.bin for an example"); return 0; } int main (int argc, char **argv) { - prnlog("IClass Cipher version 1.2, Copyright (C) 2014 Martin Holst Swende\n"); - prnlog("Comes with ABSOLUTELY NO WARRANTY"); - prnlog("Released as GPLv2\n"); - prnlog("WARNING"); - prnlog(""); - prnlog("THIS TOOL IS CREATED FOR EXPERIMENTATION AND EDUCATIONAL USE ONLY. "); - prnlog(""); - prnlog("USAGE OF THIS TOOL IN OTHER WAYS MAY INFRINGE UPON THE INTELLECTUAL "); - prnlog("PROPERTY OF OTHER PARTIES, SUCH AS INSIDE SECURE AND HID GLOBAL, "); - prnlog("AND MAY EXPOSE YOU TO AN INFRINGEMENT ACTION FROM THOSE PARTIES. "); - prnlog(""); - prnlog("THIS TOOL SHOULD NEVER BE USED TO INFRINGE PATENTS OR INTELLECTUAL PROPERTY RIGHTS. "); + PrintfAndLog("IClass Cipher version 1.2, Copyright (C) 2014 Martin Holst Swende\n"); + PrintfAndLog("Comes with ABSOLUTELY NO WARRANTY"); + PrintfAndLog("Released as GPLv2\n"); + PrintfAndLog("WARNING"); + PrintfAndLog(""); + PrintfAndLog("THIS TOOL IS CREATED FOR EXPERIMENTATION AND EDUCATIONAL USE ONLY. "); + PrintfAndLog(""); + PrintfAndLog("USAGE OF THIS TOOL IN OTHER WAYS MAY INFRINGE UPON THE INTELLECTUAL "); + PrintfAndLog("PROPERTY OF OTHER PARTIES, SUCH AS INSIDE SECURE AND HID GLOBAL, "); + PrintfAndLog("AND MAY EXPOSE YOU TO AN INFRINGEMENT ACTION FROM THOSE PARTIES. "); + PrintfAndLog(""); + PrintfAndLog("THIS TOOL SHOULD NEVER BE USED TO INFRINGE PATENTS OR INTELLECTUAL PROPERTY RIGHTS. "); char *fileName = NULL;