From bbc10bce7d8809b93197de235496dd90f6629c9b Mon Sep 17 00:00:00 2001 From: merlokk Date: Tue, 17 Oct 2017 17:19:48 +0300 Subject: [PATCH 1/2] hf mf nested added 14a timeout for check keys --- client/cmdhfmf.c | 52 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 12fb0b78..83cd729c 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -524,7 +524,35 @@ int CmdHF14AMfRestore(const char *Cmd) return 0; } +//---------------------------------------------- +// Nested +//---------------------------------------------- # define NESTED_KEY_COUNT 15 + +static void parseParamTDS(const char *Cmd, const uint8_t indx, bool *paramT, bool *paramD, uint8_t *timeout) { + char ctmp3[3] = {0}; + int len = param_getlength(Cmd, indx); + if (len > 0 && len < 4){ + param_getstr(Cmd, indx, ctmp3); + + *paramT |= (ctmp3[0] == 't' || ctmp3[0] == 'T'); + *paramD |= (ctmp3[0] == 'd' || ctmp3[0] == 'D'); + bool paramS1 = *paramT || *paramD; + + // slow and very slow + if (ctmp3[0] == 's' || ctmp3[0] == 'S' || ctmp3[1] == 's' || ctmp3[1] == 'S') { + *timeout = 11; // slow + + if (!paramS1 && (ctmp3[1] == 's' || ctmp3[1] == 'S')) { + *timeout = 53; // very slow + } + if (paramS1 && (ctmp3[2] == 's' || ctmp3[2] == 'S')) { + *timeout = 53; // very slow + } + } + } +} + int CmdHF14AMfNested(const char *Cmd) { int i, j, res, iterations; @@ -537,6 +565,8 @@ int CmdHF14AMfNested(const char *Cmd) uint8_t key[6] = {0, 0, 0, 0, 0, 0}; uint8_t keyBlock[NESTED_KEY_COUNT * 6]; uint64_t key64 = 0; + // timeout in units. (ms * 106)/10 or us*0.0106 + uint8_t btimeout14a = MF_CHKKEYS_DEFTIMEOUT; // fast by default bool autosearchKey = false; @@ -580,11 +610,10 @@ int CmdHF14AMfNested(const char *Cmd) if (param_getchar(Cmd, 1) == '*') { autosearchKey = true; - ctmp = param_getchar(Cmd, 2); - transferToEml |= (ctmp == 't' || ctmp == 'T'); - createDumpFile |= (ctmp == 'd' || ctmp == 'D'); + parseParamTDS(Cmd, 2, &transferToEml, &createDumpFile, &btimeout14a); - PrintAndLog("--nested. sectors:%2d, block no:*, eml:%c, dmp=%c ", SectorsCnt, transferToEml?'y':'n', createDumpFile?'y':'n'); + PrintAndLog("--nested. sectors:%2d, block no:*, eml:%c, dmp=%c checktimeout=%d us", + SectorsCnt, transferToEml?'y':'n', createDumpFile?'y':'n', (int)btimeout14a * 10000 / 106); } else { blockNo = param_get8(Cmd, 1); @@ -621,16 +650,13 @@ int CmdHF14AMfNested(const char *Cmd) if (ctmp != 'A' && ctmp != 'a') trgKeyType = 1; - ctmp = param_getchar(Cmd, 6); - transferToEml |= (ctmp == 't' || ctmp == 'T'); - createDumpFile |= (ctmp == 'd' || ctmp == 'D'); + parseParamTDS(Cmd, 6, &transferToEml, &createDumpFile, &btimeout14a); } else { - ctmp = param_getchar(Cmd, 4); - transferToEml |= (ctmp == 't' || ctmp == 'T'); - createDumpFile |= (ctmp == 'd' || ctmp == 'D'); + parseParamTDS(Cmd, 4, &transferToEml, &createDumpFile, &btimeout14a); } - PrintAndLog("--nested. sectors:%2d, block no:%3d, key type:%c, eml:%c, dmp=%c ", SectorsCnt, blockNo, keyType?'B':'A', transferToEml?'y':'n', createDumpFile?'y':'n'); + PrintAndLog("--nested. sectors:%2d, block no:%3d, key type:%c, eml:%c, dmp=%c checktimeout=%d us", + SectorsCnt, blockNo, keyType?'B':'A', transferToEml?'y':'n', createDumpFile?'y':'n', (int)btimeout14a * 10000 / 106); } // one-sector nested @@ -684,7 +710,7 @@ int CmdHF14AMfNested(const char *Cmd) } PrintAndLog("Testing known keys. Sector count=%d", SectorsCnt); - mfCheckKeysSec(SectorsCnt, 2, MF_CHKKEYS_DEFTIMEOUT, true, NESTED_KEY_COUNT, keyBlock, e_sector); + mfCheckKeysSec(SectorsCnt, 2, btimeout14a, true, NESTED_KEY_COUNT, keyBlock, e_sector); // get known key from array bool keyFound = false; @@ -744,7 +770,7 @@ int CmdHF14AMfNested(const char *Cmd) e_sector[sectorNo].Key[trgKeyType] = key64; // try to check this key as a key to the other sectors - mfCheckKeysSec(SectorsCnt, 2, MF_CHKKEYS_DEFTIMEOUT, true, 1, keyBlock, e_sector); + mfCheckKeysSec(SectorsCnt, 2, btimeout14a, true, 1, keyBlock, e_sector); } } } From a627d94afb954396793846ab12e9f3eaad241b2d Mon Sep 17 00:00:00 2001 From: merlokk Date: Tue, 17 Oct 2017 17:28:23 +0300 Subject: [PATCH 2/2] hf mf nested added doc to and --- client/cmdhfmf.c | 7 +- proxmark3.config | 2 + proxmark3.creator | 1 + proxmark3.files | 325 +++++++++++++++++++++++++++++++++++++++++++++ proxmark3.includes | 14 ++ 5 files changed, 347 insertions(+), 2 deletions(-) create mode 100644 proxmark3.config create mode 100644 proxmark3.creator create mode 100644 proxmark3.files create mode 100644 proxmark3.includes diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 83cd729c..71746b7b 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -580,20 +580,23 @@ int CmdHF14AMfNested(const char *Cmd) if (strlen(Cmd)<3) { PrintAndLog("Usage:"); - PrintAndLog(" all sectors: hf mf nested [t,d]"); - PrintAndLog(" all sectors autosearch key: hf mf nested * [t,d]"); + PrintAndLog(" all sectors: hf mf nested [t|d|s|ss]"); + PrintAndLog(" all sectors autosearch key: hf mf nested * [t|d|s|ss]"); PrintAndLog(" one sector: hf mf nested o "); PrintAndLog(" [t]"); PrintAndLog(" "); PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, - 1K"); PrintAndLog("t - transfer keys to emulator memory"); PrintAndLog("d - write keys to binary file dumpkeys.bin"); + PrintAndLog("s - Slow (1ms) check keys (required by some non standard cards)"); + PrintAndLog("ss - Very slow (5ms) check keys"); PrintAndLog(" "); PrintAndLog(" sample1: hf mf nested 1 0 A FFFFFFFFFFFF "); PrintAndLog(" sample2: hf mf nested 1 0 A FFFFFFFFFFFF t "); PrintAndLog(" sample3: hf mf nested 1 0 A FFFFFFFFFFFF d "); PrintAndLog(" sample4: hf mf nested o 0 A FFFFFFFFFFFF 4 A"); PrintAndLog(" sample5: hf mf nested 1 * t"); + PrintAndLog(" sample5: hf mf nested 1 * ss"); return 0; } diff --git a/proxmark3.config b/proxmark3.config new file mode 100644 index 00000000..e0284f42 --- /dev/null +++ b/proxmark3.config @@ -0,0 +1,2 @@ +// Add predefined macros for your project here. For example: +// #define THE_ANSWER 42 diff --git a/proxmark3.creator b/proxmark3.creator new file mode 100644 index 00000000..e94cbbd3 --- /dev/null +++ b/proxmark3.creator @@ -0,0 +1 @@ +[General] diff --git a/proxmark3.files b/proxmark3.files new file mode 100644 index 00000000..8dae1604 --- /dev/null +++ b/proxmark3.files @@ -0,0 +1,325 @@ +armsrc/BigBuf.c +armsrc/BigBuf.h +armsrc/LCD.c +armsrc/LCD.h +armsrc/appmain.c +armsrc/apps.h +armsrc/epa.c +armsrc/epa.h +armsrc/fonts.c +armsrc/fonts.h +armsrc/fpgaloader.c +armsrc/fpgaloader.h +armsrc/hfsnoop.c +armsrc/hitag2.c +armsrc/hitagS.c +armsrc/iclass.c +armsrc/iso14443a.c +armsrc/iso14443a.h +armsrc/iso14443b.c +armsrc/iso14443b.h +armsrc/iso15693.c +armsrc/legicrf.c +armsrc/legicrf.h +armsrc/lfops.c +armsrc/lfsampling.c +armsrc/lfsampling.h +armsrc/mifarecmd.c +armsrc/mifarecmd.h +armsrc/mifaresniff.c +armsrc/mifaresniff.h +armsrc/mifareutil.c +armsrc/mifareutil.h +armsrc/optimized_cipher.c +armsrc/optimized_cipher.h +armsrc/pcf7931.c +armsrc/pcf7931.h +armsrc/printf.c +armsrc/printf.h +armsrc/start.c +armsrc/string.c +armsrc/string.h +armsrc/util.c +armsrc/util.h +armsrc/version.c +bootrom/bootrom.c +bootrom/version.c +client/cmdcrc.c +client/cmdcrc.h +client/cmddata.c +client/cmddata.h +client/cmdhf.c +client/cmdhf.h +client/cmdhf14a.c +client/cmdhf14a.h +client/cmdhf14b.c +client/cmdhf14b.h +client/cmdhf15.c +client/cmdhf15.h +client/cmdhfepa.c +client/cmdhfepa.h +client/cmdhficlass.c +client/cmdhficlass.h +client/cmdhflegic.c +client/cmdhflegic.h +client/cmdhfmf.c +client/cmdhfmf.h +client/cmdhfmfhard.c +client/cmdhfmfhard.h +client/cmdhfmfu.c +client/cmdhfmfu.h +client/cmdhftopaz.c +client/cmdhftopaz.h +client/cmdhw.c +client/cmdhw.h +client/cmdlf.c +client/cmdlf.h +client/cmdlfawid.c +client/cmdlfawid.h +client/cmdlfcotag.c +client/cmdlfcotag.h +client/cmdlfem4x.c +client/cmdlfem4x.h +client/cmdlffdx.c +client/cmdlffdx.h +client/cmdlfgproxii.c +client/cmdlfgproxii.h +client/cmdlfhid.c +client/cmdlfhid.h +client/cmdlfhitag.c +client/cmdlfhitag.h +client/cmdlfindala.c +client/cmdlfindala.h +client/cmdlfio.c +client/cmdlfio.h +client/cmdlfjablotron.c +client/cmdlfjablotron.h +client/cmdlfnexwatch.c +client/cmdlfnexwatch.h +client/cmdlfnoralsy.c +client/cmdlfnoralsy.h +client/cmdlfpac.c +client/cmdlfpac.h +client/cmdlfparadox.c +client/cmdlfparadox.h +client/cmdlfpcf7931.c +client/cmdlfpcf7931.h +client/cmdlfpresco.c +client/cmdlfpresco.h +client/cmdlfpyramid.c +client/cmdlfpyramid.h +client/cmdlfsecurakey.c +client/cmdlfsecurakey.h +client/cmdlft55xx.c +client/cmdlft55xx.h +client/cmdlfti.c +client/cmdlfti.h +client/cmdlfviking.c +client/cmdlfviking.h +client/cmdlfvisa2000.c +client/cmdlfvisa2000.h +client/cmdmain.c +client/cmdmain.h +client/cmdparser.c +client/cmdparser.h +client/cmdscript.c +client/cmdscript.h +client/data.c +client/data.h +client/elf.h +client/flash.c +client/flash.h +client/flasher.c +client/fpga_compress.c +client/graph.c +client/graph.h +client/guidummy.cpp +client/hardnested/hardnested_bf_core.c +client/hardnested/hardnested_bf_core.h +client/hardnested/hardnested_bitarray_core.c +client/hardnested/hardnested_bitarray_core.h +client/hardnested/hardnested_bruteforce.c +client/hardnested/hardnested_bruteforce.h +client/hardnested/hardnested_tables.c +client/hid-flasher/elf.h +client/hid-flasher/flash.c +client/hid-flasher/flash.h +client/hid-flasher/flasher.c +client/hid-flasher/proxendian.h +client/hid-flasher/proxmark3.h +client/hid-flasher/proxusb.c +client/hid-flasher/proxusb.h +client/hid-flasher/sleep.h +client/hid-flasher/usb_cmd.h +client/loclass/cipher.c +client/loclass/cipher.h +client/loclass/cipherutils.c +client/loclass/cipherutils.h +client/loclass/elite_crack.c +client/loclass/elite_crack.h +client/loclass/fileutils.c +client/loclass/fileutils.h +client/loclass/ikeys.c +client/loclass/ikeys.h +client/loclass/loclass_main.h +client/loclass/main.c +client/mfkey.c +client/mfkey.h +client/mifarehost.c +client/mifarehost.h +client/pm3_binlib.c +client/pm3_binlib.h +client/pm3_bit_limits.h +client/pm3_bitlib.c +client/pm3_bitlib.h +client/proxendian.h +client/proxgui.cpp +client/proxgui.h +client/proxguiqt.cpp +client/proxguiqt.h +client/proxguiqt.moc.cpp +client/proxmark3.c +client/proxmark3.h +client/reveng/bmpbit.c +client/reveng/cli.c +client/reveng/config.h +client/reveng/getopt.c +client/reveng/getopt.h +client/reveng/model.c +client/reveng/poly.c +client/reveng/reveng.c +client/reveng/reveng.h +client/scripting.c +client/scripting.h +client/ui.c +client/ui.h +client/ui/ui_overlays.h +client/util.c +client/util.h +client/util_posix.c +client/util_posix.h +client/whereami.c +client/whereami.h +common/cmd.c +common/cmd.h +common/crapto1/crapto1.c +common/crapto1/crapto1.h +common/crapto1/crypto1.c +common/crc.c +common/crc.h +common/crc16.c +common/crc16.h +common/crc32.c +common/crc32.h +common/crc64.c +common/crc64.h +common/default_version.c +common/iso14443crc.c +common/iso14443crc.h +common/iso15693tools.c +common/iso15693tools.h +common/legic_prng.c +common/lfdemod.c +common/lfdemod.h +common/parity.c +common/parity.h +common/polarssl/aes.c +common/polarssl/aes.h +common/polarssl/des.c +common/polarssl/des.h +common/polarssl/polarssl_config.h +common/protocols.c +common/protocols.h +common/sha1.c +common/sha1.h +common/usb_cdc.c +common/usb_cdc.h +include/at91sam7s512.h +include/common.h +include/config_gpio.h +include/hitag2.h +include/hitagS.h +include/legic_prng.h +include/mifare.h +include/proxmark3.h +include/usb_cmd.h +liblua/lapi.c +liblua/lapi.h +liblua/lauxlib.c +liblua/lauxlib.h +liblua/lbaselib.c +liblua/lbitlib.c +liblua/lcode.c +liblua/lcode.h +liblua/lcorolib.c +liblua/lctype.c +liblua/lctype.h +liblua/ldblib.c +liblua/ldebug.c +liblua/ldebug.h +liblua/ldo.c +liblua/ldo.h +liblua/ldump.c +liblua/lfunc.c +liblua/lfunc.h +liblua/lgc.c +liblua/lgc.h +liblua/linit.c +liblua/liolib.c +liblua/llex.c +liblua/llex.h +liblua/llimits.h +liblua/lmathlib.c +liblua/lmem.c +liblua/lmem.h +liblua/loadlib.c +liblua/lobject.c +liblua/lobject.h +liblua/lopcodes.c +liblua/lopcodes.h +liblua/loslib.c +liblua/lparser.c +liblua/lparser.h +liblua/lstate.c +liblua/lstate.h +liblua/lstring.c +liblua/lstring.h +liblua/lstrlib.c +liblua/ltable.c +liblua/ltable.h +liblua/ltablib.c +liblua/ltm.c +liblua/ltm.h +liblua/lua.c +liblua/lua.h +liblua/lua.hpp +liblua/luac.c +liblua/luaconf.h +liblua/lualib.h +liblua/lundump.c +liblua/lundump.h +liblua/lvm.c +liblua/lvm.h +liblua/lzio.c +liblua/lzio.h +tools/mfkey/mfkey32.c +tools/mfkey/mfkey64.c +uart/uart.h +uart/uart_posix.c +uart/uart_win32.c +zlib/adler32.c +zlib/deflate.c +zlib/deflate.h +zlib/inffast.c +zlib/inffast.h +zlib/inffixed.h +zlib/inflate.c +zlib/inflate.h +zlib/inftrees.c +zlib/inftrees.h +zlib/trees.c +zlib/trees.h +zlib/zconf.h +zlib/zlib.h +zlib/zutil.c +zlib/zutil.h diff --git a/proxmark3.includes b/proxmark3.includes new file mode 100644 index 00000000..40ca84ce --- /dev/null +++ b/proxmark3.includes @@ -0,0 +1,14 @@ +armsrc +client +client/hardnested +client/hid-flasher +client/loclass +client/reveng +client/ui +common +common/crapto1 +common/polarssl +include +liblua +uart +zlib