mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-20 13:23:25 -07:00
Added block command for T55xx and support for cloning HID long format
This commit is contained in:
parent
49ec6d1d1b
commit
e98300f245
11 changed files with 503 additions and 80 deletions
|
@ -67,7 +67,8 @@ CMDSRCS = \
|
|||
cmdlfhitag.c \
|
||||
cmdlfti.c \
|
||||
cmdparser.c \
|
||||
cmdmain.c
|
||||
cmdmain.c \
|
||||
cmdlft55xx.c
|
||||
|
||||
CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
|
||||
|
||||
|
|
|
@ -77,13 +77,13 @@ start:
|
|||
PrintAndLog("Key not found (lfsr_common_prefix list is null). Nt=%08x", nt);
|
||||
} else {
|
||||
printf("------------------------------------------------------------------\n");
|
||||
PrintAndLog("Key found:%012llx \n", r_key);
|
||||
PrintAndLog("Key found:%012I64x \n", r_key);
|
||||
|
||||
num_to_bytes(r_key, 6, keyBlock);
|
||||
isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);
|
||||
}
|
||||
if (!isOK)
|
||||
PrintAndLog("Found valid key:%012llx", r_key);
|
||||
PrintAndLog("Found valid key:%012I64x", r_key);
|
||||
else
|
||||
{
|
||||
if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt);
|
||||
|
@ -575,7 +575,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
if (res)
|
||||
res = mfCheckKeys(trgBlockNo, trgKeyType, 8, &keyBlock[6 * 8], &key64);
|
||||
if (!res) {
|
||||
PrintAndLog("Found valid key:%012llx", key64);
|
||||
PrintAndLog("Found valid key:%012I64x", key64);
|
||||
|
||||
// transfer key to the emulator
|
||||
if (transferToEml) {
|
||||
|
@ -635,7 +635,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
if (res)
|
||||
res = mfCheckKeys(trgBlockNo, trgKeyType, 8, &keyBlock[6 * 8], &key64);
|
||||
if (!res) {
|
||||
PrintAndLog("Found valid key:%012llx", key64);
|
||||
PrintAndLog("Found valid key:%012I64x", key64);
|
||||
e_sector[trgBlockNo / 4].foundKey[trgKeyType] = 1;
|
||||
e_sector[trgBlockNo / 4].Key[trgKeyType] = key64;
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
PrintAndLog("|sec|key A |res|key B |res|");
|
||||
PrintAndLog("|---|----------------|---|----------------|---|");
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
PrintAndLog("|%03d| %012llx | %d | %012llx | %d |", i,
|
||||
PrintAndLog("|%03d| %012I64x | %d | %012I64x | %d |", i,
|
||||
e_sector[i].Key[0], e_sector[i].foundKey[0], e_sector[i].Key[1], e_sector[i].foundKey[1]);
|
||||
}
|
||||
PrintAndLog("|---|----------------|---|----------------|---|");
|
||||
|
@ -845,7 +845,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
}
|
||||
memset(keyBlock + 6 * keycnt, 0, 6);
|
||||
num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);
|
||||
PrintAndLog("chk custom key[%d] %012llx", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
||||
PrintAndLog("chk custom key[%d] %012I64x", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
||||
keycnt++;
|
||||
}
|
||||
} else {
|
||||
|
@ -875,7 +875,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
|||
res = mfCheckKeys(b, t, size, keyBlock +6*c, &key64);
|
||||
if (res !=1) {
|
||||
if (!res) {
|
||||
PrintAndLog("Found valid key:[%012llx]",key64);
|
||||
PrintAndLog("Found valid key:[%012I64x]",key64);
|
||||
if (transferToEml) {
|
||||
uint8_t block[16];
|
||||
mfEmlGetMem(block, get_trailer_block(b), 1);
|
||||
|
@ -1207,7 +1207,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
|
|||
}
|
||||
keyA = bytes_to_num(data, 6);
|
||||
keyB = bytes_to_num(data + 10, 6);
|
||||
PrintAndLog("|%03d| %012llx | %012llx |", i, keyA, keyB);
|
||||
PrintAndLog("|%03d| %012I64x | %012I64x |", i, keyA, keyB);
|
||||
}
|
||||
PrintAndLog("|---|----------------|----------------|");
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "cmdlfti.h"
|
||||
#include "cmdlfem4x.h"
|
||||
#include "cmdlfhitag.h"
|
||||
#include "cmdlft55xx.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -538,6 +539,7 @@ static command_t CommandTable[] =
|
|||
{"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
|
||||
{"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"},
|
||||
{"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
|
||||
{"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ int CmdLF(const char *Cmd);
|
|||
int CmdLFCommandRead(const char *Cmd);
|
||||
int CmdFlexdemod(const char *Cmd);
|
||||
int CmdIndalaDemod(const char *Cmd);
|
||||
int CmdIndalaClone(const char *Cmd);
|
||||
int CmdLFRead(const char *Cmd);
|
||||
int CmdLFSim(const char *Cmd);
|
||||
int CmdLFSimBidir(const char *Cmd);
|
||||
|
|
|
@ -62,17 +62,38 @@ int CmdHIDSim(const char *Cmd)
|
|||
|
||||
int CmdHIDClone(const char *Cmd)
|
||||
{
|
||||
unsigned int hi = 0, lo = 0;
|
||||
unsigned int hi2 = 0, hi = 0, lo = 0;
|
||||
int n = 0, i = 0;
|
||||
UsbCommand c;
|
||||
|
||||
while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
|
||||
hi = (hi << 4) | (lo >> 28);
|
||||
lo = (lo << 4) | (n & 0xf);
|
||||
if (strchr(Cmd,'l') != 0) {
|
||||
while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
|
||||
hi2 = (hi2 << 4) | (hi >> 28);
|
||||
hi = (hi << 4) | (lo >> 28);
|
||||
lo = (lo << 4) | (n & 0xf);
|
||||
}
|
||||
|
||||
PrintAndLog("Cloning tag with long ID %x%08x%08x", hi2, hi, lo);
|
||||
|
||||
c.d.asBytes[0] = 1;
|
||||
}
|
||||
else {
|
||||
while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
|
||||
hi = (hi << 4) | (lo >> 28);
|
||||
lo = (lo << 4) | (n & 0xf);
|
||||
}
|
||||
|
||||
PrintAndLog("Cloning tag with ID %x%08x", hi, lo);
|
||||
|
||||
hi2 = 0;
|
||||
c.d.asBytes[0] = 0;
|
||||
}
|
||||
|
||||
PrintAndLog("Cloning tag with ID %x%08x", hi, lo);
|
||||
c.cmd = CMD_HID_CLONE_TAG;
|
||||
c.arg[0] = hi2;
|
||||
c.arg[1] = hi;
|
||||
c.arg[2] = lo;
|
||||
|
||||
UsbCommand c = {CMD_HID_CLONE_TAG, {hi, lo}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -81,9 +102,9 @@ static command_t CommandTable[] =
|
|||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"demod", CmdHIDDemod, 1, "Demodulate HID Prox Card II (not optimal)"},
|
||||
{"fskdemod", CmdHIDDemodFSK, 0, "Realtime HID FSK demodulator"},
|
||||
{"sim", CmdHIDSim, 0, "<ID> -- HID tag simulator"},
|
||||
{"clone", CmdHIDClone, 0, "<ID> -- Clone HID to T55x7 (tag must be in antenna)"},
|
||||
{"fskdemod", CmdHIDDemodFSK, 1, "Realtime HID FSK demodulator"},
|
||||
{"sim", CmdHIDSim, 1, "<ID> -- HID tag simulator"},
|
||||
{"clone", CmdHIDClone, 1, "<ID> ['l'] -- Clone HID to T55x7 (tag must be in antenna)(option 'l' for 84bit ID)"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
151
client/cmdlft55xx.c
Normal file
151
client/cmdlft55xx.c
Normal file
|
@ -0,0 +1,151 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency T55xx commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "proxusb.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
#include "cmdlft55xx.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
||||
int CmdReadBlk(const char *Cmd)
|
||||
{
|
||||
int Block = 8; //default to invalid block
|
||||
UsbCommand c;
|
||||
|
||||
sscanf(Cmd, "%d", &Block);
|
||||
|
||||
if (Block > 7) {
|
||||
PrintAndLog("Block must be between 0 and 7");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLog("Reading block %d", Block);
|
||||
|
||||
c.cmd = CMD_T55XX_READ_BLOCK;
|
||||
c.d.asBytes[0] = 0x0; //Normal mode
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = Block;
|
||||
c.arg[2] = 0;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdReadBlkPWD(const char *Cmd)
|
||||
{
|
||||
int Block = 8; //default to invalid block
|
||||
int Password = 0xFFFFFFFF; //default to blank Block 7
|
||||
UsbCommand c;
|
||||
|
||||
sscanf(Cmd, "%d %x", &Block, &Password);
|
||||
|
||||
if (Block > 7) {
|
||||
PrintAndLog("Block must be between 0 and 7");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLog("Reading block %d with password %08X", Block, Password);
|
||||
|
||||
c.cmd = CMD_T55XX_READ_BLOCK;
|
||||
c.d.asBytes[0] = 0x1; //Password mode
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = Block;
|
||||
c.arg[2] = Password;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdWriteBlk(const char *Cmd)
|
||||
{
|
||||
int Block = 8; //default to invalid block
|
||||
int Data = 0xFFFFFFFF; //default to blank Block
|
||||
UsbCommand c;
|
||||
|
||||
sscanf(Cmd, "%x %d", &Data, &Block);
|
||||
|
||||
if (Block > 7) {
|
||||
PrintAndLog("Block must be between 0 and 7");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLog("Writting block %d with data %08X", Block, Data);
|
||||
|
||||
c.cmd = CMD_T55XX_WRITE_BLOCK;
|
||||
c.d.asBytes[0] = 0x0; //Normal mode
|
||||
c.arg[0] = Data;
|
||||
c.arg[1] = Block;
|
||||
c.arg[2] = 0;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdWriteBlkPWD(const char *Cmd)
|
||||
{
|
||||
int Block = 8; //default to invalid block
|
||||
int Data = 0xFFFFFFFF; //default to blank Block
|
||||
int Password = 0xFFFFFFFF; //default to blank Block 7
|
||||
UsbCommand c;
|
||||
|
||||
sscanf(Cmd, "%x %d %x", &Data, &Block, &Password);
|
||||
|
||||
if (Block > 7) {
|
||||
PrintAndLog("Block must be between 0 and 7");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLog("Writting block %d with data %08X and password %08X", Block, Data, Password);
|
||||
|
||||
c.cmd = CMD_T55XX_WRITE_BLOCK;
|
||||
c.d.asBytes[0] = 0x1; //Password mode
|
||||
c.arg[0] = Data;
|
||||
c.arg[1] = Block;
|
||||
c.arg[2] = Password;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdReadTrace(const char *Cmd)
|
||||
{
|
||||
|
||||
PrintAndLog("Reading traceability data");
|
||||
|
||||
UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] =
|
||||
{
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"readblock", CmdReadBlk, 1, "<Block> -- Read T55xx block data (page 0)"},
|
||||
{"readblockPWD", CmdReadBlkPWD, 1, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},
|
||||
{"writeblock", CmdWriteBlk, 1, "<Data> <Block> -- Write T55xx block data (page 0)"},
|
||||
{"writeblockPWD", CmdWriteBlkPWD, 1, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},
|
||||
{"readtrace", CmdReadTrace, 1, "Read T55xx traceability data (page 1)"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
int CmdLFT55XX(const char *Cmd)
|
||||
{
|
||||
CmdsParse(CommandTable, Cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHelp(const char *Cmd)
|
||||
{
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
21
client/cmdlft55xx.h
Normal file
21
client/cmdlft55xx.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Low frequency T55xx commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef CMDLFT55XX_H__
|
||||
#define CMDLFT55XX_H__
|
||||
|
||||
int CmdLFT55XX(const char *Cmd);
|
||||
|
||||
int CmdReadBlk(const char *Cmd);
|
||||
int CmdReadBlkPWD(const char *Cmd);
|
||||
int CmdWriteBlk(const char *Cmd);
|
||||
int CmdWriteBLkPWD(const char *Cmd);
|
||||
int CmdReadTrace(const char *Cmd);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue