mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-06 04:51:36 -07:00
style
This commit is contained in:
parent
5b37fe8af6
commit
16cbb4a446
5 changed files with 88 additions and 78 deletions
|
@ -50,22 +50,6 @@
|
||||||
#define Logic1 Iso15693Logic1
|
#define Logic1 Iso15693Logic1
|
||||||
#define FrameEOF Iso15693FrameEOF
|
#define FrameEOF Iso15693FrameEOF
|
||||||
#define CARD_MEMORY_SIZE 4096
|
#define CARD_MEMORY_SIZE 4096
|
||||||
#define HF15_UID_LENGTH 8
|
|
||||||
|
|
||||||
#ifndef Crc15
|
|
||||||
# define Crc15(data, len) Crc16ex(CRC_15693, (data), (len))
|
|
||||||
#endif
|
|
||||||
#ifndef CheckCrc15
|
|
||||||
# define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
|
||||||
#endif
|
|
||||||
#ifndef AddCrc15
|
|
||||||
#define AddCrc15(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ISO15_RAW_LEN
|
|
||||||
#define ISO15_RAW_LEN(x) (sizeof(iso15_raw_cmd_t) + (x))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ISO15_ERROR_HANDLING_RESPONSE
|
#ifndef ISO15_ERROR_HANDLING_RESPONSE
|
||||||
#define ISO15_ERROR_HANDLING_RESPONSE { \
|
#define ISO15_ERROR_HANDLING_RESPONSE { \
|
||||||
|
@ -98,6 +82,11 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t lock;
|
||||||
|
uint8_t block[8];
|
||||||
|
} t15memory_t;
|
||||||
|
|
||||||
// structure and database for uid -> tagtype lookups
|
// structure and database for uid -> tagtype lookups
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
|
@ -474,7 +463,7 @@ static int getUID(bool verbose, bool loop, uint8_t *buf) {
|
||||||
|
|
||||||
// used with 'hf search'
|
// used with 'hf search'
|
||||||
bool readHF15Uid(bool loop, bool verbose) {
|
bool readHF15Uid(bool loop, bool verbose) {
|
||||||
uint8_t uid[HF15_UID_LENGTH] = {0};
|
uint8_t uid[ISO15693_UID_LENGTH] = {0};
|
||||||
if (getUID(verbose, loop, uid) != PM3_SUCCESS) {
|
if (getUID(verbose, loop, uid) != PM3_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -665,7 +654,7 @@ static int NxpTestEAS(const uint8_t *uid) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t approxlen = 3 + HF15_UID_LENGTH + 2;
|
uint8_t approxlen = 3 + ISO15693_UID_LENGTH + 2;
|
||||||
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
|
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
|
||||||
if (packet == NULL) {
|
if (packet == NULL) {
|
||||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||||
|
@ -677,8 +666,8 @@ static int NxpTestEAS(const uint8_t *uid) {
|
||||||
packet->raw[packet->rawlen++] = ISO15693_EAS_ALARM;
|
packet->raw[packet->rawlen++] = ISO15693_EAS_ALARM;
|
||||||
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
||||||
|
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH); // add UID
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH); // add UID
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
|
|
||||||
AddCrc15(packet->raw, packet->rawlen);
|
AddCrc15(packet->raw, packet->rawlen);
|
||||||
packet->rawlen += 2;
|
packet->rawlen += 2;
|
||||||
|
@ -720,7 +709,7 @@ static int NxpCheckSig(uint8_t *uid) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t approxlen = 3 + HF15_UID_LENGTH + 2;
|
uint8_t approxlen = 3 + ISO15693_UID_LENGTH + 2;
|
||||||
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
|
iso15_raw_cmd_t *packet = (iso15_raw_cmd_t *)calloc(1, sizeof(iso15_raw_cmd_t) + approxlen);
|
||||||
if (packet == NULL) {
|
if (packet == NULL) {
|
||||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||||
|
@ -733,8 +722,8 @@ static int NxpCheckSig(uint8_t *uid) {
|
||||||
packet->raw[packet->rawlen++] = ISO15693_READ_SIGNATURE;
|
packet->raw[packet->rawlen++] = ISO15693_READ_SIGNATURE;
|
||||||
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
||||||
|
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH); // add UID
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH); // add UID
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
|
|
||||||
AddCrc15(packet->raw, packet->rawlen);
|
AddCrc15(packet->raw, packet->rawlen);
|
||||||
packet->rawlen += 2;
|
packet->rawlen += 2;
|
||||||
|
@ -787,7 +776,7 @@ static int NxpSysInfo(uint8_t *uid) {
|
||||||
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
packet->raw[packet->rawlen++] = 0x04; // IC manufacturer code
|
||||||
|
|
||||||
memcpy(packet->raw + 3, uid, 8); // add UID
|
memcpy(packet->raw + 3, uid, 8); // add UID
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
|
|
||||||
AddCrc15(packet->raw, packet->rawlen);
|
AddCrc15(packet->raw, packet->rawlen);
|
||||||
packet->rawlen += 2;
|
packet->rawlen += 2;
|
||||||
|
@ -900,11 +889,11 @@ static int StCheckSig(uint8_t *uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISO15693 Protocol params
|
// ISO15693 Protocol params
|
||||||
packet->raw[packet->rawlen++] = arg_get_raw_flag(HF15_UID_LENGTH, false, false, false);
|
packet->raw[packet->rawlen++] = arg_get_raw_flag(ISO15693_UID_LENGTH, false, false, false);
|
||||||
packet->raw[packet->rawlen++] = ISO15693_READBLOCK;
|
packet->raw[packet->rawlen++] = ISO15693_READBLOCK;
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH);
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
packet->flags = (ISO15_CONNECT | ISO15_READ_RESPONSE | ISO15_NO_DISCONNECT);
|
packet->flags = (ISO15_CONNECT | ISO15_READ_RESPONSE | ISO15_NO_DISCONNECT);
|
||||||
uint16_t blkoff = packet->rawlen;
|
uint16_t blkoff = packet->rawlen;
|
||||||
char signature_hex[65] = {0};
|
char signature_hex[65] = {0};
|
||||||
|
@ -943,9 +932,9 @@ static int StCheckSig(uint8_t *uid) {
|
||||||
uint8_t signature[16];
|
uint8_t signature[16];
|
||||||
size_t signature_len;
|
size_t signature_len;
|
||||||
hexstr_to_byte_array(signature_hex, signature, &signature_len);
|
hexstr_to_byte_array(signature_hex, signature, &signature_len);
|
||||||
uint8_t uid_swap[HF15_UID_LENGTH];
|
uint8_t uid_swap[ISO15693_UID_LENGTH];
|
||||||
reverse_array_copy(uid, HF15_UID_LENGTH, uid_swap);
|
reverse_array_copy(uid, ISO15693_UID_LENGTH, uid_swap);
|
||||||
int index = originality_check_verify_ex(uid_swap, HF15_UID_LENGTH, signature, signature_len, PK_ST25TV, false, true);
|
int index = originality_check_verify_ex(uid_swap, ISO15693_UID_LENGTH, signature, signature_len, PK_ST25TV, false, true);
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
return originality_check_print(signature, signature_len, index);
|
return originality_check_print(signature, signature_len, index);
|
||||||
}
|
}
|
||||||
|
@ -970,7 +959,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
bool unaddressed = arg_get_lit(ctx, 2);
|
bool unaddressed = arg_get_lit(ctx, 2);
|
||||||
|
@ -987,7 +976,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// default fallback to scan for tag.
|
// default fallback to scan for tag.
|
||||||
if (unaddressed == false && uidlen != HF15_UID_LENGTH) {
|
if (unaddressed == false && uidlen != ISO15693_UID_LENGTH) {
|
||||||
scan = true;
|
scan = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,10 +1003,10 @@ static int CmdHF15Info(const char *Cmd) {
|
||||||
free(packet);
|
free(packet);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
uidlen = HF15_UID_LENGTH;
|
uidlen = ISO15693_UID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uidlen == HF15_UID_LENGTH) {
|
if (uidlen == ISO15693_UID_LENGTH) {
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, uidlen);
|
memcpy(packet->raw + packet->rawlen, uid, uidlen);
|
||||||
packet->rawlen += uidlen;
|
packet->rawlen += uidlen;
|
||||||
|
@ -1486,7 +1475,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
uint8_t block_size;
|
uint8_t block_size;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
memset(&payload, 0, sizeof(payload));
|
memset(&payload, 0, sizeof(payload));
|
||||||
|
@ -1497,7 +1486,7 @@ static int CmdHF15Sim(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (uidlen != 0 && uidlen != HF15_UID_LENGTH) {
|
if (uidlen != 0 && uidlen != ISO15693_UID_LENGTH) {
|
||||||
PrintAndLogEx(WARNING, "UID must include 8 hex bytes, got ( " _RED_("%i") " )", uidlen);
|
PrintAndLogEx(WARNING, "UID must include 8 hex bytes, got ( " _RED_("%i") " )", uidlen);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -1624,7 +1613,7 @@ static int CmdHF15WriteAfi(const char *Cmd) {
|
||||||
struct {
|
struct {
|
||||||
uint8_t pwd[4];
|
uint8_t pwd[4];
|
||||||
bool use_pwd;
|
bool use_pwd;
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
bool use_uid;
|
bool use_uid;
|
||||||
uint8_t afi;
|
uint8_t afi;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
|
@ -1645,7 +1634,7 @@ static int CmdHF15WriteAfi(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
payload.use_uid = false;
|
payload.use_uid = false;
|
||||||
if (uidlen == HF15_UID_LENGTH) {
|
if (uidlen == ISO15693_UID_LENGTH) {
|
||||||
payload.use_uid = true;
|
payload.use_uid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1703,7 +1692,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH] = {0};
|
uint8_t uid[ISO15693_UID_LENGTH] = {0};
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
|
|
||||||
|
@ -1742,10 +1731,10 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
|
||||||
free(packet);
|
free(packet);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
uidlen = HF15_UID_LENGTH;
|
uidlen = ISO15693_UID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uidlen == HF15_UID_LENGTH) {
|
if (uidlen == ISO15693_UID_LENGTH) {
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, uidlen);
|
memcpy(packet->raw + packet->rawlen, uid, uidlen);
|
||||||
packet->rawlen += uidlen;
|
packet->rawlen += uidlen;
|
||||||
|
@ -1807,7 +1796,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH] = {0};
|
uint8_t uid[ISO15693_UID_LENGTH] = {0};
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
|
|
||||||
|
@ -1838,7 +1827,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// default fallback to scan for tag.
|
// default fallback to scan for tag.
|
||||||
if (uidlen != HF15_UID_LENGTH && !unaddressed) {
|
if (uidlen != ISO15693_UID_LENGTH && !unaddressed) {
|
||||||
scan = true;
|
scan = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1874,11 +1863,11 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH);
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
used_uid = true;
|
used_uid = true;
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
@ -2178,10 +2167,10 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH] = {0x00};
|
uint8_t uid[ISO15693_UID_LENGTH] = {0x00};
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
bool uid_set = (uidlen == HF15_UID_LENGTH) ? true : false;
|
bool uid_set = (uidlen == ISO15693_UID_LENGTH) ? true : false;
|
||||||
|
|
||||||
bool unaddressed = arg_get_lit(ctx, 2);
|
bool unaddressed = arg_get_lit(ctx, 2);
|
||||||
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; //Default fallback to scan for tag. Overriding unaddressed parameter.
|
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; //Default fallback to scan for tag. Overriding unaddressed parameter.
|
||||||
|
@ -2239,11 +2228,11 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH);
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
@ -2336,10 +2325,10 @@ static int CmdHF15Readblock(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
bool uid_set = (uidlen == HF15_UID_LENGTH) ? true : false;
|
bool uid_set = (uidlen == ISO15693_UID_LENGTH) ? true : false;
|
||||||
|
|
||||||
bool unaddressed = arg_get_lit(ctx, 2);
|
bool unaddressed = arg_get_lit(ctx, 2);
|
||||||
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
||||||
|
@ -2393,11 +2382,11 @@ static int CmdHF15Readblock(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
// add UID (scan, uid)
|
// add UID (scan, uid)
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH);
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
@ -2490,8 +2479,8 @@ static int hf_15_write_blk(const uint8_t *pm3flags, uint16_t flags, const uint8_
|
||||||
|
|
||||||
// add UID
|
// add UID
|
||||||
if (uid) {
|
if (uid) {
|
||||||
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
|
memcpy(packet->raw + packet->rawlen, uid, ISO15693_UID_LENGTH);
|
||||||
packet->rawlen += HF15_UID_LENGTH;
|
packet->rawlen += ISO15693_UID_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet->raw[packet->rawlen++] = blockno;
|
packet->raw[packet->rawlen++] = blockno;
|
||||||
|
@ -2550,10 +2539,10 @@ static int CmdHF15Write(const char *Cmd) {
|
||||||
argtable[arglen++] = arg_param_end;
|
argtable[arglen++] = arg_param_end;
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
bool uid_set = (uidlen == HF15_UID_LENGTH) ? true : false;
|
bool uid_set = (uidlen == ISO15693_UID_LENGTH) ? true : false;
|
||||||
|
|
||||||
bool unaddressed = arg_get_lit(ctx, 2);
|
bool unaddressed = arg_get_lit(ctx, 2);
|
||||||
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
||||||
|
@ -2589,7 +2578,7 @@ static int CmdHF15Write(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
@ -2632,7 +2621,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||||
argtable[arglen++] = arg_param_end;
|
argtable[arglen++] = arg_param_end;
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
|
|
||||||
|
@ -2662,7 +2651,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||||
|
|
||||||
// default fallback to scan for tag.
|
// default fallback to scan for tag.
|
||||||
// overriding unaddress parameter :)
|
// overriding unaddress parameter :)
|
||||||
if (uidlen != HF15_UID_LENGTH) {
|
if (uidlen != ISO15693_UID_LENGTH) {
|
||||||
scan = true;
|
scan = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2674,7 +2663,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
@ -2809,7 +2798,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
|
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
|
@ -2817,7 +2806,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
bool use_v2 = arg_get_lit(ctx, 2);
|
bool use_v2 = arg_get_lit(ctx, 2);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (uidlen != HF15_UID_LENGTH) {
|
if (uidlen != ISO15693_UID_LENGTH) {
|
||||||
PrintAndLogEx(WARNING, "UID must include 8 hex bytes, got " _RED_("%i"), uidlen);
|
PrintAndLogEx(WARNING, "UID must include 8 hex bytes, got " _RED_("%i"), uidlen);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -2831,7 +2820,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Get current tag");
|
PrintAndLogEx(INFO, "Get current tag");
|
||||||
|
|
||||||
uint8_t carduid[HF15_UID_LENGTH] = {0x00};
|
uint8_t carduid[ISO15693_UID_LENGTH] = {0x00};
|
||||||
if (getUID(true, false, carduid) != PM3_SUCCESS) {
|
if (getUID(true, false, carduid) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(FAILED, "no tag found");
|
PrintAndLogEx(FAILED, "no tag found");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -2861,10 +2850,10 @@ static int CmdHF15CSetUID(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse cardUID to compare
|
// reverse cardUID to compare
|
||||||
uint8_t revuid[HF15_UID_LENGTH] = {0};
|
uint8_t revuid[ISO15693_UID_LENGTH] = {0};
|
||||||
reverse_array_copy(carduid, sizeof(carduid), revuid);
|
reverse_array_copy(carduid, sizeof(carduid), revuid);
|
||||||
|
|
||||||
if (memcmp(revuid, payload.uid, HF15_UID_LENGTH) == 0) {
|
if (memcmp(revuid, payload.uid, ISO15693_UID_LENGTH) == 0) {
|
||||||
PrintAndLogEx(SUCCESS, "Setting new UID ( " _GREEN_("ok") " )");
|
PrintAndLogEx(SUCCESS, "Setting new UID ( " _GREEN_("ok") " )");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
return PM3_SUCCESS;;
|
return PM3_SUCCESS;;
|
||||||
|
@ -3503,10 +3492,10 @@ static int CmdHF15Wipe(const char *Cmd) {
|
||||||
argtable[arglen++] = arg_param_end;
|
argtable[arglen++] = arg_param_end;
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
uint8_t uid[HF15_UID_LENGTH];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
int uidlen = 0;
|
int uidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
CLIGetHexWithReturn(ctx, 1, uid, &uidlen);
|
||||||
bool uid_set = (uidlen == HF15_UID_LENGTH) ? true : false;
|
bool uid_set = (uidlen == ISO15693_UID_LENGTH) ? true : false;
|
||||||
|
|
||||||
bool unaddressed = arg_get_lit(ctx, 2);
|
bool unaddressed = arg_get_lit(ctx, 2);
|
||||||
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
bool scan = (arg_get_lit(ctx, 3) || (!uid_set && !unaddressed)) ? true : false; // Default fallback to scan for tag. Overriding unaddressed parameter.
|
||||||
|
@ -3538,7 +3527,7 @@ static int CmdHF15Wipe(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reverse_array(uid, HF15_UID_LENGTH);
|
reverse_array(uid, ISO15693_UID_LENGTH);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(INFO, "Using unaddressed mode");
|
PrintAndLogEx(INFO, "Using unaddressed mode");
|
||||||
|
|
|
@ -20,9 +20,24 @@
|
||||||
#define CMDHF15_H__
|
#define CMDHF15_H__
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "crc16.h"
|
||||||
|
#include "iso15.h" // typedef structs / enum
|
||||||
|
|
||||||
|
#ifndef Crc15
|
||||||
|
# define Crc15(data, len) Crc16ex(CRC_15693, (data), (len))
|
||||||
|
#endif
|
||||||
|
#ifndef CheckCrc15
|
||||||
|
# define CheckCrc15(data, len) check_crc(CRC_15693, (data), (len))
|
||||||
|
#endif
|
||||||
|
#ifndef AddCrc15
|
||||||
|
#define AddCrc15(data, len) compute_crc(CRC_15693, (data), (len), (data)+(len), (data)+(len)+1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ISO15_RAW_LEN
|
||||||
|
#define ISO15_RAW_LEN(x) (sizeof(iso15_raw_cmd_t) + (x))
|
||||||
|
#endif
|
||||||
|
|
||||||
int CmdHF15(const char *Cmd);
|
int CmdHF15(const char *Cmd);
|
||||||
|
|
||||||
bool readHF15Uid(bool loop, bool verbose);
|
bool readHF15Uid(bool loop, bool verbose);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5071,7 +5071,7 @@ static int CmdHFiClassUnhash(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count_lsb0 != 4 || count_lsb1 != 4){
|
if (count_lsb0 != 4 || count_lsb1 != 4) {
|
||||||
PrintAndLogEx(INFO, _RED_("Incorrect LSB Distribution, unable to unhash - the key might be AES based."));
|
PrintAndLogEx(INFO, _RED_("Incorrect LSB Distribution, unable to unhash - the key might be AES based."));
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -949,10 +949,13 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, const char *file
|
||||||
}
|
}
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (ret != PM3_SUCCESS)
|
if (ret != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, "The flashing procedure failed, follow the suggested steps!");
|
PrintAndLogEx(WARNING, "The flashing procedure failed, follow the suggested steps!");
|
||||||
|
}
|
||||||
|
|
||||||
ret = flash_stop_flashing();
|
ret = flash_stop_flashing();
|
||||||
CloseProxmark(g_session.current_device);
|
CloseProxmark(g_session.current_device);
|
||||||
|
|
||||||
finish2:
|
finish2:
|
||||||
for (int i = 0 ; i < num_files; ++i) {
|
for (int i = 0 ; i < num_files; ++i) {
|
||||||
flash_free(&files[i]);
|
flash_free(&files[i]);
|
||||||
|
@ -1001,7 +1004,6 @@ void pm3_init(void) {
|
||||||
// set global variables soon enough to get the log path
|
// set global variables soon enough to get the log path
|
||||||
set_my_executable_path();
|
set_my_executable_path();
|
||||||
set_my_user_directory();
|
set_my_user_directory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LIBPM3
|
#ifndef LIBPM3
|
||||||
|
|
|
@ -20,10 +20,14 @@
|
||||||
#define _ISO15_H_
|
#define _ISO15_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#define ISO15693_UID_LENGTH 8
|
||||||
|
#define ISO15693_ATQB_LENGTH 7
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t uid[8];
|
uint8_t uid[ISO15693_UID_LENGTH];
|
||||||
uint8_t uidlen;
|
uint8_t uidlen;
|
||||||
uint8_t atqb[7];
|
uint8_t atqb[ISO15693_ATQB_LENGTH];
|
||||||
uint8_t chipid;
|
uint8_t chipid;
|
||||||
uint8_t cid;
|
uint8_t cid;
|
||||||
} PACKED iso15_card_select_t;
|
} PACKED iso15_card_select_t;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue