mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 01:58:17 +00:00
cleanup
This commit is contained in:
@ -26,15 +26,16 @@ import shutil
|
|||||||
with open(".clang-format") as f:
|
with open(".clang-format") as f:
|
||||||
fmt = f.read()
|
fmt = f.read()
|
||||||
|
|
||||||
CURRENT_LLVM = os.getenv('LLVM_VERSION', 14)
|
#CURRENT_LLVM = os.getenv('LLVM_VERSION', 14)
|
||||||
CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "")
|
#CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "")
|
||||||
|
|
||||||
if shutil.which(CLANG_FORMAT_BIN) is None:
|
#if shutil.which(CLANG_FORMAT_BIN) is None:
|
||||||
CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}"
|
# CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}"
|
||||||
|
|
||||||
if shutil.which(CLANG_FORMAT_BIN) is None:
|
#if shutil.which(CLANG_FORMAT_BIN) is None:
|
||||||
print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.")
|
# print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.")
|
||||||
exit(1)
|
# exit(1)
|
||||||
|
CLANG_FORMAT_BIN = "clang-format"
|
||||||
|
|
||||||
COLUMN_LIMIT = 80
|
COLUMN_LIMIT = 80
|
||||||
for line in fmt.split("\n"):
|
for line in fmt.split("\n"):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# argvfuzz
|
#argvfuzz
|
||||||
|
|
||||||
AFL++ supports fuzzing file inputs or stdin. When source is available,
|
AFL++ supports fuzzing file inputs or stdin. When source is available,
|
||||||
`argv-fuzz-inl.h` can be used to change `main()` to build argv from stdin.
|
`argv-fuzz-inl.h` can be used to change `main()` to build argv from stdin.
|
||||||
@ -13,4 +13,4 @@ A few conditions need to be fulfilled for this mechanism to work correctly:
|
|||||||
2. If the target binary does not use the default libc's `_start` implementation
|
2. If the target binary does not use the default libc's `_start` implementation
|
||||||
(crt1.o), the hook may not run.
|
(crt1.o), the hook may not run.
|
||||||
3. The hook will replace argv with pointers to `.data` of `argvfuzz.so`. If the
|
3. The hook will replace argv with pointers to `.data` of `argvfuzz.so`. If the
|
||||||
target binary expects argv to be living on the stack, things may go wrong.
|
target binary expects argv to be living on the stack, things may go wrong.
|
||||||
|
@ -57,18 +57,20 @@
|
|||||||
\
|
\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define AFL_INIT_ARGV_PERSISTENT(persistent_buff) \
|
#define AFL_INIT_ARGV_PERSISTENT(persistent_buff) \
|
||||||
do { \
|
do { \
|
||||||
argv = afl_init_argv_persistent(&argc, persistent_buff); \
|
\
|
||||||
} while (0)
|
argv = afl_init_argv_persistent(&argc, persistent_buff); \
|
||||||
|
\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define AFL_INIT_SET0_PERSISTENT(_p, persistent_buff) \
|
#define AFL_INIT_SET0_PERSISTENT(_p, persistent_buff) \
|
||||||
do { \
|
do { \
|
||||||
\
|
\
|
||||||
argv = afl_init_argv_persistent(&argc, persistent_buff); \
|
argv = afl_init_argv_persistent(&argc, persistent_buff); \
|
||||||
argv[0] = (_p); \
|
argv[0] = (_p); \
|
||||||
if (!argc) argc = 1; \
|
if (!argc) argc = 1; \
|
||||||
\
|
\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define MAX_CMDLINE_LEN 100000
|
#define MAX_CMDLINE_LEN 100000
|
||||||
@ -105,12 +107,13 @@ static char **afl_init_argv(int *argc) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **afl_init_argv_persistent(int *argc, unsigned char *persistent_buff) {
|
static char **afl_init_argv_persistent(int *argc,
|
||||||
|
unsigned char *persistent_buff) {
|
||||||
|
|
||||||
static char *ret[MAX_CMDLINE_PAR];
|
static char *ret[MAX_CMDLINE_PAR];
|
||||||
|
|
||||||
unsigned char *ptr = persistent_buff;
|
unsigned char *ptr = persistent_buff;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
while (*ptr && rc < MAX_CMDLINE_PAR) {
|
while (*ptr && rc < MAX_CMDLINE_PAR) {
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "argv-fuzz-inl.h"
|
#include "argv-fuzz-inl.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
// Initialize the argv array for use with the AFL (American Fuzzy Lop) tool
|
// Initialize the argv array for use with the AFL (American Fuzzy Lop) tool
|
||||||
AFL_INIT_ARGV();
|
AFL_INIT_ARGV();
|
||||||
|
|
||||||
@ -12,12 +13,16 @@ int main(int argc, char **argv) {
|
|||||||
an error message is printed. If the values do match, the program
|
an error message is printed. If the values do match, the program
|
||||||
calls the abort() function. */
|
calls the abort() function. */
|
||||||
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
|
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
|
||||||
if (strcmp(argv[2], "TEST2") == 0) {
|
|
||||||
abort();
|
if (strcmp(argv[2], "TEST2") == 0) { abort(); }
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
printf("Bad number of arguments!\n");
|
printf("Bad number of arguments!\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ __AFL_FUZZ_INIT();
|
|||||||
one of the arguments.
|
one of the arguments.
|
||||||
*/
|
*/
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
#ifdef __AFL_HAVE_MANUAL_CONTROL
|
#ifdef __AFL_HAVE_MANUAL_CONTROL
|
||||||
__AFL_INIT();
|
__AFL_INIT();
|
||||||
#endif
|
#endif
|
||||||
@ -25,6 +26,7 @@ int main(int argc, char **argv) {
|
|||||||
the loop and allowing the program to terminate. It protects against
|
the loop and allowing the program to terminate. It protects against
|
||||||
accidental memory leaks and similar issues. */
|
accidental memory leaks and similar issues. */
|
||||||
while (__AFL_LOOP(100000)) {
|
while (__AFL_LOOP(100000)) {
|
||||||
|
|
||||||
int len = __AFL_FUZZ_TESTCASE_LEN;
|
int len = __AFL_FUZZ_TESTCASE_LEN;
|
||||||
|
|
||||||
// Check that the length of the test case is at least 8 bytes
|
// Check that the length of the test case is at least 8 bytes
|
||||||
@ -37,13 +39,20 @@ int main(int argc, char **argv) {
|
|||||||
If so, call the "abort" function to terminate the program.
|
If so, call the "abort" function to terminate the program.
|
||||||
Otherwise, print an error message. */
|
Otherwise, print an error message. */
|
||||||
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
|
if (argc > 1 && strcmp(argv[1], "XYZ") == 0) {
|
||||||
|
|
||||||
if (strcmp(argv[2], "TEST2") == 0) { abort(); }
|
if (strcmp(argv[2], "TEST2") == 0) { abort(); }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
printf("Bad number of arguments!\n");
|
printf("Bad number of arguments!\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exiting the loop allows the program to terminate normally. AFL will restart
|
/* Exiting the loop allows the program to terminate normally. AFL will restart
|
||||||
the process with a clean slate for allocated memory, file descriptors, etc.
|
the process with a clean slate for allocated memory, file descriptors, etc.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user