]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/loclass/main.c
ADD: default_toys.lua a script which identify tnp3xx tags
[proxmark3-svn] / client / loclass / main.c
CommitLineData
3ad48540
MHS
1/*****************************************************************************
2 * This file is part of iClassCipher. It is a reconstructon of the cipher engine
3 * used in iClass, and RFID techology.
4 *
5 * The implementation is based on the work performed by
6 * Flavio D. Garcia, Gerhard de Koning Gans, Roel Verdult and
7 * Milosch Meriac in the paper "Dismantling IClass".
8 *
9 * Copyright (C) 2014 Martin Holst Swende
10 *
11 * This is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
14 *
15 * This file is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with IClassCipher. If not, see <http://www.gnu.org/licenses/>.
22 ****************************************************************************/
23
24#include <stdio.h>
25#include <cipherutils.h>
26#include <stdint.h>
27#include <stdbool.h>
28#include <string.h>
29#include <unistd.h>
30#include <ctype.h>
31#include "cipherutils.h"
32#include "cipher.h"
33#include "ikeys.h"
34#include "fileutils.h"
35#include "elite_crack.h"
36
37int unitTests()
38{
39 int errors = testCipherUtils();
40 errors += testMAC();
41 errors += doKeyTests(0);
42 errors += testElite();
43 return errors;
44}
45int showHelp()
46{
47 prnlog("Usage: iclazz [options]");
48 prnlog("Options:");
49 prnlog("-t Perform self-test");
50 prnlog("-h Show this help");
51 prnlog("-f <filename> Bruteforce iclass dumpfile");
52 prnlog(" An iclass dumpfile is assumed to consist of an arbitrary number of malicious CSNs, and their protocol responses");
53 prnlog(" The the binary format of the file is expected to be as follows: ");
54 prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>");
55 prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>");
56 prnlog(" <8 byte CSN><8 byte CC><4 byte NR><4 byte MAC>");
57 prnlog(" ... totalling N*24 bytes");
58 prnlog(" Check iclass_dump.bin for an example");
59
60 return 0;
61}
62
63int main (int argc, char **argv)
64{
65 prnlog("IClass Cipher version 1.2, Copyright (C) 2014 Martin Holst Swende\n");
66 prnlog("Comes with ABSOLUTELY NO WARRANTY");
67 prnlog("This is free software, and you are welcome to use, abuse and repackage, please keep the credits\n");
68 char *fileName = NULL;
69 int c;
70 while ((c = getopt (argc, argv, "thf:")) != -1)
71 switch (c)
72 {
73 case 't':
74 return unitTests();
75 case 'h':
76 return showHelp();
77 case 'f':
78 fileName = optarg;
79 return bruteforceFileNoKeys(fileName);
80 case '?':
81 if (optopt == 'f')
82 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
83 else if (isprint (optopt))
84 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
85 else
86 fprintf (stderr,
87 "Unknown option character `\\x%x'.\n",
88 optopt);
89 return 1;
90 //default:
91 //showHelp();
92 }
93 showHelp();
94 return 0;
95}
96
Impressum, Datenschutz