mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
lf ti write - now uses NG, cliparser (untested)
This commit is contained in:
parent
26f7aa4cee
commit
2fcd46f278
4 changed files with 47 additions and 17 deletions
|
@ -907,7 +907,13 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_LF_TI_WRITE: {
|
case CMD_LF_TI_WRITE: {
|
||||||
WriteTItag(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2]);
|
struct p {
|
||||||
|
uint32_t high;
|
||||||
|
uint32_t low;
|
||||||
|
uint16_t crc;
|
||||||
|
} PACKED;
|
||||||
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
|
WriteTItag(payload->high, payload->low, packet->crc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_LF_SIMULATE: {
|
case CMD_LF_SIMULATE: {
|
||||||
|
|
|
@ -803,7 +803,7 @@ void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc) {
|
||||||
AcquireTiType();
|
AcquireTiType();
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
DbpString("Now use `lf ti read` to check");
|
DbpString("Now use `lf ti reader` to check");
|
||||||
StopTicks();
|
StopTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ static int CmdIdteckDemod(const char *Cmd) {
|
||||||
return demodIdteck(true);
|
return demodIdteck(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdIdteckRead(const char *Cmd) {
|
static int CmdIdteckReader(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "lf idteck reader",
|
CLIParserInit(&ctx, "lf idteck reader",
|
||||||
"read a Idteck tag",
|
"read a Idteck tag",
|
||||||
|
@ -128,7 +128,7 @@ static int CmdIdteckRead(const char *Cmd) {
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"demod", CmdIdteckDemod, AlwaysAvailable, "Demodulate an Idteck tag from the GraphBuffer"},
|
{"demod", CmdIdteckDemod, AlwaysAvailable, "Demodulate an Idteck tag from the GraphBuffer"},
|
||||||
{"read", CmdIdteckRead, IfPm3Lf, "Attempt to read and Extract tag data from the antenna"},
|
{"reader", CmdIdteckReader, IfPm3Lf, "Attempt to read and Extract tag data from the antenna"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -314,19 +314,43 @@ static int CmdTIReader(const char *Cmd) {
|
||||||
|
|
||||||
// write new data to a r/w TI tag
|
// write new data to a r/w TI tag
|
||||||
static int CmdTIWrite(const char *Cmd) {
|
static int CmdTIWrite(const char *Cmd) {
|
||||||
int res = 0;
|
|
||||||
uint64_t arg0, arg1, arg2;
|
|
||||||
res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64 "", &arg0, &arg1, &arg2);
|
|
||||||
|
|
||||||
if (res == 2)
|
CLIParserContext *ctx;
|
||||||
arg2 = 0;
|
CLIParserInit(&ctx, "lf ti write",
|
||||||
|
"write to a r/w TI tag.",
|
||||||
|
"lf ti write --raw 1122334455667788\n"
|
||||||
|
"lf ti write --raw 1122334455667788 --crc 1122\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_str1("r", "raw", "<hex>", "raw hex data. 8 bytes max"),
|
||||||
|
arg_str0(NULL, "crc", "<hex>", "optional - crc"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
|
int raw_len = 0;
|
||||||
|
uint8_t raw[8] = {0};
|
||||||
|
CLIGetHexWithReturn(ctx, 1, raw, &raw_len);
|
||||||
|
|
||||||
|
int crc_len = 0;
|
||||||
|
uint8_t crc[2] = {0};
|
||||||
|
CLIGetHexWithReturn(ctx, 2, crc, &crc_len);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_t high;
|
||||||
|
uint32_t low;
|
||||||
|
uint16_t crc;
|
||||||
|
} PACKED payload;
|
||||||
|
|
||||||
|
payload.high = bytes_to_num(raw, 4);
|
||||||
|
payload.low = bytes_to_num(raw + 4, 4);
|
||||||
|
payload.crc = bytes_to_num(crc, crc_len);
|
||||||
|
|
||||||
if (res < 2) {
|
|
||||||
PrintAndLogEx(WARNING, "Please specify the data as two hex strings, optionally the CRC as a third");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_LF_TI_WRITE, arg0, arg1, arg2, NULL, 0);
|
SendCommandNG(CMD_LF_TI_WRITE, (uint8_t*)&payload, sizeof(payload));
|
||||||
PrintAndLogEx(SUCCESS, "Done");
|
PrintAndLogEx(SUCCESS, "Done");
|
||||||
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf ti reader`") " to verify");
|
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`lf ti reader`") " to verify");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -334,7 +358,7 @@ static int CmdTIWrite(const char *Cmd) {
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"demod", CmdTIDemod, AlwaysAvailable, "Demodulate raw bits for TI-type LF tag from the GraphBuffer"},
|
{"demod", CmdTIDemod, AlwaysAvailable, "Demodulate raw bits for TI LF tag from the GraphBuffer"},
|
||||||
{"reader", CmdTIReader, IfPm3Lf, "Read and decode a TI 134 kHz tag"},
|
{"reader", CmdTIReader, IfPm3Lf, "Read and decode a TI 134 kHz tag"},
|
||||||
{"write", CmdTIWrite, IfPm3Lf, "Write new data to a r/w TI 134 kHz tag"},
|
{"write", CmdTIWrite, IfPm3Lf, "Write new data to a r/w TI 134 kHz tag"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue