1#!/bin/sh 2 3. ./test-pre.sh 4 5$ECHO "$BLUE[*] Testing: nyx_mode" 6 7test "$CI" = "true" && { 8 $ECHO "$YELLOW[-] nyx_mode cannot be tested in the Github CI, skipping ..." 9 exit 0 10} 11 12unset AFL_CC 13 14test -e ../libnyx.so && { 15 ../afl-cc -o test-instr ../test-instr.c > errors 2>&1 16 test -e test-instr && { 17 { 18 rm -rf nyx-test in out 19 $ECHO "$GREY[*] running nyx_packer" 20 python3 ../nyx_mode/packer/packer/nyx_packer.py \ 21 ./test-instr \ 22 nyx-test \ 23 afl \ 24 instrumentation \ 25 --fast_reload_mode \ 26 --purge > /dev/null 2>&1 27 28 test -e nyx-test/test-instr && { 29 30 $ECHO "$GREY[*] running nyx_config_gen" 31 python3 ../nyx_mode/packer/packer/nyx_config_gen.py nyx-test Kernel > /dev/null 2>&1 32 33 test -e nyx-test/config.ron && { 34 sudo modprobe -r kvm-intel 35 sudo modprobe -r kvm 36 sudo modprobe kvm enable_vmware_backdoor=y 37 sudo modprobe kvm-intel 38 #cat /sys/module/kvm/parameters/enable_vmware_backdoor 39 40 mkdir -p in 41 echo 00000 > in/in 42 $ECHO "$GREY[*] running afl-fuzz for nyx_mode, this will take approx 10 seconds" 43 { 44 AFL_DEBUG=1 ../afl-fuzz -i in -o out -V05 -X -- ./nyx-test >>errors 2>&1 45 } >>errors 2>&1 46 test -n "$( ls out/default/queue/id:000002* 2>/dev/null )" && { 47 $ECHO "$GREEN[+] afl-fuzz is working correctly with nyx_mode" 48 RUNTIME=`grep execs_done out/default/fuzzer_stats | awk '{print$3}'` 49 rm -rf errors nyx-test test-instr in out 50 } || { 51 echo CUT------------------------------------------------------------------CUT 52 cat errors 53 echo CUT------------------------------------------------------------------CUT 54 $ECHO "$RED[!] afl-fuzz is not working correctly with nyx_mode" 55 CODE=1 56 } 57 } || { 58 $ECHO "$RED[!] nyx_packer failed, likely install requirements not met." 59 CODE=1 60 } 61 } || { 62 $ECHO "$RED[!] nyx_packer failed, likely install requirements not met." 63 CODE=1 64 } 65 #rm -rf test-instr in out errors nyx-test 66 } 67 } || { 68 echo CUT------------------------------------------------------------------CUT 69 cat errors 70 echo CUT------------------------------------------------------------------CUT 71 $ECHO "$RED[!] afl-cc compilation of test targets failed - what is going on??" 72 CODE=1 73 } 74} || { 75 $ECHO "$YELLOW[-] nyx_mode is not compiled, cannot test" 76 INCOMPLETE=1 77} 78 79. ./test-post.sh 80