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

@ -8,8 +8,8 @@ author = 'Mosci'
version = 'v1.0.3'
desc =
[[
This is a script which writes value 0x01 to bytes from
position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
This is a script which writes value 0x01 to bytes from
position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
-- (created with 'hf legic dump -f my_dump.hex') --
]]
example = [[

View file

@ -14,7 +14,7 @@ copyright = ''
author = '0xdrrb'
version = 'v0.1.2'
desc = [[
This is a script that tries to dump and decrypt the data of a specific type of Mifare laundromat token.
This is a script that tries to dump and decrypt the data of a specific type of Mifare laundromat token.
OBS! Tag must be on the antenna.
]]
example = [[

View file

@ -1,6 +1,6 @@
//-----------------------------------------------------------------------------
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
// modified Marshmellow,
// modified Marshmellow,
// modified Iceman 2019, 2020, 2021
//
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
@ -309,9 +309,9 @@ void save_restoreDB(uint8_t saveOpt) {
static int CmdSetDebugMode(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data setdebugmode",
"Set debugging level on client side",
"data setdebugmode"
);
"Set debugging level on client side",
"data setdebugmode"
);
void *argtable[] = {
arg_param_begin,
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);
CLIParserFree(ctx);
if (dg_0 + dg_1 + dg_2 > 1 ) {
if (dg_0 + dg_1 + dg_2 > 1) {
PrintAndLogEx(INFO, "Select only one option");
return PM3_EINVARG;
}
@ -339,7 +339,7 @@ static int CmdSetDebugMode(const char *Cmd) {
if (dg_2)
g_debugMode = 2;
switch(g_debugMode) {
switch (g_debugMode) {
case 0:
PrintAndLogEx(INFO, "client debug level... %u ( no debug messages )", g_debugMode);
break;
@ -428,15 +428,15 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h
int CmdPrintDemodBuff(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data print",
"Print the data in the DemodBuffer as hex or binary.\n"
"Defaults to binary output",
"data print"
);
"Print the data in the DemodBuffer as hex or binary.\n"
"Defaults to binary output",
"data print"
);
void *argtable[] = {
arg_param_begin,
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("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("x", "hex", "output in hex (omit for binary output)"),
arg_param_end
@ -458,11 +458,11 @@ int CmdPrintDemodBuff(const char *Cmd) {
int CmdGetBitStream(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data getbitstream",
"Convert GraphBuffer's value accordingly\n"
" - larger or equal to ONE becomes ONE\n"
" - less than ONE becomes ZERO",
"data getbitstream"
);
"Convert GraphBuffer's value accordingly\n"
" - larger or equal to ONE becomes ONE\n"
" - less than ONE becomes ZERO",
"data getbitstream"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -482,9 +482,9 @@ static int CmdConvertBitStream(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data convertbitstream",
"Convert GraphBuffer's 0|1 values to 127|-127",
"data convertbitstream"
);
"Convert GraphBuffer's 0|1 values to 127|-127",
"data convertbitstream"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -644,11 +644,11 @@ static int Cmdaskmandemod(const char *Cmd) {
static int Cmdmandecoderaw(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data manrawdecode",
"Manchester decode binary stream in DemodBuffer\n"
"Converts 10 and 01 and converts to 0 and 1 respectively\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)",
"data manrawdecode"
);
"Manchester decode binary stream in DemodBuffer\n"
"Converts 10 and 01 and converts to 0 and 1 respectively\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)",
"data manrawdecode"
);
void *argtable[] = {
arg_param_begin,
arg_lit0("i", "inv", "invert output"),
@ -658,7 +658,7 @@ static int Cmdmandecoderaw(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, true);
bool invert = arg_get_lit(ctx, 1);
int max_err = arg_get_int_def(ctx, 2, 20);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (DemodBufferLen == 0) {
PrintAndLogEx(WARNING, "DemodBuffer empty, run " _YELLOW_("`data rawdemod ar`"));
@ -726,13 +726,13 @@ static int Cmdmandecoderaw(const char *Cmd) {
static int CmdBiphaseDecodeRaw(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data biphaserawdecode",
"Biphase decode binary stream in DemodBuffer\n"
"Converts 10 or 01 -> 1 and 11 or 00 -> 0\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)\n"
" - invert for Conditional Dephase Encoding (CDP) AKA Differential Manchester",
"data biphaserawdecode --> decode biphase bitstream from the demodbuffer\n"
"data biphaserawdecode -oi --> decode biphase bitstream from the demodbuffer, adjust offset, and invert output"
);
"Biphase decode binary stream in DemodBuffer\n"
"Converts 10 or 01 -> 1 and 11 or 00 -> 0\n"
" - must have binary sequence in demodbuffer (run `data rawdemod ar` before)\n"
" - invert for Conditional Dephase Encoding (CDP) AKA Differential Manchester",
"data biphaserawdecode --> decode biphase bitstream from the demodbuffer\n"
"data biphaserawdecode -oi --> decode biphase bitstream from the demodbuffer, adjust offset, and invert output"
);
void *argtable[] = {
arg_param_begin,
arg_lit0("o", "offset", "set to adjust decode start position"),
@ -744,7 +744,7 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) {
int offset = arg_get_lit(ctx, 1);
bool invert = arg_get_lit(ctx, 2);
int max_err = arg_get_int_def(ctx, 3, 20);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (DemodBufferLen == 0) {
PrintAndLogEx(WARNING, "DemodBuffer empty, run " _YELLOW_("`data rawdemod ar`"));
@ -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) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data autocorr",
"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",
"data autocorr -w 4000\n"
"data autocorr -w 4000 -g"
);
"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",
"data autocorr -w 4000\n"
"data autocorr -w 4000 -g"
);
void *argtable[] = {
arg_param_begin,
arg_lit0("g", NULL, "save back to GraphBuffer (overwrite)"),
@ -979,9 +979,9 @@ static int CmdBitsamples(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data bitsamples",
"Get raw samples from device as bitstring",
"data bitsamples"
);
"Get raw samples from device as bitstring",
"data bitsamples"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -1013,10 +1013,10 @@ static int CmdBitsamples(const char *Cmd) {
static int CmdBuffClear(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data clear",
"This function clears the bigbuff on deviceside\n"
"and graph window",
"data clear"
);
"This function clears the bigbuff on deviceside\n"
"and graph window",
"data clear"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -1105,10 +1105,10 @@ static int CmdGraphShiftZero(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data shiftgraphzero",
"Shift 0 for Graphed wave + or - shift value",
"data shiftgraphzero -n 10 --> shift 10 points\n"
"data shiftgraphzero -n -22 --> shift negative 22 points"
);
"Shift 0 for Graphed wave + or - shift value",
"data shiftgraphzero -n 10 --> shift 10 points\n"
"data shiftgraphzero -n -22 --> shift negative 22 points"
);
void *argtable[] = {
arg_param_begin,
arg_int1("n", NULL, "<dec>", "shift + or -"),
@ -1150,10 +1150,10 @@ static int CmdAskEdgeDetect(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data askedgedetect",
"Adjust Graph for manual ASK demod using the length of sample differences\n"
"to detect the edge of a wave",
"data askedgedetect -t 20"
);
"Adjust Graph for manual ASK demod using the length of sample differences\n"
"to detect the edge of a wave",
"data askedgedetect -t 20"
);
void *argtable[] = {
arg_param_begin,
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) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data detectclock",
"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 -F --> detect clock of an fsk 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"
);
"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 -F --> detect clock of an fsk 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"
);
void *argtable[] = {
arg_param_begin,
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) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data grid",
"This function overlay grid on graph plot window.\n"
"use zero value to turn off either",
"data grid --> turn off\n"
"data grid -x 64 -y 50"
);
"This function overlay grid on graph plot window.\n"
"use zero value to turn off either",
"data grid --> turn off\n"
"data grid -x 64 -y 50"
);
void *argtable[] = {
arg_param_begin,
arg_dbl0("x", NULL, "<dec>", "plot grid X coord"),
@ -1563,10 +1563,10 @@ int CmdGrid(const char *Cmd) {
static int CmdSetGraphMarkers(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data setgraphmarkers",
"Set blue and orange marker in graph window",
"data setgraphmarkers --> turn off\n"
"data setgraphmarkers -a 64 -b 50"
);
"Set blue and orange marker in graph window",
"data setgraphmarkers --> turn off\n"
"data setgraphmarkers -a 64 -b 50"
);
void *argtable[] = {
arg_param_begin,
arg_u64_0("a", NULL, "<dec>", "orange marker"),
@ -1586,9 +1586,9 @@ static int CmdHexsamples(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data hexsamples",
"Dump big buffer as hex bytes",
"data hexsamples -n 128 --> dumps 128 bytes from offset 0"
);
"Dump big buffer as hex bytes",
"data hexsamples -n 128 --> dumps 128 bytes from offset 0"
);
void *argtable[] = {
arg_param_begin,
arg_u64_0("b", "breaks", "<dec>", "row break, def 16"),
@ -1603,7 +1603,7 @@ static int CmdHexsamples(const char *Cmd) {
CLIParserFree(ctx);
// sanity checks
if (requested > pm3_capabilities.bigbuf_size) {
if (requested > pm3_capabilities.bigbuf_size) {
requested = pm3_capabilities.bigbuf_size;
PrintAndLogEx(INFO, "n is larger than big buffer size, will use %u", requested);
}
@ -1611,10 +1611,10 @@ static int CmdHexsamples(const char *Cmd) {
uint8_t got[pm3_capabilities.bigbuf_size];
if (offset + requested > sizeof(got)) {
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes %u> + <offset %u> > %d"
, requested
, offset
, pm3_capabilities.bigbuf_size
);
, requested
, offset
, pm3_capabilities.bigbuf_size
);
return PM3_EINVARG;
}
@ -1630,9 +1630,9 @@ static int CmdHexsamples(const char *Cmd) {
static int CmdHide(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data hide",
"Show graph window",
"data hide"
);
"Show graph window",
"data hide"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -1647,9 +1647,9 @@ static int CmdHide(const char *Cmd) {
int CmdHpf(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data hpf",
"Remove DC offset from trace. It should centralize around 0",
"data hpf"
);
"Remove DC offset from trace. It should centralize around 0",
"data hpf"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -1762,13 +1762,13 @@ static int CmdSamples(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data samples",
"Get raw samples for graph window (GraphBuffer) from device.\n"
"If 0, then get whole big buffer from device.",
"data samples"
);
"Get raw samples for graph window (GraphBuffer) from device.\n"
"If 0, then get whole big buffer from device.",
"data samples"
);
void *argtable[] = {
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_param_end
};
@ -1783,11 +1783,11 @@ int CmdTuneSamples(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data tune",
"Measure tuning of device antenna. Results shown in graph window.\n"
"This command doesn't actively tune your antennas, \n"
"it's only informative by measuring voltage that the antennas will generate",
"data tune"
);
"Measure tuning of device antenna. Results shown in graph window.\n"
"This command doesn't actively tune your antennas, \n"
"it's only informative by measuring voltage that the antennas will generate",
"data tune"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -2038,9 +2038,9 @@ static int CmdLoad(const char *Cmd) {
int CmdLtrim(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data ltrim",
"Trim samples from left of trace",
"data ltrim -i 300 --> keep 300 - end"
);
"Trim samples from left of trace",
"data ltrim -i 300 --> keep 300 - end"
);
void *argtable[] = {
arg_param_begin,
arg_u64_1("i", "idx", "<dec>", "from index to beginning trace"),
@ -2070,9 +2070,9 @@ static int CmdRtrim(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data rtrim",
"Trim samples from right of trace",
"data rtrim -i 4000 --> keep 0 - 4000"
);
"Trim samples from right of trace",
"data rtrim -i 4000 --> keep 0 - 4000"
);
void *argtable[] = {
arg_param_begin,
arg_u64_1("i", "idx", "<dec>", "from index to end trace"),
@ -2098,9 +2098,9 @@ static int CmdMtrim(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data mtrim",
"Trim out samples from the specified start to the specified end point",
"data mtrim -s 1000 -e 2000 --> keep between 1000 and 2000"
);
"Trim out samples from the specified start to the specified end point",
"data mtrim -s 1000 -e 2000 --> keep between 1000 and 2000"
);
void *argtable[] = {
arg_param_begin,
arg_u64_1("s", "start", "<dec>", "start point"),
@ -2132,9 +2132,9 @@ int CmdNorm(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data norm",
"Normalize max/min to +/-128",
"data norm"
);
"Normalize max/min to +/-128",
"data norm"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -2169,10 +2169,10 @@ int CmdNorm(const char *Cmd) {
int CmdPlot(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data plot",
"Show graph window \n"
"hit 'h' in window for detail keystroke help available",
"data plot"
);
"Show graph window \n"
"hit 'h' in window for detail keystroke help available",
"data plot"
);
void *argtable[] = {
arg_param_begin,
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) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data dirthreshold",
"Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev.",
"data dirthreshold -u 10 -d -10"
);
"Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev.",
"data dirthreshold -u 10 -d -10"
);
void *argtable[] = {
arg_param_begin,
arg_int1("d", "down", "<dec>", "threshold down"),
@ -2311,9 +2311,9 @@ static int CmdDirectionalThreshold(const char *Cmd) {
static int CmdZerocrossings(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data zerocrossings",
"Count time between zero-crossings",
"data zerocrossings"
);
"Count time between zero-crossings",
"data zerocrossings"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -2359,10 +2359,10 @@ static int Cmdbin2hex(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data bin2hex",
"This function converts binary to hexadecimal. It will ignore all\n"
"characters not 1 or 0 but stop reading on whitespace",
"data bin2hex -d 0101111001010"
);
"This function converts binary to hexadecimal. It will ignore all\n"
"characters not 1 or 0 but stop reading on whitespace",
"data bin2hex -d 0101111001010"
);
void *argtable[] = {
arg_param_begin,
arg_strx0("d", "data", "<bin>", "binary string to convert"),
@ -2378,8 +2378,8 @@ static int Cmdbin2hex(const char *Cmd) {
PrintAndLogEx(FAILED, "Error parsing binary string");
return PM3_EINVARG;
}
// Number of digits supplied as argument
// Number of digits supplied as argument
size_t bytelen = (blen + 7) / 8;
uint8_t *arr = (uint8_t *) calloc(bytelen, sizeof(uint8_t));
memset(arr, 0, bytelen);
@ -2406,10 +2406,10 @@ static int Cmdbin2hex(const char *Cmd) {
static int Cmdhex2bin(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data hex2bin",
"This function converts hexadecimal to binary. It will ignore all\n"
"non-hexadecimal characters but stop reading on whitespace",
"data hex2bin -d 01020304"
);
"This function converts hexadecimal to binary. It will ignore all\n"
"non-hexadecimal characters but stop reading on whitespace",
"data hex2bin -d 01020304"
);
void *argtable[] = {
arg_param_begin,
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++) {
char x = data[i];
if (isxdigit(x) == false) {
PrintAndLogEx(ERR, "Non hex digit found");
return PM3_EINVARG;
}
char x = data[i];
if (isxdigit(x) == false) {
PrintAndLogEx(ERR, "Non hex digit found");
return PM3_EINVARG;
}
}
PrintAndLogEx(SUCCESS, "" NOLF);
@ -2598,7 +2598,7 @@ static int FSKToNRZ(int *data, size_t *dataLen, uint8_t clk, uint8_t LowToneFC,
}
static int CmdFSKToNRZ(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data fsktonrz",
"Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk)\n"
@ -2632,9 +2632,9 @@ static int CmdDataIIR(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data iir",
"Apply IIR buttersworth filter on plot data",
"data iir -n 2"
);
"Apply IIR buttersworth filter on plot data",
"data iir -n 2"
);
void *argtable[] = {
arg_param_begin,
arg_u64_1("n", NULL, "<dec>", "factor n"),
@ -2703,7 +2703,7 @@ typedef struct {
static int print_modulation(lf_modulation_t b) {
PrintAndLogEx(INFO, " Modulation........ " _GREEN_("%s"), GetSelectedModulationStr(b.modulation));
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) {
case DEMOD_PSK1:
case DEMOD_PSK2:

View file

@ -1151,7 +1151,7 @@ static int CmdHF14BWriteSri(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false);
int blockno = arg_get_int_def(ctx, 1, -1);
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);
if (res) {
CLIParserFree(ctx);
@ -1170,7 +1170,7 @@ static int CmdHF14BWriteSri(const char *Cmd) {
if (use_sri512 + use_srix4k > 1) {
PrintAndLogEx(FAILED, "Select only one card type");
return PM3_EINVARG;
return PM3_EINVARG;
}
if (use_srix4k && blockno > 0x7F) {

View file

@ -442,7 +442,7 @@ static int getUID(bool loop, uint8_t *buf) {
if (loop == false) {
break;
}
}
}
}
} while (loop && kbd_enter_pressed() == false);
@ -470,7 +470,7 @@ static uint8_t arg_add_default(void *at[]) {
at[5] = arg_lit0("o", "opt", "set OPTION Flag (needed for TI)");
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;
if (unaddressed) {
// 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) {
CLIParserContext *ctx;
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 info",
"Uses the optional command `get_systeminfo` 0x2B to try and extract information",
"hf 15 info\n"
"hf 15 info -*\n"
"hf 15 info -u E011223344556677"
);
);
void *argtable[6+1] = {};
void *argtable[6 + 1] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_param_end;
@ -844,7 +844,7 @@ static int CmdHF15Info(const char *Cmd) {
if (getUID(false, uid) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "no tag found");
return PM3_EINVARG;
}
}
uidlen = 8;
}
@ -853,7 +853,7 @@ static int CmdHF15Info(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
AddCrc15(req, reqlen);
@ -1079,9 +1079,9 @@ static int CmdHF15WriteAfi(const char *Cmd) {
"Write AFI on card",
"hf 15 writeafi -* --afi 12\n"
"hf 15 writeafi -u E011223344556677 --afi 12"
);
);
void *argtable[6+2] = {};
void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1(NULL, "afi", "<dec>", "AFI number (0-255)");
argtable[arglen++] = arg_param_end;
@ -1124,7 +1124,7 @@ static int CmdHF15WriteAfi(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
}
// enforce, since we are writing
@ -1176,9 +1176,9 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
"Write DSFID on card",
"hf 15 writedsfid -* --dsfid 12\n"
"hf 15 writedsfid -u E011223344556677 --dsfid 12"
);
);
void *argtable[6+2] = {};
void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1(NULL, "dsfid", "<dec>", "DSFID number (0-255)");
argtable[arglen++] = arg_param_end;
@ -1223,7 +1223,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
}
// dsfid
@ -1239,7 +1239,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
// arg2 (recv == 1 == expect a response)
uint8_t read_respone = 1;
PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen) );
PrintAndLogEx(DEBUG, "cmd %s", sprint_hex(req, reqlen));
PacketResponseNG resp;
clearCommandBuffer();
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 -u E011223344556677 -f hf-15-my-dump.bin"
);
);
void *argtable[6+2] = {};
void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable);
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);
@ -1321,7 +1321,7 @@ static int CmdHF15Dump(const char *Cmd) {
if (getUID(false, uid) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "no tag found");
return PM3_EINVARG;
}
}
uidlen = 8;
}
@ -1330,7 +1330,7 @@ static int CmdHF15Dump(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
// detect blocksize from card :)
@ -1409,12 +1409,12 @@ static int CmdHF15Dump(const char *Cmd) {
sprintf(lck, "%d", mem[i].lock);
}
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s"
, i
, i
, sprint_hex(mem[i].block, 4)
, lck
, sprint_ascii(mem[i].block, 4)
);
, i
, i
, sprint_hex(mem[i].block, 4)
, lck
, sprint_ascii(mem[i].block, 4)
);
}
PrintAndLogEx(NORMAL, "");
@ -1449,7 +1449,7 @@ static int CmdHF15Raw(const char *Cmd) {
"Sends raw bytes over ISO-15693 to card",
"hf 15 raw -c -d 260100 --> add crc\n"
"hf 15 raw -krc -d 260100 --> add crc, keep field on, skip response"
);
);
void *argtable[] = {
arg_param_begin,
@ -1517,9 +1517,9 @@ static int CmdHF15Readmulti(const char *Cmd) {
"Read multiple pages on a ISO-15693 tag ",
"hf 15 rdmulti -* -b 1 --cnt 6 -> read 6 blocks\n"
"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);
argtable[arglen++] = arg_int1("b", NULL, "<dec>", "first page number (0-255)");
argtable[arglen++] = arg_int1(NULL, "cnt", "<dec>", "number of pages (1-6)");
@ -1570,7 +1570,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
}
// add OPTION flag, in order to get lock-info
req[0] |= ISO15_REQ_OPTION;
@ -1653,9 +1653,9 @@ static int CmdHF15Readblock(const char *Cmd) {
"Read page on ISO-15693 tag",
"hf 15 rdbl -* -b 12\n"
"hf 15 rdbl -u E011223344556677 -b 12"
);
);
void *argtable[6+2] = {};
void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
argtable[arglen++] = arg_param_end;
@ -1679,7 +1679,7 @@ static int CmdHF15Readblock(const char *Cmd) {
return PM3_EINVARG;
}
// default fallback to scan for tag.
// default fallback to scan for tag.
// overriding unaddress parameter :)
if (uidlen != 8) {
scan = true;
@ -1704,7 +1704,7 @@ static int CmdHF15Readblock(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
}
// add OPTION flag, in order to get lock-info
req[0] |= ISO15_REQ_OPTION;
@ -1819,9 +1819,9 @@ static int CmdHF15Write(const char *Cmd) {
"Write block on ISO-15693 tag",
"hf 15 wrbl -* -b 12 -d AABBCCDD\n"
"hf 15 wrbl -u E011223344556677 -b 12 -d AABBCCDD"
);
);
void *argtable[6+4] = {};
void *argtable[6 + 4] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
argtable[arglen++] = arg_str1("d", "data", "<hex>", "data, 4 bytes");
@ -1856,7 +1856,7 @@ static int CmdHF15Write(const char *Cmd) {
return PM3_EINVARG;
}
// default fallback to scan for tag.
// default fallback to scan for tag.
// overriding unaddress parameter :)
if (uidlen != 8) {
scan = true;
@ -1884,7 +1884,7 @@ static int CmdHF15Write(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
}
@ -1913,14 +1913,14 @@ static int CmdHF15Restore(const char *Cmd) {
"hf 15 restore\n"
"hf 15 restore -*\n"
"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);
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(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
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_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -1950,7 +1950,7 @@ static int CmdHF15Restore(const char *Cmd) {
return PM3_EINVARG;
}
// default fallback to scan for tag.
// default fallback to scan for tag.
// overriding unaddress parameter :)
if (uidlen != 8) {
scan = true;
@ -1968,7 +1968,7 @@ static int CmdHF15Restore(const char *Cmd) {
if (getUID(false, uid) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "no tag found");
return PM3_EINVARG;
}
}
uidlen = 8;
}
@ -1977,9 +1977,9 @@ static int CmdHF15Restore(const char *Cmd) {
memcpy(req + reqlen, uid, sizeof(uid));
reqlen += sizeof(uid);
}
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
PrintAndLogEx(SUCCESS, "Using UID... " _GREEN_("%s"), iso15693_sprintUID(NULL, uid));
} else {
PrintAndLogEx(SUCCESS, "Using unaddressed mode");
PrintAndLogEx(SUCCESS, "Using unaddressed mode");
}
PrintAndLogEx(INFO, "Using block size... %d", blocksize);

View file

@ -39,10 +39,10 @@ static void print_status_flag1_interpretation(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
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"
" | 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"
" | 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.");
" | 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.");
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
}
@ -51,28 +51,28 @@ static void print_status_flag2_interpration(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
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"
" | 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, " 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"
" | 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.");
" | 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.");
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"
" | 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"
" | 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).");
" | 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).");
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"
" | 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"
" | 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, " 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, " 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.");
@ -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, " 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"
" | 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, " 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.");
@ -111,9 +111,9 @@ static void print_number_of_block_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, " - 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"
" (or Request Service v2) command.");
" (or Request Service v2) command.");
}
/*
@ -209,7 +209,7 @@ static bool add_last_IDm(uint8_t position, uint8_t *data) {
if (last_known_card.IDm[0] != 0 && last_known_card.IDm[1] != 0) {
memcpy(data + position, last_known_card.IDm, sizeof(last_known_card.IDm));
return true;
}
}
return false;
}
@ -447,7 +447,7 @@ static bool check_last_idm(uint8_t *data, uint16_t datalen) {
PrintAndLogEx(WARNING, "No last known card! Use `" _YELLOW_("hf felica reader") "` first or set a custom IDm");
return false;
}
PrintAndLogEx(INFO, "Using last known IDm... " _GREEN_("%s"), sprint_hex_inrow(data, datalen));
return true;
}
@ -467,7 +467,7 @@ static int send_wr_plain(uint8_t flags, uint16_t datalen, uint8_t *data, bool ve
if (waitCmdFelica(0, &resp, verbose) == false) {
PrintAndLogEx(ERR, "no response from card");
return PM3_ERFTRANS;
}
}
memcpy(wr_noCry_resp, (felica_status_response_t *)resp.data.asBytes, sizeof(felica_status_response_t));
return PM3_SUCCESS;
@ -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) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf felica auth1",
"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"
_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 AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n"
"hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\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"
_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 AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAA\n"
"hf felica auth1 -i 11100910C11BC407 --an 01 --acl 0000 --sn 01 ..scl 8B00 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
);
void *argtable[] = {
arg_param_begin,
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];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length
data[1] = 0x3E; // Command ID
@ -580,14 +580,14 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
memcpy(data + 2, idm, 8);
}
// Length (1),
// Command ID (1),
// IDm (8),
// Number of Area (1),
// Area Code List (2),
// Number of Service (1),
// Service Code List (2),
// M1c (16)
// Length (1),
// Command ID (1),
// IDm (8),
// Number of Area (1),
// Area Code List (2),
// Number of Service (1),
// Service Code List (2),
// M1c (16)
uint16_t datalen = 32;
data[0] = (datalen & 0xFF);
data[1] = 0x10; // Command ID
@ -597,14 +597,14 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
}
if (anlen) {
data[10] = an[0];
data[10] = an[0];
}
if (acllen) {
data[11] = acl[0];
data[12] = acl[1];
}
if (snlen) {
data[13] = sn[0];
data[13] = sn[0];
}
if (scllen) {
data[14] = scl[0];
@ -615,7 +615,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
}
// 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));
// Create M1c Challenge with 3DES (3 Keys = 24, 2 Keys = 16)
@ -624,7 +624,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
mbedtls_des3_init(&des3_ctx);
if (keylen == 24) {
mbedtls_des3_set3key_enc(&des3_ctx, master_key);
PrintAndLogEx(INFO, "3DES Master Secret: %s", sprint_hex(master_key, keylen));
@ -659,8 +659,8 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
if (waitCmdFelica(0, &resp, 1) == false) {
PrintAndLogEx(ERR, "no response from card");
return PM3_ERFTRANS;
}
}
felica_auth1_response_t auth1_response;
memcpy(&auth1_response, (felica_auth1_response_t *)resp.data.asBytes, sizeof(felica_auth1_response_t));
@ -710,12 +710,12 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf felica auth2",
"Complete mutual authentication. This command can only be executed subsquent to Auth1\n"
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n")
_RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"),
"hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
"hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
);
"Complete mutual authentication. This command can only be executed subsquent to Auth1\n"
_RED_("INCOMPLETE / EXPERIMENTAL COMMAND!!!\n")
_RED_("EXPERIMENTAL COMMAND - M2c/P2c will be not checked"),
"hf felica auth2 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
"hf felica auth2 -i 11100910C11BC407 --cc 0102030405060708 --key AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\n"
);
void *argtable[] = {
arg_param_begin,
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];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
bool custom_IDm = false;
@ -776,7 +776,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
}
if (cclen) {
memcpy(data + 16, cc, cclen);
memcpy(data + 16, cc, cclen);
}
if (keylen) {
@ -791,7 +791,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
// M3c (8) == cc
// unsigned char m3c[8]; == cc
mbedtls_des3_context des3_ctx_enc;
mbedtls_des3_context des3_ctx_dec;
@ -824,7 +824,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
unsigned char p3c[8];
mbedtls_des3_crypt_ecb(&des3_ctx_dec, cc, p3c);
PrintAndLogEx(INFO, "3DES decrypted M3c = P3c... %s", sprint_hex_inrow(p3c, sizeof(p3c)));
// Encrypt p3c with master_key
unsigned char m4c[8];
mbedtls_des3_crypt_ecb(&des3_ctx_enc, p3c, m4c);
@ -848,7 +848,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
if (waitCmdFelica(0, &resp, 1) == false) {
PrintAndLogEx(ERR, "no response from card");
return PM3_ERFTRANS;
}
}
felica_auth2_response_t auth2_response;
memcpy(&auth2_response, (felica_auth2_response_t *)resp.data.asBytes, sizeof(felica_auth2_response_t));
@ -954,7 +954,7 @@ static int CmdHFFelicaWritePlain(const char *Cmd) {
}
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x20; // Static length
data[1] = 0x08; // Command ID
@ -1115,7 +1115,7 @@ static int CmdHFFelicaReadPlain(const char *Cmd) {
}
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x10; // Static length
data[1] = 0x06; // Command ID
@ -1152,7 +1152,7 @@ static int CmdHFFelicaReadPlain(const char *Cmd) {
PrintAndLogEx(INFO, "block | data ");
PrintAndLogEx(INFO, "------+----------------------------------------");
// main loop block reads
if (all_block_list_elements) {
@ -1217,7 +1217,7 @@ static int CmdHFFelicaRequestResponse(const char *Cmd) {
CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x0A; // Static length
data[1] = 0x04; // Command ID
@ -1294,7 +1294,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
return PM3_EINVARG;
}
uint8_t reserved[2] = {0,0};
uint8_t reserved[2] = {0, 0};
int rlen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
if (res) {
@ -1310,7 +1310,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length
data[1] = 0x3C; // Command ID
@ -1322,9 +1322,9 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
memcpy(data + 2, idm, sizeof(idm));
}
// add custom reserved
if (rlen ) {
memcpy(data +10, reserved, sizeof(reserved));
// add custom reserved
if (rlen) {
memcpy(data + 10, reserved, sizeof(reserved));
} else {
data[10] = 0x00; // Reserved Value
data[11] = 0x00; // Reserved Value
@ -1337,7 +1337,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
AddCrc(data, datalen);
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);
@ -1346,7 +1346,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
PrintAndLogEx(FAILED, "Got no response from card");
return PM3_ERFTRANS;
}
felica_request_spec_response_t spec_response;
memcpy(&spec_response, (felica_request_spec_response_t *)resp.data.asBytes, sizeof(felica_request_spec_response_t));
@ -1401,7 +1401,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
return PM3_EINVARG;
}
uint8_t reserved[2] = {0,0};
uint8_t reserved[2] = {0, 0};
int rlen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 2), reserved, sizeof(reserved), &rlen);
if (res) {
@ -1417,7 +1417,7 @@ static int CmdHFFelicaResetMode(const char *Cmd) {
CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x0C; // Static length
data[1] = 0x3E; // Command ID
@ -1495,7 +1495,7 @@ static int CmdHFFelicaRequestSystemCode(const char *Cmd) {
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
data[0] = 0x0A; // Static length
data[1] = 0x0C; // Command ID
@ -1578,7 +1578,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
return PM3_EINVARG;
}
uint8_t code[2] = {0,0};
uint8_t code[2] = {0, 0};
int clen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 3), code, sizeof(code), &clen);
if (res) {
@ -1596,7 +1596,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
CLIParserFree(ctx);
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
bool custom_IDm = false;
@ -1608,10 +1608,10 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
if (all_nodes == false) {
// Node Number
if (nlen == 1) {
memcpy(data + 10, node, sizeof(node));
memcpy(data + 10, node, sizeof(node));
}
// code
// code
if (clen == 2) {
memcpy(data + 11, code, sizeof(code));
}
@ -2055,7 +2055,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
int datalen = 0;
uint8_t data[PM3_CMD_DATA_SIZE];
memset(data, 0 , sizeof(data));
memset(data, 0, sizeof(data));
CLIGetHexWithReturn(ctx, 7, data, &datalen);
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 -p s0 s1 -> execute command with plain parameters\n"
"hf fido reg --cp 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f --ap 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\n"
);
);
void *argtable[] = {
arg_param_begin,
@ -693,7 +693,7 @@ static int cmd_hf_fido_2make_credential(const char *cmd) {
"Sample file `fido2.json` in `client/resources/`.",
"hf fido make -> default parameters file `fido2.json`\n"
"hf fido make -f test.json -> use parameters file `text.json`"
);
);
void *argtable[] = {
arg_param_begin,

View file

@ -352,7 +352,7 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
uint8_t block[MFBLOCK_SIZE] = {0x00};
int blen = 0;
CLIGetHexWithReturn(ctx, 5, block, &blen);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (blen != MFBLOCK_SIZE) {
PrintAndLogEx(WARNING, "block data must include 16 HEX bytes. Got %i", blen);
@ -386,7 +386,7 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
} else {
PrintAndLogEx(FAILED, "Write ( " _RED_("fail") " )");
// 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;
}
@ -423,7 +423,7 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
uint8_t key[6] = {0};
CLIGetHexWithReturn(ctx, 4, key, &keylen);
bool verbose = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (b > 255) {
return PM3_EINVARG;
@ -477,7 +477,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
int s = arg_get_int_def(ctx, 4, 0);
bool verbose = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (s > MIFARE_4K_MAXSECTOR) {
PrintAndLogEx(WARNING, "Sector number must be less then 40");
@ -504,7 +504,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
if (verbose) {
decode_print_st(start + blocks - 1, data + ((blocks - 1) * MFBLOCK_SIZE));
}
}
}
free(data);
PrintAndLogEx(NORMAL, "");
@ -813,7 +813,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
"The key file and data file will program the card sector trailers.\n"
"By default we authenticate to card with key B 0xFFFFFFFFFFFF.\n"
"\n"
"`--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin.\n"
"`--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin.\n"
" If not specified, it will read the card uid instead.\n"
" `-w` param you can indicate that the key file should be used for authentication instead.\n"
" if so we also try both B/A keys",
@ -821,7 +821,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
"hf mf restore --1k --uid 04010203\n"
"hf mf restore --1k --uid 04010203 -k hf-mf-AABBCCDD-key.bin\n"
"hf mf restore --4k"
);
);
void *argtable[] = {
arg_param_begin,
@ -952,7 +952,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
return PM3_EINVARG;
}
// default authentication key
// default authentication key
uint8_t default_key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
PrintAndLogEx(INFO, "Restoring " _YELLOW_("%s")" to card", datafilename);
@ -974,7 +974,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
if (use_keyfile_for_auth == false) {
// sector trailer
if (b == NumBlocksPerSector(s) - 1) {
if (b == NumBlocksPerSector(s) - 1) {
bldata[0] = (keyA[s][0]);
bldata[1] = (keyA[s][1]);
bldata[2] = (keyA[s][2]);
@ -1622,7 +1622,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
"hf mf hardnested -r --tk a0a1a2a3a4a5\n"
"hf mf hardnested -t --tk a0a1a2a3a4a5\n"
"hf mf hardnested --blk 0 -a -k a0a1a2a3a4a5 --tblk 4 --ta --tk FFFFFFFFFFFF"
);
);
void *argtable[] = {
arg_param_begin,
@ -1635,7 +1635,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
arg_lit0(NULL, "tb", "Target key B"),
arg_str0(NULL, "tk", "<hex>", "Target key, 12 hex bytes"), // 8
arg_str0("u", "uid", "<hex>", "R/W `hf-mf-<UID>-nonces.bin` instead of default name"),
arg_str0("f", "file", "<fn>", "R/W <name> instead of default name"),
arg_str0("f", "file", "<fn>", "R/W <name> instead of default name"),
arg_lit0("r", "read", "Read `hf-mf-<UID>-nonces.bin` if tag present, otherwise `nonces.bin`, and start attack"),
arg_lit0("s", "slow", "Slower acquisition (required by some non standard cards)"),
arg_lit0("t", "tests", "Run tests"),
@ -1751,7 +1751,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
free(fptr);
}
if (uidlen) {
if (uidlen) {
snprintf(filename, FILE_PATH_SIZE, "hf-mf-%s-nonces.bin", uid);
}
@ -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"),
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],
know_target_key ? "" : " (not set)"
);
@ -1808,7 +1808,7 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
static int CmdHF14AMfAutoPWN(const char *Cmd) {
CLIParserContext *ctx;
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf autopwn",
"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"
@ -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 --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"
);
);
void *argtable[] = {
arg_param_begin,
@ -1825,7 +1825,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
arg_int0("s", "sector", "<dec>", "Input sector number"),
arg_lit0("a", NULL, "Input key A (def)"),
arg_lit0("b", NULL, "Input key B"),
arg_str0("f", "file", "<fn>", "filename of dictionary"),
arg_str0("f", "file", "<fn>", "filename of dictionary"),
arg_lit0("s", "slow", "Slower acquisition (required by some non standard cards)"),
arg_lit0("l", "legacy", "legacy mode (use the slow `hf mf chk`)"),
arg_lit0("v", "verbose", "verbose output (statistics)"),
@ -2197,7 +2197,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
} else {
PrintAndLogEx(SUCCESS, "target sector %3u key type %c -- found valid key [ " _GREEN_("%s") " ]",
i,
(j == MF_KEY_B)? 'B' : 'A',
(j == MF_KEY_B) ? 'B' : 'A',
sprint_hex_inrow(tmp_key, sizeof(tmp_key))
);
}
@ -3560,7 +3560,7 @@ static int CmdHF14AMfEGetBlk(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false);
int b = arg_get_int_def(ctx, 1, 0);
bool verbose = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (b > 255) {
return PM3_EINVARG;
@ -3597,7 +3597,7 @@ static int CmdHF14AMfEGetSc(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false);
int s = arg_get_int_def(ctx, 1, 0);
bool verbose = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (s > 39) {
PrintAndLogEx(WARNING, "Sector number must be less then 40");
@ -3636,7 +3636,7 @@ static int CmdHF14AMfEClear(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
CLIParserFree(ctx);
clearCommandBuffer();
SendCommandNG(CMD_HF_MIFARE_EML_MEMCLR, NULL, 0);
return PM3_SUCCESS;
@ -3662,7 +3662,7 @@ static int CmdHF14AMfESet(const char *Cmd) {
uint8_t data[16] = {0x00};
int datalen = 0;
int res = CLIParamHexToBuf(arg_get_str(ctx, 2), data, sizeof(data), &datalen);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (res) {
PrintAndLogEx(FAILED, "Error parsing bytes");
return PM3_EINVARG;
@ -3701,7 +3701,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
int fnlen = 0;
char filename[FILE_PATH_SIZE];
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
@ -3714,7 +3714,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
int numblks = arg_get_int_def(ctx, 7, -1);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4 + mu) > 1) {
@ -3876,7 +3876,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
int fnlen = 0;
char filename[FILE_PATH_SIZE];
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
@ -3885,7 +3885,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
bool m1 = arg_get_lit(ctx, 3);
bool m2 = arg_get_lit(ctx, 4);
bool m4 = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -3895,7 +3895,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
m1 = true;
}
uint16_t block_cnt = MIFARE_1K_MAXBLOCK;
uint16_t block_cnt = MIFARE_1K_MAXBLOCK;
if (m0) {
block_cnt = MIFARE_MINI_MAXBLOCK;
@ -3959,7 +3959,7 @@ static int CmdHF14AMfEView(const char *Cmd) {
bool m1 = arg_get_lit(ctx, 2);
bool m2 = arg_get_lit(ctx, 3);
bool m4 = arg_get_lit(ctx, 4);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -4038,7 +4038,7 @@ static int CmdHF14AMfECFill(const char *Cmd) {
bool m1 = arg_get_lit(ctx, 4);
bool m2 = arg_get_lit(ctx, 5);
bool m4 = arg_get_lit(ctx, 6);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -4099,7 +4099,7 @@ static int CmdHF14AMfEKeyPrn(const char *Cmd) {
bool m1 = arg_get_lit(ctx, 3);
bool m2 = arg_get_lit(ctx, 4);
bool m4 = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -4209,7 +4209,7 @@ static int CmdHF14AMfCSetUID(const char *Cmd) {
int slen = 0;
uint8_t sak[1] = {0x00};
CLIGetHexWithReturn(ctx, 4, sak, &slen);
CLIParserFree(ctx);
CLIParserFree(ctx);
// sanity checks
if (uidlen != 4 && uidlen != 7) {
@ -4229,14 +4229,14 @@ static int CmdHF14AMfCSetUID(const char *Cmd) {
uint8_t verify_uid[7] = {0};
int res = mfCSetUID(
uid,
uidlen,
(alen) ? atqa : NULL,
(slen) ? sak : NULL,
old_uid,
verify_uid,
wipe_card
);
uid,
uidlen,
(alen) ? atqa : NULL,
(slen) ? sak : NULL,
old_uid,
verify_uid,
wipe_card
);
if (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, "New UID... %s ( %s )",
sprint_hex(verify_uid, uidlen),
(res == 0) ? _GREEN_("verified") : _RED_("fail")
);
sprint_hex(verify_uid, uidlen),
(res == 0) ? _GREEN_("verified") : _RED_("fail")
);
return PM3_SUCCESS;
}
@ -4273,11 +4273,11 @@ static int CmdHF14AMfCWipe(const char *cmd) {
int uidlen = 0;
uint8_t uid[8] = {0x00};
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
int alen = 0;
uint8_t atqa[2] = {0x00};
CLIGetHexWithReturn(ctx, 2, atqa, &alen);
int slen = 0;
uint8_t sak[1] = {0x00};
CLIGetHexWithReturn(ctx, 3, sak, &slen);
@ -4329,9 +4329,9 @@ static int CmdHF14AMfCSetBlk(const char *Cmd) {
CLIGetHexWithReturn(ctx, 2, data, &datalen);
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);
return PM3_EINVARG;
}
@ -4372,13 +4372,13 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
int fnlen = 0;
char filename[FILE_PATH_SIZE];
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool fill_from_emulator = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (fill_from_emulator) {
@ -4458,7 +4458,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
// 64 or 256blocks.
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);
free(data);
return PM3_EFILE;
@ -4508,7 +4508,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
// confirm number written blocks. Must be 64 or 256 blocks
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);
return PM3_EFILE;
}
@ -4538,7 +4538,7 @@ static int CmdHF14AMfCGetBlk(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false);
int b = arg_get_int_def(ctx, 1, 0);
bool verbose = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (b > 255) {
return PM3_EINVARG;
@ -4555,7 +4555,7 @@ static int CmdHF14AMfCGetBlk(const char *Cmd) {
uint8_t sector = GetSectorFromBlockNo(blockno);
mf_print_sector_hdr(sector);
mf_print_block(blockno, data);
if (verbose) {
decode_print_st(blockno, data);
} else {
@ -4580,7 +4580,7 @@ static int CmdHF14AMfCGetSc(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, false);
int s = arg_get_int_def(ctx, 1, 0);
bool verbose = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (s > 39) {
PrintAndLogEx(WARNING, "Sector number must be less then 40");
return PM3_EINVARG;
@ -4636,7 +4636,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
int fnlen = 0;
char filename[FILE_PATH_SIZE];
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
@ -4646,7 +4646,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
bool m2 = arg_get_lit(ctx, 4);
bool m4 = arg_get_lit(ctx, 5);
bool fill_emulator = arg_get_lit(ctx, 6);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -4791,7 +4791,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
bool m1 = arg_get_lit(ctx, 2);
bool m2 = arg_get_lit(ctx, 3);
bool m4 = arg_get_lit(ctx, 4);
CLIParserFree(ctx);
CLIParserFree(ctx);
// validations
if ((m0 + m1 + m2 + m4) > 1) {
@ -4906,7 +4906,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
uint32_t nt = 0;
int res = arg_get_u32_hexstr_def(ctx, 1, 0, &nt);
if (res != 1) {
CLIParserFree(ctx);
CLIParserFree(ctx);
PrintAndLogEx(WARNING, "check `nt` parameter");
return PM3_EINVARG;
}
@ -4914,7 +4914,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
uint32_t ar_enc = 0;
res = arg_get_u32_hexstr_def(ctx, 2, 0, &ar_enc);
if (res != 1) {
CLIParserFree(ctx);
CLIParserFree(ctx);
PrintAndLogEx(WARNING, "check `ar` parameter");
return PM3_EINVARG;
}
@ -4922,7 +4922,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
uint32_t at_enc = 0;
res = arg_get_u32_hexstr_def(ctx, 3, 0, &at_enc);
if (res != 1) {
CLIParserFree(ctx);
CLIParserFree(ctx);
PrintAndLogEx(WARNING, "check `at` parameter");
return PM3_EINVARG;
}
@ -4930,7 +4930,7 @@ static int CmdHf14AMfDecryptBytes(const char *Cmd) {
int datalen = 0;
uint8_t data[512] = {0x00};
CLIGetHexWithReturn(ctx, 4, data, &datalen);
CLIParserFree(ctx);
CLIParserFree(ctx);
PrintAndLogEx(INFO, "nt....... %08X", nt);
PrintAndLogEx(INFO, "ar enc... %08X", ar_enc);
@ -4955,12 +4955,12 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
bool m0 = arg_get_lit(ctx, 1);
bool m1 = arg_get_lit(ctx, 2);
bool m1 = arg_get_lit(ctx, 2);
int keylen = 0;
uint8_t key[6] = {0};
CLIGetHexWithReturn(ctx, 3, key, &keylen);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (m0 + m1 > 1) {
PrintAndLogEx(WARNING, "please select one modulation");
@ -5006,7 +5006,7 @@ static int CmdHf14AMfNack(const char *Cmd) {
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
bool verbose = arg_get_lit(ctx, 1);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (verbose)
PrintAndLogEx(INFO, "Started testing card for NACK bug. Press Enter to abort");
@ -5439,7 +5439,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
"hf mf personalize -f2 -> single size random ID\n"
"hf mf personalize -f3 -> single size NUID\n"
"hf mf personalize -b -k B0B1B2B3B4B5 -f3 -> use key B = 0xB0B1B2B3B4B5"
);
);
void *argtable[] = {
arg_param_begin,
@ -5449,7 +5449,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
arg_lit0(NULL, "f0", "UIDFO, double size UID"),
arg_lit0(NULL, "f1", "UIDF1, double size UID, optional usage of selection process shortcut"),
arg_lit0(NULL, "f2", "UIDF2, single size random ID"),
arg_lit0(NULL, "f3", "UIDF3, single size NUID"),
arg_lit0(NULL, "f3", "UIDF3, single size NUID"),
arg_param_end
};
CLIExecWithReturn(ctx, cmd, argtable, true);
@ -5462,7 +5462,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
CLIParserFree(ctx);
return PM3_EINVARG;
}
uint8_t keytype = 0;
if (use_b) {
keytype = 1;
@ -5500,7 +5500,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
pers_option = MIFARE_EV1_UIDF1;
} else if (f2) {
pers_option = MIFARE_EV1_UIDF2;
}
}
CLIParserFree(ctx);
@ -5520,7 +5520,7 @@ static int CmdHFMFPersonalize(const char *cmd) {
return PM3_ETIMEOUT;
}
if ( resp.status == PM3_SUCCESS) {
if (resp.status == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "Personalization ( %s )", _GREEN_("ok"));
} else {
PrintAndLogEx(FAILED, "Personalization ( %s )", _RED_("fail"));
@ -5551,11 +5551,11 @@ static int CmdHf14AGen3UID(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
uint8_t uid[7] = {0};
int uidlen = 0;
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
CLIParserFree(ctx);
CLIParserFree(ctx);
// sanity checks
if (uidlen != 4 && uidlen != 7) {
@ -5598,11 +5598,11 @@ static int CmdHf14AGen3Block(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
uint8_t data[MFBLOCK_SIZE] = {0x00};
int datalen = 0;
CLIGetHexWithReturn(ctx, 1, data, &datalen);
CLIParserFree(ctx);
CLIParserFree(ctx);
uint8_t new_block[MFBLOCK_SIZE] = {0x00};
int res = mfGen3Block(data, datalen, new_block);
@ -5630,7 +5630,7 @@ static int CmdHf14AGen3Freeze(const char *Cmd) {
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
bool confirm = arg_get_lit(ctx, 1);
CLIParserFree(ctx);
CLIParserFree(ctx);
if (confirm == false) {
PrintAndLogEx(INFO, "please confirm that you want to perma lock the card");
return PM3_SUCCESS;
@ -5907,7 +5907,7 @@ out:
}
static int CmdHF14AMfView(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf view",
"Print a MIFARE Classic dump file (bin/eml/json)",
@ -5919,12 +5919,12 @@ static int CmdHF14AMfView(const char *Cmd) {
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
CLIExecWithReturn(ctx, Cmd, argtable, false);
int fnlen = 0;
char filename[FILE_PATH_SIZE];
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool verbose = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
CLIParserFree(ctx);
// reserve memory
uint8_t *dump = calloc(MFBLOCK_SIZE * MIFARE_4K_MAXBLOCK, sizeof(uint8_t));

View file

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

View file

@ -460,13 +460,13 @@ static int CmdHFMFPWritePerso(const char *Cmd) {
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
bool verbose = arg_get_lit(ctx, 1);
uint8_t keyNum[64] = {0};
int keyNumLen = 0;
CLIGetHexWithReturn(ctx, 2, keyNum, &keyNumLen);
uint8_t key[64] = {0};
int keyLen = 0;
CLIGetHexWithReturn(ctx, 3, key, &keyLen);
@ -546,7 +546,7 @@ static int CmdHFMFPInitPerso(const char *Cmd) {
uint8_t data[250] = {0};
int datalen = 0;
int res;
mfpSetVerboseMode(verbose2);
for (uint16_t sn = 0x4000; sn < 0x4050; sn++) {
keyNum[0] = sn >> 8;
@ -590,8 +590,8 @@ static int CmdHFMFPCommitPerso(const char *Cmd) {
CLIParserInit(&ctx, "hf mfp commitp",
"Executes Commit Perso command. Can be used in SL0 mode only.",
"hf mfp commitp\n"
// "hf mfp commitp --sl 1"
);
// "hf mfp commitp --sl 1"
);
void *argtable[] = {
arg_param_begin,
@ -601,7 +601,7 @@ static int CmdHFMFPCommitPerso(const char *Cmd) {
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
bool verbose = arg_get_lit(ctx, 1);
// int slmode = arg_get_int(ctx, 2);
// int slmode = arg_get_int(ctx, 2);
CLIParserFree(ctx);
mfpSetVerboseMode(verbose);
@ -677,7 +677,7 @@ static int CmdHFMFPRdbl(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
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("p", "plain", "plain communication mode between reader and card"),
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",
"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"
);
);
void *argtable[] = {
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 --23 -k 4F4E4D494B52\n"
" lf hitag reader --26\n"
);
);
void *argtable[] = {
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, "25", "Hitag2, test recorded authentications (replay?)"),
arg_lit0(NULL, "26", "Hitag2, read UID"),
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 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_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -592,7 +592,7 @@ static int CmdLFHitagReader(const char *Cmd) {
htf = RHTSF_CHALLENGE;
memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
}
if (s02){
if (s02) {
cmd = CMD_LF_HITAGS_READ;
htf = RHTSF_KEY;
memcpy(htd.crypto.key, key, sizeof(key));
@ -615,7 +615,7 @@ static int CmdLFHitagReader(const char *Cmd) {
if (h26) {
htf = RHT2F_UID_ONLY;
}
clearCommandBuffer();
SendCommandMIX(cmd, htf, 0, 0, &htd, sizeof(htd));
PacketResponseNG resp;
@ -698,7 +698,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
"Hitag 2\n"
" lf hitag writer --24 -k 4F4E4D494B52 -p 3 -d 01020304\n"
" lf hitag writer --27 -k 4D494B52 -p 3 -d 01020304\n"
);
);
void *argtable[] = {
arg_param_begin,
@ -708,8 +708,8 @@ static int CmdLFHitagWriter(const char *Cmd) {
arg_lit0(NULL, "27", "Hitag2, write page, password mode"),
arg_int1("p", "page", "<dec>", "page address to write to"),
arg_str0("d", "data", "<hex>", "data, 4 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("k", "key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL, "nrar", "<hex>", "nonce / answer writer, 8 hex bytes"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -743,7 +743,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
uint8_t nrar[8];
int nalen = 0;
res = CLIParamHexToBuf(arg_get_str(ctx, 8), nrar, sizeof(nrar), &nalen);
CLIParserFree(ctx);
if (res != 0) {
@ -782,7 +782,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
memcpy(htd.auth.NrAr, nrar, sizeof(nrar));
memcpy(htd.auth.data, data, sizeof(data));
}
if (s04){
if (s04) {
htf = WHTSF_KEY;
memcpy(htd.crypto.key, key, sizeof(key));
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.",
"lf hitag dump -k 4F4E4D494B52\n"
"lf hitag dump -k 4D494B52\n"
);
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "file name"),
arg_str0("k","key", "<hex>", "key, 4 or 6 hex bytes"),
arg_str0(NULL,"nrar", "<hex>", "nonce / answer reader, 8 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_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -858,23 +858,23 @@ static int CmdLFHitag2Dump(const char *Cmd) {
PrintAndLogEx(WARNING, "to be implememted...");
/*
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
/*
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
clearCommandBuffer();
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd));
PacketResponseNG resp;
uint8_t *data = resp.data.asBytes;
if (fnlen < 1) {
char *fptr = filename;
fptr += sprintf(fptr, "lf-hitag-");
FillFileNameByUID(fptr, data, "-dump", 4);
}
clearCommandBuffer();
//SendCommandNG(CMD_LF_HITAG_DUMP, &htd, sizeof(htd));
PacketResponseNG resp;
uint8_t *data = resp.data.asBytes;
if (fnlen < 1) {
char *fptr = filename;
fptr += sprintf(fptr, "lf-hitag-");
FillFileNameByUID(fptr, data, "-dump", 4);
}
saveFile(filename, ".bin", data, 48);
saveFileEML(filename, data, 48, 4);
saveFileJSON(filename, jsfHitag, data, 48, NULL);
*/
saveFile(filename, ".bin", data, 48);
saveFileEML(filename, data, 48, 4);
saveFileJSON(filename, jsfHitag, data, 48, NULL);
*/
return PM3_SUCCESS;
}

View file

@ -2336,7 +2336,7 @@ static int CmdT55xxRestore(const char *Cmd) {
return PM3_EINVARG;
}
size_t dlen = 0;
size_t dlen = 0;
uint8_t *dump = calloc(T55x7_BLOCK_COUNT * 4, sizeof(uint8_t));
if (dump == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
@ -2387,7 +2387,7 @@ static int CmdT55xxRestore(const char *Cmd) {
if (usepwd)
snprintf(pwdopt, sizeof(pwdopt), "-p %08X", password);
uint32_t *data = (uint32_t*) dump;
uint32_t *data = (uint32_t *) dump;
uint8_t idx;
// Restore endien for writing to card
for (idx = 0; idx < 12; idx++) {

View file

@ -137,7 +137,7 @@ int CmdWiegandDecode(const char *Cmd) {
uint32_t top = 0, mid = 0, bot = 0;
if (hlen) {
if (hlen) {
res = hexstring_to_u96(&top, &mid, &bot, hex);
if (res != hlen) {
PrintAndLogEx(ERR, "hex string contains none hex chars");

View file

@ -1083,7 +1083,7 @@ static int CmdEMVExec(const char *Cmd) {
PrintAndLogEx(NORMAL, "AC: %s", sprint_hex(AC->value, AC->len));
if (IAD) {
PrintAndLogEx(NORMAL, "IAD: %s", sprint_hex(IAD->value, IAD->len));
// https://mst-company.ru/blog/ekvajring-emv-tranzaktsiya-emv-transaction-flow-chast-4-pdol-i-beskontaktnye-karty-osobennosti-qvsdc-i-quics
if (IAD->value[0] == 0x1f) {
PrintAndLogEx(NORMAL, " Key index: 0x%02x", IAD->value[2]);
@ -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",
"emv scan -at -> scan MSD transaction mode and show APDU and TLV\n"
"emv scan -c -> scan CDA transaction mode\n"
);
);
void *argtable[] = {
arg_param_begin,
@ -1818,7 +1818,7 @@ static int CmdEMVTest(const char *Cmd) {
"Executes tests\n",
"emv test -i\n"
"emv test --long"
);
);
void *argtable[] = {
arg_param_begin,

View file

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

View file

@ -58,7 +58,7 @@ typedef struct thread_key_args {
uint32_t nt_enc;
uint32_t nr_enc;
uint16_t enc_len;
uint8_t enc[ENC_LEN]; // next encrypted command + a full read/write
uint8_t enc[ENC_LEN]; // next encrypted command + a full read/write
} targs_key;
//------------------------------------------------------------------
@ -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,
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;
@ -444,13 +444,13 @@ static void *brute_thread(void *arguments) {
if (args->ev1) {
// 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);
} else {
printf("\nKey candidate [ " _GREEN_("....%08" PRIx64) " ]\n\n", key & 0xFFFFFFFF);
__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
pthread_mutex_unlock(&print_lock);
break;
@ -493,14 +493,14 @@ static void *brute_key_thread(void *arguments) {
// check if cmd exists
uint8_t isOK = checkValidCmdByte(dec, args->enc_len);
if (isOK == false) {
if (isOK == false) {
continue;
}
}
// lock this section to avoid interlacing prints from different threats
pthread_mutex_lock(&print_lock);
printf("\nenc: %s\n", sprint_hex_inrow_ex(local_enc, args->enc_len, 0));
printf("dec: %s\n", sprint_hex_inrow_ex(dec, args->enc_len, 0));
printf("dec: %s\n", sprint_hex_inrow_ex(dec, args->enc_len, 0));
printf("\nValid Key found [ " _GREEN_("%012" PRIx64) " ]\n\n", key);
pthread_mutex_unlock(&print_lock);
__sync_fetch_and_add(&global_found, 1);
@ -547,7 +547,7 @@ int main(int argc, char *argv[]) {
sscanf(argv[8], "%x", &at_par_err);
int enc_len = 0;
uint8_t enc[ENC_LEN] = {0}; // next encrypted command + a full read/write
uint8_t enc[ENC_LEN] = {0}; // next encrypted command + a full read/write
if (argc > 9) {
// sscanf(argv[9], "%x", &cmd_enc);
param_gethex_to_eol(argv[9], 0, enc, sizeof(enc), &enc_len);
@ -565,7 +565,7 @@ int main(int argc, char *argv[]) {
printf("at parity err........ %04x\n", at_par_err);
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();
@ -615,11 +615,11 @@ int main(int argc, char *argv[]) {
t1 = clock() - t1;
printf("execution time %.2f sec\n", (float)t1 / 1000000.0);
if (!global_found && !global_found_candidate) {
printf("\nFailed to find a key\n\n");
goto out;
}
}
if (enc_len < 4) {
printf("Too few next cmd bytes, skipping phase 2\n");
@ -635,7 +635,7 @@ int main(int argc, char *argv[]) {
printf("partial key.. %08x\n", (uint32_t)(global_candiate_key & 0xFFFFFFFF));
printf("nt enc....... %08x\n", nt_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");
fflush(stdout);