Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b250190
add AFL++ IJON functionality
vanhauser-thc Sep 24, 2025
d2ab3bd
example
vanhauser-thc Sep 24, 2025
94ab7cb
fix ijon macros
vanhauser-thc Sep 25, 2025
2ea0d2d
add ijon pass
vanhauser-thc Sep 25, 2025
021ed32
add test
vanhauser-thc Sep 25, 2025
729399d
Verify that plugins are available in `integration_maze` test
smoelius Sep 29, 2025
7e60ee1
znostart-stop-gc
vanhauser-thc Sep 29, 2025
d1f00bb
update afl++
vanhauser-thc Sep 29, 2025
bc683c6
clippy
vanhauser-thc Sep 29, 2025
86d8d2a
fmt
vanhauser-thc Sep 29, 2025
6e50d3a
clippy, cfg fuzzing, docs
vanhauser-thc Sep 30, 2025
fb9386d
clippy
vanhauser-thc Sep 30, 2025
c1da0bb
Update README.md
vanhauser-thc Oct 8, 2025
b55aa77
Update README.md
vanhauser-thc Oct 8, 2025
90ebb05
Update README.md
vanhauser-thc Oct 8, 2025
887cd59
Update README.md
vanhauser-thc Oct 8, 2025
08ce698
Update afl/examples/maze.rs
vanhauser-thc Oct 8, 2025
bd0db01
Update afl/examples/maze.rs
vanhauser-thc Oct 8, 2025
0e10bf6
Update afl/examples/maze.rs
vanhauser-thc Oct 8, 2025
c83393d
Update afl/examples/maze.rs
vanhauser-thc Oct 8, 2025
ad9e947
Update afl/src/lib.rs
vanhauser-thc Oct 8, 2025
6c7de49
Update afl/src/lib.rs
vanhauser-thc Oct 8, 2025
8777f4e
Update cargo-afl/tests/integration.rs
vanhauser-thc Oct 8, 2025
a770ae6
Update README.md
vanhauser-thc Oct 8, 2025
a214ea6
nits
vanhauser-thc Oct 8, 2025
0950ec9
nits
vanhauser-thc Oct 8, 2025
65db9f2
clippy
vanhauser-thc Oct 8, 2025
5587586
fix
vanhauser-thc Oct 8, 2025
23ab3dd
fix
vanhauser-thc Oct 8, 2025
64b7a8e
use afl::
vanhauser-thc Oct 8, 2025
6ef12b5
try maze 3 times for integration
vanhauser-thc Oct 9, 2025
ccb9745
clippy
vanhauser-thc Oct 9, 2025
ccc4b5c
clippy
vanhauser-thc Oct 9, 2025
4b29e67
Update cargo-afl/tests/integration.rs
vanhauser-thc Oct 9, 2025
ad1842c
indent
vanhauser-thc Oct 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,22 @@ environment variable `AFL_NO_CFG_FUZZING` to `1` when building.
[american-fuzzy-lop]: http://lcamtuf.coredump.cx/afl/
[AFLplusplus]: https://aflplus.plus/
[rust]: https://www.rust-lang.org

## IJON

If you want to use IJON - helping fuzzer coverage through code annotation - then
have a look at the [maze example](afl/examples/maze.rs) how to use it.

You can find the AFL++ IJON documentation at [https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/IJON.md](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/IJON.md)

Note that the IJON macros have been rustyfied to lowercase - hence `IJON_MAX(x)` is `ijon_max(x)` in Rust.

You will need to the following parts of cargo AFL:

```
use afl::ijon_hashint;
use afl::ijon_hashstr;
use std::ffi::CString;
```

plus any macros that you use, e.g. `afl::ijon_max`.
208 changes: 208 additions & 0 deletions afl/examples/maze.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/*
The maze:
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1],
[1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1],
[1,0,1,0,1,1,1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,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1],
[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1],
[1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1],
[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
*/

/* Solution:
cddbddcccacaaaccaaaaaabbbbbbbbbbaaccccccccccccaaccaabbbbbbbbbbbbbbbbbbbbbbbbbaacccccccccccccccccccccccccccccdddddddddddddddddddddddddddddbbbbbbbbbbbbbbbd
*/

#![allow(
clippy::too_many_lines,
clippy::manual_assert,
clippy::cast_possible_truncation
)]

#[cfg(fuzzing)]
use afl::ijon_hashint;
#[cfg(fuzzing)]
use afl::ijon_hashstr;
#[cfg(fuzzing)]
use afl::ijon_set;
#[cfg(fuzzing)]
use std::ffi::CString;

fn main() {
afl::fuzz!(|data: &[u8]| {
// 31x31 maze, 0 = open, 1 = wall, 2 = start, 3 = ex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_sub(1), pos.1), // up
1 => (pos.0 + 1, pos.1), // down
2 => (pos.0, pos.1.wrapping_sub(1)), // left
_ => (pos.0, pos.1 + 1), // right
};

if next.0 < 31 && next.1 < 31 && maze[next.0][next.1] != 1 {
pos = next;
}

if maze[pos.0][pos.1] == 3 {
panic!("Exited the maze!");
}

#[cfg(fuzzing)]
ijon_set!(ijon_hashint(pos.0 as u32, pos.1 as u32));
}
});
}
Loading
Loading