source: zzuf/trunk/doc/zzuf.1 @ 1798

Last change on this file since 1798 was 1798, checked in by Sam Hocevar, 13 years ago
  • Correct thinko in manpage.
File size: 16.8 KB
Line 
1.TH zzuf 1 "2006-12-22" "zzuf"
2.SH NAME
3zzuf \- multiple purpose fuzzer
4.SH SYNOPSIS
5\fBzzuf\fR [\fB\-AcdimnqSvx\fR] [\fB\-s\fR \fIseed\fR|\fB\-s\fR \fIstart:stop\fR] [\fB\-r\fR \fIratio\fR|\fB\-r\fR \fImin:max\fR]
6.br
7       [\fB\-f\fR \fIfuzzing\fR] [\fB\-D\fR \fIdelay\fR] [\fB\-F\fR \fIforks\fR] [\fB\-C\fR \fIcrashes\fR] [\fB\-B\fR \fIbytes\fR]
8.br
9       [\fB\-T\fR \fIseconds\fR] [\fB\-M\fR \fImegabytes\fR] [\fB\-P\fR \fIprotect\fR] [\fB\-R\fR \fIrefuse\fR]
10.br
11       [\fB\-p\fR \fIpick\fR] [\fB\-b\fR \fIranges\fR] [\fB\-I\fR \fIinclude\fR] [\fB\-E\fR \fIexclude\fR]
12.br
13       [\fIPROGRAM\fR [\fB\-\-\fR] [\fIARGS\fR]...]
14.br
15\fBzzuf \-h\fR | \fB\-\-help\fR
16.br
17\fBzzuf \-V\fR | \fB\-\-version\fR
18.SH DESCRIPTION
19.PP
20\fBzzuf\fR is a transparent application input fuzzer. It works by intercepting
21file and network operations and changing random bits in the program's input.
22\fBzzuf\fR's behaviour is deterministic, making it easy to reproduce bugs.
23.SH USAGE
24.PP
25\fBzzuf\fR will run an application specified on its command line, one or
26several times, with optional arguments, and will report the application's
27relevant behaviour on the standard error channel, eg:
28.PP
29\fB    zzuf cat /dev/zero\fR
30.PP
31If you want to specify flags for your application, put a \(oq\fB\-\-\fR\(cq
32marker before them on the command line (otherwise \fBzzuf\fR will try to
33interpret them as arguments for itself), eg:
34.PP
35\fB    zzuf \-B 1000 cat \-\- \-v /dev/zero\fR
36.PP
37When no program is specified, \fBzzuf\fR simply fuzzes the standard input, as
38if the \fBcat\fR utility had been called:
39.PP
40\fB    zzuf < /dev/zero\fR
41.SH OPTIONS
42.TP
43\fB\-A\fR, \fB\-\-autoinc\fR
44Increment random seed each time a new file is opened. This is only required
45if one instance of the application is expected to open the same file several
46times and you want to test a different seed each time.
47.TP
48\fB\-b\fR, \fB\-\-bytes\fR=\fIranges\fR
49Restrict fuzzing to bytes whose offsets in the file are within \fIranges\fR.
50
51Range values start at zero and are inclusive. Use dashes between range values
52and commas between ranges. If the right-hand part of a range is ommited, it
53means end of file. For instance, to restrict fuzzing to bytes 0, 3, 4, 5 and
54all bytes after offset 31, use \(oq\fB\-r0,3-5,31-\fR\(cq.
55
56This option is useful to preserve file headers or corrupt only a specific
57portion of a file.
58.TP
59\fB\-B\fR, \fB\-\-max\-bytes\fR=\fIn\fR
60Automatically terminate child processes that output more than \fIn\fR bytes
61on the standard output and standard error channels. This is useful to detect
62infinite loops. See also the \fB\-T\fR flag.
63.TP
64\fB\-c\fR, \fB\-\-cmdline\fR
65Only fuzz files whose name is specified in the target application's command
66line. This is mostly a shortcut to avoid specifying twice the argument:
67
68\fB    zzuf \-c cat file.txt\fR
69
70has the same effect as
71
72\fB    zzuf \-I \(aq^file\\.txt$\(aq cat file.txt\fR
73
74See the \fB\-I\fR flag for more information on restricting fuzzing to
75specific files.
76.TP
77\fB\-C\fR, \fB\-\-max\-crashes\fR=\fIn\fR
78Stop forking when at least \fIn\fR children have crashed. The default value
79is 1, meaning \fBzzuf\fR will stop as soon as one child has crashed. A process
80is considered to have crashed if any signal (such as, but not limited to,
81\fBSIGSEGV\fR) caused it to exit. If the \fB\-x\fR flag is used, this will
82also include processes that exit with a non-zero status.
83
84This option is only relevant if the \fB\-s\fR flag is used with a range
85argument.
86.TP
87\fB\-d\fR, \fB\-\-debug\fR
88Activate the display of debug messages.
89.TP
90\fB\-D\fR, \fB\-\-delay\fR=\fIdelay\fR
91Do not launch more than one process every \fIdelay\fR seconds. This option
92should be used together with \fB\-F\fR to avoid fork bombs.
93.TP
94\fB\-E\fR, \fB\-\-exclude\fR=\fIregex\fR
95Do not fuzz files whose name matches the \fIregex\fR regular expression. This
96option supersedes anything that is specified by the \fB\-I\fR flag. Use this
97for instance if you are unsure of what files your application is going to read
98and do not want it to fuzz files in the \fB/etc\fR directory.
99
100Multiple \fB\-E\fR flags can be specified, in which case files matching any one
101of the regular expressions will be ignored.
102.TP
103\fB\-f\fR, \fB\-\-fuzzing\fR=\fImode\fR
104Select how the input is fuzzed. Valid values for \fImode\fR are:
105.RS
106.TP
107\fBxor\fR
108randomly set and unset bits
109.TP
110\fBset\fR
111only set bits
112.TP
113\fBunset\fR
114only unset bits
115.RE
116.IP
117The default value for \fImode\fR is \fBxor\fR.
118.TP
119\fB\-F\fR, \fB\-\-max\-forks\fR=\fIforks\fR
120Specify the number of simultaneous children that can be run.
121
122This option is only relevant if the \fB\-s\fR flag is used with a range
123argument. See also the \fB\-D\fR flag.
124.TP
125\fB\-i\fR, \fB\-\-stdin\fR
126Fuzz the application's standard input. By default \fBzzuf\fR only fuzzes files.
127.TP
128\fB\-I\fR, \fB\-\-include\fR=\fIregex\fR
129Only fuzz files whose name matches the \fIregex\fR regular expression. Use
130this for instance if your application reads configuration files at startup
131and you only want specific files to be fuzzed.
132
133Multiple \fB\-I\fR flags can be specified, in which case files matching any one
134of the regular expressions will be fuzzed. See also the \fB\-c\fR flag.
135.TP
136\fB\-m\fR, \fB\-\-md5\fR
137Instead of displaying the program's \fIstandard output\fR, just print its MD5
138digest to \fBzzuf\fR's standard output. The standard error channel is left
139untouched.
140.TP
141\fB\-M\fR, \fB\-\-max-memory\fR=\fImegabytes\fR
142Specify the maximum amount of memory, in megabytes, that children are allowed
143to allocate. This is useful to detect infinite loops that eat up a lot of
144memory. The value should set reasonably high so as not to interfer with normal
145program operation.
146
147\fBzzuf\fR uses the \fBsetrlimit\fR() call to set memory usage limitations and
148relies on the operating system's ability to enforce such limitations.
149.TP
150\fB\-n\fR, \fB\-\-network\fR
151Fuzz the application's network input. By default \fBzzuf\fR only fuzzes files.
152.TP
153\fB\-p\fR, \fB\-\-pick\fR=\fIlist\fR
154Cherry-pick the file descriptors that get fuzzed. The Nth descriptor will
155really be fuzzed only if N is in \fIlist\fR.
156
157Values start at one and ranges are inclusive. Use dashes between values and
158commas between ranges. If the right-hand part of a range is ommited, it means
159all subsequent file descriptors. For instance, to restrict fuzzing to the
160first opened descriptor and all descriptors starting from the 10th, use
161\(oq\fB\-p1,10-\fR\(cq.
162
163Note that this option only affects file descriptors that would otherwise be
164fuzzed. Even if 10 write-only descriptors are opened at the beginning of the
165program, the next read-write or read-only descriptor will be the first one
166considered by the \fB\-p\fR flag.
167.TP
168\fB\-P\fR, \fB\-\-protect\fR=\fIlist\fR
169Protect a list of characters so that if they appear in input data that would
170normally be fuzzed, they are left unmodified instead.
171
172Characters in \fIlist\fR can be expressed verbatim or through escape sequences.
173The sequences interpreted by \fBzzuf\fR are:
174.RS
175.TP
176\fB\\n\fR
177new line
178.TP
179\fB\\r\fR
180return
181.TP
182\fB\\t\fR
183tabulation
184.TP
185\fB\\\fR\fINNN\fR
186the byte whose octal value is \fINNN\fR
187.TP
188\fB\\x\fR\fINN\fR
189the byte whose hexadecimal value is \fINN\fR
190.TP
191\fB\\\\\fR
192backslash (\(oq\\\(cq)
193.RE
194.IP
195You can use \(oq\fB\-\fR\(cq to specify ranges. For instance, to protect all
196bytes from \(oq\\001\(cq to \(oq/\(cq, use \(oq\fB\-P\ \(aq\\001\-/\(aq\fR\(cq.
197
198The statistical outcome of this option should not be overlooked: if characters
199are protected, the effect of the \(oq\fB\-r\fR\(cq flag will vary depending
200on the data being fuzzed. For instance, asking to fuzz 1% of input bits
201(\fB\-r0.01\fR) and to protect lowercase characters (\fB\-P\ a\-z\fR) will
202result in an actual average fuzzing ratio of 0.9% with truly random data,
2030.3% with random ASCII data and 0.2% with standard English text.
204
205See also the \fB\-R\fR flag.
206.TP
207\fB\-q\fR, \fB\-\-quiet\fR
208Hide the output of the fuzzed application. This is useful if the application
209is very verbose but only its exit code or signaled status is really useful to
210you.
211.TP
212\fB\-r\fR, \fB\-\-ratio\fR=\fIratio\fR
213.PD 0
214.TP
215\fB\-r\fR, \fB\-\-ratio\fR=\fImin:max\fR
216.PD
217Specify the proportion of bits that will be randomly fuzzed. A value of 0
218will not fuzz anything. A value of 0.05 will fuzz 5% of the open files'
219bits. A value of 1.0 or more will fuzz all the bytes, theoretically making
220the input files undiscernible from random data. The default fuzzing ratio
221is 0.004 (fuzz 0.4% of the files' bits).
222
223A range can also be specified. When doing so, \fBzzuf\fR will pick ratio
224values from the interval. The choice is deterministic and only depends on
225the interval bounds and the current seed.
226.TP
227\fB\-R\fR, \fB\-\-refuse\fR=\fIlist\fR
228Refuse a list of characters by not fuzzing bytes that would otherwise be
229changed to a character that is in \fIlist\fR. If the original byte is already
230in \fIlist\fR, it is left unchanged.
231
232See the \fB\-P\fR option for a description of \fIlist\fR.
233.TP
234\fB\-s\fR, \fB\-\-seed\fR=\fIseed\fR
235.PD 0
236.TP
237\fB\-s\fR, \fB\-\-seed\fR=\fIstart:stop\fR
238.PD
239Specify the random seed to use for fuzzing, or a range of random seeds.
240Running \fBzzuf\fR twice with the same random seed will fuzz the files exactly
241the same way, even with a different target application. The purpose of this is
242to use simple utilities such as \fBcat\fR or \fBcp\fR to generate a file that
243causes the target application to crash.
244
245If a range is specified, \fBzzuf\fR will run the application several times,
246each time with a different seed, and report the behaviour of each run.
247.TP
248\fB\-S\fR, \fB\-\-signal\fR
249Prevent children from installing signal handlers for signals that usually
250cause coredumps. These signals are \fBSIGABRT\fR, \fBSIGFPE\fR, \fBSIGILL\fR,
251\fBSIGQUIT\fR, \fBSIGSEGV\fR, \fBSIGTRAP\fR and, if available on the running
252platform, \fBSIGSYS\fR, \fBSIGEMT\fR, \fBSIGBUS\fR, \fBSIGXCPU\fR and
253\fBSIGXFSZ\fR. Instead of calling the signal handler, the application will
254simply crash. If you do not want core dumps, you should set appropriate limits
255with the \fBlimit coredumpsize\fR command. See your shell's documentation on
256how to set such limits.
257.TP
258\fB\-T\fR, \fB\-\-max\-time\fR=\fIn\fR
259Automatically terminate child processes that run for more than \fIn\fR
260seconds. This is useful to detect infinite loops or processes stuck in other
261situations. See also the \fB\-B\fR flag.
262.TP
263\fB\-v\fR, \fB\-\-verbose\fR
264Print information during the run, such as the current seed, what processes
265get run, their exit status, etc.
266.TP
267\fB\-x\fR, \fB\-\-check\-exit\fR
268Report processes that exit with a non-zero status. By default only processes
269that crash due to a signal are reported.
270.TP
271\fB\-h\fR, \fB\-\-help\fR
272Display a short help message and exit.
273.TP
274\fB\-V\fR, \fB\-\-version\fR
275Output version information and exit.
276.SH DIAGNOSTICS
277.PP
278Exit status is zero if no child process crashed. If one or several children
279crashed, \fBzzuf\fR exits with status 1.
280.SH EXAMPLES
281.PP
282Fuzz the input of the \fBcat\fR program using default settings:
283.PP
284\fB    zzuf cat /etc/motd\fR
285.PP
286Fuzz 1% of the input bits of the \fBcat\fR program using seed 94324:
287.PP
288\fB    zzuf \-s94324 \-r0.01 cat /etc/motd\fR
289.PP
290Fuzz the input of the \fBcat\fR program but do not fuzz newline characters
291and prevent non-ASCII characters from appearing in the output:
292.PP
293\fB    zzuf \-P \(aq\\n\(aq \-R \(aq\\x00\-\\x1f\\x7f\-\\xff\(aq cat /etc/motd\fR
294.PP
295Fuzz the input of the \fBconvert\fR program, using file \fBfoo.jpeg\fR as the
296original input and excluding \fB.xml\fR files from fuzzing (because
297\fBconvert\fR will also open its own XML configuration files and we do not
298want \fBzzuf\fR to fuzz them):
299.PP
300\fB    zzuf \-E \(aq\\.xml$\(aq convert \-\- foo.jpeg \-format tga /dev/null\fR
301.PP
302Fuzz the input of VLC, using file \fBmovie.avi\fR as the original input
303and restricting fuzzing to filenames that appear on the command line
304(\fB\-c\fR), then generate \fBfuzzy\-movie.avi\fR which is a file that
305can be read by VLC to reproduce the same behaviour without using
306\fBzzuf\fR:
307.PP
308\fB    zzuf \-c \-s87423 \-r0.01 vlc movie.avi\fR
309.br
310\fB    zzuf \-c \-s87423 \-r0.01 <movie.avi >fuzzy\-movie.avi\fR
311.br
312\fB    vlc fuzzy\-movie.avi\fR
313.PP
314Fuzz between 0.1% and 2% of MPlayer's input bits (\fB\-r0.001:0.02\fR)
315with seeds 0 to 9999 (\fB\-s0:10000\fR), preserving the AVI 4-byte header
316by restricting fuzzing to offsets after 4 (\fB\-b4\-\fR), disabling its
317standard output messages (\fB\-q\fR), launching up to five simultaneous child
318processes (\fB\-F5\fR) but waiting at least half a second between launches
319(\fB\-D0.5\fR), killing MPlayer if it takes more than one minute to
320read the file (\fB\-T60\fR) and disabling its \fBSIGSEGV\fR signal handler
321(\fB\-S\fR):
322.PP
323\fB    zzuf \-c \-r0.001:0.02 \-s0:10000 \-b4\- \-q \-F5 \-D0.5 \-T60 \-S \\\fR
324.br
325\fB      mplayer \-\- \-benchmark \-vo null \-fps 1000 movie.avi\fR
326.PP
327Create an HTML-like file that loads 200 times the same \fBhello.jpg\fR image
328and open it in Firefox\(tm in auto-increment mode (\fB\-A\fR):
329.PP
330\fB    seq -f \(aq<img src="hello.jpg#%g">\(aq 1 200 > hello.html\fR
331.br
332      (or: \fBjot -w \(aq<img src="hello.jpg#%d">\(aq 200 1 > hello.html\fR)
333.br
334\fB    zzuf -A -I \(aqhello[.]jpg\(aq -r0.001 firefox hello.html\fR
335.PP
336Run a simple HTTP redirector on the local host using \fBsocat\fR and
337corrupt each network connection (\fB\-n\fR) in a different way (\fB\-A\fR)
338after one megabyte of data was received on it (\fB\-b1000000\-\fR):
339.PP
340\fB     zzuf \-n \-A \-b1000000\- \\\fR
341\fB       socat TCP4-LISTEN:8080,reuseaddr,fork TCP4:192.168.1.42:80\fR
342.SH RESTRICTIONS
343.PP
344Due to \fBzzuf\fR using shared object preloading (\fBLD_PRELOAD\fR,
345\fB_RLD_LIST\fB, \fBDYLD_INSERT_LIBRARIES\fR, etc.) to run its child
346processes, it will fail in the presence of any mechanism that disables
347preloading. For instance setuid root binaries will not be fuzzed when run
348as an unprivileged user.
349.PP
350For the same reasons, \fBzzuf\fR will also not work with statically linked
351binaries. Bear this in mind when using \fBzzuf\fR on the OpenBSD platform,
352where \fBcat\fR, \fBcp\fR and \fBdd\fR are static binaries.
353.PP
354Though best efforts are made, identical behaviour for different versions of
355\fBzzuf\fR is not guaranteed. The reproducibility for subsequent calls on
356different operating systems and with different target programs is only
357guaranteed when the same version of \fBzzuf\fR is being used.
358.SH BUGS
359.PP
360\fBzzuf\fR probably does not behave correctly with 64-bit offsets.
361.PP
362It is not yet possible to insert or drop bytes from the input, to fuzz
363according to the file format, to swap bytes, etc. More advanced fuzzing
364methods are planned.
365.PP
366As of now, \fBzzuf\fR does not really support multithreaded applications. The
367behaviour with multithreaded applications where more than one thread does file
368descriptor operations is undefined.
369.SH NOTES
370In order to intercept file and network operations, signal handlers and memory
371allocations, \fBzzuf\fR diverts and reimplements the following functions,
372which can be private libc symbols, too:
373.TP
374Unix file descriptor handling:
375\fBopen\fR(), \fBlseek\fR(), \fBread\fR(), \fBreadv\fR(), \fBpread\fR(),
376\fBaccept\fR(), \fBsocket\fR(), \fBrecv\fR(), \fBrecvfrom\fR(), \fBrecvmsg\fR(),
377\fBaio_read\fR(), \fBaio_return\fR(), \fBclose\fR()
378.TP
379Standard IO streams:
380\fBfopen\fR(), \fBfreopen\fR(), \fBfseek\fR(), \fBfseeko\fR(), \fBrewind\fR(),
381\fBfread\fR(), \fBgetc\fR(), \fBfgetc\fR(), \fBfgets\fR(), \fBungetc\fR(),
382\fBfclose\fR()
383.TP
384Memory management:
385\fBmmap\fR(), \fBmunmap\fR(), \fBmalloc\fR(), \fBcalloc\fR(), \fBvalloc\fR(),
386\fBfree\fR(), \fBmemalign\fR(), \fBposix_memalign\fR()
387.TP
388Linux-specific:
389\fBopen64\fR(), \fBlseek64\fR(), \fBmmap64\fR(), \fB_IO_getc\fR(),
390\fBgetline\fR(), \fBgetdelim\fR(), \fB__getdelim\fR()
391.TP
392BSD-specific:
393\fBfgetln\fR(), \fB__srefill\fR()
394.TP
395Mac OS X-specific:
396\fBmap_fd\fR()
397.TP
398Signal handling:
399\fBsignal\fR(), \fBsigaction\fR()
400.PP
401If an application manipulates file descriptors (reading data, seeking around)
402using functions that are not in that list, \fBzzuf\fR will not fuzz its
403input consistently and the results should not be trusted. You can use a tool
404such as \fBltrace(1)\fR on Linux to know the missing functions.
405.PP
406On BSD systems, such as FreeBSD or Mac OS X, \fB__srefill\fR() is enough to
407monitor all standard IO streams functions. On other systems, such as Linux,
408each function is reimplemented on a case by case basis. One important
409unimplemented function is \fBfscanf\fR(), because of its complexity. Missing
410functions will be added upon user request.
411.SH HISTORY
412.PP
413\fBzzuf\fR started its life in 2002 as the \fBstreamfucker\fR tool, a small
414multimedia stream corrupter used to find bugs in the VLC media player.
415.SH AUTHOR
416.PP
417Copyright \(co 2002, 2007 Sam Hocevar <sam@zoy.org>.
418.PP
419\fBzzuf\fR and this manual page are free software. They come without any
420warranty, to the extent permitted by applicable law. You can redistribute
421them and/or modify them under the terms of the Do What The Fuck You Want
422To Public License, Version 2, as published by Sam Hocevar. See
423\fBhttp://sam.zoy.org/wtfpl/COPYING\fR for more details.
424.PP
425\fBzzuf\fR's webpage can be found at \fBhttp://sam.zoy.org/zzuf/\fR.
Note: See TracBrowser for help on using the repository browser.