This commit is contained in:
iceman1001 2021-04-16 17:10:08 +02:00
parent 5775a283e9
commit d2646122e7
16 changed files with 404 additions and 404 deletions

View file

@ -309,9 +309,9 @@ void save_restoreDB(uint8_t saveOpt) {
static int CmdSetDebugMode(const char *Cmd) { static int CmdSetDebugMode(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data setdebugmode", CLIParserInit(&ctx, "data setdebugmode",
"Set debugging level on client side", "Set debugging level on client side",
"data setdebugmode" "data setdebugmode"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("0", NULL, "no debug messages"), arg_lit0("0", NULL, "no debug messages"),
@ -326,7 +326,7 @@ static int CmdSetDebugMode(const char *Cmd) {
bool dg_2 = arg_get_lit(ctx, 3); bool dg_2 = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
if (dg_0 + dg_1 + dg_2 > 1 ) { if (dg_0 + dg_1 + dg_2 > 1) {
PrintAndLogEx(INFO, "Select only one option"); PrintAndLogEx(INFO, "Select only one option");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -339,7 +339,7 @@ static int CmdSetDebugMode(const char *Cmd) {
if (dg_2) if (dg_2)
g_debugMode = 2; g_debugMode = 2;
switch(g_debugMode) { switch (g_debugMode) {
case 0: case 0:
PrintAndLogEx(INFO, "client debug level... %u ( no debug messages )", g_debugMode); PrintAndLogEx(INFO, "client debug level... %u ( no debug messages )", g_debugMode);
break; break;
@ -428,15 +428,15 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
int CmdPrintDemodBuff(const char *Cmd) { int CmdPrintDemodBuff(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data print", CLIParserInit(&ctx, "data print",
"Print the data in the DemodBuffer as hex or binary.\n" "Print the data in the DemodBuffer as hex or binary.\n"
"Defaults to binary output", "Defaults to binary output",
"data print" "data print"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("i", "inv", "invert Demodbuffer before printing"), arg_lit0("i", "inv", "invert Demodbuffer before printing"),
// arg_int0("l","len", "<dec>", "length to print in # of bits or hex characters respectively"), // arg_int0("l","len", "<dec>", "length to print in # of bits or hex characters respectively"),
arg_int0("o","offset", "<dec>", "offset in # of bits"), arg_int0("o", "offset", "<dec>", "offset in # of bits"),
arg_lit0("s", "strip", "strip leading zeroes, i.e. set offset to first bit equal to one"), arg_lit0("s", "strip", "strip leading zeroes, i.e. set offset to first bit equal to one"),
arg_lit0("x", "hex", "output in hex (omit for binary output)"), arg_lit0("x", "hex", "output in hex (omit for binary output)"),
arg_param_end arg_param_end
@ -458,11 +458,11 @@ int CmdPrintDemodBuff(const char *Cmd) {
int CmdGetBitStream(const char *Cmd) { int CmdGetBitStream(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data getbitstream", CLIParserInit(&ctx, "data getbitstream",
"Convert GraphBuffer's value accordingly\n" "Convert GraphBuffer's value accordingly\n"
" - larger or equal to ONE becomes ONE\n" " - larger or equal to ONE becomes ONE\n"
" - less than ONE becomes ZERO", " - less than ONE becomes ZERO",
"data getbitstream" "data getbitstream"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -482,9 +482,9 @@ static int CmdConvertBitStream(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data convertbitstream", CLIParserInit(&ctx, "data convertbitstream",
"Convert GraphBuffer's 0|1 values to 127|-127", "Convert GraphBuffer's 0|1 values to 127|-127",
"data convertbitstream" "data convertbitstream"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -644,11 +644,11 @@ static int Cmdaskmandemod(const char *Cmd) {
static int Cmdmandecoderaw(const char *Cmd) { static int Cmdmandecoderaw(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data manrawdecode", CLIParserInit(&ctx, "data manrawdecode",
"Manchester decode binary stream in DemodBuffer\n" "Manchester decode binary stream in DemodBuffer\n"
"Converts 10 and 01 and converts to 0 and 1 respectively\n" "Converts 10 and 01 and converts to 0 and 1 respectively\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)", " - must have binary sequence in demodbuffer (run `data rawdemod ar` before)",
"data manrawdecode" "data manrawdecode"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("i", "inv", "invert output"), arg_lit0("i", "inv", "invert output"),
@ -726,13 +726,13 @@ static int Cmdmandecoderaw(const char *Cmd) {
static int CmdBiphaseDecodeRaw(const char *Cmd) { static int CmdBiphaseDecodeRaw(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data biphaserawdecode", CLIParserInit(&ctx, "data biphaserawdecode",
"Biphase decode binary stream in DemodBuffer\n" "Biphase decode binary stream in DemodBuffer\n"
"Converts 10 or 01 -> 1 and 11 or 00 -> 0\n" "Converts 10 or 01 -> 1 and 11 or 00 -> 0\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)\n" " - must have binary sequence in demodbuffer (run `data rawdemod ar` before)\n"
" - invert for Conditional Dephase Encoding (CDP) AKA Differential Manchester", " - invert for Conditional Dephase Encoding (CDP) AKA Differential Manchester",
"data biphaserawdecode --> decode biphase bitstream from the demodbuffer\n" "data biphaserawdecode --> decode biphase bitstream from the demodbuffer\n"
"data biphaserawdecode -oi --> decode biphase bitstream from the demodbuffer, adjust offset, and invert output" "data biphaserawdecode -oi --> decode biphase bitstream from the demodbuffer, adjust offset, and invert output"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("o", "offset", "set to adjust decode start position"), arg_lit0("o", "offset", "set to adjust decode start position"),
@ -942,11 +942,11 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
static int CmdAutoCorr(const char *Cmd) { static int CmdAutoCorr(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data autocorr", CLIParserInit(&ctx, "data autocorr",
"Autocorrelate over window is used to detect repeating sequences.\n" "Autocorrelate over window is used to detect repeating sequences.\n"
"We use it as detection of how long in bits a message inside the signal is", "We use it as detection of how long in bits a message inside the signal is",
"data autocorr -w 4000\n" "data autocorr -w 4000\n"
"data autocorr -w 4000 -g" "data autocorr -w 4000 -g"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("g", NULL, "save back to GraphBuffer (overwrite)"), arg_lit0("g", NULL, "save back to GraphBuffer (overwrite)"),
@ -979,9 +979,9 @@ static int CmdBitsamples(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data bitsamples", CLIParserInit(&ctx, "data bitsamples",
"Get raw samples from device as bitstring", "Get raw samples from device as bitstring",
"data bitsamples" "data bitsamples"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -1013,10 +1013,10 @@ static int CmdBitsamples(const char *Cmd) {
static int CmdBuffClear(const char *Cmd) { static int CmdBuffClear(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data clear", CLIParserInit(&ctx, "data clear",
"This function clears the bigbuff on deviceside\n" "This function clears the bigbuff on deviceside\n"
"and graph window", "and graph window",
"data clear" "data clear"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -1105,10 +1105,10 @@ static int CmdGraphShiftZero(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data shiftgraphzero", CLIParserInit(&ctx, "data shiftgraphzero",
"Shift 0 for Graphed wave + or - shift value", "Shift 0 for Graphed wave + or - shift value",
"data shiftgraphzero -n 10 --> shift 10 points\n" "data shiftgraphzero -n 10 --> shift 10 points\n"
"data shiftgraphzero -n -22 --> shift negative 22 points" "data shiftgraphzero -n -22 --> shift negative 22 points"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int1("n", NULL, "<dec>", "shift + or -"), arg_int1("n", NULL, "<dec>", "shift + or -"),
@ -1150,10 +1150,10 @@ static int CmdAskEdgeDetect(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data askedgedetect", CLIParserInit(&ctx, "data askedgedetect",
"Adjust Graph for manual ASK demod using the length of sample differences\n" "Adjust Graph for manual ASK demod using the length of sample differences\n"
"to detect the edge of a wave", "to detect the edge of a wave",
"data askedgedetect -t 20" "data askedgedetect -t 20"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("t", "thres", "<dec>", "threshold, use 20 - 45 (def 25)"), arg_int0("t", "thres", "<dec>", "threshold, use 20 - 45 (def 25)"),
@ -1175,12 +1175,12 @@ static int CmdAskEdgeDetect(const char *Cmd) {
static int CmdDetectClockRate(const char *Cmd) { static int CmdDetectClockRate(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data detectclock", CLIParserInit(&ctx, "data detectclock",
"Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer", "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer",
"data detectclock -A --> detect clock of an ask wave in GraphBuffer\n" "data detectclock -A --> detect clock of an ask wave in GraphBuffer\n"
"data detectclock -F --> detect clock of an fsk wave in GraphBuffer\n" "data detectclock -F --> detect clock of an fsk wave in GraphBuffer\n"
"data detectclock -N --> detect clock of an psk wave in GraphBuffer\n" "data detectclock -N --> detect clock of an psk wave in GraphBuffer\n"
"data detectclock -P --> detect clock of an nrz/direct wave in GraphBuffer" "data detectclock -P --> detect clock of an nrz/direct wave in GraphBuffer"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("A", "ASK", "specify ASK modulation clock detection"), arg_lit0("A", "ASK", "specify ASK modulation clock detection"),
@ -1538,11 +1538,11 @@ void setClockGrid(uint32_t clk, int offset) {
int CmdGrid(const char *Cmd) { int CmdGrid(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data grid", CLIParserInit(&ctx, "data grid",
"This function overlay grid on graph plot window.\n" "This function overlay grid on graph plot window.\n"
"use zero value to turn off either", "use zero value to turn off either",
"data grid --> turn off\n" "data grid --> turn off\n"
"data grid -x 64 -y 50" "data grid -x 64 -y 50"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_dbl0("x", NULL, "<dec>", "plot grid X coord"), arg_dbl0("x", NULL, "<dec>", "plot grid X coord"),
@ -1563,10 +1563,10 @@ int CmdGrid(const char *Cmd) {
static int CmdSetGraphMarkers(const char *Cmd) { static int CmdSetGraphMarkers(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data setgraphmarkers", CLIParserInit(&ctx, "data setgraphmarkers",
"Set blue and orange marker in graph window", "Set blue and orange marker in graph window",
"data setgraphmarkers --> turn off\n" "data setgraphmarkers --> turn off\n"
"data setgraphmarkers -a 64 -b 50" "data setgraphmarkers -a 64 -b 50"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_0("a", NULL, "<dec>", "orange marker"), arg_u64_0("a", NULL, "<dec>", "orange marker"),
@ -1586,9 +1586,9 @@ static int CmdHexsamples(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data hexsamples", CLIParserInit(&ctx, "data hexsamples",
"Dump big buffer as hex bytes", "Dump big buffer as hex bytes",
"data hexsamples -n 128 --> dumps 128 bytes from offset 0" "data hexsamples -n 128 --> dumps 128 bytes from offset 0"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_0("b", "breaks", "<dec>", "row break, def 16"), arg_u64_0("b", "breaks", "<dec>", "row break, def 16"),
@ -1611,10 +1611,10 @@ static int CmdHexsamples(const char *Cmd) {
uint8_t got[pm3_capabilities.bigbuf_size]; uint8_t got[pm3_capabilities.bigbuf_size];
if (offset + requested > sizeof(got)) { if (offset + requested > sizeof(got)) {
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes %u> + <offset %u> > %d" PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes %u> + <offset %u> > %d"
, requested , requested
, offset , offset
, pm3_capabilities.bigbuf_size , pm3_capabilities.bigbuf_size
); );
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -1630,9 +1630,9 @@ static int CmdHexsamples(const char *Cmd) {
static int CmdHide(const char *Cmd) { static int CmdHide(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data hide", CLIParserInit(&ctx, "data hide",
"Show graph window", "Show graph window",
"data hide" "data hide"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -1647,9 +1647,9 @@ static int CmdHide(const char *Cmd) {
int CmdHpf(const char *Cmd) { int CmdHpf(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data hpf", CLIParserInit(&ctx, "data hpf",
"Remove DC offset from trace. It should centralize around 0", "Remove DC offset from trace. It should centralize around 0",
"data hpf" "data hpf"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -1762,13 +1762,13 @@ static int CmdSamples(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data samples", CLIParserInit(&ctx, "data samples",
"Get raw samples for graph window (GraphBuffer) from device.\n" "Get raw samples for graph window (GraphBuffer) from device.\n"
"If 0, then get whole big buffer from device.", "If 0, then get whole big buffer from device.",
"data samples" "data samples"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("n","", "<dec>", "num of samples (512 - 40000)"), arg_int0("n", "", "<dec>", "num of samples (512 - 40000)"),
arg_lit0("v", "verbose", "verbose"), arg_lit0("v", "verbose", "verbose"),
arg_param_end arg_param_end
}; };
@ -1783,11 +1783,11 @@ int CmdTuneSamples(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data tune", CLIParserInit(&ctx, "data tune",
"Measure tuning of device antenna. Results shown in graph window.\n" "Measure tuning of device antenna. Results shown in graph window.\n"
"This command doesn't actively tune your antennas, \n" "This command doesn't actively tune your antennas, \n"
"it's only informative by measuring voltage that the antennas will generate", "it's only informative by measuring voltage that the antennas will generate",
"data tune" "data tune"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -2038,9 +2038,9 @@ static int CmdLoad(const char *Cmd) {
int CmdLtrim(const char *Cmd) { int CmdLtrim(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data ltrim", CLIParserInit(&ctx, "data ltrim",
"Trim samples from left of trace", "Trim samples from left of trace",
"data ltrim -i 300 --> keep 300 - end" "data ltrim -i 300 --> keep 300 - end"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_1("i", "idx", "<dec>", "from index to beginning trace"), arg_u64_1("i", "idx", "<dec>", "from index to beginning trace"),
@ -2070,9 +2070,9 @@ static int CmdRtrim(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rtrim", CLIParserInit(&ctx, "data rtrim",
"Trim samples from right of trace", "Trim samples from right of trace",
"data rtrim -i 4000 --> keep 0 - 4000" "data rtrim -i 4000 --> keep 0 - 4000"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_1("i", "idx", "<dec>", "from index to end trace"), arg_u64_1("i", "idx", "<dec>", "from index to end trace"),
@ -2098,9 +2098,9 @@ static int CmdMtrim(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data mtrim", CLIParserInit(&ctx, "data mtrim",
"Trim out samples from the specified start to the specified end point", "Trim out samples from the specified start to the specified end point",
"data mtrim -s 1000 -e 2000 --> keep between 1000 and 2000" "data mtrim -s 1000 -e 2000 --> keep between 1000 and 2000"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_1("s", "start", "<dec>", "start point"), arg_u64_1("s", "start", "<dec>", "start point"),
@ -2132,9 +2132,9 @@ int CmdNorm(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data norm", CLIParserInit(&ctx, "data norm",
"Normalize max/min to +/-128", "Normalize max/min to +/-128",
"data norm" "data norm"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -2169,10 +2169,10 @@ int CmdNorm(const char *Cmd) {
int CmdPlot(const char *Cmd) { int CmdPlot(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data plot", CLIParserInit(&ctx, "data plot",
"Show graph window \n" "Show graph window \n"
"hit 'h' in window for detail keystroke help available", "hit 'h' in window for detail keystroke help available",
"data plot" "data plot"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -2280,9 +2280,9 @@ int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t
static int CmdDirectionalThreshold(const char *Cmd) { static int CmdDirectionalThreshold(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data dirthreshold", CLIParserInit(&ctx, "data dirthreshold",
"Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev.", "Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev.",
"data dirthreshold -u 10 -d -10" "data dirthreshold -u 10 -d -10"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int1("d", "down", "<dec>", "threshold down"), arg_int1("d", "down", "<dec>", "threshold down"),
@ -2311,9 +2311,9 @@ static int CmdDirectionalThreshold(const char *Cmd) {
static int CmdZerocrossings(const char *Cmd) { static int CmdZerocrossings(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data zerocrossings", CLIParserInit(&ctx, "data zerocrossings",
"Count time between zero-crossings", "Count time between zero-crossings",
"data zerocrossings" "data zerocrossings"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
@ -2359,10 +2359,10 @@ static int Cmdbin2hex(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data bin2hex", CLIParserInit(&ctx, "data bin2hex",
"This function converts binary to hexadecimal. It will ignore all\n" "This function converts binary to hexadecimal. It will ignore all\n"
"characters not 1 or 0 but stop reading on whitespace", "characters not 1 or 0 but stop reading on whitespace",
"data bin2hex -d 0101111001010" "data bin2hex -d 0101111001010"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_strx0("d", "data", "<bin>", "binary string to convert"), arg_strx0("d", "data", "<bin>", "binary string to convert"),
@ -2379,7 +2379,7 @@ static int Cmdbin2hex(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
// Number of digits supplied as argument // Number of digits supplied as argument
size_t bytelen = (blen + 7) / 8; size_t bytelen = (blen + 7) / 8;
uint8_t *arr = (uint8_t *) calloc(bytelen, sizeof(uint8_t)); uint8_t *arr = (uint8_t *) calloc(bytelen, sizeof(uint8_t));
memset(arr, 0, bytelen); memset(arr, 0, bytelen);
@ -2406,10 +2406,10 @@ static int Cmdbin2hex(const char *Cmd) {
static int Cmdhex2bin(const char *Cmd) { static int Cmdhex2bin(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data hex2bin", CLIParserInit(&ctx, "data hex2bin",
"This function converts hexadecimal to binary. It will ignore all\n" "This function converts hexadecimal to binary. It will ignore all\n"
"non-hexadecimal characters but stop reading on whitespace", "non-hexadecimal characters but stop reading on whitespace",
"data hex2bin -d 01020304" "data hex2bin -d 01020304"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_str0("d", "data", "<hex>", "bytes to convert"), arg_str0("d", "data", "<hex>", "bytes to convert"),
@ -2427,11 +2427,11 @@ static int Cmdhex2bin(const char *Cmd) {
} }
for (int i = 0; i < dlen; i++) { for (int i = 0; i < dlen; i++) {
char x = data[i]; char x = data[i];
if (isxdigit(x) == false) { if (isxdigit(x) == false) {
PrintAndLogEx(ERR, "Non hex digit found"); PrintAndLogEx(ERR, "Non hex digit found");
return PM3_EINVARG; return PM3_EINVARG;
} }
} }
PrintAndLogEx(SUCCESS, "" NOLF); PrintAndLogEx(SUCCESS, "" NOLF);
@ -2632,9 +2632,9 @@ static int CmdDataIIR(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data iir", CLIParserInit(&ctx, "data iir",
"Apply IIR buttersworth filter on plot data", "Apply IIR buttersworth filter on plot data",
"data iir -n 2" "data iir -n 2"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_1("n", NULL, "<dec>", "factor n"), arg_u64_1("n", NULL, "<dec>", "factor n"),
@ -2703,7 +2703,7 @@ typedef struct {
static int print_modulation(lf_modulation_t b) { static int print_modulation(lf_modulation_t b) {
PrintAndLogEx(INFO, " Modulation........ " _GREEN_("%s"), GetSelectedModulationStr(b.modulation)); PrintAndLogEx(INFO, " Modulation........ " _GREEN_("%s"), GetSelectedModulationStr(b.modulation));
PrintAndLogEx(INFO, " Bit clock......... " _GREEN_("RF/%d"), b.bitrate); PrintAndLogEx(INFO, " Bit clock......... " _GREEN_("RF/%d"), b.bitrate);
PrintAndLogEx(INFO, " Approx baudrate... " _GREEN_("%.f") "bauds", (125000 / (float)b.bitrate) ); PrintAndLogEx(INFO, " Approx baudrate... " _GREEN_("%.f") "bauds", (125000 / (float)b.bitrate));
switch (b.modulation) { switch (b.modulation) {
case DEMOD_PSK1: case DEMOD_PSK1:
case DEMOD_PSK2: case DEMOD_PSK2:

View file

@ -1151,7 +1151,7 @@ static int CmdHF14BWriteSri(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
int blockno = arg_get_int_def(ctx, 1, -1); int blockno = arg_get_int_def(ctx, 1, -1);
int dlen = 0; int dlen = 0;
uint8_t data[4] = {0,0,0,0}; uint8_t data[4] = {0, 0, 0, 0};
int res = CLIParamHexToBuf(arg_get_str(ctx, 2), data, sizeof(data), &dlen); int res = CLIParamHexToBuf(arg_get_str(ctx, 2), data, sizeof(data), &dlen);
if (res) { if (res) {
CLIParserFree(ctx); CLIParserFree(ctx);

View file

@ -470,7 +470,7 @@ static uint8_t arg_add_default(void *at[]) {
at[5] = arg_lit0("o", "opt", "set OPTION Flag (needed for TI)"); at[5] = arg_lit0("o", "opt", "set OPTION Flag (needed for TI)");
return 6; return 6;
} }
static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bool add_option ) { static uint16_t arg_get_raw_flag(uint8_t uidlen, bool unaddressed, bool scan, bool add_option) {
uint16_t flags = 0; uint16_t flags = 0;
if (unaddressed) { if (unaddressed) {
// unaddressed mode may not be supported by all vendors // unaddressed mode may not be supported by all vendors
@ -800,15 +800,15 @@ static int NxpSysInfo(uint8_t *uid) {
*/ */
static int CmdHF15Info(const char *Cmd) { static int CmdHF15Info(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 info", CLIParserInit(&ctx, "hf 15 info",
"Uses the optional command `get_systeminfo` 0x2B to try and extract information", "Uses the optional command `get_systeminfo` 0x2B to try and extract information",
"hf 15 info\n" "hf 15 info\n"
"hf 15 info -*\n" "hf 15 info -*\n"
"hf 15 info -u E011223344556677" "hf 15 info -u E011223344556677"
); );
void *argtable[6+1] = {}; void *argtable[6 + 1] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
@ -1079,9 +1079,9 @@ static int CmdHF15WriteAfi(const char *Cmd) {
"Write AFI on card", "Write AFI on card",
"hf 15 writeafi -* --afi 12\n" "hf 15 writeafi -* --afi 12\n"
"hf 15 writeafi -u E011223344556677 --afi 12" "hf 15 writeafi -u E011223344556677 --afi 12"
); );
void *argtable[6+2] = {}; void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1(NULL, "afi", "<dec>", "AFI number (0-255)"); argtable[arglen++] = arg_int1(NULL, "afi", "<dec>", "AFI number (0-255)");
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
@ -1176,9 +1176,9 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
"Write DSFID on card", "Write DSFID on card",
"hf 15 writedsfid -* --dsfid 12\n" "hf 15 writedsfid -* --dsfid 12\n"
"hf 15 writedsfid -u E011223344556677 --dsfid 12" "hf 15 writedsfid -u E011223344556677 --dsfid 12"
); );
void *argtable[6+2] = {}; void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1(NULL, "dsfid", "<dec>", "DSFID number (0-255)"); argtable[arglen++] = arg_int1(NULL, "dsfid", "<dec>", "DSFID number (0-255)");
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
@ -1239,7 +1239,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
// arg2 (recv == 1 == expect a response) // arg2 (recv == 1 == expect a response)
uint8_t read_respone = 1; uint8_t read_respone = 1;
PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen) ); PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen));
PacketResponseNG resp; PacketResponseNG resp;
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_ISO15693_COMMAND, reqlen, fast, read_respone, req, reqlen); SendCommandMIX(CMD_HF_ISO15693_COMMAND, reqlen, fast, read_respone, req, reqlen);
@ -1277,12 +1277,12 @@ static int CmdHF15Dump(const char *Cmd) {
"hf 15 dump\n" "hf 15 dump\n"
"hf 15 dump -*\n" "hf 15 dump -*\n"
"hf 15 dump -u E011223344556677 -f hf-15-my-dump.bin" "hf 15 dump -u E011223344556677 -f hf-15-my-dump.bin"
); );
void *argtable[6+2] = {}; void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"), argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -1409,12 +1409,12 @@ static int CmdHF15Dump(const char *Cmd) {
sprintf(lck, "%d", mem[i].lock); sprintf(lck, "%d", mem[i].lock);
} }
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s" PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s"
, i , i
, i , i
, sprint_hex(mem[i].block, 4) , sprint_hex(mem[i].block, 4)
, lck , lck
, sprint_ascii(mem[i].block, 4) , sprint_ascii(mem[i].block, 4)
); );
} }
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
@ -1449,7 +1449,7 @@ static int CmdHF15Raw(const char *Cmd) {
"Sends raw bytes over ISO-15693 to card", "Sends raw bytes over ISO-15693 to card",
"hf 15 raw -c -d 260100 --> add crc\n" "hf 15 raw -c -d 260100 --> add crc\n"
"hf 15 raw -krc -d 260100 --> add crc, keep field on, skip response" "hf 15 raw -krc -d 260100 --> add crc, keep field on, skip response"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -1517,9 +1517,9 @@ static int CmdHF15Readmulti(const char *Cmd) {
"Read multiple pages on a ISO-15693 tag ", "Read multiple pages on a ISO-15693 tag ",
"hf 15 rdmulti -* -b 1 --cnt 6 -> read 6 blocks\n" "hf 15 rdmulti -* -b 1 --cnt 6 -> read 6 blocks\n"
"hf 15 rdmulti -u E011223344556677 -b 12 --cnt 3 -> read three blocks" "hf 15 rdmulti -u E011223344556677 -b 12 --cnt 3 -> read three blocks"
); );
void *argtable[6+3] = {}; void *argtable[6 + 3] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", NULL, "<dec>", "first page number (0-255)"); argtable[arglen++] = arg_int1("b", NULL, "<dec>", "first page number (0-255)");
argtable[arglen++] = arg_int1(NULL, "cnt", "<dec>", "number of pages (1-6)"); argtable[arglen++] = arg_int1(NULL, "cnt", "<dec>", "number of pages (1-6)");
@ -1653,9 +1653,9 @@ static int CmdHF15Readblock(const char *Cmd) {
"Read page on ISO-15693 tag", "Read page on ISO-15693 tag",
"hf 15 rdbl -* -b 12\n" "hf 15 rdbl -* -b 12\n"
"hf 15 rdbl -u E011223344556677 -b 12" "hf 15 rdbl -u E011223344556677 -b 12"
); );
void *argtable[6+2] = {}; void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)"); argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
@ -1679,7 +1679,7 @@ static int CmdHF15Readblock(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
// default fallback to scan for tag. // default fallback to scan for tag.
// overriding unaddress parameter :) // overriding unaddress parameter :)
if (uidlen != 8) { if (uidlen != 8) {
scan = true; scan = true;
@ -1819,9 +1819,9 @@ static int CmdHF15Write(const char *Cmd) {
"Write block on ISO-15693 tag", "Write block on ISO-15693 tag",
"hf 15 wrbl -* -b 12 -d AABBCCDD\n" "hf 15 wrbl -* -b 12 -d AABBCCDD\n"
"hf 15 wrbl -u E011223344556677 -b 12 -d AABBCCDD" "hf 15 wrbl -u E011223344556677 -b 12 -d AABBCCDD"
); );
void *argtable[6+4] = {}; void *argtable[6 + 4] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)"); argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
argtable[arglen++] = arg_str1("d", "data", "<hex>", "data, 4 bytes"); argtable[arglen++] = arg_str1("d", "data", "<hex>", "data, 4 bytes");
@ -1856,7 +1856,7 @@ static int CmdHF15Write(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
// default fallback to scan for tag. // default fallback to scan for tag.
// overriding unaddress parameter :) // overriding unaddress parameter :)
if (uidlen != 8) { if (uidlen != 8) {
scan = true; scan = true;
@ -1913,14 +1913,14 @@ static int CmdHF15Restore(const char *Cmd) {
"hf 15 restore\n" "hf 15 restore\n"
"hf 15 restore -*\n" "hf 15 restore -*\n"
"hf 15 restore -u E011223344556677 -f hf-15-my-dump.bin" "hf 15 restore -u E011223344556677 -f hf-15-my-dump.bin"
); );
void *argtable[6+5] = {}; void *argtable[6 + 5] = {};
uint8_t arglen = arg_add_default(argtable); uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"), argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"), argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"),
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"), argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output"); argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end; argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -1950,7 +1950,7 @@ static int CmdHF15Restore(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
// default fallback to scan for tag. // default fallback to scan for tag.
// overriding unaddress parameter :) // overriding unaddress parameter :)
if (uidlen != 8) { if (uidlen != 8) {
scan = true; scan = true;

View file

@ -39,10 +39,10 @@ static void print_status_flag1_interpretation(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command."); PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n" PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n"
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1."); " | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n" PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n"
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n" " | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
" | indicating the location of the error."); " | indicating the location of the error.");
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
} }
@ -51,28 +51,28 @@ static void print_status_flag2_interpration(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------"); PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command."); PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n" PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n"
" | Bytes when the purse data is incremented."); " | Bytes when the purse data is incremented.");
PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse."); PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse.");
PrintAndLogEx(INFO, " 70 | Memory error (fatal error)."); PrintAndLogEx(INFO, " 70 | Memory error (fatal error).");
PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n" PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n"
" | The maximum number of rewrites can differ, depending on the product being used.\n" " | The maximum number of rewrites can differ, depending on the product being used.\n"
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used."); " | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n" PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n"
" | falls outside the range of the prescribed value."); " | falls outside the range of the prescribed value.");
PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n" PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n"
" | command falls outside the range of the prescribed values for the product."); " | command falls outside the range of the prescribed values for the product.");
PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n" PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n"
" | Block List Element falls outside the Number of Service specified by the command \n" " | Block List Element falls outside the Number of Service specified by the command \n"
" | (or the Number of Service specified at the times of mutual authentication)."); " | (or the Number of Service specified at the times of mutual authentication).");
PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect."); PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect.");
PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n" PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n"
" | The parameter specified by the command does not satisfy the conditions for success."); " | The parameter specified by the command does not satisfy the conditions for success.");
PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n" PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n"
" | List Element does not exist. Or, Node specified by Node Code List does not exist."); " | List Element does not exist. Or, Node specified by Node Code List does not exist.");
PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect."); PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect.");
PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n" PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n"
" | specified by Block List Element exceeds the number of Blocks assigned to Service."); " | specified by Block List Element exceeds the number of Blocks assigned to Service.");
PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed."); PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed.");
PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands.");
@ -80,7 +80,7 @@ static void print_status_flag2_interpration(void) {
PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n" PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n"
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service."); " | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands."); PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands.");
@ -111,9 +111,9 @@ static void print_number_of_block_constraints(void) {
static void print_service_code_list_constraints(void) { static void print_service_code_list_constraints(void) {
PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:"); PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:");
PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n" PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n"
" be specified to Service Code List."); " be specified to Service Code List.");
PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n" PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n"
" (or Request Service v2) command."); " (or Request Service v2) command.");
} }
/* /*
@ -493,13 +493,13 @@ static void reverse_3des_key(uint8_t *master_key, int length, uint8_t *reverse_m
static int CmdHFFelicaAuthentication1(const char *Cmd) { static int CmdHFFelicaAuthentication1(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "hf felica auth1", CLIParserInit(&ctx, "hf felica auth1",
"Initiate mutual authentication. This command must always be executed before Auth2 command\n" "Initiate mutual authentication. This command must always be executed before Auth2 command\n"
"and mutual authentication is achieve only after Auth2 command has succeeded.\n" "and mutual authentication is achieve only after Auth2 command has succeeded.\n"
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!"), _RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!"),
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n" "hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
"hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n" "hf felica auth1 --an 01 --acl 0000 --sn 01 --scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n"
"hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n" "hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_str0(NULL, "an", "<hex>", "number of areas, 1 byte"), arg_str0(NULL, "an", "<hex>", "number of areas, 1 byte"),
@ -569,7 +569,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
} }
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length data[0] = 0x0C; // Static length
data[1] = 0x3E; // Command ID data[1] = 0x3E; // Command ID
@ -580,14 +580,14 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
memcpy(data + 2, idm, 8); memcpy(data + 2, idm, 8);
} }
// Length (1), // Length (1),
// Command ID (1), // Command ID (1),
// IDm (8), // IDm (8),
// Number of Area (1), // Number of Area (1),
// Area Code List (2), // Area Code List (2),
// Number of Service (1), // Number of Service (1),
// Service Code List (2), // Service Code List (2),
// M1c (16) // M1c (16)
uint16_t datalen = 32; uint16_t datalen = 32;
data[0] = (datalen & 0xFF); data[0] = (datalen & 0xFF);
data[1] = 0x10; // Command ID data[1] = 0x10; // Command ID
@ -615,7 +615,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
} }
// READER CHALLENGE - (RANDOM To Encrypt = Rac) // READER CHALLENGE - (RANDOM To Encrypt = Rac)
uint8_t nonce[8] = {1,2,3,4,5,6,7,8}; uint8_t nonce[8] = {1, 2, 3, 4, 5, 6, 7, 8};
PrintAndLogEx(INFO, "Reader challenge (unencrypted): %s", sprint_hex(nonce, 8)); PrintAndLogEx(INFO, "Reader challenge (unencrypted): %s", sprint_hex(nonce, 8));
// Create M1c Challenge with 3DES (3 Keys = 24, 2 Keys = 16) // Create M1c Challenge with 3DES (3 Keys = 24, 2 Keys = 16)
@ -710,12 +710,12 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "hf felica auth2", CLIParserInit(&ctx, "hf felica auth2",
"Complete mutual authentication. This command can only be executed subsquent to Auth1\n" "Complete mutual authentication. This command can only be executed subsquent to Auth1\n"
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n") _RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n")
_RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"), _RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"),
"hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n" "hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
"hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n" "hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_str0("i", NULL, "<hex>", "set custom IDm"), arg_str0("i", NULL, "<hex>", "set custom IDm"),
@ -758,7 +758,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
} }
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
bool custom_IDm = false; bool custom_IDm = false;
@ -954,7 +954,7 @@ static int CmdHFFelicaWritePlain(const char *Cmd) {
} }
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x20; // Static length data[0] = 0x20; // Static length
data[1] = 0x08; // Command ID data[1] = 0x08; // Command ID
@ -1115,7 +1115,7 @@ static int CmdHFFelicaReadPlain(const char *Cmd) {
} }
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x10; // Static length data[0] = 0x10; // Static length
data[1] = 0x06; // Command ID data[1] = 0x06; // Command ID
@ -1217,7 +1217,7 @@ static int CmdHFFelicaRequestResponse(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x0A; // Static length data[0] = 0x0A; // Static length
data[1] = 0x04; // Command ID data[1] = 0x04; // Command ID
@ -1294,7 +1294,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
uint8_t reserved[2] = {0,0}; uint8_t reserved[2] = {0, 0};
int rlen = 0; int rlen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen); res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
if (res) { if (res) {
@ -1310,7 +1310,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length data[0] = 0x0C; // Static length
data[1] = 0x3C; // Command ID data[1] = 0x3C; // Command ID
@ -1323,8 +1323,8 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
} }
// add custom reserved // add custom reserved
if (rlen ) { if (rlen) {
memcpy(data +10, reserved, sizeof(reserved)); memcpy(data + 10, reserved, sizeof(reserved));
} else { } else {
data[10] = 0x00; // Reserved Value data[10] = 0x00; // Reserved Value
data[11] = 0x00; // Reserved Value data[11] = 0x00; // Reserved Value
@ -1337,7 +1337,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
AddCrc(data, datalen); AddCrc(data, datalen);
datalen += 2; datalen += 2;
uint8_t flags = (FELICA_APPEND_CRC |FELICA_RAW); uint8_t flags = (FELICA_APPEND_CRC | FELICA_RAW);
clear_and_send_command(flags, datalen, data, 0); clear_and_send_command(flags, datalen, data, 0);
@ -1401,7 +1401,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
uint8_t reserved[2] = {0,0}; uint8_t reserved[2] = {0, 0};
int rlen = 0; int rlen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen); res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
if (res) { if (res) {
@ -1417,7 +1417,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length data[0] = 0x0C; // Static length
data[1] = 0x3E; // Command ID data[1] = 0x3E; // Command ID
@ -1495,7 +1495,7 @@ static int CmdHFFelicaRequestSystemCode(const char *Cmd) {
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
data[0] = 0x0A; // Static length data[0] = 0x0A; // Static length
data[1] = 0x0C; // Command ID data[1] = 0x0C; // Command ID
@ -1578,7 +1578,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
return PM3_EINVARG; return PM3_EINVARG;
} }
uint8_t code[2] = {0,0}; uint8_t code[2] = {0, 0};
int clen = 0; int clen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 3), code, sizeof(code), &clen); res = CLIParamHexToBuf(arg_get_str(ctx, 3), code, sizeof(code), &clen);
if (res) { if (res) {
@ -1596,7 +1596,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
bool custom_IDm = false; bool custom_IDm = false;
@ -2055,7 +2055,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
int datalen = 0; int datalen = 0;
uint8_t data[PM3_CMD_DATA_SIZE]; uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data)); memset(data, 0, sizeof(data));
CLIGetHexWithReturn(ctx, 7, data, &datalen); CLIGetHexWithReturn(ctx, 7, data, &datalen);
CLIParserFree(ctx); CLIParserFree(ctx);

View file

@ -181,7 +181,7 @@ static int cmd_hf_fido_register(const char *cmd) {
"hf fido reg -> execute command with 2 parameters, filled 0x00\n" "hf fido reg -> execute command with 2 parameters, filled 0x00\n"
"hf fido reg -p s0 s1 -> execute command with plain parameters\n" "hf fido reg -p s0 s1 -> execute command with plain parameters\n"
"hf fido reg --cp 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f --ap 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\n" "hf fido reg --cp 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f --ap 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -693,7 +693,7 @@ static int cmd_hf_fido_2make_credential(const char *cmd) {
"Sample file `fido2.json` in `client/resources/`.", "Sample file `fido2.json` in `client/resources/`.",
"hf fido make -> default parameters file `fido2.json`\n" "hf fido make -> default parameters file `fido2.json`\n"
"hf fido make -f test.json -> use parameters file `text.json`" "hf fido make -f test.json -> use parameters file `text.json`"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,

View file

@ -386,7 +386,7 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
} else { } else {
PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )"); PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )");
// suggest the opposite keytype than what was used. // suggest the opposite keytype than what was used.
PrintAndLogEx(HINT, "Maybe access rights? Try specify keytype " _YELLOW_("%c") " instead", (keytype == MF_KEY_A) ? 'B' : 'A' ); PrintAndLogEx(HINT, "Maybe access rights? Try specify keytype " _YELLOW_("%c") " instead", (keytype == MF_KEY_A) ? 'B' : 'A');
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -821,7 +821,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
"hf mf restore --1k --uid 04010203\n" "hf mf restore --1k --uid 04010203\n"
"hf mf restore --1k --uid 04010203 -k hf-mf-AABBCCDD-key.bin\n" "hf mf restore --1k --uid 04010203 -k hf-mf-AABBCCDD-key.bin\n"
"hf mf restore --4k" "hf mf restore --4k"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -1622,7 +1622,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
"hf mf hardnested -r --tk a0a1a2a3a4a5\n" "hf mf hardnested -r --tk a0a1a2a3a4a5\n"
"hf mf hardnested -t --tk a0a1a2a3a4a5\n" "hf mf hardnested -t --tk a0a1a2a3a4a5\n"
"hf mf hardnested --blk 0 -a -k a0a1a2a3a4a5 --tblk 4 --ta --tk FFFFFFFFFFFF" "hf mf hardnested --blk 0 -a -k a0a1a2a3a4a5 --tblk 4 --ta --tk FFFFFFFFFFFF"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -1774,7 +1774,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
PrintAndLogEx(INFO, "Target block no " _YELLOW_("%3d") ", target key type: " _YELLOW_("%c") ", known target key: " _YELLOW_("%02x%02x%02x%02x%02x%02x%s"), PrintAndLogEx(INFO, "Target block no " _YELLOW_("%3d") ", target key type: " _YELLOW_("%c") ", known target key: " _YELLOW_("%02x%02x%02x%02x%02x%02x%s"),
trg_blockno, trg_blockno,
(trg_keytype == MF_KEY_B)? 'B' : 'A', (trg_keytype == MF_KEY_B) ? 'B' : 'A',
trg_key[0], trg_key[1], trg_key[2], trg_key[3], trg_key[4], trg_key[5], trg_key[0], trg_key[1], trg_key[2], trg_key[3], trg_key[4], trg_key[5],
know_target_key ? "" : " (not set)" know_target_key ? "" : " (not set)"
); );
@ -1808,7 +1808,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
static int CmdHF14AMfAutoPWN(const char *Cmd) { static int CmdHF14AMfAutoPWN(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf autopwn", CLIParserInit(&ctx, "hf mf autopwn",
"This command automates the key recovery process on MIFARE Classic cards.\n" "This command automates the key recovery process on MIFARE Classic cards.\n"
"It uses the fchk, chk, darkside, nested, hardnested and staticnested to recover keys.\n" "It uses the fchk, chk, darkside, nested, hardnested and staticnested to recover keys.\n"
@ -1817,7 +1817,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
"hf mf autopwn -s 0 -a -k FFFFFFFFFFFF --> target MFC 1K card, Sector 0 with known key A 'FFFFFFFFFFFF'\n" "hf mf autopwn -s 0 -a -k FFFFFFFFFFFF --> target MFC 1K card, Sector 0 with known key A 'FFFFFFFFFFFF'\n"
"hf mf autopwn --1k -f mfc_default_keys --> target MFC 1K card, default dictionary\n" "hf mf autopwn --1k -f mfc_default_keys --> target MFC 1K card, default dictionary\n"
"hf mf autopwn --1k -s 0 -a -k FFFFFFFFFFFF -f mfc_default_keys --> combo of the two above samples" "hf mf autopwn --1k -s 0 -a -k FFFFFFFFFFFF -f mfc_default_keys --> combo of the two above samples"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -2197,7 +2197,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
} else { } else {
PrintAndLogEx(SUCCESS, "target sector %3u key type %c -- found valid key [ " _GREEN_("%s") " ]", PrintAndLogEx(SUCCESS, "target sector %3u key type %c -- found valid key [ " _GREEN_("%s") " ]",
i, i,
(j == MF_KEY_B)? 'B' : 'A', (j == MF_KEY_B) ? 'B' : 'A',
sprint_hex_inrow(tmp_key, sizeof(tmp_key)) sprint_hex_inrow(tmp_key, sizeof(tmp_key))
); );
} }
@ -3895,7 +3895,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
m1 = true; m1 = true;
} }
uint16_t block_cnt = MIFARE_1K_MAXBLOCK; uint16_t block_cnt = MIFARE_1K_MAXBLOCK;
if (m0) { if (m0) {
block_cnt = MIFARE_MINI_MAXBLOCK; block_cnt = MIFARE_MINI_MAXBLOCK;
@ -4229,14 +4229,14 @@ static int CmdHF14AMfCSetUID(const char *Cmd) {
uint8_t verify_uid[7] = {0}; uint8_t verify_uid[7] = {0};
int res = mfCSetUID( int res = mfCSetUID(
uid, uid,
uidlen, uidlen,
(alen) ? atqa : NULL, (alen) ? atqa : NULL,
(slen) ? sak : NULL, (slen) ? sak : NULL,
old_uid, old_uid,
verify_uid, verify_uid,
wipe_card wipe_card
); );
if (res) { if (res) {
PrintAndLogEx(ERR, "Can't set UID. error %d", res); PrintAndLogEx(ERR, "Can't set UID. error %d", res);
@ -4247,9 +4247,9 @@ static int CmdHF14AMfCSetUID(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Old UID... %s", sprint_hex(old_uid, uidlen)); PrintAndLogEx(SUCCESS, "Old UID... %s", sprint_hex(old_uid, uidlen));
PrintAndLogEx(SUCCESS, "New UID... %s ( %s )", PrintAndLogEx(SUCCESS, "New UID... %s ( %s )",
sprint_hex(verify_uid, uidlen), sprint_hex(verify_uid, uidlen),
(res == 0) ? _GREEN_("verified") : _RED_("fail") (res == 0) ? _GREEN_("verified") : _RED_("fail")
); );
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -4331,7 +4331,7 @@ static int CmdHF14AMfCSetBlk(const char *Cmd) {
uint8_t wipe_card = arg_get_lit(ctx, 3); uint8_t wipe_card = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);
if (b < 0 || b >= MIFARE_1K_MAXBLOCK ) { if (b < 0 || b >= MIFARE_1K_MAXBLOCK) {
PrintAndLogEx(FAILED, "target block number out-of-range, got %i", b); PrintAndLogEx(FAILED, "target block number out-of-range, got %i", b);
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -4458,7 +4458,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
// 64 or 256blocks. // 64 or 256blocks.
if (bytes_read != (MIFARE_1K_MAXBLOCK * MFBLOCK_SIZE) && if (bytes_read != (MIFARE_1K_MAXBLOCK * MFBLOCK_SIZE) &&
bytes_read != (MIFARE_4K_MAXBLOCK * MFBLOCK_SIZE)) { bytes_read != (MIFARE_4K_MAXBLOCK * MFBLOCK_SIZE)) {
PrintAndLogEx(ERR, "File content error. Read %zu bytes", bytes_read); PrintAndLogEx(ERR, "File content error. Read %zu bytes", bytes_read);
free(data); free(data);
return PM3_EFILE; return PM3_EFILE;
@ -4508,7 +4508,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
// confirm number written blocks. Must be 64 or 256 blocks // confirm number written blocks. Must be 64 or 256 blocks
if (blockno != MIFARE_1K_MAXBLOCK) { if (blockno != MIFARE_1K_MAXBLOCK) {
if (blockno != MIFARE_4K_MAXBLOCK) { if (blockno != MIFARE_4K_MAXBLOCK) {
PrintAndLogEx(ERR, "File content error. There must be %u blocks", MIFARE_4K_MAXBLOCK); PrintAndLogEx(ERR, "File content error. There must be %u blocks", MIFARE_4K_MAXBLOCK);
return PM3_EFILE; return PM3_EFILE;
} }
@ -5439,7 +5439,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
"hf mf personalize -f2 -> single size random ID\n" "hf mf personalize -f2 -> single size random ID\n"
"hf mf personalize -f3 -> single size NUID\n" "hf mf personalize -f3 -> single size NUID\n"
"hf mf personalize -b -k B0B1B2B3B4B5 -f3 -> use key B = 0xB0B1B2B3B4B5" "hf mf personalize -b -k B0B1B2B3B4B5 -f3 -> use key B = 0xB0B1B2B3B4B5"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -5520,7 +5520,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
if ( resp.status == PM3_SUCCESS) { if (resp.status == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "Personalization ( %s )", _GREEN_("ok")); PrintAndLogEx(SUCCESS, "Personalization ( %s )", _GREEN_("ok"));
} else { } else {
PrintAndLogEx(FAILED, "Personalization ( %s )", _RED_("fail")); PrintAndLogEx(FAILED, "Personalization ( %s )", _RED_("fail"));

View file

@ -2203,7 +2203,7 @@ static void init_it_all(void) {
known_target_key = 0; known_target_key = 0;
test_state[0] = 0; test_state[0] = 0;
test_state[1] = 0; test_state[1] = 0;
brute_force_per_second=0; brute_force_per_second = 0;
init_book_of_work(); init_book_of_work();
real_sum_a8 = 0; real_sum_a8 = 0;

View file

@ -590,8 +590,8 @@ static int CmdHFMFPCommitPerso(const char *Cmd) {
CLIParserInit(&ctx, "hf mfp commitp", CLIParserInit(&ctx, "hf mfp commitp",
"Executes Commit Perso command. Can be used in SL0 mode only.", "Executes Commit Perso command. Can be used in SL0 mode only.",
"hf mfp commitp\n" "hf mfp commitp\n"
// "hf mfp commitp --sl 1" // "hf mfp commitp --sl 1"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -677,7 +677,7 @@ static int CmdHFMFPRdbl(const char *Cmd) {
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("v", "verbose", "show internal data"), arg_lit0("v", "verbose", "show internal data"),
arg_int0("n", "count", "<dec>","blocks count (by default 1)"), arg_int0("n", "count", "<dec>", "blocks count (by default 1)"),
arg_lit0("b", "keyb", "use key B (by default keyA)"), arg_lit0("b", "keyb", "use key B (by default keyA)"),
arg_lit0("p", "plain", "plain communication mode between reader and card"), arg_lit0("p", "plain", "plain communication mode between reader and card"),
arg_int1(NULL, "blk", "<dec>", "block number (0..255)"), arg_int1(NULL, "blk", "<dec>", "block number (0..255)"),
@ -882,7 +882,7 @@ static int CmdHFMFPWrbl(const char *Cmd) {
"Writes one block to Mifare Plus card", "Writes one block to Mifare Plus card",
"hf mfp wrbl --blk 1 -d ff0000000000000000000000000000ff --key 000102030405060708090a0b0c0d0e0f -> writes block 1 data\n" "hf mfp wrbl --blk 1 -d ff0000000000000000000000000000ff --key 000102030405060708090a0b0c0d0e0f -> writes block 1 data\n"
"hf mfp wrbl --blk 2 -d ff0000000000000000000000000000ff -v -> writes block 2 data with default key 0xFF..0xFF" "hf mfp wrbl --blk 2 -d ff0000000000000000000000000000ff -v -> writes block 2 data with default key 0xFF..0xFF"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,

View file

@ -520,7 +520,7 @@ static int CmdLFHitagReader(const char *Cmd) {
" lf hitag reader --22 --nrar 0102030411223344\n" " lf hitag reader --22 --nrar 0102030411223344\n"
" lf hitag reader --23 -k 4F4E4D494B52\n" " lf hitag reader --23 -k 4F4E4D494B52\n"
" lf hitag reader --26\n" " lf hitag reader --26\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -531,8 +531,8 @@ static int CmdLFHitagReader(const char *Cmd) {
arg_lit0(NULL, "23", "Hitag2, read all pages, crypto mode. Key ISK high + ISK low. def 4F4E4D494B52 (ONMIKR)"), arg_lit0(NULL, "23", "Hitag2, read all pages, crypto mode. Key ISK high + ISK low. def 4F4E4D494B52 (ONMIKR)"),
arg_lit0(NULL, "25", "Hitag2, test recorded authentications (replay?)"), arg_lit0(NULL, "25", "Hitag2, test recorded authentications (replay?)"),
arg_lit0(NULL, "26", "Hitag2, read UID"), arg_lit0(NULL, "26", "Hitag2, read UID"),
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"), arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 hex bytes"), arg_str0(NULL, "nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -592,7 +592,7 @@ static int CmdLFHitagReader(const char *Cmd) {
htf = RHTSF_CHALLENGE; htf = RHTSF_CHALLENGE;
memcpy(htd.auth.NrAr, nrar, sizeof(nrar)); memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
} }
if (s02){ if (s02) {
cmd = CMD_LF_HITAGS_READ; cmd = CMD_LF_HITAGS_READ;
htf = RHTSF_KEY; htf = RHTSF_KEY;
memcpy(htd.crypto.key, key, sizeof(key)); memcpy(htd.crypto.key, key, sizeof(key));
@ -698,7 +698,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
"Hitag 2\n" "Hitag 2\n"
" lf hitag writer --24 -k 4F4E4D494B52 -p 3 -d 01020304\n" " lf hitag writer --24 -k 4F4E4D494B52 -p 3 -d 01020304\n"
" lf hitag writer --27 -k 4D494B52 -p 3 -d 01020304\n" " lf hitag writer --27 -k 4D494B52 -p 3 -d 01020304\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -708,8 +708,8 @@ static int CmdLFHitagWriter(const char *Cmd) {
arg_lit0(NULL, "27", "Hitag2, write page, password mode"), arg_lit0(NULL, "27", "Hitag2, write page, password mode"),
arg_int1("p", "page", "<dec>", "page address to write to"), arg_int1("p", "page", "<dec>", "page address to write to"),
arg_str0("d", "data", "<hex>", "data, 4 hex bytes"), arg_str0("d", "data", "<hex>", "data, 4 hex bytes"),
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"), arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL,"nrar", "<hex>", "nonce / answer writer, 8 hex bytes"), arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -782,7 +782,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
memcpy(htd.auth.NrAr, nrar, sizeof(nrar)); memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
memcpy(htd.auth.data, data, sizeof(data)); memcpy(htd.auth.data, data, sizeof(data));
} }
if (s04){ if (s04) {
htf = WHTSF_KEY; htf = WHTSF_KEY;
memcpy(htd.crypto.key, key, sizeof(key)); memcpy(htd.crypto.key, key, sizeof(key));
memcpy(htd.crypto.data, data, sizeof(data)); memcpy(htd.crypto.data, data, sizeof(data));
@ -822,13 +822,13 @@ static int CmdLFHitag2Dump(const char *Cmd) {
"In crypto mode the default key is 4F4E4D494B52 (ONMIKR) format: ISK high + ISK low.", "In crypto mode the default key is 4F4E4D494B52 (ONMIKR) format: ISK high + ISK low.",
"lf hitag dump -k 4F4E4D494B52\n" "lf hitag dump -k 4F4E4D494B52\n"
"lf hitag dump -k 4D494B52\n" "lf hitag dump -k 4D494B52\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_str0("f", "file", "<fn>", "file name"), arg_str0("f", "file", "<fn>", "file name"),
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"), arg_str0("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 hex bytes"), arg_str0(NULL, "nrar", "<hex>", "nonce / answer reader, 8 hex bytes"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -858,23 +858,23 @@ static int CmdLFHitag2Dump(const char *Cmd) {
PrintAndLogEx(WARNING, "to be implememted..."); PrintAndLogEx(WARNING, "to be implememted...");
/* /*
PrintAndLogEx(SUCCESS, "Dumping tag memory..."); PrintAndLogEx(SUCCESS, "Dumping tag memory...");
clearCommandBuffer(); clearCommandBuffer();
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd)); //SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd));
PacketResponseNG resp; PacketResponseNG resp;
uint8_t *data = resp.data.asBytes; uint8_t *data = resp.data.asBytes;
if (fnlen < 1) { if (fnlen < 1) {
char *fptr = filename; char *fptr = filename;
fptr += sprintf(fptr, "lf-hitag-"); fptr += sprintf(fptr, "lf-hitag-");
FillFileNameByUID(fptr, data, "-dump", 4); FillFileNameByUID(fptr, data, "-dump", 4);
} }
saveFile(filename, ".bin", data, 48); saveFile(filename, ".bin", data, 48);
saveFileEML(filename, data, 48, 4); saveFileEML(filename, data, 48, 4);
saveFileJSON(filename, jsfHitag, data, 48, NULL); saveFileJSON(filename, jsfHitag, data, 48, NULL);
*/ */
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -2387,7 +2387,7 @@ static int CmdT55xxRestore(const char *Cmd) {
if (usepwd) if (usepwd)
snprintf(pwdopt, sizeof(pwdopt), "-p %08X", password); snprintf(pwdopt, sizeof(pwdopt), "-p %08X", password);
uint32_t *data = (uint32_t*) dump; uint32_t *data = (uint32_t *) dump;
uint8_t idx; uint8_t idx;
// Restore endien for writing to card // Restore endien for writing to card
for (idx = 0; idx < 12; idx++) { for (idx = 0; idx < 12; idx++) {

View file

@ -1421,7 +1421,7 @@ static int CmdEMVScan(const char *Cmd) {
"It executes EMV contactless transaction and saves result to a file which can be used for emulation\n", "It executes EMV contactless transaction and saves result to a file which can be used for emulation\n",
"emv scan -at -> scan MSD transaction mode and show APDU and TLV\n" "emv scan -at -> scan MSD transaction mode and show APDU and TLV\n"
"emv scan -c -> scan CDA transaction mode\n" "emv scan -c -> scan CDA transaction mode\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
@ -1818,7 +1818,7 @@ static int CmdEMVTest(const char *Cmd) {
"Executes tests\n", "Executes tests\n",
"emv test -i\n" "emv test -i\n"
"emv test --long" "emv test --long"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,

View file

@ -45,25 +45,25 @@ const char *mfpGetErrorDescription(uint8_t errorCode) {
} }
AccessConditions_t MFAccessConditions[] = { AccessConditions_t MFAccessConditions[] = {
{0x00, "read AB; write AB; increment AB; decrement transfer restore AB"}, {0x00, "read AB; write AB; increment AB; decrement transfer restore AB"},
{0x01, "read AB; decrement transfer restore AB"}, {0x01, "read AB; decrement transfer restore AB"},
{0x02, "read AB"}, {0x02, "read AB"},
{0x03, "read B; write B"}, {0x03, "read B; write B"},
{0x04, "read AB; writeB"}, {0x04, "read AB; writeB"},
{0x05, "read B"}, {0x05, "read B"},
{0x06, "read AB; write B; increment B; decrement transfer restore AB"}, {0x06, "read AB; write B; increment B; decrement transfer restore AB"},
{0x07, "none"} {0x07, "none"}
}; };
AccessConditions_t MFAccessConditionsTrailer[] = { AccessConditions_t MFAccessConditionsTrailer[] = {
{0x00, "read A by A; read ACCESS by A; read B by A; write B by A"}, {0x00, "read A by A; read ACCESS by A; read B by A; write B by A"},
{0x01, "write A by A; read ACCESS by A write ACCESS by A; read B by A; write B by A"}, {0x01, "write A by A; read ACCESS by A write ACCESS by A; read B by A; write B by A"},
{0x02, "read ACCESS by A; read B by A"}, {0x02, "read ACCESS by A; read B by A"},
{0x03, "write A by B; read ACCESS by AB; write ACCESS by B; write B by B"}, {0x03, "write A by B; read ACCESS by AB; write ACCESS by B; write B by B"},
{0x04, "write A by B; read ACCESS by AB; write B by B"}, {0x04, "write A by B; read ACCESS by AB; write B by B"},
{0x05, "read ACCESS by AB; write ACCESS by B"}, {0x05, "read ACCESS by AB; write ACCESS by B"},
{0x06, "read ACCESS by AB"}, {0x06, "read ACCESS by AB"},
{0x07, "read ACCESS by AB"} {0x07, "read ACCESS by AB"}
}; };
const char *mfGetAccessConditionsDesc(uint8_t blockn, uint8_t *data) { const char *mfGetAccessConditionsDesc(uint8_t blockn, uint8_t *data) {

View file

@ -155,7 +155,7 @@ static int param_gethex_to_eol(const char *line, int paramnum, uint8_t *data, in
} }
static void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len, static void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len,
const size_t min_str_len, const size_t spaces_between, bool uppercase) { const size_t min_str_len, const size_t spaces_between, bool uppercase) {
if (buf == NULL) return; if (buf == NULL) return;
@ -444,13 +444,13 @@ static void *brute_thread(void *arguments) {
if (args->ev1) { if (args->ev1) {
// if it was EV1, we know for sure xxxAAAAAAAA recovery // if it was EV1, we know for sure xxxAAAAAAAA recovery
printf("\nKey candidate [ " _YELLOW_("....%08" PRIx64 )" ]\n\n", key & 0xFFFFFFFF); printf("\nKey candidate [ " _YELLOW_("....%08" PRIx64)" ]\n\n", key & 0xFFFFFFFF);
__sync_fetch_and_add(&global_found_candidate, 1); __sync_fetch_and_add(&global_found_candidate, 1);
} else { } else {
printf("\nKey candidate [ " _GREEN_("....%08" PRIx64) " ]\n\n", key & 0xFFFFFFFF); printf("\nKey candidate [ " _GREEN_("....%08" PRIx64) " ]\n\n", key & 0xFFFFFFFF);
__sync_fetch_and_add(&global_found, 1); __sync_fetch_and_add(&global_found, 1);
} }
__sync_fetch_and_add(&global_candiate_key, key); __sync_fetch_and_add(&global_candiate_key, key);
//release lock //release lock
pthread_mutex_unlock(&print_lock); pthread_mutex_unlock(&print_lock);
break; break;
@ -565,7 +565,7 @@ int main(int argc, char *argv[]) {
printf("at parity err........ %04x\n", at_par_err); printf("at parity err........ %04x\n", at_par_err);
if (argc > 9) { if (argc > 9) {
printf("next encrypted cmd... %s\n", sprint_hex_inrow_ex(enc, enc_len ,0)); printf("next encrypted cmd... %s\n", sprint_hex_inrow_ex(enc, enc_len, 0));
} }
clock_t t1 = clock(); clock_t t1 = clock();
@ -635,7 +635,7 @@ int main(int argc, char *argv[]) {
printf("partial key.. %08x\n", (uint32_t)(global_candiate_key & 0xFFFFFFFF)); printf("partial key.. %08x\n", (uint32_t)(global_candiate_key & 0xFFFFFFFF));
printf("nt enc....... %08x\n", nt_enc); printf("nt enc....... %08x\n", nt_enc);
printf("nr enc....... %08x\n", nr_enc); printf("nr enc....... %08x\n", nr_enc);
printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, enc_len ,0)); printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, enc_len, 0));
printf("\nlooking for the upper 16 bits of key\n"); printf("\nlooking for the upper 16 bits of key\n");
fflush(stdout); fflush(stdout);