nyx test for CI

This commit is contained in:
vanhauser-thc
2024-01-30 15:06:34 +01:00
parent d5b6c0f773
commit 9604fe922e
5 changed files with 87 additions and 1 deletions

View File

@ -124,6 +124,9 @@ void bind_to_free_cpu(afl_state_t *afl) {
} }
WARNF("Not binding to a CPU core (AFL_NO_AFFINITY set)."); WARNF("Not binding to a CPU core (AFL_NO_AFFINITY set).");
#ifdef __linux__
if (afl->fsrv.nyx_mode) { afl->fsrv.nyx_bind_cpu_id = 0; }
#endif
return; return;
} }
@ -151,6 +154,9 @@ void bind_to_free_cpu(afl_state_t *afl) {
} else { } else {
OKF("CPU binding request using -b %d successful.", afl->cpu_to_bind); OKF("CPU binding request using -b %d successful.", afl->cpu_to_bind);
#ifdef __linux__
if (afl->fsrv.nyx_mode) { afl->fsrv.nyx_bind_cpu_id = afl->cpu_to_bind; }
#endif
} }

View File

@ -1915,6 +1915,15 @@ int main(int argc, char **argv_orig, char **envp) {
bind_to_free_cpu(afl); bind_to_free_cpu(afl);
#endif /* HAVE_AFFINITY */ #endif /* HAVE_AFFINITY */
#ifdef __linux__
if (afl->fsrv.nyx_mode && afl->fsrv.nyx_bind_cpu_id == 0xFFFFFFFF) {
afl->fsrv.nyx_bind_cpu_id = 0;
}
#endif
#ifdef __HAIKU__ #ifdef __HAIKU__
/* Prioritizes performance over power saving */ /* Prioritizes performance over power saving */
set_scheduler_mode(SCHEDULER_MODE_LOW_LATENCY); set_scheduler_mode(SCHEDULER_MODE_LOW_LATENCY);

View File

@ -16,6 +16,8 @@
. ./test-frida-mode.sh . ./test-frida-mode.sh
. ./test-nyx-mode.sh
. ./test-unicorn-mode.sh . ./test-unicorn-mode.sh
. ./test-custom-mutators.sh . ./test-custom-mutators.sh

69
test/test-nyx-mode.sh Executable file
View File

@ -0,0 +1,69 @@
#!/bin/sh
. ./test-pre.sh
$ECHO "$BLUE[*] Testing: nyx_mode"
test -e ../libnyx.so && {
../afl-cc -o test-instr ../test-instr.c >/dev/null 2>&1
test -e test-instr && {
{
rm -rf nyx-test in out
$ECHO "$GREY[*] running nyx_packer"
python3 ../nyx_mode/packer/packer/nyx_packer.py \
./test-instr \
nyx-test \
afl \
instrumentation \
--fast_reload_mode \
--purge > /dev/null 2>&1
test -e nyx-test/test-instr && {
$ECHO "$GREY[*] running nyx_config_gen"
python3 ../nyx_mode/packer/packer/nyx_config_gen.py nyx-test Kernel > /dev/null 2>&1
test -e nyx-test/config.ron && {
sudo modprobe -r kvm-intel
sudo modprobe -r kvm
sudo modprobe kvm enable_vmware_backdoor=y
sudo modprobe kvm-intel
#cat /sys/module/kvm/parameters/enable_vmware_backdoor
mkdir -p in
echo 00000 > in/in
$ECHO "$GREY[*] running afl-fuzz for nyx_mode, this will take approx 10 seconds"
{
AFL_DEBUG=1 ../afl-fuzz -i in -o out -V05 -X -- ./nyx-test >>errors 2>&1
} >>errors 2>&1
test -n "$( ls out/default/queue/id:000002* 2>/dev/null )" && {
$ECHO "$GREEN[+] afl-fuzz is working correctly with nyx_mode"
RUNTIME=`grep execs_done out/default/fuzzer_stats | awk '{print$3}'`
rm -rf errors nyx-test test-instr in out
} || {
echo CUT------------------------------------------------------------------CUT
cat errors
echo CUT------------------------------------------------------------------CUT
$ECHO "$RED[!] afl-fuzz is not working correctly with nyx_mode"
CODE=1
}
} || {
$ECHO "$RED[!] nyx_packer failed, likely install requirements not met."
CODE=1
}
} || {
$ECHO "$RED[!] nyx_packer failed, likely install requirements not met."
CODE=1
}
#rm -rf test-instr in out errors nyx-test
}
} || {
$ECHO "$RED[!] afl-cc compilation of test targets failed - what is going on??"
CODE=1
}
} || {
$ECHO "$YELLOW[-] nyx_mode is not compiled, cannot test"
INCOMPLETE=1
}
. ./test-post.sh

View File

@ -20,7 +20,7 @@ echo foobar | grep -qE 'asd|oob' 2>/dev/null || { echo Error: grep command does
test -e ./test-all.sh || cd $(dirname $0) || exit 1 test -e ./test-all.sh || cd $(dirname $0) || exit 1
test -e ./test-all.sh || { echo Error: you must be in the test/ directory ; exit 1 ; } test -e ./test-all.sh || { echo Error: you must be in the test/ directory ; exit 1 ; }
export AFL_PATH=`pwd`/.. export AFL_PATH=`pwd`/..
export AFL_NO_AFFINITY=1 # workaround for travis that fails for no avail cores export AFL_TRY_AFFINITY=1 # workaround for travis that fails for no avail cores
echo 1 > test.1 echo 1 > test.1
echo 1 > test.2 echo 1 > test.2