mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 23:36:31 +08:00
hf 14b sniff, sim, info, - now uses cliparser
This commit is contained in:
parent
19a458e31e
commit
01af87e6d7
|
@ -1126,11 +1126,10 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
break;
|
||||
}
|
||||
case CMD_HF_ISO14443B_SIMULATE: {
|
||||
SimulateIso14443bTag(packet->oldarg[0]);
|
||||
SimulateIso14443bTag(packet->data.asBytes);
|
||||
break;
|
||||
}
|
||||
case CMD_HF_ISO14443B_COMMAND: {
|
||||
//SendRawCommand14443B(packet->oldarg[0],packet->oldarg[1],packet->oldarg[2],packet->data.asBytes);
|
||||
SendRawCommand14443B_Ex(packet);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -530,7 +530,7 @@ static void TransmitFor14443b_AsTag(uint8_t *response, uint16_t len) {
|
|||
// Main loop of simulated tag: receive commands from reader, decide what
|
||||
// response to send, and send it.
|
||||
//-----------------------------------------------------------------------------
|
||||
void SimulateIso14443bTag(uint32_t pupi) {
|
||||
void SimulateIso14443bTag(uint8_t *pupi) {
|
||||
|
||||
LED_A_ON();
|
||||
// the only commands we understand is WUPB, AFI=0, Select All, N=1:
|
||||
|
@ -553,15 +553,15 @@ void SimulateIso14443bTag(uint32_t pupi) {
|
|||
0x5e, 0xd7
|
||||
};
|
||||
|
||||
// response to HLTB and ATTRIB
|
||||
static const uint8_t respOK[] = {0x00, 0x78, 0xF0};
|
||||
|
||||
// ...PUPI/UID supplied from user. Adjust ATQB response accordingly
|
||||
if (pupi > 0) {
|
||||
num_to_bytes(pupi, 4, respATQB + 1);
|
||||
if (memcmp("\x00\x00\x00\x00", pupi, 4) != 0) {
|
||||
memcpy(respATQB + 1, pupi, 4);
|
||||
AddCrc14B(respATQB, 12);
|
||||
}
|
||||
|
||||
// response to HLTB and ATTRIB
|
||||
static const uint8_t respOK[] = {0x00, 0x78, 0xF0};
|
||||
|
||||
// setup device.
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, uint8
|
|||
int iso14443b_select_card(iso14b_card_select_t *card);
|
||||
int iso14443b_select_card_srx(iso14b_card_select_t *card);
|
||||
|
||||
void SimulateIso14443bTag(uint32_t pupi);
|
||||
void SimulateIso14443bTag(uint8_t *pupi);
|
||||
void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
|
||||
void ReadSTMemoryIso14443b(uint16_t numofblocks);
|
||||
void SniffIso14443b(void);
|
||||
|
|
|
@ -34,35 +34,6 @@ bool apdu_in_framing_enable = true;
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int usage_hf_14b_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf 14b info [h] [s]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h this help");
|
||||
PrintAndLogEx(NORMAL, " s silently");
|
||||
PrintAndLogEx(NORMAL, "Example:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b info"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_14b_reader(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf 14b reader [h] [v]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h this help");
|
||||
PrintAndLogEx(NORMAL, " v verbose");
|
||||
PrintAndLogEx(NORMAL, "Example:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b reader"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_14b_sim(void) {
|
||||
PrintAndLogEx(NORMAL, "Emulating ISO/IEC 14443 type B tag with 4 UID / PUPI");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf 14b sim [h] u <uid>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h this help");
|
||||
PrintAndLogEx(NORMAL, " u 4byte UID/PUPI");
|
||||
PrintAndLogEx(NORMAL, "Example:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sim"));
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf 14b sim u 11223344"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_14b_read_srx(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf 14b sriread [h] <1|2>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -158,16 +129,29 @@ static int CmdHF14BList(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdHF14BSim(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_14b_sim();
|
||||
|
||||
uint32_t pupi = 0;
|
||||
if (cmdp == 'u') {
|
||||
pupi = param_get32ex(Cmd, 1, 0, 16);
|
||||
}
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b sim",
|
||||
"Simulate a ISO/IEC 14443 type B tag with 4 byte UID / PUPI",
|
||||
"hf 14b sim\n"
|
||||
"hf 14b sim -u 11AA33BB"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_strx0("u", "uid", "hex", "4byte UID/PUPI"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
|
||||
uint8_t pupi[4];
|
||||
int n = 0;
|
||||
CLIParamHexToBuf(arg_get_str(ctx, 1), pupi, sizeof(pupi), &n);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_ISO14443B_SIMULATE, pupi, 0, 0, NULL, 0);
|
||||
SendCommandNG(CMD_HF_ISO14443B_SIMULATE, pupi, sizeof(pupi));
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -722,10 +706,20 @@ static bool HF14B_ST_Info(bool verbose) {
|
|||
|
||||
// menu command to get and print all info known about any known 14b tag
|
||||
static int CmdHF14Binfo(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_14b_info();
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b info",
|
||||
"Tag information for ISO/IEC 14443 type B based tags",
|
||||
"hf 14b info\n"
|
||||
);
|
||||
|
||||
bool verbose = !(cmdp == 's');
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("v", "verbose", "verbose"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool verbose = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
return infoHF14B(verbose);
|
||||
}
|
||||
|
||||
|
@ -938,9 +932,20 @@ static bool HF14B_other_reader(bool verbose) {
|
|||
|
||||
// menu command to get and print general info about all known 14b chips
|
||||
static int CmdHF14BReader(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_14b_reader();
|
||||
bool verbose = (cmdp == 'v');
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf 14b reader",
|
||||
"Act as a 14443B reader to identify a tag",
|
||||
"hf 14b reader\n"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0("v", "verbose", "verbose"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
bool verbose = arg_get_lit(ctx, 1);
|
||||
CLIParserFree(ctx);
|
||||
return readHF14B(verbose);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue