From 7867e610b5cffd2c0749703eca1333bdd7840824 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 1 Mar 2018 13:20:26 +0100 Subject: added -S switch, make install, updated README --- afl-dyninst.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'afl-dyninst.cpp') diff --git a/afl-dyninst.cpp b/afl-dyninst.cpp index 787fb18..2f12fc1 100644 --- a/afl-dyninst.cpp +++ b/afl-dyninst.cpp @@ -30,13 +30,14 @@ set < string > runtimeLibraries; int bbSkip = 0, dynfix = 0; unsigned int bbMinSize = 1; bool skipMainModule = false; +char *skipFunc = NULL; BPatch_function *save_rdi; BPatch_function *restore_rdi; const char *instLibrary = "libAflDyninst.so"; -static const char *OPT_STR = "fi:o:l:e:vs:dr:m:"; +static const char *OPT_STR = "fi:o:l:e:vs:dr:m:S:"; static const char *USAGE = " -i -o -l -e
-s -m \n \ -i: Input binary \n \ -o: Output binary\n \ @@ -47,6 +48,7 @@ static const char *USAGE = " -i -o -l -e
- -s: Number of basic blocks to skip\n \ -m: minimum size of a basic bock to instrument (default: 1)\n \ -f: try to fix crashes\n \ + -S: do not instrument this function (can be specified only once)\n \ -v: Verbose output\n"; bool parseOptions(int argc, char **argv) { @@ -54,6 +56,9 @@ bool parseOptions(int argc, char **argv) { while ((c = getopt(argc, argv, OPT_STR)) != -1) { switch ((char) c) { + case 'S': + skipFunc = optarg; + break; case 'e': entryPoint = strtoul(optarg, NULL, 16);; break; @@ -181,7 +186,7 @@ bool insertBBCallback(BPatch_binaryEdit *appBin, BPatch_function *curFunc, char randID = rand() % USHRT_MAX; if (verbose) { - cout << "Instrumenting Basic Block 0x" << hex << address << " of " << funcName << " of size " << dec << (*iter)->size() << " with random id " << randID << endl; + cout << "Instrumenting Basic Block 0x" << hex << address << " of " << funcName << " with size " << dec << (*iter)->size() << " with random id " << randID << "/0x" << hex << randID << endl; } BPatch_Vector < BPatch_snippet * >instArgs1; @@ -322,6 +327,11 @@ int main(int argc, char **argv) { curFunc->getName(funcName, 1024); if (string(funcName) == string("_start")) continue; // here's a bug on hlt // XXX: check what happens if removed + if (skipFunc != NULL && strcmp(skipFunc, funcName) == 0) { + if (verbose) + cout << "Skipping instrumenting function " << funcName << endl; + continue; + } insertBBCallback(appBin, curFunc, funcName, bbCallback, &bbIndex); } } -- cgit 1.4.1