int testMAC() { prnlog("[+] Testing MAC calculation..."); //From the "dismantling.IClass" paper: uint8_t cc_nr[] = {0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0,0,0,0}; //From the paper uint8_t div_key[8] = {0xE0,0x33,0xCA,0x41,0x9A,0xEE,0x43,0xF9}; uint8_t correct_MAC[4] = {0x1d,0x49,0xC9,0xDA}; uint8_t calculated_mac[4] = {0}; doMAC(cc_nr,div_key, calculated_mac); if(memcmp(calculated_mac, correct_MAC,4) == 0) { prnlog("[+] MAC calculation OK!"); }else { prnlog("[+] FAILED: MAC calculation failed:"); printarr(" Calculated_MAC", calculated_mac, 4); printarr(" Correct_MAC ", correct_MAC, 4); return 1; } return 0; }
int unitTests() { int errors = testCipherUtils(); errors += testMAC(); errors += doKeyTests(0); errors += testElite(); errors += testOptMAC(); if(errors) { prnlog("OBS! There were errors!!!"); } return errors; }
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. "); char *fileName = NULL; int c; while ((c = getopt (argc, argv, "xthf:")) != -1) switch (c) { case 'x': brute_hash1(); return 0; case 't': return unitTests(); case 'h': return showHelp(); case 'f': fileName = optarg; return bruteforceFileNoKeys(fileName); case '?': if (optopt == 'f') fprintf (stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 1; //default: //showHelp(); } showHelp(); return 0; }
int showHelp() { prnlog("Usage: loclass [options]"); prnlog("Options:"); prnlog("-t Perform self-test"); prnlog("-h Show this help"); prnlog("-d <CSN> -k <key> Calculate diversified key, based on CSN and K_CUS. Key should be on standard NIST-format, not iclass format "); prnlog("-f <filename> Bruteforce iclass dumpfile"); prnlog(" An iclass dumpfile is assumed to consist of an arbitrary number of malicious CSNs, and their protocol responses"); prnlog(" The 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"); return 0; }
int showHelp() { prnlog("Usage: iclazz [options]"); prnlog("Options:"); prnlog("-t Perform self-test"); prnlog("-h Show this help"); prnlog("-f <filename> Bruteforce iclass dumpfile"); prnlog(" An iclass dumpfile is assumed to consist of an arbitrary number of malicious CSNs, and their protocol responses"); prnlog(" The 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"); return 0; }