mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-08 16:21:32 +00:00
Unicorn mode for BSD proposal.
Darwin fix
This commit is contained in:
parent
e2442f7471
commit
a09cfd57a4
@ -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,39 @@ 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
|
||||
TARCMD=tar
|
||||
EASY_INSTALL=easy_install
|
||||
fi
|
||||
|
||||
if [ "$PLT" = "Darwin" ]; then
|
||||
CKSUMCMD="shasum -a 384"
|
||||
PYTHONBIN=python2.7
|
||||
MAKECMD=make
|
||||
TARCMD=tar
|
||||
EASY_INSTALL=easy_install-2.7
|
||||
fi
|
||||
|
||||
if [ "$PLT" = "FreeBSD" ]; then
|
||||
CKSUMCMD="sha384 -q"
|
||||
PYTHONBIN=python2.7
|
||||
MAKECMD=gmake
|
||||
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
|
||||
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 +111,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,7 +134,7 @@ 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
|
||||
|
||||
@ -108,7 +142,7 @@ if [ ! "$CKSUM" = "$UNICORN_SHA384" ]; then
|
||||
rm -f "$ARCHIVE"
|
||||
wget -O "$ARCHIVE" -- "$UNICORN_URL" || exit 1
|
||||
|
||||
CKSUM=`sha384sum -- "$ARCHIVE" 2>/dev/null | cut -d' ' -f1`
|
||||
CKSUM=`CKSUMCMD "$ARCHIVE" 2>/dev/null | cut -d' ' -f1`
|
||||
|
||||
fi
|
||||
|
||||
@ -127,7 +161,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 +183,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 -j4 || exit 1
|
||||
|
||||
echo "[+] Build process successful!"
|
||||
|
||||
@ -157,10 +191,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 +209,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user