make style

This commit is contained in:
Philippe Teuwen
2026-02-21 12:43:25 +01:00
parent 237841db9e
commit b62658f5ac
8 changed files with 727 additions and 910 deletions
+88 -82
View File
@@ -140,8 +140,8 @@ static bool find_tag(tag_t *tag_type) {
switch (version_len) {
case 0x0A: {
if ((memcmp(version, "\x00\x04\x03\x01\x04\x00\x0F\x03", 8) == 0) ||
(memcmp(version, "\x00\x04\x03\x02\x04\x00\x0F\x03", 8) == 0) ||
(memcmp(version, "\x00\x04\x03\x03\x04\x00\x0F\x03", 8) == 0)) {
(memcmp(version, "\x00\x04\x03\x02\x04\x00\x0F\x03", 8) == 0) ||
(memcmp(version, "\x00\x04\x03\x03\x04\x00\x0F\x03", 8) == 0)) {
*tag_type = TAG_ULAES;
// DbpString("Found Ultralight AES");
}
@@ -342,10 +342,16 @@ static bool write_auth0(tag_t type) {
uint8_t cmd[8] = {MIFARE_ULC_WRITE};
if (type == TAG_ULC) {
cmd[1] = 0x2A;
cmd[2] = 0x30; cmd[3] = 0x00; cmd[4] = 0x00; cmd[5] = 0x00;
cmd[2] = 0x30;
cmd[3] = 0x00;
cmd[4] = 0x00;
cmd[5] = 0x00;
} else if (type == TAG_ULAES) {
cmd[1] = 0x29;
cmd[2] = 0x00; cmd[3] = 0x00; cmd[4] = 0x00; cmd[5] = 0x3C;
cmd[2] = 0x00;
cmd[3] = 0x00;
cmd[4] = 0x00;
cmd[5] = 0x3C;
} else {
goto out;
}
@@ -387,92 +393,92 @@ void RunMod(void) {
}
switch (state) {
case ST_LOOK_FOR_CARD: {
if (welcome_state_look) {
Dbprintf("Place an Ultralight C or Ultralight AES tag on the Proxmark3.");
welcome_state_look = false;
}
blink_led_slow(LED_A);
if (find_tag(&tag_type)) {
if (tag_type == TAG_ULC) {
DbpString("Found Ultralight C tag!");
state = ST_SNIFF_AUTH;
// SpinDelay(1000);
break;
}else if (tag_type == TAG_ULAES) {
DbpString("Found Ultralight AES tag!");
state = ST_SNIFF_AUTH;
// SpinDelay(1000);
break;
} else {
DbpString("Found other tag type, ignoring...");
uint32_t t0 = GetTickCount();
while (GetTickCount() - t0 < 2000) {
blink_led_fast(LED_A);
case ST_LOOK_FOR_CARD: {
if (welcome_state_look) {
Dbprintf("Place an Ultralight C or Ultralight AES tag on the Proxmark3.");
welcome_state_look = false;
}
blink_led_slow(LED_A);
if (find_tag(&tag_type)) {
if (tag_type == TAG_ULC) {
DbpString("Found Ultralight C tag!");
state = ST_SNIFF_AUTH;
// SpinDelay(1000);
break;
} else if (tag_type == TAG_ULAES) {
DbpString("Found Ultralight AES tag!");
state = ST_SNIFF_AUTH;
// SpinDelay(1000);
break;
} else {
DbpString("Found other tag type, ignoring...");
uint32_t t0 = GetTickCount();
while (GetTickCount() - t0 < 2000) {
blink_led_fast(LED_A);
}
}
}
break;
}
break;
}
case ST_SNIFF_AUTH: {
if (welcome_state_sniff) {
Dbprintf("Bring the tag and Proxmark3 together slowly towards the authenticating reader.");
welcome_state_sniff = false;
case ST_SNIFF_AUTH: {
if (welcome_state_sniff) {
Dbprintf("Bring the tag and Proxmark3 together slowly towards the authenticating reader.");
welcome_state_sniff = false;
}
LED_A_ON();
LED_B_ON();
if (sniff_wait_for_rnda_reply(tag_type)) {
LED_B_ON();
LED_C_ON();
DbpString("Card is authenticated!");
state = ST_WAIT_BUTTON;
}
break;
}
LED_A_ON();
LED_B_ON();
if (sniff_wait_for_rnda_reply(tag_type)) {
case ST_WAIT_BUTTON: {
if (welcome_state_button) {
Dbprintf("Pull the tag and Proxmark3 together away from the reader, then press the button.");
welcome_state_button = false;
}
LED_A_ON();
LED_B_ON();
blink_led_slow(LED_C);
if (BUTTON_PRESS()) {
state = ST_WAIT_BUTTON_RELEASE;
}
break;
}
case ST_WAIT_BUTTON_RELEASE: {
LED_A_ON();
LED_B_ON();
blink_led_slow(LED_C);
if (BUTTON_PRESS() == false) {
state = ST_WRITE_AUTH0;
}
break;
}
case ST_WRITE_AUTH0: {
LED_A_ON();
LED_B_ON();
LED_C_ON();
DbpString("Card is authenticated!");
state = ST_WAIT_BUTTON;
}
break;
}
case ST_WAIT_BUTTON: {
if (welcome_state_button) {
Dbprintf("Pull the tag and Proxmark3 together away from the reader, then press the button.");
welcome_state_button = false;
}
LED_A_ON();
LED_B_ON();
blink_led_slow(LED_C);
if (BUTTON_PRESS()) {
state = ST_WAIT_BUTTON_RELEASE;
}
break;
}
case ST_WAIT_BUTTON_RELEASE: {
LED_A_ON();
LED_B_ON();
blink_led_slow(LED_C);
if (BUTTON_PRESS() == false) {
state = ST_WRITE_AUTH0;
}
break;
}
case ST_WRITE_AUTH0: {
LED_A_ON();
LED_B_ON();
LED_C_ON();
if (write_auth0(tag_type)) {
Dbprintf("AUTH0 written! Press the button to exit.");
LED_D_ON();
while (!BUTTON_PRESS()) {}
} else {
Dbprintf("AUTH0 write failed. Press the button to exit.");
while (!BUTTON_PRESS()) {
blink_led_fast(LED_D);
if (write_auth0(tag_type)) {
Dbprintf("AUTH0 written! Press the button to exit.");
LED_D_ON();
while (!BUTTON_PRESS()) {}
} else {
Dbprintf("AUTH0 write failed. Press the button to exit.");
while (!BUTTON_PRESS()) {
blink_led_fast(LED_D);
}
}
state = ST_EXIT;
break;
}
state = ST_EXIT;
break;
}
case ST_EXIT:
break;
default:
state = ST_LOOK_FOR_CARD;
break;
case ST_EXIT:
break;
default:
state = ST_LOOK_FOR_CARD;
break;
}
WDT_HIT();
}
+1 -1
View File
@@ -561,7 +561,7 @@ void felica_sendraw(const PacketCommandNG *c) {
param = request->flags;
len = request->rawlen;
payload = request->raw;
bool do_connect = ((param & FELICA_CONNECT) == FELICA_CONNECT);
bool no_disconnect = ((param & FELICA_NO_DISCONNECT) == FELICA_NO_DISCONNECT);
+3 -3
View File
@@ -1472,9 +1472,9 @@ static int ulev1_print_counters(uint64_t tagtype, bool use_schann) {
if ((tagtype & MFU_TT_UL_AES) != MFU_TT_UL_AES) {
ulev1_readTearing(i, tear, sizeof(tear));
PrintAndLogEx(SUCCESS, " - %02X tearing ( %s )"
, tear[0]
, (tear[0] == 0xBD) ? _GREEN_("ok") : _RED_("fail")
);
, tear[0]
, (tear[0] == 0xBD) ? _GREEN_("ok") : _RED_("fail")
);
}
}
}
+562 -716
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -587,6 +587,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hw standalone" },
{ 0, "hw tia" },
{ 0, "hw tune" },
{ 0, "hw decay" },
{ 1, "lf help" },
{ 0, "lf config" },
{ 0, "lf cmdread" },
+18 -2
View File
@@ -8722,6 +8722,22 @@
],
"usage": "hw dbg [-h01234]"
},
"hw decay": {
"command": "hw decay",
"description": "Measure HF antenna decay after field-off. Captures how quickly the peak-detect capacitor voltage drops after the 13.56 MHz field is turned off. Different antenna loading (unloaded, booster board, damaged) produces different decay profiles.",
"notes": [
"hw decay",
"hw decay --ms 100 -> stabilize for 100ms before measurement",
"hw decay --us 5000 -> measure 5ms decay window"
],
"offline": false,
"options": [
"-h, --help This help",
"--ms <dec> Field stabilization time in ms (default: 50)",
"--us <dec> Measurement window in us (default: 2000)"
],
"usage": "hw decay [-h] [--ms <dec>] [--us <dec>]"
},
"hw fpgaoff": {
"command": "hw fpgaoff",
"description": "Turn of fpga and antenna field",
@@ -13795,8 +13811,8 @@
}
},
"metadata": {
"commands_extracted": 790,
"commands_extracted": 791,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2026-02-09T00:12:02"
"extracted_on": "2026-02-21T11:42:25"
}
}
+1
View File
@@ -878,6 +878,7 @@ Check column "offline" for their availability.
|`hw standalone `|N |`Start installed standalone mode on device`
|`hw tia `|N |`Trigger a Timing Interval Acquisition to re-adjust the RealTimeCounter divider`
|`hw tune `|N |`Measure tuning of device antenna`
|`hw decay `|N |`Measure HF antenna decay after field-off`
### lf
+53 -106
View File
@@ -28,19 +28,16 @@
#define PM3_CMD_DATA_SIZE 512
#define PM3_CMD_DATA_SIZE_MIX (PM3_CMD_DATA_SIZE - 3 * sizeof(uint64_t))
typedef struct
{
typedef struct {
uint64_t cmd;
uint64_t arg[3];
union
{
union {
uint8_t asBytes[PM3_CMD_DATA_SIZE];
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
} d;
} PACKED PacketCommandOLD;
typedef struct
{
typedef struct {
uint32_t magic;
uint16_t length : 15; // length of the variable part, 0 if none.
bool ng : 1;
@@ -50,21 +47,18 @@ typedef struct
#define COMMANDNG_PREAMBLE_MAGIC 0x61334d50 // PM3a
#define COMMANDNG_POSTAMBLE_MAGIC 0x3361 // a3
typedef struct
{
typedef struct {
uint16_t crc;
} PACKED PacketCommandNGPostamble;
// For internal usage
typedef struct
{
typedef struct {
uint16_t cmd;
uint16_t length;
uint32_t magic; // NG
uint16_t crc; // NG
uint64_t oldarg[3]; // OLD
union
{
union {
uint8_t asBytes[PM3_CMD_DATA_SIZE];
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
} data;
@@ -72,26 +66,22 @@ typedef struct
} PacketCommandNG;
// For reception and CRC check
typedef struct
{
typedef struct {
PacketCommandNGPreamble pre;
uint8_t data[PM3_CMD_DATA_SIZE];
PacketCommandNGPostamble foopost; // Probably not at that offset!
} PACKED PacketCommandNGRaw;
typedef struct
{
typedef struct {
uint64_t cmd;
uint64_t arg[3];
union
{
union {
uint8_t asBytes[PM3_CMD_DATA_SIZE];
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
} d;
} PACKED PacketResponseOLD;
typedef struct
{
typedef struct {
uint32_t magic;
uint16_t length : 15; // length of the variable part, 0 if none.
bool ng : 1;
@@ -103,14 +93,12 @@ typedef struct
#define RESPONSENG_PREAMBLE_MAGIC 0x62334d50 // PM3b
#define RESPONSENG_POSTAMBLE_MAGIC 0x3362 // b3
typedef struct
{
typedef struct {
uint16_t crc;
} PACKED PacketResponseNGPostamble;
// For internal usage
typedef struct
{
typedef struct {
uint16_t cmd;
uint16_t length;
uint32_t magic; // NG
@@ -118,8 +106,7 @@ typedef struct
int8_t reason; // NG
uint16_t crc; // NG
uint64_t oldarg[3]; // OLD
union
{
union {
uint8_t asBytes[PM3_CMD_DATA_SIZE];
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
} data;
@@ -127,16 +114,14 @@ typedef struct
} PacketResponseNG;
// For reception and CRC check
typedef struct
{
typedef struct {
PacketResponseNGPreamble pre;
uint8_t data[PM3_CMD_DATA_SIZE];
PacketResponseNGPostamble foopost; // Probably not at that offset!
} PACKED PacketResponseNGRaw;
// A struct used to send sample-configs over USB
typedef struct
{
typedef struct {
int8_t decimation;
int8_t bits_per_sample;
int8_t averaging;
@@ -148,8 +133,7 @@ typedef struct
// Defines a frame that will be used in a polling sequence
// Polling loop annotations are up to 20 bytes long, 24 bytes should cover future and other cases
typedef struct
{
typedef struct {
uint8_t frame[24];
// negative values can be used to carry special info
int8_t frame_length;
@@ -158,8 +142,7 @@ typedef struct
} PACKED iso14a_polling_frame_t;
// Defines polling sequence configuration
typedef struct
{
typedef struct {
// 6 would be enough for 4 magsafe, 1 wupa, 1 pla,
iso14a_polling_frame_t frames[6];
int8_t frame_count;
@@ -167,8 +150,7 @@ typedef struct
} PACKED iso14a_polling_parameters_t;
// A struct used to send hf14a-configs over USB
typedef struct
{
typedef struct {
int8_t forceanticol; // 0:auto 1:force executing anticol 2:force skipping anticol
int8_t forcebcc; // 0:expect valid BCC 1:force using computed BCC 2:force using card BCC
int8_t forcecl2; // 0:auto 1:force executing CL2 2:force skipping CL2
@@ -180,8 +162,7 @@ typedef struct
// Defines a frame that will be used in ISO14443B polling sequence
// Polling loop annotations are up to 20 bytes long, 24 bytes should cover future and other cases
typedef struct
{
typedef struct {
uint8_t frame[24];
// negative values can be used to carry special info
int8_t frame_length;
@@ -190,14 +171,12 @@ typedef struct
} PACKED iso14b_polling_frame_t;
// A struct used to send hf14b-configs over USB
typedef struct
{
typedef struct {
iso14b_polling_frame_t polling_loop_annotation; // Polling loop annotation
} PACKED hf14b_config_t;
// Tracelog Header struct
typedef struct
{
typedef struct {
uint32_t timestamp;
uint16_t duration;
uint16_t data_len : 15;
@@ -211,8 +190,7 @@ typedef struct
#define TRACELOG_PARITY_LEN(x) (((x)->data_len - 1) / 8 + 1)
// T55XX - Extended to support 1 of 4 timing
typedef struct
{
typedef struct {
uint16_t start_gap;
uint16_t write_gap;
uint16_t write_0;
@@ -224,14 +202,12 @@ typedef struct
// T55XX - This setup will allow for the 4 downlink modes "m" as well as other items if needed.
// Given the one struct we can then read/write to flash/client in one go.
typedef struct
{
typedef struct {
t55xx_config_t m[4]; // mode
} t55xx_configurations_t;
// Capabilities struct to keep track of what functions was compiled in the device firmware
typedef struct
{
typedef struct {
uint8_t version;
uint32_t baudrate;
uint32_t bigbuf_size;
@@ -272,24 +248,21 @@ typedef struct
extern capabilities_t g_pm3_capabilities;
// For CMD_LF_T55XX_WRITEBL
typedef struct
{
typedef struct {
uint32_t data;
uint32_t pwd;
uint8_t blockno;
uint8_t flags;
} PACKED t55xx_write_block_t;
typedef struct
{
typedef struct {
uint8_t data[128];
uint8_t bitlen;
uint32_t time;
} PACKED t55xx_test_block_t;
// For CMD_LF_HID_SIMULATE (FSK)
typedef struct
{
typedef struct {
uint32_t hi2;
uint32_t hi;
uint32_t lo;
@@ -299,8 +272,7 @@ typedef struct
} PACKED lf_hidsim_t;
// For CMD_LF_FSK_SIMULATE (FSK)
typedef struct
{
typedef struct {
uint8_t fchigh;
uint8_t fclow;
uint8_t separator;
@@ -309,8 +281,7 @@ typedef struct
} PACKED lf_fsksim_t;
// For CMD_LF_ASK_SIMULATE (ASK)
typedef struct
{
typedef struct {
uint8_t encoding;
uint8_t invert;
uint8_t separator;
@@ -319,8 +290,7 @@ typedef struct
} PACKED lf_asksim_t;
// For CMD_LF_PSK_SIMULATE (PSK)
typedef struct
{
typedef struct {
uint8_t carrier;
uint8_t invert;
uint8_t clock;
@@ -328,16 +298,14 @@ typedef struct
} PACKED lf_psksim_t;
// For CMD_LF_NRZ_SIMULATE (NRZ)
typedef struct
{
typedef struct {
uint8_t invert;
uint8_t separator;
uint8_t clock;
uint8_t data[];
} PACKED lf_nrzsim_t;
typedef struct
{
typedef struct {
uint8_t type;
uint16_t len;
uint8_t data[];
@@ -347,23 +315,20 @@ typedef struct
#define LF_SAMPLES_BITS 30
#define MAX_LF_SAMPLES ((((uint32_t)1u) << LF_SAMPLES_BITS) - 1)
typedef struct
{
typedef struct {
// 64KB SRAM -> 524288 bits(max sample num) < 2^30
uint32_t samples : LF_SAMPLES_BITS;
bool realtime : 1;
bool verbose : 1;
} PACKED lf_sample_payload_t;
typedef struct
{
typedef struct {
uint8_t blockno;
uint8_t keytype;
uint8_t key[6];
} PACKED mf_readblock_t;
typedef enum
{
typedef enum {
MF_WAKE_NONE,
MF_WAKE_WUPA, // 52(7) + anticoll
MF_WAKE_REQA, // 26(7) + anticoll
@@ -372,8 +337,7 @@ typedef enum
MF_WAKE_GDM_ALT, // 20(7)/23
} PACKED MifareWakeupType;
typedef struct
{
typedef struct {
MifareWakeupType wakeup;
uint8_t auth_cmd;
uint8_t key[6];
@@ -381,8 +345,7 @@ typedef struct
uint8_t block_no;
} PACKED mf_readblock_ex_t;
typedef struct
{
typedef struct {
MifareWakeupType wakeup;
uint8_t auth_cmd;
uint8_t key[6];
@@ -391,15 +354,13 @@ typedef struct
uint8_t block_data[16];
} PACKED mf_writeblock_ex_t;
typedef struct
{
typedef struct {
uint8_t sectorcnt;
uint8_t keytype;
uint8_t key[6];
} PACKED mfc_eload_t;
typedef struct
{
typedef struct {
uint8_t turn_off_field : 1;
uint8_t check_answer : 1;
uint8_t keyno : 2;
@@ -409,13 +370,11 @@ typedef struct
uint8_t key[16];
} PACKED mful_3passauth_t;
enum
{
enum {
MIFAREU3P_KEY_SIZE = 16,
MIFAREU3P_CHKKEY_HEADER = 2 + MIFAREU3P_KEY_SIZE
};
typedef struct
{
typedef struct {
uint8_t key_index : 2;
uint8_t firstchunk : 1;
uint8_t lastchunk : 1;
@@ -427,8 +386,7 @@ typedef struct
uint8_t data[PM3_CMD_DATA_SIZE - MIFAREU3P_CHKKEY_HEADER];
} PACKED mful_3passchk_t;
typedef struct
{
typedef struct {
bool use_schann;
uint8_t block_no;
uint8_t num_of_blocks;
@@ -437,14 +395,12 @@ typedef struct
uint8_t key[16];
} PACKED mful_readblock_t;
typedef struct
{
typedef struct {
uint16_t bytelen;
uint16_t startidx;
} PACKED mful_readblock_resp_t;
typedef struct
{
typedef struct {
bool use_schann;
uint8_t block_no;
uint8_t keytype;
@@ -453,8 +409,7 @@ typedef struct
uint8_t data[16];
} PACKED mful_writeblock_t;
typedef struct
{
typedef struct {
bool has_auth_key;
bool use_schann;
uint8_t auth_key[16];
@@ -463,8 +418,7 @@ typedef struct
uint8_t key[16];
} PACKED mful_setkey_t;
typedef struct
{
typedef struct {
uint8_t status;
uint8_t CSN[8];
uint8_t CONFIG[8];
@@ -472,14 +426,12 @@ typedef struct
uint8_t AIA[8];
} PACKED iclass_reader_t;
typedef struct
{
typedef struct {
const char *desc;
const char *value;
} PACKED ecdsa_publickey_t;
typedef struct
{
typedef struct {
uint16_t delay_us;
int8_t skip;
bool on;
@@ -487,8 +439,7 @@ typedef struct
} PACKED tearoff_params_t;
// when writing to SPIFFS
typedef struct
{
typedef struct {
bool append : 1;
uint16_t bytes_in_packet : 15;
uint8_t fnlen;
@@ -497,8 +448,7 @@ typedef struct
} PACKED flashmem_write_t;
// when CMD_FLASHMEM_WRITE old flashmem commands
typedef struct
{
typedef struct {
uint32_t startidx;
uint16_t len;
uint8_t data[PM3_CMD_DATA_SIZE - sizeof(uint32_t) - sizeof(uint16_t)];
@@ -507,14 +457,12 @@ typedef struct
//-----------------------------------------------------------------------------
// ISO 7618 Smart Card
//-----------------------------------------------------------------------------
typedef struct
{
typedef struct {
uint8_t atr_len;
uint8_t atr[50];
} PACKED smart_card_atr_t;
typedef enum SMARTCARD_COMMAND
{
typedef enum SMARTCARD_COMMAND {
SC_CONNECT = (1 << 0),
SC_NO_DISCONNECT = (1 << 1),
SC_RAW = (1 << 2),
@@ -525,8 +473,7 @@ typedef enum SMARTCARD_COMMAND
SC_WAIT = (1 << 7),
} smartcard_command_t;
typedef struct
{
typedef struct {
uint8_t flags;
uint32_t wait_delay;
uint16_t len;