diff options
author | Joey Jiao <joeyjiaojg@163.com> | 2021-01-14 14:16:17 +0800 |
---|---|---|
committer | Joey Jiao <joeyjiaojg@163.com> | 2021-01-20 15:46:41 +0800 |
commit | 868ef6c10c8137e0085789452a84435cd6b72f2f (patch) | |
tree | 41b71a9965f930424542c4d89320dc3af4ce1253 | |
parent | 52f1d535bd8a40698e8446786b134d6629700713 (diff) | |
download | afl++-868ef6c10c8137e0085789452a84435cd6b72f2f.tar.gz |
android: afl_frida: get target lib/function from command line
-rw-r--r-- | utils/afl_frida/afl-frida.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index b5b8196d..89a5b932 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -153,7 +153,7 @@ static int enumerate_ranges(const GumRangeDetails *details, } -int main() { +int main(int argc, char** argv) { #ifndef __APPLE__ (void)personality(ADDR_NO_RANDOMIZE); // disable ASLR @@ -164,17 +164,32 @@ int main() { // If there is just one function, then there is nothing to change // or add here. - void *dl = dlopen(TARGET_LIBRARY, RTLD_LAZY); + void *dl = NULL; + if (argc > 2) { + dl = dlopen(argv[1], RTLD_LAZY); + } else { + dl = dlopen(TARGET_LIBRARY, RTLD_LAZY); + } if (!dl) { - fprintf(stderr, "Could not load %s\n", TARGET_LIBRARY); + if (argc > 2) + fprintf(stderr, "Could not load %s\n", argv[1]); + else + fprintf(stderr, "Could not load %s\n", TARGET_LIBRARY); exit(-1); } - if (!(o_function = dlsym(dl, TARGET_FUNCTION))) { + if (argc > 2) + o_function = dlsym(dl, argv[2]); + else + o_function = dlsym(dl, TARGET_FUNCTION); + if (!o_function) { - fprintf(stderr, "Could not find function %s\n", TARGET_FUNCTION); + if (argc > 2) + fprintf(stderr, "Could not find function %s\n", argv[2]); + else + fprintf(stderr, "Could not find function %s\n", TARGET_FUNCTION); exit(-1); } |