mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
Change lf t55xx chk -m to read dictionary from spiffs file
This commit is contained in:
parent
470536f0fd
commit
2fe0ba57b2
3 changed files with 17 additions and 21 deletions
|
@ -2782,15 +2782,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload->startidx == DEFAULT_T55XX_KEYS_OFFSET_P(spi_flash_pages64k)) {
|
if (payload->startidx == FLASH_MEM_SIGNATURE_OFFSET_P(spi_flash_pages64k)) {
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
|
||||||
Flash_WriteEnable();
|
|
||||||
Flash_Erase4k(spi_flash_pages64k - 1, 0xC);
|
|
||||||
} else if (payload->startidx == DEFAULT_ICLASS_KEYS_OFFSET_P(spi_flash_pages64k)) {
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
|
||||||
Flash_WriteEnable();
|
|
||||||
Flash_Erase4k(spi_flash_pages64k - 1, 0xB);
|
|
||||||
} else if (payload->startidx == FLASH_MEM_SIGNATURE_OFFSET_P(spi_flash_pages64k)) {
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
Flash_CheckBusy(BUSY_TIMEOUT);
|
||||||
Flash_WriteEnable();
|
Flash_WriteEnable();
|
||||||
Flash_Erase4k(spi_flash_pages64k - 1, 0xF);
|
Flash_Erase4k(spi_flash_pages64k - 1, 0xF);
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "protocols.h"
|
#include "protocols.h"
|
||||||
#include "pmflash.h"
|
#include "pmflash.h"
|
||||||
#include "flashmem.h" // persistence on flash
|
#include "flashmem.h" // persistence on flash
|
||||||
|
#include "spiffs.h" // spiffs
|
||||||
#include "appmain.h" // print stack
|
#include "appmain.h" // print stack
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2146,29 +2147,31 @@ void T55xx_ChkPwds(uint8_t flags, bool ledcontrol) {
|
||||||
#ifdef WITH_FLASH
|
#ifdef WITH_FLASH
|
||||||
|
|
||||||
BigBuf_Clear_EM();
|
BigBuf_Clear_EM();
|
||||||
uint16_t isok = 0;
|
uint32_t size = 0;
|
||||||
uint8_t counter[2] = {0x00, 0x00};
|
|
||||||
isok = Flash_ReadData(DEFAULT_T55XX_KEYS_OFFSET_P(spi_flash_pages64k), counter, sizeof(counter));
|
|
||||||
if (isok != sizeof(counter))
|
|
||||||
goto OUT;
|
|
||||||
|
|
||||||
pwd_count = (uint16_t)(counter[1] << 8 | counter[0]);
|
if (exists_in_spiffs(T55XX_KEYS_FILE)) {
|
||||||
|
size = size_in_spiffs(T55XX_KEYS_FILE);
|
||||||
|
}
|
||||||
|
if (size == 0) {
|
||||||
|
Dbprintf("Spiffs file: %s does not exists or empty.", T55XX_KEYS_FILE);
|
||||||
|
goto OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
pwd_count = size / T55XX_KEY_LENGTH;
|
||||||
if (pwd_count == 0)
|
if (pwd_count == 0)
|
||||||
goto OUT;
|
goto OUT;
|
||||||
|
|
||||||
// since flash can report way too many pwds, we need to limit it.
|
// since flash can report way too many pwds, we need to limit it.
|
||||||
// bigbuff EM size is determined by CARD_MEMORY_SIZE
|
// bigbuff EM size is determined by CARD_MEMORY_SIZE
|
||||||
// a password is 4bytes.
|
// a password is 4bytes.
|
||||||
uint16_t pwd_size_available = MIN(CARD_MEMORY_SIZE, pwd_count * 4);
|
uint16_t pwd_size_available = MIN(CARD_MEMORY_SIZE, pwd_count * T55XX_KEY_LENGTH);
|
||||||
|
|
||||||
// adjust available pwd_count
|
// adjust available pwd_count
|
||||||
pwd_count = pwd_size_available / 4;
|
pwd_count = pwd_size_available / T55XX_KEY_LENGTH;
|
||||||
|
|
||||||
isok = Flash_ReadData(DEFAULT_T55XX_KEYS_OFFSET_P(spi_flash_pages64k) + 2, pwds, pwd_size_available);
|
rdv40_spiffs_read_as_filetype(T55XX_KEYS_FILE, pwds, pwd_size_available, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
if (isok != pwd_size_available)
|
|
||||||
goto OUT;
|
|
||||||
|
|
||||||
Dbprintf("Password dictionary count " _YELLOW_("%d"), pwd_count);
|
if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u passwords from spiffs file: %s", pwd_count, T55XX_KEYS_FILE);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1925,6 +1925,7 @@ void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *da
|
||||||
goto OUT;
|
goto OUT;
|
||||||
|
|
||||||
rdv40_spiffs_read_as_filetype(MF_KEYS_FILE, datain, keyCount * MF_KEY_LENGTH, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_read_as_filetype(MF_KEYS_FILE, datain, keyCount * MF_KEY_LENGTH, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
|
|
||||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u keys from spiffs file: %s", keyCount, MF_KEYS_FILE);
|
if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u keys from spiffs file: %s", keyCount, MF_KEYS_FILE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue