2 # -*- coding: utf-8 -*-
4 # dissector_fuzz.sh -- fuzz test netsniff-ng's dissector and pcap io methods
5 # with shitty pcap example files from the Wireshark archive
7 # Copyright (C) 2012 Daniel Borkmann <borkmann@redhat.com>
8 # Copyright (C) 2012 Stefan Seering <sseerin@imn.htwk-leipzig.de>
10 # Note: build and *install* the toolkit first before running this script!
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License version 2 as
14 # published by the Free Software Foundation.
18 if [ ${BASH_VERSINFO} -lt 3 ] ; then
19 echo 'Error: Your bash need to be version 3 or newer. Exiting.'
20 exit 1 # operators like =~ produce errors silently in old bash versions, so exit here
23 archive
='ftp://wireshark.org/automated/captures/'
24 show_output
='' # empty string evaluates to false
25 run_through
='' # empty string evaluates to false
30 if [ $# -gt 0 ] ; then
31 if [ "$1" = '-h' -o "$1" = '--help' -o "$1" = '--usage' ] ; then
32 echo 'Usage: dissector_fuzz [-s (show netsniff-ng output, default: no)] [-r (keep running on errors, default: no)] [netsniff-ng long-args]'
37 if [ "${opt}" = '-s' ] ; then
39 elif [ "${opt}" = '-r' ] ; then
42 netsniff_ng_opts
="${netsniff_ng_opts} ${opt}";
49 wget
-r -Nc -np -nd -A.pcap
"$archive" |
& grep -E "%|^--"
54 echo "Testing file $file ..."
55 if [ $show_output ]; then
56 netsniff-ng
--in "$file" "${netsniff_ng_opts}"
58 netsniff-ng
--in "$file" "${netsniff_ng_opts}" > /dev
/null
61 echo "Fuck, core dumped on $file!"
62 let count_cores
=count_cores
+1
63 if [ $run_through ]; then
71 if which cowsay
> /dev
/null
; then
77 ${echo_cmd} 'Your fuckup Score'
78 echo " * tested pcaps: $count_files"
79 echo " * core dumps: $count_cores"