mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
commit
c3be58229d
3 changed files with 23 additions and 12 deletions
|
@ -2130,6 +2130,9 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
||||||
|
|
||||||
// free eventually allocated BigBuf memory
|
// free eventually allocated BigBuf memory
|
||||||
BigBuf_free_keep_EM();
|
BigBuf_free_keep_EM();
|
||||||
|
// Init early to be sure FPGA is loaded before any EML operation
|
||||||
|
// usefull when eml memory is empty (UID supplied)
|
||||||
|
Iso15693InitTag(); // to be sure FPGA is loaded before any EML operation
|
||||||
|
|
||||||
iso15_tag_t *tag = (iso15_tag_t *) BigBuf_get_EM_addr();
|
iso15_tag_t *tag = (iso15_tag_t *) BigBuf_get_EM_addr();
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
|
@ -2176,8 +2179,6 @@ void SimTagIso15693(uint8_t *uid, uint8_t block_size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iso15693InitTag();
|
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
|
||||||
if (g_dbglevel >= DBG_DEBUG) {
|
if (g_dbglevel >= DBG_DEBUG) {
|
||||||
|
|
|
@ -1164,21 +1164,31 @@ static int CmdHF15ELoad(const char *Cmd) {
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
uint8_t *data = NULL;
|
iso15_tag_t *tag = NULL;
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
int res = pm3_load_dump(filename, (void **)&data, &bytes_read, CARD_MEMORY_SIZE);
|
int res = pm3_load_dump(filename, (void **)&tag, &bytes_read, sizeof(iso15_tag_t));
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes_read > CARD_MEMORY_SIZE || bytes_read > sizeof(iso15_tag_t)) {
|
if (bytes_read != sizeof(iso15_tag_t)) {
|
||||||
PrintAndLogEx(FAILED, "Memory image too large.");
|
PrintAndLogEx(FAILED, "Memory image is not matching tag structure.");
|
||||||
free(data);
|
free(tag);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
if (bytes_read == 0) {
|
if (bytes_read == 0) {
|
||||||
PrintAndLogEx(FAILED, "Memory image empty.");
|
PrintAndLogEx(FAILED, "Memory image empty.");
|
||||||
free(data);
|
free(tag);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tag->pagesCount > ISO15693_TAG_MAX_PAGES) ||
|
||||||
|
((tag->pagesCount * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) ||
|
||||||
|
(tag->pagesCount == 0) ||
|
||||||
|
(tag->bytesPerPage == 0)) {
|
||||||
|
PrintAndLogEx(FAILED, "Tag size error: pagesCount=%d, bytesPerPage=%d",
|
||||||
|
tag->pagesCount, tag->bytesPerPage);
|
||||||
|
free(tag);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,9 +1212,9 @@ static int CmdHF15ELoad(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t bytestosend = MIN(chuncksize, bytes_read);
|
uint16_t bytestosend = MIN(chuncksize, bytes_read);
|
||||||
if (hf15EmlSetMem(data + offset, bytestosend, offset) != PM3_SUCCESS) {
|
if (hf15EmlSetMem((uint8_t*)tag + offset, bytestosend, offset) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(FAILED, "Can't set emulator memory at offest: %zu / 0x%zx", offset, offset);
|
PrintAndLogEx(FAILED, "Can't set emulator memory at offest: %zu / 0x%zx", offset, offset);
|
||||||
free(data);
|
free(tag);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "." NOLF);
|
PrintAndLogEx(NORMAL, "." NOLF);
|
||||||
|
@ -1213,7 +1223,7 @@ static int CmdHF15ELoad(const char *Cmd) {
|
||||||
offset += bytestosend;
|
offset += bytestosend;
|
||||||
bytes_read -= bytestosend;
|
bytes_read -= bytestosend;
|
||||||
}
|
}
|
||||||
free(data);
|
free(tag);
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, "uploaded " _YELLOW_("%zu") " bytes to emulator memory", offset);
|
PrintAndLogEx(SUCCESS, "uploaded " _YELLOW_("%zu") " bytes to emulator memory", offset);
|
||||||
|
|
||||||
|
|
|
@ -1755,7 +1755,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||||
sptr += len;
|
sptr += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
*datalen = sptr;
|
*datalen = sizeof(iso15_tag_t);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue