Skip to content

Instantly share code, notes, and snippets.

@bnagy bnagy/afl-pause.sh
Last active Mar 20, 2018

Embed
What would you like to do?
#!/bin/sh
#
# american fuzzy lop - pause a set of fuzzers
# --------------------------------------
#
# By @rantyben, based on afl-whatsup, which is:
# Written and maintained by Michal Zalewski <lcamtuf@google.com>
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This pauses all live fuzzers in the given output directory using
# SIGSTOP
echo "afl-pause - pause fuzzers"
echo
DIR="$1"
if [ "$DIR" = "" ]; then
echo "Usage: $0 afl_sync_dir" 1>&2
echo 1>&2
exit 1
fi
cd "$DIR" || exit 1
if [ -d queue ]; then
echo "[-] Error: parameter is an individual output directory, not a sync dir." 1>&2
exit 1
fi
TMP=`mktemp -t .afl-whatsup-XXXXXXXX` || exit 1
ALIVE_CNT=0
DEAD_CNT=0
for i in `find . -maxdepth 2 -iname fuzzer_stats`; do
sed 's/^command_line.*$/_skip:1/;s/[ ]*:[ ]*/="/;s/$/"/' "$i" >"$TMP"
. "$TMP"
if ! kill -0 "$fuzzer_pid" 2>/dev/null; then
echo "Instance is dead or running remotely, skipping."
echo
DEAD_CNT=$((DEAD_CNT + 1))
continue
fi
ALIVE_CNT=$((ALIVE_CNT + 1))
if ! kill -STOP "$fuzzer_pid" 2>/dev/null; then
echo "Unable to pause fuzzer pid $fuzzer_pid, aborting."
echo
exit 1
fi
done
rm -f "$TMP"
echo "Fuzzers paused: $ALIVE_CNT"
if [ ! "$DEAD_CNT" = "0" ]; then
echo "Dead or remote: $DEAD_CNT (excluded from stats)"
fi
exit 0
#!/bin/sh
#
# american fuzzy lop - resume a set of fuzzers
# --------------------------------------
#
# By @rantyben, based on afl-whatsup, which is:
# Written and maintained by Michal Zalewski <lcamtuf@google.com>
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This resumes all live fuzzers in the given output directory using
# SIGCONT
echo "afl-resume - resume fuzzers"
echo
DIR="$1"
if [ "$DIR" = "" ]; then
echo "Usage: $0 afl_sync_dir" 1>&2
echo 1>&2
exit 1
fi
cd "$DIR" || exit 1
if [ -d queue ]; then
echo "[-] Error: parameter is an individual output directory, not a sync dir." 1>&2
exit 1
fi
TMP=`mktemp -t .afl-whatsup-XXXXXXXX` || exit 1
ALIVE_CNT=0
DEAD_CNT=0
for i in `find . -maxdepth 2 -iname fuzzer_stats`; do
sed 's/^command_line.*$/_skip:1/;s/[ ]*:[ ]*/="/;s/$/"/' "$i" >"$TMP"
. "$TMP"
if ! kill -0 "$fuzzer_pid" 2>/dev/null; then
echo "Instance is dead or running remotely, skipping."
echo
DEAD_CNT=$((DEAD_CNT + 1))
continue
fi
ALIVE_CNT=$((ALIVE_CNT + 1))
if ! kill -CONT "$fuzzer_pid" 2>/dev/null; then
echo "Unable to stop fuzzer pid $fuzzer_pid, aborting."
echo
exit 1
fi
done
rm -f "$TMP"
echo "Fuzzers resumed: $ALIVE_CNT"
if [ ! "$DEAD_CNT" = "0" ]; then
echo "Dead or remote: $DEAD_CNT (excluded from stats)"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.