aboutsummaryrefslogtreecommitdiff
path: root/src/afl-showmap.c
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2019-09-18 10:22:55 +0200
committerGitHub <noreply@github.com>2019-09-18 10:22:55 +0200
commitb55ea6409dfcadf3c43244fb8e72ea660fd4fcc2 (patch)
tree8c2a81fde3312449b18cff1ab6ce27432db6e3e2 /src/afl-showmap.c
parent68b3849d51e94e394334305b8ab7e4f613a8bbb9 (diff)
parent5e56d3bf368df07d964de769aa5142ad98536330 (diff)
downloadafl++-b55ea6409dfcadf3c43244fb8e72ea660fd4fcc2.tar.gz
Merge pull request #60 from vanhauser-thc/wine_mode
Wine mode
Diffstat (limited to 'src/afl-showmap.c')
-rw-r--r--src/afl-showmap.c86
1 files changed, 21 insertions, 65 deletions
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index bf9306d5..0720a234 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -64,7 +64,6 @@ u8* trace_bits; /* SHM with instrumentation bitmap */
static u8 *out_file, /* Trace output file */
*doc_path, /* Path to docs */
- *target_path, /* Path to target binary */
*at_file; /* Substitution string for @@ */
static u32 exec_tmout; /* Exec timeout (ms) */
@@ -419,6 +418,7 @@ static void usage(u8* argv0) {
" -m megs - memory limit for child process (%d MB)\n"
" -Q - use binary-only instrumentation (QEMU mode)\n"
" -U - use Unicorn-based instrumentation (Unicorn mode)\n"
+ " -W - use qemu-based instrumentation with Wine (Wine mode)\n"
" (Not necessary, here for consistency with other afl-* "
"tools)\n\n"
@@ -493,77 +493,18 @@ static void find_binary(u8* fname) {
}
-/* Fix up argv for QEMU. */
-
-static char** get_qemu_argv(u8* own_loc, char** argv, int argc) {
-
- char** new_argv = ck_alloc(sizeof(char*) * (argc + 4));
- u8 * tmp, *cp, *rsl, *own_copy;
-
- memcpy(new_argv + 3, argv + 1, sizeof(char*) * argc);
-
- new_argv[2] = target_path;
- new_argv[1] = "--";
-
- /* Now we need to actually find qemu for argv[0]. */
-
- tmp = getenv("AFL_PATH");
-
- if (tmp) {
-
- cp = alloc_printf("%s/afl-qemu-trace", tmp);
-
- if (access(cp, X_OK)) FATAL("Unable to find '%s'", tmp);
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- own_copy = ck_strdup(own_loc);
- rsl = strrchr(own_copy, '/');
-
- if (rsl) {
-
- *rsl = 0;
-
- cp = alloc_printf("%s/afl-qemu-trace", own_copy);
- ck_free(own_copy);
-
- if (!access(cp, X_OK)) {
-
- target_path = new_argv[0] = cp;
- return new_argv;
-
- }
-
- } else
-
- ck_free(own_copy);
-
- if (!access(BIN_PATH "/afl-qemu-trace", X_OK)) {
-
- target_path = new_argv[0] = BIN_PATH "/afl-qemu-trace";
- return new_argv;
-
- }
-
- FATAL("Unable to find 'afl-qemu-trace'.");
-
-}
-
/* Main entry point */
int main(int argc, char** argv) {
s32 opt;
- u8 mem_limit_given = 0, timeout_given = 0, qemu_mode = 0, unicorn_mode = 0;
+ u8 mem_limit_given = 0, timeout_given = 0, qemu_mode = 0, unicorn_mode = 0, use_wine = 0;
u32 tcnt = 0;
char** use_argv;
doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH;
- while ((opt = getopt(argc, argv, "+o:m:t:A:eqZQUbcrh")) > 0)
+ while ((opt = getopt(argc, argv, "+o:m:t:A:eqZQUWbcrh")) > 0)
switch (opt) {
@@ -671,6 +612,16 @@ int main(int argc, char** argv) {
unicorn_mode = 1;
break;
+ case 'W': /* Wine+QEMU mode */
+
+ if (use_wine) FATAL("Multiple -W options not supported");
+ qemu_mode = 1;
+ use_wine = 1;
+
+ if (!mem_limit_given) mem_limit = 0;
+
+ break;
+
case 'b':
/* Secret undocumented mode. Writes output in raw binary format
@@ -719,9 +670,14 @@ int main(int argc, char** argv) {
detect_file_args(argv + optind, at_file);
- if (qemu_mode)
- use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
- else
+ if (qemu_mode) {
+
+ if (use_wine)
+ use_argv = get_wine_argv(argv[0], argv + optind, argc - optind);
+ else
+ use_argv = get_qemu_argv(argv[0], argv + optind, argc - optind);
+
+ } else
use_argv = argv + optind;
run_target(use_argv);