From ecca9fc56376839b75034e8f730426bf35d2c721 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 26 Sep 2019 21:21:13 +0200 Subject: [PATCH] rework clone --- client/cmdlfnedap.c | 58 +++++++++++++++------------------------------ client/cmdlfnedap.h | 13 ---------- 2 files changed, 19 insertions(+), 52 deletions(-) diff --git a/client/cmdlfnedap.c b/client/cmdlfnedap.c index b186a1354..cab5e55c6 100644 --- a/client/cmdlfnedap.c +++ b/client/cmdlfnedap.c @@ -9,6 +9,19 @@ #include "cmdlfnedap.h" +#include + +#include +#include +#include "cmdparser.h" // command_t +#include "comms.h" +#include "crc16.h" +#include "cmdlft55xx.h" // verifywrite +#include "ui.h" +#include "cmddata.h" +#include "cmdlf.h" +#include "lfdemod.h" + #define FIXED_71 0x71 #define FIXED_40 0x40 #define UNKNOWN_A 0x00 @@ -431,7 +444,7 @@ int CmdLFNedapClone(const char *Cmd) { return PM3_ESOFT; } - CmdPrintDemodBuff("x"); + //CmdPrintDemodBuff("x"); // What we had before in commented code: //NEDAP - compat mode, ASK/DIphase, data rate 64, 4 data blocks @@ -455,47 +468,14 @@ int CmdLFNedapClone(const char *Cmd) { PrintAndLogEx(SUCCESS, "Preparing to clone NEDAP to T55x7"); print_blocks(blocks, max); - uint8_t res = 0; - PacketResponseNG resp; - - // fast push mode - conn.block_after_ACK = true; - for (uint8_t i = 0; i < max; i++) { - if (i == max - 1) { - // Disable fast mode on last packet - conn.block_after_ACK = false; - } - clearCommandBuffer(); - t55xx_write_block_t ng; - ng.data = blocks[i]; - ng.pwd = 0; - ng.blockno = i; - ng.flags = 0; - - SendCommandNG(CMD_LF_T55XX_WRITEBL, (uint8_t *)&ng, sizeof(ng)); - if (!WaitForResponseTimeout(CMD_LF_T55XX_WRITEBL, &resp, T55XX_WRITE_TIMEOUT)) { - PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation."); - return PM3_ETIMEOUT; - } - - if (i == 0) { - SetConfigWithBlock0(blocks[0]); - if (t55xxAquireAndCompareBlock0(false, 0, blocks[0], false)) - continue; - } - - if (t55xxVerifyWrite(i, 0, false, false, 0, 0xFF, blocks[i]) == false) - res++; - } - - if (res == 0) - PrintAndLogEx(SUCCESS, "Success writing to tag"); - else { - PrintAndLogEx(NORMAL, ""); + int res = clone_t55xx_tag(blocks, max); + if (res == PM3_SUCCESS) { PrintAndLogEx(INFO, "The block 0 was changed (eXtended) which can be hard to detect."); PrintAndLogEx(INFO, " Configure it manually " _YELLOW_("`lf t55xx config b 64 d BI i 1 o 32`")); + } else { + PrintAndLogEx(NORMAL, ""); } - return PM3_SUCCESS; + return res; } static int CmdLFNedapSim(const char *Cmd) { diff --git a/client/cmdlfnedap.h b/client/cmdlfnedap.h index 74fdd30fb..fda0e130e 100644 --- a/client/cmdlfnedap.h +++ b/client/cmdlfnedap.h @@ -11,19 +11,6 @@ #include "common.h" -#include - -#include -#include -#include "cmdparser.h" // command_t -#include "comms.h" -#include "crc16.h" -#include "cmdlft55xx.h" // verifywrite -#include "ui.h" -#include "cmddata.h" -#include "cmdlf.h" -#include "lfdemod.h" - int CmdLFNedap(const char *Cmd); int demodNedap(void);