*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-//#include <libgen.h>
+
+#ifndef __MINGW32__
+#include <libgen.h>
+#endif
#define _GNU_SOURCE
#include <getopt.h>
" -r --read Read a mifare sector\n"
" -l --loop-read Loop reading a mifare sector\n"
" -w --write Write a mifare sector\n"
- " -k --key Specify mifare access key (in hex tuples)\n");
+ " -k --key Specify mifare access key (in hex tuples)\n"
+ " -b --brute-force n Brute Force read sector n\n");
}
static struct option mifare_opts[] = {
{ "loop-read", 1, 0, 'l' },
{ "write", 1 ,0, 'w' },
{ "help", 0, 0, 'h' },
+ { "brute-force", 1, 0, 'b' },
{ 0, 0, 0, 0 }
};
program_name = basename(argv[0]);
#endif/*__MINGW32__*/
- memcpy(key, MIFARE_CL_KEYA_DEFAULT_INFINEON,
- sizeof(MIFARE_CL_KEYA_DEFAULT_INFINEON));
+ memcpy(key, MIFARE_CL_KEYA_DEFAULT_INFINEON, MIFARE_CL_KEY_LEN);
printf("%s - (C) 2006 by Harald Welte\n"
"This program is Free Software and has "
}
while (1) {
- c = getopt_long(argc, argv, "k:r:l:w:", mifare_opts,
+ c = getopt_long(argc, argv, "k:r:l:w:b:h", mifare_opts,
&option_index);
if (c == -1)
break;
switch (c) {
+ int i;
+ case 'b':
+ page = atoi(optarg);
+ printf("key: %s\n", hexdump(key, MIFARE_CL_KEY_LEN));
+ len = MIFARE_CL_PAGE_SIZE;
+ mifare_l3();
+ for (i = 0; i <= 0xff; i++) {
+ key[MIFARE_CL_KEY_LEN-1]=i;
+ if (mifare_cl_auth(key, page) >= 0)
+ printf("KEY: %s\n",hexdump(key, MIFARE_CL_KEY_LEN));
+ }
+
+ break;
case 'k':
hexread(key, optarg, strlen(optarg));
printf("key: %s\n", hexdump(key, MIFARE_CL_KEY_LEN));