This commit is contained in:
Philippe Teuwen 2021-04-18 18:31:51 +02:00
commit ed78bca62b
6 changed files with 113 additions and 113 deletions

View file

@ -113,7 +113,7 @@ end
local function dump_tag(uid, sak) local function dump_tag(uid, sak)
dbg('dumping tag memory') dbg('dumping tag memory')
if utils.confirm('Do you wish to create a memory dump of tag?') then if utils.confirm('Do you wish to create a memory dump of tag?') then
local dumpfile = 'hf-mf-'..uid..'-dump' local dumpfile = 'hf-mf-'..uid..'-dump'

View file

@ -24,7 +24,7 @@ static int openAIDFile(json_t **root, bool verbose) {
int retval = PM3_SUCCESS; int retval = PM3_SUCCESS;
*root = json_load_file(path, 0, &error); *root = json_load_file(path, 0, &error);
if (!*root) { if (!*root) {
PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text); PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text);
retval = PM3_ESOFT; retval = PM3_ESOFT;
goto out; goto out;

View file

@ -365,18 +365,18 @@ static int CmdConvertBitStream(const char *Cmd) {
// askType switches decode: ask/raw = 0, ask/manchester = 1 // askType switches decode: ask/raw = 0, ask/manchester = 1
int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, bool verbose, bool emSearch, uint8_t askType, bool *stCheck) { int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, bool verbose, bool emSearch, uint8_t askType, bool *stCheck) {
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) clk %i invert %i maxErr %i maxLen %zu amplify %i verbose %i emSearch %i askType %i " PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) clk %i invert %i maxErr %i maxLen %zu amplify %i verbose %i emSearch %i askType %i "
, clk , clk
, invert , invert
, maxErr , maxErr
, maxlen , maxlen
, amplify , amplify
, verbose , verbose
, emSearch , emSearch
, askType , askType
); );
uint8_t askamp = 0; uint8_t askamp = 0;
if (maxlen == 0) if (maxlen == 0)
maxlen = pm3_capabilities.bigbuf_size; maxlen = pm3_capabilities.bigbuf_size;
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t)); uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
@ -427,32 +427,32 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b
if (errCnt < 0 || bitlen < 16) { //if fatal error (or -1) if (errCnt < 0 || bitlen < 16) { //if fatal error (or -1)
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) No data found errors:%d, %s bitlen:%zu, clock:%d" PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) No data found errors:%d, %s bitlen:%zu, clock:%d"
, errCnt , errCnt
, (invert) ? "inverted," : "" , (invert) ? "inverted," : ""
, bitlen , bitlen
, clk , clk
); );
free(bits); free(bits);
return PM3_ESOFT; return PM3_ESOFT;
} }
if (errCnt > maxErr) { if (errCnt > maxErr) {
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Too many errors found, errors:%d, bits:%zu, clock:%d" PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Too many errors found, errors:%d, bits:%zu, clock:%d"
, errCnt , errCnt
, bitlen , bitlen
, clk , clk
); );
free(bits); free(bits);
return PM3_ESOFT; return PM3_ESOFT;
} }
if (verbose) { if (verbose) {
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) using clock:%d, %sbits found:%zu, start index %d" PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) using clock:%d, %sbits found:%zu, start index %d"
, clk , clk
, (invert) ? "inverted, " : "" , (invert) ? "inverted, " : ""
, bitlen , bitlen
, start_idx , start_idx
); );
} }
//output //output
@ -465,10 +465,10 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b
if (askType) { if (askType) {
PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Manchester") " - clock %d - decoded bitstream", clk); PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Manchester") " - clock %d - decoded bitstream", clk);
PrintAndLogEx(INFO,"---------------------------------------------"); PrintAndLogEx(INFO, "---------------------------------------------");
} else { } else {
PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Raw") " - clock %d - decoded bitstream", clk); PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Raw") " - clock %d - decoded bitstream", clk);
PrintAndLogEx(INFO,"--------------------------------------"); PrintAndLogEx(INFO, "--------------------------------------");
} }
printDemodBuff(0, false, false, false); printDemodBuff(0, false, false, false);
@ -493,18 +493,18 @@ int ASKDemod(int clk, int invert, int maxErr, size_t maxlen, bool amplify, bool
static int Cmdaskmandemod(const char *Cmd) { static int Cmdaskmandemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --am", CLIParserInit(&ctx, "data rawdemod --am",
"ASK/MANCHESTER demodulate the data in the GraphBuffer and output binary", "ASK/MANCHESTER demodulate the data in the GraphBuffer and output binary",
"data rawdemod --am --> demod a ask/manchester tag, using autodetect\n" "data rawdemod --am --> demod a ask/manchester tag, using autodetect\n"
"data rawdemod --am -c 32 --> demod a ask/manchester tag, using a clock of RF/32\n" "data rawdemod --am -c 32 --> demod a ask/manchester tag, using a clock of RF/32\n"
"data rawdemod --am -i --> demod a ask/manchester tag, using autodetect, invert output\n" "data rawdemod --am -i --> demod a ask/manchester tag, using autodetect, invert output\n"
"data rawdemod --am -c 32 -i --> demod a ask/manchester tag, using a clock of RF/32, invert output\n" "data rawdemod --am -c 32 -i --> demod a ask/manchester tag, using a clock of RF/32, invert output\n"
"data rawdemod --am -c 64 -i --max 0 --> demod a ask/manchester tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --am -c 64 -i --max 0 --> demod a ask/manchester tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"), arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"),
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_lit0("s", "st", "check for sequence terminator"), arg_lit0("s", "st", "check for sequence terminator"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"),
arg_int0(NULL, "samples", "<dec>", "maximum samples to read (def 32768) [512 bits at RF/64]"), arg_int0(NULL, "samples", "<dec>", "maximum samples to read (def 32768) [512 bits at RF/64]"),
@ -708,18 +708,18 @@ int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) {
static int Cmdaskbiphdemod(const char *Cmd) { static int Cmdaskbiphdemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --ab", CLIParserInit(&ctx, "data rawdemod --ab",
"ASK/BIPHASE demodulate the data in the GraphBuffer and output binary\n" "ASK/BIPHASE demodulate the data in the GraphBuffer and output binary\n"
"NOTE, `--invert` for Conditional Dephase Encoding (CDP) AKA Differential Manchester\n", "NOTE, `--invert` for Conditional Dephase Encoding (CDP) AKA Differential Manchester\n",
"data rawdemod --ab --> demod a ask/biphase tag, using autodetect\n" "data rawdemod --ab --> demod a ask/biphase tag, using autodetect\n"
"data rawdemod --ab -c 32 --> demod a ask/biphase tag, using a clock of RF/32\n" "data rawdemod --ab -c 32 --> demod a ask/biphase tag, using a clock of RF/32\n"
"data rawdemod --ab -i --> demod a ask/biphase tag, using autodetect, invert output\n" "data rawdemod --ab -i --> demod a ask/biphase tag, using autodetect, invert output\n"
"data rawdemod --ab -c 32 -i --> demod a ask/biphase tag, using a clock of RF/32, invert output\n" "data rawdemod --ab -c 32 -i --> demod a ask/biphase tag, using a clock of RF/32, invert output\n"
"data rawdemod --ab -c 64 -i --max 0 --> demod a ask/biphase tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --ab -c 64 -i --max 0 --> demod a ask/biphase tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_int0("o", "offset", "<dec>", "offset to begin biphase (def 0)"), arg_int0("o", "offset", "<dec>", "offset to begin biphase (def 0)"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 50)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 50)"),
arg_param_end arg_param_end
@ -739,18 +739,18 @@ static int Cmdaskbiphdemod(const char *Cmd) {
static int Cmdaskrawdemod(const char *Cmd) { static int Cmdaskrawdemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --ar", CLIParserInit(&ctx, "data rawdemod --ar",
"ASK/RAW demodulate the data in the GraphBuffer and output binary", "ASK/RAW demodulate the data in the GraphBuffer and output binary",
"data rawdemod --ar -a --> demod a ask tag, using autodetect, amplified\n" "data rawdemod --ar -a --> demod a ask tag, using autodetect, amplified\n"
"data rawdemod --ar -c 32 --> demod a ask tag, using a clock of RF/32\n" "data rawdemod --ar -c 32 --> demod a ask tag, using a clock of RF/32\n"
"data rawdemod --ar -i --> demod a ask tag, using autodetect, invert output\n" "data rawdemod --ar -i --> demod a ask tag, using autodetect, invert output\n"
"data rawdemod --ar -c 32 -i --> demod a ask tag, using a clock of RF/32, invert output\n" "data rawdemod --ar -c 32 -i --> demod a ask tag, using a clock of RF/32, invert output\n"
"data rawdemod --ar -c 64 -i --max 0 --> demod a ask tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --ar -c 64 -i --max 0 --> demod a ask tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"), arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"),
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_lit0("s", "st", "check for sequence terminator"), arg_lit0("s", "st", "check for sequence terminator"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"),
arg_int0(NULL, "samples", "<dec>", "maximum samples to read (def 32768) [512 bits at RF/64]"), arg_int0(NULL, "samples", "<dec>", "maximum samples to read (def 32768) [512 bits at RF/64]"),
@ -1179,7 +1179,7 @@ int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bo
size_t bitlen = getFromGraphBuf(bits); size_t bitlen = getFromGraphBuf(bits);
if (bitlen == 0) { if (bitlen == 0) {
PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf"); PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf");
free(bits); free(bits);
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -1211,14 +1211,14 @@ int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bo
// Now output the bitstream to the scrollback by line of 16 bits // Now output the bitstream to the scrollback by line of 16 bits
if (verbose || g_debugMode) { if (verbose || g_debugMode) {
PrintAndLogEx(DEBUG, "DEBUG: (FSKrawDemod) using clock:%u, %sfc high:%u, fc low:%u" PrintAndLogEx(DEBUG, "DEBUG: (FSKrawDemod) using clock:%u, %sfc high:%u, fc low:%u"
, rfLen , rfLen
, (invert) ? "inverted, " : "" , (invert) ? "inverted, " : ""
, fchigh , fchigh
, fclow , fclow
); );
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, _YELLOW_("%s") " decoded bitstream", GetFSKType(fchigh, fclow, invert)); PrintAndLogEx(SUCCESS, _YELLOW_("%s") " decoded bitstream", GetFSKType(fchigh, fclow, invert));
PrintAndLogEx(INFO,"-----------------------"); PrintAndLogEx(INFO, "-----------------------");
printDemodBuff(0, false, invert, false); printDemodBuff(0, false, invert, false);
} }
goto out; goto out;
@ -1237,19 +1237,19 @@ out:
static int CmdFSKrawdemod(const char *Cmd) { static int CmdFSKrawdemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --fs", CLIParserInit(&ctx, "data rawdemod --fs",
"FSK demodulate the data in the GraphBuffer and output binary", "FSK demodulate the data in the GraphBuffer and output binary",
"data rawdemod --fs --> demod an fsk tag, using autodetect\n" "data rawdemod --fs --> demod an fsk tag, using autodetect\n"
"data rawdemod --fs -c 32 --> demod an fsk tag, using a clock of RF/32, autodetect fc\n" "data rawdemod --fs -c 32 --> demod an fsk tag, using a clock of RF/32, autodetect fc\n"
"data rawdemod --fs -i --> demod an fsk tag, using autodetect, invert output\n" "data rawdemod --fs -i --> demod an fsk tag, using autodetect, invert output\n"
"data rawdemod --fs -c 32 -i --> demod an fsk tag, using a clock of RF/32, invert output, autodetect fc\n" "data rawdemod --fs -c 32 -i --> demod an fsk tag, using a clock of RF/32, invert output, autodetect fc\n"
"data rawdemod --fs -c 64 --hi 8 --lo 5 --> demod an fsk1 RF/64 tag\n" "data rawdemod --fs -c 64 --hi 8 --lo 5 --> demod an fsk1 RF/64 tag\n"
"data rawdemod --fs -c 50 --hi 10 --lo 8 --> demod an fsk2 RF/50 tag\n" "data rawdemod --fs -c 50 --hi 10 --lo 8 --> demod an fsk2 RF/50 tag\n"
"data rawdemod --fs -c 50 -i --hi 10 --lo 8 --> demod an fsk2a RF/50 tag\n" "data rawdemod --fs -c 50 -i --hi 10 --lo 8 --> demod an fsk2a RF/50 tag\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("c", "clk", "<dec>", "set clock manually (def: autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def: autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_int0(NULL, "hi", "<dec>", "larger field clock length (def: autodetect)"), arg_int0(NULL, "hi", "<dec>", "larger field clock length (def: autodetect)"),
arg_int0(NULL, "lo", "<dec>", "small field clock length (def: autodetect)"), arg_int0(NULL, "lo", "<dec>", "small field clock length (def: autodetect)"),
arg_param_end arg_param_end
@ -1318,7 +1318,7 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) {
int errCnt = 0, clkStartIdx = 0; int errCnt = 0, clkStartIdx = 0;
if (getSignalProperties()->isnoise) { if (getSignalProperties()->isnoise) {
if (verbose) { if (verbose) {
PrintAndLogEx(INFO, "signal looks like noise"); PrintAndLogEx(INFO, "signal looks like noise");
} }
return PM3_ESOFT; return PM3_ESOFT;
@ -1369,17 +1369,17 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) {
static int CmdNRZrawDemod(const char *Cmd) { static int CmdNRZrawDemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --nr", CLIParserInit(&ctx, "data rawdemod --nr",
"NRZ/DIRECT demodulate the data in the GraphBuffer and output binary", "NRZ/DIRECT demodulate the data in the GraphBuffer and output binary",
"data rawdemod --nr --> demod a nrz/direct tag, using autodetect\n" "data rawdemod --nr --> demod a nrz/direct tag, using autodetect\n"
"data rawdemod --nr -c 32 --> demod a nrz/direct tag, using a clock of RF/32\n" "data rawdemod --nr -c 32 --> demod a nrz/direct tag, using a clock of RF/32\n"
"data rawdemod --nr -i --> demod a nrz/direct tag, using autodetect, invert output\n" "data rawdemod --nr -i --> demod a nrz/direct tag, using autodetect, invert output\n"
"data rawdemod --nr -c 32 -i --> demod a nrz/direct tag, using a clock of RF/32, invert output\n" "data rawdemod --nr -c 32 -i --> demod a nrz/direct tag, using a clock of RF/32, invert output\n"
"data rawdemod --nr -c 64 -i --max 0 --> demod a nrz/direct tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --nr -c 64 -i --max 0 --> demod a nrz/direct tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"),
arg_param_end arg_param_end
}; };
@ -1399,17 +1399,17 @@ static int CmdNRZrawDemod(const char *Cmd) {
int CmdPSK1rawDemod(const char *Cmd) { int CmdPSK1rawDemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --p1", CLIParserInit(&ctx, "data rawdemod --p1",
"PSK1 demodulate the data in the GraphBuffer and output binary", "PSK1 demodulate the data in the GraphBuffer and output binary",
"data rawdemod --p1 --> demod a psk1 tag, using autodetect\n" "data rawdemod --p1 --> demod a psk1 tag, using autodetect\n"
"data rawdemod --p1 -c 32 --> demod a psk1 tag, using a clock of RF/32\n" "data rawdemod --p1 -c 32 --> demod a psk1 tag, using a clock of RF/32\n"
"data rawdemod --p1 -i --> demod a psk1 tag, using autodetect, invert output\n" "data rawdemod --p1 -i --> demod a psk1 tag, using autodetect, invert output\n"
"data rawdemod --p1 -c 32 -i --> demod a psk1 tag, using a clock of RF/32, invert output\n" "data rawdemod --p1 -c 32 -i --> demod a psk1 tag, using a clock of RF/32, invert output\n"
"data rawdemod --p1 -c 64 -i --max 0 --> demod a psk1 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --p1 -c 64 -i --max 0 --> demod a psk1 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"),
arg_param_end arg_param_end
}; };
@ -1437,17 +1437,17 @@ int CmdPSK1rawDemod(const char *Cmd) {
static int CmdPSK2rawDemod(const char *Cmd) { static int CmdPSK2rawDemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod --p2", CLIParserInit(&ctx, "data rawdemod --p2",
"PSK2 demodulate the data in the GraphBuffer and output binary", "PSK2 demodulate the data in the GraphBuffer and output binary",
"data rawdemod --p2 --> demod a psk2 tag, using autodetect\n" "data rawdemod --p2 --> demod a psk2 tag, using autodetect\n"
"data rawdemod --p2 -c 32 --> demod a psk2 tag, using a clock of RF/32\n" "data rawdemod --p2 -c 32 --> demod a psk2 tag, using a clock of RF/32\n"
"data rawdemod --p2 -i --> demod a psk2 tag, using autodetect, invert output\n" "data rawdemod --p2 -i --> demod a psk2 tag, using autodetect, invert output\n"
"data rawdemod --p2 -c 32 -i --> demod a psk2 tag, using a clock of RF/32, invert output\n" "data rawdemod --p2 -c 32 -i --> demod a psk2 tag, using a clock of RF/32, invert output\n"
"data rawdemod --p2 -c 64 -i --max 0 --> demod a psk2 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" "data rawdemod --p2 -c 64 -i --max 0 --> demod a psk2 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"), arg_int0("c", "clk", "<dec>", "set clock manually (def autodetect)"),
arg_lit0("i","inv", "invert output"), arg_lit0("i", "inv", "invert output"),
arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"), arg_int0(NULL, "max", "<dec>", "maximum allowed errors (def 100)"),
arg_param_end arg_param_end
}; };
@ -1476,15 +1476,15 @@ static int CmdRawDemod(const char *Cmd) {
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "data rawdemod", CLIParserInit(&ctx, "data rawdemod",
"Demodulate the data in the GraphBuffer and output binary", "Demodulate the data in the GraphBuffer and output binary",
"data rawdemod --fs --> demod FSK - autodetect\n" "data rawdemod --fs --> demod FSK - autodetect\n"
"data rawdemod --ab --> demod ASK/BIPHASE - autodetect\n" "data rawdemod --ab --> demod ASK/BIPHASE - autodetect\n"
"data rawdemod --am --> demod ASK/MANCHESTER - autodetect\n" "data rawdemod --am --> demod ASK/MANCHESTER - autodetect\n"
"data rawdemod --ar --> demod ASK/RAW - autodetect\n" "data rawdemod --ar --> demod ASK/RAW - autodetect\n"
"data rawdemod --nr --> demod NRZ/DIRECT - autodetect\n" "data rawdemod --nr --> demod NRZ/DIRECT - autodetect\n"
"data rawdemod --p1 --> demod PSK1 - autodetect\n" "data rawdemod --p1 --> demod PSK1 - autodetect\n"
"data rawdemod --p2 --> demod PSK2 - autodetect\n" "data rawdemod --p2 --> demod PSK2 - autodetect\n"
); );
void *argtable[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_lit0(NULL, "ab", "ASK/Biphase demodulation"), arg_lit0(NULL, "ab", "ASK/Biphase demodulation"),
@ -1515,18 +1515,18 @@ static int CmdRawDemod(const char *Cmd) {
CLIParserFree(ctx); CLIParserFree(ctx);
int foo = (ab + am + ar + fs + nr + p1 + p2); int foo = (ab + am + ar + fs + nr + p1 + p2);
if ( foo > 1 ) { if (foo > 1) {
PrintAndLogEx(WARNING, "please, select only one modulation"); PrintAndLogEx(WARNING, "please, select only one modulation");
return PM3_EINVARG; return PM3_EINVARG;
} }
if ( foo == 0 ) { if (foo == 0) {
PrintAndLogEx(WARNING, "please, select a modulation"); PrintAndLogEx(WARNING, "please, select a modulation");
return PM3_EINVARG; return PM3_EINVARG;
} }
int ans = 0; int ans = 0;
const char *s = Cmd + n; const char *s = Cmd + n;
if (fs) if (fs)
ans = CmdFSKrawdemod(s); ans = CmdFSKrawdemod(s);
else if (ab) else if (ab)
ans = Cmdaskbiphdemod(s); ans = Cmdaskbiphdemod(s);

View file

@ -114,7 +114,7 @@ static inline uint32_t leadingzeros(uint64_t a) {
} }
static void iclass_upload_emul(uint8_t *d, uint32_t n, uint32_t *bytes_sent) { static void iclass_upload_emul(uint8_t *d, uint32_t n, uint32_t *bytes_sent) {
// fast push mode // fast push mode
conn.block_after_ACK = true; conn.block_after_ACK = true;
//Send to device //Send to device
@ -265,7 +265,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke
HFiClassCalcDivKey(iclass_last_known_card.csn, iClass_Key_Table[0], iclass_last_known_card.key_d, false); HFiClassCalcDivKey(iclass_last_known_card.csn, iClass_Key_Table[0], iclass_last_known_card.key_d, false);
memset(data, 0x00, tot_bytes); memset(data, 0x00, tot_bytes);
memcpy(data, (uint8_t*)&iclass_last_known_card, sizeof(picopass_hdr_t)); memcpy(data, (uint8_t *)&iclass_last_known_card, sizeof(picopass_hdr_t));
// Keyrolling configuration cards are special. // Keyrolling configuration cards are special.
if (strstr(o->desc, "Keyroll") != NULL) { if (strstr(o->desc, "Keyroll") != NULL) {

View file

@ -777,7 +777,7 @@ void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
for (uint8_t i = 0; i < 2; i++, pos++) { for (uint8_t i = 0; i < 2; i++, pos++) {
bool found_annotation = true; bool found_annotation = true;
switch (cmd[pos]) { switch (cmd[pos]) {
case MFDES_CREATE_APPLICATION: case MFDES_CREATE_APPLICATION:
snprintf(exp, size, "CREATE APPLICATION"); snprintf(exp, size, "CREATE APPLICATION");
@ -897,7 +897,7 @@ void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
found_annotation = false; found_annotation = false;
break; break;
} }
if (found_annotation) { if (found_annotation) {
break; break;
} }

View file

@ -403,7 +403,7 @@ int CmdLFPac(const char *Cmd) {
// find PAC preamble in already demoded data // find PAC preamble in already demoded data
int detectPac(uint8_t *dest, size_t *size, bool *invert) { int detectPac(uint8_t *dest, size_t *size, bool *invert) {
// make sure buffer has data // make sure buffer has data
if (*size < 128) if (*size < 128)
return -1; return -1;
size_t startIdx = 0; size_t startIdx = 0;
@ -422,7 +422,7 @@ int detectPac(uint8_t *dest, size_t *size, bool *invert) {
// wrong demoded size // wrong demoded size
if (*size != 128) if (*size != 128)
return -3; return -3;
// return start position // return start position
return (int)startIdx; return (int)startIdx;
} }