make style
This commit is contained in:
31 files changed
+369
-329
No files matched your search
@@ -946,7 +946,7 @@ static int StCheckSig(uint8_t *uid) {
|
||||
uint8_t signature[16];
|
||||
size_t signature_len = 0;
|
||||
hexstr_to_byte_array(signature_hex, signature, &signature_len);
|
||||
|
||||
|
||||
uint8_t uid_swap[ISO15693_UID_LENGTH];
|
||||
reverse_array_copy(uid, ISO15693_UID_LENGTH, uid_swap);
|
||||
|
||||
|
||||
+61
-61
@@ -180,12 +180,12 @@ typedef struct {
|
||||
|
||||
typedef int (*felica_node_discovery_visitor_t)(const felica_discovered_node_t *node, void *ctx);
|
||||
typedef bool (*felica_node_discovery_runner_t)(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
|
||||
typedef struct {
|
||||
felica_node_discovery_method_t method;
|
||||
@@ -221,29 +221,29 @@ typedef enum {
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static void clear_and_send_command(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose);
|
||||
static int send_felica_payload_with_retries(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose,
|
||||
int expected_response_cmd, uint32_t timeout_ms, uint32_t retries, uint32_t backoff_ms, bool logging,
|
||||
PacketResponseNG *resp, const char *request_name);
|
||||
int expected_response_cmd, uint32_t timeout_ms, uint32_t retries, uint32_t backoff_ms, bool logging,
|
||||
PacketResponseNG *resp, const char *request_name);
|
||||
static bool felica_discover_nodes_with_request_code_list(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
static bool felica_discover_nodes_with_search_service_code(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
static bool felica_discover_nodes_with_request_service(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status);
|
||||
static bool felica_discover_nodes_with_read_without_encryption(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
@@ -956,7 +956,7 @@ static int CmdHFFelicaReader(const char *Cmd) {
|
||||
if (cm) {
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||
}
|
||||
|
||||
|
||||
return read_felica_uid(cm, verbose);
|
||||
}
|
||||
|
||||
@@ -1461,8 +1461,8 @@ static void print_read_without_encryption_response(felica_read_without_encryptio
|
||||
* @return PM3_SUCCESS on success
|
||||
*/
|
||||
static int send_felica_payload_with_retries(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose,
|
||||
int expected_response_cmd, uint32_t timeout_ms, uint32_t retries, uint32_t backoff_ms, bool logging,
|
||||
PacketResponseNG *resp, const char *request_name) {
|
||||
int expected_response_cmd, uint32_t timeout_ms, uint32_t retries, uint32_t backoff_ms, bool logging,
|
||||
PacketResponseNG *resp, const char *request_name) {
|
||||
for (uint32_t attempt = 0; attempt <= retries; attempt++) {
|
||||
if (attempt > 0) {
|
||||
if (logging) {
|
||||
@@ -1526,10 +1526,10 @@ int send_request_service(uint8_t flags, uint16_t datalen, uint8_t *data, bool ve
|
||||
}
|
||||
PacketResponseNG resp;
|
||||
if (send_felica_payload_with_retries(flags, datalen, data, verbose,
|
||||
0x03,
|
||||
FELICA_DEFAULT_TIMEOUT_MS, 0,
|
||||
0, true,
|
||||
&resp, "request service") != PM3_SUCCESS) {
|
||||
0x03,
|
||||
FELICA_DEFAULT_TIMEOUT_MS, 0,
|
||||
0, true,
|
||||
&resp, "request service") != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "\nGot no response from card");
|
||||
return PM3_ERFTRANS;
|
||||
}
|
||||
@@ -1882,12 +1882,12 @@ static void felica_print_node_discovery_method_used(felica_node_discovery_method
|
||||
}
|
||||
|
||||
static bool felica_discover_nodes_with_request_code_list(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
|
||||
uint8_t data[14] = {0};
|
||||
data[0] = sizeof(data);
|
||||
@@ -2000,12 +2000,12 @@ static bool felica_discover_nodes_with_request_code_list(uint8_t *flags,
|
||||
}
|
||||
|
||||
static bool felica_discover_nodes_with_search_service_code(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
|
||||
uint8_t data[12] = {0};
|
||||
data[0] = sizeof(data);
|
||||
@@ -2069,16 +2069,16 @@ static bool felica_discover_nodes_with_search_service_code(uint8_t *flags,
|
||||
}
|
||||
|
||||
static bool felica_request_service_send_probe_batch(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
const uint16_t *node_codes_le,
|
||||
const bool *is_area_nodes,
|
||||
size_t node_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
bool *supported,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
const uint16_t *node_codes_le,
|
||||
const bool *is_area_nodes,
|
||||
size_t node_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
bool *supported,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
if (node_count == 0 || node_count > FELICA_REQUEST_SERVICE_DISCOVERY_BATCH_SIZE) {
|
||||
return false;
|
||||
}
|
||||
@@ -2149,12 +2149,12 @@ static bool felica_request_service_send_probe_batch(uint8_t *flags,
|
||||
}
|
||||
|
||||
static bool felica_discover_nodes_with_request_service(uint8_t *flags,
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
const uint8_t *idm,
|
||||
uint32_t retry_count,
|
||||
felica_node_discovery_visitor_t visitor,
|
||||
void *ctx,
|
||||
uint32_t *discovered_count,
|
||||
int *stop_status) {
|
||||
bool supported = false;
|
||||
uint32_t local_count = 0;
|
||||
|
||||
|
||||
@@ -875,7 +875,7 @@ static int hfgal_read_desfire_card(uint32_t aid, uint8_t *site_key, bool verbose
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
current_aid,
|
||||
'A' + creds.region_code,
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
@@ -1699,7 +1699,7 @@ static int CmdGallagherDecode(const char *cmd) {
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds.region_code,
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
|
||||
@@ -1615,7 +1615,8 @@ static int gst_selftest_zlib(void) {
|
||||
};
|
||||
static const uint8_t loyalty_object_id[] = {0x04, 0x21, 0xC9, 0x4A, 0x51, 0x01, 0xE2, 0x5E, 0xAA};
|
||||
static const uint8_t customer_id[] = {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static const size_t sample_decompressed_len = 1312;
|
||||
static const size_t service_value_record_1_len = 1224;
|
||||
static const size_t loyalty_record_len = 1206;
|
||||
|
||||
+100
-71
@@ -1374,7 +1374,10 @@ static int CmdHFiClassTagSim(const char *Cmd) {
|
||||
dump[1] = (uint8_t)((fc >> 4) ^ (cn & 0xFF) ^ 0x5C);
|
||||
dump[2] = (uint8_t)((cn >> 16) ^ fc ^ 0x7F);
|
||||
dump[3] = (uint8_t)((cn >> 8) ^ (fc << 3) ^ 0xE9);
|
||||
dump[4] = 0xF7; dump[5] = 0xFF; dump[6] = 0x12; dump[7] = 0xE0;
|
||||
dump[4] = 0xF7;
|
||||
dump[5] = 0xFF;
|
||||
dump[6] = 0x12;
|
||||
dump[7] = 0xE0;
|
||||
}
|
||||
memcpy(csn, dump, 8);
|
||||
|
||||
@@ -1527,12 +1530,23 @@ static int CmdHFiClassTagSim(const char *Cmd) {
|
||||
if (k == TAGSIM_KEY_NONE) { continue; }
|
||||
|
||||
switch (k) {
|
||||
case TAGSIM_KEY_FC_INC: card.FacilityCode++; break;
|
||||
case TAGSIM_KEY_FC_DEC: card.FacilityCode--; break;
|
||||
case TAGSIM_KEY_CN_INC: card.CardNumber++; break;
|
||||
case TAGSIM_KEY_CN_DEC: card.CardNumber--; break;
|
||||
case TAGSIM_KEY_ABORT: running = false; break;
|
||||
case TAGSIM_KEY_NONE: break;
|
||||
case TAGSIM_KEY_FC_INC:
|
||||
card.FacilityCode++;
|
||||
break;
|
||||
case TAGSIM_KEY_FC_DEC:
|
||||
card.FacilityCode--;
|
||||
break;
|
||||
case TAGSIM_KEY_CN_INC:
|
||||
card.CardNumber++;
|
||||
break;
|
||||
case TAGSIM_KEY_CN_DEC:
|
||||
card.CardNumber--;
|
||||
break;
|
||||
case TAGSIM_KEY_ABORT:
|
||||
running = false;
|
||||
break;
|
||||
case TAGSIM_KEY_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
// Rebuild CSN deterministically from new FC/CN
|
||||
@@ -1543,7 +1557,10 @@ static int CmdHFiClassTagSim(const char *Cmd) {
|
||||
csn[1] = (uint8_t)((fc >> 4) ^ (cn & 0xFF) ^ 0x5C);
|
||||
csn[2] = (uint8_t)((cn >> 16) ^ fc ^ 0x7F);
|
||||
csn[3] = (uint8_t)((cn >> 8) ^ (fc << 3) ^ 0xE9);
|
||||
csn[4] = 0xF7; csn[5] = 0xFF; csn[6] = 0x12; csn[7] = 0xE0;
|
||||
csn[4] = 0xF7;
|
||||
csn[5] = 0xFF;
|
||||
csn[6] = 0x12;
|
||||
csn[7] = 0xE0;
|
||||
}
|
||||
|
||||
// New diversified KD/KC for the new CSN
|
||||
@@ -3841,7 +3858,7 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Using Key... " _GREEN_("%s"), sprint_hex_inrow(key, sizeof(key)));
|
||||
PrintAndLogEx(SUCCESS, "Using Key... " _GREEN_("%s"), sprint_hex_inrow(key, sizeof(key)));
|
||||
}
|
||||
|
||||
if (data_len && data_len != 8) {
|
||||
@@ -3906,7 +3923,7 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
|
||||
if (shallow_mod) {
|
||||
payload_rdr.flags |= FLAG_ICLASS_READER_SHALLOW_MOD;
|
||||
}
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_HF_ICLASS_READER, (uint8_t *)&payload_rdr, sizeof(iclass_card_select_t));
|
||||
@@ -4308,28 +4325,28 @@ out:
|
||||
|
||||
static void iclass_read_interesting_data(uint8_t *key, uint8_t keyType, bool elite, bool rawkey, bool use_replay,
|
||||
bool verbose, bool shallow_mod) {
|
||||
bool auth = false;
|
||||
uint8_t blockno = 3;
|
||||
uint8_t kd_read[8] = {0};
|
||||
iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, shallow_mod, kd_read, false, false);
|
||||
bool auth = false;
|
||||
uint8_t blockno = 3;
|
||||
uint8_t kd_read[8] = {0};
|
||||
iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, shallow_mod, kd_read, false, false);
|
||||
|
||||
blockno = 4;
|
||||
uint8_t kc_read[8] = {0};
|
||||
iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, shallow_mod, kc_read, false, false);
|
||||
blockno = 4;
|
||||
uint8_t kc_read[8] = {0};
|
||||
iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, auth, shallow_mod, kc_read, false, false);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Raw Debit Key.............. " _YELLOW_("%s"), sprint_hex_inrow(kd_read, sizeof(kd_read)));
|
||||
PrintAndLogEx(SUCCESS, "Raw Credit Key............. " _YELLOW_("%s"), sprint_hex_inrow(kc_read, sizeof(kc_read)));
|
||||
PrintAndLogEx(SUCCESS, "Raw Debit Key.............. " _YELLOW_("%s"), sprint_hex_inrow(kd_read, sizeof(kd_read)));
|
||||
PrintAndLogEx(SUCCESS, "Raw Credit Key............. " _YELLOW_("%s"), sprint_hex_inrow(kc_read, sizeof(kc_read)));
|
||||
|
||||
// read dump data here and print (SIO , wiegand)
|
||||
uint16_t n = 0;
|
||||
uint8_t d[0x100 * PICOPASS_BLOCK_SIZE] = {0};
|
||||
iclass_dump_non_secure(shallow_mod, d, &n);
|
||||
// read dump data here and print (SIO , wiegand)
|
||||
uint16_t n = 0;
|
||||
uint8_t d[0x100 * PICOPASS_BLOCK_SIZE] = {0};
|
||||
iclass_dump_non_secure(shallow_mod, d, &n);
|
||||
|
||||
DropField();
|
||||
DropField();
|
||||
|
||||
iclass_decode_credentials(d);
|
||||
iclass_decode_credentials(d);
|
||||
|
||||
// We should send it to SAM if we detect one installed, and get the FC/CN out
|
||||
// We should send it to SAM if we detect one installed, and get the FC/CN out
|
||||
}
|
||||
|
||||
static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
@@ -4441,7 +4458,7 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
keyType = ICLASS_CREDIT_KEYTYPE;
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "Using " _YELLOW_("debit") " key");
|
||||
}
|
||||
}
|
||||
|
||||
if (tearoff_loop > 1) {
|
||||
PrintAndLogEx(SUCCESS, _YELLOW_("%u") " attempts / tearoff", tearoff_loop);
|
||||
@@ -4507,13 +4524,13 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
#define TEAR_NON_SECURE_MODE 0x2C
|
||||
#define TEAR_INITAL 0x3C
|
||||
#define TEAR_PERSO 0xAC
|
||||
#define TEAR_NON_SECURE_MODE 0x2C
|
||||
#define TEAR_INITAL 0x3C
|
||||
#define TEAR_PERSO 0xAC
|
||||
|
||||
#define TEAR_IS_PERSO_SET(x) (((x) & 0x80) == 0x80)
|
||||
#define TEAR_IS_NONSECURE_SET(x) ((((x) & 0x18) >> 3) == PICOPASS_NON_SECURE_PAGEMODE)
|
||||
#define TEAR_BAD(x) (((x) & 0x01) == 0)
|
||||
#define TEAR_IS_PERSO_SET(x) (((x) & 0x80) == 0x80)
|
||||
#define TEAR_IS_NONSECURE_SET(x) ((((x) & 0x18) >> 3) == PICOPASS_NON_SECURE_PAGEMODE)
|
||||
#define TEAR_BAD(x) (((x) & 0x01) == 0)
|
||||
|
||||
// perform initial read here, repeat if failed or 00s
|
||||
|
||||
@@ -4615,7 +4632,7 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
}
|
||||
|
||||
// skip authentication for config block
|
||||
read_auth = false;
|
||||
read_auth = false;
|
||||
|
||||
res = iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, read_auth, shallow_mod, data_read, false, false);
|
||||
if (res == PM3_SUCCESS && !reread) {
|
||||
@@ -4744,7 +4761,7 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
isok = PM3_SUCCESS;
|
||||
goto_out = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (goto_out) {
|
||||
goto out;
|
||||
@@ -4758,9 +4775,9 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Read: " _GREEN_("%s") " %s"
|
||||
, sprint_hex_inrow(data_read, sizeof(data_read)),
|
||||
(expected_values) ? _GREEN_(" -> Expected values!") : ""
|
||||
);
|
||||
, sprint_hex_inrow(data_read, sizeof(data_read)),
|
||||
(expected_values) ? _GREEN_(" -> Expected values!") : ""
|
||||
);
|
||||
}
|
||||
|
||||
loop_count++;
|
||||
@@ -4797,9 +4814,9 @@ out:
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
clearCommandBuffer();
|
||||
|
||||
read_auth = false;
|
||||
uint8_t data_read[8]= {0};
|
||||
|
||||
read_auth = false;
|
||||
uint8_t data_read[8] = {0};
|
||||
|
||||
int res = iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, read_auth, shallow_mod, data_read, false, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
return res;
|
||||
@@ -4807,35 +4824,35 @@ out:
|
||||
|
||||
uint8_t b7 = data_read[7];
|
||||
|
||||
if ( b7 == TEAR_INITAL) {
|
||||
PrintAndLogEx(INFO, _YELLOW_("Fuses unchanged. Try again if the OTP is unchanged"));
|
||||
// check for OTP change?
|
||||
if (b7 == TEAR_INITAL) {
|
||||
PrintAndLogEx(INFO, _YELLOW_("Fuses unchanged. Try again if the OTP is unchanged"));
|
||||
// check for OTP change?
|
||||
} else if (TEAR_IS_NONSECURE_SET(b7)) {
|
||||
// don't do anything as this is ok
|
||||
PrintAndLogEx(SUCCESS, "Detected fuse: " _GREEN_("0x%02X")" _non secure memory_ ( %s )", data_read[7], _GREEN_("ok"));
|
||||
// don't do anything as this is ok
|
||||
PrintAndLogEx(SUCCESS, "Detected fuse: " _GREEN_("0x%02X")" _non secure memory_ ( %s )", data_read[7], _GREEN_("ok"));
|
||||
|
||||
iclass_read_interesting_data(key, keyType, elite, rawkey, use_replay, verbose, shallow_mod);
|
||||
iclass_read_interesting_data(key, keyType, elite, rawkey, use_replay, verbose, shallow_mod);
|
||||
} else if (TEAR_IS_PERSO_SET(b7)) {
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Detected fuse: " _GREEN_("0x%02X") " set non-secure memory: " _YELLOW_("0xAC"), data_read[7]);
|
||||
PrintAndLogEx(SUCCESS, "Detected fuse: " _GREEN_("0x%02X") " set non-secure memory: " _YELLOW_("0xAC"), data_read[7]);
|
||||
|
||||
memcpy(data, data_read, PICOPASS_BLOCK_SIZE);
|
||||
data[7] = TEAR_NON_SECURE_MODE;
|
||||
memcpy(data, data_read, PICOPASS_BLOCK_SIZE);
|
||||
data[7] = TEAR_NON_SECURE_MODE;
|
||||
|
||||
// set non-secure memory with 0xAC, in this state it will always succeed
|
||||
if(do_not_stabilize) {
|
||||
PrintAndLogEx(INFO, "Not stabilizing the bits...");
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Stabilizing the bits...");
|
||||
iclass_write_block(blockno, data, mac, key, use_credit_key, elite, rawkey, use_replay, false, auth, shallow_mod);
|
||||
}
|
||||
// set non-secure memory with 0xAC, in this state it will always succeed
|
||||
if (do_not_stabilize) {
|
||||
PrintAndLogEx(INFO, "Not stabilizing the bits...");
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Stabilizing the bits...");
|
||||
iclass_write_block(blockno, data, mac, key, use_credit_key, elite, rawkey, use_replay, false, auth, shallow_mod);
|
||||
}
|
||||
|
||||
iclass_read_interesting_data(key, keyType, elite, rawkey, use_replay, verbose, shallow_mod);
|
||||
iclass_read_interesting_data(key, keyType, elite, rawkey, use_replay, verbose, shallow_mod);
|
||||
} else if (TEAR_BAD(b7)) {
|
||||
PrintAndLogEx(WARNING, "Bad fuse state detected: " _RED_("0x%02X") ", cannot proceed", b7);
|
||||
return PM3_EFAILED;
|
||||
} else {
|
||||
PrintAndLogEx(INFO, _YELLOW_("Did not detect " _YELLOW_("0xBC") " or " _YELLOW_("0xBE") " or " _YELLOW_("0x9C") " fuse, might need manual intervention!"));
|
||||
PrintAndLogEx(INFO, _YELLOW_("Did not detect " _YELLOW_("0xBC") " or " _YELLOW_("0xBE") " or " _YELLOW_("0x9C") " fuse, might need manual intervention!"));
|
||||
}
|
||||
|
||||
return isok;
|
||||
@@ -5011,18 +5028,30 @@ static void print_iclass_sio_decoded(uint8_t *sio, size_t sio_len) {
|
||||
} else if (itag == 0x81 && ilen == 1) {
|
||||
const char *ktype;
|
||||
switch (ival[0]) {
|
||||
case 0x00: ktype = "Elite keyed"; break;
|
||||
case 0x01: ktype = "Standard keyed"; break;
|
||||
default: ktype = "Custom keyed"; break;
|
||||
case 0x00:
|
||||
ktype = "Elite keyed";
|
||||
break;
|
||||
case 0x01:
|
||||
ktype = "Standard keyed";
|
||||
break;
|
||||
default:
|
||||
ktype = "Custom keyed";
|
||||
break;
|
||||
}
|
||||
PrintAndLogEx(INFO, " Key Reference ID : " _YELLOW_("0x%02X") " ( %s )", ival[0], ktype);
|
||||
} else if (itag == 0x04 && ilen >= 1) {
|
||||
uint8_t ctype = ival[ilen - 1];
|
||||
const char *cname;
|
||||
switch (ctype) {
|
||||
case 0x08: cname = "EAX"; break;
|
||||
case 0x09: cname = "EAX'"; break;
|
||||
default: cname = "Unknown"; break;
|
||||
case 0x08:
|
||||
cname = "EAX";
|
||||
break;
|
||||
case 0x09:
|
||||
cname = "EAX'";
|
||||
break;
|
||||
default:
|
||||
cname = "Unknown";
|
||||
break;
|
||||
}
|
||||
PrintAndLogEx(INFO, " Crypto Suite : " _YELLOW_("%s") " ( %s )", sprint_hex_inrow(ival, ilen), cname);
|
||||
}
|
||||
@@ -5979,7 +6008,7 @@ static int iclass_recover(uint8_t key[8], uint32_t index_start, uint32_t loop, u
|
||||
while (repeat == true) {
|
||||
|
||||
uint32_t payload_size = sizeof(iclass_recover_req_t);
|
||||
|
||||
|
||||
iclass_recover_req_t *payload = calloc(1, payload_size);
|
||||
if (payload == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
@@ -6227,8 +6256,8 @@ static int CmdHFiClassLegBrute_MT(uint8_t epurse[8], uint8_t macs[8], uint8_t ma
|
||||
memcpy(args[i].startingKey, startingKey, 8);
|
||||
args[i].index_start = index + (uint64_t)i * slice;
|
||||
args[i].index_end = (i == thread_count - 1)
|
||||
? index + keyspace // last thread absorbs remainder
|
||||
: index + (uint64_t)(i + 1) * slice;
|
||||
? index + keyspace // last thread absorbs remainder
|
||||
: index + (uint64_t)(i + 1) * slice;
|
||||
memcpy(args[i].CCNR1, CCNR, 12);
|
||||
memcpy(args[i].MAC_TAG1, MAC_TAG, 4);
|
||||
memcpy(args[i].CCNR2, CCNR2, 12);
|
||||
@@ -7185,14 +7214,14 @@ static void generate(uint8_t *data, uint8_t len) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *pkey = calloc(len, sizeof(uint8_t));
|
||||
if (pkey == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
free(key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "input key...... %s", sprint_hex_inrow(data, len));
|
||||
permute(data, len, pkey);
|
||||
PrintAndLogEx(SUCCESS, "permuted key... %s", sprint_hex_inrow(pkey, len));
|
||||
@@ -8022,7 +8051,7 @@ int info_iclass(bool shallow_mod) {
|
||||
bool found_aa2 = false;
|
||||
uint8_t aa1_idx = 0;
|
||||
uint8_t key[PICOPASS_KEY_SIZE] = {0};
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < ARRAYLEN(iClass_Key_Table); i++) {
|
||||
|
||||
memcpy(key, iClass_Key_Table[i], sizeof(key));
|
||||
|
||||
@@ -873,12 +873,12 @@ static int mf_analyse_st_block(uint8_t blockno, uint8_t *block, bool force) {
|
||||
uint8_t bar = 4;
|
||||
for (uint8_t foo = 0; foo < bar; foo++) {
|
||||
if (mfReadOnlyAccessConditions(foo, &block[6])) {
|
||||
// WARNING: Sectors 33+ assume ACLs apply to groups of 4 blocks, not 1 block.
|
||||
// The code as-is is bugged and actually wastes iterations. If you have 16 blocks, it'll run all 16 but only error out like it's a 4-block sector.
|
||||
if (blockno<128)
|
||||
// WARNING: Sectors 33+ assume ACLs apply to groups of 4 blocks, not 1 block.
|
||||
// The code as-is is bugged and actually wastes iterations. If you have 16 blocks, it'll run all 16 but only error out like it's a 4-block sector.
|
||||
if (blockno < 128)
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on block " _YELLOW_("%u") " detected", blockno - bar + 1 + foo);
|
||||
else
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on blocks " _YELLOW_("%u-%u") " detected", blockno - bar*4 + 1 + foo*5, blockno - bar*4 + 1 + foo*5 + 4);
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on blocks " _YELLOW_("%u-%u") " detected", blockno - bar * 4 + 1 + foo * 5, blockno - bar * 4 + 1 + foo * 5 + 4);
|
||||
ro_detected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ static uint64_t num_keys_tested = 0;
|
||||
static statelist_t *candidates = NULL;
|
||||
|
||||
static int add_nonce(uint32_t nonce_enc, uint8_t par_enc) {
|
||||
|
||||
|
||||
uint8_t first_byte = nonce_enc >> 24;
|
||||
noncelistentry_t *p1 = nonces[first_byte].first;
|
||||
noncelistentry_t *p2 = NULL;
|
||||
@@ -912,10 +912,10 @@ static void update_allbitflips_array(void) {
|
||||
if (nonces[i].all_bitflips_dirty[odd_even]) {
|
||||
|
||||
uint32_t old_count = num_all_bitflips_bitarray[odd_even];
|
||||
|
||||
|
||||
num_all_bitflips_bitarray[odd_even] = count_bitarray_low20_AND(all_bitflips_bitarray[odd_even], nonces[i].states_bitarray[odd_even]);
|
||||
nonces[i].all_bitflips_dirty[odd_even] = false;
|
||||
|
||||
|
||||
if (num_all_bitflips_bitarray[odd_even] != old_count) {
|
||||
all_bitflips_bitarray_dirty[odd_even] = true;
|
||||
}
|
||||
@@ -1556,7 +1556,7 @@ static int simulate_acquire_nonces(void) {
|
||||
simulate_MFplus_RNG(cuid, known_target_key, &nt_enc, &par_enc);
|
||||
|
||||
int add_res = add_nonce(nt_enc, par_enc);
|
||||
if ( add_res == PM3_EMALLOC) {
|
||||
if (add_res == PM3_EMALLOC) {
|
||||
return add_res;
|
||||
}
|
||||
num_acquired_nonces += add_res;
|
||||
@@ -1701,7 +1701,7 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
|
||||
DropField();
|
||||
return add_res;
|
||||
}
|
||||
|
||||
|
||||
num_acquired_nonces += add_res;
|
||||
|
||||
// PrintAndLogEx(INFO, "Encrypted nonce: %08x, encrypted_parity: %02x\n", nt_enc2, par_enc & 0x0f);
|
||||
|
||||
@@ -1199,12 +1199,12 @@ static int mfp_analyse_st_block(uint8_t blockno, uint8_t *block, bool force) {
|
||||
uint8_t bar = 4;
|
||||
for (uint8_t foo = 0; foo < bar; foo++) {
|
||||
if (mfReadOnlyAccessConditions(foo, &block[6])) {
|
||||
// WARNING: Sectors 33+ assume ACLs apply to groups of 4 blocks, not 1 block.
|
||||
// The code as-is is bugged and actually wastes iterations. If you have 16 blocks, it'll run all 16 but only error out like it's a 4-block sector.
|
||||
if (blockno<128)
|
||||
// WARNING: Sectors 33+ assume ACLs apply to groups of 4 blocks, not 1 block.
|
||||
// The code as-is is bugged and actually wastes iterations. If you have 16 blocks, it'll run all 16 but only error out like it's a 4-block sector.
|
||||
if (blockno < 128)
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on block " _YELLOW_("%u") " detected", blockno - bar + 1 + foo);
|
||||
else
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on blocks " _YELLOW_("%u-%u") " detected", blockno - bar*4 + 1 + foo*5, blockno - bar*4 + 1 + foo*5 + 4);
|
||||
PrintAndLogEx(WARNING, "Strict ReadOnly Access Conditions on blocks " _YELLOW_("%u-%u") " detected", blockno - bar * 4 + 1 + foo * 5, blockno - bar * 4 + 1 + foo * 5 + 4);
|
||||
ro_detected = true;
|
||||
}
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ static int CmdHFMFPWrbl(const char *Cmd) {
|
||||
int keylen = 0;
|
||||
CLIGetHexWithReturn(ctx, 7, key, &keylen);
|
||||
bool force = arg_get_lit(ctx, 8);
|
||||
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t keyn[2] = {0};
|
||||
|
||||
@@ -1752,13 +1752,13 @@ typedef struct {
|
||||
|
||||
static mfu_otp_identify_t mfu_otp_ident_table[] = {
|
||||
{ "SALTO Systems card", 12, 4, "534C544F", ul_c_otpgenA, "report to iceman!" },
|
||||
{ NULL, 0, 0, NULL , NULL, NULL} // must be the last item
|
||||
{ NULL, 0, 0, NULL, NULL, NULL} // must be the last item
|
||||
};
|
||||
|
||||
static mfu_otp_identify_t *mfu_match_otp_fingerprint(uint8_t *uid, uint8_t *data) {
|
||||
uint8_t i = 0;
|
||||
do {
|
||||
if ( mfu_otp_ident_table[i].desc == NULL) {
|
||||
if (mfu_otp_ident_table[i].desc == NULL) {
|
||||
break;
|
||||
}
|
||||
int ml = 0;
|
||||
|
||||
@@ -476,11 +476,11 @@ static int CmdHFHIDConfigSim(const char *Cmd) {
|
||||
strncpy(uid_str, sprint_hex_inrow(uid, uidlen), sizeof(uid_str) - 1);
|
||||
uid_str[sizeof(uid_str) - 1] = '\0';
|
||||
PrintAndLogEx(INFO, "HID Config Card sim:"
|
||||
" UID " _YELLOW_("%s")
|
||||
" AID " _YELLOW_("%s")
|
||||
" ATS len " _YELLOW_("%d")
|
||||
" APDU overrides " _YELLOW_("%u")
|
||||
" default resp " _YELLOW_("%s"),
|
||||
" UID " _YELLOW_("%s")
|
||||
" AID " _YELLOW_("%s")
|
||||
" ATS len " _YELLOW_("%d")
|
||||
" APDU overrides " _YELLOW_("%u")
|
||||
" default resp " _YELLOW_("%s"),
|
||||
uid_str, aid_str, ats_len, apdu_count,
|
||||
has_default_resp ? sprint_hex_inrow(default_resp, default_resp_len_sz) : "9000 (builtin)");
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " or " _GREEN_("<Enter>") " to abort simulation");
|
||||
|
||||
+15
-15
@@ -361,9 +361,9 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
|
||||
uint8_t responseCode[2] = {0};
|
||||
uint8_t mac[8] = {0};
|
||||
size_t cryptogram_length = 0;
|
||||
|
||||
|
||||
// Parse the response to extract the three tags
|
||||
for (int i = 0; i < resplen - 2; ) {
|
||||
for (int i = 0; i < resplen - 2;) {
|
||||
if (response[i] == 0x85) {
|
||||
// Cryptogram tag
|
||||
size_t offset = i + 1;
|
||||
@@ -384,7 +384,7 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
|
||||
i += 2 + response[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------- Cryptogram Response -------------------
|
||||
if (cryptogram_length > 0) {
|
||||
uint8_t decrypted[cryptogram_length];
|
||||
@@ -392,15 +392,15 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
|
||||
|
||||
// Decrypt the response
|
||||
decrypt_cryptogram(diversified_enc_key, cryptogram, decrypted, cryptogram_length, encryption_algorithm);
|
||||
|
||||
|
||||
//PrintAndLogEx(SUCCESS, "Cryptogram....................... " _YELLOW_("%s"), sprint_hex_inrow(cryptogram, cryptogram_length));
|
||||
//PrintAndLogEx(SUCCESS, "Decrypted........................ " _YELLOW_("%s"), sprint_hex_inrow(decrypted, cryptogram_length));
|
||||
|
||||
|
||||
// Parse TLV: tag can be 1 or 2 bytes
|
||||
int offset = 0;
|
||||
uint8_t tag[2] = {0x00, 0x00};
|
||||
int tag_len = 1;
|
||||
|
||||
|
||||
// Check if it's a 2-byte tag (first byte has bits 5-1 all set to 1)
|
||||
if ((decrypted[offset] & 0x1F) == 0x1F) {
|
||||
tag[0] = decrypted[offset];
|
||||
@@ -411,28 +411,28 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
|
||||
tag[0] = decrypted[offset];
|
||||
offset += 1;
|
||||
}
|
||||
|
||||
|
||||
// Get length byte
|
||||
uint8_t length_byte = decrypted[offset];
|
||||
offset += 1;
|
||||
|
||||
|
||||
// Extract the value
|
||||
getDataSize = length_byte;
|
||||
memcpy(sioOutput, decrypted + offset, getDataSize);
|
||||
*sio_size = getDataSize;
|
||||
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Tag.............................. " _YELLOW_("%s"), sprint_hex_inrow(tag, tag_len));
|
||||
PrintAndLogEx(SUCCESS, "Value............................ " _YELLOW_("%s"), sprint_hex_inrow(sioOutput, getDataSize));
|
||||
}
|
||||
|
||||
|
||||
if (responseCode[0] != 0x00 || responseCode[1] != 0x00) {
|
||||
PrintAndLogEx(SUCCESS, "Response Code.................... " _YELLOW_("%s"), sprint_hex_inrow(responseCode, ARRAYLEN(responseCode)));
|
||||
}
|
||||
|
||||
|
||||
// if (mac[0] != 0x00) {
|
||||
// PrintAndLogEx(SUCCESS, "MAC.............................. " _YELLOW_("%s"), sprint_hex_inrow(mac, sizeof(mac)));
|
||||
// }
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
};
|
||||
|
||||
@@ -874,9 +874,9 @@ static int select_df_decode(uint8_t *response, uint8_t response_length, int *ALG
|
||||
}
|
||||
|
||||
if (plaintext_adf == false) {
|
||||
if (plaintext_adf == false) {
|
||||
PrintAndLogEx(SUCCESS, "CRYPTOGRAM Encrypted Data........ " _YELLOW_("%s"), sprint_hex_inrow(CRYPTOGRAM_encrypted_data, 64));
|
||||
}
|
||||
if (plaintext_adf == false) {
|
||||
PrintAndLogEx(SUCCESS, "CRYPTOGRAM Encrypted Data........ " _YELLOW_("%s"), sprint_hex_inrow(CRYPTOGRAM_encrypted_data, 64));
|
||||
}
|
||||
}
|
||||
// PrintAndLogEx(SUCCESS, "MAC.............................. " _YELLOW_("%s"), sprint_hex_inrow(MAC_value, 8));
|
||||
|
||||
|
||||
@@ -632,8 +632,8 @@ typedef struct {
|
||||
} vas_reader_key_t;
|
||||
|
||||
static void VasReaderCleanup(vas_reader_key_t *keys, int keys_initialized,
|
||||
char **key_values, int key_count,
|
||||
char **pid_values, int pid_count) {
|
||||
char **key_values, int key_count,
|
||||
char **pid_values, int pid_count) {
|
||||
for (int i = 0; keys != NULL && i < keys_initialized; i++) {
|
||||
mbedtls_ecp_keypair_free(&keys[i].key);
|
||||
}
|
||||
@@ -758,9 +758,9 @@ static int VASGetData(const char *passIdentifier, const uint8_t *pidHash, bool h
|
||||
}
|
||||
|
||||
static int VASRead(bool has_pid, size_t request_count,
|
||||
char *const *pid_values, const char *url, int urllen,
|
||||
uint8_t vas_mode, bool verbose,
|
||||
vas_reader_key_t *keys, int key_count) {
|
||||
char *const *pid_values, const char *url, int urllen,
|
||||
uint8_t vas_mode, bool verbose,
|
||||
vas_reader_key_t *keys, int key_count) {
|
||||
uint16_t select_status = VAS_STATUS_NOT_AVAILABLE;
|
||||
if (VASSelectOse(&select_status, verbose) != PM3_SUCCESS) {
|
||||
PrintVASFailureReason(select_status, VAS_STATUS_NOT_AVAILABLE);
|
||||
@@ -975,12 +975,12 @@ static int CmdVASReader(const char *Cmd) {
|
||||
continue;
|
||||
}
|
||||
int iter_res = VASRead(has_pid, request_count, pid_values,
|
||||
url, urllen, vas_mode, verbose,
|
||||
keys, key_count);
|
||||
url, urllen, vas_mode, verbose,
|
||||
keys, key_count);
|
||||
if (iter_res != PM3_SUCCESS && final_res == PM3_SUCCESS) {
|
||||
final_res = iter_res;
|
||||
}
|
||||
|
||||
|
||||
if (continuous) {
|
||||
// Drop field so that iPhone displays the checkmark or a pass
|
||||
DropField();
|
||||
|
||||
+14
-14
@@ -1824,17 +1824,17 @@ static int lf_relay_rdr(const char *ip, uint16_t port) {
|
||||
int CmdLFRelay(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "lf relay",
|
||||
"Relay LF signal between two Proxmark3 devices over TCP.\n"
|
||||
"By default it uses PORT 8000 and uses 40000 samples from Graphbuffer\n"
|
||||
" --rdr : Reading device, act as IP client and reads LF tag and sends data\n"
|
||||
" --tag : Simulation device, act as IP server and simulates relayed data\n",
|
||||
_WHITE_("Device A, reading LF tag, client") "\n"
|
||||
"lf relay --rdr --ip 192.168.1.141 -> Client, connect to IP 192.168.1.141:8000\n"
|
||||
"lf relay --rdr --ip 192.168.1.141 -p 18111 -> Client, connect to IP 192.168.1.141:18111 \n\n"
|
||||
_WHITE_("Device B, simulate LF tag, server") "\n"
|
||||
"lf relay --tag -p 8111 -> Server listening port 8111, recv 40000 samples\n"
|
||||
"lf relay --tag -s 10000 -> Server listening port 8000, recv 10000 samples\n"
|
||||
);
|
||||
"Relay LF signal between two Proxmark3 devices over TCP.\n"
|
||||
"By default it uses PORT 8000 and uses 40000 samples from Graphbuffer\n"
|
||||
" --rdr : Reading device, act as IP client and reads LF tag and sends data\n"
|
||||
" --tag : Simulation device, act as IP server and simulates relayed data\n",
|
||||
_WHITE_("Device A, reading LF tag, client") "\n"
|
||||
"lf relay --rdr --ip 192.168.1.141 -> Client, connect to IP 192.168.1.141:8000\n"
|
||||
"lf relay --rdr --ip 192.168.1.141 -p 18111 -> Client, connect to IP 192.168.1.141:18111 \n\n"
|
||||
_WHITE_("Device B, simulate LF tag, server") "\n"
|
||||
"lf relay --tag -p 8111 -> Server listening port 8111, recv 40000 samples\n"
|
||||
"lf relay --tag -s 10000 -> Server listening port 8000, recv 10000 samples\n"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -1876,7 +1876,7 @@ int CmdLFRelay(const char *Cmd) {
|
||||
if (is_tag) {
|
||||
return lf_relay_tag(samples, port);
|
||||
}
|
||||
|
||||
|
||||
if (is_rdr) {
|
||||
return lf_relay_rdr(ip, port);
|
||||
}
|
||||
@@ -1986,13 +1986,13 @@ int CmdLFfind(const char *Cmd) {
|
||||
|
||||
// identify chipset
|
||||
bool lf_special_search = check_chiptype(is_online);
|
||||
if ( lf_special_search ) {
|
||||
if (lf_special_search) {
|
||||
found++;
|
||||
} else {
|
||||
PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed"));
|
||||
}
|
||||
|
||||
if ( found == 0) {
|
||||
if (found == 0) {
|
||||
PrintAndLogEx(HINT, "Hint: try `" _YELLOW_("hf search") "` - since tag might not be LF");
|
||||
}
|
||||
|
||||
|
||||
@@ -145,11 +145,11 @@ static int mqtt_receive(const char *addr, const char *port, const char *topic, c
|
||||
|
||||
char cid[20] = "pm3_";
|
||||
snprintf(cid + strlen(cid), sizeof(cid) - 4, "%02x%02x%02x%02x"
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
);
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
, rand() % 0xFF
|
||||
);
|
||||
|
||||
// Ensure we have a clean session
|
||||
uint8_t connect_flags = MQTT_CONNECT_CLEAN_SESSION;
|
||||
|
||||
+30
-15
@@ -181,13 +181,20 @@ void doMAC(uint8_t *cc_nr_p, uint8_t *div_key_p, uint8_t mac[4]) {
|
||||
static void suc_bytes(const uint8_t *k, State_t *s, const uint8_t *in, int length) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
uint8_t b = in[i];
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b); b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
b >>= 1;
|
||||
successor(k, s, b);
|
||||
}
|
||||
}
|
||||
@@ -197,14 +204,22 @@ static void suc_bytes(const uint8_t *k, State_t *s, const uint8_t *in, int lengt
|
||||
static void output_bytes(const uint8_t *k, State_t *s, uint8_t *out, int nbytes) {
|
||||
for (int i = 0; i < nbytes; i++) {
|
||||
uint8_t bout = 0;
|
||||
bout |= (s->r & 0x4) >> 2; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) >> 1; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4); successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 1; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 2; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 3; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 4; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 5; successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) >> 2;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) >> 1;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4);
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 1;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 2;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 3;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 4;
|
||||
successor(k, s, 0);
|
||||
bout |= (s->r & 0x4) << 5;
|
||||
successor(k, s, 0);
|
||||
out[i] = bout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ void print_gallagher_creds(GallagherCredentials_t *creds) {
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds->region_code,
|
||||
'A' + creds->region_code,
|
||||
creds->region_code,
|
||||
creds->facility_code,
|
||||
creds->card_number,
|
||||
|
||||
+1
-1
@@ -683,7 +683,7 @@ int parse_uint32_hex_or_dec(const char *text, uint32_t *out) {
|
||||
base = 16;
|
||||
} else {
|
||||
for (const char *p = text; *p; p++) {
|
||||
if (isalpha((unsigned char)*p)) {
|
||||
if (isalpha((unsigned char) * p)) {
|
||||
base = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user