App to create broken files, can be used as fuzzer for some apps.
https://github.com/qarmin/create_broken_files.git
unwrap# Create Broken Files This app is generates broken files from valid ones.
It is useful in fuzzing parsers/apps like image-rs(loading images), ruff(parsing and linting python files) or godot(loading models/images).
Typical fuzzer workflow:
Create Broken Files workflow:
ruff with cargo-fuzz(typical fuzzer build at the top
libFuzzer) after 2 hours of checking(mostly / characters + some random bytes) I found 1 crash and 1 error that not
crashed fuzzer(I found it in logs).
This app + script to find exact file that causes problems found in 30 minutes almost 60 errors and crashes(script doesn't distinguish them) - some are probably duplicated, not reported them yet.
I have noticed that in the case of normal fuzzers the code coverage from a single run is very small and it is almost never possible to test a significant portion of the code in a reasonable time.
Correct files, however, pass through most of the code without much trouble. Therefore, when parsing a file that is slightly corrupted, its small corruption may allow you to pass through a significant portion of the code and only then test the error handling nested deep in the code, which an ordinary fuzzer could reach after hundreds of thousands of years.
App contains 2 modes - binary/utf-8
In binary mode app is allowed to:
ruff which tests Python IIf input file contained at start only utf-8 characters, then in this mode also should contain only them in output file.
At start just install it with
cargo install create_broken_files
Usage:
create_broken_files --input-path <INPUT> --output-path <OUTPUT> --number-of-broken-files <NUMBER> [--character-mode <IS_CHARACTER_MODE>] [--special-words <WORDS>]
input-path - input path of folder or file to use(folders are only checked with depth 1)output-path - path where generated files will be placednumber-of-broken-files - number of files that will be generated from one input file(real number may be a littlecharacter-mode - c - [OPTIONAL, default_value=false] if true change mode to utf-8(described above)special-words - s - [OPTIONAL, default_value=[]], works only when character-mode is true, adds random words fromconnect_multiple_files - m - [OPTIONAL, default_value=false], if true then some files will be added at the endExample(short version of long names are available):
create_broken_files -i /home/rafal/inputs -o /home/pli -n 1000
create_broken_files -i /home/rafal/Desktop/22.txt -o /home/rafal/Desktop/33 -n 10 -c -m -s "False" "await" "else"