chg: 'hf mf fchk' - depth first search

This commit is contained in:
iceman1001
2017-12-11 21:43:29 +01:00
parent da57e74140
commit dd024b5300
5 changed files with 84 additions and 54 deletions

View File

@@ -418,6 +418,24 @@ int CmdAnalyseTEASelfTest(const char *Cmd){
int CmdAnalyseA(const char *Cmd){
bool term = !isatty(STDIN_FILENO);
if (!term) {
char star[4];
star[0] = '-';
star[1] = '\\';
star[2] = '|';
star[4] = '/';
for (uint8_t k=0; k<5; k = (k+1) % 4 ) {
printf("\e[s%c\e[u", star[k]);
fflush(stdout);
if (ukbhit()) {
int gc = getchar(); (void)gc;
break;
}
}
}
//piwi
// uid(2e086b1a) nt(230736f6) ks(0b0008000804000e) nr(000000000)
// uid(2e086b1a) nt(230736f6) ks(0e0b0e0b090c0d02) nr(000000001)

View File

@@ -13,6 +13,7 @@
#include <stdlib.h> //size_t
#include <string.h>
#include <unistd.h>
#include "cmdmain.h"
#include "proxmark3.h"
#include "ui.h" // PrintAndLog

View File

@@ -89,10 +89,10 @@ int GetModels(char *Models[], int *count, uint8_t *width){
int Cnt = 0;
if (width[0] == 0) { //reveng -D
*count = mcount();
if(!*count)
if (!*count)
return uerr("no preset models available");
for(int mode = 0; mode < *count; ++mode) {
for (int mode = 0; mode < *count; ++mode) {
mbynum(&model, mode);
mcanon(&model);
size_t size = (model.name && *model.name) ? strlen(model.name) : 6;
@@ -107,20 +107,20 @@ int GetModels(char *Models[], int *count, uint8_t *width){
mfree(&model);
} else { //reveng -s
if(~model.flags & P_MULXN)
if (~model.flags & P_MULXN)
return uerr("cannot search for non-Williams compliant models");
praloc(&model.spoly, (unsigned long)width[0]);
praloc(&model.init, (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]);
else
width[0] = (uint8_t)plen(model.spoly);
/* special case if qpoly is zero, search to end of range */
if(!ptst(qpoly))
if (!ptst(qpoly))
rflags &= ~R_HAVEQ;
/* if endianness not specified, try
@@ -135,7 +135,7 @@ int GetModels(char *Models[], int *count, uint8_t *width){
do {
psets = mcount();
while(psets) {
while (psets) {
mbynum(&pset, --psets);
/* skip if different width, or refin or refout don't match */

View File

@@ -1272,7 +1272,7 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
if ( keyitems - keycnt < 2) {
p = realloc(keyBlock, 6 * (keyitems += 64));
if (!p) {
PrintAndLog("Cannot allocate memory for defKeys");
PrintAndLog("Cannot allocate memory for default keys");
free(keyBlock);
fclose(f);
return 2;
@@ -1372,11 +1372,11 @@ int CmdHF14AMfChk_fast(const char *Cmd) {
// all keys?
if ( curr_keys == SectorsCnt*2 || lastChunk ) {
memcpy(e_sector, resp.d.asBytes, SectorsCnt * sizeof(icesector_t) );
break;
goto out;
}
}
}
out:
t1 = msclock() - t1;
PrintAndLog("[+] Time in checkkeys (fast): %.1fs\n", (float)(t1/1000.0));