2010-02-21 08:47:22 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
2018-02-15 06:03:39 +08:00
|
|
|
// Merlok - 2017
|
2019-12-22 18:16:59 +08:00
|
|
|
// Doegox - 2019
|
|
|
|
// Iceman - 2019
|
2020-01-12 23:45:24 +08:00
|
|
|
// Piwi - 2019
|
2010-02-21 08:47:22 +08:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// High frequency commands
|
|
|
|
//-----------------------------------------------------------------------------
|
2019-10-25 06:55:16 +08:00
|
|
|
#include "cmdhf.h"
|
2019-08-08 22:57:33 +08:00
|
|
|
|
2020-01-12 23:45:24 +08:00
|
|
|
#include <ctype.h> // tolower
|
|
|
|
#include "cmdparser.h" // command_t
|
2020-12-21 09:06:43 +08:00
|
|
|
#include "cliparser.h" // parse
|
2020-01-12 23:45:24 +08:00
|
|
|
#include "comms.h" // clearCommandBuffer
|
2020-01-13 00:13:02 +08:00
|
|
|
#include "lfdemod.h" // computeSignalProperties
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "cmdhf14a.h" // ISO14443-A
|
|
|
|
#include "cmdhf14b.h" // ISO14443-B
|
|
|
|
#include "cmdhf15.h" // ISO15693
|
|
|
|
#include "cmdhfepa.h"
|
2020-12-06 08:22:20 +08:00
|
|
|
#include "cmdhfemrtd.h" // eMRTD
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "cmdhflegic.h" // LEGIC
|
|
|
|
#include "cmdhficlass.h" // ICLASS
|
2021-02-12 05:08:51 +08:00
|
|
|
#include "cmdhfjooki.h" // MFU based Jooki
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "cmdhfmf.h" // CLASSIC
|
|
|
|
#include "cmdhfmfu.h" // ULTRALIGHT/NTAG etc
|
|
|
|
#include "cmdhfmfp.h" // Mifare Plus
|
|
|
|
#include "cmdhfmfdes.h" // DESFIRE
|
|
|
|
#include "cmdhftopaz.h" // TOPAZ
|
|
|
|
#include "cmdhffelica.h" // ISO18092 / FeliCa
|
|
|
|
#include "cmdhffido.h" // FIDO authenticators
|
2021-05-28 23:54:44 +08:00
|
|
|
#include "cmdhfcipurse.h" // CIPURSE transport cards
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "cmdhfthinfilm.h" // Thinfilm
|
2019-12-22 18:16:59 +08:00
|
|
|
#include "cmdhflto.h" // LTO-CM
|
2020-04-06 12:17:05 +08:00
|
|
|
#include "cmdhfcryptorf.h" // CryptoRF
|
2021-05-20 16:07:04 +08:00
|
|
|
#include "cmdhfseos.h" // SEOS
|
2021-05-30 20:55:58 +08:00
|
|
|
#include "cmdhfst25ta.h" // ST25TA
|
2020-09-13 01:38:29 +08:00
|
|
|
#include "cmdhfwaveshare.h" // Waveshare
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "cmdtrace.h" // trace list
|
|
|
|
#include "ui.h"
|
2020-05-03 06:33:28 +08:00
|
|
|
#include "proxgui.h"
|
2020-01-12 23:45:24 +08:00
|
|
|
#include "cmddata.h"
|
|
|
|
#include "graph.h"
|
2020-04-19 19:00:35 +08:00
|
|
|
#include "fpga.h"
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
|
|
|
static int CmdHelp(const char *Cmd);
|
|
|
|
|
2019-03-10 18:20:22 +08:00
|
|
|
int CmdHFSearch(const char *Cmd) {
|
2015-11-02 02:49:08 +08:00
|
|
|
|
2020-12-21 09:40:04 +08:00
|
|
|
CLIParserContext *ctx;
|
|
|
|
CLIParserInit(&ctx, "hf search",
|
|
|
|
"Will try to find a HF read out of the unknown tag.\n"
|
|
|
|
"Continues to search for all different HF protocols.",
|
2020-12-24 17:55:36 +08:00
|
|
|
"hf search"
|
2020-12-24 02:51:10 +08:00
|
|
|
);
|
2020-12-21 09:40:04 +08:00
|
|
|
void *argtable[] = {
|
|
|
|
arg_param_begin,
|
|
|
|
arg_param_end
|
|
|
|
};
|
|
|
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
2020-12-24 17:55:36 +08:00
|
|
|
CLIParserFree(ctx);
|
|
|
|
|
2020-04-16 15:01:14 +08:00
|
|
|
int res = PM3_ESOFT;
|
|
|
|
|
2019-10-18 03:58:57 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for ThinFilm tag...");
|
2019-08-04 04:14:04 +08:00
|
|
|
if (IfPm3NfcBarcode()) {
|
|
|
|
if (infoThinFilm(false) == PM3_SUCCESS) {
|
2020-04-22 08:22:55 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Thinfilm tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-08-04 04:14:04 +08:00
|
|
|
}
|
2019-08-01 21:39:33 +08:00
|
|
|
}
|
2019-09-09 19:15:55 +08:00
|
|
|
|
2019-12-22 18:16:59 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for LTO-CM tag...");
|
2019-12-22 18:16:59 +08:00
|
|
|
if (IfPm3Iso14443a()) {
|
|
|
|
if (infoLTO(false) == PM3_SUCCESS) {
|
2020-04-22 08:22:55 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LTO-CM tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-12-22 18:16:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 03:58:57 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for ISO14443-A tag...");
|
2019-08-04 04:14:04 +08:00
|
|
|
if (IfPm3Iso14443a()) {
|
2019-11-05 01:54:51 +08:00
|
|
|
if (infoHF14A(false, false, false) > 0) {
|
2021-04-16 06:00:02 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 14443-A tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2021-06-17 18:24:16 +08:00
|
|
|
|
|
|
|
infoHF14A4Applications();
|
2019-08-04 04:14:04 +08:00
|
|
|
}
|
2019-03-10 06:35:06 +08:00
|
|
|
}
|
2019-10-21 19:46:23 +08:00
|
|
|
|
2019-10-18 03:58:57 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for ISO15693 tag...");
|
2019-08-04 04:14:04 +08:00
|
|
|
if (IfPm3Iso15693()) {
|
2020-08-14 20:57:02 +08:00
|
|
|
if (readHF15Uid(false, false)) {
|
2021-04-16 06:00:02 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 15693 tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-08-04 04:14:04 +08:00
|
|
|
}
|
2019-03-10 06:35:06 +08:00
|
|
|
}
|
2019-09-09 19:15:55 +08:00
|
|
|
|
2020-07-14 00:20:43 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-07-29 17:02:30 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for iCLASS / PicoPass tag...");
|
2020-07-14 00:20:43 +08:00
|
|
|
if (IfPm3Iclass()) {
|
2020-07-29 17:02:30 +08:00
|
|
|
if (read_iclass_csn(false, false) == PM3_SUCCESS) {
|
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("iCLASS tag / PicoPass tag") " found\n");
|
2020-07-14 00:20:43 +08:00
|
|
|
res = PM3_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 03:58:57 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for LEGIC tag...");
|
2019-08-04 04:14:04 +08:00
|
|
|
if (IfPm3Legicrf()) {
|
2020-12-21 10:40:06 +08:00
|
|
|
if (readLegicUid(false, false) == PM3_SUCCESS) {
|
2020-04-22 08:22:55 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LEGIC Prime tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-08-04 04:14:04 +08:00
|
|
|
}
|
2019-03-10 06:35:06 +08:00
|
|
|
}
|
2019-09-09 19:15:55 +08:00
|
|
|
|
2019-10-18 03:58:57 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-06-27 05:31:32 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for Topaz tag...");
|
2019-08-04 04:14:04 +08:00
|
|
|
if (IfPm3Iso14443a()) {
|
2020-04-03 23:37:46 +08:00
|
|
|
if (readTopazUid(false) == PM3_SUCCESS) {
|
2020-04-22 08:22:55 +08:00
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Topaz tag") " found\n");
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-08-04 04:14:04 +08:00
|
|
|
}
|
2019-03-10 06:35:06 +08:00
|
|
|
}
|
2021-06-04 00:13:11 +08:00
|
|
|
|
2021-04-24 04:25:58 +08:00
|
|
|
// 14b is the longest test
|
2021-04-14 14:15:30 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2021-04-24 04:25:58 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for ISO14443-B tag...");
|
|
|
|
if (IfPm3Iso14443b()) {
|
|
|
|
if (readHF14B(false, false) == PM3_SUCCESS) {
|
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 14443-B tag") " found\n");
|
2021-04-14 14:15:30 +08:00
|
|
|
res = PM3_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 17:54:13 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2021-04-24 04:25:58 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for FeliCa tag...");
|
|
|
|
if (IfPm3Felica()) {
|
|
|
|
if (read_felica_uid(false, false) == PM3_SUCCESS) {
|
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 18092 / FeliCa tag") " found\n");
|
2020-08-15 17:54:13 +08:00
|
|
|
res = PM3_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-24 04:25:58 +08:00
|
|
|
|
2021-04-03 21:44:13 +08:00
|
|
|
/*
|
2021-03-27 20:23:01 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2021-04-14 14:15:30 +08:00
|
|
|
PrintAndLogEx(INPLACE, " Searching for CryptoRF tag...");
|
|
|
|
if (IfPm3Iso14443b()) {
|
|
|
|
if (readHFCryptoRF(false, false) == PM3_SUCCESS) {
|
|
|
|
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") " found\n");
|
2021-03-27 20:23:01 +08:00
|
|
|
res = PM3_SUCCESS;
|
2019-10-18 03:58:57 +08:00
|
|
|
}
|
2021-03-27 20:23:01 +08:00
|
|
|
}
|
2020-04-16 15:01:14 +08:00
|
|
|
*/
|
2019-10-18 03:58:57 +08:00
|
|
|
|
2019-12-14 19:56:19 +08:00
|
|
|
PROMPT_CLEARLINE;
|
2020-04-03 23:37:46 +08:00
|
|
|
if (res != PM3_SUCCESS) {
|
2020-09-06 23:41:55 +08:00
|
|
|
PrintAndLogEx(WARNING, _RED_("No known/supported 13.56 MHz tags found"));
|
2020-04-03 23:37:46 +08:00
|
|
|
res = PM3_ESOFT;
|
|
|
|
}
|
2020-08-29 01:24:10 +08:00
|
|
|
|
2020-12-22 03:50:47 +08:00
|
|
|
DropField();
|
2020-04-03 23:37:46 +08:00
|
|
|
return res;
|
2015-05-13 00:57:47 +08:00
|
|
|
}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2019-03-10 18:20:22 +08:00
|
|
|
int CmdHFTune(const char *Cmd) {
|
2020-12-21 09:06:43 +08:00
|
|
|
|
|
|
|
CLIParserContext *ctx;
|
|
|
|
CLIParserInit(&ctx, "hf tune",
|
|
|
|
"Continuously measure HF antenna tuning.\n"
|
|
|
|
"Press button or <Enter> to interrupt.",
|
|
|
|
"hf tune\n"
|
2020-12-21 19:55:36 +08:00
|
|
|
"hf tune --mix"
|
2020-12-21 09:06:43 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
void *argtable[] = {
|
|
|
|
arg_param_begin,
|
|
|
|
arg_u64_0("n", "iter", "<dec>", "number of iterations (default: 0=infinite)"),
|
|
|
|
arg_lit0(NULL, "bar", "bar style"),
|
|
|
|
arg_lit0(NULL, "mix", "mixed style"),
|
|
|
|
arg_lit0(NULL, "value", "values style"),
|
|
|
|
arg_param_end
|
|
|
|
};
|
|
|
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
|
|
|
uint32_t iter = arg_get_u32_def(ctx, 1, 0);
|
|
|
|
bool is_bar = arg_get_lit(ctx, 2);
|
|
|
|
bool is_mix = arg_get_lit(ctx, 3);
|
|
|
|
bool is_value = arg_get_lit(ctx, 4);
|
|
|
|
CLIParserFree(ctx);
|
|
|
|
|
|
|
|
if ((is_bar + is_mix + is_value) > 1) {
|
|
|
|
PrintAndLogEx(ERR, "Select only one output style");
|
|
|
|
return PM3_EINVARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
barMode_t style = session.bar_mode;
|
|
|
|
if (is_bar)
|
|
|
|
style = STYLE_BAR;
|
|
|
|
if (is_mix)
|
|
|
|
style = STYLE_MIXED;
|
|
|
|
if (is_value)
|
|
|
|
style = STYLE_VALUE;
|
2019-05-14 06:36:58 +08:00
|
|
|
|
2020-04-22 08:22:55 +08:00
|
|
|
PrintAndLogEx(INFO, "Measuring HF antenna, click " _GREEN_("pm3 button") " or press " _GREEN_("Enter") " to exit");
|
2019-05-03 14:40:21 +08:00
|
|
|
PacketResponseNG resp;
|
2019-05-14 06:36:58 +08:00
|
|
|
clearCommandBuffer();
|
2020-02-24 16:44:48 +08:00
|
|
|
|
2019-05-14 14:25:26 +08:00
|
|
|
uint8_t mode[] = {1};
|
|
|
|
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
|
2019-08-07 18:41:53 +08:00
|
|
|
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000)) {
|
2019-05-14 14:25:26 +08:00
|
|
|
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF initialization, aborting");
|
2019-05-14 06:36:58 +08:00
|
|
|
return PM3_ETIMEOUT;
|
|
|
|
}
|
2020-02-24 16:44:48 +08:00
|
|
|
|
2019-05-14 14:25:26 +08:00
|
|
|
mode[0] = 2;
|
2020-12-21 09:06:43 +08:00
|
|
|
|
|
|
|
uint32_t max = 0xFFFF;
|
|
|
|
bool first = true;
|
|
|
|
|
2020-12-23 08:12:35 +08:00
|
|
|
print_progress(0, max, style);
|
2020-12-21 09:06:43 +08:00
|
|
|
|
2019-05-14 14:25:26 +08:00
|
|
|
// loop forever (till button pressed) if iter = 0 (default)
|
2019-05-14 23:42:17 +08:00
|
|
|
for (uint8_t i = 0; iter == 0 || i < iter; i++) {
|
2020-02-24 16:44:48 +08:00
|
|
|
if (kbd_enter_pressed()) {
|
2019-05-14 14:40:16 +08:00
|
|
|
break;
|
|
|
|
}
|
2020-02-24 16:44:48 +08:00
|
|
|
|
2019-05-14 14:25:26 +08:00
|
|
|
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
|
2019-08-07 18:41:53 +08:00
|
|
|
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000)) {
|
2020-02-24 16:44:48 +08:00
|
|
|
PrintAndLogEx(NORMAL, "");
|
2019-05-14 06:36:58 +08:00
|
|
|
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF measure, aborting");
|
2020-12-21 09:06:43 +08:00
|
|
|
break;
|
2019-05-14 06:36:58 +08:00
|
|
|
}
|
2020-02-24 16:44:48 +08:00
|
|
|
|
|
|
|
if ((resp.status == PM3_EOPABORTED) || (resp.length != sizeof(uint16_t))) {
|
2020-12-21 09:06:43 +08:00
|
|
|
PrintAndLogEx(NORMAL, "");
|
2019-05-14 06:36:58 +08:00
|
|
|
break;
|
2020-02-24 16:44:48 +08:00
|
|
|
}
|
|
|
|
|
2019-08-07 18:58:25 +08:00
|
|
|
uint16_t volt = resp.data.asDwords[0] & 0xFFFF;
|
2020-12-21 09:06:43 +08:00
|
|
|
if (first) {
|
|
|
|
max = (volt * 1.03);
|
|
|
|
first = false;
|
|
|
|
}
|
2020-12-24 02:51:10 +08:00
|
|
|
if (volt > max) {
|
2020-12-21 09:06:43 +08:00
|
|
|
max = (volt * 1.03);
|
|
|
|
}
|
|
|
|
print_progress(volt, max, style);
|
2019-05-14 06:36:58 +08:00
|
|
|
}
|
2019-05-14 14:25:26 +08:00
|
|
|
mode[0] = 3;
|
2020-02-24 16:44:48 +08:00
|
|
|
|
2019-05-14 14:25:26 +08:00
|
|
|
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode));
|
2019-08-07 18:41:53 +08:00
|
|
|
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000)) {
|
2019-05-14 14:25:26 +08:00
|
|
|
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF shutdown, aborting");
|
2019-05-03 14:40:21 +08:00
|
|
|
return PM3_ETIMEOUT;
|
|
|
|
}
|
2020-12-21 09:06:43 +08:00
|
|
|
PrintAndLogEx(NORMAL, "\x1b%c[2K\r", 30);
|
2020-03-16 05:41:05 +08:00
|
|
|
PrintAndLogEx(INFO, "Done.");
|
2019-05-03 14:40:21 +08:00
|
|
|
return PM3_SUCCESS;
|
2018-02-15 06:03:39 +08:00
|
|
|
}
|
|
|
|
|
2020-06-20 00:34:47 +08:00
|
|
|
// Collects pars of u8,
|
2020-06-18 17:54:19 +08:00
|
|
|
// uses 16bit transfers from FPGA for speed
|
|
|
|
// Takes all available bigbuff memory
|
|
|
|
// data sample to download? Not sure what we can do with the data.
|
2019-03-11 21:55:02 +08:00
|
|
|
int CmdHFSniff(const char *Cmd) {
|
2020-12-21 09:06:43 +08:00
|
|
|
|
|
|
|
CLIParserContext *ctx;
|
|
|
|
CLIParserInit(&ctx, "hf sniff",
|
2020-12-21 09:40:04 +08:00
|
|
|
"The high frequency sniffer will assign all available memory on device for sniffed data.\n"
|
2020-12-21 09:06:43 +08:00
|
|
|
"Use `data samples` to download from device and `data plot` to visualize it.\n"
|
|
|
|
"Press button to quit the sniffing.",
|
|
|
|
"hf sniff\n"
|
|
|
|
"hf sniff --sp 1000 --st 0 -> skip 1000 pairs, skip 0 triggers"
|
2020-12-24 02:51:10 +08:00
|
|
|
);
|
2020-12-21 09:06:43 +08:00
|
|
|
void *argtable[] = {
|
|
|
|
arg_param_begin,
|
|
|
|
arg_u64_0(NULL, "sp", "<dec>", "skip sample pairs"),
|
|
|
|
arg_u64_0(NULL, "st", "<dec>", "skip number of triggers"),
|
|
|
|
arg_param_end
|
|
|
|
};
|
|
|
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
2019-03-09 15:59:13 +08:00
|
|
|
|
2020-06-18 17:54:19 +08:00
|
|
|
struct {
|
|
|
|
uint32_t samplesToSkip;
|
|
|
|
uint32_t triggersToSkip;
|
|
|
|
} PACKED params;
|
|
|
|
|
2020-12-21 09:06:43 +08:00
|
|
|
params.samplesToSkip = arg_get_u32_def(ctx, 1, 0);
|
|
|
|
params.triggersToSkip = arg_get_u32_def(ctx, 2, 0);
|
|
|
|
CLIParserFree(ctx);
|
2019-03-09 15:59:13 +08:00
|
|
|
|
2019-03-10 06:35:06 +08:00
|
|
|
clearCommandBuffer();
|
2020-06-20 00:34:47 +08:00
|
|
|
SendCommandNG(CMD_HF_SNIFF, (uint8_t *)¶ms, sizeof(params));
|
2020-06-18 17:54:19 +08:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
if (kbd_enter_pressed()) {
|
2020-06-22 00:13:14 +08:00
|
|
|
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
2020-06-18 17:54:19 +08:00
|
|
|
PrintAndLogEx(INFO, "User aborted");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
PacketResponseNG resp;
|
2020-06-22 00:13:14 +08:00
|
|
|
if (WaitForResponseTimeout(CMD_HF_SNIFF, &resp, 1000)) {
|
2020-06-18 17:54:19 +08:00
|
|
|
|
|
|
|
if (resp.status == PM3_EOPABORTED) {
|
2020-06-22 00:13:14 +08:00
|
|
|
PrintAndLogEx(INFO, "Button pressed, user aborted");
|
2020-06-18 17:54:19 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (resp.status == PM3_SUCCESS) {
|
|
|
|
|
2020-06-22 00:13:14 +08:00
|
|
|
struct r {
|
|
|
|
uint16_t len;
|
|
|
|
} PACKED;
|
|
|
|
struct r *retval = (struct r *)resp.data.asBytes;
|
2020-08-13 18:25:04 +08:00
|
|
|
|
2020-06-22 00:13:14 +08:00
|
|
|
PrintAndLogEx(INFO, "HF sniff (%u samples)", retval->len);
|
|
|
|
|
|
|
|
PrintAndLogEx(HINT, "Use `" _YELLOW_("data hpf") "` to remove offset");
|
2020-06-18 17:54:19 +08:00
|
|
|
PrintAndLogEx(HINT, "Use `" _YELLOW_("data plot") "` to view");
|
|
|
|
PrintAndLogEx(HINT, "Use `" _YELLOW_("data save") "` to save");
|
2020-06-20 00:34:47 +08:00
|
|
|
|
2020-08-13 18:25:04 +08:00
|
|
|
// download bigbuf_malloc:d.
|
2020-06-22 00:13:14 +08:00
|
|
|
// it reserve memory from the higher end.
|
2020-08-13 18:25:04 +08:00
|
|
|
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
2020-06-22 00:13:14 +08:00
|
|
|
// we can't start from beginning idx 0 but from that hi-to-start-of-allocated.
|
|
|
|
uint32_t start = pm3_capabilities.bigbuf_size - retval->len;
|
|
|
|
int res = getSamplesEx(start, start, false);
|
2020-06-18 17:54:19 +08:00
|
|
|
if (res != PM3_SUCCESS) {
|
|
|
|
PrintAndLogEx(WARNING, "failed to download samples to client");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrintAndLogEx(INFO, "Done.");
|
2019-08-04 05:36:55 +08:00
|
|
|
return PM3_SUCCESS;
|
2015-10-28 04:47:21 +08:00
|
|
|
}
|
|
|
|
|
2020-10-24 17:56:47 +08:00
|
|
|
int handle_hf_plot(void) {
|
2020-11-02 08:46:47 +08:00
|
|
|
|
2020-01-13 00:28:12 +08:00
|
|
|
uint8_t buf[FPGA_TRACE_SIZE];
|
|
|
|
|
2020-01-12 23:45:24 +08:00
|
|
|
PacketResponseNG response;
|
|
|
|
if (!GetFromDevice(FPGA_MEM, buf, FPGA_TRACE_SIZE, 0, NULL, 0, &response, 4000, true)) {
|
|
|
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
|
|
|
return PM3_ETIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) {
|
2020-10-24 17:56:47 +08:00
|
|
|
GraphBuffer[i] = ((int)buf[i]) - 128;
|
2020-01-12 23:45:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphTraceLen = FPGA_TRACE_SIZE;
|
2020-01-13 00:13:02 +08:00
|
|
|
|
2020-01-12 23:45:24 +08:00
|
|
|
ShowGraphWindow();
|
2020-01-13 00:13:02 +08:00
|
|
|
|
|
|
|
// remove signal offset
|
|
|
|
CmdHpf("");
|
|
|
|
|
|
|
|
setClockGrid(0, 0);
|
|
|
|
DemodBufferLen = 0;
|
2020-01-12 23:45:24 +08:00
|
|
|
RepaintGraphWindow();
|
2020-01-13 00:28:12 +08:00
|
|
|
return PM3_SUCCESS;
|
2020-01-12 23:45:24 +08:00
|
|
|
}
|
|
|
|
|
2020-10-24 17:56:47 +08:00
|
|
|
int CmdHFPlot(const char *Cmd) {
|
|
|
|
CLIParserContext *ctx;
|
|
|
|
CLIParserInit(&ctx, "hf plot",
|
|
|
|
"Plots HF signal after RF signal path and A/D conversion.",
|
|
|
|
"This can be used after any hf command and will show the last few milliseconds of the HF signal.\n"
|
|
|
|
"Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n");
|
|
|
|
void *argtable[] = {
|
|
|
|
arg_param_begin,
|
|
|
|
arg_param_end
|
|
|
|
};
|
|
|
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
|
|
|
CLIParserFree(ctx);
|
|
|
|
|
|
|
|
return handle_hf_plot();
|
|
|
|
}
|
|
|
|
|
2021-04-20 03:43:32 +08:00
|
|
|
static int CmdHFList(const char *Cmd) {
|
|
|
|
return CmdTraceListAlias(Cmd, "hf", "raw");
|
|
|
|
}
|
|
|
|
|
2016-03-06 17:35:25 +08:00
|
|
|
static command_t CommandTable[] = {
|
2020-11-02 08:46:47 +08:00
|
|
|
|
2020-10-23 04:16:44 +08:00
|
|
|
{"--------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("High Frequency") " -----------------------"},
|
2020-12-06 08:22:20 +08:00
|
|
|
{"14a", CmdHF14A, AlwaysAvailable, "{ ISO14443A RFIDs... }"},
|
|
|
|
{"14b", CmdHF14B, AlwaysAvailable, "{ ISO14443B RFIDs... }"},
|
|
|
|
{"15", CmdHF15, AlwaysAvailable, "{ ISO15693 RFIDs... }"},
|
|
|
|
// {"cryptorf", CmdHFCryptoRF, AlwaysAvailable, "{ CryptoRF RFIDs... }"},
|
2021-05-28 23:54:44 +08:00
|
|
|
{"cipurse", CmdHFCipurse, AlwaysAvailable, "{ Cipurse transport Cards... }"},
|
2020-12-06 08:22:20 +08:00
|
|
|
{"epa", CmdHFEPA, AlwaysAvailable, "{ German Identification Card... }"},
|
|
|
|
{"emrtd", CmdHFeMRTD, AlwaysAvailable, "{ Machine Readable Travel Document... }"},
|
|
|
|
{"felica", CmdHFFelica, AlwaysAvailable, "{ ISO18092 / FeliCa RFIDs... }"},
|
|
|
|
{"fido", CmdHFFido, AlwaysAvailable, "{ FIDO and FIDO2 authenticators... }"},
|
2021-02-12 05:08:51 +08:00
|
|
|
{"jooki", CmdHF_Jooki, AlwaysAvailable, "{ Jooki RFIDs... }"},
|
2020-12-06 08:22:20 +08:00
|
|
|
{"iclass", CmdHFiClass, AlwaysAvailable, "{ ICLASS RFIDs... }"},
|
|
|
|
{"legic", CmdHFLegic, AlwaysAvailable, "{ LEGIC RFIDs... }"},
|
|
|
|
{"lto", CmdHFLTO, AlwaysAvailable, "{ LTO Cartridge Memory RFIDs... }"},
|
|
|
|
{"mf", CmdHFMF, AlwaysAvailable, "{ MIFARE RFIDs... }"},
|
|
|
|
{"mfp", CmdHFMFP, AlwaysAvailable, "{ MIFARE Plus RFIDs... }"},
|
|
|
|
{"mfu", CmdHFMFUltra, AlwaysAvailable, "{ MIFARE Ultralight RFIDs... }"},
|
|
|
|
{"mfdes", CmdHFMFDes, AlwaysAvailable, "{ MIFARE Desfire RFIDs... }"},
|
2021-05-20 16:07:04 +08:00
|
|
|
{"seos", CmdHFSeos, AlwaysAvailable, "{ SEOS RFIDs... }"},
|
2021-05-30 20:55:58 +08:00
|
|
|
{"st25ta", CmdHFST25TA, AlwaysAvailable, "{ ST25TA RFIDs... }"},
|
2020-12-06 08:22:20 +08:00
|
|
|
{"thinfilm", CmdHFThinfilm, AlwaysAvailable, "{ Thinfilm RFIDs... }"},
|
|
|
|
{"topaz", CmdHFTopaz, AlwaysAvailable, "{ TOPAZ (NFC Type 1) RFIDs... }"},
|
|
|
|
{"waveshare", CmdHFWaveshare, AlwaysAvailable, "{ Waveshare NFC ePaper... }"},
|
2020-11-02 08:46:47 +08:00
|
|
|
{"-----------", CmdHelp, AlwaysAvailable, "--------------------- " _CYAN_("General") " ---------------------"},
|
2020-10-23 04:16:44 +08:00
|
|
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
2021-04-20 03:43:32 +08:00
|
|
|
{"list", CmdHFList, AlwaysAvailable, "List protocol data in trace buffer"},
|
2020-01-12 23:45:24 +08:00
|
|
|
{"plot", CmdHFPlot, IfPm3Hfplot, "Plot signal"},
|
2019-05-02 02:48:15 +08:00
|
|
|
{"tune", CmdHFTune, IfPm3Present, "Continuously measure HF antenna tuning"},
|
2019-09-09 19:15:55 +08:00
|
|
|
{"search", CmdHFSearch, AlwaysAvailable, "Search for known HF tags"},
|
2021-01-05 06:06:06 +08:00
|
|
|
{"sniff", CmdHFSniff, IfPm3Hfsniff, "Generic HF Sniff"},
|
2019-05-02 02:48:15 +08:00
|
|
|
{NULL, NULL, NULL, NULL}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
};
|
|
|
|
|
2019-03-10 18:20:22 +08:00
|
|
|
int CmdHF(const char *Cmd) {
|
2019-03-10 06:35:06 +08:00
|
|
|
clearCommandBuffer();
|
2019-04-19 06:47:51 +08:00
|
|
|
return CmdsParse(CommandTable, Cmd);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
}
|
|
|
|
|
2019-03-10 18:20:22 +08:00
|
|
|
int CmdHelp(const char *Cmd) {
|
2019-04-10 18:23:40 +08:00
|
|
|
(void)Cmd; // Cmd is not used so far
|
2019-03-10 06:35:06 +08:00
|
|
|
CmdsHelp(CommandTable);
|
2019-08-04 05:36:55 +08:00
|
|
|
return PM3_SUCCESS;
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
}
|