mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-20 05:23:43 +00:00
Added support for graphical command line flag, improved the general organization of script
Script works as "intended"
This commit is contained in:
244
afl-plot
244
afl-plot
@ -22,16 +22,21 @@ get_abs_path() {
|
|||||||
echo "progress plotting utility for afl-fuzz by Michal Zalewski"
|
echo "progress plotting utility for afl-fuzz by Michal Zalewski"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ ! "$#" = "2" ]; then
|
if ( [ "$#" != "2" ] && [ "$#" != "3" ] ) || ( [ "$#" = "3" ] && [ "$3" != "-g" ] && [ "$3" != "--graphical" ] ); then
|
||||||
|
|
||||||
cat 1>&2 <<_EOF_
|
cat 1>&2 <<_EOF_
|
||||||
$0 afl_state_dir graph_output_dir
|
$0 afl_state_dir graph_output_dir [ -g | --graphical ]
|
||||||
|
|
||||||
This program generates gnuplot images from afl-fuzz output data. Usage:
|
This program generates gnuplot images from afl-fuzz output data.
|
||||||
|
|
||||||
The afl_state_dir parameter should point to an existing state directory for any
|
Usage:
|
||||||
active or stopped instance of afl-fuzz; while graph_output_dir should point to
|
|
||||||
an empty directory where this tool can write the resulting plots to.
|
afl_state_dir should point to an existing state directory for any
|
||||||
|
active or stopped instance of afl-fuzz
|
||||||
|
graph_output_dir should point to an empty directory where this
|
||||||
|
tool can write the resulting plots to
|
||||||
|
-g, --graphical (optional) display the plots in a graphical window
|
||||||
|
(requires GTK as a dependency)
|
||||||
|
|
||||||
The program will put index.html and three PNG images in the output directory;
|
The program will put index.html and three PNG images in the output directory;
|
||||||
you should be able to view it with any web browser of your choice.
|
you should be able to view it with any web browser of your choice.
|
||||||
@ -102,10 +107,92 @@ fi
|
|||||||
rm -f "$outputdir/high_freq.png" "$outputdir/low_freq.png" "$outputdir/exec_speed.png" "$outputdir/edges.png"
|
rm -f "$outputdir/high_freq.png" "$outputdir/low_freq.png" "$outputdir/exec_speed.png" "$outputdir/edges.png"
|
||||||
mv -f "$outputdir/index.html" "$outputdir/index.html.orig" 2>/dev/null
|
mv -f "$outputdir/index.html" "$outputdir/index.html.orig" 2>/dev/null
|
||||||
|
|
||||||
mkdir -p "$outputdir/tmp"
|
GNUPLOT_SETUP="
|
||||||
/usr/local/bin/afl-plot-ui > "$outputdir/tmp/win_ids" &
|
#set xdata time
|
||||||
|
#set timefmt '%s'
|
||||||
|
#set format x \"%b %d\n%H:%M\"
|
||||||
|
set tics font 'small'
|
||||||
|
unset mxtics
|
||||||
|
unset mytics
|
||||||
|
|
||||||
sleep 1
|
set grid xtics linetype 0 linecolor rgb '#e0e0e0'
|
||||||
|
set grid ytics linetype 0 linecolor rgb '#e0e0e0'
|
||||||
|
set border linecolor rgb '#50c0f0'
|
||||||
|
set tics textcolor rgb '#000000'
|
||||||
|
set key outside
|
||||||
|
|
||||||
|
set autoscale xfixmin
|
||||||
|
set autoscale xfixmax
|
||||||
|
|
||||||
|
set xlabel \"relative time in seconds\" font \"small\"
|
||||||
|
"
|
||||||
|
|
||||||
|
PLOT_HF="
|
||||||
|
set terminal png truecolor enhanced size 1000,300 butt
|
||||||
|
set output '$outputdir/high_freq.png'
|
||||||
|
|
||||||
|
$GNUPLOT_SETUP
|
||||||
|
|
||||||
|
plot '$inputdir/plot_data' using 1:4 with filledcurve x1 title 'total paths' linecolor rgb '#000000' fillstyle transparent solid 0.2 noborder, \\
|
||||||
|
'' using 1:3 with filledcurve x1 title 'current path' linecolor rgb '#f0f0f0' fillstyle transparent solid 0.5 noborder, \\
|
||||||
|
'' using 1:5 with lines title 'pending paths' linecolor rgb '#0090ff' linewidth 3, \\
|
||||||
|
'' using 1:6 with lines title 'pending favs' linecolor rgb '#c00080' linewidth 3, \\
|
||||||
|
'' using 1:2 with lines title 'cycles done' linecolor rgb '#c000f0' linewidth 3
|
||||||
|
"
|
||||||
|
|
||||||
|
PLOT_LF="
|
||||||
|
set terminal png truecolor enhanced size 1000,200 butt
|
||||||
|
set output '$outputdir/low_freq.png'
|
||||||
|
|
||||||
|
$GNUPLOT_SETUP
|
||||||
|
|
||||||
|
plot '$inputdir/plot_data' using 1:8 with filledcurve x1 title '' linecolor rgb '#c00080' fillstyle transparent solid 0.2 noborder, \\
|
||||||
|
'' using 1:8 with lines title ' uniq crashes' linecolor rgb '#c00080' linewidth 3, \\
|
||||||
|
'' using 1:9 with lines title 'uniq hangs' linecolor rgb '#c000f0' linewidth 3, \\
|
||||||
|
'' using 1:10 with lines title 'levels' linecolor rgb '#0090ff' linewidth 3
|
||||||
|
"
|
||||||
|
|
||||||
|
PLOT_ES="
|
||||||
|
set terminal png truecolor enhanced size 1000,200 butt
|
||||||
|
set output '$outputdir/exec_speed.png'
|
||||||
|
|
||||||
|
$GNUPLOT_SETUP
|
||||||
|
|
||||||
|
plot '$inputdir/plot_data' using 1:11 with filledcurve x1 title '' linecolor rgb '#0090ff' fillstyle transparent solid 0.2 noborder, \\
|
||||||
|
'$inputdir/plot_data' using 1:11 with lines title ' execs/sec' linecolor rgb '#0090ff' linewidth 3 smooth bezier;
|
||||||
|
"
|
||||||
|
|
||||||
|
PLOT_EG="
|
||||||
|
set terminal png truecolor enhanced size 1000,300 butt
|
||||||
|
set output '$outputdir/edges.png'
|
||||||
|
|
||||||
|
$GNUPLOT_SETUP
|
||||||
|
|
||||||
|
plot '$inputdir/plot_data' using 1:13 with lines title ' edges' linecolor rgb '#0090ff' linewidth 3
|
||||||
|
"
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$#" = "3" ] && ( [ "$3" = "-g" ] || [ "$3" = "--graphical" ] ); then
|
||||||
|
|
||||||
|
afl-plot-ui -h > /dev/null 2>&1
|
||||||
|
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
|
||||||
|
cat 1>&2 <<_EOF_
|
||||||
|
You do not seem to have the afl-plot-ui utility installed. If you have installed afl-plot-ui, make sure the afl-plot-ui executable is in your PATH.
|
||||||
|
If you are still facing any problems, please open an issue at https://github.com/AFLplusplus/AFLplusplus/issues.
|
||||||
|
|
||||||
|
No plots have been generated. Please rerun without the "-g" or "--graphical" flag to generate the plots.
|
||||||
|
_EOF_
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$outputdir/tmp"
|
||||||
|
afl-plot-ui > "$outputdir/tmp/win_ids" &
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
W_ID1=$(cat $outputdir/tmp/win_ids | head -1)
|
W_ID1=$(cat $outputdir/tmp/win_ids | head -1)
|
||||||
W_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1)
|
W_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1)
|
||||||
@ -117,38 +204,11 @@ echo "[*] Generating plots..."
|
|||||||
(
|
(
|
||||||
|
|
||||||
cat << _EOF_
|
cat << _EOF_
|
||||||
set terminal png truecolor enhanced size 1000,300 butt
|
|
||||||
|
|
||||||
set output '$outputdir/high_freq.png'
|
|
||||||
|
|
||||||
#set xdata time
|
|
||||||
#set timefmt '%s'
|
|
||||||
#set format x "%b %d\n%H:%M"
|
|
||||||
set tics font 'small'
|
|
||||||
unset mxtics
|
|
||||||
unset mytics
|
|
||||||
|
|
||||||
set grid xtics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set grid ytics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set border linecolor rgb '#50c0f0'
|
|
||||||
set tics textcolor rgb '#000000'
|
|
||||||
set key outside
|
|
||||||
|
|
||||||
set autoscale xfixmin
|
|
||||||
set autoscale xfixmax
|
|
||||||
|
|
||||||
set xlabel "relative time in seconds" font "small"
|
|
||||||
|
|
||||||
plot '$inputdir/plot_data' using 1:4 with filledcurve x1 title 'total paths' linecolor rgb '#000000' fillstyle transparent solid 0.2 noborder, \\
|
|
||||||
'' using 1:3 with filledcurve x1 title 'current path' linecolor rgb '#f0f0f0' fillstyle transparent solid 0.5 noborder, \\
|
|
||||||
'' using 1:5 with lines title 'pending paths' linecolor rgb '#0090ff' linewidth 3, \\
|
|
||||||
'' using 1:6 with lines title 'pending favs' linecolor rgb '#c00080' linewidth 3, \\
|
|
||||||
'' using 1:2 with lines title 'cycles done' linecolor rgb '#c000f0' linewidth 3
|
|
||||||
|
|
||||||
|
$PLOT_HF
|
||||||
set term x11 window "$W_ID3"
|
set term x11 window "$W_ID3"
|
||||||
set output
|
set output
|
||||||
replot
|
replot
|
||||||
|
|
||||||
pause mouse close
|
pause mouse close
|
||||||
|
|
||||||
_EOF_
|
_EOF_
|
||||||
@ -158,36 +218,11 @@ _EOF_
|
|||||||
(
|
(
|
||||||
|
|
||||||
cat << _EOF_
|
cat << _EOF_
|
||||||
#set xdata time
|
|
||||||
#set timefmt '%s'
|
|
||||||
#set format x "%b %d\n%H:%M"
|
|
||||||
set tics font 'small'
|
|
||||||
unset mxtics
|
|
||||||
unset mytics
|
|
||||||
|
|
||||||
set grid xtics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set grid ytics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set border linecolor rgb '#50c0f0'
|
|
||||||
set tics textcolor rgb '#000000'
|
|
||||||
set key outside
|
|
||||||
|
|
||||||
set autoscale xfixmin
|
|
||||||
set autoscale xfixmax
|
|
||||||
|
|
||||||
set xlabel "relative time in seconds" font "small"
|
|
||||||
|
|
||||||
set terminal png truecolor enhanced size 1000,200 butt
|
|
||||||
set output '$outputdir/low_freq.png'
|
|
||||||
|
|
||||||
plot '$inputdir/plot_data' using 1:8 with filledcurve x1 title '' linecolor rgb '#c00080' fillstyle transparent solid 0.2 noborder, \\
|
|
||||||
'' using 1:8 with lines title ' uniq crashes' linecolor rgb '#c00080' linewidth 3, \\
|
|
||||||
'' using 1:9 with lines title 'uniq hangs' linecolor rgb '#c000f0' linewidth 3, \\
|
|
||||||
'' using 1:10 with lines title 'levels' linecolor rgb '#0090ff' linewidth 3
|
|
||||||
|
|
||||||
|
$PLOT_LF
|
||||||
set term x11 window "$W_ID4"
|
set term x11 window "$W_ID4"
|
||||||
set output
|
set output
|
||||||
replot
|
replot
|
||||||
|
|
||||||
pause mouse close
|
pause mouse close
|
||||||
|
|
||||||
_EOF_
|
_EOF_
|
||||||
@ -197,34 +232,11 @@ _EOF_
|
|||||||
(
|
(
|
||||||
|
|
||||||
cat << _EOF_
|
cat << _EOF_
|
||||||
#set xdata time
|
|
||||||
#set timefmt '%s'
|
|
||||||
#set format x "%b %d\n%H:%M"
|
|
||||||
set tics font 'small'
|
|
||||||
unset mxtics
|
|
||||||
unset mytics
|
|
||||||
|
|
||||||
set grid xtics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set grid ytics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set border linecolor rgb '#50c0f0'
|
|
||||||
set tics textcolor rgb '#000000'
|
|
||||||
set key outside
|
|
||||||
|
|
||||||
set autoscale xfixmin
|
|
||||||
set autoscale xfixmax
|
|
||||||
|
|
||||||
set xlabel "relative time in seconds" font "small"
|
|
||||||
|
|
||||||
set terminal png truecolor enhanced size 1000,200 butt
|
|
||||||
set output '$outputdir/exec_speed.png'
|
|
||||||
|
|
||||||
plot '$inputdir/plot_data' using 1:11 with filledcurve x1 title '' linecolor rgb '#0090ff' fillstyle transparent solid 0.2 noborder, \\
|
|
||||||
'$inputdir/plot_data' using 1:11 with lines title ' execs/sec' linecolor rgb '#0090ff' linewidth 3 smooth bezier;
|
|
||||||
|
|
||||||
|
$PLOT_ES
|
||||||
set term x11 window "$W_ID2"
|
set term x11 window "$W_ID2"
|
||||||
set output
|
set output
|
||||||
replot
|
replot
|
||||||
|
|
||||||
pause mouse close
|
pause mouse close
|
||||||
|
|
||||||
_EOF_
|
_EOF_
|
||||||
@ -234,33 +246,11 @@ _EOF_
|
|||||||
(
|
(
|
||||||
|
|
||||||
cat << _EOF_
|
cat << _EOF_
|
||||||
#set xdata time
|
|
||||||
#set timefmt '%s'
|
|
||||||
#set format x "%b %d\n%H:%M"
|
|
||||||
set tics font 'small'
|
|
||||||
unset mxtics
|
|
||||||
unset mytics
|
|
||||||
|
|
||||||
set grid xtics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set grid ytics linetype 0 linecolor rgb '#e0e0e0'
|
|
||||||
set border linecolor rgb '#50c0f0'
|
|
||||||
set tics textcolor rgb '#000000'
|
|
||||||
set key outside
|
|
||||||
|
|
||||||
set autoscale xfixmin
|
|
||||||
set autoscale xfixmax
|
|
||||||
|
|
||||||
set xlabel "relative time in seconds" font "small"
|
|
||||||
|
|
||||||
set terminal png truecolor enhanced size 1000,300 butt
|
|
||||||
set output '$outputdir/edges.png'
|
|
||||||
|
|
||||||
plot '$inputdir/plot_data' using 1:13 with lines title ' edges' linecolor rgb '#0090ff' linewidth 3
|
|
||||||
|
|
||||||
|
$PLOT_EG
|
||||||
set term x11 window "$W_ID1"
|
set term x11 window "$W_ID1"
|
||||||
set output
|
set output
|
||||||
replot
|
replot
|
||||||
|
|
||||||
pause mouse close
|
pause mouse close
|
||||||
|
|
||||||
_EOF_
|
_EOF_
|
||||||
@ -269,6 +259,34 @@ _EOF_
|
|||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
rm "$outputdir/tmp/win_ids"
|
||||||
|
|
||||||
|
if [ -z "$(ls -A $outputdir/tmp)" ]; then
|
||||||
|
rm -r "$outputdir/tmp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "[*] Generating plots..."
|
||||||
|
|
||||||
|
(
|
||||||
|
|
||||||
|
cat << _EOF_
|
||||||
|
|
||||||
|
$PLOT_HF
|
||||||
|
|
||||||
|
$PLOT_LF
|
||||||
|
|
||||||
|
$PLOT_ES
|
||||||
|
|
||||||
|
$PLOT_EG
|
||||||
|
|
||||||
|
_EOF_
|
||||||
|
|
||||||
|
) | gnuplot
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -s "$outputdir/exec_speed.png" ]; then
|
if [ ! -s "$outputdir/exec_speed.png" ]; then
|
||||||
|
|
||||||
echo "[-] Error: something went wrong! Perhaps you have an ancient version of gnuplot?" 1>&2
|
echo "[-] Error: something went wrong! Perhaps you have an ancient version of gnuplot?" 1>&2
|
||||||
@ -299,12 +317,6 @@ _EOF_
|
|||||||
chmod 755 "$outputdir"
|
chmod 755 "$outputdir"
|
||||||
chmod 644 "$outputdir/high_freq.png" "$outputdir/low_freq.png" "$outputdir/exec_speed.png" "$outputdir/edges.png" "$outputdir/index.html"
|
chmod 644 "$outputdir/high_freq.png" "$outputdir/low_freq.png" "$outputdir/exec_speed.png" "$outputdir/edges.png" "$outputdir/index.html"
|
||||||
|
|
||||||
rm "$outputdir/tmp/win_ids"
|
|
||||||
|
|
||||||
if [ -z "$(ls -A $outputdir/tmp)" ]; then
|
|
||||||
rm -r "$outputdir/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[+] All done - enjoy your charts!"
|
echo "[+] All done - enjoy your charts!"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user