chg: 'lf viking clone' - now uses NG

This commit is contained in:
iceman1001 2019-09-14 19:58:17 +02:00
commit 2bec009778
5 changed files with 50 additions and 24 deletions

View file

@ -856,7 +856,12 @@ static void PacketReceived(PacketCommandNG *packet) {
break; break;
} }
case CMD_LF_VIKING_CLONE: { case CMD_LF_VIKING_CLONE: {
CopyVikingtoT55xx(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2]); struct p {
bool Q5;
uint8_t blocks[8];
} PACKED;
struct p *payload = (struct p*)packet->data.asBytes;
CopyVikingtoT55xx(payload->blocks, payload->Q5);
break; break;
} }
case CMD_LF_COTAG_READ: { case CMD_LF_COTAG_READ: {
@ -1217,7 +1222,11 @@ static void PacketReceived(PacketCommandNG *packet) {
break; break;
} }
case CMD_HF_ICLASS_READER: { case CMD_HF_ICLASS_READER: {
ReaderIClass(packet->oldarg[0]); struct p {
uint8_t flags;
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
ReaderIClass(payload->flags);
break; break;
} }
case CMD_HF_ICLASS_REPLAY: { case CMD_HF_ICLASS_REPLAY: {

View file

@ -2152,13 +2152,19 @@ void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t
LED_D_OFF(); LED_D_OFF();
} }
// clone viking tag to T55xx // clone viking tag to T55xx
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) { void CopyVikingtoT55xx(uint8_t *blocks, uint8_t Q5) {
uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), block1, block2};
if (Q5) data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT; uint32_t data[] = {T55x7_BITRATE_RF_32 | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT), 0, 0};
if (Q5)
data[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_MANCHESTER | 2 << T5555_MAXBLOCK_SHIFT;
data[1] = bytes_to_num(blocks, 4);
data[2] = bytes_to_num(blocks +4, 4);
// Program the data blocks for supplied ID and the block 0 config // Program the data blocks for supplied ID and the block 0 config
WriteT55xx(data, 0, 3); WriteT55xx(data, 0, 3);
LED_D_OFF(); LED_D_OFF();
reply_mix(CMD_ACK, 0, 0, 0, 0, 0); reply_ng(CMD_LF_VIKING_CLONE, PM3_SUCCESS, NULL, 0);
} }
// Define 9bit header for EM410x tags // Define 9bit header for EM410x tags

View file

@ -43,7 +43,7 @@ void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol);
void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol); void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567 void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567
void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567 void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5); void CopyVikingtoT55xx(uint8_t *blocks, uint8_t Q5);
void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo); void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
void CopyIndala64toT55x7(uint32_t hi, uint32_t lo); // Clone Indala 64-bit tag by UID to T55x7 void CopyIndala64toT55x7(uint32_t hi, uint32_t lo); // Clone Indala 64-bit tag by UID to T55x7
void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7); // Clone Indala 224-bit tag by UID to T55x7 void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7); // Clone Indala 224-bit tag by UID to T55x7

View file

@ -9,17 +9,6 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "cmdlfviking.h" #include "cmdlfviking.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "cmdparser.h" // command_t
#include "comms.h"
#include "ui.h"
#include "cmddata.h"
#include "cmdlf.h"
#include "lfdemod.h"
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
static int usage_lf_viking_clone(void) { static int usage_lf_viking_clone(void) {
@ -90,22 +79,31 @@ static int CmdVikingClone(const char *Cmd) {
id = param_get32ex(Cmd, 0, 0, 16); id = param_get32ex(Cmd, 0, 0, 16);
if (id == 0) return usage_lf_viking_clone(); if (id == 0) return usage_lf_viking_clone();
cmdp = param_getchar(Cmd, 1); cmdp = tolower(param_getchar(Cmd, 1));
if (cmdp == 'Q' || cmdp == 'q') if (cmdp == 'q')
Q5 = true; Q5 = true;
rawID = getVikingBits(id); rawID = getVikingBits(id);
PrintAndLogEx(INFO, "Preparing to clone Viking tag - ID " _YELLOW_("%08X")" raw " _YELLOW_("%08X%08X"), id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF)); struct p {
bool Q5;
uint8_t blocks[8];
} PACKED payload;
payload.Q5 = Q5;
num_to_bytes(rawID, 8, &payload.blocks[0]);
PrintAndLogEx(INFO, "Preparing to clone Viking tag - ID " _YELLOW_("%08X")" raw " _YELLOW_("%s"), id, sprint_hex(payload.blocks, sizeof(payload.blocks)));
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_LF_VIKING_CLONE, rawID >> 32, rawID & 0xFFFFFFFF, Q5, NULL, 0);
SendCommandNG(CMD_LF_VIKING_CLONE, (uint8_t*)&payload, sizeof(payload));
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, T55XX_WRITE_TIMEOUT)) { if (!WaitForResponseTimeout(CMD_LF_VIKING_CLONE, &resp, T55XX_WRITE_TIMEOUT)) {
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;
} }
return PM3_SUCCESS; return resp.status;
} }
static int CmdVikingSim(const char *Cmd) { static int CmdVikingSim(const char *Cmd) {

View file

@ -9,8 +9,21 @@
#ifndef CMDLFVIKING_H__ #ifndef CMDLFVIKING_H__
#define CMDLFVIKING_H__ #define CMDLFVIKING_H__
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "common.h" #include "common.h"
#include "cmdparser.h" // command_t
#include "comms.h"
#include "ui.h"
#include "cmddata.h"
#include "cmdlf.h"
#include "lfdemod.h"
#include "commonutil.h" // num_to_bytes
int CmdLFViking(const char *Cmd); int CmdLFViking(const char *Cmd);
int demodViking(void); int demodViking(void);