mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Merge branch 'master' into topaz_cliparser
This commit is contained in:
commit
9646c34c94
3 changed files with 36 additions and 74 deletions
|
@ -1696,7 +1696,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||||
CLIParserInit(&ctx, "hf iclass restore",
|
CLIParserInit(&ctx, "hf iclass restore",
|
||||||
"Restore data from dumpfile onto a iCLASS tag",
|
"Restore data from dumpfile onto a iCLASS tag",
|
||||||
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0\n"
|
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0\n"
|
||||||
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0 --elite"
|
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0 --elite\n"
|
||||||
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 -k 1122334455667788 --elite\n"
|
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 -k 1122334455667788 --elite\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include "cliparser.h"
|
||||||
#include "cmdparser.h" // command_t
|
#include "cmdparser.h" // command_t
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "cmdtrace.h"
|
#include "cmdtrace.h"
|
||||||
|
@ -22,28 +22,6 @@
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_thinfilm_info(void) {
|
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf thinfilm info [h]");
|
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
|
||||||
PrintAndLogEx(NORMAL, " h this help");
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
|
||||||
PrintAndLogEx(NORMAL, " hf thinfilm info");
|
|
||||||
return PM3_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int usage_thinfilm_sim(void) {
|
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf thinfilm sim [h] [d <data>]");
|
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
|
||||||
PrintAndLogEx(NORMAL, " h this help");
|
|
||||||
PrintAndLogEx(NORMAL, " d <bytes> bytes to send, in hex");
|
|
||||||
PrintAndLogEx(NORMAL, " r raw, provided bytes should include CRC");
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
|
||||||
PrintAndLogEx(NORMAL, " hf thinfilm sim d B70470726f786d61726b2e636f6d");
|
|
||||||
return PM3_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Printing function based upon the code in libnfc
|
// Printing function based upon the code in libnfc
|
||||||
// ref
|
// ref
|
||||||
// https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-barcode.c
|
// https://github.com/nfc-tools/libnfc/blob/master/utils/nfc-barcode.c
|
||||||
|
@ -119,25 +97,16 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len, bool verbos
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHfThinFilmInfo(const char *Cmd) {
|
static int CmdHfThinFilmInfo(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf thinfilm info",
|
||||||
|
"Get info from Thinfilm tags",
|
||||||
|
"hf thinfilm info");
|
||||||
|
|
||||||
uint8_t cmdp = 0;
|
void *argtable[] = {
|
||||||
bool errors = false;
|
arg_param_begin,
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
arg_param_end
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
};
|
||||||
case 'h':
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
return usage_thinfilm_info();
|
|
||||||
default:
|
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Validations
|
|
||||||
if (errors) {
|
|
||||||
usage_thinfilm_info();
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
return infoThinFilm(true);
|
return infoThinFilm(true);
|
||||||
}
|
}
|
||||||
|
@ -168,45 +137,40 @@ int infoThinFilm(bool verbose) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHfThinFilmSim(const char *Cmd) {
|
static int CmdHfThinFilmSim(const char *Cmd) {
|
||||||
uint8_t cmdp = 0;
|
CLIParserContext *ctx;
|
||||||
uint8_t data[512];
|
CLIParserInit(&ctx, "hf thinfilm sim",
|
||||||
int datalen = 0;
|
"Simulate Thinfilm tag",
|
||||||
|
"hf thinfilm sim -d B70470726f786d61726b2e636f6d");
|
||||||
|
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_str1("d", "data", "<hex>", "bytes to send"),
|
||||||
|
arg_lit0(NULL, "raw", "raw, provided bytes should include CRC"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
|
int data_len = 0;
|
||||||
|
uint8_t data[512] = {0};
|
||||||
|
CLIGetHexWithReturn(ctx, 1, data, &data_len);
|
||||||
|
|
||||||
bool addcrc = true;
|
bool addcrc = true;
|
||||||
bool errors = false;
|
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
if (arg_get_lit(ctx, 2)) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
|
||||||
case 'h':
|
|
||||||
return usage_thinfilm_sim();
|
|
||||||
case 'd':
|
|
||||||
// Retrieve the data
|
|
||||||
param_gethex_ex(Cmd, cmdp + 1, data, &datalen);
|
|
||||||
datalen >>= 1;
|
|
||||||
cmdp += 2;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
addcrc = false;
|
addcrc = false;
|
||||||
cmdp++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validations
|
CLIParserFree(ctx);
|
||||||
if (errors || cmdp == 0 || datalen == 0 || datalen > 512) return usage_thinfilm_sim();
|
|
||||||
if (addcrc && datalen <= 510) {
|
if (addcrc && data_len <= 510) {
|
||||||
uint8_t b1, b2;
|
uint8_t b1, b2;
|
||||||
compute_crc(CRC_14443_A, data, datalen, &b1, &b2);
|
compute_crc(CRC_14443_A, data, data_len, &b1, &b2);
|
||||||
data[datalen++] = b2;
|
data[data_len++] = b2;
|
||||||
data[datalen++] = b1;
|
data[data_len++] = b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_HF_THINFILM_SIMULATE, (uint8_t *)&data, datalen);
|
SendCommandNG(CMD_HF_THINFILM_SIMULATE, (uint8_t *)&data, data_len);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,6 @@ hf mfu otptear
|
||||||
hf mfdes enum
|
hf mfdes enum
|
||||||
hf mfdes getuid
|
hf mfdes getuid
|
||||||
hf mfdes info
|
hf mfdes info
|
||||||
hf thinfilm info
|
|
||||||
hf thinfilm sim
|
|
||||||
hw connect
|
hw connect
|
||||||
hw dbg
|
hw dbg
|
||||||
hw detectreader
|
hw detectreader
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue