mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
keys are copied blockwise via spiffs to device because of
- flash memory limitation (big dictionaries) - user feedback (infos about progress)
This commit is contained in:
parent
8fde0ba047
commit
0a21f7dd8f
1 changed files with 29 additions and 19 deletions
|
@ -16,8 +16,6 @@
|
||||||
#include "cmdflashmemspiffs.h"
|
#include "cmdflashmemspiffs.h"
|
||||||
#include "cmdparser.h"
|
#include "cmdparser.h"
|
||||||
|
|
||||||
#define CARD_MEMORY_SIZE 4096
|
|
||||||
|
|
||||||
#define BYTES2UINT32(x) ((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | (x[3]))
|
#define BYTES2UINT32(x) ((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | (x[3]))
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -456,13 +454,14 @@ int CmdEM4x50Chk(const char *Cmd) {
|
||||||
// if no filename is given dictionary "t55xx_default_pwds.dic" is used
|
// if no filename is given dictionary "t55xx_default_pwds.dic" is used
|
||||||
|
|
||||||
int status = PM3_EFAILED;
|
int status = PM3_EFAILED;
|
||||||
int res = 0, slen = 0;
|
int keyblock = 2000; // block with 2000 bytes -> 500 keys
|
||||||
|
int res = 0, slen = 0, bytes_remaining = 0;
|
||||||
size_t datalen = 0;
|
size_t datalen = 0;
|
||||||
uint8_t data[FLASH_MEM_MAX_SIZE] = {0x0};
|
uint8_t data[FLASH_MEM_MAX_SIZE] = {0x0};
|
||||||
uint8_t *keys = data;
|
uint8_t *keys = data;
|
||||||
uint32_t key_count = 0, offset = 0;
|
uint32_t key_count = 0;
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
|
||||||
uint8_t destfn[32] = "em4x50_chk.bin";
|
uint8_t destfn[32] = "em4x50_chk.bin";
|
||||||
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
|
@ -486,7 +485,6 @@ int CmdEM4x50Chk(const char *Cmd) {
|
||||||
// no filename -> default = t55xx_default_pwds
|
// no filename -> default = t55xx_default_pwds
|
||||||
if (strlen(filename) == 0) {
|
if (strlen(filename) == 0) {
|
||||||
snprintf(filename, sizeof(filename), "t55xx_default_pwds");
|
snprintf(filename, sizeof(filename), "t55xx_default_pwds");
|
||||||
offset = DEFAULT_T55XX_KEYS_OFFSET;
|
|
||||||
PrintAndLogEx(INFO, "treating file as T55xx keys");
|
PrintAndLogEx(INFO, "treating file as T55xx keys");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,23 +494,35 @@ int CmdEM4x50Chk(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
|
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
|
||||||
|
|
||||||
if (IfPm3Flash()) {
|
if (IfPm3Flash() == false) {
|
||||||
// upload to flash.
|
|
||||||
res = flashmem_spiffs_load(destfn, keys, datalen + 2);
|
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(WARNING, "SPIFFS upload failed");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(WARNING, "no flash memory available");
|
PrintAndLogEx(WARNING, "no flash memory available");
|
||||||
return PM3_EFLASH;
|
return PM3_EFLASH;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
bytes_remaining = datalen;
|
||||||
SendCommandNG(CMD_LF_EM4X50_CHK, destfn, sizeof(destfn));
|
while (bytes_remaining > 0) {
|
||||||
WaitForResponseTimeoutW(CMD_LF_EM4X50_CHK, &resp, -1, false);
|
|
||||||
|
|
||||||
status = resp.status;
|
PrintAndLogEx(INPLACE, "Remaining keys: %i ", bytes_remaining / 4);
|
||||||
|
|
||||||
|
// upload to flash.
|
||||||
|
datalen = MIN(bytes_remaining, keyblock);
|
||||||
|
res = flashmem_spiffs_load(destfn, keys, datalen);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(WARNING, "SPIFFS upload failed");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearCommandBuffer();
|
||||||
|
SendCommandNG(CMD_LF_EM4X50_CHK, destfn, sizeof(destfn));
|
||||||
|
WaitForResponseTimeoutW(CMD_LF_EM4X50_CHK, &resp, -1, false);
|
||||||
|
|
||||||
|
status = resp.status;
|
||||||
|
if ((status == PM3_SUCCESS) || (status == PM3_EOPABORTED))
|
||||||
|
break;
|
||||||
|
|
||||||
|
bytes_remaining -= keyblock;
|
||||||
|
keys += keyblock;
|
||||||
|
}
|
||||||
|
|
||||||
// print response
|
// print response
|
||||||
if (status == PM3_SUCCESS) {
|
if (status == PM3_SUCCESS) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue