39 | | == Altering the fuzzing ratio == |
| 45 | == Invoking different programs == |
| 46 | |
| 47 | Let’s fuzz the `cat` utility instead of `hd`, but read the final output with `hd` nonetheless: |
| 48 | |
| 49 | {{{ |
| 50 | % zzuf cat /dev/zero | hd -vn 32 |
| 51 | 00000000 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 52 | 00000010 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 |................| |
| 53 | 00000020 |
| 54 | % |
| 55 | }}} |
| 56 | |
| 57 | Now instead of calling `hd`, let’s try `od`, the octal dumper: |
| 58 | {{{ |
| 59 | % zzuf od -vN 32 /dev/zero |
| 60 | 0000000 000000 000002 000000 000000 000000 000000 000000 000000 |
| 61 | 0000020 000000 000000 001000 000000 000000 000000 000000 000000 |
| 62 | 0000040 |
| 63 | % |
| 64 | }}} |
| 65 | |
| 66 | If you understand octal dumps as fluently as hexadecimal dumps, you noticed that the data has been fuzzed exactly like with `hd`. |
| 67 | |
| 68 | This is another very important property of `zzuf`: '''data is fuzzed the same way regardless of the fuzzed application'''. |
| 69 | |
| 70 | == The fuzzing ratio == |
| 107 | |
| 108 | == The random seed == |
| 109 | |
| 110 | `zzuf`’s behaviour is reproducible, but we might not be satisfied with the output. Or we may simply want to fuzz in several different ways, but still using the same fuzzing ratio. This is done by changing the '''random seed''' with the '''`-s` flag'''. The random seed is the initial value of `zzuf`’s random number generator. The default seed is 0, so let’s try with other values: |
| 111 | |
| 112 | {{{ |
| 113 | % zzuf -s 2 hd -vn 32 /dev/zero |
| 114 | 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 115 | 00000010 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 116 | 00000020 |
| 117 | % zzuf -s 79432 hd -vn 32 /dev/zero |
| 118 | 00000000 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 |....... ........| |
| 119 | 00000010 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 |................| |
| 120 | 00000020 |
| 121 | % |
| 122 | }}} |
| 123 | |
| 124 | As can be seen, each seed value initiates a different behaviour of the random number generator. |
| 125 | |
| 126 | == Creating fuzzed files == |
| 127 | |
| 128 | It is possible to fuzz files directly, without calling applications at all. |
| 129 | |
| 130 | To do so, simply call `zzuf` with no application argument. It will fuzz its standard input by default: |
| 131 | |
| 132 | {{{ |
| 133 | % cat /dev/zero | zzuf | hd -vn32 |
| 134 | 00000000 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 135 | 00000010 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 |................| |
| 136 | 00000020 |
| 137 | % |
| 138 | }}} |
| 139 | |
| 140 | `zzuf` can be used to create files: |
| 141 | |
| 142 | {{{ |
| 143 | % dd if=/dev/zero bs=1 count=32 | zzuf > output.file |
| 144 | 32+0 records in |
| 145 | 32+0 records out |
| 146 | 32 bytes (32 B) copied, 9.1129e-05 s, 351 kB/s |
| 147 | % hd -v output.file |
| 148 | 00000000 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 149 | 00000010 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 |................| |
| 150 | 00000020 |
| 151 | % |
| 152 | }}} |
| 153 | |
| 154 | This may be useful if a given application is not supported by `zzuf`, but it is especially useful to generate files that reproduce `zzuf`’s behaviour without requiring `zzuf`. |
| 155 | |