mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-10-23 21:44:50 +00:00
1 parent
8ad242ad74
commit
9f0171a706
14 files changed
+2242
-42
No files matched your search
@@ -90,7 +90,7 @@ static int CmdConfigFpga(const char *Cmd) {
|
||||
// Start to send data in chunks
|
||||
size_t offset = 0;
|
||||
while (offset < datalen) {
|
||||
size_t chunk_size = (datalen - offset) > PM3_CMD_DATA_SIZE ? PM3_CMD_DATA_SIZE : (datalen - offset);
|
||||
size_t chunk_size = (datalen - offset) > pm3_max_cmd_data_size() ? pm3_max_cmd_data_size() : (datalen - offset);
|
||||
SendCommandNG(CMD_FPGA_BITSTREAM_CONFIG_WRITE, data + offset, chunk_size);
|
||||
// Wait for response before sending next chunk
|
||||
if (WaitForResponseTimeout(CMD_FPGA_BITSTREAM_CONFIG_WRITE, &resp, 5000) == false) {
|
||||
|
||||
@@ -301,7 +301,7 @@ int hf14a_getversion_data(iso14a_card_select_t *card, uint64_t select_status, ve
|
||||
void SendIso14aReaderEx(uint32_t flags, const uint8_t *data, uint16_t datalen, uint16_t len,
|
||||
uint16_t lenbits, uint32_t timeout, uint32_t wait_us) {
|
||||
|
||||
if (datalen > (PM3_CMD_DATA_SIZE - sizeof(iso14a_raw_cmd_t))) {
|
||||
if (datalen > (pm3_max_cmd_data_size() - sizeof(iso14a_raw_cmd_t))) {
|
||||
PrintAndLogEx(WARNING, "Sending " _RED_("%u") " bytes of payload is too much, abort", datalen);
|
||||
return;
|
||||
}
|
||||
@@ -1235,7 +1235,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = { 0x0a | gs_frames_num, 0x00 };
|
||||
gs_frames_num ^= 1;
|
||||
|
||||
int min = MIN((PM3_CMD_DATA_SIZE - 2), (datainlen & 0x1FF));
|
||||
int min = MIN((int)(pm3_max_cmd_data_size() - 2), (datainlen & 0x1FF));
|
||||
memcpy(&data[2], datain, min);
|
||||
SendIso14aReader(ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, data, min + 2);
|
||||
|
||||
@@ -1541,7 +1541,7 @@ int ExchangeAPDU14a(const uint8_t *datain, int datainlen, bool activateField, bo
|
||||
|
||||
// 3 byte here - 1b framing header, 2b crc16
|
||||
if (g_apdu_in_framing_enable &&
|
||||
((gs_frame_len && (datainlen > gs_frame_len - 3)) || (datainlen > PM3_CMD_DATA_SIZE - 3))) {
|
||||
((gs_frame_len && (datainlen > gs_frame_len - 3)) || (datainlen > pm3_max_cmd_data_size() - 3))) {
|
||||
|
||||
int clen = 0;
|
||||
|
||||
|
||||
@@ -1269,7 +1269,7 @@ static int CmdHF14BRaw(const char *Cmd) {
|
||||
}
|
||||
|
||||
// Max buffer is PM3_CMD_DATA_SIZE
|
||||
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||
datalen = (datalen > pm3_max_cmd_data_size()) ? pm3_max_cmd_data_size() : datalen;
|
||||
|
||||
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + datalen);
|
||||
if (packet == NULL) {
|
||||
@@ -2935,7 +2935,7 @@ int exchange_14b_apdu(uint8_t *datain, int datainlen, bool activate_field,
|
||||
|
||||
// 3 byte here - 1b framing header, 2b crc16
|
||||
if (apdu_in_framing_enable &&
|
||||
((apdu_frame_length && (datainlen > apdu_frame_length - 3)) || (datainlen > PM3_CMD_DATA_SIZE - 3))) {
|
||||
((apdu_frame_length && (datainlen > apdu_frame_length - 3)) || (datainlen > pm3_max_cmd_data_size() - 3))) {
|
||||
|
||||
int clen = 0;
|
||||
bool v_activate_field = activate_field;
|
||||
|
||||
@@ -1649,7 +1649,7 @@ static int hf15EmlSetMem(const uint8_t *data, uint16_t count, size_t offset) {
|
||||
uint8_t data[];
|
||||
} PACKED;
|
||||
|
||||
if (count > (PM3_CMD_DATA_SIZE - sizeof(struct p))) {
|
||||
if (count > (pm3_max_cmd_data_size() - sizeof(struct p))) {
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
@@ -2575,11 +2575,11 @@ static int CmdHF15Raw(const char *Cmd) {
|
||||
bool wait = arg_get_lit(ctx, 7);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
datalen = (datalen >= PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||
datalen = (datalen >= pm3_max_cmd_data_size()) ? pm3_max_cmd_data_size() : datalen;
|
||||
|
||||
if (crc) {
|
||||
|
||||
if ((datalen - 2) < PM3_CMD_DATA_SIZE) {
|
||||
if ((datalen - 2) < pm3_max_cmd_data_size()) {
|
||||
AddCrc15(data, datalen);
|
||||
datalen += 2;
|
||||
} else {
|
||||
|
||||
@@ -8252,7 +8252,7 @@ static int felica_sim_model_from_json(json_t *root, felica_sim_model_t *model_ou
|
||||
|
||||
static int felica_sim_send_control(uint8_t subcommand, uint32_t total_len, uint32_t offset, uint16_t model_crc,
|
||||
const uint8_t *data, uint16_t data_len, uint32_t timeout_ms) {
|
||||
if (data_len > (PM3_CMD_DATA_SIZE - sizeof(felica_sim_upload_t))) {
|
||||
if (data_len > (pm3_max_cmd_data_size() - sizeof(felica_sim_upload_t))) {
|
||||
return PM3_EOVFLOW;
|
||||
}
|
||||
|
||||
@@ -8287,7 +8287,7 @@ static int felica_sim_upload_model(const felica_sim_model_t *model) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
const uint16_t chunk_size = PM3_CMD_DATA_SIZE - sizeof(felica_sim_upload_t);
|
||||
const uint16_t chunk_size = pm3_max_cmd_data_size() - sizeof(felica_sim_upload_t);
|
||||
uint32_t offset = 0;
|
||||
PrintAndLogEx(INFO, "Uploading simulator model");
|
||||
PrintAndLogEx(INFO, "." NOLF);
|
||||
@@ -9438,7 +9438,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||
}
|
||||
|
||||
// Max transport buffer is PM3_CMD_DATA_SIZE
|
||||
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||
datalen = (datalen > pm3_max_cmd_data_size()) ? pm3_max_cmd_data_size() : datalen;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Data: %s", sprint_hex(data, datalen));
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ static void iclass_upload_emul(uint8_t *d, uint16_t n, uint16_t offset, uint16_t
|
||||
PrintAndLogEx(INFO, "." NOLF);
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE - 4, bytes_remaining);
|
||||
uint32_t bytes_in_packet = MIN((uint32_t)(pm3_max_cmd_data_size() - 4), bytes_remaining);
|
||||
if (bytes_in_packet == bytes_remaining) {
|
||||
// Disable fast mode on last packet
|
||||
g_conn.block_after_ACK = false;
|
||||
@@ -3565,8 +3565,8 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
||||
|
||||
uint32_t payload_size = sizeof(iclass_restore_req_t) + (sizeof(iclass_restore_item_t) * (endblock - startblock + 1));
|
||||
|
||||
if (payload_size > PM3_CMD_DATA_SIZE) {
|
||||
PrintAndLogEx(NORMAL, "Trying to write too many blocks at once. Max: %d", PM3_CMD_DATA_SIZE / 8);
|
||||
if (payload_size > pm3_max_cmd_data_size()) {
|
||||
PrintAndLogEx(NORMAL, "Trying to write too many blocks at once. Max: %d", pm3_max_cmd_data_size() / 8);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -6065,8 +6065,8 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
|
||||
// USB_COMMAND. 512/4 = 103 mac
|
||||
uint32_t max_chunk_size = 0;
|
||||
if (keycount > ((PM3_CMD_DATA_SIZE - sizeof(iclass_chk_t)) / 4))
|
||||
max_chunk_size = (PM3_CMD_DATA_SIZE - sizeof(iclass_chk_t)) / 4;
|
||||
if (keycount > ((pm3_max_cmd_data_size() - sizeof(iclass_chk_t)) / 4))
|
||||
max_chunk_size = (pm3_max_cmd_data_size() - sizeof(iclass_chk_t)) / 4;
|
||||
else
|
||||
max_chunk_size = keycount;
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
|
||||
uint8_t blockno = 0;
|
||||
|
||||
// 12 is the size of the struct the fct mf_eml_set_mem_xt uses to transfer to device
|
||||
uint16_t max_avail_blocks = ((PM3_CMD_DATA_SIZE - 12) / blockwidth);
|
||||
uint16_t max_avail_blocks = ((pm3_max_cmd_data_size() - 12) / blockwidth);
|
||||
|
||||
while (datalen) {
|
||||
if (datalen == blockwidth) {
|
||||
|
||||
@@ -35,7 +35,7 @@ static int CmdHelp(const char *Cmd);
|
||||
#define LEGIC_PRIME_MIM256 256
|
||||
#define LEGIC_PRIME_MIM1024 1024
|
||||
#define LEGIC_BLOCK_SIZE 8
|
||||
#define LEGIC_PACKET_SIZE (PM3_CMD_DATA_SIZE - sizeof(legic_packet_t))
|
||||
#define LEGIC_PACKET_SIZE (pm3_max_cmd_data_size() - sizeof(legic_packet_t))
|
||||
|
||||
static bool legic_xor(uint8_t *data, uint16_t cardsize) {
|
||||
|
||||
|
||||
@@ -3395,7 +3395,9 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||
res = mf_check_keys_fast(sector_cnt, true, true, 1, key_cnt, keyBlock, e_sector, use_flashmemory, verbose);
|
||||
} else {
|
||||
|
||||
uint32_t chunksize = key_cnt > MFC_CHKKEYS_FAST_MAX_KEYS ? MFC_CHKKEYS_FAST_MAX_KEYS : key_cnt;
|
||||
uint32_t maxkeys = (pm3_max_cmd_data_size() - sizeof(mf_chkkeys_fast_t)) / 6;
|
||||
if (maxkeys > 255) maxkeys = 255;
|
||||
uint32_t chunksize = key_cnt > maxkeys ? maxkeys : key_cnt;
|
||||
bool firstChunk = true, lastChunk = false;
|
||||
|
||||
for (uint8_t strategy = 1; strategy < 3; strategy++) {
|
||||
@@ -4045,7 +4047,9 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
uint32_t chunksize = (keycnt > MFC_CHKKEYS_FAST_MAX_KEYS) ? MFC_CHKKEYS_FAST_MAX_KEYS : keycnt;
|
||||
uint32_t maxkeys = (pm3_max_cmd_data_size() - sizeof(mf_chkkeys_fast_t)) / 6;
|
||||
if (maxkeys > 255) maxkeys = 255;
|
||||
uint32_t chunksize = (keycnt > maxkeys) ? maxkeys : keycnt;
|
||||
bool firstChunk = true, lastChunk = false;
|
||||
|
||||
int i = 0;
|
||||
@@ -5429,7 +5433,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
int cnt = 0;
|
||||
|
||||
// 12 is the size of the struct the fct mf_eml_set_mem_xt uses to transfer to device
|
||||
uint16_t max_avail_blocks = ((PM3_CMD_DATA_SIZE - 12) / block_width) * block_width;
|
||||
uint16_t max_avail_blocks = ((pm3_max_cmd_data_size() - 12) / block_width) * block_width;
|
||||
|
||||
while (bytes_read && cnt < block_cnt) {
|
||||
if (bytes_read == block_width) {
|
||||
@@ -9404,7 +9408,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
|
||||
uint16_t bytes_left = bytes ;
|
||||
|
||||
// 12 is the size of the struct the fct mf_eml_set_mem_xt uses to transfer to device
|
||||
uint16_t max_avail_blocks = ((PM3_CMD_DATA_SIZE - 12) / MFBLOCK_SIZE) * MFBLOCK_SIZE;
|
||||
uint16_t max_avail_blocks = ((pm3_max_cmd_data_size() - 12) / MFBLOCK_SIZE) * MFBLOCK_SIZE;
|
||||
|
||||
while (bytes_left > 0 && cnt < block_cnt) {
|
||||
if (bytes_left == MFBLOCK_SIZE) {
|
||||
|
||||
@@ -4687,7 +4687,7 @@ static int CmdHF14AMfUCAuth(const char *Cmd) {
|
||||
uint16_t max_retries_per_call = retries;
|
||||
if (collect_nonces) {
|
||||
// Not strictly needed, but to avoid fw warning
|
||||
max_retries_per_call = ((PM3_CMD_DATA_SIZE - sizeof(uint32_t) * 2) / sizeof(uint64_t)) - 1;
|
||||
max_retries_per_call = ((pm3_max_cmd_data_size() - sizeof(uint32_t) * 2) / sizeof(uint64_t)) - 1;
|
||||
}
|
||||
isok = ul3pass_authentication(auth_key_ptr, MIFAREULC_KEY_INDEX, !keep_field_on, MIN(retries - auths, max_retries_per_call), &auths, &ms, false, !skip_auth, check_answer, use_fastread0, collect_nonces, (uint8_t *)(nonces + auths), reset_field, available_pairs, pairs);
|
||||
} while (skip_auth && auths < 1 + retries);
|
||||
@@ -4783,7 +4783,7 @@ static int CmdHF14AMfUCAuthChk(const char *Cmd) {
|
||||
}
|
||||
|
||||
// cap by what fits in one frame, then by what the nkeys field can announce
|
||||
uint32_t max_chunk = (PM3_CMD_DATA_SIZE - MIFAREU3P_CHKKEY_HEADER) / keysize;
|
||||
uint32_t max_chunk = (pm3_max_cmd_data_size() - MIFAREU3P_CHKKEY_HEADER) / keysize;
|
||||
if (max_chunk > MIFAREU3P_CHKKEY_MAX_KEYS) {
|
||||
max_chunk = MIFAREU3P_CHKKEY_MAX_KEYS;
|
||||
}
|
||||
@@ -5002,7 +5002,7 @@ static int CmdHF14AMfUAESAuthChk(const char *Cmd) {
|
||||
}
|
||||
|
||||
// cap by what fits in one frame, then by what the nkeys field can announce
|
||||
uint32_t max_chunk = (PM3_CMD_DATA_SIZE - MIFAREU3P_CHKKEY_HEADER) / keysize;
|
||||
uint32_t max_chunk = (pm3_max_cmd_data_size() - MIFAREU3P_CHKKEY_HEADER) / keysize;
|
||||
if (max_chunk > MIFAREU3P_CHKKEY_MAX_KEYS) {
|
||||
max_chunk = MIFAREU3P_CHKKEY_MAX_KEYS;
|
||||
}
|
||||
@@ -8685,9 +8685,9 @@ static int CmdHF14AMfUeSetBlk(const char *Cmd) {
|
||||
|
||||
// one esetblk is a single CMD_HF_MIFARE_EML_MEMSET; its payload (data + a 4-byte
|
||||
// header) must fit the command buffer. Larger sets should use `hf mfu eload`.
|
||||
if (datalen > (int)(PM3_CMD_DATA_SIZE - 4)) {
|
||||
if (datalen > (int)(pm3_max_cmd_data_size() - 4)) {
|
||||
PrintAndLogEx(WARNING, "too many pages for one command: max %d pages (%d bytes). Use " _YELLOW_("`hf mfu eload`") " for larger sets",
|
||||
(int)((PM3_CMD_DATA_SIZE - 4) / MFU_BLOCK_SIZE), (int)(PM3_CMD_DATA_SIZE - 4));
|
||||
(int)((pm3_max_cmd_data_size() - 4) / MFU_BLOCK_SIZE), (int)(pm3_max_cmd_data_size() - 4));
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1910,8 +1910,8 @@ static int CmdPing(const char *Cmd) {
|
||||
uint32_t len = arg_get_u32_def(ctx, 1, 32);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (len > PM3_CMD_DATA_SIZE)
|
||||
len = PM3_CMD_DATA_SIZE;
|
||||
if (len > pm3_max_cmd_data_size())
|
||||
len = pm3_max_cmd_data_size();
|
||||
|
||||
if (len) {
|
||||
PrintAndLogEx(INFO, "Ping sent with payload len... " _YELLOW_("%d"), len);
|
||||
|
||||
+11
-11
@@ -1069,9 +1069,9 @@ int lfsim_upload_gb(void) {
|
||||
|
||||
//can send only 512 bits at a time (1 byte sent per bit...)
|
||||
PrintAndLogEx(INFO, "." NOLF);
|
||||
for (size_t i = 0; i < g_GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) {
|
||||
for (size_t i = 0; i < g_GraphTraceLen; i += pm3_max_cmd_data_size() - 3) {
|
||||
|
||||
size_t len = MIN((g_GraphTraceLen - i), PM3_CMD_DATA_SIZE - 3);
|
||||
size_t len = MIN((g_GraphTraceLen - i), (size_t)(pm3_max_cmd_data_size() - 3));
|
||||
clearCommandBuffer();
|
||||
payload_up.offset = i;
|
||||
|
||||
@@ -1236,10 +1236,10 @@ int CmdLFfskSim(const char *Cmd) {
|
||||
}
|
||||
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t));
|
||||
if (size > (pm3_max_cmd_data_size() - sizeof(lf_fsksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, (size_t)(pm3_max_cmd_data_size() - sizeof(lf_fsksim_t)));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
size = PM3_CMD_DATA_SIZE - sizeof(lf_fsksim_t);
|
||||
size = pm3_max_cmd_data_size() - sizeof(lf_fsksim_t);
|
||||
}
|
||||
|
||||
lf_fsksim_t *payload = calloc(1, sizeof(lf_fsksim_t) + size);
|
||||
@@ -1353,10 +1353,10 @@ int CmdLFaskSim(const char *Cmd) {
|
||||
}
|
||||
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_asksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_asksim_t));
|
||||
if (size > (pm3_max_cmd_data_size() - sizeof(lf_asksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, (size_t)(pm3_max_cmd_data_size() - sizeof(lf_asksim_t)));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
size = PM3_CMD_DATA_SIZE - sizeof(lf_asksim_t);
|
||||
size = pm3_max_cmd_data_size() - sizeof(lf_asksim_t);
|
||||
}
|
||||
|
||||
lf_asksim_t *payload = calloc(1, sizeof(lf_asksim_t) + size);
|
||||
@@ -1489,10 +1489,10 @@ int CmdLFpskSim(const char *Cmd) {
|
||||
}
|
||||
|
||||
size_t size = g_DemodBufferLen;
|
||||
if (size > (PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t));
|
||||
if (size > (pm3_max_cmd_data_size() - sizeof(lf_psksim_t))) {
|
||||
PrintAndLogEx(WARNING, "DemodBuffer too long for current implementation - length: %zu - max: %zu", size, (size_t)(pm3_max_cmd_data_size() - sizeof(lf_psksim_t)));
|
||||
PrintAndLogEx(INFO, "Continuing with trimmed down data");
|
||||
size = PM3_CMD_DATA_SIZE - sizeof(lf_psksim_t);
|
||||
size = pm3_max_cmd_data_size() - sizeof(lf_psksim_t);
|
||||
}
|
||||
|
||||
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + size);
|
||||
|
||||
@@ -166,7 +166,7 @@ static int em4x50_load_file(const char *filename, uint8_t *data, size_t data_len
|
||||
static int em4x50_seteml(const uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||
|
||||
// an EM4x50 is 136 bytes, so the whole tag always fits in a single frame
|
||||
if ((offset + numofbytes) > (PM3_CMD_DATA_SIZE - sizeof(em4x50_eset_t))) {
|
||||
if ((offset + numofbytes) > (pm3_max_cmd_data_size() - sizeof(em4x50_eset_t))) {
|
||||
PrintAndLogEx(FAILED, "%u bytes at offset %u doesn't fit in one frame", numofbytes, offset);
|
||||
return PM3_EOUTOFBOUND;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user