mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
style
This commit is contained in:
parent
4c6e74c3ce
commit
1a91d42b7d
2 changed files with 37 additions and 10 deletions
|
@ -82,20 +82,25 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
SETBMP();
|
SETBMP();
|
||||||
|
|
||||||
if (width[0] == 0) { //reveng -D
|
if (width[0] == 0) { //reveng -D
|
||||||
|
|
||||||
*count = mcount();
|
*count = mcount();
|
||||||
if (!*count) {
|
if (!*count) {
|
||||||
PrintAndLogEx(WARNING, "no preset models available");
|
PrintAndLogEx(WARNING, "no preset models available");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int mode = 0; mode < *count; ++mode) {
|
for (int mode = 0; mode < *count; ++mode) {
|
||||||
|
|
||||||
mbynum(&model, mode);
|
mbynum(&model, mode);
|
||||||
mcanon(&model);
|
mcanon(&model);
|
||||||
size_t size = (model.name && *model.name) ? strlen(model.name) : 7;
|
size_t size = (model.name && *model.name) ? strlen(model.name) : 7;
|
||||||
|
|
||||||
char *tmp = calloc(size + 1, sizeof(char));
|
char *tmp = calloc(size + 1, sizeof(char));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
PrintAndLogEx(WARNING, "out of memory?");
|
PrintAndLogEx(WARNING, "out of memory?");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.name != NULL) {
|
if (model.name != NULL) {
|
||||||
memcpy(tmp, model.name, size);
|
memcpy(tmp, model.name, size);
|
||||||
Models[mode] = tmp;
|
Models[mode] = tmp;
|
||||||
|
@ -113,18 +118,21 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
PrintAndLogEx(WARNING, "cannot search for non-Williams compliant models");
|
PrintAndLogEx(WARNING, "cannot search for non-Williams compliant models");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
praloc(&model.spoly, (unsigned long)width[0]);
|
praloc(&model.spoly, (unsigned long)width[0]);
|
||||||
praloc(&model.init, (unsigned long)width[0]);
|
praloc(&model.init, (unsigned long)width[0]);
|
||||||
praloc(&model.xorout, (unsigned long)width[0]);
|
praloc(&model.xorout, (unsigned long)width[0]);
|
||||||
|
|
||||||
if (!plen(model.spoly))
|
if (!plen(model.spoly)) {
|
||||||
palloc(&model.spoly, (unsigned long)width[0]);
|
palloc(&model.spoly, (unsigned long)width[0]);
|
||||||
else
|
} else {
|
||||||
width[0] = (uint8_t)plen(model.spoly);
|
width[0] = (uint8_t)plen(model.spoly);
|
||||||
|
}
|
||||||
|
|
||||||
/* special case if qpoly is zero, search to end of range */
|
/* special case if qpoly is zero, search to end of range */
|
||||||
if (!ptst(qpoly))
|
if (!ptst(qpoly)) {
|
||||||
rflags &= ~R_HAVEQ;
|
rflags &= ~R_HAVEQ;
|
||||||
|
}
|
||||||
|
|
||||||
int pass;
|
int pass;
|
||||||
|
|
||||||
|
@ -135,31 +143,41 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
*/
|
*/
|
||||||
/* scan against preset models */
|
/* scan against preset models */
|
||||||
if (~uflags & C_NOPCK) {
|
if (~uflags & C_NOPCK) {
|
||||||
|
|
||||||
pass = 0;
|
pass = 0;
|
||||||
int Cnt = 0;
|
int Cnt = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int psets = mcount();
|
int psets = mcount();
|
||||||
|
|
||||||
while (psets) {
|
while (psets) {
|
||||||
|
|
||||||
mbynum(&pset, --psets);
|
mbynum(&pset, --psets);
|
||||||
|
|
||||||
/* skip if different width, or refin or refout don't match */
|
/* skip if different width, or refin or refout don't match */
|
||||||
if (plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT))
|
if (plen(pset.spoly) != width[0] || (model.flags ^ pset.flags) & (P_REFIN | P_REFOUT)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* skip if the preset doesn't match specified parameters */
|
/* skip if the preset doesn't match specified parameters */
|
||||||
if (rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly))
|
if (rflags & R_HAVEP && pcmp(&model.spoly, &pset.spoly)) {
|
||||||
continue;
|
continue;
|
||||||
if (rflags & R_HAVEI && psncmp(&model.init, &pset.init))
|
}
|
||||||
|
|
||||||
|
if (rflags & R_HAVEI && psncmp(&model.init, &pset.init)) {
|
||||||
continue;
|
continue;
|
||||||
if (rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout))
|
}
|
||||||
|
|
||||||
|
if (rflags & R_HAVEX && psncmp(&model.xorout, &pset.xorout)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//for additional args (not used yet, maybe future?)
|
//for additional args (not used yet, maybe future?)
|
||||||
apoly = pclone(pset.xorout);
|
apoly = pclone(pset.xorout);
|
||||||
|
|
||||||
if (pset.flags & P_REFOUT)
|
if (pset.flags & P_REFOUT) {
|
||||||
prev(&apoly);
|
prev(&apoly);
|
||||||
|
}
|
||||||
|
|
||||||
for (qptr = apolys; qptr < pptr; ++qptr) {
|
for (qptr = apolys; qptr < pptr; ++qptr) {
|
||||||
crc = pcrc(*qptr, pset.spoly, pset.init, apoly, 0);
|
crc = pcrc(*qptr, pset.spoly, pset.init, apoly, 0);
|
||||||
|
@ -183,6 +201,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
PrintAndLogEx(WARNING, "out of memory?");
|
PrintAndLogEx(WARNING, "out of memory?");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
width[Cnt] = width[0];
|
width[Cnt] = width[0];
|
||||||
memcpy(tmp, pset.name, size);
|
memcpy(tmp, pset.name, size);
|
||||||
Models[Cnt++] = tmp;
|
Models[Cnt++] = tmp;
|
||||||
|
@ -199,6 +218,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
prevch(qptr, ibperhx);
|
prevch(qptr, ibperhx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (~rflags & R_HAVERI && ++pass < 2);
|
} while (~rflags & R_HAVERI && ++pass < 2);
|
||||||
}
|
}
|
||||||
//got everything now free the memory...
|
//got everything now free the memory...
|
||||||
|
@ -208,6 +228,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
pfree(qptr);
|
pfree(qptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uflags & C_NOBFS && ~rflags & R_HAVEP) {
|
if (uflags & C_NOBFS && ~rflags & R_HAVEP) {
|
||||||
PrintAndLogEx(WARNING, "no models found");
|
PrintAndLogEx(WARNING, "no models found");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -217,24 +238,30 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
|
||||||
PrintAndLogEx(WARNING, "cannot search for crossed-endian models");
|
PrintAndLogEx(WARNING, "cannot search for crossed-endian models");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pass = 0;
|
pass = 0;
|
||||||
int args = 0;
|
int args = 0;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
model_t *candmods = reveng(&model, qpoly, rflags, args, apolys);
|
model_t *candmods = reveng(&model, qpoly, rflags, args, apolys);
|
||||||
model_t *mptr = candmods;
|
model_t *mptr = candmods;
|
||||||
if (mptr && plen(mptr->spoly)) {
|
if (mptr && plen(mptr->spoly)) {
|
||||||
uflags |= C_RESULT;
|
uflags |= C_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mptr && plen(mptr->spoly)) {
|
while (mptr && plen(mptr->spoly)) {
|
||||||
mfree(mptr++);
|
mfree(mptr++);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(candmods);
|
free(candmods);
|
||||||
|
|
||||||
if (~rflags & R_HAVERI) {
|
if (~rflags & R_HAVERI) {
|
||||||
model.flags ^= P_REFIN | P_REFOUT;
|
model.flags ^= P_REFIN | P_REFOUT;
|
||||||
for (qptr = apolys; qptr < pptr; ++qptr) {
|
for (qptr = apolys; qptr < pptr; ++qptr) {
|
||||||
prevch(qptr, ibperhx);
|
prevch(qptr, ibperhx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (~rflags & R_HAVERI && ++pass < 2);
|
} while (~rflags & R_HAVERI && ++pass < 2);
|
||||||
|
|
||||||
for (qptr = apolys; qptr < pptr; ++qptr) {
|
for (qptr = apolys; qptr < pptr; ++qptr) {
|
||||||
|
|
|
@ -2739,7 +2739,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// read uid to generate a filename for the key file
|
// read uid to generate a filename for the key file
|
||||||
char suffix[FILE_PATH_SIZE];
|
char suffix[FILE_PATH_SIZE + strlen(outfilename)];
|
||||||
if (outfnlen) {
|
if (outfnlen) {
|
||||||
snprintf(suffix, sizeof(suffix) - strlen(outfilename), "-key-%s.bin", outfilename);
|
snprintf(suffix, sizeof(suffix) - strlen(outfilename), "-key-%s.bin", outfilename);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue