From 06809babbbbff155d2e357188e29f5efc7c77f43 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 15 Sep 2019 01:33:54 +0200 Subject: [PATCH] chg: 'lf pyramid clone' - add verification --- client/cmdlfpyramid.c | 30 +++++++++++++----------------- client/cmdlfpyramid.h | 15 +++++++++++++++ client/cmdlfsecurakey.c | 6 +++--- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/client/cmdlfpyramid.c b/client/cmdlfpyramid.c index d5c3076a9..90a4ccfde 100644 --- a/client/cmdlfpyramid.c +++ b/client/cmdlfpyramid.c @@ -9,21 +9,6 @@ //----------------------------------------------------------------------------- #include "cmdlfpyramid.h" -#include -#include -#include -#include - -#include "cmdparser.h" // command_t -#include "comms.h" -#include "ui.h" -#include "graph.h" -#include "cmddata.h" -#include "cmdlf.h" -#include "protocols.h" // for T55xx config register definitions -#include "lfdemod.h" // parityTest -#include "crc.h" - static int CmdHelp(const char *Cmd); static int usage_lf_pyramid_clone(void) { @@ -246,12 +231,13 @@ static int CmdPyramidClone(const char *Cmd) { PrintAndLogEx(INFO, "Preparing to clone Farpointe/Pyramid to T55x7 with Facility Code: %u, Card Number: %u", facilitycode, cardnumber); print_blocks(blocks, 5); + uint8_t res = 0; PacketResponseNG resp; // fast push mode conn.block_after_ACK = true; - for (uint8_t i = 0; i < 5; i++) { - if (i == 4) { + for (int8_t i = 4; i >= 0; i--) { + if (i == 0) { // Disable fast mode on last packet conn.block_after_ACK = false; } @@ -267,7 +253,17 @@ static int CmdPyramidClone(const char *Cmd) { PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation."); return PM3_ETIMEOUT; } + + bool isok = t55xxVerifyWrite(i, 0, false, false, 0, 0, blocks[i]); + if ( isok == false) { + PrintAndLogEx(WARNING, "Couldn't verify write"); + res++; + } } + + if ( res == 0 ) + PrintAndLogEx(SUCCESS, "Success writing to tag"); + return PM3_SUCCESS; } diff --git a/client/cmdlfpyramid.h b/client/cmdlfpyramid.h index 2d717fbb3..0a9e2674a 100644 --- a/client/cmdlfpyramid.h +++ b/client/cmdlfpyramid.h @@ -10,6 +10,21 @@ #define CMDLFPYRAMID_H__ #include "common.h" +#include +#include +#include +#include + +#include "cmdparser.h" // command_t +#include "comms.h" +#include "ui.h" +#include "graph.h" +#include "cmddata.h" +#include "cmdlf.h" +#include "protocols.h" // for T55xx config register definitions +#include "lfdemod.h" // parityTest +#include "crc.h" +#include "cmdlft55xx.h" // verifywrite int CmdLFPyramid(const char *Cmd); diff --git a/client/cmdlfsecurakey.c b/client/cmdlfsecurakey.c index c916478da..e14a679f2 100644 --- a/client/cmdlfsecurakey.c +++ b/client/cmdlfsecurakey.c @@ -111,12 +111,12 @@ static int CmdSecurakeyRead(const char *Cmd) { return CmdSecurakeyDemod(Cmd); } -static int CmdSecuraClone(const char *Cmd) { +static int CmdSecurakeyClone(const char *Cmd) { PrintAndLogEx(INFO, " To be implemented, feel free to contribute!"); return PM3_SUCCESS; } -static int CmdSecureSim(const char *Cmd) { +static int CmdSecurakeySim(const char *Cmd) { PrintAndLogEx(INFO, " To be implemented, feel free to contribute!"); return PM3_SUCCESS; } @@ -126,7 +126,7 @@ static command_t CommandTable[] = { {"demod", CmdSecurakeyDemod, AlwaysAvailable, "Demodulate an Securakey tag from the GraphBuffer"}, {"read", CmdSecurakeyRead, IfPm3Lf, "Attempt to read and extract tag data from the antenna"}, {"clone", CmdSecurakeyClone, IfPm3Lf, "clone Securakey tag"}, - {"sim", CmdSecurakeydSim, IfPm3Lf, "simulate Securakey tag"}, + {"sim", CmdSecurakeySim, IfPm3Lf, "simulate Securakey tag"}, {NULL, NULL, NULL, NULL} };