diff --git a/ropgadget_patternfinder.c b/ropgadget_patternfinder.c index ecb1974..567dafe 100644 --- a/ropgadget_patternfinder.c +++ b/ropgadget_patternfinder.c @@ -277,11 +277,24 @@ int locate_pattern() { int ret=0; size_t pos, i; - unsigned int found, found2; + unsigned int found=0, found2=0; unsigned int tmpval, tmpval2; + unsigned char *tmpbuf = NULL; unsigned char calchash[0x20]; + if(patterntype==0 && patternmask) + { + tmpbuf = malloc(hashblocksize); + if(tmpbuf==NULL) + { + printf("Failed to alloc tmpbuf in locate_pattern().\n"); + return 8; + } + + memset(tmpbuf, 0, hashblocksize); + } + for(pos=0; pos Selects the pattern-type, which must be one of the following(this option is required): sha256 or datacmp. sha256: Hash every --patternsha256size bytes in the binary, for locating the target pattern. The input bindata(sha256 hash) size must be 0x20-bytes.\n"); printf("--patterndata= Pattern data to use during searching the binary, see --patterntype.\n"); - printf("--patterndatamask= Mask data to use with pattern-type datacmp. The byte-size can be less than the size of patterndata as well. The data loaded from the filebuf is &= with this mask data.\n"); + printf("--patterndatamask= Mask data to use with the data loaded from the file. The byte-size can be less than the size of patterndata / patternsha256size as well. The data loaded from the filebuf is &= with this mask data.\n"); printf("--patternsha256size=0x See --patterntype.\n"); printf("--stride=0x 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"); printf("--findtarget=0x Stop searching once this number of matches were found, by default this is 0x1. When this is 0x0, this will not stop until the end of the binary is reached.\n");