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
|
// dictionary mode
|
||||||
if (dict_filenamelen) {
|
if (dict_filenamelen) {
|
||||||
size_t endFilePosition = 0;
|
size_t endFilePosition = 0;
|
||||||
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), &keyListLen, 16, NULL, 0, &endFilePosition);
|
uint16_t keycnt = 0;
|
||||||
printf("---endFilePosition %d", endFilePosition);
|
res = loadFileDICTIONARYEx((char *)dict_filename, keyList, sizeof(keyList), NULL, 16, &keycnt, 0, &endFilePosition);
|
||||||
|
keyListLen = keycnt;
|
||||||
|
printf("---endFilePosition %d\n", endFilePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyListLen == 0) {
|
if (keyListLen == 0) {
|
||||||
|
@ -870,6 +872,8 @@ static int CmdHFMFPChk(const char *cmd) {
|
||||||
Fill2bPattern(keyList, &keyListLen, &startPattern);
|
Fill2bPattern(keyList, &keyListLen, &startPattern);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (dict_filenamelen) {
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -785,10 +785,10 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
|
||||||
|
|
||||||
if (startFilePosition)
|
if (startFilePosition)
|
||||||
fseek(f, startFilePosition, SEEK_SET);
|
fseek(f, startFilePosition, SEEK_SET);
|
||||||
|
|
||||||
// read file
|
// read file
|
||||||
while (fgets(line, sizeof(line), f)) {
|
while (!feof(f) && fgets(line, sizeof(line), f)) {
|
||||||
|
|
||||||
// add null terminator
|
// add null terminator
|
||||||
line[keylen] = 0;
|
line[keylen] = 0;
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
|
||||||
if (line[0] == '#')
|
if (line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (CheckStringIsHEXValue(line))
|
if (!CheckStringIsHEXValue(line))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// cant store more data
|
// cant store more data
|
||||||
|
@ -811,10 +811,10 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
|
||||||
*endFilePosition = pos;
|
*endFilePosition = pos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hex_to_bytes(line, data + counter, keylen >> 1) != (keylen >> 1))
|
if (hex_to_bytes(line, data + counter, keylen >> 1) != (keylen >> 1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vkeycnt++;
|
vkeycnt++;
|
||||||
memset(line, 0, sizeof(line));
|
memset(line, 0, sizeof(line));
|
||||||
counter += (keylen >> 1);
|
counter += (keylen >> 1);
|
||||||
|
|
|
@ -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) {
|
int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValueLen) {
|
||||||
char buf[3];
|
char buf[4] = {0};
|
||||||
int indx = 0;
|
int indx = 0;
|
||||||
int bytesValueLen = 0;
|
int bytesValueLen = 0;
|
||||||
while (hexValue[indx]) {
|
while (hexValue[indx]) {
|
||||||
|
@ -405,7 +405,6 @@ int hex_to_bytes(const char *hexValue, uint8_t *bytesValue, size_t maxBytesValue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isxdigit(hexValue[indx])) {
|
if (isxdigit(hexValue[indx])) {
|
||||||
buf[strlen(buf) + 1] = 0x00;
|
|
||||||
buf[strlen(buf)] = hexValue[indx];
|
buf[strlen(buf)] = hexValue[indx];
|
||||||
} else {
|
} else {
|
||||||
// if we have symbols other than spaces and hex
|
// 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;
|
uint32_t temp = 0;
|
||||||
sscanf(buf, "%x", &temp);
|
sscanf(buf, "%x", &temp);
|
||||||
bytesValue[bytesValueLen] = (uint8_t)(temp & 0xff);
|
bytesValue[bytesValueLen] = (uint8_t)(temp & 0xff);
|
||||||
buf[0] = 0;
|
memset(buf, 0, sizeof(buf));
|
||||||
bytesValueLen++;
|
bytesValueLen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue