diff --git a/ropgadget_patternfinder.c b/ropgadget_patternfinder.c index 9550674..1f0aaf0 100644 --- a/ropgadget_patternfinder.c +++ b/ropgadget_patternfinder.c @@ -7,6 +7,17 @@ //Build with: gcc -o ropgadget_patternfinder ropgadget_patternfinder.c -lcrypto +int patterntype = -1; +unsigned int findtarget=1; +unsigned int stride = 4; +unsigned int baseaddr = 0; +int plainout = 0; +unsigned char *filebuf = NULL, *patterndata = NULL, *patternmask = NULL; +size_t filebufsz=0, hashblocksize=0; +size_t patterndata_size=0, patternmask_size=0; + +char line_prefix[256]; + int load_bindata(char *arg, unsigned char **buf, unsigned int *size) { int i; @@ -94,20 +105,91 @@ int load_bindata(char *arg, unsigned char **buf, unsigned int *size) return 0; } +int locate_pattern() +{ + int ret; + size_t pos, i; + unsigned int found, found2; + unsigned int tmpval, tmpval2; + + unsigned char calchash[0x20]; + + for(pos=0; pos below can be either hex with any byte-length(unless specified otherwise), or '@' followed by a file-path to load the data from."); + printf(" below can be either hex with any byte-length(unless specified otherwise), or '@' followed by a file-path to load the data from.\n"); printf("Usage:\n"); printf("ropgadget_patternfinder \n"); printf("Options:\n"); @@ -126,12 +208,15 @@ int main(int argc, char **argv) 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"); printf("--baseaddr=0x This is the value which is added to the located offset when printing it, by default this is 0x0.\n"); + printf("--plainout[=] Only print the located offset/address, unless an error occurs. If '=' is specified, print that before printing the located offset/address.\n"); return 0; } ret = 0; + memset(line_prefix, 0, sizeof(line_prefix)); + for(argi=2; argi