From 834023b132599c23bb8752bd393a4f6720c8facf Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 30 Jul 2022 10:03:51 +0200 Subject: [PATCH] add a pwd to ntag215 sim if empty --- armsrc/Makefile | 3 ++- armsrc/iso14443a.c | 8 ++++++++ common/generator.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 5505119b7..c0703ccf4 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -152,7 +152,8 @@ THUMBSRC = start.c \ BigBuf.c \ ticks.c \ clocks.c \ - hfsnoop.c + hfsnoop.c \ + generator.c # These are to be compiled in ARM mode diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 4af72bfba..bcf206cc8 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -34,6 +34,7 @@ #include "commonutil.h" #include "crc16.h" #include "protocols.h" +#include "generator.h" #define MAX_ISO14A_TIMEOUT 524288 @@ -1104,6 +1105,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r // READ_SIG memcpy(rSIGN, mfu_header->signature, 32); AddCrc14A(rSIGN, sizeof(rSIGN) - 2); + } break; case 8: { // MIFARE Classic 4k @@ -1642,7 +1644,13 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_ // PWD stored in dump now uint8_t pwd[4]; emlGetMemBt(pwd, (pages - 1) * 4 + MFU_DUMP_PREFIX_LENGTH, sizeof(pwd)); + if (memcmp(pwd, "\x00\x00\x00\x00", 4) == 0) { + Uint4byteToMemLe(pwd, ul_ev1_pwdgenB(data)); + Dbprintf("Calc pwd... %02X %02X %02X %02X", pwd[0], pwd[1], pwd[2] ,pwd[3]); + } + if (memcmp(receivedCmd + 1, pwd, 4) == 0) { + uint8_t pack[4]; emlGetMemBt(pack, pages * 4 + MFU_DUMP_PREFIX_LENGTH, 2); if (memcmp(pack, "\x00\x00\x00\x00", 4) == 0) { diff --git a/common/generator.c b/common/generator.c index 4b23d30ce..b06e9deaf 100644 --- a/common/generator.c +++ b/common/generator.c @@ -27,10 +27,20 @@ #include "common.h" //BSWAP_32/64 #include "util.h" #include "pm3_cmd.h" -#include "ui.h" +#include "crc16.h" // crc16 ccitt #include "mbedtls/sha1.h" #include "mbedtls/md5.h" -#include "crc16.h" // crc16 ccitt +#include "mbedtls/cmac.h" +#include "mbedtls/cipher.h" +#include "mbedtls/md.h" + +#ifndef ON_DEVICE +#include "ui.h" +# define prnt(args...) PrintAndLogEx(DEBUG, ## args ); +#else +# include "dbprint.h" +# define prnt Dbprintf +#endif // Implementation tips: // For each implementation of the algos, I recommend adding a self test for easy "simple unit" tests when Travis CI / Appveyor runs.