xref: /aosp_15_r20/external/AFLplusplus/docs/afl-fuzz_approach.md (revision 08b48e0b10e97b33e7b60c5b6e2243bd915777f2)
1*08b48e0bSAndroid Build Coastguard Worker# The afl-fuzz approach
2*08b48e0bSAndroid Build Coastguard Worker
3*08b48e0bSAndroid Build Coastguard WorkerAFL++ is a brute-force fuzzer coupled with an exceedingly simple but rock-solid
4*08b48e0bSAndroid Build Coastguard Workerinstrumentation-guided genetic algorithm. It uses a modified form of edge
5*08b48e0bSAndroid Build Coastguard Workercoverage to effortlessly pick up subtle, local-scale changes to program control
6*08b48e0bSAndroid Build Coastguard Workerflow.
7*08b48e0bSAndroid Build Coastguard Worker
8*08b48e0bSAndroid Build Coastguard WorkerNote: If you are interested in a more current up-to-date deep dive how AFL++
9*08b48e0bSAndroid Build Coastguard Workerworks then we commend this blog post:
10*08b48e0bSAndroid Build Coastguard Worker[https://blog.ritsec.club/posts/afl-under-hood/](https://blog.ritsec.club/posts/afl-under-hood/)
11*08b48e0bSAndroid Build Coastguard Worker
12*08b48e0bSAndroid Build Coastguard WorkerSimplifying a bit, the overall algorithm can be summed up as:
13*08b48e0bSAndroid Build Coastguard Worker
14*08b48e0bSAndroid Build Coastguard Worker1) Load user-supplied initial test cases into the queue.
15*08b48e0bSAndroid Build Coastguard Worker
16*08b48e0bSAndroid Build Coastguard Worker2) Take the next input file from the queue.
17*08b48e0bSAndroid Build Coastguard Worker
18*08b48e0bSAndroid Build Coastguard Worker3) Attempt to trim the test case to the smallest size that doesn't alter the
19*08b48e0bSAndroid Build Coastguard Worker   measured behavior of the program.
20*08b48e0bSAndroid Build Coastguard Worker
21*08b48e0bSAndroid Build Coastguard Worker4) Repeatedly mutate the file using a balanced and well-researched variety of
22*08b48e0bSAndroid Build Coastguard Worker   traditional fuzzing strategies.
23*08b48e0bSAndroid Build Coastguard Worker
24*08b48e0bSAndroid Build Coastguard Worker5) If any of the generated mutations resulted in a new state transition recorded
25*08b48e0bSAndroid Build Coastguard Worker   by the instrumentation, add mutated output as a new entry in the queue.
26*08b48e0bSAndroid Build Coastguard Worker
27*08b48e0bSAndroid Build Coastguard Worker6) Go to 2.
28*08b48e0bSAndroid Build Coastguard Worker
29*08b48e0bSAndroid Build Coastguard WorkerThe discovered test cases are also periodically culled to eliminate ones that
30*08b48e0bSAndroid Build Coastguard Workerhave been obsoleted by newer, higher-coverage finds; and undergo several other
31*08b48e0bSAndroid Build Coastguard Workerinstrumentation-driven effort minimization steps.
32*08b48e0bSAndroid Build Coastguard Worker
33*08b48e0bSAndroid Build Coastguard WorkerAs a side result of the fuzzing process, the tool creates a small,
34*08b48e0bSAndroid Build Coastguard Workerself-contained corpus of interesting test cases. These are extremely useful for
35*08b48e0bSAndroid Build Coastguard Workerseeding other, labor- or resource-intensive testing regimes - for example, for
36*08b48e0bSAndroid Build Coastguard Workerstress-testing browsers, office applications, graphics suites, or closed-source
37*08b48e0bSAndroid Build Coastguard Workertools.
38*08b48e0bSAndroid Build Coastguard Worker
39*08b48e0bSAndroid Build Coastguard WorkerThe fuzzer is thoroughly tested to deliver out-of-the-box performance far
40*08b48e0bSAndroid Build Coastguard Workersuperior to blind fuzzing or coverage-only tools.
41*08b48e0bSAndroid Build Coastguard Worker
42*08b48e0bSAndroid Build Coastguard Worker## Understanding the status screen
43*08b48e0bSAndroid Build Coastguard Worker
44*08b48e0bSAndroid Build Coastguard WorkerThis section provides an overview of the status screen - plus tips for
45*08b48e0bSAndroid Build Coastguard Workertroubleshooting any warnings and red text shown in the UI.
46*08b48e0bSAndroid Build Coastguard Worker
47*08b48e0bSAndroid Build Coastguard WorkerFor the general instruction manual, see [README.md](README.md).
48*08b48e0bSAndroid Build Coastguard Worker
49*08b48e0bSAndroid Build Coastguard Worker### A note about colors
50*08b48e0bSAndroid Build Coastguard Worker
51*08b48e0bSAndroid Build Coastguard WorkerThe status screen and error messages use colors to keep things readable and
52*08b48e0bSAndroid Build Coastguard Workerattract your attention to the most important details. For example, red almost
53*08b48e0bSAndroid Build Coastguard Workeralways means "consult this doc" :-)
54*08b48e0bSAndroid Build Coastguard Worker
55*08b48e0bSAndroid Build Coastguard WorkerUnfortunately, the UI will only render correctly if your terminal is using
56*08b48e0bSAndroid Build Coastguard Workertraditional un*x palette (white text on black background) or something close to
57*08b48e0bSAndroid Build Coastguard Workerthat.
58*08b48e0bSAndroid Build Coastguard Worker
59*08b48e0bSAndroid Build Coastguard WorkerIf you are using inverse video, you may want to change your settings, say:
60*08b48e0bSAndroid Build Coastguard Worker
61*08b48e0bSAndroid Build Coastguard Worker- For GNOME Terminal, go to `Edit > Profile` preferences, select the "colors"
62*08b48e0bSAndroid Build Coastguard Worker  tab, and from the list of built-in schemes, choose "white on black".
63*08b48e0bSAndroid Build Coastguard Worker- For the MacOS X Terminal app, open a new window using the "Pro" scheme via the
64*08b48e0bSAndroid Build Coastguard Worker  `Shell > New Window` menu (or make "Pro" your default).
65*08b48e0bSAndroid Build Coastguard Worker
66*08b48e0bSAndroid Build Coastguard WorkerAlternatively, if you really like your current colors, you can edit config.h to
67*08b48e0bSAndroid Build Coastguard Workercomment out USE_COLORS, then do `make clean all`.
68*08b48e0bSAndroid Build Coastguard Worker
69*08b48e0bSAndroid Build Coastguard WorkerWe are not aware of any other simple way to make this work without causing other
70*08b48e0bSAndroid Build Coastguard Workerside effects - sorry about that.
71*08b48e0bSAndroid Build Coastguard Worker
72*08b48e0bSAndroid Build Coastguard WorkerWith that out of the way, let's talk about what's actually on the screen...
73*08b48e0bSAndroid Build Coastguard Worker
74*08b48e0bSAndroid Build Coastguard Worker### The status bar
75*08b48e0bSAndroid Build Coastguard Worker
76*08b48e0bSAndroid Build Coastguard Worker```
77*08b48e0bSAndroid Build Coastguard Workeramerican fuzzy lop ++3.01a (default) [fast] {0}
78*08b48e0bSAndroid Build Coastguard Worker```
79*08b48e0bSAndroid Build Coastguard Worker
80*08b48e0bSAndroid Build Coastguard WorkerThe top line shows you which mode afl-fuzz is running in (normal: "american
81*08b48e0bSAndroid Build Coastguard Workerfuzzy lop", crash exploration mode: "peruvian rabbit mode") and the version of
82*08b48e0bSAndroid Build Coastguard WorkerAFL++. Next to the version is the banner, which, if not set with -T by hand,
83*08b48e0bSAndroid Build Coastguard Workerwill either show the binary name being fuzzed, or the -M/-S main/secondary name
84*08b48e0bSAndroid Build Coastguard Workerfor parallel fuzzing. Second to last is the power schedule mode being run
85*08b48e0bSAndroid Build Coastguard Worker(default: fast). Finally, the last item is the CPU id.
86*08b48e0bSAndroid Build Coastguard Worker
87*08b48e0bSAndroid Build Coastguard Worker### Process timing
88*08b48e0bSAndroid Build Coastguard Worker
89*08b48e0bSAndroid Build Coastguard Worker```
90*08b48e0bSAndroid Build Coastguard Worker  +----------------------------------------------------+
91*08b48e0bSAndroid Build Coastguard Worker  |        run time : 0 days, 8 hrs, 32 min, 43 sec    |
92*08b48e0bSAndroid Build Coastguard Worker  |   last new find : 0 days, 0 hrs, 6 min, 40 sec     |
93*08b48e0bSAndroid Build Coastguard Worker  | last uniq crash : none seen yet                    |
94*08b48e0bSAndroid Build Coastguard Worker  |  last uniq hang : 0 days, 1 hrs, 24 min, 32 sec    |
95*08b48e0bSAndroid Build Coastguard Worker  +----------------------------------------------------+
96*08b48e0bSAndroid Build Coastguard Worker```
97*08b48e0bSAndroid Build Coastguard Worker
98*08b48e0bSAndroid Build Coastguard WorkerThis section is fairly self-explanatory: it tells you how long the fuzzer has
99*08b48e0bSAndroid Build Coastguard Workerbeen running and how much time has elapsed since its most recent finds. This is
100*08b48e0bSAndroid Build Coastguard Workerbroken down into "paths" (a shorthand for test cases that trigger new execution
101*08b48e0bSAndroid Build Coastguard Workerpatterns), crashes, and hangs.
102*08b48e0bSAndroid Build Coastguard Worker
103*08b48e0bSAndroid Build Coastguard WorkerWhen it comes to timing: there is no hard rule, but most fuzzing jobs should be
104*08b48e0bSAndroid Build Coastguard Workerexpected to run for days or weeks; in fact, for a moderately complex project,
105*08b48e0bSAndroid Build Coastguard Workerthe first pass will probably take a day or so. Every now and then, some jobs
106*08b48e0bSAndroid Build Coastguard Workerwill be allowed to run for months.
107*08b48e0bSAndroid Build Coastguard Worker
108*08b48e0bSAndroid Build Coastguard WorkerThere's one important thing to watch out for: if the tool is not finding new
109*08b48e0bSAndroid Build Coastguard Workerpaths within several minutes of starting, you're probably not invoking the
110*08b48e0bSAndroid Build Coastguard Workertarget binary correctly and it never gets to parse the input files that are
111*08b48e0bSAndroid Build Coastguard Workerthrown at it; other possible explanations are that the default memory limit
112*08b48e0bSAndroid Build Coastguard Worker(`-m`) is too restrictive and the program exits after failing to allocate a
113*08b48e0bSAndroid Build Coastguard Workerbuffer very early on; or that the input files are patently invalid and always
114*08b48e0bSAndroid Build Coastguard Workerfail a basic header check.
115*08b48e0bSAndroid Build Coastguard Worker
116*08b48e0bSAndroid Build Coastguard WorkerIf there are no new paths showing up for a while, you will eventually see a big
117*08b48e0bSAndroid Build Coastguard Workerred warning in this section, too :-)
118*08b48e0bSAndroid Build Coastguard Worker
119*08b48e0bSAndroid Build Coastguard Worker### Overall results
120*08b48e0bSAndroid Build Coastguard Worker
121*08b48e0bSAndroid Build Coastguard Worker```
122*08b48e0bSAndroid Build Coastguard Worker  +-----------------------+
123*08b48e0bSAndroid Build Coastguard Worker  |  cycles done : 0      |
124*08b48e0bSAndroid Build Coastguard Worker  |  total paths : 2095   |
125*08b48e0bSAndroid Build Coastguard Worker  | uniq crashes : 0      |
126*08b48e0bSAndroid Build Coastguard Worker  |   uniq hangs : 19     |
127*08b48e0bSAndroid Build Coastguard Worker  +-----------------------+
128*08b48e0bSAndroid Build Coastguard Worker```
129*08b48e0bSAndroid Build Coastguard Worker
130*08b48e0bSAndroid Build Coastguard WorkerThe first field in this section gives you the count of queue passes done so far
131*08b48e0bSAndroid Build Coastguard Worker- that is, the number of times the fuzzer went over all the interesting test
132*08b48e0bSAndroid Build Coastguard Worker  cases discovered so far, fuzzed them, and looped back to the very beginning.
133*08b48e0bSAndroid Build Coastguard Worker  Every fuzzing session should be allowed to complete at least one cycle; and
134*08b48e0bSAndroid Build Coastguard Worker  ideally, should run much longer than that.
135*08b48e0bSAndroid Build Coastguard Worker
136*08b48e0bSAndroid Build Coastguard WorkerAs noted earlier, the first pass can take a day or longer, so sit back and
137*08b48e0bSAndroid Build Coastguard Workerrelax.
138*08b48e0bSAndroid Build Coastguard Worker
139*08b48e0bSAndroid Build Coastguard WorkerTo help make the call on when to hit `Ctrl-C`, the cycle counter is color-coded.
140*08b48e0bSAndroid Build Coastguard WorkerIt is shown in magenta during the first pass, progresses to yellow if new finds
141*08b48e0bSAndroid Build Coastguard Workerare still being made in subsequent rounds, then blue when that ends - and
142*08b48e0bSAndroid Build Coastguard Workerfinally, turns green after the fuzzer hasn't been seeing any action for a longer
143*08b48e0bSAndroid Build Coastguard Workerwhile.
144*08b48e0bSAndroid Build Coastguard Worker
145*08b48e0bSAndroid Build Coastguard WorkerThe remaining fields in this part of the screen should be pretty obvious:
146*08b48e0bSAndroid Build Coastguard Workerthere's the number of test cases ("paths") discovered so far, and the number of
147*08b48e0bSAndroid Build Coastguard Workerunique faults. The test cases, crashes, and hangs can be explored in real-time
148*08b48e0bSAndroid Build Coastguard Workerby browsing the output directory, see
149*08b48e0bSAndroid Build Coastguard Worker[#interpreting-output](#interpreting-output).
150*08b48e0bSAndroid Build Coastguard Worker
151*08b48e0bSAndroid Build Coastguard Worker### Cycle progress
152*08b48e0bSAndroid Build Coastguard Worker
153*08b48e0bSAndroid Build Coastguard Worker```
154*08b48e0bSAndroid Build Coastguard Worker  +-------------------------------------+
155*08b48e0bSAndroid Build Coastguard Worker  |  now processing : 1296 (61.86%)     |
156*08b48e0bSAndroid Build Coastguard Worker  | paths timed out : 0 (0.00%)         |
157*08b48e0bSAndroid Build Coastguard Worker  +-------------------------------------+
158*08b48e0bSAndroid Build Coastguard Worker```
159*08b48e0bSAndroid Build Coastguard Worker
160*08b48e0bSAndroid Build Coastguard WorkerThis box tells you how far along the fuzzer is with the current queue cycle: it
161*08b48e0bSAndroid Build Coastguard Workershows the ID of the test case it is currently working on, plus the number of
162*08b48e0bSAndroid Build Coastguard Workerinputs it decided to ditch because they were persistently timing out.
163*08b48e0bSAndroid Build Coastguard Worker
164*08b48e0bSAndroid Build Coastguard WorkerThe "*" suffix sometimes shown in the first line means that the currently
165*08b48e0bSAndroid Build Coastguard Workerprocessed path is not "favored" (a property discussed later on).
166*08b48e0bSAndroid Build Coastguard Worker
167*08b48e0bSAndroid Build Coastguard Worker### Map coverage
168*08b48e0bSAndroid Build Coastguard Worker
169*08b48e0bSAndroid Build Coastguard Worker```
170*08b48e0bSAndroid Build Coastguard Worker  +--------------------------------------+
171*08b48e0bSAndroid Build Coastguard Worker  |    map density : 10.15% / 29.07%     |
172*08b48e0bSAndroid Build Coastguard Worker  | count coverage : 4.03 bits/tuple     |
173*08b48e0bSAndroid Build Coastguard Worker  +--------------------------------------+
174*08b48e0bSAndroid Build Coastguard Worker```
175*08b48e0bSAndroid Build Coastguard Worker
176*08b48e0bSAndroid Build Coastguard WorkerThe section provides some trivia about the coverage observed by the
177*08b48e0bSAndroid Build Coastguard Workerinstrumentation embedded in the target binary.
178*08b48e0bSAndroid Build Coastguard Worker
179*08b48e0bSAndroid Build Coastguard WorkerThe first line in the box tells you how many branch tuples already were hit, in
180*08b48e0bSAndroid Build Coastguard Workerproportion to how much the bitmap can hold. The number on the left describes the
181*08b48e0bSAndroid Build Coastguard Workercurrent input; the one on the right is the value for the entire input corpus.
182*08b48e0bSAndroid Build Coastguard Worker
183*08b48e0bSAndroid Build Coastguard WorkerBe wary of extremes:
184*08b48e0bSAndroid Build Coastguard Worker
185*08b48e0bSAndroid Build Coastguard Worker- Absolute numbers below 200 or so suggest one of three things: that the program
186*08b48e0bSAndroid Build Coastguard Worker  is extremely simple; that it is not instrumented properly (e.g., due to being
187*08b48e0bSAndroid Build Coastguard Worker  linked against a non-instrumented copy of the target library); or that it is
188*08b48e0bSAndroid Build Coastguard Worker  bailing out prematurely on your input test cases. The fuzzer will try to mark
189*08b48e0bSAndroid Build Coastguard Worker  this in pink, just to make you aware.
190*08b48e0bSAndroid Build Coastguard Worker- Percentages over 70% may very rarely happen with very complex programs that
191*08b48e0bSAndroid Build Coastguard Worker  make heavy use of template-generated code. Because high bitmap density makes
192*08b48e0bSAndroid Build Coastguard Worker  it harder for the fuzzer to reliably discern new program states, we recommend
193*08b48e0bSAndroid Build Coastguard Worker  recompiling the binary with `AFL_INST_RATIO=10` or so and trying again (see
194*08b48e0bSAndroid Build Coastguard Worker  [env_variables.md](env_variables.md)). The fuzzer will flag high percentages
195*08b48e0bSAndroid Build Coastguard Worker  in red. Chances are, you will never see that unless you're fuzzing extremely
196*08b48e0bSAndroid Build Coastguard Worker  hairy software (say, v8, perl, ffmpeg).
197*08b48e0bSAndroid Build Coastguard Worker
198*08b48e0bSAndroid Build Coastguard WorkerThe other line deals with the variability in tuple hit counts seen in the
199*08b48e0bSAndroid Build Coastguard Workerbinary. In essence, if every taken branch is always taken a fixed number of
200*08b48e0bSAndroid Build Coastguard Workertimes for all the inputs that were tried, this will read `1.00`. As we manage to
201*08b48e0bSAndroid Build Coastguard Workertrigger other hit counts for every branch, the needle will start to move toward
202*08b48e0bSAndroid Build Coastguard Worker`8.00` (every bit in the 8-bit map hit), but will probably never reach that
203*08b48e0bSAndroid Build Coastguard Workerextreme.
204*08b48e0bSAndroid Build Coastguard Worker
205*08b48e0bSAndroid Build Coastguard WorkerTogether, the values can be useful for comparing the coverage of several
206*08b48e0bSAndroid Build Coastguard Workerdifferent fuzzing jobs that rely on the same instrumented binary.
207*08b48e0bSAndroid Build Coastguard Worker
208*08b48e0bSAndroid Build Coastguard Worker### Stage progress
209*08b48e0bSAndroid Build Coastguard Worker
210*08b48e0bSAndroid Build Coastguard Worker```
211*08b48e0bSAndroid Build Coastguard Worker  +-------------------------------------+
212*08b48e0bSAndroid Build Coastguard Worker  |  now trying : interest 32/8         |
213*08b48e0bSAndroid Build Coastguard Worker  | stage execs : 3996/34.4k (11.62%)   |
214*08b48e0bSAndroid Build Coastguard Worker  | total execs : 27.4M                 |
215*08b48e0bSAndroid Build Coastguard Worker  |  exec speed : 891.7/sec             |
216*08b48e0bSAndroid Build Coastguard Worker  +-------------------------------------+
217*08b48e0bSAndroid Build Coastguard Worker```
218*08b48e0bSAndroid Build Coastguard Worker
219*08b48e0bSAndroid Build Coastguard WorkerThis part gives you an in-depth peek at what the fuzzer is actually doing right
220*08b48e0bSAndroid Build Coastguard Workernow. It tells you about the current stage, which can be any of:
221*08b48e0bSAndroid Build Coastguard Worker
222*08b48e0bSAndroid Build Coastguard Worker- calibration - a pre-fuzzing stage where the execution path is examined to
223*08b48e0bSAndroid Build Coastguard Worker  detect anomalies, establish baseline execution speed, and so on. Executed very
224*08b48e0bSAndroid Build Coastguard Worker  briefly whenever a new find is being made.
225*08b48e0bSAndroid Build Coastguard Worker- trim L/S - another pre-fuzzing stage where the test case is trimmed to the
226*08b48e0bSAndroid Build Coastguard Worker  shortest form that still produces the same execution path. The length (L) and
227*08b48e0bSAndroid Build Coastguard Worker  stepover (S) are chosen in general relationship to file size.
228*08b48e0bSAndroid Build Coastguard Worker- bitflip L/S - deterministic bit flips. There are L bits toggled at any given
229*08b48e0bSAndroid Build Coastguard Worker  time, walking the input file with S-bit increments. The current L/S variants
230*08b48e0bSAndroid Build Coastguard Worker  are: `1/1`, `2/1`, `4/1`, `8/8`, `16/8`, `32/8`.
231*08b48e0bSAndroid Build Coastguard Worker- arith L/8 - deterministic arithmetics. The fuzzer tries to subtract or add
232*08b48e0bSAndroid Build Coastguard Worker  small integers to 8-, 16-, and 32-bit values. The stepover is always 8 bits.
233*08b48e0bSAndroid Build Coastguard Worker- interest L/8 - deterministic value overwrite. The fuzzer has a list of known
234*08b48e0bSAndroid Build Coastguard Worker  "interesting" 8-, 16-, and 32-bit values to try. The stepover is 8 bits.
235*08b48e0bSAndroid Build Coastguard Worker- extras - deterministic injection of dictionary terms. This can be shown as
236*08b48e0bSAndroid Build Coastguard Worker  "user" or "auto", depending on whether the fuzzer is using a user-supplied
237*08b48e0bSAndroid Build Coastguard Worker  dictionary (`-x`) or an auto-created one. You will also see "over" or
238*08b48e0bSAndroid Build Coastguard Worker  "insert", depending on whether the dictionary words overwrite existing data or
239*08b48e0bSAndroid Build Coastguard Worker  are inserted by offsetting the remaining data to accommodate their length.
240*08b48e0bSAndroid Build Coastguard Worker- havoc - a sort-of-fixed-length cycle with stacked random tweaks. The
241*08b48e0bSAndroid Build Coastguard Worker  operations attempted during this stage include bit flips, overwrites with
242*08b48e0bSAndroid Build Coastguard Worker  random and "interesting" integers, block deletion, block duplication, plus
243*08b48e0bSAndroid Build Coastguard Worker  assorted dictionary-related operations (if a dictionary is supplied in the
244*08b48e0bSAndroid Build Coastguard Worker  first place).
245*08b48e0bSAndroid Build Coastguard Worker- splice - a last-resort strategy that kicks in after the first full queue cycle
246*08b48e0bSAndroid Build Coastguard Worker  with no new paths. It is equivalent to 'havoc', except that it first splices
247*08b48e0bSAndroid Build Coastguard Worker  together two random inputs from the queue at some arbitrarily selected
248*08b48e0bSAndroid Build Coastguard Worker  midpoint.
249*08b48e0bSAndroid Build Coastguard Worker- sync - a stage used only when `-M` or `-S` is set (see
250*08b48e0bSAndroid Build Coastguard Worker  [fuzzing_in_depth.md:3c) Using multiple cores](fuzzing_in_depth.md#c-using-multiple-cores)).
251*08b48e0bSAndroid Build Coastguard Worker  No real fuzzing is involved, but the tool scans the output from other fuzzers
252*08b48e0bSAndroid Build Coastguard Worker  and imports test cases as necessary. The first time this is done, it may take
253*08b48e0bSAndroid Build Coastguard Worker  several minutes or so.
254*08b48e0bSAndroid Build Coastguard Worker
255*08b48e0bSAndroid Build Coastguard WorkerThe remaining fields should be fairly self-evident: there's the exec count
256*08b48e0bSAndroid Build Coastguard Workerprogress indicator for the current stage, a global exec counter, and a benchmark
257*08b48e0bSAndroid Build Coastguard Workerfor the current program execution speed. This may fluctuate from one test case
258*08b48e0bSAndroid Build Coastguard Workerto another, but the benchmark should be ideally over 500 execs/sec most of the
259*08b48e0bSAndroid Build Coastguard Workertime - and if it stays below 100, the job will probably take very long.
260*08b48e0bSAndroid Build Coastguard Worker
261*08b48e0bSAndroid Build Coastguard WorkerThe fuzzer will explicitly warn you about slow targets, too. If this happens,
262*08b48e0bSAndroid Build Coastguard Workersee the [best_practices.md#improving-speed](best_practices.md#improving-speed)
263*08b48e0bSAndroid Build Coastguard Workerfor ideas on how to speed things up.
264*08b48e0bSAndroid Build Coastguard Worker
265*08b48e0bSAndroid Build Coastguard Worker### Findings in depth
266*08b48e0bSAndroid Build Coastguard Worker
267*08b48e0bSAndroid Build Coastguard Worker```
268*08b48e0bSAndroid Build Coastguard Worker  +--------------------------------------+
269*08b48e0bSAndroid Build Coastguard Worker  | favored paths : 879 (41.96%)         |
270*08b48e0bSAndroid Build Coastguard Worker  |  new edges on : 423 (20.19%)         |
271*08b48e0bSAndroid Build Coastguard Worker  | total crashes : 0 (0 unique)         |
272*08b48e0bSAndroid Build Coastguard Worker  |  total tmouts : 24 (19 unique)       |
273*08b48e0bSAndroid Build Coastguard Worker  +--------------------------------------+
274*08b48e0bSAndroid Build Coastguard Worker```
275*08b48e0bSAndroid Build Coastguard Worker
276*08b48e0bSAndroid Build Coastguard WorkerThis gives you several metrics that are of interest mostly to complete nerds.
277*08b48e0bSAndroid Build Coastguard WorkerThe section includes the number of paths that the fuzzer likes the most based on
278*08b48e0bSAndroid Build Coastguard Workera minimization algorithm baked into the code (these will get considerably more
279*08b48e0bSAndroid Build Coastguard Workerair time), and the number of test cases that actually resulted in better edge
280*08b48e0bSAndroid Build Coastguard Workercoverage (versus just pushing the branch hit counters up). There are also
281*08b48e0bSAndroid Build Coastguard Workeradditional, more detailed counters for crashes and timeouts.
282*08b48e0bSAndroid Build Coastguard Worker
283*08b48e0bSAndroid Build Coastguard WorkerNote that the timeout counter is somewhat different from the hang counter; this
284*08b48e0bSAndroid Build Coastguard Workerone includes all test cases that exceeded the timeout, even if they did not
285*08b48e0bSAndroid Build Coastguard Workerexceed it by a margin sufficient to be classified as hangs.
286*08b48e0bSAndroid Build Coastguard Worker
287*08b48e0bSAndroid Build Coastguard Worker### Fuzzing strategy yields
288*08b48e0bSAndroid Build Coastguard Worker
289*08b48e0bSAndroid Build Coastguard Worker```
290*08b48e0bSAndroid Build Coastguard Worker  +-----------------------------------------------------+
291*08b48e0bSAndroid Build Coastguard Worker  |   bit flips : 57/289k, 18/289k, 18/288k             |
292*08b48e0bSAndroid Build Coastguard Worker  |  byte flips : 0/36.2k, 4/35.7k, 7/34.6k             |
293*08b48e0bSAndroid Build Coastguard Worker  | arithmetics : 53/2.54M, 0/537k, 0/55.2k             |
294*08b48e0bSAndroid Build Coastguard Worker  |  known ints : 8/322k, 12/1.32M, 10/1.70M            |
295*08b48e0bSAndroid Build Coastguard Worker  |  dictionary : 9/52k, 1/53k, 1/24k                   |
296*08b48e0bSAndroid Build Coastguard Worker  |havoc/splice : 1903/20.0M, 0/0                       |
297*08b48e0bSAndroid Build Coastguard Worker  |py/custom/rq : unused, 53/2.54M, unused              |
298*08b48e0bSAndroid Build Coastguard Worker  |    trim/eff : 20.31%/9201, 17.05%                   |
299*08b48e0bSAndroid Build Coastguard Worker  +-----------------------------------------------------+
300*08b48e0bSAndroid Build Coastguard Worker```
301*08b48e0bSAndroid Build Coastguard Worker
302*08b48e0bSAndroid Build Coastguard WorkerThis is just another nerd-targeted section keeping track of how many paths were
303*08b48e0bSAndroid Build Coastguard Workernetted, in proportion to the number of execs attempted, for each of the fuzzing
304*08b48e0bSAndroid Build Coastguard Workerstrategies discussed earlier on. This serves to convincingly validate
305*08b48e0bSAndroid Build Coastguard Workerassumptions about the usefulness of the various approaches taken by afl-fuzz.
306*08b48e0bSAndroid Build Coastguard Worker
307*08b48e0bSAndroid Build Coastguard WorkerThe trim strategy stats in this section are a bit different than the rest. The
308*08b48e0bSAndroid Build Coastguard Workerfirst number in this line shows the ratio of bytes removed from the input files;
309*08b48e0bSAndroid Build Coastguard Workerthe second one corresponds to the number of execs needed to achieve this goal.
310*08b48e0bSAndroid Build Coastguard WorkerFinally, the third number shows the proportion of bytes that, although not
311*08b48e0bSAndroid Build Coastguard Workerpossible to remove, were deemed to have no effect and were excluded from some of
312*08b48e0bSAndroid Build Coastguard Workerthe more expensive deterministic fuzzing steps.
313*08b48e0bSAndroid Build Coastguard Worker
314*08b48e0bSAndroid Build Coastguard WorkerNote that when deterministic mutation mode is off (which is the default because
315*08b48e0bSAndroid Build Coastguard Workerit is not very efficient) the first five lines display "disabled (default,
316*08b48e0bSAndroid Build Coastguard Workerenable with -D)".
317*08b48e0bSAndroid Build Coastguard Worker
318*08b48e0bSAndroid Build Coastguard WorkerOnly what is activated will have counter shown.
319*08b48e0bSAndroid Build Coastguard Worker
320*08b48e0bSAndroid Build Coastguard Worker### Path geometry
321*08b48e0bSAndroid Build Coastguard Worker
322*08b48e0bSAndroid Build Coastguard Worker```
323*08b48e0bSAndroid Build Coastguard Worker  +---------------------+
324*08b48e0bSAndroid Build Coastguard Worker  |    levels : 5       |
325*08b48e0bSAndroid Build Coastguard Worker  |   pending : 1570    |
326*08b48e0bSAndroid Build Coastguard Worker  |  pend fav : 583     |
327*08b48e0bSAndroid Build Coastguard Worker  | own finds : 0       |
328*08b48e0bSAndroid Build Coastguard Worker  |  imported : 0       |
329*08b48e0bSAndroid Build Coastguard Worker  | stability : 100.00% |
330*08b48e0bSAndroid Build Coastguard Worker  +---------------------+
331*08b48e0bSAndroid Build Coastguard Worker```
332*08b48e0bSAndroid Build Coastguard Worker
333*08b48e0bSAndroid Build Coastguard WorkerThe first field in this section tracks the path depth reached through the guided
334*08b48e0bSAndroid Build Coastguard Workerfuzzing process. In essence: the initial test cases supplied by the user are
335*08b48e0bSAndroid Build Coastguard Workerconsidered "level 1". The test cases that can be derived from that through
336*08b48e0bSAndroid Build Coastguard Workertraditional fuzzing are considered "level 2"; the ones derived by using these as
337*08b48e0bSAndroid Build Coastguard Workerinputs to subsequent fuzzing rounds are "level 3"; and so forth. The maximum
338*08b48e0bSAndroid Build Coastguard Workerdepth is therefore a rough proxy for how much value you're getting out of the
339*08b48e0bSAndroid Build Coastguard Workerinstrumentation-guided approach taken by afl-fuzz.
340*08b48e0bSAndroid Build Coastguard Worker
341*08b48e0bSAndroid Build Coastguard WorkerThe next field shows you the number of inputs that have not gone through any
342*08b48e0bSAndroid Build Coastguard Workerfuzzing yet. The same stat is also given for "favored" entries that the fuzzer
343*08b48e0bSAndroid Build Coastguard Workerreally wants to get to in this queue cycle (the non-favored entries may have to
344*08b48e0bSAndroid Build Coastguard Workerwait a couple of cycles to get their chance).
345*08b48e0bSAndroid Build Coastguard Worker
346*08b48e0bSAndroid Build Coastguard WorkerNext is the number of new paths found during this fuzzing section and imported
347*08b48e0bSAndroid Build Coastguard Workerfrom other fuzzer instances when doing parallelized fuzzing; and the extent to
348*08b48e0bSAndroid Build Coastguard Workerwhich identical inputs appear to sometimes produce variable behavior in the
349*08b48e0bSAndroid Build Coastguard Workertested binary.
350*08b48e0bSAndroid Build Coastguard Worker
351*08b48e0bSAndroid Build Coastguard WorkerThat last bit is actually fairly interesting: it measures the consistency of
352*08b48e0bSAndroid Build Coastguard Workerobserved traces. If a program always behaves the same for the same input data,
353*08b48e0bSAndroid Build Coastguard Workerit will earn a score of 100%. When the value is lower but still shown in purple,
354*08b48e0bSAndroid Build Coastguard Workerthe fuzzing process is unlikely to be negatively affected. If it goes into red,
355*08b48e0bSAndroid Build Coastguard Workeryou may be in trouble, since AFL++ will have difficulty discerning between
356*08b48e0bSAndroid Build Coastguard Workermeaningful and "phantom" effects of tweaking the input file.
357*08b48e0bSAndroid Build Coastguard Worker
358*08b48e0bSAndroid Build Coastguard WorkerNow, most targets will just get a 100% score, but when you see lower figures,
359*08b48e0bSAndroid Build Coastguard Workerthere are several things to look at:
360*08b48e0bSAndroid Build Coastguard Worker
361*08b48e0bSAndroid Build Coastguard Worker- The use of uninitialized memory in conjunction with some intrinsic sources of
362*08b48e0bSAndroid Build Coastguard Worker  entropy in the tested binary. Harmless to AFL, but could be indicative of a
363*08b48e0bSAndroid Build Coastguard Worker  security bug.
364*08b48e0bSAndroid Build Coastguard Worker- Attempts to manipulate persistent resources, such as left over temporary files
365*08b48e0bSAndroid Build Coastguard Worker  or shared memory objects. This is usually harmless, but you may want to
366*08b48e0bSAndroid Build Coastguard Worker  double-check to make sure the program isn't bailing out prematurely. Running
367*08b48e0bSAndroid Build Coastguard Worker  out of disk space, SHM handles, or other global resources can trigger this,
368*08b48e0bSAndroid Build Coastguard Worker  too.
369*08b48e0bSAndroid Build Coastguard Worker- Hitting some functionality that is actually designed to behave randomly.
370*08b48e0bSAndroid Build Coastguard Worker  Generally harmless. For example, when fuzzing sqlite, an input like `select
371*08b48e0bSAndroid Build Coastguard Worker  random();` will trigger a variable execution path.
372*08b48e0bSAndroid Build Coastguard Worker- Multiple threads executing at once in semi-random order. This is harmless when
373*08b48e0bSAndroid Build Coastguard Worker  the 'stability' metric stays over 90% or so, but can become an issue if not.
374*08b48e0bSAndroid Build Coastguard Worker  Here's what to try:
375*08b48e0bSAndroid Build Coastguard Worker  * Use afl-clang-fast from [instrumentation](../instrumentation/) - it uses a
376*08b48e0bSAndroid Build Coastguard Worker    thread-local tracking model that is less prone to concurrency issues,
377*08b48e0bSAndroid Build Coastguard Worker  * See if the target can be compiled or run without threads. Common
378*08b48e0bSAndroid Build Coastguard Worker    `./configure` options include `--without-threads`, `--disable-pthreads`, or
379*08b48e0bSAndroid Build Coastguard Worker    `--disable-openmp`.
380*08b48e0bSAndroid Build Coastguard Worker  * Replace pthreads with GNU Pth (https://www.gnu.org/software/pth/), which
381*08b48e0bSAndroid Build Coastguard Worker    allows you to use a deterministic scheduler.
382*08b48e0bSAndroid Build Coastguard Worker- In persistent mode, minor drops in the "stability" metric can be normal,
383*08b48e0bSAndroid Build Coastguard Worker  because not all the code behaves identically when re-entered; but major dips
384*08b48e0bSAndroid Build Coastguard Worker  may signify that the code within `__AFL_LOOP()` is not behaving correctly on
385*08b48e0bSAndroid Build Coastguard Worker  subsequent iterations (e.g., due to incomplete clean-up or reinitialization of
386*08b48e0bSAndroid Build Coastguard Worker  the state) and that most of the fuzzing effort goes to waste.
387*08b48e0bSAndroid Build Coastguard Worker
388*08b48e0bSAndroid Build Coastguard WorkerThe paths where variable behavior is detected are marked with a matching entry
389*08b48e0bSAndroid Build Coastguard Workerin the `<out_dir>/queue/.state/variable_behavior/` directory, so you can look
390*08b48e0bSAndroid Build Coastguard Workerthem up easily.
391*08b48e0bSAndroid Build Coastguard Worker
392*08b48e0bSAndroid Build Coastguard Worker### CPU load
393*08b48e0bSAndroid Build Coastguard Worker
394*08b48e0bSAndroid Build Coastguard Worker```
395*08b48e0bSAndroid Build Coastguard Worker  [cpu: 25%]
396*08b48e0bSAndroid Build Coastguard Worker```
397*08b48e0bSAndroid Build Coastguard Worker
398*08b48e0bSAndroid Build Coastguard WorkerThis tiny widget shows the apparent CPU utilization on the local system. It is
399*08b48e0bSAndroid Build Coastguard Workercalculated by taking the number of processes in the "runnable" state, and then
400*08b48e0bSAndroid Build Coastguard Workercomparing it to the number of logical cores on the system.
401*08b48e0bSAndroid Build Coastguard Worker
402*08b48e0bSAndroid Build Coastguard WorkerIf the value is shown in green, you are using fewer CPU cores than available on
403*08b48e0bSAndroid Build Coastguard Workeryour system and can probably parallelize to improve performance; for tips on how
404*08b48e0bSAndroid Build Coastguard Workerto do that, see
405*08b48e0bSAndroid Build Coastguard Worker[fuzzing_in_depth.md:3c) Using multiple cores](fuzzing_in_depth.md#c-using-multiple-cores).
406*08b48e0bSAndroid Build Coastguard Worker
407*08b48e0bSAndroid Build Coastguard WorkerIf the value is shown in red, your CPU is *possibly* oversubscribed, and running
408*08b48e0bSAndroid Build Coastguard Workeradditional fuzzers may not give you any benefits.
409*08b48e0bSAndroid Build Coastguard Worker
410*08b48e0bSAndroid Build Coastguard WorkerOf course, this benchmark is very simplistic; it tells you how many processes
411*08b48e0bSAndroid Build Coastguard Workerare ready to run, but not how resource-hungry they may be. It also doesn't
412*08b48e0bSAndroid Build Coastguard Workerdistinguish between physical cores, logical cores, and virtualized CPUs; the
413*08b48e0bSAndroid Build Coastguard Workerperformance characteristics of each of these will differ quite a bit.
414*08b48e0bSAndroid Build Coastguard Worker
415*08b48e0bSAndroid Build Coastguard WorkerIf you want a more accurate measurement, you can run the `afl-gotcpu` utility
416*08b48e0bSAndroid Build Coastguard Workerfrom the command line.
417*08b48e0bSAndroid Build Coastguard Worker
418*08b48e0bSAndroid Build Coastguard Worker## Interpreting output
419*08b48e0bSAndroid Build Coastguard Worker
420*08b48e0bSAndroid Build Coastguard WorkerSee [#understanding-the-status-screen](#understanding-the-status-screen) for
421*08b48e0bSAndroid Build Coastguard Workerinformation on how to interpret the displayed stats and monitor the health of
422*08b48e0bSAndroid Build Coastguard Workerthe process. Be sure to consult this file especially if any UI elements are
423*08b48e0bSAndroid Build Coastguard Workerhighlighted in red.
424*08b48e0bSAndroid Build Coastguard Worker
425*08b48e0bSAndroid Build Coastguard WorkerThe fuzzing process will continue until you press Ctrl-C. At a minimum, you want
426*08b48e0bSAndroid Build Coastguard Workerto allow the fuzzer to at least one queue cycle without any new finds, which may
427*08b48e0bSAndroid Build Coastguard Workertake anywhere from a couple of hours to a week or so.
428*08b48e0bSAndroid Build Coastguard Worker
429*08b48e0bSAndroid Build Coastguard WorkerThere are three subdirectories created within the output directory and updated
430*08b48e0bSAndroid Build Coastguard Workerin real-time:
431*08b48e0bSAndroid Build Coastguard Worker
432*08b48e0bSAndroid Build Coastguard Worker- queue/   - test cases for every distinctive execution path, plus all the
433*08b48e0bSAndroid Build Coastguard Worker             starting files given by the user. This is the synthesized corpus.
434*08b48e0bSAndroid Build Coastguard Worker
435*08b48e0bSAndroid Build Coastguard Worker             Before using this corpus for any other purposes, you can shrink
436*08b48e0bSAndroid Build Coastguard Worker             it to a smaller size using the afl-cmin tool. The tool will find
437*08b48e0bSAndroid Build Coastguard Worker             a smaller subset of files offering equivalent edge coverage.
438*08b48e0bSAndroid Build Coastguard Worker
439*08b48e0bSAndroid Build Coastguard Worker- crashes/ - unique test cases that cause the tested program to receive a fatal
440*08b48e0bSAndroid Build Coastguard Worker             signal (e.g., SIGSEGV, SIGILL, SIGABRT). The entries are grouped by
441*08b48e0bSAndroid Build Coastguard Worker             the received signal.
442*08b48e0bSAndroid Build Coastguard Worker
443*08b48e0bSAndroid Build Coastguard Worker- hangs/   - unique test cases that cause the tested program to time out. The
444*08b48e0bSAndroid Build Coastguard Worker             default time limit before something is classified as a hang is the
445*08b48e0bSAndroid Build Coastguard Worker             larger of 1 second and the value of the -t parameter. The value can
446*08b48e0bSAndroid Build Coastguard Worker             be fine-tuned by setting AFL_HANG_TMOUT, but this is rarely
447*08b48e0bSAndroid Build Coastguard Worker             necessary.
448*08b48e0bSAndroid Build Coastguard Worker
449*08b48e0bSAndroid Build Coastguard WorkerCrashes and hangs are considered "unique" if the associated execution paths
450*08b48e0bSAndroid Build Coastguard Workerinvolve any state transitions not seen in previously-recorded faults. If a
451*08b48e0bSAndroid Build Coastguard Workersingle bug can be reached in multiple ways, there will be some count inflation
452*08b48e0bSAndroid Build Coastguard Workerearly in the process, but this should quickly taper off.
453*08b48e0bSAndroid Build Coastguard Worker
454*08b48e0bSAndroid Build Coastguard WorkerThe file names for crashes and hangs are correlated with the parent,
455*08b48e0bSAndroid Build Coastguard Workernon-faulting queue entries. This should help with debugging.
456*08b48e0bSAndroid Build Coastguard Worker
457*08b48e0bSAndroid Build Coastguard Worker## Visualizing
458*08b48e0bSAndroid Build Coastguard Worker
459*08b48e0bSAndroid Build Coastguard WorkerIf you have gnuplot installed, you can also generate some pretty graphs for any
460*08b48e0bSAndroid Build Coastguard Workeractive fuzzing task using afl-plot. For an example of how this looks like, see
461*08b48e0bSAndroid Build Coastguard Worker[https://lcamtuf.coredump.cx/afl/plot/](https://lcamtuf.coredump.cx/afl/plot/).
462*08b48e0bSAndroid Build Coastguard Worker
463*08b48e0bSAndroid Build Coastguard WorkerYou can also manually build and install afl-plot-ui, which is a helper utility
464*08b48e0bSAndroid Build Coastguard Workerfor showing the graphs generated by afl-plot in a graphical window using GTK.
465*08b48e0bSAndroid Build Coastguard WorkerYou can build and install it as follows:
466*08b48e0bSAndroid Build Coastguard Worker
467*08b48e0bSAndroid Build Coastguard Worker```shell
468*08b48e0bSAndroid Build Coastguard Workersudo apt install libgtk-3-0 libgtk-3-dev pkg-config
469*08b48e0bSAndroid Build Coastguard Workercd utils/plot_ui
470*08b48e0bSAndroid Build Coastguard Workermake
471*08b48e0bSAndroid Build Coastguard Workercd ../../
472*08b48e0bSAndroid Build Coastguard Workersudo make install
473*08b48e0bSAndroid Build Coastguard Worker```
474*08b48e0bSAndroid Build Coastguard Worker
475*08b48e0bSAndroid Build Coastguard WorkerTo learn more about remote monitoring and metrics visualization with StatsD, see
476*08b48e0bSAndroid Build Coastguard Worker[rpc_statsd.md](rpc_statsd.md).
477*08b48e0bSAndroid Build Coastguard Worker
478*08b48e0bSAndroid Build Coastguard Worker### Addendum: status and plot files
479*08b48e0bSAndroid Build Coastguard Worker
480*08b48e0bSAndroid Build Coastguard WorkerFor unattended operation, some of the key status screen information can be also
481*08b48e0bSAndroid Build Coastguard Workerfound in a machine-readable format in the fuzzer_stats file in the output
482*08b48e0bSAndroid Build Coastguard Workerdirectory. This includes:
483*08b48e0bSAndroid Build Coastguard Worker
484*08b48e0bSAndroid Build Coastguard Worker- `start_time`        - unix time indicating the start time of afl-fuzz
485*08b48e0bSAndroid Build Coastguard Worker- `last_update`       - unix time corresponding to the last update of this file
486*08b48e0bSAndroid Build Coastguard Worker- `run_time`          - run time in seconds to the last update of this file
487*08b48e0bSAndroid Build Coastguard Worker- `fuzzer_pid`        - PID of the fuzzer process
488*08b48e0bSAndroid Build Coastguard Worker- `cycles_done`       - queue cycles completed so far
489*08b48e0bSAndroid Build Coastguard Worker- `cycles_wo_finds`   - number of cycles without any new paths found
490*08b48e0bSAndroid Build Coastguard Worker- `time_wo_finds`     - longest time in seconds no new path was found
491*08b48e0bSAndroid Build Coastguard Worker- `execs_done`        - number of execve() calls attempted
492*08b48e0bSAndroid Build Coastguard Worker- `execs_per_sec`     - overall number of execs per second
493*08b48e0bSAndroid Build Coastguard Worker- `corpus_count`      - total number of entries in the queue
494*08b48e0bSAndroid Build Coastguard Worker- `corpus_favored`    - number of queue entries that are favored
495*08b48e0bSAndroid Build Coastguard Worker- `corpus_found`      - number of entries discovered through local fuzzing
496*08b48e0bSAndroid Build Coastguard Worker- `corpus_imported`   - number of entries imported from other instances
497*08b48e0bSAndroid Build Coastguard Worker- `max_depth`         - number of levels in the generated data set
498*08b48e0bSAndroid Build Coastguard Worker- `cur_item`          - currently processed entry number
499*08b48e0bSAndroid Build Coastguard Worker- `pending_favs`      - number of favored entries still waiting to be fuzzed
500*08b48e0bSAndroid Build Coastguard Worker- `pending_total`     - number of all entries waiting to be fuzzed
501*08b48e0bSAndroid Build Coastguard Worker- `corpus_variable`   - number of test cases showing variable behavior
502*08b48e0bSAndroid Build Coastguard Worker- `stability`         - percentage of bitmap bytes that behave consistently
503*08b48e0bSAndroid Build Coastguard Worker- `bitmap_cvg`        - percentage of edge coverage found in the map so far
504*08b48e0bSAndroid Build Coastguard Worker- `saved_crashes`     - number of unique crashes recorded
505*08b48e0bSAndroid Build Coastguard Worker- `saved_hangs`       - number of unique hangs encountered
506*08b48e0bSAndroid Build Coastguard Worker- `last_find`         - seconds since the last find was found
507*08b48e0bSAndroid Build Coastguard Worker- `last_crash`        - seconds since the last crash was found
508*08b48e0bSAndroid Build Coastguard Worker- `last_hang`         - seconds since the last hang was found
509*08b48e0bSAndroid Build Coastguard Worker- `execs_since_crash` - execs since the last crash was found
510*08b48e0bSAndroid Build Coastguard Worker- `exec_timeout`      - the -t command line value
511*08b48e0bSAndroid Build Coastguard Worker- `slowest_exec_ms`   - real time of the slowest execution in ms
512*08b48e0bSAndroid Build Coastguard Worker- `peak_rss_mb`       - max rss usage reached during fuzzing in MB
513*08b48e0bSAndroid Build Coastguard Worker- `edges_found`       - how many edges have been found
514*08b48e0bSAndroid Build Coastguard Worker- `var_byte_count`    - how many edges are non-deterministic
515*08b48e0bSAndroid Build Coastguard Worker- `afl_banner`        - banner text (e.g., the target name)
516*08b48e0bSAndroid Build Coastguard Worker- `afl_version`       - the version of AFL++ used
517*08b48e0bSAndroid Build Coastguard Worker- `target_mode`       - default, persistent, qemu, unicorn, non-instrumented
518*08b48e0bSAndroid Build Coastguard Worker- `command_line`      - full command line used for the fuzzing session
519*08b48e0bSAndroid Build Coastguard Worker
520*08b48e0bSAndroid Build Coastguard WorkerMost of these map directly to the UI elements discussed earlier on.
521*08b48e0bSAndroid Build Coastguard Worker
522*08b48e0bSAndroid Build Coastguard WorkerOn top of that, you can also find an entry called `plot_data`, containing a
523*08b48e0bSAndroid Build Coastguard Workerplottable history for most of these fields. If you have gnuplot installed, you
524*08b48e0bSAndroid Build Coastguard Workercan turn this into a nice progress report with the included `afl-plot` tool.
525*08b48e0bSAndroid Build Coastguard Worker
526*08b48e0bSAndroid Build Coastguard Worker### Addendum: automatically sending metrics with StatsD
527*08b48e0bSAndroid Build Coastguard Worker
528*08b48e0bSAndroid Build Coastguard WorkerIn a CI environment or when running multiple fuzzers, it can be tedious to log
529*08b48e0bSAndroid Build Coastguard Workerinto each of them or deploy scripts to read the fuzzer statistics. Using
530*08b48e0bSAndroid Build Coastguard Worker`AFL_STATSD` (and the other related environment variables `AFL_STATSD_HOST`,
531*08b48e0bSAndroid Build Coastguard Worker`AFL_STATSD_PORT`, `AFL_STATSD_TAGS_FLAVOR`) you can automatically send metrics
532*08b48e0bSAndroid Build Coastguard Workerto your favorite StatsD server. Depending on your StatsD server, you will be
533*08b48e0bSAndroid Build Coastguard Workerable to monitor, trigger alerts, or perform actions based on these metrics
534*08b48e0bSAndroid Build Coastguard Worker(e.g.: alert on slow exec/s for a new build, threshold of crashes, time since
535*08b48e0bSAndroid Build Coastguard Workerlast crash > X, etc.).
536*08b48e0bSAndroid Build Coastguard Worker
537*08b48e0bSAndroid Build Coastguard WorkerThe selected metrics are a subset of all the metrics found in the status and in
538*08b48e0bSAndroid Build Coastguard Workerthe plot file. The list is the following: `cycle_done`, `cycles_wo_finds`,
539*08b48e0bSAndroid Build Coastguard Worker`execs_done`,`execs_per_sec`, `corpus_count`, `corpus_favored`, `corpus_found`,
540*08b48e0bSAndroid Build Coastguard Worker`corpus_imported`, `max_depth`, `cur_item`, `pending_favs`, `pending_total`,
541*08b48e0bSAndroid Build Coastguard Worker`corpus_variable`, `saved_crashes`, `saved_hangs`, `total_crashes`,
542*08b48e0bSAndroid Build Coastguard Worker`slowest_exec_ms`, `edges_found`, `var_byte_count`, `havoc_expansion`. Their
543*08b48e0bSAndroid Build Coastguard Workerdefinitions can be found in the addendum above.
544*08b48e0bSAndroid Build Coastguard Worker
545*08b48e0bSAndroid Build Coastguard WorkerWhen using multiple fuzzer instances with StatsD, it is *strongly* recommended
546*08b48e0bSAndroid Build Coastguard Workerto setup the flavor (`AFL_STATSD_TAGS_FLAVOR`) to match your StatsD server. This
547*08b48e0bSAndroid Build Coastguard Workerwill allow you to see individual fuzzer performance, detect bad ones, see the
548*08b48e0bSAndroid Build Coastguard Workerprogress of each strategy...