mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 02:34:48 +08:00
CHG: use FillFileNameByUID() for filename generation for 'hf mf dump' and 'hf mf chk * ? d'
This commit is contained in:
parent
314253c359
commit
d050e473b7
3 changed files with 18 additions and 18 deletions
|
@ -340,7 +340,7 @@ int usage_hf14_nack(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int GetHFMF14AUID(uint8_t *uid) {
|
||||
int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -355,25 +355,23 @@ int GetHFMF14AUID(uint8_t *uid) {
|
|||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(uid, card.uid, card.uidlen * sizeof(uint8_t));
|
||||
*uidlen=card.uidlen;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char * GenerateFilename(const char *prefix, const char *suffix){
|
||||
uint8_t uid[4] = {0,0,0,0};
|
||||
int len=0;
|
||||
uint8_t uid[8] = {0,0,0,0,0,0,0,0};
|
||||
int uidlen=0;
|
||||
char * fptr = malloc (sizeof (char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid)*2 + 1);
|
||||
|
||||
if (!GetHFMF14AUID(uid)) {
|
||||
if (!GetHFMF14AUID(uid, &uidlen)) {
|
||||
PrintAndLog("No tag found.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(fptr, prefix);
|
||||
len=strlen(fptr);
|
||||
for (int i=0;i<sizeof(uid)/sizeof(uint8_t);i++)
|
||||
len += sprintf(fptr+len, "%02x", uid[i]);
|
||||
strcat(fptr, suffix);
|
||||
|
||||
strcpy(fptr, prefix);
|
||||
FillFileNameByUID(fptr,uid,suffix,uidlen);
|
||||
|
||||
return fptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,17 +101,19 @@ void AddLogCurrentDT(char *fn) {
|
|||
// param *uid - pointer to uid byte array
|
||||
// param *ext - ".log"
|
||||
// param uidlen - length of uid array.
|
||||
void FillFileNameByUID(char *fn, uint8_t *uid, char *ext, int uidlen) {
|
||||
if ( fn == NULL || uid == NULL || ext == NULL ){
|
||||
void FillFileNameByUID(char *filenamePrefix, uint8_t *uid, const char *ext, int uidlen) {
|
||||
if ( filenamePrefix == NULL || uid == NULL || ext == NULL ){
|
||||
printf("[!] error parameter is NULL\n");
|
||||
return;
|
||||
}
|
||||
char *fnameptr = fn;
|
||||
memset(fn, 0x00, FILE_PATH_SIZE);
|
||||
|
||||
for (int j = 0; j < uidlen; j++, fnameptr += 2)
|
||||
sprintf(fnameptr, "%02X", uid[j]);
|
||||
sprintf(fnameptr, "%s", ext);
|
||||
int len=0;
|
||||
len=strlen(filenamePrefix);
|
||||
//memset(fn, 0x00, FILE_PATH_SIZE);
|
||||
|
||||
for (int j = 0; j < uidlen; j++)
|
||||
sprintf(filenamePrefix + len + j * 2, "%02X", uid[j]);
|
||||
strcat(filenamePrefix, ext);
|
||||
}
|
||||
|
||||
void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len,
|
||||
|
|
|
@ -174,7 +174,7 @@ extern void AddLogLine(char *fileName, char *extData, char *c);
|
|||
extern void AddLogHex(char *fileName, char *extData, const uint8_t * data, const size_t len);
|
||||
extern void AddLogUint64(char *fileName, char *extData, const uint64_t data);
|
||||
extern void AddLogCurrentDT(char *fileName);
|
||||
extern void FillFileNameByUID(char *fileName, uint8_t * uid, char *ext, int byteCount);
|
||||
extern void FillFileNameByUID(char *fileName, uint8_t * uid, const char *ext, int uidlen);
|
||||
|
||||
extern void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len,
|
||||
const size_t hex_max_len, const size_t min_str_len, const size_t spaces_between,
|
||||
|
|
Loading…
Reference in a new issue