This commit is contained in:
iceman1001 2018-02-03 23:15:14 +01:00
commit 7c8de64c57

View file

@ -37,7 +37,6 @@ int split(char *str, char *arr[MAX_ARGS]){
char *tmp = calloc(len + 1, sizeof(char)); char *tmp = calloc(len + 1, sizeof(char));
memcpy(tmp, &str[beginIndex], len); memcpy(tmp, &str[beginIndex], len);
arr[wordCnt++] = tmp; arr[wordCnt++] = tmp;
//PrintAndLog("cnt: %d, %s",wordCnt-1, arr[wordCnt-1]);
beginIndex = endIndex; beginIndex = endIndex;
if (wordCnt == maxWords) if (wordCnt == maxWords)
break; break;
@ -59,7 +58,6 @@ int CmdCrc(const char *Cmd)
} else { } else {
reveng_main(argc, argv); reveng_main(argc, argv);
} }
//PrintAndLog("DEBUG argc: %d, %s %s Cmd: %s",argc, argv[0], Cmd2, Cmd);
for(int i = 0; i < argc; ++i) { for(int i = 0; i < argc; ++i) {
free(argv[i]); free(argv[i]);
} }
@ -262,11 +260,11 @@ int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *res
SETBMP(); SETBMP();
//set model //set model
if (!(c = mbynam(&model, inModel))) { if (!(c = mbynam(&model, inModel))) {
PrintAndLog("error: preset model '%s' not found. Use reveng -D to list presets.", inModel); PrintAndLog("[!] error: preset model '%s' not found. Use reveng -D to list presets.", inModel);
return 0; return 0;
} }
if (c < 0) if (c < 0)
return uerr("no preset models available"); return uerr("[-] no preset models available");
rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX; rflags |= R_HAVEP | R_HAVEI | R_HAVERI | R_HAVERO | R_HAVEX;
@ -378,7 +376,7 @@ int CmdrevengTestC(const char *Cmd){
int ans = RunModel(inModel, inHexStr, reverse, endian, result); int ans = RunModel(inModel, inHexStr, reverse, endian, result);
if (!ans) return 0; if (!ans) return 0;
PrintAndLog("Result: %s",result); PrintAndLog("[+] result: %s",result);
return 1; return 1;
} }
@ -434,15 +432,15 @@ int CmdrevengSearch(const char *Cmd){
ans = RunModel(Models[i], outHex, false, 0, result); ans = RunModel(Models[i], outHex, false, 0, result);
if (ans) { if (ans) {
// test for match // test for match
if (memcmp(result, inCRC, crcChars)==0){ if (memcmp(result, inCRC, crcChars) == 0){
PrintAndLog("\nFound a possible match!\nModel: %s\nValue: %s\n",Models[i], result); PrintAndLog("\n[+] found possible match\n[+] model: %s | value: %s\n", Models[i], result);
//optional - stop searching if found... //optional - stop searching if found...
found = true; found = true;
} else { } else {
if (crcChars > 2){ if (crcChars > 2){
char *swapEndian = SwapEndianStr(result, crcChars, crcChars); char *swapEndian = SwapEndianStr(result, crcChars, crcChars);
if (memcmp(swapEndian, inCRC, crcChars)==0){ if (memcmp(swapEndian, inCRC, crcChars) == 0){
PrintAndLog("\nFound a possible match!\nModel: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian); PrintAndLog("\n[+] found possible match\n[+] model: %s | value endian swapped: %s\n", Models[i], swapEndian);
// optional - stop searching if found... // optional - stop searching if found...
found = true; found = true;
} }
@ -450,20 +448,18 @@ int CmdrevengSearch(const char *Cmd){
} }
} }
} }
// if (!found){
ans = RunModel(Models[i], outHex, true, 0, revResult); ans = RunModel(Models[i], outHex, true, 0, revResult);
if (ans) { if (ans) {
// test for match // test for match
if (memcmp(revResult, inCRC, crcChars)==0){ if (memcmp(revResult, inCRC, crcChars) == 0){
PrintAndLog("\nFound a possible match!\nModel Reversed: %s\nValue: %s\n",Models[i], revResult); PrintAndLog("\n[+] found possible match\n[+] model reversed: %s | value: %s\n", Models[i], revResult);
// optional - stop searching if found... // optional - stop searching if found...
found = true; found = true;
} else { } else {
if (crcChars > 2){ if (crcChars > 2){
char *swapEndian = SwapEndianStr(revResult, crcChars, crcChars); char *swapEndian = SwapEndianStr(revResult, crcChars, crcChars);
if (memcmp(swapEndian, inCRC, crcChars)==0){ if (memcmp(swapEndian, inCRC, crcChars) == 0){
PrintAndLog("\nFound a possible match!\nModel Reversed: %s\nValue EndianSwapped: %s\n",Models[i], swapEndian); PrintAndLog("\n[+] found possible match\n[+] model reversed: %s | value endian swapped: %s\n", Models[i], swapEndian);
// optional - stop searching if found... // optional - stop searching if found...
found = true; found = true;
} }
@ -471,12 +467,11 @@ int CmdrevengSearch(const char *Cmd){
} }
} }
} }
// }
free(inCRC); free(inCRC);
free(outHex); free(outHex);
free(Models[i]); free(Models[i]);
} }
if (!found) PrintAndLog("\nNo matches found\n"); if (!found) PrintAndLog("\n[-] no matches found\n");
return 1; return 1;
} }