diff options
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | docs/ChangeLog | 2 | ||||
-rwxr-xr-x | qemu_mode/build_qemu_support.sh | 5 | ||||
-rwxr-xr-x | unicorn_mode/build_unicorn_support.sh | 67 |
4 files changed, 62 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml index 9ff3edef..4569bd9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ language: c env: - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_STOP_MANUALLY=1 - - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_EXIT_WHEN_DONE=1 + # - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_EXIT_WHEN_DONE=1 # TODO: test AFL_BENCH_UNTIL_CRASH once we have a target that crashes - - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_BENCH_JUST_ONE=1 + # - AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_UI=1 AFL_BENCH_JUST_ONE=1 before_install: - sudo apt update diff --git a/docs/ChangeLog b/docs/ChangeLog index 3924226e..7bc6dec4 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -25,6 +25,8 @@ Version ++2.58d (dev): - libcompcov floating point splitting support for qemu and unicorn - Dockerfile by courtesy of devnexen - ripped regex.dictionary from Google afl PR + - qemu and unicorn download scripts now try to download until the full + download succeeded. f*ckin travis fails downloading 40% of the time! - removed unnecessary warnings diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index 6b9f91f9..c3983aa1 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -100,7 +100,10 @@ if [ ! "$CKSUM" = "$QEMU_SHA384" ]; then echo "[*] Downloading QEMU ${VERSION} from the web..." rm -f "$ARCHIVE" - wget -O "$ARCHIVE" -- "$QEMU_URL" || exit 1 + OK= + while [ -z "$OK" ]; do + wget -c -O "$ARCHIVE" -- "$QEMU_URL" && OK=1 + done CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1` diff --git a/unicorn_mode/build_unicorn_support.sh b/unicorn_mode/build_unicorn_support.sh index 3bd404b8..589ab852 100755 --- a/unicorn_mode/build_unicorn_support.sh +++ b/unicorn_mode/build_unicorn_support.sh @@ -43,9 +43,11 @@ echo echo "[*] Performing basic sanity checks..." -if [ ! "`uname -s`" = "Linux" ]; then +PLT=`uname -s` - echo "[-] Error: Unicorn instrumentation is supported only on Linux." +if [ ! "$PLT" = "Linux" ] && [ ! "$PLT" = "Darwin" ] && [ ! "$PLT" = "FreeBSD" ] && [ ! "$PLT" = "NetBSD" ] && [ ! "$PLT" = "OpenBSD" ]; then + + echo "[-] Error: Unicorn instrumentation is unsupported on $PLT." exit 1 fi @@ -64,7 +66,43 @@ if [ ! -f "../afl-showmap" ]; then fi -for i in wget python automake autoconf sha384sum; do +if [ "$PLT" = "Linux" ]; then + CKSUMCMD='sha384sum --' + PYTHONBIN=python2 + MAKECMD=make + CORES=`nproc` + TARCMD=tar + EASY_INSTALL=easy_install +fi + +if [ "$PLT" = "Darwin" ]; then + CKSUMCMD="shasum -a 384" + PYTHONBIN=python2.7 + MAKECMD=make + CORES=`sysctl hw.ncpu | cut -d' ' -f2` + TARCMD=tar + EASY_INSTALL=easy_install-2.7 +fi + +if [ "$PLT" = "FreeBSD" ]; then + CKSUMCMD="sha384 -q" + PYTHONBIN=python2.7 + MAKECMD=gmake + CORES=`sysctl hw.ncpu | cut -d' ' -f2` + TARCMD=gtar + EASY_INSTALL=easy_install-2.7 +fi + +if [ "$PLT" = "NetBSD" ] || [ "$PLT" = "OpenBSD" ]; then + CKSUMCMD="cksum -a sha384 -q" + PYTHONBIN=python2.7 + MAKECMD=gmake + CORES=`sysctl hw.ncpu | cut -d' ' -f2` + TARCMD=gtar + EASY_INSTALL=easy_install-2.7 +fi + +for i in wget $PYTHONBIN automake autoconf $MAKECMD $TARCMD; do T=`which "$i" 2>/dev/null` @@ -77,10 +115,10 @@ for i in wget python automake autoconf sha384sum; do done -if ! which easy_install > /dev/null; then +if ! which $EASY_INSTALL > /dev/null; then # work around for unusual installs - if [ '!' -e /usr/lib/python2.7/dist-packages/easy_install.py ]; then + if [ '!' -e /usr/lib/python2.7/dist-packages/easy_install.py ] && [ '!' -e /usr/local/lib/python2.7/dist-packages/easy_install.py ] && [ '!' -e /usr/pkg/lib/python2.7/dist-packages/easy_install.py ]; then echo "[-] Error: Python setup-tools not found. Run 'sudo apt-get install python-setuptools'." exit 1 @@ -100,15 +138,18 @@ echo "[+] All checks passed!" ARCHIVE="`basename -- "$UNICORN_URL"`" -CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1` +CKSUM=`$CKSUMCMD "$ARCHIVE" 2>/dev/null | cut -d' ' -f1` if [ ! "$CKSUM" = "$UNICORN_SHA384" ]; then echo "[*] Downloading Unicorn v1.0.1 from the web..." rm -f "$ARCHIVE" - wget -O "$ARCHIVE" -- "$UNICORN_URL" || exit 1 + OK= + while [ -z "$OK" ]; do + wget -c -O "$ARCHIVE" -- "$UNICORN_URL" && OK=1 + done - CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1` + CKSUM=`$CKSUMCMD "$ARCHIVE" 2>/dev/null | cut -d' ' -f1` fi @@ -127,7 +168,7 @@ echo "[*] Uncompressing archive (this will take a while)..." rm -rf "unicorn" || exit 1 mkdir "unicorn" || exit 1 -tar xzf "$ARCHIVE" -C ./unicorn --strip-components=1 || exit 1 +$TARCMD xzf "$ARCHIVE" -C ./unicorn --strip-components=1 || exit 1 echo "[+] Unpacking successful." @@ -149,7 +190,7 @@ echo "[+] Configuration complete." echo "[*] Attempting to build Unicorn (fingers crossed!)..." -UNICORN_QEMU_FLAGS='--python=python2' make -j `nproc` || exit 1 +UNICORN_QEMU_FLAGS="--python=$PYTHONBIN" $MAKECMD -j$CORES || exit 1 echo "[+] Build process successful!" @@ -157,10 +198,10 @@ echo "[*] Installing Unicorn python bindings..." cd bindings/python || exit 1 if [ -z "$VIRTUAL_ENV" ]; then echo "[*] Info: Installing python unicorn using --user" - python setup.py install --user || exit 1 + $PYTHONBIN setup.py install --user || exit 1 else echo "[*] Info: Installing python unicorn to virtualenv: $VIRTUAL_ENV" - python setup.py install || exit 1 + $PYTHONBIN setup.py install || exit 1 fi export LIBUNICORN_PATH='$(pwd)' # in theory, this allows to switch between afl-unicorn and unicorn so files. @@ -175,7 +216,7 @@ cd ../samples/simple || exit 1 # Run afl-showmap on the sample application. If anything comes out then it must have worked! unset AFL_INST_RATIO -echo 0 | ../../../afl-showmap -U -m none -q -o .test-instr0 -- python simple_test_harness.py ./sample_inputs/sample1.bin || exit 1 +echo 0 | ../../../afl-showmap -U -m none -q -o .test-instr0 -- $PYTHONBIN simple_test_harness.py ./sample_inputs/sample1.bin || exit 1 if [ -s .test-instr0 ] then |