sort mfc tools

This commit is contained in:
Philippe Teuwen 2024-08-01 16:43:25 +02:00
commit c47578c048
49 changed files with 143 additions and 175 deletions

11
.gitignore vendored
View file

@ -74,21 +74,10 @@ flasher
lua
luac
tools/fpga_compress/fpga_compress
tools/mfkey/mfkey32
tools/mfkey/mfkey64
tools/mfkey/staticnested
tools/nonce2key/nonce2key
tools/cryptorf/cm
tools/cryptorf/sm
tools/cryptorf/sma
tools/cryptorf/sma_multi
tools/mf_fudan_rf08s/rf08s_nested
tools/mf_fudan_rf08s/rf08s_nested_known
tools/mf_fudan_rf08s/rf08s_nested_known_collision
tools/mf_fudan_rf08s/rf08s_nested_known_match
tools/mf_fudan_rf08s/keys*
tools/mf_nonce_brute/mf_nonce_brute
tools/mf_nonce_brute/mf_trace_brute
tools/jtag_openocd/openocd_configuration
tools/mfd_aes_brute/mfd_aes_brute
tools/mfd_aes_brute/mfd_multi_brute

View file

@ -29,7 +29,7 @@ ifneq (,$(DESTDIR))
endif
endif
all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% mfd_aes_brute/% fpga_compress/% cryptorf/%
all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfc_card_only/% mfc_card_reader/% mfd_aes_brute/% fpga_compress/% cryptorf/%
# hitag2crack toolsuite is not yet integrated in "all", it must be called explicitly: "make hitag2crack"
#all clean install uninstall check: %: hitag2crack/%
@ -112,13 +112,10 @@ endif
cryptorf/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
mfkey/check: FORCE
mfc_card_only/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
nonce2key/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
mf_nonce_brute/check: FORCE
mfc_card_reader/check: FORCE
$(info [*] CHECK $(patsubst %/check,%,$@))
$(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
mfd_aes_brute/check: FORCE
@ -151,15 +148,12 @@ check: common/check
cryptorf/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/cryptorf $(patsubst cryptorf/%,%,$@) DESTDIR=$(MYDESTDIR)
mfkey/%: FORCE
mfc_card_only/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@) DESTDIR=$(MYDESTDIR)
nonce2key/%: FORCE
$(Q)$(MAKE) --no-print-directory -C tools/mfc/card_only $(patsubst mfc_card_only/%,%,$@) DESTDIR=$(MYDESTDIR)
mfc_card_reader/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@) DESTDIR=$(MYDESTDIR)
mf_nonce_brute/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/mf_nonce_brute $(patsubst mf_nonce_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
$(Q)$(MAKE) --no-print-directory -C tools/mfc/card_reader $(patsubst mfc_card_reader/%,%,$@) DESTDIR=$(MYDESTDIR)
mfd_aes_brute/%: FORCE
$(info [*] MAKE $@)
$(Q)$(MAKE) --no-print-directory -C tools/mfd_aes_brute $(patsubst mfd_aes_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
@ -185,7 +179,7 @@ hitag2crack/%: FORCE
$(Q)$(MAKE) --no-print-directory -C tools/hitag2crack $(patsubst hitag2crack/%,%,$@) DESTDIR=$(MYDESTDIR)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute mfd_aes_brute hitag2crack style miscchecks release FORCE udev accessrights cleanifplatformchanged
.PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfc_card_only mfc_card_reader mfd_aes_brute hitag2crack style miscchecks release FORCE udev accessrights cleanifplatformchanged
help:
@echo "Multi-OS Makefile"
@ -203,9 +197,8 @@ help:
@echo
@echo "+ client - Make only the OS-specific host client"
@echo "+ cryptorf - Make tools/cryptorf"
@echo "+ mfkey - Make tools/mfkey"
@echo "+ nonce2key - Make tools/nonce2key"
@echo "+ mf_nonce_brute - Make tools/mf_nonce_brute"
@echo "+ mfc_card_only - Make tools/mfc/card_only"
@echo "+ mfc_card_reader - Make tools/mfc/card_reader"
@echo "+ mfd_aes_brute - Make tools/mfd_aes_brute"
@echo "+ hitag2crack - Make tools/hitag2crack"
@echo "+ fpga_compress - Make tools/fpga_compress"
@ -245,11 +238,9 @@ recovery: recovery/all
cryptorf: cryptorf/all
mfkey: mfkey/all
mfc_card_only: mfc_card_only/all
nonce2key: nonce2key/all
mf_nonce_brute: mf_nonce_brute/all
mfc_card_reader: mfc_card_reader/all
mfd_aes_brute: mfd_aes_brute/all

View file

@ -1364,7 +1364,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
, ar_nr_resp[i].sector
, (ar_nr_resp[i].keytype == AUTHKEYA) ? "key A" : "key B"
);
Dbprintf("../tools/mfkey/mfkey32 %08x %08x %08x %08x %08x %08x",
Dbprintf("../tools/mfc_card_reader/mfkey32 %08x %08x %08x %08x %08x %08x",
ar_nr_resp[i].cuid, //UID
ar_nr_resp[i].nonce, //NT
ar_nr_resp[i].nr, //NR1
@ -1383,7 +1383,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
, ar_nr_resp[i].sector
, (ar_nr_resp[i].keytype == AUTHKEYB) ? "key A" : "key B"
);
Dbprintf("../tools/mfkey/mfkey32v2 %08x %08x %08x %08x %08x %08x %08x",
Dbprintf("../tools/mfc_card_reader/mfkey32v2 %08x %08x %08x %08x %08x %08x %08x",
ar_nr_resp[i].cuid, //UID
ar_nr_resp[i].nonce, //NT
ar_nr_resp[i].nr, //NR1

View file

@ -2235,7 +2235,7 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, uint8_t *parity, bool isRes
mf_get_paritybinstr(sat, AuthData.at_enc, AuthData.at_enc_par);
PrintAndLogEx(NORMAL, "Nested authentication detected!");
PrintAndLogEx(NORMAL, "tools/mf_nonce_brute/mf_nonce_brute %x %x %s %x %x %s %x %s %s\n"
PrintAndLogEx(NORMAL, "tools/mfc/card_reader/mf_nonce_brute %x %x %s %x %x %s %x %s %s\n"
, AuthData.uid
, AuthData.nt_enc
, snt

View file

@ -1,33 +0,0 @@
MYSRCPATHS = ../../common ../../common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c
MYINCLUDES = -I../../include -I../../common
MYCFLAGS = -O3
MYDEFS =
BINS = rf08s_nested rf08s_nested_known rf08s_nested_known_collision rf08s_nested_known_match
INSTALLTOOLS = $(BINS)
include ../../Makefile.host
# rf08s_nested.c needs pthread support. Older glibc needs it externally
ifneq ($(SKIPPTHREAD),1)
MYLDLIBS += -lpthread
endif
# checking platform can be done only after Makefile.host
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
CFLAGS += -D_ISOC99_SOURCE
endif
# macOS doesn't like these compiler params
ifneq ($(platform),Darwin)
MYCFLAGS += --param max-completely-peeled-insns=1000 --param max-completely-peel-times=10000
endif
rf08s_nested : $(OBJDIR)/rf08s_nested.o $(MYOBJS)
rf08s_nested_known : $(OBJDIR)/rf08s_nested_known.o $(MYOBJS)
rf08s_nested_known_collision : $(OBJDIR)/rf08s_nested_known_collision.o $(MYOBJS)
rf08s_nested_known_match : $(OBJDIR)/rf08s_nested_known_match.o $(MYOBJS)

View file

@ -1,25 +0,0 @@
MYSRCPATHS = ../../common ../../common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c iso14443crc.c sleep.c util_posix.c
MYINCLUDES = -I../../include -I../../common
MYCFLAGS = -O3
MYDEFS =
MYLDLIBS =
ifneq ($(SKIPPTHREAD),1)
MYLDLIBS += -lpthread
endif
BINS = mf_nonce_brute mf_trace_brute
INSTALLTOOLS = $(BINS)
include ../../Makefile.host
# checking platform can be done only after Makefile.host
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
CFLAGS += -D_ISOC99_SOURCE
endif
mf_nonce_brute : $(OBJDIR)/mf_nonce_brute.o $(MYOBJS)
mf_trace_brute : $(OBJDIR)/mf_trace_brute.o $(MYOBJS)

13
tools/mfc/card_only/.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
nonce2key
staticnested_0nt
staticnested_1nt
staticnested_2nt
staticnested_2x1nt_rf08s_1key
staticnested_2x1nt_rf08s
nonce2key.exe
staticnested_0nt.exe
staticnested_1nt.exe
staticnested_2nt.exe
staticnested_2x1nt_rf08s_1key.exe
staticnested_2x1nt_rf08s.exe
keys*.dic

View file

@ -0,0 +1,36 @@
ROOTPATH = ../../..
MYSRCPATHS = $(ROOTPATH)/common $(ROOTPATH)/common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c nested_util.c
MYINCLUDES = -I$(ROOTPATH)/include -I$(ROOTPATH)/common
MYCFLAGS = -O3
MYDEFS =
BINS = nonce2key staticnested_0nt staticnested_1nt staticnested_2nt staticnested_2x1nt_rf08s_1key staticnested_2x1nt_rf08s
INSTALLTOOLS = $(BINS)
include $(ROOTPATH)/Makefile.host
# nested_util.c needs pthread support. Older glibc needs it externally
ifneq ($(SKIPPTHREAD),1)
MYLDLIBS += -lpthread
endif
# checking platform can be done only after Makefile.host
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
CFLAGS += -D_ISOC99_SOURCE
endif
# macOS doesn't like these compiler params
ifneq ($(platform),Darwin)
MYCFLAGS += --param max-completely-peeled-insns=1000 --param max-completely-peel-times=10000
endif
nonce2key : $(OBJDIR)/nonce2key.o $(MYOBJS)
staticnested_0nt : $(OBJDIR)/staticnested_0nt.o $(MYOBJS)
staticnested_1nt : $(OBJDIR)/staticnested_1nt.o $(MYOBJS)
staticnested_2nt : $(OBJDIR)/staticnested_2nt.o $(MYOBJS)
staticnested_2x1nt_rf08s_1key : $(OBJDIR)/staticnested_2x1nt_rf08s_1key.o $(MYOBJS)
staticnested_2x1nt_rf08s : $(OBJDIR)/staticnested_2x1nt_rf08s.o $(MYOBJS)

View file

@ -13,7 +13,8 @@ int main(const int argc, const char *argv[]) {
nr = rr = 0;
if (argc < 5) {
printf("\nsyntax: %s <uid> <nt> <par> <ks>\n\n", argv[0]);
printf("\nsyntax: %s <uid> <nt> <par> <ks>\n", argv[0]);
printf("example: %s 92c0456b 73294ab7 a3fbfb537343eb7b 070608090e060a02\n\n", argv[0]);
return 1;
}
sscanf(argv[1], "%08x", &uid);

View file

@ -0,0 +1,9 @@
./staticnested_2nt 461dce03 7eef3586 ffb02eda 322bc14d ffc875ca;
./staticnested_2nt 461dce03 7eef3586 7f21594f 322bc14d 7f815fba;
./staticnested_2nt 461dce03 7eef3586 ff315fe7 322bc14d ffc1364d;
./staticnested_2nt 461dce03 7eef3586 d742a617 322bc14d d7f2f337;
./staticnested_2nt 461dce03 7eef3586 5e3e037c 322bc14d 5ef705c2;
./staticnested_2nt 461dce03 7eef3586 5fcaebc6 322bc14d 5f72de17;
./staticnested_2nt 461dce03 7eef3586 3fbcfb30 322bc14d 3fe4c47c;
./staticnested_2nt 461dce03 7eef3586 1fb6b496 322bc14d 1f4eebdd;
./staticnested_2nt 461dce03 7eef3586 7fa28c7e 322bc14d 7f62b3d6;

View file

@ -8,7 +8,7 @@
// * Use backdoor on the targeted sector to get the clear static nested nT for keyA and for keyB
// * Generate 2 lists of key candidates based on clear and encrypted nT
// * Search couples of keyA/keyB satisfying some obscure relationship
// * Use the resulting dictionary to bruteforce the keyA (and rf08s_nested_known_match for keyB)
// * Use the resulting dictionary to bruteforce the keyA (and staticnested_2x1nt_rf08s_1key for keyB)
//
// Doegox, 2024
@ -69,7 +69,7 @@ static uint16_t compute_seednt16_nt32(uint32_t nt32, uint64_t key) {
int main(int argc, char *const argv[]) {
if (argc != 3) {
printf("Usage:\n %s keys_<uid:08x>_<sector:02>_<nt1:08x>.dic keys_<uid:08x>_<sector:02>_<nt2:08x>.dic\n"
" where both dict files are produced by rf08s_nested_known *for the same UID and same sector*\n",
" where both dict files are produced by staticnested_1nt *for the same UID and same sector*\n",
argv[0]);
return 1;
}

10
tools/mfc/card_reader/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
mfkey32
mfkey32v2
mfkey64
mf_nonce_brute
mf_trace_brute
mfkey32.exe
mfkey32v2.exe
mfkey64.exe
mf_nonce_brute.exe
mf_trace_brute.exe

View file

@ -1,19 +1,19 @@
MYSRCPATHS = ../../common ../../common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c nested_util.c
MYINCLUDES = -I../../include -I../../common
ROOTPATH = ../../..
MYSRCPATHS = $(ROOTPATH)/common $(ROOTPATH)/common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c iso14443crc.c sleep.c util_posix.c
MYINCLUDES = -I$(ROOTPATH)/include -I$(ROOTPATH)/common
MYCFLAGS = -O3
MYDEFS =
BINS = mfkey32 mfkey32v2 mfkey64 staticnested
INSTALLTOOLS = $(BINS)
include ../../Makefile.host
# nested_util.c needs pthread support. Older glibc needs it externally
MYLDLIBS =
ifneq ($(SKIPPTHREAD),1)
MYLDLIBS += -lpthread
endif
BINS = mfkey32 mfkey32v2 mfkey64 mf_nonce_brute mf_trace_brute
INSTALLTOOLS = $(BINS)
include $(ROOTPATH)/Makefile.host
# checking platform can be done only after Makefile.host
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
@ -29,4 +29,5 @@ endif
mfkey32 : $(OBJDIR)/mfkey32.o $(MYOBJS)
mfkey32v2 : $(OBJDIR)/mfkey32v2.o $(MYOBJS)
mfkey64 : $(OBJDIR)/mfkey64.o $(MYOBJS)
staticnested : $(OBJDIR)/staticnested.o $(MYOBJS)
mf_nonce_brute : $(OBJDIR)/mf_nonce_brute.o $(MYOBJS)
mf_trace_brute : $(OBJDIR)/mf_trace_brute.o $(MYOBJS)

View file

@ -1,14 +1,14 @@
mf_nonce_brute
==============
Nested auntenticated sector key recovery tool
Nested autenticated sector key recovery tool
-----------------------------------------------
Compatible tags:
* Mifare Classic 1k (4k)
* Mifare Plus in SL1 mode
To recover keys to nested auntenticated sectors you need a reader-card communication log. To get it use
To recover keys to nested autenticated sectors you need a reader-card communication log. To get it use
hardware tools that able to sniff communication (for example Proxmark3 or HydraNFC).
This enhanced version:

View file

@ -1,4 +1,5 @@
:: TRACE
## Sample trace
```
+ 50422: : 26
+ 64: 0: TAG 04 00
+ 944: : 93 20
@ -9,32 +10,38 @@
+ 113: 0: TAG 82 a4 16 6c
+ 1287: : a1 e4 58 ce 6e ea 41 e0
+ 64: 0: TAG 5c ad f4 39
```
Usage with sample trace:
`./mfkey64 9C599B32 82A4166C A1E458CE 6EEA41E0 5CADF439`
:: Sample of trace above,
./mfkey64 9c599b32 82a4166c a1e458ce 6eea41e0 5cadf439
## Other examples
-----------------------------------------------------------------------------------------------------
:: For mfkey32, you want to get two different NR_0/NR_1 values.
For mfkey32, you want to get two different NR_0/NR_1 values.
:: <uid> <nt> <nr_0> <ar_0> <nr_1> <ar_1>
```
# <uid> <nt> <nr_0> <ar_0> <nr_1> <ar_1>
./mfkey32 52B0F519 5417D1F8 4D545EA7 E15AC8C2 DAC1A7F4 5AE5C37F
```
:: For mfkey32v2 (moebius), you want to get two different NT/NT1 values. (like in the SIM commands)
:: <uid> <nt> <nr_0> <ar_0> <nt1> <nr_1> <ar_1>
For mfkey32v2 (moebius), you want to get two different NT/NT1 values. (like in the SIM commands)
```
# <uid> <nt> <nr_0> <ar_0> <nt1> <nr_1> <ar_1>
./mfkey32v2 12345678 1AD8DF2B 1D316024 620EF048 30D6CB07 C52077E2 837AC61A
./mfkey32v2 52B0F519 5417D1F8 4D545EA7 E15AC8C2 A1BA88C6 DAC1A7F4 5AE5C37F
```
:: for mfkey64, you want to have the AT response from tag.
:: <uid> <nt> <nr> <ar> <at>
For mfkey64, you want to have the AT response from tag.
```
# <uid> <nt> <nr> <ar> <at>
./mfkey64 9C599B32 82A4166C A1E458CE 6EEA41E0 5CADF439
./mfkey64 52B0F519 5417D1F8 4D545EA7 E15AC8C2 5056E41B
```
-----------------------------------------------------------------------------------------------------
New functionality from @zhovner,
-----------------------------------------------------------------------------------------------------
### Communication decryption
A new functionality from @zhovner
Example: given the following trace
```
RDR 26
TAG 04 00
RDR 93 20
@ -54,10 +61,11 @@ TAG 49 e2 c9 de f4 86 8d 17 77 67 0e 58 4c 27 23 02 86 f4
RDR fb dc d7 c1
TAG 4a bd 96 4b 07 d3 56 3a a0 66 ed 0a 2e ac 7f 63 12 bf
RDR 9f 91 49 ea
```
`./mfkey64 14579f69 ce844261 f8049ccb 0525c84f 9431cc40 7093df99 9972428ce2e8523f456b99c831e769dced09 8ca6827b ab797fd369e8b93a86776b40dae3ef686efd c3c381ba 49e2c9def4868d1777670e584c27230286f4 fbdcd7c1 4abd964b07d3563aa066ed0a2eac7f6312bf 9f9149ea`
./mfkey64 14579f69 ce844261 f8049ccb 0525c84f 9431cc40 7093df99 9972428ce2e8523f456b99c831e769dced09 8ca6827b ab797fd369e8b93a86776b40dae3ef686efd c3c381ba 49e2c9def4868d1777670e584c27230286f4 fbdcd7c1 4abd964b07d3563aa066ed0a2eac7f6312bf 9f9149ea
```
Recovering key for:
uid: 14579f69
nt: ce844261
@ -94,3 +102,4 @@ Decrypted communication:
{dec8}: 61148834
Found Key: [091e639cb715]
```

0
tools/pm3_gen_mfsim.sh → tools/mfc/pm3_gen_mfsim.sh Normal file → Executable file
View file

View file

@ -1,7 +0,0 @@
mfkey32
mfkey32v2
mfkey64
mfkey32.exe
mfkey32v2.exe
mfkey64.exe

View file

@ -1,9 +0,0 @@
./staticnested 461dce03 7eef3586 ffb02eda 322bc14d ffc875ca;
./staticnested 461dce03 7eef3586 7f21594f 322bc14d 7f815fba;
./staticnested 461dce03 7eef3586 ff315fe7 322bc14d ffc1364d;
./staticnested 461dce03 7eef3586 d742a617 322bc14d d7f2f337;
./staticnested 461dce03 7eef3586 5e3e037c 322bc14d 5ef705c2;
./staticnested 461dce03 7eef3586 5fcaebc6 322bc14d 5f72de17;
./staticnested 461dce03 7eef3586 3fbcfb30 322bc14d 3fe4c47c;
./staticnested 461dce03 7eef3586 1fb6b496 322bc14d 1f4eebdd;
./staticnested 461dce03 7eef3586 7fa28c7e 322bc14d 7f62b3d6;

View file

@ -1,19 +0,0 @@
MYSRCPATHS = ../../common ../../common/crapto1
MYSRCS = crypto1.c crapto1.c bucketsort.c
MYINCLUDES = -I../../include -I../../common
MYCFLAGS =
MYDEFS =
BINS = nonce2key
INSTALLTOOLS = $(BINS)
include ../../Makefile.host
# checking platform can be done only after Makefile.host
ifneq (,$(findstring MINGW,$(platform)))
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
CFLAGS += -D_ISOC99_SOURCE
endif
nonce2key : $(OBJDIR)/nonce2key.o $(MYOBJS)

View file

@ -1,7 +0,0 @@
To test the nonce2key tool.
:: tip
You can use the output from "hf mf mifare" to use with this tool.
:: sample
./nonce2key 92c0456b 73294ab7 a3fbfb537343eb7b 070608090e060a02

0
tools/pm3_tears_for_fears.py Normal file → Executable file
View file

View file

@ -10,6 +10,7 @@ SLOWTESTS=false
OPENCLTESTS=false
TESTALL=true
TESTMFKEY=false
TESTSTATICNESTED=false
TESTNONCE2KEY=false
TESTMFNONCEBRUTE=false
TESTMFDAESBRUTE=false
@ -28,7 +29,7 @@ while (( "$#" )); do
case "$1" in
-h|--help)
echo """
Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|mfd_aes_brute|cryptorf|fpga_compress|bootrom|armsrc|client|recovery|common]
Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|staticnested|mfd_aes_brute|cryptorf|fpga_compress|bootrom|armsrc|client|recovery|common]
--long: Enable slow tests
--opencl: Enable tests requiring OpenCL (preferably a Nvidia GPU)
--clientbin ...: Specify path to proxmark3 binary to test
@ -73,6 +74,11 @@ Usage: $0 [--long] [--opencl] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|
TESTMFNONCEBRUTE=true
shift
;;
staticnested)
TESTALL=false
TESTSTATICNESTED=true
shift
;;
mfd_aes_brute)
TESTALL=false
TESTMFDAESBRUTE=true
@ -262,7 +268,7 @@ while true; do
if ! CheckExecute "xorcheck test" "tools/xorcheck.py 04 00 80 64 ba" "final LRC XOR byte value: 5A"; then break; fi
if ! CheckExecute "findbits test" "tools/findbits.py 73 0110010101110011" "Match at bit 9: 011001010"; then break; fi
if ! CheckExecute "findbits_test test" "tools/findbits_test.py 2>&1" "OK"; then break; fi
if ! CheckExecute "pm3_eml_mfd test" "tools/pm3_eml_mfd_test.py 2>&1" "OK"; then break; fi
if ! CheckExecute "pm3_eml_mfd test" "tools/mfc/pm3_eml_mfd_test.py 2>&1" "OK"; then break; fi
if ! CheckExecute "recover_pk test" "tools/recover_pk.py selftests 2>&1" "Tests:.*\(.*ok.*"; then break; fi
if ! CheckExecute "mkversion create test" "tools/mkversion.sh --short" 'Iceman/'; then break; fi
fi
@ -284,23 +290,26 @@ while true; do
if ! CheckFileExist "fpgacompress exists" "$FPGACPMPRESSBIN"; then break; fi
fi
if $TESTALL || $TESTMFKEY; then
echo -e "\n${C_BLUE}Testing mfkey:${C_NC} ${MFKEY32V2BIN:=./tools/mfkey/mfkey32v2} ${MFKEY64BIN:=./tools/mfkey/mfkey64} ${STATICNESTEDBIN:=./tools/mfkey/staticnested}"
echo -e "\n${C_BLUE}Testing mfkey:${C_NC} ${MFKEY32V2BIN:=./tools/mfc/card_reader/mfkey32v2} ${MFKEY64BIN:=./tools/mfc/card_reader/mfkey64}"
if ! CheckFileExist "mfkey32v2 exists" "$MFKEY32V2BIN"; then break; fi
if ! CheckFileExist "mfkey64 exists" "$MFKEY64BIN"; then break; fi
if ! CheckFileExist "staticnested exists" "$STATICNESTEDBIN"; then break; fi
# Need a decent example for mfkey32...
if ! CheckExecute "mfkey32v2 test" "$MFKEY32V2BIN 12345678 1AD8DF2B 1D316024 620EF048 30D6CB07 C52077E2 837AC61A" "Found Key: \[a0a1a2a3a4a5\]"; then break; fi
if ! CheckExecute "mfkey64 test" "$MFKEY64BIN 9c599b32 82a4166c a1e458ce 6eea41e0 5cadf439" "Found Key: \[ffffffffffff\]"; then break; fi
if ! CheckExecute "mfkey64 long trace test" "$MFKEY64BIN 14579f69 ce844261 f8049ccb 0525c84f 9431cc40 7093df99 9972428ce2e8523f456b99c831e769dced09 8ca6827b ab797fd369e8b93a86776b40dae3ef686efd c3c381ba 49e2c9def4868d1777670e584c27230286f4 fbdcd7c1 4abd964b07d3563aa066ed0a2eac7f6312bf 9f9149ea" "Found Key: \[091e639cb715\]"; then break; fi
if ! CheckExecute "staticnested test" "$STATICNESTEDBIN 461dce03 7eef3586 7fa28c7e 322bc14d 7f62b3d6" "\[ 2 \].*ffffffffff40.*"; then break; fi
fi
if $TESTALL || $TESTSTATICNESTED; then
echo -e "\n${C_BLUE}Testing staticnested:${C_NC} ${STATICNESTED2NTBIN:=./tools/mfc/card_only/staticnested_2nt}"
if ! CheckFileExist "staticnested_2nt exists" "$STATICNESTED2NTBIN"; then break; fi
if ! CheckExecute "staticnested_2nt test" "$STATICNESTED2NTBIN 461dce03 7eef3586 7fa28c7e 322bc14d 7f62b3d6" "\[ 2 \].*ffffffffff40.*"; then break; fi
fi
if $TESTALL || $TESTNONCE2KEY; then
echo -e "\n${C_BLUE}Testing nonce2key:${C_NC} ${NONCE2KEYBIN:=./tools/nonce2key/nonce2key}"
echo -e "\n${C_BLUE}Testing nonce2key:${C_NC} ${NONCE2KEYBIN:=./tools/mfc/card_only/nonce2key}"
if ! CheckFileExist "nonce2key exists" "$NONCE2KEYBIN"; then break; fi
if ! CheckExecute "nonce2key test" "$NONCE2KEYBIN e9cadd9c a8bf4a12 a020a8285858b090 050f010607060e07 5693be6c00000000" "key recovered: fc00018778f7"; then break; fi
fi
if $TESTALL || $TESTMFNONCEBRUTE; then
echo -e "\n${C_BLUE}Testing mf_nonce_brute:${C_NC} ${MFNONCEBRUTEBIN:=./tools/mf_nonce_brute/mf_nonce_brute}"
echo -e "\n${C_BLUE}Testing mf_nonce_brute:${C_NC} ${MFNONCEBRUTEBIN:=./tools/mfc/card_reader/mf_nonce_brute}"
if ! CheckFileExist "mf_nonce_brute exists" "$MFNONCEBRUTEBIN"; then break; fi
if ! CheckExecute slow "mf_nonce_brute test 1/2" "$MFNONCEBRUTEBIN 9c599b32 5a920d85 1011 98d76b77 d6c6e870 0000 ca7e0b63 0111 3e709c8a" "Key found \[.*ffffffffffff.*\]"; then break; fi
if ! CheckExecute slow "mf_nonce_brute test 2/2" "$MFNONCEBRUTEBIN 96519578 d7e3c6ac 0011 cd311951 9da49e49 0010 2bb22e00 0100 a4f7f398" "Key found \[.*3b7e4fd575ad.*\]"; then break; fi