Make sure MFC dumps & keys are saved in the dump user pref path

This commit is contained in:
Philippe Teuwen 2024-10-14 22:53:00 +02:00
commit 02f0b1bcdd
3 changed files with 7 additions and 4 deletions

View file

@ -460,7 +460,7 @@ static int mf_save_keys_from_arr(uint16_t n, uint8_t *d) {
char fn[FILE_PATH_SIZE] = {0};
snprintf(fn, sizeof(fn), "hf-mf-%s-key", sprint_hex_inrow(d, 4));
saveFile(fn, ".bin", keys, keysize);
saveFileEx(fn, ".bin", keys, keysize, spDump);
free(keys);
return PM3_SUCCESS;
}

View file

@ -261,12 +261,14 @@ void truncate_filename(char *fn, uint16_t maxlen) {
// --------- SAVE FILES
int saveFile(const char *preferredName, const char *suffix, const void *data, size_t datalen) {
return saveFileEx(preferredName, suffix, data, datalen, spDefault);
}
int saveFileEx(const char *preferredName, const char *suffix, const void *data, size_t datalen, savePaths_t e_save_path) {
if (data == NULL || datalen == 0) {
return PM3_EINVARG;
}
char *fileName = newfilenamemcopy(preferredName, suffix);
char *fileName = newfilenamemcopyEx(preferredName, suffix, e_save_path);
if (fileName == NULL) {
return PM3_EMALLOC;
}
@ -3135,7 +3137,7 @@ int pm3_save_mf_dump(const char *fn, uint8_t *d, size_t n, JSONFileType jsft) {
PrintAndLogEx(INFO, "No data to save, skipping...");
return PM3_EINVARG;
}
saveFile(fn, ".bin", d, n);
saveFileEx(fn, ".bin", d, n, spDump);
iso14a_mf_extdump_t jd = {0};
jd.card_info.ats_len = 0;

View file

@ -125,6 +125,7 @@ void truncate_filename(char *fn, uint16_t maxlen);
* @return 0 for ok, 1 for failz
*/
int saveFile(const char *preferredName, const char *suffix, const void *data, size_t datalen);
int saveFileEx(const char *preferredName, const char *suffix, const void *data, size_t datalen, savePaths_t e_save_path);
/** STUB
* @brief Utility function to save JSON data to a file. This method takes a preferred name, but if that