1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
american fuzzy lop++ - LD_PRELOAD for fuzzing argv in binaries
------------------------------------------------------------
Copyright 2019-2022 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);
}
|