mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Merge pull request #3112 from kormax/felica-info-improvement
Extract more information with 'hf felica info'
This commit is contained in:
+485
-79
File diff suppressed because it is too large
Load Diff
@@ -2049,11 +2049,11 @@ void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||
case FELICA_GETSTATUS_ACK:
|
||||
snprintf(exp, size, "GET STATUS ACK");
|
||||
break;
|
||||
case FELICA_OSVER_REQ:
|
||||
snprintf(exp, size, "REQUEST SPECIFIC VERSION");
|
||||
case FELICA_REQUEST_SPEC_VERSION_REQ:
|
||||
snprintf(exp, size, "REQUEST SPEC VERSION");
|
||||
break;
|
||||
case FELICA_OSVER_ACK:
|
||||
snprintf(exp, size, "RSV ACK");
|
||||
case FELICA_REQUEST_SPEC_VERSION_ACK:
|
||||
snprintf(exp, size, "REQUEST SPEC ACK");
|
||||
break;
|
||||
case FELICA_RESET_MODE_REQ:
|
||||
snprintf(exp, size, "RESET MODE");
|
||||
|
||||
@@ -1368,6 +1368,39 @@ void clean_ascii(unsigned char *buf, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
bool decode_zero_padded_ascii(const uint8_t *data, size_t data_len, char *out, size_t out_len) {
|
||||
if (data == NULL || out == NULL || out_len == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t text_len = 0;
|
||||
while (text_len < data_len && data[text_len] != 0x00) {
|
||||
if (data[text_len] < 0x20 || data[text_len] > 0x7E) {
|
||||
return false;
|
||||
}
|
||||
text_len++;
|
||||
}
|
||||
|
||||
if (text_len == 0 || text_len == data_len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = text_len; i < data_len; i++) {
|
||||
if (data[i] != 0x00) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t copy_len = text_len;
|
||||
if (copy_len > out_len - 1) {
|
||||
copy_len = out_len - 1;
|
||||
}
|
||||
|
||||
memcpy(out, data, copy_len);
|
||||
out[copy_len] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
// replace \r \n to \0
|
||||
void str_cleanrn(char *buf, size_t len) {
|
||||
str_creplace(buf, len, '\n', '\0');
|
||||
|
||||
@@ -166,6 +166,7 @@ void strn_upper(char *s, size_t n);
|
||||
bool str_startswith(const char *s, const char *pre); // check for prefix in string
|
||||
bool str_endswith(const char *s, const char *suffix); // check for suffix in string
|
||||
void clean_ascii(unsigned char *buf, size_t len);
|
||||
bool decode_zero_padded_ascii(const uint8_t *data, size_t data_len, char *out, size_t out_len);
|
||||
void str_cleanrn(char *buf, size_t len);
|
||||
void str_creplace(char *buf, size_t len, char from, char to);
|
||||
void str_reverse(char *buf, size_t len);
|
||||
|
||||
+66
-9
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define FELICA_SPECIFICATION_VERSION_MAX_OPTIONS 16U
|
||||
|
||||
typedef enum FELICA_COMMAND {
|
||||
FELICA_CONNECT = (1 << 0),
|
||||
FELICA_NO_DISCONNECT = (1 << 1),
|
||||
@@ -81,11 +83,75 @@ typedef struct {
|
||||
uint8_t IDm[8];
|
||||
} PACKED felica_frame_response_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t sync[2];
|
||||
uint8_t length[1];
|
||||
uint8_t cmd_code[1];
|
||||
} PACKED felica_frame_response_noidm_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t status_flag1[1];
|
||||
uint8_t status_flag2[1];
|
||||
} PACKED felica_status_flags_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length[1];
|
||||
uint8_t command_code[1];
|
||||
uint8_t reserved[2];
|
||||
} PACKED felica_get_container_id_request_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_noidm_t frame_response;
|
||||
uint8_t container_idm[8];
|
||||
} PACKED felica_get_container_id_response_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length[1];
|
||||
uint8_t command_code[1];
|
||||
uint8_t property_index[2];
|
||||
} PACKED felica_get_container_property_request_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_noidm_t frame_response;
|
||||
uint8_t property_data[];
|
||||
} PACKED felica_get_container_property_response_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length[1];
|
||||
uint8_t command_code[1];
|
||||
uint8_t IDm[8];
|
||||
uint8_t reserved[2];
|
||||
} PACKED felica_get_container_issue_info_request_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_t frame_response;
|
||||
uint8_t format_version_carrier_information[5];
|
||||
uint8_t mobile_phone_model_information[11];
|
||||
} PACKED felica_get_container_issue_info_response_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length[1];
|
||||
uint8_t command_code[1];
|
||||
uint8_t IDm[8];
|
||||
} PACKED felica_get_platform_info_request_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length[1];
|
||||
uint8_t command_code[1];
|
||||
uint8_t IDm[8];
|
||||
uint8_t reserved[2];
|
||||
} PACKED felica_request_specification_version_request_t;
|
||||
|
||||
typedef struct {
|
||||
felica_status_flags_t status_flags;
|
||||
bool has_specification_version;
|
||||
uint8_t format_version;
|
||||
uint8_t basic_version[2];
|
||||
uint8_t number_of_option;
|
||||
size_t option_version_count;
|
||||
uint8_t option_version_list[FELICA_SPECIFICATION_VERSION_MAX_OPTIONS * 2];
|
||||
} felica_request_specification_version_info_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_t frame_response;
|
||||
uint8_t node_number[1];
|
||||
@@ -115,15 +181,6 @@ typedef struct {
|
||||
uint8_t system_code_list[32];
|
||||
} PACKED felica_syscode_response_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_t frame_response;
|
||||
felica_status_flags_t status_flags;
|
||||
uint8_t format_version[1];
|
||||
uint8_t basic_version[2];
|
||||
uint8_t number_of_option[1];
|
||||
uint8_t option_version_list[4];
|
||||
} PACKED felica_request_spec_response_t;
|
||||
|
||||
typedef struct {
|
||||
felica_frame_response_t frame_response;
|
||||
uint8_t m2c[8];
|
||||
|
||||
+14
-2
@@ -849,14 +849,23 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
||||
#define FELICA_WRTSEC_REQ 0x16
|
||||
#define FELICA_WRTSEC_ACK 0x17
|
||||
|
||||
#define FELICA_GET_CONTAINER_ISSUE_INFO_REQ 0x22
|
||||
#define FELICA_GET_CONTAINER_ISSUE_INFO_ACK 0x23
|
||||
|
||||
#define FELICA_GET_CONTAINER_PROPERTY_REQ 0x2e
|
||||
#define FELICA_GET_CONTAINER_PROPERTY_ACK 0x2f
|
||||
|
||||
#define FELICA_REQSRV2_REQ 0x32
|
||||
#define FELICA_REQSRV2_ACK 0x33
|
||||
|
||||
#define FELICA_GETSTATUS_REQ 0x38
|
||||
#define FELICA_GETSTATUS_ACK 0x39
|
||||
|
||||
#define FELICA_OSVER_REQ 0x3c
|
||||
#define FELICA_OSVER_ACK 0x3d
|
||||
#define FELICA_GETPLATFORMINFO_REQ 0x3a
|
||||
#define FELICA_GETPLATFORMINFO_ACK 0x3b
|
||||
|
||||
#define FELICA_REQUEST_SPEC_VERSION_REQ 0x3c
|
||||
#define FELICA_REQUEST_SPEC_VERSION_ACK 0x3d
|
||||
|
||||
#define FELICA_RESET_MODE_REQ 0x3e
|
||||
#define FELICA_RESET_MODE_ACK 0x3f
|
||||
@@ -875,6 +884,9 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
||||
#define FELICA_UPDATE_RNDID_REQ 0x4C
|
||||
#define FELICA_UPDATE_RNDID_ACK 0x4D
|
||||
|
||||
#define FELICA_GET_CONTAINER_ID_REQ 0x70
|
||||
#define FELICA_GET_CONTAINER_ID_ACK 0x71
|
||||
|
||||
// FeliCa SYSTEM list
|
||||
#define SYSTEMCODE_ANY 0xffff // ANY
|
||||
#define SYSTEMCODE_FELICA_LITE 0x88b4 // FeliCa Lite
|
||||
|
||||
Reference in New Issue
Block a user