Implemented --stride.

This commit is contained in:
yellows8 2015-06-05 21:33:26 -04:00
parent 39c9794d64
commit 0af74215db

View File

@ -106,6 +106,7 @@ int main(int argc, char **argv)
unsigned char *inhashptr; unsigned char *inhashptr;
size_t filebufsz=0, pos, hashblocksize=0; size_t filebufsz=0, pos, hashblocksize=0;
unsigned int tmpsize=0; unsigned int tmpsize=0;
unsigned int stride = 4;
struct stat filestat; struct stat filestat;
FILE *fbin; FILE *fbin;
@ -119,6 +120,7 @@ int main(int argc, char **argv)
printf("Options:\n"); printf("Options:\n");
printf("--patternsha256=<bindata> Hash every --patternsha256size bytes in the binary, for locating the target pattern. The input bindata(sha256 hash) size must be 0x20-bytes.\n"); printf("--patternsha256=<bindata> Hash every --patternsha256size bytes in the binary, for locating the target pattern. The input bindata(sha256 hash) size must be 0x20-bytes.\n");
printf("--patternsha256size=0x<hexval> See --patternsha256.\n"); printf("--patternsha256size=0x<hexval> See --patternsha256.\n");
printf("--stride=0x<hexval> In the search loop, this is the value that the pos is increased by at the end of each interation. By default this is 0x4.\n");
return 0; return 0;
} }
@ -149,6 +151,11 @@ int main(int argc, char **argv)
hashblocksize = tmpsize; hashblocksize = tmpsize;
} }
if(strncmp(argv[argi], "--stride=", 9)==0)
{
sscanf(&argv[argi][9], "0x%x", &stride);
}
if(ret!=0)break; if(ret!=0)break;
} }
@ -201,7 +208,7 @@ int main(int argc, char **argv)
found = 0; found = 0;
ret = 0; ret = 0;
for(pos=0; pos<filebufsz; pos+=4) for(pos=0; pos<filebufsz; pos+=stride)
{ {
if(filebufsz - pos < hashblocksize)break; if(filebufsz - pos < hashblocksize)break;