afl-whatsup 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/sh
  2. #
  3. # american fuzzy lop - status check tool
  4. # --------------------------------------
  5. #
  6. # Written and maintained by Michal Zalewski <lcamtuf@google.com>
  7. #
  8. # Copyright 2015 Google Inc. All rights reserved.
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at:
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # This tool summarizes the status of any locally-running synchronized
  17. # instances of afl-fuzz.
  18. #
  19. echo "status check tool for afl-fuzz by <lcamtuf@google.com>"
  20. echo
  21. if [ "$1" = "-s" ]; then
  22. SUMMARY_ONLY=1
  23. DIR="$2"
  24. else
  25. unset SUMMARY_ONLY
  26. DIR="$1"
  27. fi
  28. if [ "$DIR" = "" ]; then
  29. echo "Usage: $0 [ -s ] afl_sync_dir" 1>&2
  30. echo 1>&2
  31. echo "The -s option causes the tool to skip all the per-fuzzer trivia and show" 1>&2
  32. echo "just the summary results. See docs/parallel_fuzzing.txt for additional tips." 1>&2
  33. echo 1>&2
  34. exit 1
  35. fi
  36. cd "$DIR" || exit 1
  37. if [ -d queue ]; then
  38. echo "[-] Error: parameter is an individual output directory, not a sync dir." 1>&2
  39. exit 1
  40. fi
  41. CUR_TIME=`date +%s`
  42. TMP=`mktemp -t .afl-whatsup-XXXXXXXX` || exit 1
  43. ALIVE_CNT=0
  44. DEAD_CNT=0
  45. TOTAL_TIME=0
  46. TOTAL_EXECS=0
  47. TOTAL_EPS=0
  48. TOTAL_CRASHES=0
  49. TOTAL_PFAV=0
  50. TOTAL_PENDING=0
  51. if [ "$SUMMARY_ONLY" = "" ]; then
  52. echo "Individual fuzzers"
  53. echo "=================="
  54. echo
  55. fi
  56. for i in `find . -maxdepth 2 -iname fuzzer_stats | sort`; do
  57. sed 's/^command_line.*$/_skip:1/;s/[ ]*:[ ]*/="/;s/$/"/' "$i" >"$TMP"
  58. . "$TMP"
  59. RUN_UNIX=$((CUR_TIME - start_time))
  60. RUN_DAYS=$((RUN_UNIX / 60 / 60 / 24))
  61. RUN_HRS=$(((RUN_UNIX / 60 / 60) % 24))
  62. if [ "$SUMMARY_ONLY" = "" ]; then
  63. echo ">>> $afl_banner ($RUN_DAYS days, $RUN_HRS hrs) <<<"
  64. echo
  65. fi
  66. if ! kill -0 "$fuzzer_pid" 2>/dev/null; then
  67. if [ "$SUMMARY_ONLY" = "" ]; then
  68. echo " Instance is dead or running remotely, skipping."
  69. echo
  70. fi
  71. DEAD_CNT=$((DEAD_CNT + 1))
  72. continue
  73. fi
  74. ALIVE_CNT=$((ALIVE_CNT + 1))
  75. EXEC_SEC=$((execs_done / RUN_UNIX))
  76. PATH_PERC=$((cur_path * 100 / paths_total))
  77. TOTAL_TIME=$((TOTAL_TIME + RUN_UNIX))
  78. TOTAL_EPS=$((TOTAL_EPS + EXEC_SEC))
  79. TOTAL_EXECS=$((TOTAL_EXECS + execs_done))
  80. TOTAL_CRASHES=$((TOTAL_CRASHES + unique_crashes))
  81. TOTAL_PENDING=$((TOTAL_PENDING + pending_total))
  82. TOTAL_PFAV=$((TOTAL_PFAV + pending_favs))
  83. if [ "$SUMMARY_ONLY" = "" ]; then
  84. echo " cycle $((cycles_done + 1)), lifetime speed $EXEC_SEC execs/sec, path $cur_path/$paths_total (${PATH_PERC}%)"
  85. if [ "$unique_crashes" = "0" ]; then
  86. echo " pending $pending_favs/$pending_total, coverage $bitmap_cvg, no crashes yet"
  87. else
  88. echo " pending $pending_favs/$pending_total, coverage $bitmap_cvg, crash count $unique_crashes (!)"
  89. fi
  90. echo
  91. fi
  92. done
  93. rm -f "$TMP"
  94. TOTAL_DAYS=$((TOTAL_TIME / 60 / 60 / 24))
  95. TOTAL_HRS=$(((TOTAL_TIME / 60 / 60) % 24))
  96. test "$TOTAL_TIME" = "0" && TOTAL_TIME=1
  97. echo "Summary stats"
  98. echo "============="
  99. echo
  100. echo " Fuzzers alive : $ALIVE_CNT"
  101. if [ ! "$DEAD_CNT" = "0" ]; then
  102. echo " Dead or remote : $DEAD_CNT (excluded from stats)"
  103. fi
  104. echo " Total run time : $TOTAL_DAYS days, $TOTAL_HRS hours"
  105. echo " Total execs : $((TOTAL_EXECS / 1000 / 1000)) million"
  106. echo " Cumulative speed : $TOTAL_EPS execs/sec"
  107. echo " Pending paths : $TOTAL_PFAV faves, $TOTAL_PENDING total"
  108. if [ "$ALIVE_CNT" -gt "1" ]; then
  109. echo " Pending per fuzzer : $((TOTAL_PFAV/ALIVE_CNT)) faves, $((TOTAL_PENDING/ALIVE_CNT)) total (on average)"
  110. fi
  111. echo " Crashes found : $TOTAL_CRASHES locally unique"
  112. echo
  113. exit 0