mirror of
https://github.com/Savapitech/42sh.git
synced 2026-01-18 16:57:28 +01:00
Add afl
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -40,5 +40,8 @@ result
|
||||
testcmd
|
||||
unit_tests
|
||||
|
||||
# Python (CI)
|
||||
*.pyc
|
||||
# Debug
|
||||
.dbug
|
||||
|
||||
# AFL
|
||||
afl/generated
|
||||
|
||||
26
Makefile
26
Makefile
@@ -70,6 +70,7 @@ endef
|
||||
$(eval $(call mk-profile, release, SRC, , $(BIN_NAME)))
|
||||
$(eval $(call mk-profile, debug, SRC, -D U_DEBUG_MODE -g3, debug))
|
||||
$(eval $(call mk-profile, test, SRC, --coverage, test))
|
||||
$(eval $(call mk-profile, afl, SRC, -D AFL_MODE, afl_runner))
|
||||
|
||||
all: $(NAME_release)
|
||||
|
||||
@@ -85,6 +86,31 @@ cov: tests_run
|
||||
--exclude-unreachable-branches \
|
||||
--exclude tests
|
||||
|
||||
.PHONY: afl
|
||||
afl: CC := AFL_USE_ASAN=1 afl-gcc-fast
|
||||
afl: $(NAME_afl)
|
||||
|
||||
define newline
|
||||
|
||||
|
||||
endef
|
||||
|
||||
AFL_FLAGS := -i afl/inputs
|
||||
AFL_FLAGS += -x afl/tokens
|
||||
AFL_FLAGS += -o afl/generated
|
||||
|
||||
PROCS ?= $(shell nproc)
|
||||
|
||||
.PHONY: afl_run
|
||||
afl_run: afl
|
||||
@ mkdir -p afl/generated
|
||||
screen -dmS main_instance \
|
||||
afl-fuzz $(AFL_FLAGS) -M fuzzer_1 -- ./afl_runner
|
||||
$(foreach instance, $(shell seq 1 $(PROCS)),\
|
||||
screen -dmS afl_$(instance) \
|
||||
afl-fuzz $(AFL_FLAGS) -S fuzzer_$(instance) -- ./afl_runner$(newline))
|
||||
watch -n 0.25 -- afl-whatsup -s afl/generated
|
||||
|
||||
clean:
|
||||
@ $(RM) $(OBJ)
|
||||
@ $(LOG_TIME) "$(C_YELLOW) RM $(C_PURPLE) $(OBJ) $(C_RESET)"
|
||||
|
||||
4
afl/inputs/commands
Normal file
4
afl/inputs/commands
Normal file
@@ -0,0 +1,4 @@
|
||||
hi
|
||||
cd
|
||||
ls
|
||||
env
|
||||
7
afl/tokens/tokens
Normal file
7
afl/tokens/tokens
Normal file
@@ -0,0 +1,7 @@
|
||||
... ~ / \t
|
||||
abc def ghi
|
||||
jkl mno pqr
|
||||
stu vw xyz
|
||||
!! ? - = !=
|
||||
& >> << < >
|
||||
012 345 678 9
|
||||
@@ -146,6 +146,9 @@ int launch_bin(char *full_bin_path, char **args, env_t *env, char *buff)
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid == 0) {
|
||||
#if defined(AFL_MODE)
|
||||
exit(0);
|
||||
#else
|
||||
if (execve(full_bin_path, args, env->env) < 0) {
|
||||
status = command_error(full_bin_path, args, errno);
|
||||
free_env(env);
|
||||
@@ -153,6 +156,7 @@ int launch_bin(char *full_bin_path, char **args, env_t *env, char *buff)
|
||||
free(buff);
|
||||
exit(status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
waitpid(pid, &status, 0);
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user