mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
refactoring + make dictionary works
This commit is contained in:
parent
131730e7db
commit
94eb741a4f
3 changed files with 14 additions and 11 deletions
|
@ -842,8 +842,10 @@ static int CmdHFMFPChk(const char *cmd) {
|
|||
// dictionary mode
|
||||
if (dict_filenamelen) {
|
||||
size_t endFilePosition = 0;
|
||||
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), &keyListLen, 16, NULL, 0, &endFilePosition);
|
||||
printf("---endFilePosition %d", endFilePosition);
|
||||
uint16_t keycnt = 0;
|
||||
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), NULL, 16, &keycnt, 0, &endFilePosition);
|
||||
keyListLen = keycnt;
|
||||
printf("---endFilePosition %d\n", endFilePosition);
|
||||
}
|
||||
|
||||
if (keyListLen == 0) {
|
||||
|
@ -870,6 +872,8 @@ static int CmdHFMFPChk(const char *cmd) {
|
|||
Fill2bPattern(keyList, &keyListLen, &startPattern);
|
||||
continue;
|
||||
}
|
||||
if (dict_filenamelen) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -787,7 +787,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
|
|||
fseek(f, startFilePosition, SEEK_SET);
|
||||
|
||||
// read file
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
while (!feof(f) && fgets(line, sizeof(line), f)) {
|
||||
|
||||
// add null terminator
|
||||
line[keylen] = 0;
|
||||
|
@ -800,7 +800,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
|
|||
if (line[0] == '#')
|
||||
continue;
|
||||
|
||||
if (CheckStringIsHEXValue(line))
|
||||
if (!CheckStringIsHEXValue(line))
|
||||
continue;
|
||||
|
||||
// cant store more data
|
||||
|
|
|
@ -395,7 +395,7 @@ void print_blocks(uint32_t *data, size_t len) {
|
|||
}
|
||||
|
||||
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen) {
|
||||
char buf[3];
|
||||
char buf[4] = {0};
|
||||
int indx = 0;
|
||||
int bytesValueLen = 0;
|
||||
while (hexValue[indx]) {
|
||||
|
@ -405,7 +405,6 @@ int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValue
|
|||
}
|
||||
|
||||
if (isxdigit(hexValue[indx])) {
|
||||
buf[strlen(buf) + 1] = 0x00;
|
||||
buf[strlen(buf)] = hexValue[indx];
|
||||
} else {
|
||||
// if we have symbols other than spaces and hex
|
||||
|
@ -421,7 +420,7 @@ int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValue
|
|||
uint32_t temp = 0;
|
||||
sscanf(buf, "%x", &temp);
|
||||
bytesValue[bytesValueLen] = (uint8_t)(temp & 0xff);
|
||||
buf[0] = 0;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
bytesValueLen++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue