chg: 'lf hitag reader 21' - now save BIN/EML formats.

This commit is contained in:
iceman1001 2019-03-13 16:31:34 +01:00
parent 9e5f928d27
commit dda69c593a

View file

@ -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 {
char filename[FILE_PATH_SIZE];
FILE *f = NULL;
sprintf(filename, "%08x_%04x.ht2", id, (rand() & 0xffff));
f = fopen(filename, "wb");
if (!f) {
PrintAndLogEx(WARNING, "Error: Could not open file [%s]", filename);
return 1;
}
// Write the 48 tag memory bytes to file and finalize uint8_t *data = resp.d.asBytes;
fwrite(resp.d.asBytes, 1, 48, f);
fclose(f); char filename[FILE_PATH_SIZE];
PrintAndLogEx(NORMAL, "Succesfully saved tag memory to [%s]", filename); char *fnameptr = filename;
fnameptr += sprintf(fnameptr, "lf-hitag-");
FillFileNameByUID(fnameptr, data, "-dump", 4);
saveFile(filename, "bin", data, 48);
saveFileEML(filename, "eml", data, 48, 4);
} }
return 0; return 0;
} }