mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
style
This commit is contained in:
parent
0446509d1e
commit
a776f9a0bd
10 changed files with 231 additions and 187 deletions
|
@ -359,15 +359,15 @@ typedef struct _em4x70_transmit_log_t {
|
||||||
em4x70_sublog_t receive;
|
em4x70_sublog_t receive;
|
||||||
} em4x70_transmitted_data_log_t;
|
} em4x70_transmitted_data_log_t;
|
||||||
em4x70_transmitted_data_log_t g_not_used_directly; // change to bigbuff allocation?
|
em4x70_transmitted_data_log_t g_not_used_directly; // change to bigbuff allocation?
|
||||||
em4x70_transmitted_data_log_t* g_Log = &g_not_used_directly;
|
em4x70_transmitted_data_log_t *g_Log = &g_not_used_directly;
|
||||||
static void log_reset(void) {
|
static void log_reset(void) {
|
||||||
if (g_Log != NULL) {
|
if (g_Log != NULL) {
|
||||||
memset(g_Log, 0, sizeof(em4x70_transmitted_data_log_t));
|
memset(g_Log, 0, sizeof(em4x70_transmitted_data_log_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void log_dump_helper(em4x70_sublog_t * part, bool is_transmit) {
|
static void log_dump_helper(em4x70_sublog_t *part, bool is_transmit) {
|
||||||
if (g_dbglevel >= DBG_INFO || FORCE_ENABLE_LOGGING) {
|
if (g_dbglevel >= DBG_INFO || FORCE_ENABLE_LOGGING) {
|
||||||
char const * const direction = is_transmit ? "sent >>>" : "recv <<<";
|
char const *const direction = is_transmit ? "sent >>>" : "recv <<<";
|
||||||
if (part->bits_used == 0) {
|
if (part->bits_used == 0) {
|
||||||
DPRINTF_EXTENDED(("%s: no data", direction));
|
DPRINTF_EXTENDED(("%s: no data", direction));
|
||||||
} else {
|
} else {
|
||||||
|
@ -390,7 +390,7 @@ static void log_dump(void) {
|
||||||
if (g_dbglevel >= DBG_INFO || FORCE_ENABLE_LOGGING) {
|
if (g_dbglevel >= DBG_INFO || FORCE_ENABLE_LOGGING) {
|
||||||
bool hasContent = false;
|
bool hasContent = false;
|
||||||
if (g_Log != NULL) {
|
if (g_Log != NULL) {
|
||||||
uint8_t * check_for_data = (uint8_t *)g_Log;
|
uint8_t *check_for_data = (uint8_t *)g_Log;
|
||||||
for (size_t i = 0; i < sizeof(em4x70_transmitted_data_log_t); ++i) {
|
for (size_t i = 0; i < sizeof(em4x70_transmitted_data_log_t); ++i) {
|
||||||
if (check_for_data[i] != 0) {
|
if (check_for_data[i] != 0) {
|
||||||
hasContent = true;
|
hasContent = true;
|
||||||
|
@ -516,12 +516,12 @@ typedef struct _em4x70_command_bitstream {
|
||||||
uint8_t received_data_converted_to_bytes[(EM4X70_MAX_BITSTREAM_BITS / 8) + (EM4X70_MAX_BITSTREAM_BITS % 8 ? 1 : 0)];
|
uint8_t received_data_converted_to_bytes[(EM4X70_MAX_BITSTREAM_BITS / 8) + (EM4X70_MAX_BITSTREAM_BITS % 8 ? 1 : 0)];
|
||||||
} em4x70_command_bitstream_t;
|
} em4x70_command_bitstream_t;
|
||||||
|
|
||||||
typedef bool (*bitstream_command_generator_id_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity);
|
typedef bool (*bitstream_command_generator_id_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity);
|
||||||
typedef bool (*bitstream_command_generator_um1_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity);
|
typedef bool (*bitstream_command_generator_um1_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity);
|
||||||
typedef bool (*bitstream_command_generator_um2_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity);
|
typedef bool (*bitstream_command_generator_um2_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity);
|
||||||
typedef bool (*bitstream_command_generator_auth_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, const uint8_t * rnd, const uint8_t * frnd);
|
typedef bool (*bitstream_command_generator_auth_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, const uint8_t *rnd, const uint8_t *frnd);
|
||||||
typedef bool (*bitstream_command_generator_pin_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, const uint8_t * tag_id, const uint32_t pin_little_endian);
|
typedef bool (*bitstream_command_generator_pin_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, const uint8_t *tag_id, const uint32_t pin_little_endian);
|
||||||
typedef bool (*bitstream_command_generator_write_t)(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, uint16_t data_little_endian, uint8_t address);
|
typedef bool (*bitstream_command_generator_write_t)(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, uint16_t data_little_endian, uint8_t address);
|
||||||
|
|
||||||
typedef struct _em4x70_command_generators_t {
|
typedef struct _em4x70_command_generators_t {
|
||||||
bitstream_command_generator_id_t id;
|
bitstream_command_generator_id_t id;
|
||||||
|
@ -534,9 +534,9 @@ typedef struct _em4x70_command_generators_t {
|
||||||
|
|
||||||
#endif // #pragma endregion // Bitstream structures / enumerations
|
#endif // #pragma endregion // Bitstream structures / enumerations
|
||||||
#if 1 // #pragma region // Functions to dump bitstreams to debug output
|
#if 1 // #pragma region // Functions to dump bitstreams to debug output
|
||||||
static void bitstream_dump_helper(const em4x70_bitstream_t * bitstream, bool is_transmit) {
|
static void bitstream_dump_helper(const em4x70_bitstream_t *bitstream, bool is_transmit) {
|
||||||
// mimic the log's output format to make comparisons easier
|
// mimic the log's output format to make comparisons easier
|
||||||
char const * const direction = is_transmit ? "sent >>>" : "recv <<<";
|
char const *const direction = is_transmit ? "sent >>>" : "recv <<<";
|
||||||
if (bitstream->bitcount == 0) {
|
if (bitstream->bitcount == 0) {
|
||||||
if (g_dbglevel >= DBG_INFO || true) {
|
if (g_dbglevel >= DBG_INFO || true) {
|
||||||
DPRINTF_EXTENDED(("%s: no data", direction));
|
DPRINTF_EXTENDED(("%s: no data", direction));
|
||||||
|
@ -559,8 +559,8 @@ static void bitstream_dump_helper(const em4x70_bitstream_t * bitstream, bool is_
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void bitstream_dump(const em4x70_command_bitstream_t * cmd_bitstream) {
|
static void bitstream_dump(const em4x70_command_bitstream_t *cmd_bitstream) {
|
||||||
bitstream_dump_helper(&cmd_bitstream->to_send, true );
|
bitstream_dump_helper(&cmd_bitstream->to_send, true);
|
||||||
bitstream_dump_helper(&cmd_bitstream->to_receive, false);
|
bitstream_dump_helper(&cmd_bitstream->to_receive, false);
|
||||||
}
|
}
|
||||||
#endif // #pragma region // Functions to dump bitstreams to debug output
|
#endif // #pragma region // Functions to dump bitstreams to debug output
|
||||||
|
@ -570,13 +570,13 @@ static void bitstream_dump(const em4x70_command_bitstream_t * cmd_bitstream) {
|
||||||
/// @details This function presumes a validated structure, and sends the bitstream without delays, to support timing-sensitive operations.
|
/// @details This function presumes a validated structure, and sends the bitstream without delays, to support timing-sensitive operations.
|
||||||
/// @param send The details on the bitstream to send to the tag.
|
/// @param send The details on the bitstream to send to the tag.
|
||||||
/// @return
|
/// @return
|
||||||
static bool send_bitstream_internal(const em4x70_bitstream_t * send) {
|
static bool send_bitstream_internal(const em4x70_bitstream_t *send) {
|
||||||
// similar to original send_command_and_read, but using provided bitstream
|
// similar to original send_command_and_read, but using provided bitstream
|
||||||
int retries = EM4X70_COMMAND_RETRIES;
|
int retries = EM4X70_COMMAND_RETRIES;
|
||||||
|
|
||||||
// TIMING SENSITIVE FUNCTION ... Minimize delays after finding the listen window
|
// TIMING SENSITIVE FUNCTION ... Minimize delays after finding the listen window
|
||||||
while (retries) {
|
while (retries) {
|
||||||
const uint8_t * s = send->one_bit_per_byte;
|
const uint8_t *s = send->one_bit_per_byte;
|
||||||
uint8_t sent = 0;
|
uint8_t sent = 0;
|
||||||
retries--;
|
retries--;
|
||||||
if (find_listen_window(true)) { // `true` will automatically send the two `RM` zero bits
|
if (find_listen_window(true)) { // `true` will automatically send the two `RM` zero bits
|
||||||
|
@ -597,9 +597,9 @@ static bool send_bitstream_internal(const em4x70_bitstream_t * send) {
|
||||||
/// @param recv Buffer to store received data from the tag.
|
/// @param recv Buffer to store received data from the tag.
|
||||||
/// `recv->expected_bitcount` must be initialized to indicate expected bits to receive from the tag.
|
/// `recv->expected_bitcount` must be initialized to indicate expected bits to receive from the tag.
|
||||||
/// @return true only if the bitstream was sent and the expected count of bits were received from the tag.
|
/// @return true only if the bitstream was sent and the expected count of bits were received from the tag.
|
||||||
static bool send_bitstream_and_read(em4x70_command_bitstream_t * command_bitstream) {
|
static bool send_bitstream_and_read(em4x70_command_bitstream_t *command_bitstream) {
|
||||||
const em4x70_bitstream_t * send = &command_bitstream->to_send;
|
const em4x70_bitstream_t *send = &command_bitstream->to_send;
|
||||||
em4x70_bitstream_t * recv = &command_bitstream->to_receive;
|
em4x70_bitstream_t *recv = &command_bitstream->to_receive;
|
||||||
|
|
||||||
// Validate the parameters before proceeding
|
// Validate the parameters before proceeding
|
||||||
bool parameters_valid = true;
|
bool parameters_valid = true;
|
||||||
|
@ -694,9 +694,9 @@ static bool send_bitstream_and_read(em4x70_command_bitstream_t * command_bitstre
|
||||||
// finally return the result of the operation
|
// finally return the result of the operation
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool send_bitstream_wait_ack_wait_read(em4x70_command_bitstream_t * command_bitstream) {
|
static bool send_bitstream_wait_ack_wait_read(em4x70_command_bitstream_t *command_bitstream) {
|
||||||
const em4x70_bitstream_t * send = &command_bitstream->to_send;
|
const em4x70_bitstream_t *send = &command_bitstream->to_send;
|
||||||
em4x70_bitstream_t * recv = &command_bitstream->to_receive;
|
em4x70_bitstream_t *recv = &command_bitstream->to_receive;
|
||||||
|
|
||||||
// Validate the parameters before proceeding
|
// Validate the parameters before proceeding
|
||||||
bool parameters_valid = true;
|
bool parameters_valid = true;
|
||||||
|
@ -769,10 +769,10 @@ static bool send_bitstream_wait_ack_wait_read(em4x70_command_bitstream_t * comma
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool send_bitstream_wait_ack_wait_ack(em4x70_command_bitstream_t * command_bitstream) {
|
static bool send_bitstream_wait_ack_wait_ack(em4x70_command_bitstream_t *command_bitstream) {
|
||||||
|
|
||||||
const em4x70_bitstream_t * send = &command_bitstream->to_send;
|
const em4x70_bitstream_t *send = &command_bitstream->to_send;
|
||||||
em4x70_bitstream_t * recv = &command_bitstream->to_receive;
|
em4x70_bitstream_t *recv = &command_bitstream->to_receive;
|
||||||
|
|
||||||
// Validate the parameters before proceeding
|
// Validate the parameters before proceeding
|
||||||
bool parameters_valid = true;
|
bool parameters_valid = true;
|
||||||
|
@ -835,7 +835,7 @@ static bool send_bitstream_wait_ack_wait_ack(em4x70_command_bitstream_t * comman
|
||||||
#endif // #pragma region // Functions to send bitstreams, with options to receive data
|
#endif // #pragma region // Functions to send bitstreams, with options to receive data
|
||||||
#if 1 // #pragma region // Create bitstreams for each type of EM4x70 command
|
#if 1 // #pragma region // Create bitstreams for each type of EM4x70 command
|
||||||
|
|
||||||
static bool add_bit_to_bitstream(em4x70_bitstream_t * s, bool b) {
|
static bool add_bit_to_bitstream(em4x70_bitstream_t *s, bool b) {
|
||||||
uint8_t i = s->bitcount;
|
uint8_t i = s->bitcount;
|
||||||
uint8_t bits_to_add = 1u;
|
uint8_t bits_to_add = 1u;
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ static bool add_bit_to_bitstream(em4x70_bitstream_t * s, bool b) {
|
||||||
s->bitcount++;
|
s->bitcount++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static bool add_nibble_to_bitstream(em4x70_bitstream_t * s, uint8_t nibble, bool add_fifth_parity_bit) {
|
static bool add_nibble_to_bitstream(em4x70_bitstream_t *s, uint8_t nibble, bool add_fifth_parity_bit) {
|
||||||
uint8_t i = s->bitcount;
|
uint8_t i = s->bitcount;
|
||||||
uint8_t bits_to_add = add_fifth_parity_bit ? 5u : 4u;
|
uint8_t bits_to_add = add_fifth_parity_bit ? 5u : 4u;
|
||||||
|
|
||||||
|
@ -875,7 +875,7 @@ static bool add_nibble_to_bitstream(em4x70_bitstream_t * s, uint8_t nibble, bool
|
||||||
s->bitcount += bits_to_add;
|
s->bitcount += bits_to_add;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static bool add_byte_to_bitstream(em4x70_bitstream_t * s, uint8_t b) {
|
static bool add_byte_to_bitstream(em4x70_bitstream_t *s, uint8_t b) {
|
||||||
uint8_t i = s->bitcount;
|
uint8_t i = s->bitcount;
|
||||||
uint8_t bits_to_add = 8u;
|
uint8_t bits_to_add = 8u;
|
||||||
|
|
||||||
|
@ -897,7 +897,7 @@ static bool add_byte_to_bitstream(em4x70_bitstream_t * s, uint8_t b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_id(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_id(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity) {
|
||||||
const uint8_t expected_bits_to_send = 4u;
|
const uint8_t expected_bits_to_send = 4u;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
|
@ -911,7 +911,7 @@ static bool create_legacy_em4x70_bitstream_for_cmd_id(em4x70_command_bitstream_t
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_um1(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_um1(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity) {
|
||||||
const uint8_t expected_bits_to_send = 4u;
|
const uint8_t expected_bits_to_send = 4u;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
|
@ -925,7 +925,7 @@ static bool create_legacy_em4x70_bitstream_for_cmd_um1(em4x70_command_bitstream_
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_um2(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_um2(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity) {
|
||||||
const uint8_t expected_bits_to_send = 4u;
|
const uint8_t expected_bits_to_send = 4u;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
|
@ -939,14 +939,14 @@ static bool create_legacy_em4x70_bitstream_for_cmd_um2(em4x70_command_bitstream_
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_auth(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, const uint8_t *rnd, const uint8_t *frnd) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_auth(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, const uint8_t *rnd, const uint8_t *frnd) {
|
||||||
const uint8_t expected_bits_to_send = 96u;
|
const uint8_t expected_bits_to_send = 96u;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
out_cmd_bitstream->command = EM4X70_COMMAND_AUTH;
|
out_cmd_bitstream->command = EM4X70_COMMAND_AUTH;
|
||||||
|
|
||||||
em4x70_bitstream_t * s = &out_cmd_bitstream->to_send;
|
em4x70_bitstream_t *s = &out_cmd_bitstream->to_send;
|
||||||
|
|
||||||
// *********************************************************************************
|
// *********************************************************************************
|
||||||
// HACK -- Insert an extra zero bit to match legacy behavior
|
// HACK -- Insert an extra zero bit to match legacy behavior
|
||||||
|
@ -994,12 +994,12 @@ static bool create_legacy_em4x70_bitstream_for_cmd_auth(em4x70_command_bitstream
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_pin(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, const uint8_t *tag_id, const uint32_t pin) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_pin(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, const uint8_t *tag_id, const uint32_t pin) {
|
||||||
const uint8_t expected_bits_to_send = 69; // normally 68 bits, but legacy hack inserts an extra RM bit, and always adds a command parity bit
|
const uint8_t expected_bits_to_send = 69; // normally 68 bits, but legacy hack inserts an extra RM bit, and always adds a command parity bit
|
||||||
bool result = true;
|
bool result = true;
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
|
|
||||||
em4x70_bitstream_t * s = &out_cmd_bitstream->to_send;
|
em4x70_bitstream_t *s = &out_cmd_bitstream->to_send;
|
||||||
|
|
||||||
out_cmd_bitstream->command = EM4X70_COMMAND_PIN;
|
out_cmd_bitstream->command = EM4X70_COMMAND_PIN;
|
||||||
|
|
||||||
|
@ -1015,7 +1015,7 @@ static bool create_legacy_em4x70_bitstream_for_cmd_pin(em4x70_command_bitstream_
|
||||||
// Send tag's ID ... indexes 4 .. 35
|
// Send tag's ID ... indexes 4 .. 35
|
||||||
// e.g., tag_id points to &tag.data[4] ... &tag.data[7]
|
// e.g., tag_id points to &tag.data[4] ... &tag.data[7]
|
||||||
for (uint_fast8_t i = 0; i < 4; i++) {
|
for (uint_fast8_t i = 0; i < 4; i++) {
|
||||||
uint8_t b = tag_id[3-i];
|
uint8_t b = tag_id[3 - i];
|
||||||
result = result && add_byte_to_bitstream(s, b);
|
result = result && add_byte_to_bitstream(s, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,13 +1033,13 @@ static bool create_legacy_em4x70_bitstream_for_cmd_pin(em4x70_command_bitstream_
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
static bool create_legacy_em4x70_bitstream_for_cmd_write(em4x70_command_bitstream_t * out_cmd_bitstream, bool with_command_parity, uint16_t new_data, uint8_t address) {
|
static bool create_legacy_em4x70_bitstream_for_cmd_write(em4x70_command_bitstream_t *out_cmd_bitstream, bool with_command_parity, uint16_t new_data, uint8_t address) {
|
||||||
const uint8_t expected_bits_to_send = 35u; // normally 34 bits, but legacy hack inserts an extra RM bit, and always adds a command parity bit
|
const uint8_t expected_bits_to_send = 35u; // normally 34 bits, but legacy hack inserts an extra RM bit, and always adds a command parity bit
|
||||||
bool result = true;
|
bool result = true;
|
||||||
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
memset(out_cmd_bitstream, 0, sizeof(em4x70_command_bitstream_t));
|
||||||
out_cmd_bitstream->command = EM4X70_COMMAND_WRITE;
|
out_cmd_bitstream->command = EM4X70_COMMAND_WRITE;
|
||||||
|
|
||||||
em4x70_bitstream_t * s = &out_cmd_bitstream->to_send;
|
em4x70_bitstream_t *s = &out_cmd_bitstream->to_send;
|
||||||
|
|
||||||
// *********************************************************************************
|
// *********************************************************************************
|
||||||
// HACK -- Insert an extra zero bit to match legacy behavior
|
// HACK -- Insert an extra zero bit to match legacy behavior
|
||||||
|
@ -1105,7 +1105,7 @@ const em4x70_command_generators_t legacy_em4x70_command_generators = {
|
||||||
static int authenticate(const uint8_t *rnd, const uint8_t *frnd, uint8_t *response) {
|
static int authenticate(const uint8_t *rnd, const uint8_t *frnd, uint8_t *response) {
|
||||||
em4x70_command_bitstream_t auth_cmd;
|
em4x70_command_bitstream_t auth_cmd;
|
||||||
|
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->auth(&auth_cmd, command_parity, rnd, frnd);
|
generator->auth(&auth_cmd, command_parity, rnd, frnd);
|
||||||
|
|
||||||
bool result = send_bitstream_and_read(&auth_cmd);
|
bool result = send_bitstream_and_read(&auth_cmd);
|
||||||
|
@ -1193,7 +1193,7 @@ static int bruteforce(const uint8_t address, const uint8_t *rnd, const uint8_t *
|
||||||
// log entry/exit point
|
// log entry/exit point
|
||||||
static int send_pin(const uint32_t pin) {
|
static int send_pin(const uint32_t pin) {
|
||||||
em4x70_command_bitstream_t send_pin_cmd;
|
em4x70_command_bitstream_t send_pin_cmd;
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->pin(&send_pin_cmd, command_parity, &tag.data[4], pin);
|
generator->pin(&send_pin_cmd, command_parity, &tag.data[4], pin);
|
||||||
|
|
||||||
bool result = send_bitstream_wait_ack_wait_read(&send_pin_cmd);
|
bool result = send_bitstream_wait_ack_wait_read(&send_pin_cmd);
|
||||||
|
@ -1204,7 +1204,7 @@ static int send_pin(const uint32_t pin) {
|
||||||
static int write(const uint16_t word, const uint8_t address) {
|
static int write(const uint16_t word, const uint8_t address) {
|
||||||
em4x70_command_bitstream_t write_cmd;
|
em4x70_command_bitstream_t write_cmd;
|
||||||
|
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->write(&write_cmd, command_parity, word, address);
|
generator->write(&write_cmd, command_parity, word, address);
|
||||||
|
|
||||||
bool result = send_bitstream_wait_ack_wait_ack(&write_cmd);
|
bool result = send_bitstream_wait_ack_wait_ack(&write_cmd);
|
||||||
|
@ -1291,7 +1291,7 @@ static uint8_t encoded_bit_array_to_byte(const uint8_t *bits, int count_of_bits)
|
||||||
*/
|
*/
|
||||||
static bool em4x70_read_id(void) {
|
static bool em4x70_read_id(void) {
|
||||||
em4x70_command_bitstream_t read_id_cmd;
|
em4x70_command_bitstream_t read_id_cmd;
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->id(&read_id_cmd, command_parity);
|
generator->id(&read_id_cmd, command_parity);
|
||||||
|
|
||||||
bool result = send_bitstream_and_read(&read_id_cmd);
|
bool result = send_bitstream_and_read(&read_id_cmd);
|
||||||
|
@ -1308,7 +1308,7 @@ static bool em4x70_read_id(void) {
|
||||||
*/
|
*/
|
||||||
static bool em4x70_read_um1(void) {
|
static bool em4x70_read_um1(void) {
|
||||||
em4x70_command_bitstream_t read_um1_cmd;
|
em4x70_command_bitstream_t read_um1_cmd;
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->um1(&read_um1_cmd, command_parity);
|
generator->um1(&read_um1_cmd, command_parity);
|
||||||
|
|
||||||
bool result = send_bitstream_and_read(&read_um1_cmd);
|
bool result = send_bitstream_and_read(&read_um1_cmd);
|
||||||
|
@ -1327,7 +1327,7 @@ static bool em4x70_read_um1(void) {
|
||||||
*/
|
*/
|
||||||
static bool em4x70_read_um2(void) {
|
static bool em4x70_read_um2(void) {
|
||||||
em4x70_command_bitstream_t read_um2_cmd;
|
em4x70_command_bitstream_t read_um2_cmd;
|
||||||
const em4x70_command_generators_t * generator = &legacy_em4x70_command_generators;
|
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
|
||||||
generator->um2(&read_um2_cmd, command_parity);
|
generator->um2(&read_um2_cmd, command_parity);
|
||||||
|
|
||||||
bool result = send_bitstream_and_read(&read_um2_cmd);
|
bool result = send_bitstream_and_read(&read_um2_cmd);
|
||||||
|
|
|
@ -87,15 +87,15 @@ size_t DemodPCF7931(uint8_t **outBlocks, bool ledcontrol) {
|
||||||
samplePosLastEdge = 0;
|
samplePosLastEdge = 0;
|
||||||
block_done = 0;
|
block_done = 0;
|
||||||
bitPos = 0;
|
bitPos = 0;
|
||||||
lastClockDuration=0;
|
lastClockDuration = 0;
|
||||||
|
|
||||||
for (sample = 1 ; sample < g_GraphTraceLen-4; sample++) {
|
for (sample = 1 ; sample < g_GraphTraceLen - 4; sample++) {
|
||||||
// condition is searching for the next edge, in the expected diretion.
|
// condition is searching for the next edge, in the expected diretion.
|
||||||
//todo: without flouz
|
//todo: without flouz
|
||||||
dest[sample] = (uint8_t)(dest[sample-1] * IIR_CONST1 + dest[sample] * IIR_CONST2); // apply IIR filter
|
dest[sample] = (uint8_t)(dest[sample - 1] * IIR_CONST1 + dest[sample] * IIR_CONST2); // apply IIR filter
|
||||||
|
|
||||||
if ( ((dest[sample] + THRESHOLD) < dest[sample-1] && expectedNextEdge == FALLING ) ||
|
if (((dest[sample] + THRESHOLD) < dest[sample - 1] && expectedNextEdge == FALLING) ||
|
||||||
((dest[sample] - THRESHOLD) > dest[sample-1] && expectedNextEdge == RISING )) {
|
((dest[sample] - THRESHOLD) > dest[sample - 1] && expectedNextEdge == RISING)) {
|
||||||
//okay, next falling/rising edge found
|
//okay, next falling/rising edge found
|
||||||
|
|
||||||
expectedNextEdge = (expectedNextEdge == FALLING) ? RISING : FALLING; //toggle the next expected edge
|
expectedNextEdge = (expectedNextEdge == FALLING) ? RISING : FALLING; //toggle the next expected edge
|
||||||
|
@ -193,7 +193,7 @@ size_t DemodPCF7931(uint8_t **outBlocks, bool ledcontrol) {
|
||||||
half_switch = 0;
|
half_switch = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
// Dbprintf("%d, %d", sample, dest[sample]);
|
// Dbprintf("%d, %d", sample, dest[sample]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ void ReadPCF7931(bool ledcontrol) {
|
||||||
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
/*
|
/*
|
||||||
Dbprintf("-----------------------------------------");
|
Dbprintf("-----------------------------------------");
|
||||||
Dbprintf("Memory content:");
|
Dbprintf("Memory content:");
|
||||||
Dbprintf("-----------------------------------------");
|
Dbprintf("-----------------------------------------");
|
||||||
|
@ -424,7 +424,7 @@ end:
|
||||||
|
|
||||||
Dbprintf("-----------------------------------------");
|
Dbprintf("-----------------------------------------");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ static void RealWritePCF7931(
|
||||||
uint16_t init_delay,
|
uint16_t init_delay,
|
||||||
int8_t offsetPulseWidth, int8_t offsetPulsePosition,
|
int8_t offsetPulseWidth, int8_t offsetPulsePosition,
|
||||||
uint8_t address, uint8_t byte, uint8_t data,
|
uint8_t address, uint8_t byte, uint8_t data,
|
||||||
bool ledcontrol){
|
bool ledcontrol) {
|
||||||
|
|
||||||
uint32_t tab[1024] = {0}; // data times frame
|
uint32_t tab[1024] = {0}; // data times frame
|
||||||
uint32_t u = 0;
|
uint32_t u = 0;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
typedef enum{
|
typedef enum {
|
||||||
FALLING,
|
FALLING,
|
||||||
RISING
|
RISING
|
||||||
} EdgeType;
|
} EdgeType;
|
||||||
|
|
|
@ -186,6 +186,7 @@ static void fill_grabber(const char *string) {
|
||||||
g_grabbed_output.ptr = tmp;
|
g_grabbed_output.ptr = tmp;
|
||||||
g_grabbed_output.size += MAX_PRINT_BUFFER;
|
g_grabbed_output.size += MAX_PRINT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = snprintf(g_grabbed_output.ptr + g_grabbed_output.idx, MAX_PRINT_BUFFER, "%s", string);
|
int len = snprintf(g_grabbed_output.ptr + g_grabbed_output.idx, MAX_PRINT_BUFFER, "%s", string);
|
||||||
if (len < 0 || len > MAX_PRINT_BUFFER) {
|
if (len < 0 || len > MAX_PRINT_BUFFER) {
|
||||||
// We leave current g_grabbed_output_len untouched
|
// We leave current g_grabbed_output_len untouched
|
||||||
|
@ -196,25 +197,35 @@ static void fill_grabber(const char *string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space) {
|
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space) {
|
||||||
|
|
||||||
char buff[2000] = "Options:\n";
|
char buff[2000] = "Options:\n";
|
||||||
char format[2000] = "";
|
char format[2000] = "";
|
||||||
size_t counts[2] = {0, 0};
|
size_t counts[2] = {0, 0};
|
||||||
for (size_t i = 0; i < size; i++)
|
|
||||||
for (size_t j = 0 ; j < 2 ; j++)
|
for (size_t i = 0; i < size; i++) {
|
||||||
|
for (size_t j = 0 ; j < 2 ; j++) {
|
||||||
if (counts[j] < strlen(str[i][j])) {
|
if (counts[j] < strlen(str[i][j])) {
|
||||||
counts[j] = strlen(str[i][j]);
|
counts[j] = strlen(str[i][j]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
|
|
||||||
for (size_t j = 0; j < 2; j++) {
|
for (size_t j = 0; j < 2; j++) {
|
||||||
if (j == 0)
|
if (j == 0) {
|
||||||
snprintf(format, sizeof(format), "%%%zus%%%zus", space, counts[j]);
|
snprintf(format, sizeof(format), "%%%zus%%%zus", space, counts[j]);
|
||||||
else
|
} else {
|
||||||
snprintf(format, sizeof(format), "%%%zus%%-%zus", space, counts[j]);
|
snprintf(format, sizeof(format), "%%%zus%%-%zus", space, counts[j]);
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), format, " ", str[i][j]);
|
snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), format, " ", str[i][j]);
|
||||||
}
|
}
|
||||||
if (i < size - 1)
|
|
||||||
|
if (i < size - 1) {
|
||||||
strncat(buff, "\n", sizeof(buff) - strlen(buff) - 1);
|
strncat(buff, "\n", sizeof(buff) - strlen(buff) - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
PrintAndLogEx(NORMAL, "%s", buff);
|
PrintAndLogEx(NORMAL, "%s", buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,12 +234,14 @@ static uint8_t PrintAndLogEx_spinidx = 0;
|
||||||
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
|
|
||||||
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG -0'
|
// skip debug messages if client debugging is turned off i.e. 'DATA SETDEBUG -0'
|
||||||
if (g_debugMode == 0 && level == DEBUG)
|
if (g_debugMode == 0 && level == DEBUG) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
// skip HINT messages if client has hints turned off i.e. 'HINT 0'
|
||||||
if (g_session.show_hints == false && level == HINT)
|
if (g_session.show_hints == false && level == HINT) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char prefix[40] = {0};
|
char prefix[40] = {0};
|
||||||
char buffer[MAX_PRINT_BUFFER] = {0};
|
char buffer[MAX_PRINT_BUFFER] = {0};
|
||||||
|
@ -242,17 +255,19 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
};
|
};
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case ERR:
|
case ERR:
|
||||||
if (g_session.emoji_mode == EMO_EMOJI)
|
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||||
strncpy(prefix, "[" _RED_("!!") "] :rotating_light: ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _RED_("!!") "] :rotating_light: ", sizeof(prefix) - 1);
|
||||||
else
|
} else {
|
||||||
strncpy(prefix, "[" _RED_("!!") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _RED_("!!") "] ", sizeof(prefix) - 1);
|
||||||
|
}
|
||||||
stream = stderr;
|
stream = stderr;
|
||||||
break;
|
break;
|
||||||
case FAILED:
|
case FAILED:
|
||||||
if (g_session.emoji_mode == EMO_EMOJI)
|
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||||
strncpy(prefix, "[" _RED_("-") "] :no_entry: ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _RED_("-") "] :no_entry: ", sizeof(prefix) - 1);
|
||||||
else
|
} else {
|
||||||
strncpy(prefix, "[" _RED_("-") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _RED_("-") "] ", sizeof(prefix) - 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
strncpy(prefix, "[" _BLUE_("#") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _BLUE_("#") "] ", sizeof(prefix) - 1);
|
||||||
|
@ -264,10 +279,11 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
strncpy(prefix, "[" _GREEN_("+") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _GREEN_("+") "] ", sizeof(prefix) - 1);
|
||||||
break;
|
break;
|
||||||
case WARNING:
|
case WARNING:
|
||||||
if (g_session.emoji_mode == EMO_EMOJI)
|
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||||
strncpy(prefix, "[" _CYAN_("!") "] :warning: ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _CYAN_("!") "] :warning: ", sizeof(prefix) - 1);
|
||||||
else
|
} else {
|
||||||
strncpy(prefix, "[" _CYAN_("!") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _CYAN_("!") "] ", sizeof(prefix) - 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case INFO:
|
case INFO:
|
||||||
strncpy(prefix, "[" _YELLOW_("=") "] ", sizeof(prefix) - 1);
|
strncpy(prefix, "[" _YELLOW_("=") "] ", sizeof(prefix) - 1);
|
||||||
|
@ -276,14 +292,16 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
if (g_session.emoji_mode == EMO_EMOJI) {
|
if (g_session.emoji_mode == EMO_EMOJI) {
|
||||||
strncpy(prefix, spinner_emoji[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
strncpy(prefix, spinner_emoji[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
||||||
PrintAndLogEx_spinidx++;
|
PrintAndLogEx_spinidx++;
|
||||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner_emoji))
|
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner_emoji)) {
|
||||||
PrintAndLogEx_spinidx = 0;
|
PrintAndLogEx_spinidx = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
strncpy(prefix, spinner[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
strncpy(prefix, spinner[PrintAndLogEx_spinidx], sizeof(prefix) - 1);
|
||||||
PrintAndLogEx_spinidx++;
|
PrintAndLogEx_spinidx++;
|
||||||
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner))
|
if (PrintAndLogEx_spinidx >= ARRAYLEN(spinner)) {
|
||||||
PrintAndLogEx_spinidx = 0;
|
PrintAndLogEx_spinidx = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
// no prefixes for normal
|
// no prefixes for normal
|
||||||
|
@ -306,8 +324,9 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
const char delim[2] = "\n";
|
const char delim[2] = "\n";
|
||||||
|
|
||||||
// line starts with newline
|
// line starts with newline
|
||||||
if (buffer[0] == '\n')
|
if (buffer[0] == '\n') {
|
||||||
fPrintAndLog(stream, "");
|
fPrintAndLog(stream, "");
|
||||||
|
}
|
||||||
|
|
||||||
token = strtok_r(buffer, delim, &tmp_ptr);
|
token = strtok_r(buffer, delim, &tmp_ptr);
|
||||||
|
|
||||||
|
@ -315,16 +334,21 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
|
|
||||||
size_t size = strlen(buffer2);
|
size_t size = strlen(buffer2);
|
||||||
|
|
||||||
if (strlen(token))
|
if (strlen(token)) {
|
||||||
snprintf(buffer2 + size, sizeof(buffer2) - size, "%s%s\n", prefix, token);
|
snprintf(buffer2 + size, sizeof(buffer2) - size, "%s%s\n", prefix, token);
|
||||||
else
|
} else {
|
||||||
snprintf(buffer2 + size, sizeof(buffer2) - size, "\n");
|
snprintf(buffer2 + size, sizeof(buffer2) - size, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
token = strtok_r(NULL, delim, &tmp_ptr);
|
token = strtok_r(NULL, delim, &tmp_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrintAndLog(stream, "%s", buffer2);
|
fPrintAndLog(stream, "%s", buffer2);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
snprintf(buffer2, sizeof(buffer2), "%s%s", prefix, buffer);
|
snprintf(buffer2, sizeof(buffer2), "%s%s", prefix, buffer);
|
||||||
|
|
||||||
if (level == INPLACE) {
|
if (level == INPLACE) {
|
||||||
// ignore INPLACE if rest of output is grabbed
|
// ignore INPLACE if rest of output is grabbed
|
||||||
if (!(g_printAndLog & PRINTANDLOG_GRAB)) {
|
if (!(g_printAndLog & PRINTANDLOG_GRAB)) {
|
||||||
|
@ -354,6 +378,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
if (logging && g_session.incognito) {
|
if (logging && g_session.incognito) {
|
||||||
logging = 0;
|
logging = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && !logfile) {
|
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && !logfile) {
|
||||||
char *my_logfile_path = NULL;
|
char *my_logfile_path = NULL;
|
||||||
char filename[40];
|
char filename[40];
|
||||||
|
@ -361,11 +386,15 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
timenow = gmtime(&now);
|
timenow = gmtime(&now);
|
||||||
strftime(filename, sizeof(filename), PROXLOG, timenow);
|
strftime(filename, sizeof(filename), PROXLOG, timenow);
|
||||||
|
|
||||||
if (searchHomeFilePath(&my_logfile_path, LOGS_SUBDIR, filename, true) != PM3_SUCCESS) {
|
if (searchHomeFilePath(&my_logfile_path, LOGS_SUBDIR, filename, true) != PM3_SUCCESS) {
|
||||||
|
|
||||||
printf(_YELLOW_("[-]") " Logging disabled!\n");
|
printf(_YELLOW_("[-]") " Logging disabled!\n");
|
||||||
my_logfile_path = NULL;
|
my_logfile_path = NULL;
|
||||||
logging = 0;
|
logging = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
logfile = fopen(my_logfile_path, "a");
|
logfile = fopen(my_logfile_path, "a");
|
||||||
if (logfile == NULL) {
|
if (logfile == NULL) {
|
||||||
printf(_YELLOW_("[-]") " Can't open logfile %s, logging disabled!\n", my_logfile_path);
|
printf(_YELLOW_("[-]") " Can't open logfile %s, logging disabled!\n", my_logfile_path);
|
||||||
|
@ -411,14 +440,17 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
linefeed = false;
|
linefeed = false;
|
||||||
buffer[strlen(buffer) - 1] = 0;
|
buffer[strlen(buffer) - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filter_ansi = !g_session.supports_colors;
|
bool filter_ansi = !g_session.supports_colors;
|
||||||
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
||||||
if (g_printAndLog & PRINTANDLOG_PRINT) {
|
|
||||||
|
if ((g_printAndLog & PRINTANDLOG_PRINT) == PRINTANDLOG_PRINT) {
|
||||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), g_session.emoji_mode);
|
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), g_session.emoji_mode);
|
||||||
fprintf(stream, "%s", buffer3);
|
fprintf(stream, "%s", buffer3);
|
||||||
if (linefeed)
|
if (linefeed) {
|
||||||
fprintf(stream, "\n");
|
fprintf(stream, "\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RL_STATE_READCMD
|
#ifdef RL_STATE_READCMD
|
||||||
// We are using GNU readline. libedit (OSX) doesn't support this flag.
|
// We are using GNU readline. libedit (OSX) doesn't support this flag.
|
||||||
|
@ -433,33 +465,44 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
|
|
||||||
if (((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) ||
|
if (((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) ||
|
||||||
(g_printAndLog & PRINTANDLOG_GRAB)) {
|
(g_printAndLog & PRINTANDLOG_GRAB)) {
|
||||||
|
|
||||||
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), EMO_ALTTEXT);
|
memcpy_filter_emoji(buffer3, buffer2, sizeof(buffer2), EMO_ALTTEXT);
|
||||||
|
|
||||||
if (filter_ansi == false) {
|
if (filter_ansi == false) {
|
||||||
memcpy_filter_ansi(buffer, buffer3, sizeof(buffer3), true);
|
memcpy_filter_ansi(buffer, buffer3, sizeof(buffer3), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) {
|
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) {
|
||||||
|
|
||||||
if (filter_ansi) {
|
if (filter_ansi) {
|
||||||
fprintf(logfile, "%s", buffer3);
|
fprintf(logfile, "%s", buffer3);
|
||||||
} else {
|
} else {
|
||||||
fprintf(logfile, "%s", buffer);
|
fprintf(logfile, "%s", buffer);
|
||||||
}
|
}
|
||||||
if (linefeed)
|
|
||||||
|
if (linefeed) {
|
||||||
fprintf(logfile, "\n");
|
fprintf(logfile, "\n");
|
||||||
|
}
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_printAndLog & PRINTANDLOG_GRAB) {
|
if (g_printAndLog & PRINTANDLOG_GRAB) {
|
||||||
|
|
||||||
if (filter_ansi) {
|
if (filter_ansi) {
|
||||||
fill_grabber(buffer3);
|
fill_grabber(buffer3);
|
||||||
} else {
|
} else {
|
||||||
fill_grabber(buffer);
|
fill_grabber(buffer);
|
||||||
}
|
}
|
||||||
if (linefeed)
|
|
||||||
|
if (linefeed) {
|
||||||
fill_grabber("\n");
|
fill_grabber("\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flushAfterWrite)
|
if (flushAfterWrite) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
//release lock
|
//release lock
|
||||||
pthread_mutex_unlock(&g_print_lock);
|
pthread_mutex_unlock(&g_print_lock);
|
||||||
|
@ -478,9 +521,10 @@ void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n) {
|
||||||
uint8_t *rsrc = (uint8_t *)src;
|
uint8_t *rsrc = (uint8_t *)src;
|
||||||
uint16_t si = 0;
|
uint16_t si = 0;
|
||||||
for (size_t i = 0; i < n; i++) {
|
for (size_t i = 0; i < n; i++) {
|
||||||
if ((rsrc[i] == '\001') || (rsrc[i] == '\002'))
|
if ((rsrc[i] == '\001') || (rsrc[i] == '\002')) {
|
||||||
// skip readline special markers
|
// skip readline special markers
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
rdest[si++] = rsrc[i];
|
rdest[si++] = rsrc[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5047,7 +5047,7 @@
|
||||||
"-v, --verbose verbose output",
|
"-v, --verbose verbose output",
|
||||||
"-f, --file <fn> Specify a filename for dump file",
|
"-f, --file <fn> Specify a filename for dump file",
|
||||||
"--emu from emulator memory",
|
"--emu from emulator memory",
|
||||||
"--start <dec> index of block to start writing (default 0)",
|
"--start <dec> index of block to start writing (def 0)",
|
||||||
"--end <dec> index of block to end writing (default last block)"
|
"--end <dec> index of block to end writing (default last block)"
|
||||||
],
|
],
|
||||||
"usage": "hf mf gload [-hv] [--mini] [--1k] [--1k+] [--2k] [--4k] [-p <hex>] [-f <fn>] [--emu] [--start <dec>] [--end <dec>]"
|
"usage": "hf mf gload [-hv] [--mini] [--1k] [--1k+] [--2k] [--4k] [-p <hex>] [-f <fn>] [--emu] [--start <dec>] [--end <dec>]"
|
||||||
|
@ -10992,8 +10992,8 @@
|
||||||
"-r, --reset Reset configuration to default values",
|
"-r, --reset Reset configuration to default values",
|
||||||
"-p, --pwd <hex> Password, 7bytes, LSB-order",
|
"-p, --pwd <hex> Password, 7bytes, LSB-order",
|
||||||
"-d, --delay <dec> Tag initialization delay (in us)",
|
"-d, --delay <dec> Tag initialization delay (in us)",
|
||||||
"--lw <dec> offset, low pulses width (in us)",
|
"--lw <dec> offset, low pulses width (in us), optional!",
|
||||||
"--lp <dec> offset, low pulses position (in us)"
|
"--lp <dec> offset, low pulses position (in us), optional!"
|
||||||
],
|
],
|
||||||
"usage": "lf pcf7931 config [-hr] [-p <hex>] [-d <dec>] [--lw <dec>] [--lp <dec>]"
|
"usage": "lf pcf7931 config [-hr] [-p <hex>] [-d <dec>] [--lw <dec>] [--lp <dec>]"
|
||||||
},
|
},
|
||||||
|
@ -13232,6 +13232,6 @@
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"commands_extracted": 760,
|
"commands_extracted": 760,
|
||||||
"extracted_by": "PM3Help2JSON v1.00",
|
"extracted_by": "PM3Help2JSON v1.00",
|
||||||
"extracted_on": "2025-03-12T15:46:33"
|
"extracted_on": "2025-03-18T06:54:58"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue