chg: 'lf visa2000 clone' - now verify successful write of blocks.

This commit is contained in:
iceman1001 2019-09-14 19:31:00 +02:00
commit cd28641d96
3 changed files with 32 additions and 23 deletions

View file

@ -421,25 +421,24 @@ bool t55xxVerifyWrite(uint8_t block, bool page1, bool usepwd, uint8_t override,
// this messes up with ppls config.. // this messes up with ppls config..
if (block == 0 && page1 == false) { 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; bool got_modulation = false;
for ( uint8_t m = 0; m < 4; m++) { for ( uint8_t m = 0; m < 4; m++) {
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, password, m) == false) { if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password, m) == false) {
PrintAndLogEx(INPLACE, ".");
continue; continue;
} }
if (tryDetectModulation(m, true) == false) { if (tryDetectModulation(m, false) == false) {
PrintAndLogEx(INPLACE, "."); PrintAndLogEx(INPLACE, ".");
continue; continue;
} else { } else {
got_modulation = true; got_modulation = true;
PrintAndLogEx(NORMAL, "");
break; break;
} }
} }
PrintAndLogEx(NORMAL, "");
if (got_modulation == false) if (got_modulation == false)
return false; return false;

View file

@ -11,19 +11,6 @@
#include "cmdlfvisa2000.h" #include "cmdlfvisa2000.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.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
#define BL0CK1 0x56495332 #define BL0CK1 0x56495332
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
@ -171,7 +158,7 @@ static int CmdVisa2kClone(const char *Cmd) {
id = param_get32ex(Cmd, 0, 0, 10); id = param_get32ex(Cmd, 0, 0, 10);
//Q5 //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[0] = T5555_MODULATION_MANCHESTER | T5555_SET_BITRATE(64) | T5555_ST_TERMINATOR | 3 << T5555_MAXBLOCK_SHIFT;
blocks[2] = id; blocks[2] = id;
@ -180,6 +167,8 @@ static int CmdVisa2kClone(const char *Cmd) {
PrintAndLogEx(INFO, "Preparing to clone Visa2000 to T55x7 with CardId: %u", id); PrintAndLogEx(INFO, "Preparing to clone Visa2000 to T55x7 with CardId: %u", id);
print_blocks(blocks, 4); print_blocks(blocks, 4);
uint8_t res = 0;
PacketResponseNG resp; PacketResponseNG resp;
// fast push mode // fast push mode
@ -202,7 +191,16 @@ static int CmdVisa2kClone(const char *Cmd) {
PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation."); PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation.");
return PM3_ETIMEOUT; 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; return PM3_SUCCESS;
} }

View file

@ -9,7 +9,19 @@
#ifndef CMDLFVISA2000_H__ #ifndef CMDLFVISA2000_H__
#define CMDLFVISA2000_H__ #define CMDLFVISA2000_H__
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "common.h" #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); int CmdLFVisa2k(const char *Cmd);