mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
fixes ntag424
This commit is contained in:
@@ -3990,7 +3990,10 @@ static int CmdHF14AMfKeyBrute(const char *Cmd) {
|
||||
if (cmdp == 'b') keytype = MF_KEY_B;
|
||||
|
||||
// key
|
||||
if (param_gethex(Cmd, 2, key, 12)) return usage_hf14_keybrute();
|
||||
int keylen = 0;
|
||||
if (param_gethex_ex(Cmd, 2, key, &keylen) && (keylen != 12)) {
|
||||
return usage_hf14_keybrute();
|
||||
}
|
||||
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
|
||||
+180
-200
File diff suppressed because it is too large
Load Diff
@@ -528,8 +528,9 @@ static int CmdEM410xBrute(const char *Cmd) {
|
||||
//The line start with # is comment, skip
|
||||
if (buf[0] == '#') continue;
|
||||
|
||||
if (param_gethex(buf, 0, uid, 10)) {
|
||||
PrintAndLogEx(FAILED, "EM Tag IDs must include 5 hex bytes (10 hex symbols)");
|
||||
int uidlen = 0;
|
||||
if (param_gethex_ex(buf, 0, uid, &uidlen) && (uidlen != 10)) {
|
||||
PrintAndLogEx(FAILED, "EM Tag IDs must include 5 hex bytes (10 hex symbols), got ( " _RED_("%d") " )", uidlen);
|
||||
free(uidblock);
|
||||
fclose(f);
|
||||
return PM3_ESOFT;
|
||||
|
||||
@@ -590,9 +590,10 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||
}
|
||||
hashstring[128] = '\0';
|
||||
|
||||
int hash1n = 0;
|
||||
uint8_t hash_1[64];
|
||||
if (param_gethex(hashstring, 0, hash_1, 128)) {
|
||||
PrintAndLogEx(FAILED, "Couldn't read SHA-512 file");
|
||||
if (param_gethex_ex(hashstring, 0, hash_1, &hash1n) && hash1n != 128) {
|
||||
PrintAndLogEx(FAILED, "Couldn't read SHA-512 file. expect 128 hex bytes, got ( "_RED_("%d") " )", hash1n);
|
||||
free(hashstring);
|
||||
free(firmware);
|
||||
return PM3_ESOFT;
|
||||
|
||||
+4
-20
@@ -759,25 +759,6 @@ float param_getfloat(const char *line, int paramnum, float deflt) {
|
||||
return deflt;
|
||||
}
|
||||
|
||||
int param_gethex(const char *line, int paramnum, uint8_t *data, int hexcnt) {
|
||||
int bg, en, i;
|
||||
uint32_t temp;
|
||||
|
||||
if (hexcnt & 1) return 1;
|
||||
|
||||
if (param_getptr(line, &bg, &en, paramnum)) return 1;
|
||||
|
||||
if (en - bg + 1 != hexcnt) return 1;
|
||||
|
||||
for (i = 0; i < hexcnt; i += 2) {
|
||||
if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1]))) return 1;
|
||||
|
||||
sscanf((char[]) {line[bg + i], line[bg + i + 1], 0}, "%X", &temp);
|
||||
data[i / 2] = temp & 0xff;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int param_gethex_ex(const char *line, int paramnum, uint8_t *data, int *hexcnt) {
|
||||
int bg, en, i;
|
||||
uint32_t temp;
|
||||
@@ -785,8 +766,11 @@ int param_gethex_ex(const char *line, int paramnum, uint8_t *data, int *hexcnt)
|
||||
if (param_getptr(line, &bg, &en, paramnum)) return 1;
|
||||
|
||||
*hexcnt = en - bg + 1;
|
||||
if (*hexcnt % 2) //error if not complete hex bytes
|
||||
|
||||
// error if not complete hex bytes
|
||||
if (*hexcnt & 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < *hexcnt; i += 2) {
|
||||
if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1]))) return 1;
|
||||
|
||||
@@ -106,7 +106,6 @@ uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base);
|
||||
float param_getfloat(const char *line, int paramnum, float deflt);
|
||||
uint8_t param_getdec(const char *line, int paramnum, uint8_t *destination);
|
||||
uint8_t param_isdec(const char *line, int paramnum);
|
||||
int param_gethex(const char *line, int paramnum, uint8_t *data, int hexcnt);
|
||||
int param_gethex_ex(const char *line, int paramnum, uint8_t *data, int *hexcnt);
|
||||
int param_gethex_to_eol(const char *line, int paramnum, uint8_t *data, int maxdatalen, int *datalen);
|
||||
int param_getbin_to_eol(const char *line, int paramnum, uint8_t *data, int maxdatalen, int *datalen);
|
||||
|
||||
Reference in New Issue
Block a user