diff options
author | van Hauser <vh@thc.org> | 2019-12-24 20:16:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-24 20:16:39 +0100 |
commit | 3122790295489dee77ffc9993561807fe09be3b8 (patch) | |
tree | 267de04c9450d6f7a7fbb999fa353b4bc5217551 /experimental/argv_fuzzing/argvfuzz.c | |
parent | b0a2160c3ab97956855cb448d312beefdcfe2abd (diff) | |
parent | 5aa089d1b22b092a2cc2e797abe755a717f0afc4 (diff) | |
download | afl++-3122790295489dee77ffc9993561807fe09be3b8.tar.gz |
Merge pull request #152 from afflux/argvfuzz
argvfuzz preload for fuzzing binaries' argv
Diffstat (limited to 'experimental/argv_fuzzing/argvfuzz.c')
-rw-r--r-- | experimental/argv_fuzzing/argvfuzz.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/experimental/argv_fuzzing/argvfuzz.c b/experimental/argv_fuzzing/argvfuzz.c new file mode 100644 index 00000000..65fb5e13 --- /dev/null +++ b/experimental/argv_fuzzing/argvfuzz.c @@ -0,0 +1,49 @@ +/* + american fuzzy lop - LD_PRELOAD for fuzzing argv in binaries + ------------------------------------------------------------ + + Copyright 2019 Kjell Braden <afflux@pentabarf.de> + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + + */ + +#define _GNU_SOURCE /* for RTLD_NEXT */ +#include <dlfcn.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include "argv-fuzz-inl.h" + +int __libc_start_main(int (*main)(int, char **, char **), int argc, char **argv, + void (*init)(void), void (*fini)(void), + void (*rtld_fini)(void), void *stack_end) { + + int (*orig)(int (*main)(int, char **, char **), int argc, char **argv, + void (*init)(void), void (*fini)(void), void (*rtld_fini)(void), + void *stack_end); + int sub_argc; + char **sub_argv; + + (void)argc; + (void)argv; + + orig = dlsym(RTLD_NEXT, __func__); + + if (!orig) { + + fprintf(stderr, "hook did not find original %s: %s\n", __func__, dlerror()); + exit(EXIT_FAILURE); + + } + + sub_argv = afl_init_argv(&sub_argc); + + return orig(main, sub_argc, sub_argv, init, fini, rtld_fini, stack_end); + +} + |