chg: 'lf hitag reader 21' - now save BIN/EML formats.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "cmddata.h"
|
#include "cmddata.h"
|
||||||
|
#include "loclass/fileutils.h" // savefile
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
@@ -277,21 +278,18 @@ int CmdLFHitagReader(const char *Cmd) {
|
|||||||
uint32_t id = bytes_to_num(resp.d.asBytes, 4);
|
uint32_t id = bytes_to_num(resp.d.asBytes, 4);
|
||||||
|
|
||||||
if (htf == RHT2F_UID_ONLY) {
|
if (htf == RHT2F_UID_ONLY) {
|
||||||
PrintAndLogEx(NORMAL, "Valid Hitag2 tag found - UID: %08x", id);
|
PrintAndLogEx(SUCCESS, "Valid Hitag2 tag found - UID: %08x", id);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
uint8_t *data = resp.d.asBytes;
|
||||||
|
|
||||||
char filename[FILE_PATH_SIZE];
|
char filename[FILE_PATH_SIZE];
|
||||||
FILE *f = NULL;
|
char *fnameptr = filename;
|
||||||
sprintf(filename, "%08x_%04x.ht2", id, (rand() & 0xffff));
|
fnameptr += sprintf(fnameptr, "lf-hitag-");
|
||||||
f = fopen(filename, "wb");
|
FillFileNameByUID(fnameptr, data, "-dump", 4);
|
||||||
if (!f) {
|
|
||||||
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the 48 tag memory bytes to file and finalize
|
saveFile(filename, "bin", data, 48);
|
||||||
fwrite(resp.d.asBytes, 1, 48, f);
|
saveFileEML(filename, "eml", data, 48, 4);
|
||||||
fclose(f);
|
|
||||||
PrintAndLogEx(NORMAL, "Succesfully saved tag memory to [%s]", filename);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user