OLD | NEW |
(Empty) | |
| 1 #!/bin/sh |
| 2 # |
| 3 # american fuzzy lop - Advanced Persistent Graphing |
| 4 # ------------------------------------------------- |
| 5 # |
| 6 # Written and maintained by Michal Zalewski <lcamtuf@google.com> |
| 7 # Based on a design & prototype by Michael Rash. |
| 8 # |
| 9 # Copyright 2014, 2015 Google Inc. All rights reserved. |
| 10 # |
| 11 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 12 # you may not use this file except in compliance with the License. |
| 13 # You may obtain a copy of the License at: |
| 14 # |
| 15 # http://www.apache.org/licenses/LICENSE-2.0 |
| 16 # |
| 17 |
| 18 echo "progress plotting utility for afl-fuzz by <lcamtuf@google.com>" |
| 19 echo |
| 20 |
| 21 if [ ! "$#" = "2" ]; then |
| 22 |
| 23 cat 1>&2 <<_EOF_ |
| 24 This program generates gnuplot images from afl-fuzz output data. Usage: |
| 25 |
| 26 $0 afl_state_dir graph_output_dir |
| 27 |
| 28 The afl_state_dir parameter should point to an existing state directory for any |
| 29 active or stopped instance of afl-fuzz; while graph_output_dir should point to |
| 30 an empty directory where this tool can write the resulting plots to. |
| 31 |
| 32 The program will put index.html and three PNG images in the output directory; |
| 33 you should be able to view it with any web browser of your choice. |
| 34 |
| 35 _EOF_ |
| 36 |
| 37 exit 1 |
| 38 |
| 39 fi |
| 40 |
| 41 echo "$1" | grep -qE '^(/var)?/tmp/' |
| 42 T1="$?" |
| 43 |
| 44 echo "$2" | grep -qE '^(/var)?/tmp/' |
| 45 T2="$?" |
| 46 |
| 47 if [ "$T1" = "0" -o "$T2" = "0" ]; then |
| 48 |
| 49 echo "[-] Error: this script shouldn't be used with shared /tmp directories."
1>&2 |
| 50 exit 1 |
| 51 |
| 52 fi |
| 53 |
| 54 if [ ! -f "$1/plot_data" ]; then |
| 55 |
| 56 echo "[-] Error: input directory is not valid (missing 'plot_data')." 1>&2 |
| 57 exit 1 |
| 58 |
| 59 fi |
| 60 |
| 61 BANNER="`cat "$1/fuzzer_stats" | grep '^afl_banner ' | cut -d: -f2- | cut -b2-`" |
| 62 |
| 63 test "$BANNER" = "" && BANNER="(none)" |
| 64 |
| 65 GNUPLOT=`which gnuplot 2>/dev/null` |
| 66 |
| 67 if [ "$GNUPLOT" = "" ]; then |
| 68 |
| 69 echo "[-] Error: can't find 'gnuplot' in your \$PATH." 1>&2 |
| 70 exit 1 |
| 71 |
| 72 fi |
| 73 |
| 74 mkdir "$2" 2>/dev/null |
| 75 |
| 76 if [ ! -d "$2" ]; then |
| 77 |
| 78 echo "[-] Error: unable to create the output directory - pick another location
." 1>&2 |
| 79 exit 1 |
| 80 |
| 81 fi |
| 82 |
| 83 rm -f "$2/high_freq.png" "$2/low_freq.png" "$2/exec_speed.png" |
| 84 mv -f "$2/index.html" "$2/index.html.orig" 2>/dev/null |
| 85 |
| 86 echo "[*] Generating plots..." |
| 87 |
| 88 ( |
| 89 |
| 90 cat <<_EOF_ |
| 91 set terminal png truecolor enhanced size 1000,300 butt |
| 92 |
| 93 set output '$2/high_freq.png' |
| 94 |
| 95 set xdata time |
| 96 set timefmt '%s' |
| 97 set format x "%b %d\n%H:%M" |
| 98 set tics font 'small' |
| 99 unset mxtics |
| 100 unset mytics |
| 101 |
| 102 set grid xtics linetype 0 linecolor rgb '#e0e0e0' |
| 103 set grid ytics linetype 0 linecolor rgb '#e0e0e0' |
| 104 set border linecolor rgb '#50c0f0' |
| 105 set tics textcolor rgb '#000000' |
| 106 set key outside |
| 107 |
| 108 set autoscale xfixmin |
| 109 set autoscale xfixmax |
| 110 |
| 111 plot '$1/plot_data' using 1:4 with filledcurve x1 title 'total paths' linecolor
rgb '#000000' fillstyle transparent solid 0.2 noborder, \\ |
| 112 '' using 1:3 with filledcurve x1 title 'current path' linecolor rgb '#f0f0f
0' fillstyle transparent solid 0.5 noborder, \\ |
| 113 '' using 1:5 with lines title 'pending paths' linecolor rgb '#0090ff' linew
idth 3, \\ |
| 114 '' using 1:6 with lines title 'pending favs' linecolor rgb '#c00080' linewi
dth 3, \\ |
| 115 '' using 1:2 with lines title 'cycles done' linecolor rgb '#c000f0' linewid
th 3 |
| 116 |
| 117 set terminal png truecolor enhanced size 1000,200 butt |
| 118 set output '$2/low_freq.png' |
| 119 |
| 120 plot '$1/plot_data' using 1:8 with filledcurve x1 title '' linecolor rgb '#c0008
0' fillstyle transparent solid 0.2 noborder, \\ |
| 121 '' using 1:8 with lines title ' uniq crashes' linecolor rgb '#c00080' linew
idth 3, \\ |
| 122 '' using 1:9 with lines title 'uniq hangs' linecolor rgb '#c000f0' linewidt
h 3, \\ |
| 123 '' using 1:10 with lines title 'levels' linecolor rgb '#0090ff' linewidth 3 |
| 124 |
| 125 set terminal png truecolor enhanced size 1000,200 butt |
| 126 set output '$2/exec_speed.png' |
| 127 |
| 128 plot '$1/plot_data' using 1:11 with filledcurve x1 title '' linecolor rgb '#0090
ff' fillstyle transparent solid 0.2 noborder, \\ |
| 129 '$1/plot_data' using 1:11 with lines title ' execs/sec' linecolor rgb '#
0090ff' linewidth 3 smooth bezier; |
| 130 |
| 131 _EOF_ |
| 132 |
| 133 ) | gnuplot |
| 134 |
| 135 if [ ! -s "$2/exec_speed.png" ]; then |
| 136 |
| 137 echo "[-] Error: something went wrong! Perhaps you have an ancient version of
gnuplot?" 1>&2 |
| 138 exit 1 |
| 139 |
| 140 fi |
| 141 |
| 142 echo "[*] Generating index.html..." |
| 143 |
| 144 cat >"$2/index.html" <<_EOF_ |
| 145 <table style="font-family: 'Trebuchet MS', 'Tahoma', 'Arial', 'Helvetica'"> |
| 146 <tr><td style="width: 18ex"><b>Banner:</b></td><td>$BANNER</td></tr> |
| 147 <tr><td><b>Directory:</b></td><td>$1</td></tr> |
| 148 <tr><td><b>Generated on:</b></td><td>`date`</td></tr> |
| 149 </table> |
| 150 <p> |
| 151 <img src="high_freq.png" width=1000 height=300><p> |
| 152 <img src="low_freq.png" width=1000 height=200><p> |
| 153 <img src="exec_speed.png" width=1000 height=200> |
| 154 |
| 155 _EOF_ |
| 156 |
| 157 # Make it easy to remotely view results when outputting directly to a directory |
| 158 # served by Apache or other HTTP daemon. Since the plots aren't horribly |
| 159 # sensitive, this seems like a reasonable trade-off. |
| 160 |
| 161 chmod 755 "$2" |
| 162 chmod 644 "$2/high_freq.png" "$2/low_freq.png" "$2/exec_speed.png" "$2/index.htm
l" |
| 163 |
| 164 echo "[+] All done - enjoy your charts!" |
| 165 |
| 166 exit 0 |
OLD | NEW |