From c6f4bf2aa6bb6683d6ae8a919367ccd3d42c338b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 29 Oct 2019 19:32:27 +0100 Subject: [PATCH 1/6] return codes --- client/cmdhf14b.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/client/cmdhf14b.c b/client/cmdhf14b.c index 03a5f9b9f..ba8db1f92 100644 --- a/client/cmdhf14b.c +++ b/client/cmdhf14b.c @@ -147,15 +147,15 @@ static bool waitCmd14b(bool verbose) { if (len >= 3) { bool crc = check_crc(CRC_14443_B, data, len); - PrintAndLogEx(NORMAL, "[LEN %u] %s[%02X %02X] %s", + PrintAndLogEx(SUCCESS, "[LEN %u] %s[%02X %02X] %s", len, sprint_hex(data, len - 2), data[len - 2], data[len - 1], - (crc) ? "OK" : "FAIL" + (crc) ? _GREEN_("OK") : _RED_("FAIL") ); } else { - PrintAndLogEx(NORMAL, "[LEN %u] %s", len, sprint_hex(data, len)); + PrintAndLogEx(SUCCESS, "[LEN %u] %s", len, sprint_hex(data, len)); } } return true; @@ -182,7 +182,7 @@ static int CmdHF14BSim(const char *Cmd) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443B_SIMULATE, pupi, 0, 0, NULL, 0); - return 0; + return PM3_SUCCESS; } static int CmdHF14BSniff(const char *Cmd) { @@ -192,7 +192,7 @@ static int CmdHF14BSniff(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_HF_ISO14443B_SNIFF, NULL, 0); - return 0; + return PM3_SUCCESS; } static int CmdHF14BCmdRaw(const char *Cmd) { @@ -262,15 +262,16 @@ static int CmdHF14BCmdRaw(const char *Cmd) { continue; } PrintAndLogEx(WARNING, "unknown parameter '%c'\n", param_getchar(Cmd, i)); - return 0; + return PM3_EINVARG; } if (hasTimeout) { -#define MAX_TIMEOUT 40542464 // = (2^32-1) * (8*16) / 13560000Hz * 1000ms/s + +#define MAX_14B_TIMEOUT 40542464 // = (2^32-1) * (8*16) / 13560000Hz * 1000ms/s flags |= ISO14B_SET_TIMEOUT; - if (user_timeout > MAX_TIMEOUT) { - user_timeout = MAX_TIMEOUT; - PrintAndLogEx(NORMAL, "Set timeout to 40542 seconds (11.26 hours). The max we can wait for response"); + if (user_timeout > MAX_14B_TIMEOUT) { + user_timeout = MAX_14B_TIMEOUT; + PrintAndLogEx(INFO, "Set timeout to 40542 seconds (11.26 hours). The max we can wait for response"); } time_wait = 13560000 / 1000 / (8 * 16) * user_timeout; // timeout in ETUs (time to transfer 1 bit, approx. 9.4 us) } @@ -287,7 +288,7 @@ static int CmdHF14BCmdRaw(const char *Cmd) { clearCommandBuffer(); SendCommandOLD(CMD_HF_ISO14443B_COMMAND, flags, datalen, time_wait, data, datalen); - if (!reply) return 1; + if (!reply) return PM3_SUCCESS; bool success = true; // get back iso14b_card_select_t, don't print it. @@ -297,7 +298,7 @@ static int CmdHF14BCmdRaw(const char *Cmd) { // get back response from the raw bytes you sent. if (success && datalen > 0) waitCmd14b(true); - return 1; + return PM3_SUCCESS; } static bool get_14b_UID(iso14b_card_select_t *card) { @@ -484,7 +485,6 @@ static void print_st_general_info(uint8_t *data, uint8_t len) { PrintAndLogEx(NORMAL, " UID: %s", sprint_hex(SwapEndian64(data, 8, 8), len)); PrintAndLogEx(NORMAL, " MFG: %02X, %s", data[6], getTagInfo(data[6])); PrintAndLogEx(NORMAL, "Chip: %02X, %s", data[5] >> 2, get_ST_Chip_Model(data[5] >> 2)); - return; } //05 00 00 = find one tag in field @@ -793,18 +793,18 @@ static int CmdHF14BWriteSri(const char *Cmd) { if (isSrix4k) { if (blockno > 0x7f && blockno != 0xff) { PrintAndLogEx(FAILED, "block number out of range"); - return 0; + return PM3_ESOFT; } } else { if (blockno > 0x0f && blockno != 0xff) { PrintAndLogEx(FAILED, "block number out of range"); - return 0; + return PM3_ESOFT; } } if (param_gethex(Cmd, 2, data, 8)) { PrintAndLogEx(WARNING, "data must include 8 HEX symbols"); - return 0; + return PM3_ESOFT; } if (blockno == 0xff) { @@ -822,8 +822,7 @@ static int CmdHF14BWriteSri(const char *Cmd) { } sprintf(str, "-ss -c %02x %02x %02x %02x %02x %02x", ISO14443B_WRITE_BLK, blockno, data[0], data[1], data[2], data[3]); - CmdHF14BCmdRaw(str); - return 0; + return CmdHF14BCmdRaw(str); } // need to write to file @@ -875,7 +874,7 @@ static int CmdHF14BDump(const char *Cmd) { if (!get_14b_UID(&card)) { PrintAndLogEx(WARNING, "No tag found."); - return 1; + return PM3_SUCCESS; } if (fileNameLen < 1) { @@ -1102,7 +1101,7 @@ static command_t CommandTable[] = { static int CmdHelp(const char *Cmd) { (void)Cmd; // Cmd is not used so far CmdsHelp(CommandTable); - return 0; + return PM3_SUCCESS; } int CmdHF14B(const char *Cmd) { From f9a80ea47bb8ec0a210b7b79290d3c44529eb5bd Mon Sep 17 00:00:00 2001 From: Riley Guerin Date: Tue, 29 Oct 2019 12:41:33 -0700 Subject: [PATCH 2/6] make warning about ModemManager louder #updatingforafriend --- .../Linux-Installation-Instructions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md index f82d0f677..d56d1056c 100644 --- a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md @@ -58,7 +58,8 @@ git clone https://github.com/RfidResearchGroup/proxmark3.git # Check ModemManager -**Very important**: make sure ModemManager will not interfer, otherwise it could brick your Proxmark3! +### ⚠️ Very important ⚠️ +make sure ModemManager will not interfer, otherwise it could brick your Proxmark3! Read carefully [this page about ModemManager](ModemManager-Must-Be-Discarded.md) and follow its instructions. # Check connection From 417679c3d83fce07306d70fd652a7bd285e298bf Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 30 Oct 2019 11:16:53 +0100 Subject: [PATCH 3/6] more keys --- client/dictionaries/mfc_default_keys.dic | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/dictionaries/mfc_default_keys.dic b/client/dictionaries/mfc_default_keys.dic index 376676f1a..ab113b0f5 100644 --- a/client/dictionaries/mfc_default_keys.dic +++ b/client/dictionaries/mfc_default_keys.dic @@ -21,6 +21,8 @@ a0478cc39091 8fd0a4f256e9 # d2ece8b9395e # lib +# NSCP default key +☻1494E81663D7 # # more Keys from mfc_default_keys.lua 000000000001 From 01b149efa5809a4f480f27a9abda325585cc9986 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 30 Oct 2019 15:44:57 +0100 Subject: [PATCH 4/6] fix: fdx crc calc --- client/cmdlffdx.c | 22 ++++++++++++---------- common/crc16.c | 17 ++++++++++++++++- common/crc16.h | 11 ++++++++--- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c index 244c0caf3..6cf3b0efa 100644 --- a/client/cmdlffdx.c +++ b/client/cmdlffdx.c @@ -13,6 +13,7 @@ #include #include #include +#include // tolower #include "cmdparser.h" // command_t #include "comms.h" @@ -226,15 +227,12 @@ static int CmdFdxDemod(const char *Cmd) { uint8_t dataBlockBit = DemodBuffer[48]; uint32_t reservedCode = bytebits_to_byteLSBF(DemodBuffer + 49, 14); uint8_t animalBit = DemodBuffer[63]; - uint32_t crc_16 = bytebits_to_byteLSBF(DemodBuffer + 64, 16); + uint16_t crc = bytebits_to_byteLSBF(DemodBuffer + 64, 16); uint32_t extended = bytebits_to_byteLSBF(DemodBuffer + 80, 24); uint64_t rawid = (uint64_t)(bytebits_to_byte(DemodBuffer, 32)) << 32 | bytebits_to_byte(DemodBuffer + 32, 32); uint8_t raw[8]; num_to_bytes(rawid, 8, raw); - - uint16_t calcCrc = crc16_kermit(raw, 8); - PrintAndLogEx(SUCCESS, "\nFDX-B / ISO 11784/5 Animal Tag ID Found: Raw : %s", sprint_hex(raw, 8)); PrintAndLogEx(SUCCESS, "Animal ID %04u-%012" PRIu64, countryCode, NationalCode); PrintAndLogEx(SUCCESS, "National Code %012" PRIu64 " (0x%" PRIx64 ")", NationalCode, NationalCode); @@ -242,7 +240,10 @@ static int CmdFdxDemod(const char *Cmd) { PrintAndLogEx(SUCCESS, "Reserved/RFU %u (0x04%X)", reservedCode, reservedCode); PrintAndLogEx(SUCCESS, "Animal Tag %s", animalBit ? _YELLOW_("True") : "False"); PrintAndLogEx(SUCCESS, "Has extended data %s [0x%X]", dataBlockBit ? _YELLOW_("True") : "False", extended); - PrintAndLogEx(SUCCESS, "CRC-16 0x%04X - 0x%04X [%s]", crc_16, calcCrc, (calcCrc == crc_16) ? _GREEN_("Ok") : _RED_("Fail")); + + uint8_t c[] = {0, 0}; + compute_crc(CRC_11784, raw, sizeof(raw), &c[0], &c[1]); + PrintAndLogEx(SUCCESS, "CRC-16 0x%04X [ %s] ", crc, (crc == (c[1] << 8 | c[0]) ) ? _GREEN_("OK") : _RED_("Fail")); if (g_debugMode) { PrintAndLogEx(DEBUG, "Start marker %d; Size %zu", preambleIndex, size); @@ -265,8 +266,8 @@ static int CmdFdxClone(const char *Cmd) { uint32_t countryid = 0; uint64_t animalid = 0; - char cmdp = param_getchar(Cmd, 0); - if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_clone(); + char cmdp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_fdx_clone(); countryid = param_get32ex(Cmd, 0, 0, 10); animalid = param_get64ex(Cmd, 1, 0, 10); @@ -305,8 +306,8 @@ static int CmdFdxSim(const char *Cmd) { uint32_t countryid = 0; uint64_t animalid = 0; - char cmdp = param_getchar(Cmd, 0); - if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_sim(); + char cmdp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_fdx_sim(); countryid = param_get32ex(Cmd, 0, 0, 10); animalid = param_get64ex(Cmd, 1, 0, 10); @@ -417,7 +418,8 @@ int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t for (uint8_t i = 0; i < 8; ++i) raw[i] = bytebits_to_byte(bits + 11 + i * 9, 8); - uint16_t crc = crc16_kermit(raw, 8); + init_table(CRC_11784); + uint16_t crc = crc16_fdx(raw, 8); num_to_bytebitsLSBF(crc >> 0, 8, bits + 83); num_to_bytebitsLSBF(crc >> 8, 8, bits + 92); diff --git a/common/crc16.c b/common/crc16.c index 22445beda..b1c2ac248 100644 --- a/common/crc16.c +++ b/common/crc16.c @@ -46,6 +46,9 @@ void init_table(CrcType_t crctype) { case CRC_KERMIT: generate_table(CRC16_POLY_CCITT, true); break; + case CRC_11784: + generate_table(CRC16_POLY_CCITT, false); + break; case CRC_NONE: crc_table_init = false; current_crc_type = CRC_NONE; @@ -185,6 +188,9 @@ void compute_crc(CrcType_t ct, const uint8_t *d, size_t n, uint8_t *first, uint8 case CRC_KERMIT: crc = crc16_kermit(d, n); break; + case CRC_11784: + crc = crc16_fdx(d, n); + break; case CRC_LEGIC: // TODO return; @@ -215,6 +221,8 @@ uint16_t Crc16ex(CrcType_t ct, const uint8_t *d, size_t n) { return crc16_ccitt(d, n); case CRC_KERMIT: return crc16_kermit(d, n); + case CRC_11784: + return crc16_fdx(d, n); case CRC_LEGIC: // TODO return 0; @@ -257,6 +265,8 @@ bool check_crc(CrcType_t ct, const uint8_t *d, size_t n) { return (crc16_ccitt(d, n) == 0); case CRC_KERMIT: return (crc16_kermit(d, n) == 0); + case CRC_11784: + return (crc16_fdx(d, n) == 0); case CRC_LEGIC: // TODO return false; @@ -272,7 +282,12 @@ uint16_t crc16_ccitt(uint8_t const *d, size_t n) { return crc16_fast(d, n, 0xffff, false, false); } -// FDX-B ISO11784/85) uses KERMIT +// FDX-B ISO11784/85) uses KERMIT/CCITT +// poly 0x xx init=0x000 refin=false refout=true xorout=0x0000 ... +uint16_t crc16_fdx(uint8_t const *d, size_t n) { + return crc16_fast(d, n, 0x0000, false, true); +} + // poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 name="KERMIT" uint16_t crc16_kermit(uint8_t const *d, size_t n) { return crc16_fast(d, n, 0x0000, true, true); diff --git a/common/crc16.h b/common/crc16.h index 6989af22e..7a273683c 100644 --- a/common/crc16.h +++ b/common/crc16.h @@ -10,14 +10,16 @@ #include "common.h" -#define CRC16_POLY_CCITT 0x1021 -#define CRC16_POLY_LEGIC 0xc6c6 //0x6363 -#define CRC16_POLY_DNP 0x3d65 +#define CRC16_POLY_CCITT 0x1021 +#define CRC16_POLY_KERMIT 0x8408 +#define CRC16_POLY_LEGIC 0xc6c6 //0x6363 +#define CRC16_POLY_DNP 0x3d65 #define X25_CRC_CHECK ((uint16_t)(~0xF0B8 & 0xFFFF)) // use this for checking of a correct crc typedef enum { CRC_NONE, + CRC_11784, CRC_14443_A, CRC_14443_B, CRC_15693, @@ -41,6 +43,9 @@ bool check_crc(CrcType_t ct, const uint8_t *d, size_t n); uint16_t crc16_ccitt(uint8_t const *d, size_t n); // Calculate CRC-16/KERMIT (FDX-B ISO11784/85) LF +uint16_t crc16_fdx(uint8_t const *d, size_t n); + +// Calculate CRC-16/KERMIT uint16_t crc16_kermit(uint8_t const *d, size_t n); // Calculate CRC-16/XMODEM (FeliCa) From eb7fd5f8ab841dd3a1418e1eedbec5847aa58a3c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 30 Oct 2019 15:45:52 +0100 Subject: [PATCH 5/6] textual --- client/cmdhw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/cmdhw.c b/client/cmdhw.c index 619e73abe..5eb6c7100 100644 --- a/client/cmdhw.c +++ b/client/cmdhw.c @@ -542,7 +542,7 @@ static int CmdPing(const char *Cmd) { bool error = false; if (len) { error = memcmp(data, resp.data.asBytes, len) != 0; - PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received") "and content is %s", error ? _RED_("NOT ok") : _GREEN_("ok")); + PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received") "and content is %s", error ? _RED_("NOT ok") : _GREEN_("OK")); } else { PrintAndLogEx(SUCCESS, "Ping response " _GREEN_("received")); } From b383b16dede8b5f8a5f59eaca3116a626fbf425f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 31 Oct 2019 08:39:11 +0100 Subject: [PATCH 6/6] chg: lf fdx clone/sim - added extended data --- client/cmdlffdx.c | 61 ++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c index 6cf3b0efa..17dbd2fd0 100644 --- a/client/cmdlffdx.c +++ b/client/cmdlffdx.c @@ -50,15 +50,14 @@ static int CmdHelp(const char *Cmd); static int usage_lf_fdx_clone(void) { PrintAndLogEx(NORMAL, "Clone a FDX-B animal tag to a T55x7 tag."); - PrintAndLogEx(NORMAL, "Usage: lf fdx clone [h] "); + PrintAndLogEx(NORMAL, "Usage: lf fdx clone [h] "); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h : This help"); PrintAndLogEx(NORMAL, " : Country id"); PrintAndLogEx(NORMAL, " : Animal id"); - // has extended data? + PrintAndLogEx(NORMAL, " : Extended data"); //reserved/rfu //is animal tag - // extended data PrintAndLogEx(NORMAL, " : Specify write to Q5 (t5555 instead of t55x7)"); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "Examples:"); @@ -70,11 +69,12 @@ static int usage_lf_fdx_sim(void) { PrintAndLogEx(NORMAL, "Enables simulation of FDX-B animal tag"); PrintAndLogEx(NORMAL, "Simulation runs until the button is pressed or another USB command is issued."); PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(NORMAL, "Usage: lf fdx sim [h] "); + PrintAndLogEx(NORMAL, "Usage: lf fdx sim [h] "); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h : This help"); PrintAndLogEx(NORMAL, " : Country ID"); PrintAndLogEx(NORMAL, " : Animal ID"); + PrintAndLogEx(NORMAL, " : Extended data"); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, " lf fdx sim 999 112233"); @@ -82,14 +82,14 @@ static int usage_lf_fdx_sim(void) { } // clearing the topbit needed for the preambl detection. -static void verify_values(uint32_t countryid, uint64_t animalid) { - if ((animalid & 0x3FFFFFFFFF) != animalid) { - animalid &= 0x3FFFFFFFFF; - PrintAndLogEx(INFO, "Animal ID Truncated to 38bits: %"PRIx64, animalid); +static void verify_values(uint64_t *animalid, uint32_t *countryid) { + if ((*animalid & 0x3FFFFFFFFF) != *animalid) { + *animalid &= 0x3FFFFFFFFF; + PrintAndLogEx(INFO, "Animal ID Truncated to 38bits: %"PRIx64, *animalid); } - if ((countryid & 0x3ff) != countryid) { - countryid &= 0x3ff; - PrintAndLogEx(INFO, "Country ID Truncated to 10bits: %03d", countryid); + if ((*countryid & 0x3ff) != *countryid) { + *countryid &= 0x3ff; + PrintAndLogEx(INFO, "Country ID Truncated to 10bits: %03d", *countryid); } } @@ -264,19 +264,21 @@ static int CmdFdxRead(const char *Cmd) { static int CmdFdxClone(const char *Cmd) { - uint32_t countryid = 0; + uint32_t countryid = 0, extended = 0; uint64_t animalid = 0; + char cmdp = tolower(param_getchar(Cmd, 0)); if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_fdx_clone(); countryid = param_get32ex(Cmd, 0, 0, 10); animalid = param_get64ex(Cmd, 1, 0, 10); + extended = param_get32ex(Cmd, 2, 0, 10); - verify_values(countryid, animalid); + verify_values(&animalid, &countryid); uint8_t *bits = calloc(128, sizeof(uint8_t)); - if (getFDXBits(animalid, countryid, 1, 0, 0, bits) != PM3_SUCCESS) { + if (getFDXBits(animalid, countryid, 1, (extended > 0), extended, bits) != PM3_SUCCESS) { PrintAndLogEx(ERR, "Error with tag bitstream generation."); free(bits); return PM3_ESOFT; @@ -285,7 +287,7 @@ static int CmdFdxClone(const char *Cmd) { uint32_t blocks[5] = {T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0}; //Q5 - if (param_getchar(Cmd, 2) == 'Q' || param_getchar(Cmd, 2) == 'q') + if (tolower(param_getchar(Cmd, 2)) == 'q') blocks[0] = T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(32) | 4 << T5555_MAXBLOCK_SHIFT; // convert from bit stream to block data @@ -303,7 +305,7 @@ static int CmdFdxClone(const char *Cmd) { } static int CmdFdxSim(const char *Cmd) { - uint32_t countryid = 0; + uint32_t countryid = 0, extended = 0; uint64_t animalid = 0; char cmdp = tolower(param_getchar(Cmd, 0)); @@ -311,25 +313,33 @@ static int CmdFdxSim(const char *Cmd) { countryid = param_get32ex(Cmd, 0, 0, 10); animalid = param_get64ex(Cmd, 1, 0, 10); + extended = param_get32ex(Cmd, 2, 0 , 10); - verify_values(countryid, animalid); + verify_values(&animalid, &countryid); PrintAndLogEx(SUCCESS, "Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid); - uint8_t bs[128]; //getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) - getFDXBits(animalid, countryid, 1, 0, 0, bs); + uint8_t *bits = calloc(128, sizeof(uint8_t)); + + if (getFDXBits(animalid, countryid, 1, (extended > 0), extended, bits) != PM3_SUCCESS) { + PrintAndLogEx(ERR, "Error with tag bitstream generation."); + free(bits); + return PM3_ESOFT; + } // 32, no STT, BIPHASE INVERTED == diphase - lf_asksim_t *payload = calloc(1, sizeof(lf_asksim_t) + sizeof(bs)); + lf_asksim_t *payload = calloc(1, sizeof(lf_asksim_t) + 128); payload->encoding = 2; payload->invert = 1; payload->separator = 0; payload->clock = 32; - memcpy(payload->data, bs, sizeof(bs)); + memcpy(payload->data, bits, 128); clearCommandBuffer(); - SendCommandNG(CMD_LF_ASK_SIMULATE, (uint8_t *)payload, sizeof(lf_asksim_t) + sizeof(bs)); + SendCommandNG(CMD_LF_ASK_SIMULATE, (uint8_t *)payload, sizeof(lf_asksim_t) + 128); + + free(bits); free(payload); PacketResponseNG resp; @@ -338,6 +348,7 @@ static int CmdFdxSim(const char *Cmd) { PrintAndLogEx(INFO, "Done"); if (resp.status != PM3_EOPABORTED) return resp.status; + return PM3_SUCCESS; } @@ -379,7 +390,7 @@ int demodFDX(void) { return CmdFdxDemod(""); } -int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) { +int getFDXBits(uint64_t national_id, uint16_t country, uint8_t is_animal, uint8_t is_extended, uint32_t extended, uint8_t *bits) { // add preamble ten 0x00 and one 0x01 memset(bits, 0x00, 10); @@ -397,10 +408,10 @@ int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t num_to_bytebitsLSBF(0x00 >> 7, 7, bits + 74); // add animal flag - OK - bits[65] = isanimal; + bits[65] = is_animal; // add extended flag - OK - bits[81] = isextended; + bits[81] = is_extended; // add national code 40bits - OK num_to_bytebitsLSBF(national_id >> 0, 8, bits + 11);