From cd28641d962c8a1335ee6a6de80704a8b1e5f2e2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 14 Sep 2019 19:31:00 +0200 Subject: [PATCH] chg: 'lf visa2000 clone' - now verify successful write of blocks. --- client/cmdlft55xx.c | 15 +++++++-------- client/cmdlfvisa2000.c | 28 +++++++++++++--------------- client/cmdlfvisa2000.h | 12 ++++++++++++ 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index faf371443..5575ef80e 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -421,29 +421,28 @@ bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override, // this messes up with ppls config.. if (block == 0 && page1 == false) { - PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible (pwd == %08X)", password); - + + PrintAndLogEx(INFO, "Block0 write detected, running `detect` to see if validation is possible"); bool got_modulation = false; for ( uint8_t m = 0; m < 4; m++) { - if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, password, m) == false) { - PrintAndLogEx(INPLACE, "."); + if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false) { continue; } - - if (tryDetectModulation(m, true) == false) { + + if (tryDetectModulation(m, false) == false) { PrintAndLogEx(INPLACE, "."); continue; } else { got_modulation = true; - PrintAndLogEx(NORMAL, ""); break; } } + PrintAndLogEx(NORMAL, ""); if (got_modulation == false) return false; - + return t55xxVerifyWrite(block, page1, usepwd, 2, password, downlink_mode, data); } } diff --git a/client/cmdlfvisa2000.c b/client/cmdlfvisa2000.c index ed181d991..1433ced01 100644 --- a/client/cmdlfvisa2000.c +++ b/client/cmdlfvisa2000.c @@ -11,19 +11,6 @@ #include "cmdlfvisa2000.h" -#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 - #define BL0CK1 0x56495332 static int CmdHelp(const char *Cmd); @@ -171,7 +158,7 @@ static int CmdVisa2kClone(const char *Cmd) { id = param_get32ex(Cmd, 0, 0, 10); //Q5 - if (param_getchar(Cmd, 1) == 'Q' || param_getchar(Cmd, 1) == 'q') + if (tolower(param_getchar(Cmd, 1)) == 'q') blocks[0] = T5555_MODULATION_MANCHESTER | T5555_SET_BITRATE(64) | T5555_ST_TERMINATOR | 3 << T5555_MAXBLOCK_SHIFT; blocks[2] = id; @@ -180,8 +167,10 @@ static int CmdVisa2kClone(const char *Cmd) { PrintAndLogEx(INFO, "Preparing to clone Visa2000 to T55x7 with CardId: %u", id); print_blocks(blocks, 4); + uint8_t res = 0; + PacketResponseNG resp; - + // fast push mode conn.block_after_ACK = true; for (uint8_t i = 0; i < 4; i++) { @@ -202,7 +191,16 @@ static int CmdVisa2kClone(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/cmdlfvisa2000.h b/client/cmdlfvisa2000.h index 63e7fdc67..e8995cbdd 100644 --- a/client/cmdlfvisa2000.h +++ b/client/cmdlfvisa2000.h @@ -9,7 +9,19 @@ #ifndef CMDLFVISA2000_H__ #define CMDLFVISA2000_H__ +#include +#include +#include #include "common.h" +#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 "cmdlft55xx.h" // write verify int CmdLFVisa2k(const char *Cmd);