From f72430711b737a5e16bc19dd9bb54cbaba7fa656 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Wed, 4 Aug 2021 21:27:55 +0530 Subject: Wrote a simple and minimal UI in GTK, with GNUplot graphs embedded in it TODO: Improve upon the extremely minimal (yet functional) UI --- src/afl-plot-ui.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/afl-plot-ui.c diff --git a/src/afl-plot-ui.c b/src/afl-plot-ui.c new file mode 100644 index 00000000..53aa5b4c --- /dev/null +++ b/src/afl-plot-ui.c @@ -0,0 +1,149 @@ +#include +#include +#include + +#define WIDTH 400 +#define HEIGHT 640 + +static void plot_toggled(GtkWidget *caller, gpointer data); + +int main(int argc, char **argv) { + + GtkWidget *window; + GtkWidget *main_vbox; + + GtkWidget *cbuttons_frame; + GtkWidget *cbuttons_hbox; + + GtkWidget *separator_maj, *separator_min1, *separator_min2, *separator_min3; + + GtkWidget *plots_vbox; + GtkWidget *plot_edges_frame, *plot_exec_speed_frame, *plot_high_freq_frame, + *plot_low_freq_frame; + GtkWidget *plot_edges, *plot_exec_speed, *plot_high_freq, *plot_low_freq; + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), WIDTH, HEIGHT); + gtk_window_set_title(GTK_WINDOW(window), "Graph drawing"); + gtk_container_set_border_width(GTK_CONTAINER(window), 10); + + main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + cbuttons_frame = gtk_frame_new("Select the plots"); + gtk_container_set_border_width(GTK_CONTAINER(cbuttons_frame), 5); + + cbuttons_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + + GtkWidget *cbutton_edges, *cbutton_exec_speed, *cbutton_high_freq, + *cbutton_low_freq; + + cbutton_edges = gtk_check_button_new_with_label("Edges"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_edges), TRUE); + g_signal_connect(cbutton_edges, "toggled", G_CALLBACK(plot_toggled), + &plot_edges_frame); + + cbutton_exec_speed = gtk_check_button_new_with_label("Execution Speed"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_exec_speed), TRUE); + g_signal_connect(cbutton_exec_speed, "toggled", G_CALLBACK(plot_toggled), + &plot_exec_speed_frame); + + cbutton_high_freq = gtk_check_button_new_with_label("High Frequency"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_high_freq), TRUE); + g_signal_connect(cbutton_high_freq, "toggled", G_CALLBACK(plot_toggled), + &plot_high_freq_frame); + + cbutton_low_freq = gtk_check_button_new_with_label("Low Frequency"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_low_freq), TRUE); + g_signal_connect(cbutton_low_freq, "toggled", G_CALLBACK(plot_toggled), + &plot_low_freq_frame); + + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_edges, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_exec_speed, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_high_freq, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_low_freq, TRUE, TRUE, 1); + + gtk_container_add(GTK_CONTAINER(cbuttons_frame), cbuttons_hbox); + gtk_box_pack_start(GTK_BOX(main_vbox), cbuttons_frame, FALSE, TRUE, 1); + + separator_maj = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + gtk_box_pack_start(GTK_BOX(main_vbox), separator_maj, FALSE, TRUE, 1); + + plots_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); + + plot_edges_frame = gtk_frame_new("Edges"); + gtk_container_set_border_width(GTK_CONTAINER(plot_edges_frame), 5); + plot_edges = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_edges_frame), plot_edges); + + plot_exec_speed_frame = gtk_frame_new("Exec Speed"); + gtk_container_set_border_width(GTK_CONTAINER(plot_exec_speed_frame), 5); + plot_exec_speed = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_exec_speed_frame), plot_exec_speed); + + plot_high_freq_frame = gtk_frame_new("High Frequency"); + gtk_container_set_border_width(GTK_CONTAINER(plot_high_freq_frame), 5); + plot_high_freq = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_high_freq_frame), plot_high_freq); + + plot_low_freq_frame = gtk_frame_new("Low Frequency"); + gtk_container_set_border_width(GTK_CONTAINER(plot_low_freq_frame), 5); + plot_low_freq = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_low_freq_frame), plot_low_freq); + + separator_min1 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + separator_min2 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + separator_min3 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_edges_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min1, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_exec_speed_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min2, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_high_freq_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min3, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_low_freq_frame, TRUE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(main_vbox), plots_vbox, TRUE, TRUE, 1); + + gtk_container_add(GTK_CONTAINER(window), main_vbox); + + guint id_edges = gtk_socket_get_id(GTK_SOCKET(plot_edges)); + guint id_exec_speed = gtk_socket_get_id(GTK_SOCKET(plot_exec_speed)); + guint id_high_freq = gtk_socket_get_id(GTK_SOCKET(plot_high_freq)); + guint id_low_freq = gtk_socket_get_id(GTK_SOCKET(plot_low_freq)); + + printf("%x\n%x\n%x\n%x\n", id_edges, id_exec_speed, id_high_freq, + id_low_freq); + + fclose(stdout); + + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), + NULL); + gtk_widget_show_all(window); + gtk_main(); + + return EXIT_SUCCESS; + +} + +static void plot_toggled(GtkWidget *caller, gpointer data) { + + gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(caller)); + + GtkWidget *widget = *(GtkWidget **)data; + + if (state) { + + gtk_widget_show(widget); + + } else { + + gtk_widget_hide(widget); + + } + +} -- cgit 1.4.1 From bb9be56dd6d2766e81797042d491c75aa121a3e0 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Wed, 4 Aug 2021 21:30:52 +0530 Subject: Updated the afl-plot shell script to use GTK UI TODO: Currently the script is very huge, and needs to be made more concise and clean. In it's current state, it is hard to maintain. --- afl-plot | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 2 deletions(-) diff --git a/afl-plot b/afl-plot index 662c0907..094b35c7 100755 --- a/afl-plot +++ b/afl-plot @@ -102,11 +102,21 @@ fi 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 +mkdir -p "$outputdir/tmp" +/usr/local/bin/afl-plot-ui > "$outputdir/tmp/win_ids" & + +sleep 1 + +W_ID1=$(cat $outputdir/tmp/win_ids | head -1) +W_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1) +W_ID3=$(cat $outputdir/tmp/win_ids | head -3 | tail -1) +W_ID4=$(cat $outputdir/tmp/win_ids | tail -1) + echo "[*] Generating plots..." ( -cat <<_EOF_ +cat << _EOF_ set terminal png truecolor enhanced size 1000,300 butt set output '$outputdir/high_freq.png' @@ -135,6 +145,37 @@ plot '$inputdir/plot_data' using 1:4 with filledcurve x1 title 'total paths' lin '' 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 +set term x11 window "$W_ID3" +set output +replot + +pause mouse close + +_EOF_ + +) | gnuplot & + +( + +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' @@ -143,20 +184,90 @@ plot '$inputdir/plot_data' using 1:8 with filledcurve x1 title '' linecolor rgb '' 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 +set term x11 window "$W_ID4" +set output +replot + +pause mouse close + +_EOF_ + +) | gnuplot & + +( + +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; +set term x11 window "$W_ID2" +set output +replot + +pause mouse close + +_EOF_ + +) | gnuplot & + +( + +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 +set term x11 window "$W_ID1" +set output +replot + +pause mouse close + _EOF_ -) | gnuplot +) | gnuplot & + +sleep 2 if [ ! -s "$outputdir/exec_speed.png" ]; then @@ -188,6 +299,12 @@ _EOF_ chmod 755 "$outputdir" 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!" exit 0 -- cgit 1.4.1 From c7a93d50c438e3d6da85232e8d377b838237617b Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:40:38 +0530 Subject: Added usage info and command line help flag support TODO: Prevent standalone execution --- utils/plot_ui/afl-plot-ui.c | 166 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 utils/plot_ui/afl-plot-ui.c diff --git a/utils/plot_ui/afl-plot-ui.c b/utils/plot_ui/afl-plot-ui.c new file mode 100644 index 00000000..856bf082 --- /dev/null +++ b/utils/plot_ui/afl-plot-ui.c @@ -0,0 +1,166 @@ +#include +#include +#include +#include + +#define WIDTH 400 +#define HEIGHT 640 + +char USAGE[] = + "is a helper utility for rendering the GNUplot graphs in a GTK window. This allows to real time resizing, scrolling, and cursor positioning features while viewing the graph. This utility also provides options to hide graphs using check buttons.\n \ +\n \ +Usage:\n \ + -h, --help Show this help menu\n \ +\n \ +NOTE: This utility is not meant to be used standalone. Never run this utility directly. Always run afl-plot, which will, in turn, invoke this utility (when run using `-g` or `--graphical` flag).\n \ +"; + +static void plot_toggled(GtkWidget *caller, gpointer data); + +int main(int argc, char **argv) { + + if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-help"))) { + + printf("%s %s", argv[0], USAGE); + return EXIT_SUCCESS; + + } + + GtkWidget *window; + GtkWidget *main_vbox; + + GtkWidget *cbuttons_frame; + GtkWidget *cbuttons_hbox; + + GtkWidget *separator_maj, *separator_min1, *separator_min2, *separator_min3; + + GtkWidget *plots_vbox; + GtkWidget *plot_edges_frame, *plot_exec_speed_frame, *plot_high_freq_frame, + *plot_low_freq_frame; + GtkWidget *plot_edges, *plot_exec_speed, *plot_high_freq, *plot_low_freq; + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), WIDTH, HEIGHT); + gtk_window_set_title(GTK_WINDOW(window), "Graph drawing"); + gtk_container_set_border_width(GTK_CONTAINER(window), 10); + + main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + cbuttons_frame = gtk_frame_new("Select the plots"); + gtk_container_set_border_width(GTK_CONTAINER(cbuttons_frame), 5); + + cbuttons_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + + GtkWidget *cbutton_edges, *cbutton_exec_speed, *cbutton_high_freq, + *cbutton_low_freq; + + cbutton_edges = gtk_check_button_new_with_label("Edges"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_edges), TRUE); + g_signal_connect(cbutton_edges, "toggled", G_CALLBACK(plot_toggled), + &plot_edges_frame); + + cbutton_exec_speed = gtk_check_button_new_with_label("Execution Speed"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_exec_speed), TRUE); + g_signal_connect(cbutton_exec_speed, "toggled", G_CALLBACK(plot_toggled), + &plot_exec_speed_frame); + + cbutton_high_freq = gtk_check_button_new_with_label("High Frequency"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_high_freq), TRUE); + g_signal_connect(cbutton_high_freq, "toggled", G_CALLBACK(plot_toggled), + &plot_high_freq_frame); + + cbutton_low_freq = gtk_check_button_new_with_label("Low Frequency"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_low_freq), TRUE); + g_signal_connect(cbutton_low_freq, "toggled", G_CALLBACK(plot_toggled), + &plot_low_freq_frame); + + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_edges, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_exec_speed, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_high_freq, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_low_freq, TRUE, TRUE, 1); + + gtk_container_add(GTK_CONTAINER(cbuttons_frame), cbuttons_hbox); + gtk_box_pack_start(GTK_BOX(main_vbox), cbuttons_frame, FALSE, TRUE, 1); + + separator_maj = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + gtk_box_pack_start(GTK_BOX(main_vbox), separator_maj, FALSE, TRUE, 1); + + plots_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); + + plot_edges_frame = gtk_frame_new("Edges"); + gtk_container_set_border_width(GTK_CONTAINER(plot_edges_frame), 5); + plot_edges = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_edges_frame), plot_edges); + + plot_exec_speed_frame = gtk_frame_new("Exec Speed"); + gtk_container_set_border_width(GTK_CONTAINER(plot_exec_speed_frame), 5); + plot_exec_speed = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_exec_speed_frame), plot_exec_speed); + + plot_high_freq_frame = gtk_frame_new("High Frequency"); + gtk_container_set_border_width(GTK_CONTAINER(plot_high_freq_frame), 5); + plot_high_freq = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_high_freq_frame), plot_high_freq); + + plot_low_freq_frame = gtk_frame_new("Low Frequency"); + gtk_container_set_border_width(GTK_CONTAINER(plot_low_freq_frame), 5); + plot_low_freq = gtk_socket_new(); + gtk_container_add(GTK_CONTAINER(plot_low_freq_frame), plot_low_freq); + + separator_min1 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + separator_min2 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + separator_min3 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_edges_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min1, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_exec_speed_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min2, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_high_freq_frame, TRUE, TRUE, 1); + gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min3, FALSE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(plots_vbox), plot_low_freq_frame, TRUE, TRUE, 1); + + gtk_box_pack_start(GTK_BOX(main_vbox), plots_vbox, TRUE, TRUE, 1); + + gtk_container_add(GTK_CONTAINER(window), main_vbox); + + guint id_edges = gtk_socket_get_id(GTK_SOCKET(plot_edges)); + guint id_exec_speed = gtk_socket_get_id(GTK_SOCKET(plot_exec_speed)); + guint id_high_freq = gtk_socket_get_id(GTK_SOCKET(plot_high_freq)); + guint id_low_freq = gtk_socket_get_id(GTK_SOCKET(plot_low_freq)); + + printf("%x\n%x\n%x\n%x\n", id_edges, id_exec_speed, id_high_freq, + id_low_freq); + + fclose(stdout); + + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), + NULL); + gtk_widget_show_all(window); + gtk_main(); + + return EXIT_SUCCESS; + +} + +static void plot_toggled(GtkWidget *caller, gpointer data) { + + gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(caller)); + + GtkWidget *widget = *(GtkWidget **)data; + + if (state) { + + gtk_widget_show(widget); + + } else { + + gtk_widget_hide(widget); + + } + +} -- cgit 1.4.1 From 6f3e63de0507647719f64eec7df99f2e2f98d123 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:41:55 +0530 Subject: Added Makefile for building and installing afl-plot-ui Currently, it offers make and make clean functionality only --- utils/plot_ui/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 utils/plot_ui/Makefile diff --git a/utils/plot_ui/Makefile b/utils/plot_ui/Makefile new file mode 100644 index 00000000..7ade8a40 --- /dev/null +++ b/utils/plot_ui/Makefile @@ -0,0 +1,10 @@ +CFLAGS=`pkg-config --cflags gtk+-3.0` +LDFLAGS=`pkg-config --libs gtk+-3.0` + +all: afl-plot-ui + +afl-plot-ui: afl-plot-ui.c + $(CC) $(CFLAGS) -o afl-plot-ui afl-plot-ui.c $(LDFLAGS) + +clean: + rm -f afl-plot-ui \ No newline at end of file -- cgit 1.4.1 From 7bedd862d374c4292d72e5ce8211b425b1d6ddf2 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:42:49 +0530 Subject: Added README to describe the working of afl-plot-ui --- utils/plot_ui/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 utils/plot_ui/README.md diff --git a/utils/plot_ui/README.md b/utils/plot_ui/README.md new file mode 100644 index 00000000..d8afa09f --- /dev/null +++ b/utils/plot_ui/README.md @@ -0,0 +1,5 @@ +# afl-plot-ui + +`afl-plot-ui` is a helper utility for rendering the GNUplot graphs in a GTK window. This allows to real time resizing, scrolling, and cursor positioning features while viewing the graph. This utility also provides options to hide graphs using check buttons. + +*NOTE:* This utility is not meant to be used standalone. Never run this utility directly. Always run [`afl-plot`](../../afl-plot), which will, in turn, invoke this utility (when run using `-g` or `--graphical` flag). \ No newline at end of file -- cgit 1.4.1 From fa7e3453d3e5e60907f93af23c7c5e5441d0d5eb Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:43:43 +0530 Subject: Added support for graphical command line flag, improved the general organization of script Script works as "intended" --- afl-plot | 220 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 116 insertions(+), 104 deletions(-) diff --git a/afl-plot b/afl-plot index 094b35c7..52cec521 100755 --- a/afl-plot +++ b/afl-plot @@ -22,16 +22,21 @@ get_abs_path() { echo "progress plotting utility for afl-fuzz by Michal Zalewski" echo -if [ ! "$#" = "2" ]; then +if ( [ "$#" != "2" ] && [ "$#" != "3" ] ) || ( [ "$#" = "3" ] && [ "$3" != "-g" ] && [ "$3" != "--graphical" ] ); then 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 -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. +Usage: + + 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; you should be able to view it with any web browser of your choice. @@ -102,28 +107,10 @@ fi 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 -mkdir -p "$outputdir/tmp" -/usr/local/bin/afl-plot-ui > "$outputdir/tmp/win_ids" & - -sleep 1 - -W_ID1=$(cat $outputdir/tmp/win_ids | head -1) -W_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1) -W_ID3=$(cat $outputdir/tmp/win_ids | head -3 | tail -1) -W_ID4=$(cat $outputdir/tmp/win_ids | tail -1) - -echo "[*] Generating plots..." - -( - -cat << _EOF_ -set terminal png truecolor enhanced size 1000,300 butt - -set output '$outputdir/high_freq.png' - +GNUPLOT_SETUP=" #set xdata time #set timefmt '%s' -#set format x "%b %d\n%H:%M" +#set format x \"%b %d\n%H:%M\" set tics font 'small' unset mxtics unset mytics @@ -137,94 +124,105 @@ set key outside set autoscale xfixmin set autoscale xfixmax -set xlabel "relative time in seconds" font "small" +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 +" -set term x11 window "$W_ID3" -set output -replot +PLOT_LF=" +set terminal png truecolor enhanced size 1000,200 butt +set output '$outputdir/low_freq.png' -pause mouse close +$GNUPLOT_SETUP -_EOF_ +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 +" -) | gnuplot & +PLOT_ES=" +set terminal png truecolor enhanced size 1000,200 butt +set output '$outputdir/exec_speed.png' -( +$GNUPLOT_SETUP -cat << _EOF_ -#set xdata time -#set timefmt '%s' -#set format x "%b %d\n%H:%M" -set tics font 'small' -unset mxtics -unset mytics +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; +" -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 +PLOT_EG=" +set terminal png truecolor enhanced size 1000,300 butt +set output '$outputdir/edges.png' -set autoscale xfixmin -set autoscale xfixmax +$GNUPLOT_SETUP -set xlabel "relative time in seconds" font "small" +plot '$inputdir/plot_data' using 1:13 with lines title ' edges' linecolor rgb '#0090ff' linewidth 3 +" -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 +if [ "$#" = "3" ] && ( [ "$3" = "-g" ] || [ "$3" = "--graphical" ] ); then -set term x11 window "$W_ID4" -set output -replot +afl-plot-ui -h > /dev/null 2>&1 -pause mouse close +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_ -) | gnuplot & +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_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1) +W_ID3=$(cat $outputdir/tmp/win_ids | head -3 | tail -1) +W_ID4=$(cat $outputdir/tmp/win_ids | tail -1) + +echo "[*] Generating plots..." ( 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 +$PLOT_HF +set term x11 window "$W_ID3" +set output +replot +pause mouse close -set autoscale xfixmin -set autoscale xfixmax +_EOF_ -set xlabel "relative time in seconds" font "small" +) | gnuplot & -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; +cat << _EOF_ -set term x11 window "$W_ID2" +$PLOT_LF +set term x11 window "$W_ID4" set output replot - pause mouse close _EOF_ @@ -234,33 +232,25 @@ _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 +$PLOT_ES +set term x11 window "$W_ID2" +set output +replot +pause mouse close -set autoscale xfixmin -set autoscale xfixmax +_EOF_ -set xlabel "relative time in seconds" font "small" +) | gnuplot & -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 +cat << _EOF_ +$PLOT_EG set term x11 window "$W_ID1" set output replot - pause mouse close _EOF_ @@ -269,6 +259,34 @@ _EOF_ 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 echo "[-] Error: something went wrong! Perhaps you have an ancient version of gnuplot?" 1>&2 @@ -299,12 +317,6 @@ _EOF_ chmod 755 "$outputdir" 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!" exit 0 -- cgit 1.4.1 From 41aebad83ec74265ffa005d6c2475e71d67498e8 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:45:28 +0530 Subject: Added build and install instructions for afl-plot-ui I am implicitly assuming that the user already has GK and pkg-config installed, as requested in the build instructions in the main README --- GNUmakefile | 5 ++ src/afl-plot-ui.c | 149 ------------------------------------------------------ 2 files changed, 5 insertions(+), 149 deletions(-) delete mode 100644 src/afl-plot-ui.c diff --git a/GNUmakefile b/GNUmakefile index 7a1ba88a..4151d5b2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -570,6 +570,7 @@ clean: $(MAKE) -C utils/afl_network_proxy clean $(MAKE) -C utils/socket_fuzzing clean $(MAKE) -C utils/argv_fuzzing clean + $(MAKE) -C utils/plot_ui clean $(MAKE) -C qemu_mode/unsigaction clean $(MAKE) -C qemu_mode/libcompcov clean $(MAKE) -C qemu_mode/libqasan clean @@ -601,6 +602,7 @@ distrib: all $(MAKE) -C utils/afl_network_proxy $(MAKE) -C utils/socket_fuzzing $(MAKE) -C utils/argv_fuzzing + $(MAKE) -C utils/plot_ui -$(MAKE) -C frida_mode -cd qemu_mode && sh ./build_qemu_support.sh -cd unicorn_mode && unset CFLAGS && sh ./build_unicorn_support.sh @@ -612,6 +614,7 @@ binary-only: test_shm test_python ready $(PROGS) $(MAKE) -C utils/afl_network_proxy $(MAKE) -C utils/socket_fuzzing $(MAKE) -C utils/argv_fuzzing + $(MAKE) -C utils/plot_ui -$(MAKE) -C frida_mode -cd qemu_mode && sh ./build_qemu_support.sh -cd unicorn_mode && unset CFLAGS && sh ./build_unicorn_support.sh @@ -622,6 +625,7 @@ source-only: all -$(MAKE) -f GNUmakefile.gcc_plugin $(MAKE) -C utils/libdislocator $(MAKE) -C utils/libtokencap + $(MAKE) -C utils/plot_ui %.8: % @echo .TH $* 8 $(BUILD_DATE) "afl++" > $@ @@ -650,6 +654,7 @@ install: all $(MANPAGES) @rm -f $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH)/afl-gcc-rt.o install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH) @if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi + @if [ -f utils/plot_ui/afl-plot-ui ]; then install -m 755 utils/plot_ui/afl-plot-ui $${DESTDIR}$(BIN_PATH); fi @if [ -f libdislocator.so ]; then set -e; install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH); fi @if [ -f libtokencap.so ]; then set -e; install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH); fi @if [ -f libcompcov.so ]; then set -e; install -m 755 libcompcov.so $${DESTDIR}$(HELPER_PATH); fi diff --git a/src/afl-plot-ui.c b/src/afl-plot-ui.c deleted file mode 100644 index 53aa5b4c..00000000 --- a/src/afl-plot-ui.c +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include -#include - -#define WIDTH 400 -#define HEIGHT 640 - -static void plot_toggled(GtkWidget *caller, gpointer data); - -int main(int argc, char **argv) { - - GtkWidget *window; - GtkWidget *main_vbox; - - GtkWidget *cbuttons_frame; - GtkWidget *cbuttons_hbox; - - GtkWidget *separator_maj, *separator_min1, *separator_min2, *separator_min3; - - GtkWidget *plots_vbox; - GtkWidget *plot_edges_frame, *plot_exec_speed_frame, *plot_high_freq_frame, - *plot_low_freq_frame; - GtkWidget *plot_edges, *plot_exec_speed, *plot_high_freq, *plot_low_freq; - - gtk_init(&argc, &argv); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window), WIDTH, HEIGHT); - gtk_window_set_title(GTK_WINDOW(window), "Graph drawing"); - gtk_container_set_border_width(GTK_CONTAINER(window), 10); - - main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - - cbuttons_frame = gtk_frame_new("Select the plots"); - gtk_container_set_border_width(GTK_CONTAINER(cbuttons_frame), 5); - - cbuttons_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); - - GtkWidget *cbutton_edges, *cbutton_exec_speed, *cbutton_high_freq, - *cbutton_low_freq; - - cbutton_edges = gtk_check_button_new_with_label("Edges"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_edges), TRUE); - g_signal_connect(cbutton_edges, "toggled", G_CALLBACK(plot_toggled), - &plot_edges_frame); - - cbutton_exec_speed = gtk_check_button_new_with_label("Execution Speed"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_exec_speed), TRUE); - g_signal_connect(cbutton_exec_speed, "toggled", G_CALLBACK(plot_toggled), - &plot_exec_speed_frame); - - cbutton_high_freq = gtk_check_button_new_with_label("High Frequency"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_high_freq), TRUE); - g_signal_connect(cbutton_high_freq, "toggled", G_CALLBACK(plot_toggled), - &plot_high_freq_frame); - - cbutton_low_freq = gtk_check_button_new_with_label("Low Frequency"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbutton_low_freq), TRUE); - g_signal_connect(cbutton_low_freq, "toggled", G_CALLBACK(plot_toggled), - &plot_low_freq_frame); - - gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_edges, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_exec_speed, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_high_freq, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(cbuttons_hbox), cbutton_low_freq, TRUE, TRUE, 1); - - gtk_container_add(GTK_CONTAINER(cbuttons_frame), cbuttons_hbox); - gtk_box_pack_start(GTK_BOX(main_vbox), cbuttons_frame, FALSE, TRUE, 1); - - separator_maj = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start(GTK_BOX(main_vbox), separator_maj, FALSE, TRUE, 1); - - plots_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); - - plot_edges_frame = gtk_frame_new("Edges"); - gtk_container_set_border_width(GTK_CONTAINER(plot_edges_frame), 5); - plot_edges = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(plot_edges_frame), plot_edges); - - plot_exec_speed_frame = gtk_frame_new("Exec Speed"); - gtk_container_set_border_width(GTK_CONTAINER(plot_exec_speed_frame), 5); - plot_exec_speed = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(plot_exec_speed_frame), plot_exec_speed); - - plot_high_freq_frame = gtk_frame_new("High Frequency"); - gtk_container_set_border_width(GTK_CONTAINER(plot_high_freq_frame), 5); - plot_high_freq = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(plot_high_freq_frame), plot_high_freq); - - plot_low_freq_frame = gtk_frame_new("Low Frequency"); - gtk_container_set_border_width(GTK_CONTAINER(plot_low_freq_frame), 5); - plot_low_freq = gtk_socket_new(); - gtk_container_add(GTK_CONTAINER(plot_low_freq_frame), plot_low_freq); - - separator_min1 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - separator_min2 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - separator_min3 = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - - gtk_box_pack_start(GTK_BOX(plots_vbox), plot_edges_frame, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min1, FALSE, TRUE, 1); - - gtk_box_pack_start(GTK_BOX(plots_vbox), plot_exec_speed_frame, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min2, FALSE, TRUE, 1); - - gtk_box_pack_start(GTK_BOX(plots_vbox), plot_high_freq_frame, TRUE, TRUE, 1); - gtk_box_pack_start(GTK_BOX(plots_vbox), separator_min3, FALSE, TRUE, 1); - - gtk_box_pack_start(GTK_BOX(plots_vbox), plot_low_freq_frame, TRUE, TRUE, 1); - - gtk_box_pack_start(GTK_BOX(main_vbox), plots_vbox, TRUE, TRUE, 1); - - gtk_container_add(GTK_CONTAINER(window), main_vbox); - - guint id_edges = gtk_socket_get_id(GTK_SOCKET(plot_edges)); - guint id_exec_speed = gtk_socket_get_id(GTK_SOCKET(plot_exec_speed)); - guint id_high_freq = gtk_socket_get_id(GTK_SOCKET(plot_high_freq)); - guint id_low_freq = gtk_socket_get_id(GTK_SOCKET(plot_low_freq)); - - printf("%x\n%x\n%x\n%x\n", id_edges, id_exec_speed, id_high_freq, - id_low_freq); - - fclose(stdout); - - g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), - NULL); - gtk_widget_show_all(window); - gtk_main(); - - return EXIT_SUCCESS; - -} - -static void plot_toggled(GtkWidget *caller, gpointer data) { - - gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(caller)); - - GtkWidget *widget = *(GtkWidget **)data; - - if (state) { - - gtk_widget_show(widget); - - } else { - - gtk_widget_hide(widget); - - } - -} -- cgit 1.4.1 From df5e61de8386d3dc9c22d8b541f2a70548d8872e Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:51:21 +0530 Subject: Added afl-plot-ui executable in .gitignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8c420b5e..5627d8ab 100644 --- a/.gitignore +++ b/.gitignore @@ -85,4 +85,5 @@ gmon.out afl-frida-trace.so utils/afl_network_proxy/afl-network-client utils/afl_network_proxy/afl-network-server +utils/plot_ui/afl-plot-ui *.o.tmp -- cgit 1.4.1 From 533c612dc9cef84ee54c86493da8253373791b31 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:53:00 +0530 Subject: Updated README to contain description regarding plot_ui --- utils/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/README.md b/utils/README.md index b157424f..1c401237 100644 --- a/utils/README.md +++ b/utils/README.md @@ -5,6 +5,9 @@ Here's a quick overview of the stuff you can find in this directory: - afl_network_proxy - fuzz a target over the network: afl-fuzz on a host, target on an embedded system. + - plot_ui - simple UI window utility to display the + plots generated by afl-plot + - afl_proxy - skeleton file example to show how to fuzz something where you gather coverage data via different means, e.g. hw debugger -- cgit 1.4.1 From ca98778b2815433aee166e984798687040e54790 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 18:53:37 +0530 Subject: Added additional dependencies which need to be installed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fcc31ff..9da42bcc 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ The easiest choice is to build and install everything: ```shell sudo apt-get update -sudo apt-get install -y build-essential python3-dev automake git flex bison libglib2.0-dev libpixman-1-dev python3-setuptools +sudo apt-get install -y build-essential python3-dev automake git flex bison libglib2.0-dev libpixman-1-dev python3-setuptools libgtk-3-0 libgtk-3-dev pkg-config # try to install llvm 11 and install the distro default if that fails sudo apt-get install -y lld-11 llvm-11 llvm-11-dev clang-11 || sudo apt-get install -y lld llvm llvm-dev clang sudo apt-get install -y gcc-$(gcc --version|head -n1|sed 's/.* //'|sed 's/\..*//')-plugin-dev libstdc++-$(gcc --version|head -n1|sed 's/.* //'|sed 's/\..*//')-dev -- cgit 1.4.1 From 7e49b928489ab1620e6611b1cbb15ea706a88228 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 20:50:20 +0530 Subject: Updated the CI configuration to install the new dependencies introduced --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35051a20..1f82e4f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: update run: sudo apt-get update && sudo apt-get upgrade -y - name: install packages - run: sudo apt-get install -y -m -f --install-suggests build-essential git libtool libtool-bin automake bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build + run: sudo apt-get install -y -m -f --install-suggests build-essential git libtool libtool-bin automake bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build libgtk-3-0 libgtk-3-dev pkg-config - name: compiler installed run: gcc -v ; echo ; clang -v - name: install gcc plugin -- cgit 1.4.1 From 1095840b98588c51d214cf7920f0e3f6bfaa716b Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 21:08:50 +0530 Subject: Changed parameter order, reduced script execution time --- afl-plot | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/afl-plot b/afl-plot index 52cec521..a06b0c7f 100755 --- a/afl-plot +++ b/afl-plot @@ -22,10 +22,17 @@ get_abs_path() { echo "progress plotting utility for afl-fuzz by Michal Zalewski" echo -if ( [ "$#" != "2" ] && [ "$#" != "3" ] ) || ( [ "$#" = "3" ] && [ "$3" != "-g" ] && [ "$3" != "--graphical" ] ); then +GRAPHICAL="0" + +if [ "$1" = "-g" ] || [ "$1" = "--graphical" ]; then +GRAPHICAL="1" +shift +fi + +if [ "$#" != "2" ]; then cat 1>&2 <<_EOF_ -$0 afl_state_dir graph_output_dir [ -g | --graphical ] +$0 [ -g | --graphical ] afl_state_dir graph_output_dir This program generates gnuplot images from afl-fuzz output data. @@ -36,7 +43,7 @@ Usage: 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) + (you should have built afl-plot-ui to use this option) 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. @@ -171,8 +178,7 @@ $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 +if [ "$#" = "2" ] && [ "$GRAPHICAL" = "1" ]; then afl-plot-ui -h > /dev/null 2>&1 @@ -192,7 +198,7 @@ fi mkdir -p "$outputdir/tmp" afl-plot-ui > "$outputdir/tmp/win_ids" & -sleep 2 +sleep 0.5 W_ID1=$(cat $outputdir/tmp/win_ids | head -1) W_ID2=$(cat $outputdir/tmp/win_ids | head -2 | tail -1) @@ -213,7 +219,7 @@ pause mouse close _EOF_ -) | gnuplot & +) | gnuplot 2> /dev/null & ( @@ -227,7 +233,7 @@ pause mouse close _EOF_ -) | gnuplot & +) | gnuplot 2> /dev/null & ( @@ -241,7 +247,7 @@ pause mouse close _EOF_ -) | gnuplot & +) | gnuplot 2> /dev/null & ( @@ -255,9 +261,9 @@ pause mouse close _EOF_ -) | gnuplot & +) | gnuplot 2> /dev/null & -sleep 2 +sleep 1 rm "$outputdir/tmp/win_ids" @@ -285,6 +291,8 @@ _EOF_ ) | gnuplot +echo "[?] You can also use -g flag to view the plots in an GUI window, and interact with the plots (if you have build afl-plot-ui). Run \"afl-plot\" to know more." + fi if [ ! -s "$outputdir/exec_speed.png" ]; then -- cgit 1.4.1 From 9578546048268d261815476f18b48031606c2121 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 22:09:50 +0530 Subject: Commented out all the builds of afl-plot-ui Also add the "-" qualifier to denote a possibly unsuccessful build --- GNUmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 4151d5b2..68800269 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -570,7 +570,7 @@ clean: $(MAKE) -C utils/afl_network_proxy clean $(MAKE) -C utils/socket_fuzzing clean $(MAKE) -C utils/argv_fuzzing clean - $(MAKE) -C utils/plot_ui clean + -$(MAKE) -C utils/plot_ui clean $(MAKE) -C qemu_mode/unsigaction clean $(MAKE) -C qemu_mode/libcompcov clean $(MAKE) -C qemu_mode/libqasan clean @@ -602,7 +602,7 @@ distrib: all $(MAKE) -C utils/afl_network_proxy $(MAKE) -C utils/socket_fuzzing $(MAKE) -C utils/argv_fuzzing - $(MAKE) -C utils/plot_ui + # -$(MAKE) -C utils/plot_ui -$(MAKE) -C frida_mode -cd qemu_mode && sh ./build_qemu_support.sh -cd unicorn_mode && unset CFLAGS && sh ./build_unicorn_support.sh @@ -614,7 +614,7 @@ binary-only: test_shm test_python ready $(PROGS) $(MAKE) -C utils/afl_network_proxy $(MAKE) -C utils/socket_fuzzing $(MAKE) -C utils/argv_fuzzing - $(MAKE) -C utils/plot_ui + # -$(MAKE) -C utils/plot_ui -$(MAKE) -C frida_mode -cd qemu_mode && sh ./build_qemu_support.sh -cd unicorn_mode && unset CFLAGS && sh ./build_unicorn_support.sh @@ -625,7 +625,7 @@ source-only: all -$(MAKE) -f GNUmakefile.gcc_plugin $(MAKE) -C utils/libdislocator $(MAKE) -C utils/libtokencap - $(MAKE) -C utils/plot_ui + # -$(MAKE) -C utils/plot_ui %.8: % @echo .TH $* 8 $(BUILD_DATE) "afl++" > $@ -- cgit 1.4.1 From e7d8272aeda73a6ed7750de36bb97f540401bf3e Mon Sep 17 00:00:00 2001 From: DMaroo Date: Fri, 6 Aug 2021 22:13:00 +0530 Subject: Fixed a typo --- afl-plot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afl-plot b/afl-plot index a06b0c7f..87b9caae 100755 --- a/afl-plot +++ b/afl-plot @@ -291,7 +291,7 @@ _EOF_ ) | gnuplot -echo "[?] You can also use -g flag to view the plots in an GUI window, and interact with the plots (if you have build afl-plot-ui). Run \"afl-plot\" to know more." +echo "[?] You can also use -g flag to view the plots in an GUI window, and interact with the plots (if you have built afl-plot-ui). Run \"afl-plot-h\" to know more." fi -- cgit 1.4.1 From 691af58b7379dce67ab327405687480e89812e31 Mon Sep 17 00:00:00 2001 From: DMaroo Date: Sat, 7 Aug 2021 14:05:50 +0530 Subject: Removed the optional build dependencies for afl-plot-ui --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f82e4f1..35051a20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: update run: sudo apt-get update && sudo apt-get upgrade -y - name: install packages - run: sudo apt-get install -y -m -f --install-suggests build-essential git libtool libtool-bin automake bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build libgtk-3-0 libgtk-3-dev pkg-config + run: sudo apt-get install -y -m -f --install-suggests build-essential git libtool libtool-bin automake bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build - name: compiler installed run: gcc -v ; echo ; clang -v - name: install gcc plugin -- cgit 1.4.1 From fda210aabd9d5493d72f36eaaefe7bdff34c241c Mon Sep 17 00:00:00 2001 From: DMaroo Date: Sat, 7 Aug 2021 14:06:12 +0530 Subject: Added separate build and install instructions for afl-plot-ui --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9da42bcc..ed534c36 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ The easiest choice is to build and install everything: ```shell sudo apt-get update -sudo apt-get install -y build-essential python3-dev automake git flex bison libglib2.0-dev libpixman-1-dev python3-setuptools libgtk-3-0 libgtk-3-dev pkg-config +sudo apt-get install -y build-essential python3-dev automake git flex bison libglib2.0-dev libpixman-1-dev python3-setuptools # try to install llvm 11 and install the distro default if that fails sudo apt-get install -y lld-11 llvm-11 llvm-11-dev clang-11 || sudo apt-get install -y lld llvm llvm-dev clang sudo apt-get install -y gcc-$(gcc --version|head -n1|sed 's/.* //'|sed 's/\..*//')-plugin-dev libstdc++-$(gcc --version|head -n1|sed 's/.* //'|sed 's/\..*//')-dev @@ -1159,6 +1159,18 @@ If you have gnuplot installed, you can also generate some pretty graphs for any active fuzzing task using afl-plot. For an example of how this looks like, see [http://lcamtuf.coredump.cx/afl/plot/](http://lcamtuf.coredump.cx/afl/plot/). +You can also manually build and install afl-plot-ui, which is a helper utility +for showing the graphs generated by afl-plot in a graphical window using GTK. +You can build and install it as follows + +```shell +sudo apt install libgtk-3-0 libgtk-3-dev pkg-config +cd utils/plot_ui +make +cd ../../ +sudo make install +``` + ## Help: Crash triage The coverage-based grouping of crashes usually produces a small data set that -- cgit 1.4.1