Commit e30a2863 authored by Samuel Henrique's avatar Samuel Henrique

Update upstream source from tag 'upstream/0.3.8+git20180720'

Update to upstream version '0.3.8+git20180720'
with Debian dir 4c6deb553625b3b114795c4e4f2da1eb1531e35f
parents 7205fabf 2b971476
This diff is collapsed.
This diff is collapsed.
......@@ -2,8 +2,7 @@ README
======
Compiling:
automake
autoconf
autoreconf -is
./configure
make
......@@ -24,7 +23,7 @@ LICENSE
GPL. See MFCUK_LICENSE for more information.
BIBLIOGRPAHY (no specific order)
BIBLIOGRAPHY (no specific order)
---------------------------------
1. [WPMCC09] - "Wirelessly Pickpocketing a Mifare Classic Card"
2. [ESO08] - "2008-esorics.pdf"
......
This diff is collapsed.
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
/* Define to 1 if you have the <CoreFoundation/CoreFoundation.h> header file.
*/
#undef HAVE_COREFOUNDATION_COREFOUNDATION_H
/* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_ENDIAN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#undef HAVE_REALLOC
/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if you have the <sys/endian.h> header file. */
#undef HAVE_SYS_ENDIAN_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT64_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to 500 if Single Unix conformance is wanted, 600 for sixth revision.
*/
#undef _XOPEN_SOURCE
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to rpl_realloc if the replacement function should be used. */
#undef realloc
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef uint64_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
This diff is collapsed.
AC_INIT([mfcuk], [0.3.8], [zveriu@gmail.com])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Checks for pkg-config modules.
......@@ -30,7 +28,6 @@ AC_TYPE_UINT8_T
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_FUNCS([memset strchr strtoul])
# Checks for endianness convertion
......@@ -41,6 +38,9 @@ fi
AC_CHECK_HEADERS([byteswap.h])
AC_CHECK_HEADERS([unistd.h])
AM_CONDITIONAL([HAVE_UNISTD], [test $ac_cv_header_unistd_h = "yes"])
AC_DEFINE([_XOPEN_SOURCE], [600], [Define to 500 if Single Unix conformance is wanted, 600 for sixth revision.])
# Help us to write great code ;-)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,9 +2,14 @@ AM_CFLAGS = @libnfc_CFLAGS@
bin_PROGRAMS = mfcuk
noinst_HEADERS = crapto1.h mifare.h nfc-utils.h mfcuk_mifare.h mfcuk_finger.h mfcuk_utils.h xgetopt.h mfcuk.h
noinst_HEADERS = crapto1.h mifare.h nfc-utils.h mfcuk_mifare.h mfcuk_finger.h mfcuk_utils.h mfcuk.h xgetopt.h
mfcuk_SOURCES = crapto1.c crypto1.c mifare.c nfc-utils.c mfcuk_mifare.c mfcuk_finger.c mfcuk_utils.c xgetopt.c mfcuk.c
mfcuk_SOURCES = crapto1.c crypto1.c mifare.c nfc-utils.c mfcuk_mifare.c mfcuk_finger.c mfcuk_utils.c mfcuk.c
mfcuk_LDADD = @libnfc_LIBS@
# If system does not have unistd.h, use our own getopt function from xgetopt.c
if ! HAVE_UNISTD
mfcuk_SOURCES += xgetopt.c
endif
# dist_man_MANS = mfcuk.1
This diff is collapsed.
MAIN_FILE=mfcuk_keyrecovery_darkside
LIBNFC=libnfc
CFLAGS=`pkg-config --cflags ${LIBNFC}`
CFLAGS_LIBNFC=`pkg-config --cflags libnfc | cut -d ' ' -f 1`/${LIBNFC}
gcc ./${MAIN_FILE}.c ./mfcuk_mifare.c ./mfcuk_utils.c ./mfcuk_finger.c ./crapto1.c ./crypto1.c ./bin/libnfc.lib ${CFLAGS} ${CFLAGS_LIBNFC} -o ./bin/${MAIN_FILE}_cygwin.exe
......@@ -43,13 +43,19 @@ static void quicksort(uint32_t *const start, uint32_t *const stop)
++it;
else if (*rit > *start)
--rit;
else
*it ^= (*it ^= *rit, *rit ^= *it);
else {
uint32_t x = *it;
*it = *rit;
*rit = x;
}
if (*rit >= *start)
--rit;
if (rit != start)
*rit ^= (*rit ^= *start, *start ^= *rit);
if (rit != start) {
uint32_t x = *it;
*it = *rit;
*rit = x;
}
quicksort(start, rit - 1);
quicksort(rit + 1, stop);
......@@ -322,7 +328,9 @@ uint8_t lfsr_rollback_bit(struct Crypto1State *s, uint32_t in, int fb)
uint8_t ret;
s->odd &= 0xffffff;
s->odd ^= (s->odd ^= s->even, s->even ^= s->odd);
uint32_t x = s->odd;
s->odd = s->even;
s->even = x;
out = s->even & 1;
out ^= LF_POLY_EVEN & (s->even >>= 1);
......
......@@ -56,7 +56,9 @@ uint8_t crypto1_bit(struct Crypto1State *s, uint8_t in, int is_encrypted)
feedin ^= LF_POLY_EVEN & s->even;
s->even = s->even << 1 | parity(feedin);
s->odd ^= (s->odd ^= s->even, s->even ^= s->odd);
uint32_t x = s->odd;
s->odd = s->even;
s->even = x;
return ret;
}
......
+ 561882: 1 : 26
+ 64: 2 : TAG 04 00
+ 10217: 2 : 93 20
+ 64: 5 : TAG 9c 59 9b 32 6c
+ 12313: 9 : 93 70 9c 59 9b 32 6c 6b 30
+ 64: 3 : TAG 08 b6 dd
+ 923318: 4 : 60 00 f5 7b
+ 112: 4 : TAG 82 a4 16 6c
+ 6985: 8 : a1 e4! 58 ce! 6e ea! 41 e0! !crc
+ 64: 4 : TAG 5c! ad f4 39!
+ 811513: 4 : 8e 0e! 5d! b9 !crc
+ 112: 4 : TAG 5a! 92 0d! 85!
+ 6946: 8 : 98! d7 6b! 77 d6 c6 e8 70 !crc
+ 64: 4 : TAG ca 7e! 0b! 63!
+ 670868: 4 : 3e! 70 9c! 8a !crc
+ 112: 4 : TAG 36! 41 24! 79
+ 9505: 8 : 1b! 8c 3a! 48! 83 5a 4a! 27 !crc
+ 64: 4 : TAG 40! 6a! 99! 4b
+ 905612: 4 : c9 7c 64! 13! !crc
+ 112: 4 : TAG b5! ab! 1d! 2b
+ 6936: 8 : 7e! d2 5c! ca! 4b! 50! 88! c4 !crc
+ 64: 4 : TAG bf dd 01 be!
+ 987853: 4 : 56 98 49 d6! !crc
+ 72: 18 : TAG 09 bf! f5! f6! fc! b9! 5e! 51! 07 ac f6 72 f8 73 3b! 1b 73! ad! !crc
+ 94864: 4 : 5c! 7b 24! 02 !crc
+ 72: 18 : TAG a0 1f! 0b! b7 0d! ba c9 e7! fa! 36! 47 d2 a0! 01! 40! 87 ff 95! !crc
+ 94827: 4 : c9 90 dc! a3 !crc
+ 72: 18 : TAG df b8! 7a bc! 17! 99 82! 5c 55 d5! 98! 68 8b f8 e7 89 dc 42! !crc
+ 99081: 4 : 9f! d5 0f! d8! !crc
+ 72: 18 : TAG ca! 40 fa! 34 82 cc 3e de 1f! 7f f7! f0 62! 18! 77! 34 30 07 !crc
+ 93995: 4 : ad 7f! 3e 0c! !crc
+ 72: 18 : TAG f4! 2b 17! 4c a2! 5a 0c! a0! d8 03! 05 cc cc 4c 1f 12! 0c! 78! !crc
+ 94857: 4 : f1! b4 f0 3b! !crc
+ 72: 18 : TAG 8f da ca 17! 42 8e 24 c9! 8e fb! 38! aa! 39 e2! dd dd! a8 a6 !crc
+ 94850: 4 : c4 03! 7b! 9a !crc
+ 72: 18 : TAG 9f! 42! 42 49! cd d1! 3d! fd 8e 8f d3 8d! d5! ca! ef! 15 84 c9! !crc
+ 93961: 4 : 33! 3b! ae 0a! !crc
+ 72: 18 : TAG 74 ed! 58 46! e7 cc 48 d1! 5a 4b b0! 3a! c1 79! 8a! bf! e7! 42 !crc
+ 93193: 4 : f6 ec! 36 91! !crc
+ 72: 18 : TAG 79! 63 89! 21! 24 1e 3e! 03! a8! c3! 9b 95! a1 ad! 6c! 34 52 94 !crc
+ 94866: 4 : ad! 5c! 47 c5! !crc
+ 72: 18 : TAG 68 d4 9d c2! 2b 18 46! f7 e8! 28 ea 03 a4 df d5! 9f 23 00! !crc
+ 93994: 4 : 41 4c! 40! 11 !crc
+ 72: 18 : TAG b1 95 17! 84! ac fc! 31 b8! 02 40 97! ec! 4c 19 6f e9 f0! 8c! !crc
+ 94818: 4 : b8! b5! 5c! 74! !crc
+ 72: 18 : TAG c6 03 b9 92! 7d! eb! 13 8a 56 b7 9c 7c 07 3d! 6a 95! 7e! 44 !crc
# http://www.proxmark.org/forum/post/550/#p550
# UID = 0x9c599b32
# KEY = 0xffffffffffff
# 0x9c599b32 0x82a4166c 0xa1e458ce 0x6eea41e0 0x5cadf439
+ 0: 0: TAG 00!
+ 337281: : 30 00 02 a8
+ 5032: : 50 00 57 cd
+ 9952: : 52
+ 141825: : 30 00 02 a8
+ 5040: : 50 00 57 cd
+ 10528: : 52
+ 7624: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 10656: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 89345: : 30 00 02 a8
+ 72: 0: TAG 04
+ 4976: : 50 00 57 cd
+ 9952: : 52
+ 64: 0: TAG 04 00
+ 7720: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 14120: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 105352: : 30 00 02 a8
+ 72: 0: TAG 04
+ 21952: : 50 00 57 cd
+ 9944: : 52
+ 64: 0: TAG 04 00
+ 14448: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 10736: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 124904: : 30 00 02 a8
+ 72: 0: TAG 04
+ 4968: : 50 00 57 cd
+ 10346: : 52
+ 64: 0: TAG 04 00
+ 7272: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 13240: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 89320: : 30 00 02 a8
+ 72: 0: TAG 04
+ 5000: : 50 00 57 cd
+ 10784: : 52
+ 64: 0: TAG 04 00
+ 7680: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 11560: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 89305: : 30 00 02 a8
+ 72: 0: TAG 04
+ 4960: : 50 00 57 cd
+ 10040: : 52
+ 64: 0: TAG 04 00
+ 43208: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 10696: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 89305: : 30 00 02 a8
+ 72: 0: TAG 04
+ 4984: : 50 00 57 cd
+ 10824: : 52
+ 64: 0: TAG 04 00
+ 9352: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 10680: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 90184: : 30 00 02 a8
+ 72: 0: TAG 04
+ 4984: : 50 00 57 cd
+ 9944: : 52
+ 64: 0: TAG 04 00
+ 102224: : 93 20
+ 64: 0: TAG ca fd ca 13 ee
+ 939902: : 93 70 ca fd ca 13 ee 8e ea
+ 64: 0: TAG 08 b6 dd
+ 752874: : 60 00 f5 7b
+ 112: 0: TAG e9 01 a1 69
+ 10352: : 71 03 4a be f9 2f 51 2f !crc
+ 64: 0: TAG 99 25! ef! 9d!
+ 864094: : dc 9f f9 65 !crc
+ 72: 0: TAG e5 82 07 a2! e1 ea c5 cd 14 85! aa! 97! 58! 17 0e b5 ab! ff !crc
+ 312194: : 4b de 1d e9 !crc
+ 72: 0: TAG 04 0a! 1c! ad 54! 3e ed 03! 60! 82 42 e4 da! 83! 98! 22 14! f2 !crc
+ 290616: : cc 06 39 d7 !crc
+ 72: 0: TAG 0a a3 f1 86 34 8f 9d! 1f! 4d! 7e! f1! 56 8e 9f ee 32! 88 89 !crc
+ 204658: : 80 f4 eb 55 !crc
+ 72: 0: TAG 9d 6e 88 db! fc 88 14! fa af dd 10! cc 74 81! 71 52 fd! d9 !crc
+ 543394: : 26 f0 ea aa !crc
+ 72: 0: TAG d5! a1! ed 8d 73! fe! 3e 94 56 db! 39! ad! dc! ff 9c! a3 f2 24! !crc
+ 299722: : 56 00 9a 4d !crc
+ 72: 0: TAG 58! cf 13 c4 78 50! 0f! b8 73 1c 33! 25 23 12 1e a2! 4a 32! !crc
+ 215834: : db a2 ec 42 !crc
+ 72: 0: TAG 78 3f! 30! 02 64 85 63! fe! 81! 9e 27 70 f7 cc b0 77 ce! 4b !crc
+ 97112: : a5 78 3e 3d !crc
+ 72: 0: TAG ef! fd! 47! 36 e5 c3! c1 96 c5 97 7b! 3d! ce! ab! 6e! 5e bd 8b !crc
+ 87752: : a1 9b 41 09 !crc
+ 72: 0: TAG e5! e1! 28 7d! ee ae! 60 d7 29 96! d7! a1! 6e 4e da! 66! 93 bd! !crc
+ 89104: : 70 ff 99 6c !crc
+ 72: 0: TAG 17 97 04 0a! 92! 66! 7d e7! 62 a8 b5! 56 d4 a1 ab! b8 70 4e! !crc
+ 87928: : 5e 6c 03 09 !crc
+ 72: 0: TAG c5! da 86 a4 a0 24! ab da! f3 d9 95! f3! 2d! 8e! b7! 07 a5! e6 !crc
+ 88434: : 2e 91 6d 54 !crc
+ 72: 0: TAG b4 37 84 6b! fd! c8 71 f9 bf! a1! 96! af! 85! d3 b9! f0! 5b! 57! !crc
+ 87648: : 25 ad 12 4f !crc
+ 72: 0: TAG 7a! 21! 36 81 d1! eb d6! 39! 04! b7 28! 3f! b1 19! 2e b2 b4 23! !crc
+ 87649: : f1 94 78 4b !crc
+ 72: 0: TAG 5f! e4 b5 6c c1 3f ce e4 49 d0! e0! 78 bc 46! 92 0f 7a! e5! !crc
+ 104544: : 01 6b c7 c4 !crc
+ 72: 0: TAG 95! 78! ca 79! ab! 32 47 8d! 1c! 81! 3d! 26 85 5e f3 02 71 3f! !crc
+ 99737: : f6 67 6d 48 !crc
+ 72: 0: TAG 4b! 6e fa 87 51 7d 92 a2! fb! 1b! 1d 62! f8! 7b! 2d! cf! c1 20 !crc
+ 360330: : b8 59 c0 94 !crc
+ 72: 0: TAG b0! 05 25! 4b! 94 8d! 75 62 70! 85 77! e7 a6 1f! 9e! 54 07! d5! !crc
+ 443146: : 7f 3a fa 6a !crc
+ 72: 0: TAG ac c9 81! b4! de ee! e5! 0b! 73! 79! 6c fe! d8 53 00! e1 3c! f0 !crc
+ 198008: : 47 e6 ec f7 !crc
+ 72: 0: TAG a6 b1! 1e! 8e! 86! ee d0 4a 4c ee 34 df 6b e6! da 45! d6! ed !crc
+ 455019: : 49 13 9c fb !crc
+ 72: 0: TAG 31! 1d 7d 21! 22! e3 af! bc ce 6e! 6c! 9f 48 c1! 16! 28! f3! 18 !crc
+ 223097: : ff 43 e9 35 !crc
+ 72: 0: TAG e5! 41 d7 99! 46 8d! ff e7! 1e! 22 32! d0 93! 9e a1 c5 5c! 32! !crc
# http://www.proxmark.org/forum/topic/385/error-with-mifarecrackpy/
# real uid is: ca fd ca 13
# 0xcafdca13 0xe901a169 0x71034abe 0xf92f512f 0x9925ef9d
+2770194: : 26
+ 64: 0: TAG 04 00
+ 1432: : 93 20
+ 64: 0: TAG 5e c2 1c 61 e1
+ 2168: : 93 70 5e c2 1c 61 e1 d5 65
+ 64: 0: TAG 08 b6 dd
+ 31064: : 60 08 bd f7
+ 112: 0: TAG d7 b2 ae bd
+ 1976: : 60 d1 57 7f aa 02 78 ea !crc
+ 599060: : 26
+ 64: 0: TAG 04 00
+ 1424: : 93 20
+ 64: 0: TAG 5e c2 1c 61 e1
+ 2168: : 93 70 5e c2 1c 61 e1 d5 65
+ 64: 0: TAG 08 b6 dd
+ 31160: : 60 08 bd f7
+ 112: 0: TAG cc ec 00 cd
+ 1976: : 86 ae b4 79 69 34 ed 50 !crc
+ 545300: : 26
+ 64: 0: TAG 04 00
+ 1440: : 93 20
+ 64: 0: TAG 5e c2 1c 61 e1
+ 2168: : 93 70 5e c2 1c 61 e1 d5 65
+ 64: 0: TAG 08 b6 dd
+ 31144: : 60 08 bd f7
+ 112: 0: TAG 9c 6a 3c 1e
+ 1976: : 33 aa 1e 4c 8a a1 58 ed !crc
# http://www.proxmark.org/forum/post/2346/#p2346
# 0x5ec21c61 0xd7b2aebd 0x60d1577f 0xaa0278ea 0x26
\ No newline at end of file
......@@ -174,15 +174,7 @@ static inline uint64_t bswap_64(uint64_t x)
#include <err.h>
#include <errno.h>
#ifdef WIN32
#define NOMINMAX
#include "windows.h"
#include "xgetopt.h"
#elif __STDC__
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#endif
// NFC
#include <nfc/nfc.h>
......@@ -214,9 +206,8 @@ static inline uint64_t bswap_64(uint64_t x)
static uint32_t bswap_32_pu8(uint8_t *pu8)
{
uint32_t u32;
memcpy(&u32, pu8, sizeof(uint32_t));
return u32;
// TODO: This function need to be tested on both endianness machine types
return pu8[0] << 24 | pu8[1] << 16 | pu8[2] << 8 | pu8[3];
}
extern mfcuk_finger_tmpl_entry mfcuk_finger_db[];
......@@ -498,7 +489,7 @@ static uint32_t mfcuk_key_recovery_block(nfc_device *pnd, uint32_t uiUID, uint64
if (ptrFoundTagNonceEntry->current_out_of_8 >= MFCUK_DARKSIDE_MAX_LEVELS)
{
//printf("FAILURE - This Nt, {Pfx}, consecutive {Nr}s and {ParBits} combination cannot produce a key-recoverable state\n");
//printf("\tINFO: try changing initial {Nr}, {Ar} and timings of sleep()\n");
//printf("\tINFO: try changing initial {Nr}, {Ar} and timings of sleepmillis()\n");
//printf("{Nr} is not a DEADBEEF.... Need to find BEEF ALIVE!... Trying next one...\n");
ptrFoundTagNonceEntry->spoofNrEnc++;
......@@ -517,7 +508,7 @@ static uint32_t mfcuk_key_recovery_block(nfc_device *pnd, uint32_t uiUID, uint64
if (ptrFoundTagNonceEntry->parBitsCrntCombination[ptrFoundTagNonceEntry->current_out_of_8] >= 0x20)
{
//printf("FAILURE - This consecutive {Nr}s and {ParBits} combination cannot produce all 8 required NACKs and KSs of NACKs\n");
//printf("\tINFO: try changing initial {Nr}, {Ar} and timings of sleep()\n");
//printf("\tINFO: try changing initial {Nr}, {Ar} and timings of sleepmillis()\n");
//printf("{Nr} is not a DEADBEEF.... Need to find BEEF ALIVE!... Trying next one...\n");
ptrFoundTagNonceEntry->spoofNrEnc++;
......@@ -728,10 +719,10 @@ static void print_usage(FILE *fp, const char *prog_name)
fprintf(fp, "\n");
fprintf(fp, "Usage examples:\n");
fprintf(fp, " Recove all keys from all sectors:\n");
fprintf(fp, " Recover all keys from all sectors:\n");
fprintf(fp, " %s -C -R -1\n", prog_name);
fprintf(fp, " Recove the sector #0 key with 250 ms for all delays (delays could give more results): \n");
fprintf(fp, " Recover the sector #0 key with 250 ms for all delays (delays could give more results): \n");
fprintf(fp, " %s -C -R 0 -s 250 -S 250\n", prog_name);
return;
}
......@@ -839,7 +830,7 @@ static bool mfcuk_darkside_select_tag(nfc_device *pnd, int iSleepAtFieldOFF, int
}
// {WPMCC09} 2.4. Tag nonces: "drop the field (for approximately 30us) to discharge all capacitors"
sleep(iSleepAtFieldOFF);
sleepmillis(iSleepAtFieldOFF);
// Let the reader only try once to find a tag
if (0 > nfc_device_set_property_bool(pnd, NP_INFINITE_SELECT, false)) {
......@@ -865,7 +856,7 @@ static bool mfcuk_darkside_select_tag(nfc_device *pnd, int iSleepAtFieldOFF, int
}
// Switch the field back on, and wait for a constant amount of time before authenticating
sleep(iSleepAfterFieldON);
sleepmillis(iSleepAfterFieldON);
// Poll for a ISO14443A (MIFARE) tag
if (0 >= nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &ti_tmp)) {
......
......@@ -45,12 +45,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mfcuk_utils.h"
#include "config.h"
#ifdef __STDC__
struct timeval global_timeout;
#if defined(WIN32)
#include <windows.h>
#elif defined(HAVE_UNISTD_H)
#include <unistd.h>
#else
#error "Unsupported system"
#endif
#include "mfcuk_utils.h"
#include <stdio.h>
/*
http://www.velocityreviews.com/forums/t451319-advice-required-on-my-ascii-to-hex-conversion-c.html
Basically, converting a hex digit into a hex nibble (4 binary digits) algorithm looks like;
......@@ -79,3 +86,22 @@ unsigned char hex2bin(unsigned char h, unsigned char l)
l -= -(l > 9) & 0x27;
return h << 4 | l;
}
void sleepmillis(unsigned int millis)
{
#ifdef WIN32 // If system is Windows, use system's own function if possible to reduce overhead, even if a standard C library is available
Sleep(millis);
#else
usleep(millis * 1000);
#endif
}
void clear_screen()
{
#ifdef WIN32 // On Windows, use "cls" command
system("cls");
#else // Otherwise fall back to TTY control characters
printf("\033[1;1H\033[J");
#endif
}
......@@ -48,35 +48,6 @@
#ifndef _MFCUK_UTILS_H_
#define _MFCUK_UTILS_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#define NOMINMAX
#include "windows.h"
#include "xgetopt.h"
#elif __STDC__
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#endif
// "Portable" sleep(miliseconds)
#ifdef WIN32
#define sleep(x) Sleep(x)
#elif __STDC__
extern struct timeval global_timeout;
#define sleep(x) { global_timeout.tv_usec = 1000 * (x); select(0,NULL,NULL,NULL,&global_timeout); }
#endif
// "Portable" clear_screen() - NOTE: system performance penalty introduced
#ifdef WIN32
#define clear_screen() system("cls")
#elif __STDC__
#define clear_screen() system("sh -c clear")
#endif
/**
* @fn int is_hex(char c)
* @brief Checks if an ASCII character is a valid hexadecimal base digit
......@@ -101,4 +72,23 @@ int is_hex(char c);
*/
unsigned char hex2bin(unsigned char h, unsigned char l);
/**
* @fn void sleepmillis(unsigned int millis)
* @brief Pauses execution for a certain amount of milliseconds
* @param millis Number of milliseconds to sleep
*
* Wrapper for system-dependant sleep function. It pauses execution for a certain amount of milliseconds.
*/
void sleepmillis(unsigned int millis);
/**
* @fn void clear_screen(void);
* @brief Clears output console
*
* Wrapper for system-dependant clear screen function.
* Resets output console, clearing text and resetting character pointer.
*/
void clear_screen(void);
#endif // _MFCUK_UTILS_H_
This diff is collapsed.
+ 561882: 1 : 26
+ 64: 2 : TAG 04 00
+ 10217: 2 : 93 20
+ 64: 5 : TAG 9c 59 9b 32 6c
+ 12313: 9 : 93 70 9c 59 9b 32 6c 6b 30
+ 64: 3 : TAG 08 b6 dd
+ 923318: 4 : 60 00 f5 7b
+ 112: 4 : TAG 82 a4 16 6c
+ 6985: 8 : a1 e4! 58 ce! 6e ea! 41 e0! !crc
+ 64: 4 : TAG 5c! ad f4 39!
+ 811513: 4 : 8e 0e! 5d! b9 !crc
+ 112: 4 : TAG 5a! 92 0d! 85!
+ 6946: 8 : 98! d7 6b! 77 d6 c6 e8 70 !crc
+ 64: 4 : TAG ca 7e! 0b! 63!
+ 670868: 4 : 3e! 70 9c! 8a !crc
+ 112: 4 : TAG 36! 41 24! 79
+ 9505: 8 : 1b! 8c 3a! 48! 83 5a 4a! 27 !crc
+ 64: 4 : TAG 40! 6a! 99! 4b
+ 905612: 4 : c9 7c 64! 13! !crc
+ 112: 4 : TAG b5! ab! 1d! 2b
+ 6936: 8 : 7e! d2 5c! ca! 4b! 50! 88! c4 !crc
+ 64: 4 : TAG bf dd 01 be!
+ 987853: 4 : 56 98 49 d6! !crc
+ 72: 18 : TAG 09 bf! f5! f6! fc! b9! 5e! 51! 07 ac f6 72 f8 73 3b! 1b 73! ad! !crc
+ 94864: 4 : 5c! 7b 24! 02 !crc
+ 72: 18 : TAG a0 1f! 0b! b7 0d! ba c9 e7! fa! 36! 47 d2 a0! 01! 40! 87 ff 95! !crc
+ 94827: 4 : c9 90 dc! a3 !crc
+ 72: 18 : TAG df b8! 7a bc! 17! 99 82! 5c 55 d5! 98! 68 8b f8 e7 89 dc 42! !crc
+ 99081: 4 : 9f! d5 0f! d8! !crc
+ 72: 18 : TAG ca! 40 fa! 34 82 cc 3e de 1f! 7f f7! f0 62! 18! 77! 34 30 07 !crc
+ 93995: 4 : ad 7f! 3e 0c! !crc
+ 72: 18 : TAG f4! 2b 17! 4c a2! 5a 0c! a0! d8 03! 05 cc cc 4c 1f 12! 0c! 78! !crc
+ 94857: 4 : f1! b4 f0 3b! !crc
+ 72: 18 : TAG 8f da ca 17! 42 8e 24 c9! 8e fb! 38! aa! 39 e2! dd dd! a8 a6 !crc
+ 94850: 4 : c4 03! 7b! 9a !crc
+ 72: 18 : TAG 9f! 42! 42 49! cd d1! 3d! fd 8e 8f d3 8d! d5! ca! ef! 15 84 c9! !crc
+ 93961: 4 : 33! 3b! ae 0a! !crc
+ 72: 18 : TAG 74 ed! 58 46! e7 cc 48 d1! 5a 4b b0! 3a! c1 79! 8a! bf! e7! 42 !crc
+ 93193: 4 : f6 ec! 36 91! !crc
+ 72: 18 : TAG 79! 63 89! 21! 24 1e 3e! 03! a8! c3! 9b 95! a1 ad! 6c! 34 52 94 !crc
+ 94866: 4 : ad! 5c! 47 c5! !crc
+ 72: 18 : TAG 68 d4 9d c2! 2b 18 46! f7 e8! 28 ea 03 a4 df d5! 9f 23 00! !crc
+ 93994: 4 : 41 4c! 40! 11 !crc
+ 72: 18 : TAG b1 95 17! 84! ac fc! 31 b8! 02 40 97! ec! 4c 19 6f e9 f0! 8c! !crc
+ 94818: 4 : b8! b5! 5c! 74! !crc
+ 72: 18 : TAG c6 03 b9 92! 7d! eb! 13 8a 56 b7 9c 7c 07 3d! 6a 95! 7e! 44 !crc
# http://www.proxmark.org/forum/post/550/#p550
# UID = 0x9c599b32
# KEY = 0xffffffffffff
# 0x9c599b32 0x82a4166c 0xa1e458ce 0x6eea41e0 0x5cadf439
......@@ -15,9 +15,15 @@
#ifndef XGETOPT_H
#define XGETOPT_H
#if HAVE_UNISTD_H
#include <unistd.h>
#else
extern int optind, opterr;
extern char *optarg;
int getopt(int argc, char *argv[], char *optstring);
#endif
#endif //XGETOPT_H
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment