Skip to content

Get AFL up and running in a couple minutes and see how fast your computer really is!

License

Notifications You must be signed in to change notification settings

grimm-co/afl-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# This file will show you what you need to do to run the benchmark.
# If you are feeling lazy, you can just run `bash README`
VERSION=2.51b


### This section is just figuring out what package manager your
### Linux distrubution has so the dependencies can be installed
PKGMGR='NULL'

#
# Detect Package Manager
#
# APT
which apt &> /dev/null
if [ $? = 0 ] && [ $PKGMGR = 'NULL' ]; then
	PKGMGR='APT'
	echo 'Package manager detected: Using apt'
fi
# DNF
which dnf &> /dev/null
if [ $? = 0 ] && [ $PKGMGR = 'NULL' ]; then
	PKGMGR='DNF'
	echo 'Package manager detected: Using dnf'
fi
# YUM
which yum &> /dev/null
if [ $? = 0 ] && [ $PKGMGR = 'NULL' ]; then
	PKGMGR='YUM'
	echo 'Package manager detected: Using yum'
fi

# Check for unknown package manager
if [ $PKGMGR = 'NULL' ]
then
	echo 'Your package manager is not supported for an automated install.'
	echo 'Please consider submitting a patch for your package manager or'
	echo 'contact the developers.'
	exit 1
fi

### We use sudo when it is available, as it means entering a password only once
SUDO=`which sudo`
if [[ "$SUDO" != "" ]]; then
	echo "When propmted for a password, it's your password (and you'll need sudo rights)"
else
	echo "When propmted for a password, it's the root password"
fi

#
# Install all dependencies up front
#
case $PKGMGR in
	APT)
		$SUDO su -c "apt install llvm clang golang-go gnuplot make"
		;;
	DNF)
		$SUDO su -c "dnf install llvm clang llvm-devel golang gnuplot make"
		;;
	YUM)
		$SUDO su -c "yum install llvm clang llvm-devel golang gnuplot make"
		;;
esac


### Now that the dependencies are installed, we can move on to the more interesting stuff
#
# Extract and compile AFL
#
tar zxf afl-$VERSION.tgz
cd afl-$VERSION/
make
cd llvm_mode/
make
cd ../..

#
# Compile afl-launch
#
# If you have internet access:
#git clone https://github.com/bnagy/afl-launch
# If not:
tar -Jxf afl-launch.tar.xz
cd afl-launch
go build
cd ..

# Extract and compile the target (tar)
cd targets/
tar Jxf tar-1.29.tar.xz 
cd tar-1.29/
AFL_HARDEN=1 CC=`pwd`/../../afl-$VERSION/afl-clang-fast ./configure
AFL_HARDEN=1 CC=`pwd`/../../afl-$VERSION/afl-clang-fast make
cd ../..

# tar is going to completely screw over the permissions of the cwd, so we need
# to take precautions...
mkdir -p run
chmod 755 run
cd run

# Prep for running AFL:
# chattr +i makes the run directory immutable, so you can't chmod it (otherwise tar can change permissions on ".")
$SUDO su -c "chattr +i .; echo core >/proc/sys/kernel/core_pattern; cd /sys/devices/system/cpu; echo performance | tee cpu*/cpufreq/scaling_governor"

# Test AFL to make sure it's working properly
mkdir -p ../output
../afl-$VERSION/afl-fuzz -i ../afl-$VERSION/testcases/archives/common/tar/ -o ../output/tar_test -- ../targets/tar-1.29/src/tar -x
# It might throw errors about the kernel throttling the CPU.
# If it does, it'll tell you have to fix in.
# Once everything is fixed and you are sure AFL is working
# properly, we're finally ready to do the benchmarking!

NUMPROCS=`cat /proc/cpuinfo | grep processor | wc -l`
PATH=$PATH:`pwd`/../afl-$VERSION
../afl-launch/afl-launch -no-master -n "$NUMPROCS" -i ../afl-$VERSION/testcases/archives/common/tar/ -o ../output/tar -- ../targets/tar-1.29/src/tar -x
cd ..
echo "Chill for a few minutes while AFL does its thing"
sleep $((60*3))  # Wait 3 minutes

# Monitor statistics with afl-whatsup and afl-plot
./afl-$VERSION/afl-whatsup -s ./output/tar
mkdir -p fake_output
./combine_plot_data.py -o ./fake_output/plot_data -d 30 ./output/tar/*/plot_data
./afl-$VERSION/afl-plot fake_output ./plot_output
firefox ./plot_output/index.html

# If you start the benchmark over, remember to clean out the
# "output" directory first, or your stats will be all wrong

# For comparison:
# AMD Opteron(TM) Processor 6274 => ~11,100 executions per second
# That's a 16-core CPU @ 2.2GHz running 16 instances of AFL

# AMD Opteron(tm) Processor 6386 SE => ~13,700 executions per second
# That's a 16-core CPU @ 2.8GHz running 16 instances of AFL

# Intel(R) Core(TM) i7-5600U CPU => ~4,250 executions per second
# That's a 2 physical core/4 logical core CPU @ 2.60GHz running 4 instances fo AFL

# Quad-CPU Operton(TM) Processor 6276 = ~34,000 executions per second
# This is a computer with four 16-core CPUs running @ 2.3GHz, 64 instancs of AFL

About

Get AFL up and running in a couple minutes and see how fast your computer really is!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages