Compare commits

...

1958 Commits

Author SHA1 Message Date
49de014a31 avoid copy of function names 2025-07-30 12:14:22 +00:00
9bbc5e7c78 Merge branch 'fret_141' into fret_153 2025-07-28 12:03:09 +00:00
aac9cff7bf remove states from nodes 2025-07-23 06:38:16 +00:00
f262c32f47 update bounds 2025-07-22 12:58:27 +00:00
2dfb5f853d reduce state space by ignoring lower priorities 2025-07-04 07:37:15 +00:00
fabf746c4c update scripts 2025-05-28 11:48:39 +00:00
27811aaaca minor refactoring 2025-05-28 11:46:22 +00:00
lazymio
918e8a6527
use libafl_wide (#3274)
* use libafl_wide

* fix
2025-05-26 18:38:34 +08:00
Dominik Maier
d5ecf7304d
NoStd Bolts (#3272) 2025-05-25 22:16:07 +02:00
Dongjia "toka" Zhang
c12750f7b8
No more no_std clippy (#3271) 2025-05-24 19:43:48 +02:00
Ch4r1l3
9a202acfed
fix fuzzbench cmplog ForkServer builder and rtn_extend_encoding buffer copy overflow (#3270) 2025-05-24 18:02:43 +02:00
Andrea Fioraldi
ce63b76558
Update to v0.15.3 (#3259)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-23 22:50:23 +02:00
Dominik Maier
b22c2ca99c
Replace LibNyx with crates.io version (#3269) 2025-05-23 20:28:59 +02:00
Dongjia "toka" Zhang
7b9be937f7
Use nightly for miri (#3268)
* miri nightly

* actually add miri

* ??

* clp cache new
2025-05-23 19:22:15 +02:00
dependabot[bot]
9611c59a6c
Update pyo3-build-config requirement from 0.24.0 to 0.25.0 (#3230)
Updates the requirements on [pyo3-build-config](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.24.0...v0.24.2)

---
updated-dependencies:
- dependency-name: pyo3-build-config
  dependency-version: 0.24.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-23 19:15:48 +02:00
Dongjia "toka" Zhang
2c262b0597
UPDATE LOCKFILE (#3267) 2025-05-23 16:35:30 +02:00
lazymio
18d46bed29
Allow InputLocation::Stdin to specify a file name (#3265)
* Allow filename for InputLocation::StdIn

* clippy

* format code

* rename to input_file

* fix

* changes left out
2025-05-23 16:31:41 +02:00
jma
71d08f5f04
Update aarch64.rs (#3266) 2025-05-23 14:28:27 +02:00
jma
871548c366
Allow passing Qemu object to QemuBytesCoverageSugar (#3261)
* attempt to return Qemu object as a parameter to QemuBytesCoverageSugar

* apply clippy suggestions from precommit.sh

* python qemu sugar: add option to enable stdout

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-23 10:22:00 +02:00
WorksButNotTested
213651a95c
Speedup & cleanup Ci (#3263)
* Fix caching

* Simplify names of fuzzers

* Fix missing equals sign

* Rename utils job
2025-05-22 23:47:08 +02:00
WorksButNotTested
4abd6a4a6a
Support downloading devcontainer rather than building it (#3264) 2025-05-22 20:45:13 +02:00
Dongjia "toka" Zhang
fa8fd63eb3
Fix heartbeat (#3262)
* Update fastbloom requirement from 0.9.0 to 0.10.0

---
updated-dependencies:
- dependency-name: fastbloom
  dependency-version: 0.9.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* manual upd

* dfasf

* put it back

* more

* fixer

* ci

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-22 18:14:16 +02:00
dependabot[bot]
6cd6600e7e
Update fastbloom requirement from 0.9.0 to 0.10.0 (#3213)
* Update fastbloom requirement from 0.9.0 to 0.10.0

---
updated-dependencies:
- dependency-name: fastbloom
  dependency-version: 0.9.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* manual upd

* dfasf

* put it back

* more

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-22 16:49:40 +02:00
WorksButNotTested
1355bd5294
Improve CI (#3258)
* Improve CI

* Fix markup errors

* Remove unnecessary matrix parameters

* Rename matrix jobs to tidy up the UI

* Allow the docker cache to be updated

* Fix cache name

* Share some caches

* Rename tools
2025-05-22 16:08:35 +02:00
WorksButNotTested
3a62013c85
LibAFL_QEMU: Add redirect stdout module (#3256)
* Add redirect stdout

* Review changes
2025-05-21 13:26:02 +02:00
3ff617e4a9 update scripts 2025-05-21 08:32:24 +00:00
794b617205 rm README; /dev/null drive 2025-05-21 08:25:13 +00:00
08019ae94f fix partial eq for refined tcb; remains unused 2025-05-21 08:22:29 +00:00
Rowan Hart
0b25d723c0
Windows Support for LibAFL-LibFuzzer (#3130)
* Add windows build script and additional changes to support windows for libafl-libfuzzer

* Update build scripts and harness wrapping directives

* Resolve issue with corpus edge count calculation

* Add help message and make fork do nothing on Windows

* Format harness_wrap.cpp

* Clippy happiness pass

* Clippy happiness pass

* Clippy happiness pass

* Correct logic

* Correct logic

* Update help output and make runs argument work

* Add test for libafl_libfuzzer on windows

* Add workflow for libafl_libfuzzer test

* Fix copy without dependent task

* Add libafl_libfuzzer_windows to preflight list

* Format harness

* Explicitly ignore windows fuzzer

* Remove windows-specific copy from unix instructions

* Ensure using nightly

* Fix job name

* Update build to use libFuzzer.lib on Windows to keep consistent with Linux

* Remove nightly requirement

---------

Co-authored-by: Rowan Hart <rowanhart@microsoft.com>
2025-05-21 01:35:48 +02:00
WorksButNotTested
db1d38eeb6
LibAFL_QEMU/librasan: Add support for reading environment (#3241)
* Add support for reading environment

* Fix clippy

* Review fixes
2025-05-20 21:48:08 +02:00
WorksButNotTested
d7eb3bd234
LibAFL_QEMU: Fix snapshots for large mappings (#3252) 2025-05-20 17:30:26 +02:00
Dongjia "toka" Zhang
e832e32d52
Nightly fmt (#3255)
* fmt

* a

* a

* ab
2025-05-20 12:30:39 +02:00
Dongjia "toka" Zhang
619f6cba52
Use nightly fmt (#3254)
* fmt

* a
2025-05-20 10:57:41 +02:00
fc68b55749 targets 2025-05-19 12:51:57 +00:00
dependabot[bot]
4dc5a8ed14
Update criterion requirement from 0.5.1 to 0.6.0 (#3251)
* Update criterion requirement from 0.5.1 to 0.6.0

Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.5.1...0.6.0)

---
updated-dependencies:
- dependency-name: criterion
  dependency-version: 0.6.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* clippy

* undo / too modern

* clip

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <dmnk@google.com>
2025-05-19 14:49:25 +02:00
EvianZhang
0015254071
Use ShMemProvider for forkserver (#3249)
* Add android CI

* update

* Move together

* Use shmem for forkserver several pointers

* Fix clippy

* Fix

* Make shmem's into_raw private

* Log error message in forkserver

* Fix clippy

* Fix clippy

---------

Co-authored-by: mio <mio@lazym.io>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-19 12:17:53 +02:00
WorksButNotTested
74a5362c15
Add x86_64 architecture to QEMU in Dockerfile (#3250) 2025-05-19 12:10:36 +02:00
lazymio
90223028fd
Remove spurious logs (#3246) 2025-05-19 11:29:06 +02:00
lazymio
73cc2f5b9c
Make unique_std_input_file more unique (#3247) 2025-05-18 23:17:29 +02:00
lazymio
542b7f75b7
Fix CI (#3248)
* fix ci

track: https://github.com/dtolnay/proc-macro2/pull/501

* format toml

* fix typo

* Use nightly for libafl_frida

* Install nightly for splitter

* Use dtolnay/rust-toolchain@nightly

* install ca-certificates
2025-05-18 22:00:40 +08:00
lazymio
0e9dfd62ee
LetForkserverExecutor being Send (#3242)
* Implement `Send` for `Shm`

it is safe because we take the ownership of the inner map pointer. Only potential
violation is deref the underlying pointer but that’s already unsafe. Therefore,
the properties of Send still hold within the safe world.

* Bump 1.87

* use std::io::pipe so that they are `Send`

* clippy

* upgrade

* Avoid phantomdata to make ForkserverExecutor !Send

* Missing gates

* Fix nostd

* bump in Dockerfile

* use dtolnay/rust-toolchain@stable instead

* setup latest toolchain on non Linux

* Fix typo
2025-05-17 14:45:08 +02:00
lazymio
ba93e9d2ea
Add support for AFL_LLVM/GCC_ONLY_FSRV (#3245)
* Add support for AFL_LLVM/GCC_ONLY_FSRV

* clippy
2025-05-17 13:56:28 +02:00
lazymio
ddd0930e67
Support binding to a single core for ForkserverExecutor (#3236)
* support bind to core for ForkserverExecutor

* fix for non-fork platforms

* clippy

* Remove redundant env
2025-05-17 13:55:44 +02:00
Ivan Gulakov
4763ada075
Use is_multiple_of instead of % == 0 (#3244)
I was reading the changelog of 1.87 and noticed that it's stable now.
Realised that I saw a todo in the code :)

https://releases.rs/docs/1.87.0/
2025-05-17 00:13:31 +02:00
WorksButNotTested
bb24fb555b
Update Dockerfile (#3243) 2025-05-16 18:31:17 +02:00
lazymio
be74774463
Use Arc<()> to ref-counting InputFile (#3240)
* clean lib_bolts::fs

* clippy

* avoid racy
2025-05-16 17:06:23 +02:00
Dongjia "toka" Zhang
7a9f46b9fb
Remove nightly from CI. (#3232)
* stable ci

* fixer

* aa

* no -z flag

* doc

* ??

* this one needs

* nightly for some of them ..

* turn off fail fast for now 🥱

* aaa

* afasdfasfas

* mm

* tmate

* linker's fault

* fixer

* f

* dfsafdasfasf
2025-05-16 15:23:44 +02:00
lazymio
8c0ee046cd
Implement HasBytesConverter for NopFuzzer (#3239) 2025-05-16 13:31:15 +02:00
lazymio
7a9cca9e1b
Expose AFL++ style extended cmplog for unicornafl (#3238)
* expose afl++ style extended cmplog for unicornafl

* also update map ptr

* fix imports

* fix naming

* feature dep
2025-05-16 13:29:49 +02:00
Dominik Maier
8b0fc8ca73
Forkserver: Add __AFL_SHM_FUZZ_MAP_SIZE, clean up env variables (#3235)
* Clean up env variables, add env for map size

* Bring back lockfiles

* fix

* PAGE_SIZE->MAP_SIZE
2025-05-16 12:15:17 +02:00
WorksButNotTested
b5ab6bad1c
Allow QEMU location and version to be specified in environment (#3226)
* Allow QEMU location and version to be specified in environment

* Rename things

* Change remote to url
2025-05-16 11:34:18 +02:00
d94da1b875 demo build script++ 2025-05-15 14:03:28 +00:00
Dongjia "toka" Zhang
626812a7ce
Remove nightly feature from libafl_qemu (#3231)
* ci_splitter

* clpo

* FIX

* aa

* no nightly qemu
2025-05-15 14:29:44 +02:00
WorksButNotTested
2e0d6343af
Add CI for utils (#3224) 2025-05-15 06:45:17 +02:00
WorksButNotTested
e3a3dfb41b
Optimize data structures used by librasan (#3227) 2025-05-15 06:29:37 +02:00
WorksButNotTested
23185b642b
Fix gdb_qemu after spurious find-replace (#3223) 2025-05-14 12:40:18 +02:00
f7804f9b0c update targets 2025-05-14 09:10:04 +00:00
Dominik Maier
b138c528ec
Add doc links to newly added load_callback return err (#3222) 2025-05-14 09:41:26 +02:00
Aarnav
c44802cf02
Make input loading fallible in SyncFromDiskStage (#3195)
* Make input loading fallible in SyncFromDiskStage

* fmt

* Add InvalidInput in Error enum and skip the Input in SyncFromDiskStage if it is encountered

* sync: remove file if error on loading in SyncFromDiskStage

* add reason to Error::InvalidInput

* sync make failure log a warning. clippy, fmt

* typo

* fmt

* fmt

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-05-14 08:39:25 +02:00
Dominik Maier
fef129e23c
Conform AFL struct casing to codebase/rust (#3221)
* Conform AFL struct casing to codebase/rust

* Actually, Aflpp looks better
2025-05-13 17:56:58 +02:00
Dominik Maier
c606ac106a
Add Lua mutator, a mutator to write mutations in Lua (#3220)
* Add Lua mutator, a mutator using Lua

* lua?

* fix name

* move lints about

* Testing more fix

* More fix?

* macros?

* macros

* more fmt

* fix doc?
2025-05-13 17:36:28 +02:00
lazymio
f901c2085d
Support capturing stdout/stderr for ForkserverExecutor and code clean (#3216)
* Support capture stdout/stderr for ForkserverExecutor

Reduce code duplication for ForkserverExecutor and CommandExecutor

* use memfd_create from nix for macos and remove debug print

* resolve macos issue

* clippy

* fix macos again

* fix docs

* fix imports

* format code

* fix docs again

* fix sample

* fix another wrong import

* restore cargo.lock

* add an inner for target args

* fix and docs

* fix

* rename to ChildArgs and ChildArgsInner

* revert forkserver_simple

* allow debug child with observers

* fmt

* std marker

* fix

* move implementation to observers

* implement serde

* Add a forkserver_capture_stdout

* renaming

* fix

* fmt

* fix CommandExecutor

* add a test to check capture

* fix imports

* clippy

* fix sample

* update sample to make it closer to real usecase

* also CommandExecutor for sample

* format

* add forkserver_capture_stdout to CI

* fix doc

* accidentally remove

* fix non_std

* fix for windows

* remove useless lint

* remove spurious fuzzer

* fix for windows again

* fix imports

* fix doc sample

* fix docs

* fix sample

* fmt

* clippy

* clippy again

* fix msrv

* have cargo.lock for sample fuzzer

* avoid double read

* fix fsrv and cmd

* fix sample

* fix docs for windows

* fix typo

* clippy again

* fix exec

* typo

* clippy

* update

* fix nyx executor

* cliipy

* fmt again

* last clippy

* clippy
2025-05-13 16:08:27 +02:00
Dominik Maier
2dbf636201
Fix fuzzers in docs, add them to CI (fixes #3185) (#3210)
* Fix fuzzers in docs, add them to CI (fixes #3185)

* ignore macos for now

* Ooops wrong one

* fix?

* clp

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-13 14:14:12 +02:00
12396f7104 plot script fixes 2025-05-13 12:09:58 +00:00
Dominik Maier
1eb61383d3
Simple Clippy Fix (#3219)
* Update sugar to new things

* Fixes

* tiny

* fix qemu

* Fix cmplog

* taplo fmt

* Fix cmplog forkserver sugar, clippy

* clip

* clip

* Simple clippy fix
2025-05-13 03:22:22 +02:00
Dominik Maier
24c31943f3
Update libafl-sugar with latest bells and whistles (#3209)
* Update sugar to new things

* Fixes

* tiny

* fix qemu

* Fix cmplog

* taplo fmt

* Fix cmplog forkserver sugar, clippy

* clip

* clip
2025-05-13 03:06:00 +02:00
Dongjia "toka" Zhang
ecaa013263
Replace parallellize_cargo_check.py with Rust code (#3217)
* ci_splitter

* clpo

* FIX

* aa
2025-05-12 18:01:21 +02:00
a0ab58a6c9 bump STG_MAP_SIZE 2025-05-12 15:45:39 +00:00
c420e5c381 configTASK_NOTIFICATION_ARRAY_ENTRIES=10 + new target 2025-05-12 15:15:17 +00:00
Romain Malmain
c9b0dc216f
LibAFL QEMU update to v10.0.0 (#3181)
* update qemu hash

* clippy, fmt

* update

* Revert "Update hashbrown requirement from 0.14.5 to 0.15.3 (#3184)" (#3186)

This reverts commit 4448799dc2205e4cb1753b8b8d91b4f6d299365d.

* update qemu

* fix systemmode

* update qemu

* update qemu

* update qemu with fix

* debug

* cargo hack

* FMT

---------

Co-authored-by: Dongjia Zhang <tokazerkje@outlook.com>
2025-05-12 16:58:11 +02:00
Wim de With
0d962bc561
librasan: Simplify assembly patches (#3192)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-12 16:17:56 +02:00
lazymio
df9b5b7e3d
Fix for LLVM-15 (#3215) 2025-05-12 15:54:43 +02:00
dependabot[bot]
522e00eda0
Bump tokio from 1.44.1 to 1.45.0 in /fuzzers/binary_only/frida_libpng (#3212)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.44.1 to 1.45.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.45.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.45.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-05-12 15:29:14 +02:00
Dongjia "toka" Zhang
390008e1d5
fix qemu launcher bug (#3206)
* no more shellscript

* metadatas

* clp

* clippo

* fix bug

* taplo

* Merge branch 'qemu_launcher_insane' of github.com:AFLplusplus/LibAFL into qemu_launcher_insane

* fix wrong code
2025-05-12 15:12:20 +02:00
Dongjia "toka" Zhang
60c05396da
Remove scripts/test_fuzzer.sh, Rewrite in Rust (#3205)
* no more shellscript

* metadatas

* clp

* clippo

* this language breaks everyday

* stop

* 2404?

* purge rust

* everything is broken

* test

* ci dead

* aa

* aa

* remove broken shit

* remove broken shit

* broken shit

* a

* lol

* aaaaa

* AI fix

* aa

* aaa

* yes?

* a

* FK

* tmate

* wtf who tf did this shit????

* aa

* useless printlnt

* for system too

* unset first
2025-05-12 13:25:04 +02:00
139a637898 WIP: start parsing queues 2025-05-12 10:21:24 +00:00
Dominik Maier
87bd8a6c73
bolts: Fix UB in Truncate trait (#3207)
* bolts: Fix UB in Truncate trait

* fix test

* rename test

* fmt
2025-05-09 20:09:29 +02:00
dependabot[bot]
58bdbd293a
Bump tokio in /fuzzers/binary_only/frida_windows_gdiplus (#3204)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.44.1 to 1.45.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.45.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.45.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-08 14:44:18 +02:00
Dominik Maier
8d5a80d4b2
Update mach crate to maintained fork (#3203) 2025-05-08 13:09:52 +02:00
Dongjia "toka" Zhang
d8f8640982
Always show user monitor in SimpleMonitor (#3202)
* *recursion* is not proper

* user monitor on

* api changer

* no submodule anymore
2025-05-07 18:17:58 +02:00
Dongjia "toka" Zhang
f33376f1cd
Change error message in restarting manager a bit (#3201)
* *recursion* is not proper

* say that it's a bug
2025-05-07 13:55:52 +02:00
EvianZhang
6dd52722de
Add cmplog shared memory mapping method for forkserver (#3200) 2025-05-07 10:44:44 +02:00
WorksButNotTested
3b6a350b24
Change formatting for durations (#3198) 2025-05-06 17:24:30 +02:00
Dongjia "toka" Zhang
feedca9de8
Enable errors backtrace always (#3199) 2025-05-06 15:08:24 +02:00
EvianZhang
2353eaa61a
Add weak symbol for forkserver (#3196)
* Add weak global symbol sharedmem_fuzzing

* Try

* Try

* Win
2025-05-06 13:23:25 +02:00
Ivan Gulakov
1f91420cd3
Add disable/enable to Corpus (#3193)
* Add enable and disable methods for Corpus

* Add insert_inner_with_id to fix disable/enable & test

Since we need to insert an 'existing' testcase with a certain id, let's
use a private inner function for it.

It's not the most posh way to keep consistency, but as showed in the
test it works 'good enough'.

* Implement disable/enable for libafl_libfuzzer/corpus

* fix clippy issues and fix cfg[not"corpus_btreemap"]

* Move enable/disable from Corpus to a trait

* Rename HasCorpusEnablementOperations to EnableDisableCorpus

Unless we come up with a better idea. Naming is hard.

* fmt the changes
2025-05-05 17:55:55 -07:00
EvianZhang
c0e32cdbba
Refactor to new forkserver (#3183)
* Refactor to new forkserver

* Fix fuzzer examples and delete forkserver.c

* Fix clippy and doc warnings

* Fix symbol error

* Format Cargo.toml; Fix wrong doc link

* Fix silly typo.

* Rename ForkServer to Forkserver to make it more consistent

* Fix build.rs

* Merge StdForkserverParent and PersistentForkserverParent since the forkserver parent has not idea of whether it is persistent and the persistent version can handle the non-persistent version

* Fix clippy

* Do not take ownership for last_child_pid since it may be in persistent mode
2025-05-05 16:45:12 +08:00
Henry Chu
4ae6f34ab4
Split nautilus Python dependencies into separate feature (#3191)
* Split nautilus Python dependencies into separate feature

* Fix Nautilus imports order and tidy formatting

* Refactor tree generation to reduce code duplication

* Make plain_or_script_rule mutable
2025-05-05 00:11:20 -07:00
Ivan Gulakov
3ec09711eb
Add a mention of precommit.sh to CONTRIBUTING.md (#3194) 2025-05-04 18:58:17 +02:00
dependabot[bot]
d3ddc8edc4
Bump pyo3 in /fuzzers/structure_aware/baby_fuzzer_nautilus (#3189)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.24.0 to 0.24.2.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.24.0...v0.24.2)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-version: 0.24.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-03 02:37:52 -07:00
Henry Chu
b9f1c51531
Remove unnecessary trait bounds in NautilusSpliceMutator (#3190)
* Remove unnecessary triat bounds in NautilusSpliceMutator

* Remove unused HasCorpus import
2025-05-03 02:37:33 -07:00
WorksButNotTested
ec734c74a5
Move to nostd printf and musl crates (#3188)
* Adopt nostd-printf

* Adopt nostd-musl
2025-05-02 18:46:08 -07:00
Wim de With
0ddc5f156d
librasan: Support patching Thumb functions (#3176)
* librasan: Use bx instruction for ARM patch

* librasan: Support patching Thumb functions

* Get page size dynamically, protect two pages and undo changes after

* Rename ARM patch test functions

* librasan: Simplify patch for ARM
2025-05-02 18:45:03 -07:00
Wim de With
3b23012faf
Exclude ASAN DSO address ranges in QEMU AsanModule (#3180)
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-05-02 15:14:39 +02:00
Romain Malmain
1620bd766f
Revert "Update hashbrown requirement from 0.14.5 to 0.15.3 (#3184)" (#3186)
This reverts commit 4448799dc2205e4cb1753b8b8d91b4f6d299365d.
2025-05-02 11:36:36 +02:00
dependabot[bot]
4448799dc2
Update hashbrown requirement from 0.14.5 to 0.15.3 (#3184)
Updates the requirements on [hashbrown](https://github.com/rust-lang/hashbrown) to permit the latest version.
- [Release notes](https://github.com/rust-lang/hashbrown/releases)
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.14.5...v0.15.3)

---
updated-dependencies:
- dependency-name: hashbrown
  dependency-version: 0.15.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-01 23:52:09 -07:00
Dongjia "toka" Zhang
b11ec7e630
Clean up LLVM Passes (#3182)
* cleanup llvm passes

* upd

* clean up

* LOL

* mac

* ?

* ?

* aaaaaa

* stop

* ?/

* i'm done with this shit language

* nothing works

* debug

* diet

* mm

* aa

* bb
2025-04-30 19:03:37 +02:00
Dongjia "toka" Zhang
62d9485f10
Use symlink instead to get the corpus (#3177)
* a

* add real symlink

* tmate

* corpus

* detmate

---------

Co-authored-by: Skynet 2 <name@domain.example>
2025-04-28 18:47:10 +02:00
Dongjia "toka" Zhang
3ec8098d76
Remove duplicate corpus folders (#3174)
* remove duplicate pngs

* add tmin corpus back

* fix

* windows?

* space

* exit 0

* oops
2025-04-28 15:39:47 +02:00
Wim de With
977189174b
librasan: Fix errno_location function name (#3172) 2025-04-25 23:08:30 +02:00
forky2
c3475cd577
Qemu tmin (#3118)
* Start on qemu_tmin

* WIP

* qemu_tmin working for single testcase.
Also some comment improvements.

* Add env_logger to baby_fuzzer

* Remove old reference.

* Added comment doc for qemu_tmin.

* Slight reorder for parallelisation

* Finished single-thread qemu_tmin

* Finishing touches to single thread version.

* A pre_commit.sh change I didn't notice.

* Duplicate to attempt multi-threaded version

* Fix taplo whine.
Mark "fork" mode as broken.

* Launcher for parallelisation implemented, but for one core.

* Running in parallel. Now need tidy up.

* Parallel version complete.

* Add comment

* Merged single-core/multi-core qemu_tmin into one crate

* Removed forkexecutor mode.

* Precommit fixes

* Add qemu_tmin to build_and_test.yml

* Clippy fixes

* Change tmin test cores to 0.
2025-04-25 23:08:18 +02:00
dependabot[bot]
6bbff51951
Update perf-event-open-sys requirement from 4.0.0 to 5.0.0 (#3136)
---
updated-dependencies:
- dependency-name: perf-event-open-sys
  dependency-version: 5.0.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-25 13:08:51 +02:00
749b909e32 update freertos bindings 2025-04-25 10:44:11 +00:00
c404037d49 plot styling 2025-04-25 10:41:35 +00:00
dependabot[bot]
76850e9588
Bump pyo3 in /fuzzers/structure_aware/forkserver_simple_nautilus (#3120)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.24.0 to 0.24.1.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/v0.24.1/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.24.0...v0.24.1)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-24 19:58:00 +02:00
Dongjia "toka" Zhang
95f7c155bd
Make fuzzer hold testcase bytes converter (#3127)
* add

* fixing

* done

* fix

* a

* no std

* mm

* aaa

* fix

* mm

* please stop

* please stop

* please stop

* Just

* aaaaa

* aaa

* plz stop

* aaa

* mmm

* aaa

* AAAAAAAAAAAAAA

* a bit faster CI?

* win

* wtf are these garbages..?

* no cache?

* ???

* always

* ?/

* aa

* aa

* glib

* glib

* pixman

* AAA

* AA

* unicorn

* unicron

* nyx
2025-04-24 19:34:24 +02:00
Konstantinos Kanavouras
50e1239de9
Remove unneeded workaround for bindgen not supporting f16 types (#3166) 2025-04-24 18:33:12 +02:00
dependabot[bot]
9b3400ffbc
Bump tokio from 1.44.1 to 1.44.2 in /utils/libafl_repo_tools (#3139)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.44.1 to 1.44.2.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.44.2)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.44.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-24 17:01:38 +02:00
Dongjia "toka" Zhang
d0acc3efc2
Add doc (#3171) 2025-04-23 16:04:35 +02:00
Dongjia "toka" Zhang
03a49fa5a8
Make InputFilter public (#3170) 2025-04-23 15:06:52 +02:00
jma
e443d68a39
Fix python bindings (#3164)
* fix python bindings when compiling for ARM Qemu user

* apply partial precommit.sh
2025-04-17 13:07:16 +02:00
MingxiYe
8b194bdd40
fix typo in qemu_linux_process (#3163) 2025-04-16 23:27:26 +02:00
Nathaniel Bennett
a198b33096
Fix 0/0 stability feedback for libafl_nyx (#3162) 2025-04-15 14:58:18 +02:00
lazymio
eb06d4a757
Default to use SIMD acceleration map feedbacks (#3157)
* Feature renam and clean urls

* Fix features renaming

* wip: working libafl_bolts simd

* initial default SimdMapFeedback implementation

* clippy

* fix imports

* clippy again

* fmt

* also generalize simplify_map

* clippy again

* fix no_std

* fmt

* fix import for no-std

* fmt

* fixes

* Fix fuzzers

* Fix cargo docs

* better bounds

* fmt

* Fix fuzzer

* Accidentally commit the file
2025-04-14 12:29:51 +02:00
Dongjia "toka" Zhang
dd0bcba103
Fix #3155 (#3156)
* robot

* do ne

* FIXER

* fixer

* plz

* LOL

* FIXER
2025-04-12 22:39:32 +02:00
Francesco Cirillo
796ce20cd8
ScheduledMutator Fix with_max_stack_pow (#3148)
* ScheduledMutator Fix with_max_stack_pow

* Renamed StdScheduledMutator to HavocScheduledMutator

* Added SingleChoiceScheduledMutator

* Changed HavocScheduledMutator description

* Added rename in migration

* Missed renaming

* cargo fmt fix

* cargo fmt fix 2

* Clippy duplicate code and safer test

* cargo fmt fix 3

* Removed my hallucination
2025-04-12 20:35:31 +02:00
Dongjia "toka" Zhang
7ea4070338
Fix TUI (#3151) 2025-04-10 18:27:39 +02:00
Dominik Maier
6372148149
Update README.md (#3149) 2025-04-10 02:21:17 +02:00
Romain Malmain
4f5ca8f8e2
Fix cmplog for qemu fork executor (#3145)
* update cmplog map ptr

* do not lower it; it's still there so it should be working
2025-04-09 15:25:13 +02:00
Marco C.
398104c299
CI: try to speedup by avoiding unnecessary installs (#3144)
* Start removing non-apt deps

GH images come with baked-in software that doesn't
come from apt, getting the apt version will just
slow down CI since the baked in version will be
used anyway.

* Do not install llvm-X if already there

* Do not remove old llvm-X

Est-ce qu'ils nous derangent ?

* default llvm install is missing stuff

* CLang is already baked-in

* Set installed clang as default

* Move ARM deps to qemu fuzzers
2025-04-09 15:09:16 +02:00
Romain Malmain
7680ea1346
Safe qemu cpu from index (#2941)
* safe cpu from index

* add comment
2025-04-09 14:43:26 +02:00
Dongjia "toka" Zhang
d1f566c441
Remove "global" prefix from TUI (#3146) 2025-04-09 11:22:18 +02:00
Dongjia "toka" Zhang
8683c68e59
Fix #3133 #2755 (#3143)
* incroyable

* lolg
2025-04-08 22:20:17 +02:00
Romain Malmain
fb8939eefc
Fix fork bug in libafl qemu (#3109)
* fix fork bug

* lol

* fix

* lower it; we're gonna move from this anyway

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-08 19:08:40 +02:00
lazymio
bfc55c98a7
Enable SIMD acceleration for stable rust toolchain (#3140)
* initial support

* migrate SAND

* Update comments

* Fmt

* Clippy

* Fix missing docs

* fmt fix

* clippy again

* weird clippy

* clippy

* Fix

* Allow new SIMDMapFeedback

* Fix features

* Fix features again

* Allow custom names

* Fix imports

* Fix imports

* Fmt

* Fix missing implementations

* Requires std to simd

* DO NOT Overwrite names

* Format toml

* no_std fix

* fmt

* Use SIMDMapFeedback for libfuzzer_libpng

* no_std (?)

* clippy

* fix no_alloc

* allow cargo docs to enable all features

* clippy again

* Fix missing import

* Fix cargo docs

* Naive simplify_map doesn't require wide

* Accidentally commit the file

* more fine grined features

* Fix clippy.ps1

* Fix wide256 for simplify_map

* Renaming to SimdMapFeedback

* Dynamic dispatch

* Fix naming

* Move to simd.rs

* clippy

* clippy

* dispatch earlier

* Fix clippy

* clippy

* clippy

* Revert previous change

* Fix comments

* Update comments for std_covmap_is_interesting

* remove SIMD and choose fastest implementation based on target_arch

* no longer nightly imports

* Fix

* upstream benchmark code

* Fix docs

* Fix libfuzzer_libpng

* Disable clippy for benchmark

* clippy

* clippy again

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-08 19:08:16 +02:00
Dongjia "toka" Zhang
373fe03633
Use HashMap to manage ClientStat, Fix #3133 (#3142)
* fix

* lol

* lol

* clp fixer

* clp fixer

* revert cargo.toml
2025-04-08 19:06:20 +02:00
lazymio
fa8a576ef0
Introduce HasAflStyleTargetArguments and restore parse_afl_cmdline for CommandExecutor (#3125)
* Introduce HasAflStyleTargetArguments and restore parse_afl_cmdline for CommandExecutor

* clippy

* Fix imports

* Move envs to the shared trait

* Move to a standalone file

* Format

* Gate via std and unix

* Fix

* clippy

* move InputLocation to afl_args

* clippy

* Fix

* fmt

* Fix more

* Shall last missing

* Rename to AflTargetArgs

* Fmt

* move AflTargetArgs to libafl_bolts and adapt CMainArgsBuilder to use it

* use_stdin is no longer needed

* leaveout

* Fix again

* Renaming

* Leave out lib.rs

* Leave out fmt

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-08 13:19:44 +02:00
Marco C.
a7d735c1de
Add IntelPT tracing module to libafl_qemu systemmode with KVM (#2774)
* intelpt module
2025-04-08 10:10:39 +02:00
Daniel Hajjar
ec24513c95
Add RISC-V support to libafl_unicorn (#3134) 2025-04-07 16:18:10 +02:00
dependabot[bot]
8426ba5d58
Update crossterm requirement from 0.28.1 to 0.29.0 (#3135)
---
updated-dependencies:
- dependency-name: crossterm
  dependency-version: 0.29.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-07 16:12:54 +02:00
lazymio
a1b090609d
Migrate NopExecutor used in tests to ConstExecutor (#3129) 2025-04-04 14:55:33 +02:00
lazymio
caf12a647c
NopStage::should_restart shall return false (#3128) 2025-04-04 07:50:58 +02:00
lazymio
db7ce822dc
QoL Types and Changes (#3124)
* Nop executor

* Qol types

* no stage

* A new() for NopStage

* clippy

* clippy again

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-03 17:25:11 +02:00
lazymio
0fdfa1d7a1
Add back executions to Testcase (#3115)
* Add back executions to Testcase

* Small clippy

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-04-03 17:24:38 +02:00
Dongjia "toka" Zhang
c99371fd20
Fix tiny inst (#3126)
* fix tn inst

* add

* fix more
2025-04-03 16:22:25 +02:00
bernhl
fb0848e174
Remove unecessary HasTargetBytes constraint (#3117) 2025-04-01 20:39:01 +02:00
Romain Malmain
9dff7a438d
Add client stats to Events (#3116)
* add stats alongside Event over the wire
2025-04-01 16:51:52 +02:00
Romain Malmain
184b69be8e
Update QEMU syshook ret value (#3092)
* update syshook ret value
2025-03-31 15:51:01 +02:00
WorksButNotTested
c68b30ae2a
Add iniitialize feature to librasan (#3113)
* Optimize memset

* Make the initialization of memory buffers an optional feature

---------

Co-authored-by: Your Name <you@example.com>
2025-03-28 20:52:57 +01:00
WorksButNotTested
36c748100e
Change GuestTracking to use a BTreeSet to remove performance bottleneck (#3112)
Co-authored-by: Your Name <you@example.com>
2025-03-28 20:13:34 +01:00
Dongjia "toka" Zhang
b67bd1792f
update libnyx (#3111)
* apude

* lock
2025-03-27 13:25:58 +01:00
dkoch144
f700aac911
Enable building libpng on CI without using GUI (#3110)
* Fixing windows ci build in justfile. harness.cc modified for cl.exe. Additions to README.

* More precise compiler check for noinline definition.

---------

Co-authored-by: dkoch <dkoch@vigilantsys.com>
2025-03-26 22:16:06 +01:00
jejuisland87654
58bb64fac4
Upgrade pyo3 0.23.2 -> 0.24.0 (#3107) 2025-03-26 11:57:08 +01:00
WorksButNotTested
869edd068d
Various updates to librasan (#3106)
* Add rawmemchr

* Add stpncpy

* Add strchrnul

* Fix strcat

* Added strncat

* Add wcschr

* Minor tweak

* Add wcsncmp

* Add wcsnlen

* Add wcsrchr

* Add wmemchr

* Fix asan load/store sizes for wide string functions

* Refactor patches

* Rename tracking functions to prevent collision with allocator

* Change return type of asan_sym to make it consistent with the other native functions

* Fix mutex re-entrancy issue in Patches by splitting locks

* Fix tests on 32-bit platforms

---------

Co-authored-by: Your Name <you@example.com>
2025-03-25 15:22:20 +01:00
Romain Malmain
58607dc333
Update QEMU to v9.2.2 (#3088)
* update qemu to v9.2.2

* alignment field has been removed
2025-03-25 14:34:44 +01:00
Dongjia "toka" Zhang
bd12639f8e
0.15.2 (#3104)
* 0.15.2

* miri

* mistake

* unsafe

* lock file
2025-03-25 13:30:15 +01:00
Dominik Maier
ebc6c0d94c
Change ptr::eq to ptr::addr_eq where semantically more correct (#3105)
* Change ptr::eq to ptr::addr_eq where semantically more correct

* not needed here?
2025-03-24 15:04:36 -07:00
Romain Malmain
c863c8bd6c
Fix clippy (#3102)
* fix clippy

* libafl_frida/

* lol

* lol

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-03-24 15:03:04 +01:00
Dongjia "toka" Zhang
60d0ccb8cb
Commandline args handling for binary only target on libafl_qemu (#3098)
* POC

* POC

* pin the obj

* add map_input_to_memory

* still trying to get things to work

* Justfile

* lol

* nah bad idea

* done

* revert

* revert

* lol

* Move to libafl_qemu

* a

* add

* add

* lol

* clp

* a

* tmate

* Thank you bash I love you

* aaaaaaaa

* a

* bbb
2025-03-21 18:43:08 +01:00
Dan Blackwell
9195245998
Proposed fix for issue #3094, whereby all conditional comparisons are treat as 1 byte (rather than 2, 4, or 8) (#3095) 2025-03-21 12:55:58 +01:00
Dongjia "toka" Zhang
f73d47dfb8
More stable just test for libfuzzer_stb_image_sugar (#3097)
* aa

* tab to space

* bash syntax is ❤❤❤❤
2025-03-20 15:10:14 +01:00
dependabot[bot]
2166b45838
Update typed-builder requirement from 0.20.0 to 0.21.0 (#3096)
Updates the requirements on [typed-builder](https://github.com/idanarye/rust-typed-builder) to permit the latest version.
- [Release notes](https://github.com/idanarye/rust-typed-builder/releases)
- [Changelog](https://github.com/idanarye/rust-typed-builder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/idanarye/rust-typed-builder/compare/v0.20.0...v0.20.1)

---
updated-dependencies:
- dependency-name: typed-builder
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-20 13:16:36 +01:00
Dongjia "toka" Zhang
4130e3860f
Add redirect stdin module (#3077)
* forkserver api

* poc

* i'm dumb

* add things

* use snapshot

* delete println debug

* anglais

* d

* fixer

* take care of further read

* take care about u32

* aa

* fix cursor

* mm

* pushing things temporary so i can try this path later

* delete useless setter

* rme

* BytesConverter

* now revert

* clp

* typo

* change how input passing works

* fuck

* fmt

* fixer

* fix

* lol

* lol

* lol

* disable CI

* delete assert

* clp

* a
2025-03-19 19:03:02 +01:00
WorksButNotTested
30946641cd
Add filter to ASAN module in qemu_launcher (#3089)
also add filters to rasan runner.

Co-authored-by: Your Name <you@example.com>
2025-03-19 16:13:45 +01:00
Addison Crump
1b85a92577
Fixup libafl_libfuzzer with new nightly internal symbol mangling (#3093)
* fixup libfuzzer with new nightly internal symbol mangling

* cringe, clippy fail
2025-03-19 16:05:23 +01:00
Dongjia "toka" Zhang
d0da90cf6a
Make Qemu.mmap public and accept fd as the argument (#3083)
* chg mmap

* Proper error handling

* lol

* fix ci
2025-03-18 12:21:11 +01:00
forky2
0a923b27d2
Fix git pager (needs less, not cat, for expected behaviour). (#3085) 2025-03-18 11:17:48 +01:00
Romain Malmain
d5ddc1359e
Fix qemu snapshot module unmap (#3084)
* fix qemu usermode snapshot unmap

* fix phys addr computation for qemu. some cleanup.
2025-03-18 10:31:16 +01:00
Romain Malmain
a613676675
Fix LibAFL QEMU race condition between main loop and a vcpu (#3072) 2025-03-18 09:43:00 +01:00
WorksButNotTested
d317725170
Add total execs to TUI (#3078)
* Add total execs to TUI

* Pretty print large numbers

---------

Co-authored-by: Your Name <you@example.com>
2025-03-14 20:47:51 +01:00
dependabot[bot]
8e32947db6
Update winsafe requirement from 0.0.22 to 0.0.23 (#3034)
Updates the requirements on [winsafe](https://github.com/rodrigocfd/winsafe) to permit the latest version.
- [Commits](https://github.com/rodrigocfd/winsafe/compare/v0.0.22...v0.0.23)

---
updated-dependencies:
- dependency-name: winsafe
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-03-14 16:57:27 +01:00
Romain Malmain
d67296f34e
Soft recovery from crashes in libafl qemu usermode (#3073)
* soft recovery from crashes in qemu

* regen bindings for clippy

* configurable crash behaviour
2025-03-14 16:56:03 +01:00
Dongjia "toka" Zhang
d4a86cdeeb
Hide Forkserver constructor API (#3076) 2025-03-14 14:30:54 +01:00
WorksButNotTested
0154a3b930
Added heap feature (#3074)
* Added heap feature

* Rename feature and add some more docs

* Use document-features crate

* Expose the patching API for more flexibility

---------

Co-authored-by: Your Name <you@example.com>
2025-03-14 13:19:23 +01:00
dependabot[bot]
e728df9843
Update which requirement from 6.0.3 to 7.0.2 (#3075)
Updates the requirements on [which](https://github.com/harryfei/which-rs) to permit the latest version.
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/6.0.3...7.0.2)

---
updated-dependencies:
- dependency-name: which
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-14 12:54:35 +01:00
Romain Malmain
85bcafa831
Track lockfiles (#3015)
* rename libafl_fmt into liabfl_repo_tools

* add option to generate lockfiles

* only keep binary lockfiles (update gitignore)
2025-03-13 12:32:09 +01:00
Dongjia "toka" Zhang
f3da9da7bf
Fix metadata addition when solution is found (#3069)
* fix

* fixer
2025-03-12 13:57:06 +01:00
Dongjia "toka" Zhang
63e82d898e
Bring back #3029 (#3067)
* rerevert

* add comments
2025-03-11 19:52:24 +01:00
Dongjia "toka" Zhang
ff8a5b3baa
Fix wrong path in Justfile (#3068) 2025-03-11 18:58:53 +01:00
Dongjia "toka" Zhang
226a20e6cf
Fix usage of TracingStage (#3062)
* real fix

* more

* debug

* fix

* fixer

* mmmm

* mm

* mm

* mm

* fix

* fix atheris

* ?
2025-03-11 14:37:19 +01:00
Dongjia "toka" Zhang
f4cb9a827d
Partially Revert #3029 and #3053 (#3063)
* revert begins

* fixer

* e?

* fixer

* how you didn't report that at the same time though???

* i'm tired of you
2025-03-11 12:53:27 +01:00
Dominik Maier
115672904e
Auto-implement Rand for (normal, rusty rng) CoreRng types, fixes #3060 (#3064)
* Auto-implement Rand for (normal, rusty rng) CoreRng types, fixes #3060

* clippy

* cleanup

* clip

* doc

* more doc
2025-03-11 11:51:31 +01:00
s1341
bf3c391ffa
librasan: tiny fixes to make it build (#3065)
* librasan: tiny fixes to make it build

* librasan: source -> .
2025-03-11 09:12:43 +02:00
WorksButNotTested
728b1216bb
Librasan (#3023)
* Fixes to main

* Add librasan

* Party like it's 2024

* Fix snapshot module to work with guest asan

* Fix guest_asan module

* Fixes to runner

* Fix linking issues using a REL

* Fix qemu_launcher

* Change modify_mapping to a method

* Fix gasan_test

* Remove debug from Justfile

* Optimize release build of librasan

* Set ulimit for qasan and gasan tests

* Tidy up symbol renaming

* Add missing symbols for PPC

* Change to support rustix 1.0.0

* Canonicalize the CUSTOM_ASAN_PATH

* Review changes

* Restructure backends

* release_max_level_info

* More review changes

* Clippy fixes

* Changes to reduce the burden on the CI

* Fix macos clippy

---------

Co-authored-by: Your Name <you@example.com>
2025-03-10 17:27:55 +01:00
dependabot[bot]
f64554c5db
Update cargo_toml requirement from 0.21.0 to 0.22.0 (#3057)
---
updated-dependencies:
- dependency-name: cargo_toml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-03-10 16:00:57 +01:00
dependabot[bot]
8233117962
Update pyo3-build-config requirement from 0.23.2 to 0.24.0 (#3058)
Updates the requirements on [pyo3-build-config](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.23.2...v0.23.5)

---
updated-dependencies:
- dependency-name: pyo3-build-config
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-10 14:58:24 +01:00
Dongjia "toka" Zhang
15da05f8e8
Cleanup for #3035 (#3059) 2025-03-10 14:09:54 +01:00
Rowan Hart
b8387daa0f
Add build option for FuzzerInterceptors (#3049)
* Add build option for FuzzerInterceptors

* Add removed whole_archive feature

---------

Co-authored-by: Rowan Hart <rowanhart@microsoft.com>
2025-03-09 21:13:05 +01:00
Dongjia "toka" Zhang
620500e295
Remove AdaptiveSerializer, Send off interesting testcase from crash handler, Add clearer error message (#3053)
* clean

* test thread 1

* add some error messages

* mm

* std

* mm

* aa

* pp

* fix

* change fuzzers

* fix

---------

Co-authored-by: Your Name <you@example.com>
2025-03-08 20:12:16 +01:00
Dongjia "toka" Zhang
758fa7f231
Add more debugging tips (#3056)
* add more debugging tips

* fixer
2025-03-07 23:42:13 +01:00
Dongjia "toka" Zhang
0902dc06c4
Debug Windows CI (again) (#3052) 2025-03-07 14:26:58 +01:00
Dhanvith Nayak
41f16890b8
convert share_objectives into a runtime option (#3033)
* add share_objectives field to StdFuzzer

* uhhh maybe add field to StdState instead

* trivial

* implement to handle_in_client()

* fmt

* revert changes to state

* no gating on receiving objectives

* add query method to hasobjectives

* make input field of Event::Objective optional

* fmt and clippy

* move setter to hasobjectives

* better way to handle incoming objective

* fmt

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-03-07 14:18:48 +01:00
Dongjia "toka" Zhang
76539fa247
Debug windows CI (#3051)
* debug windows ci

* can't reproduce
2025-03-07 13:13:42 +01:00
Dongjia "toka" Zhang
7b0a3b861e
Forbid overwriting MapIndexesMetadata (#3048) 2025-03-06 20:56:48 +01:00
Dongjia "toka" Zhang
41bb64f5cb
Revive self-hosted CI (#3045)
* revive CI

* cici
2025-03-06 16:28:49 +01:00
Dongjia "toka" Zhang
629787771b
Fix snapshot module (#3047) 2025-03-06 16:12:05 +01:00
lazymio
c0894c40e5
Fix implementation of UniqueTrace and add UnclassifiedTrace (#3046)
* Fix implementation of UniqueTrace and add UnclassifiedTrace

* Update comments

* Move the implemetnation to classify_counts

* Only init for unique trace

* The missing inline

* Add a TODO
2025-03-06 16:04:39 +01:00
lazymio
de2bc166f0
Implementation of SAND: Decoupling Sanitization from Fuzzing for Low Overhead (#3037)
* Reference implementation of SAND: Decoupling Sanitization from Fuzzing for Low Overhead

* Format code

* make clippy happy

* Update docs

* clean output

* fmt

* Fix for nostd

* Update docs

* use use alloc::vec::Vec;

* Docs updates

* Update docs

* Format toml

* Format again

* Add CI

* Rename run_targets to run_target_all

* Update docs

* Update justfile to test fuzzer

* left out justfile

* Format

* Corner case when bitmap size is as small as 1

* Add comments

* clippy

* Format vuln.c

* Format toml

* Fix doc

* Fix justfile

* Move ExecutorsTuple to executors/mod.rs

* Fix

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-03-06 14:15:22 +01:00
forky2
eaa600e5ac
libafl_qemu: access() size can be zero. (#3038)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-03-05 20:42:06 +01:00
Dongjia "toka" Zhang
6fa564b10b
Delete useless file (#3041) 2025-03-05 20:31:49 +01:00
Dongjia "toka" Zhang
c50bedb4c6
Disable CI that uses self-hosted runner (#3040)
* disable CI

* real fix
2025-03-05 20:18:42 +01:00
Dongjia "toka" Zhang
687f62ff1c
Disable CI that uses self-hosted runner (#3039) 2025-03-05 20:14:06 +01:00
Dongjia "toka" Zhang
977ff10a0f
Make corpus and solution not mutually exclusive (#3029)
* make fuzzer great again

* crash handlers

* hello from windows

* fk

* gee

* m

* temporary fix

* f

* mm

* CICI

* fixer

* Fix Dockerfile

* lol

* clp

* Fuck you clippy

* This lint makes no sense, 0

* ??

* a

* fix

* this lint makes 0 sense

* mm

* clp

* a

* a

* clp

* clippy

* clp

* mm

* FMT

* p

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: toka <toka@tokas-MacBook-Air.local>
2025-03-05 20:10:04 +01:00
Dongjia "toka" Zhang
89342b22c2
Revert #2935 (#3031)
* revert

* null check

* no std
2025-02-28 20:09:01 +01:00
Dongjia "toka" Zhang
86d6fa005e
Disable libafl_qemu tests (#3032)
* llvm upd

* mmmmm

* THIS LANGUAGE IS A JOKE
2025-02-28 18:38:23 +01:00
Romain Malmain
e864bc28b1
Abort on triple fault for in process executors, refactor AddressFilter and PageFilter (#3026)
* abort on triple fault in generic inprocess signal handler

* refactor qemu filters

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-02-28 15:44:22 +01:00
60be7f97ac calculate wcrt bounds 2025-02-28 11:23:36 +01:00
108d5dfe77 benchmark split 2025-02-27 18:47:33 +01:00
c3d45680e8 config+bounds update 2025-02-27 17:10:18 +01:00
Dongjia "toka" Zhang
191bc6d12d
Remove aarch64, arm, i386, ppc tests from C (#3028) 2025-02-27 15:47:10 +01:00
Dominik Maier
ce5fd435ea
Move all unnecessary std uses to core,alloc (#3027)
* Move all unnecessary std uses to core,alloc

* More

* more fix

* more

* more

* Remove libafl-fuzz grimoire

* more

* more

* more cleanup

* remove bins

* fix

* more fix
2025-02-27 14:32:37 +01:00
Dominik Maier
c7207dceb0
Rust 2024 edition (#3022)
* Rust 2024 edition

* gen = generalized

* Fixes

* more fix

* More fix

* even more fix

* fix libfuzzer

* ignore clippy lint

* even more

* fix docs?

* more?

* More pub more better

* win

* docs

* more

* More

* doc stuff?

* counter_maps->counters_maps

* libafl qemu fixes for rust 2024

* fix?

* fmt

* unsafe lint

* final fixes

* fmt

* working?

* not working

* unused import

* win?

* update libafl qemu hash

* fmt

* fix

* unused imports

* fix

* fix

* more foix

* less edition

* fix

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-02-27 00:12:29 +01:00
dependabot[bot]
3d31adcca1
Update ctor requirement to 0.4.0 (#3005)
* Update ctor requirement from 0.2.9 to 0.3.6

---
updated-dependencies:
- dependency-name: ctor
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* ctor 0.4.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dominik Maier <dmnk@google.com>
2025-02-26 22:28:00 +01:00
Dongjia "toka" Zhang
a0d8f7e255
Disable windows-libfuzzer-asan (#3025) 2025-02-26 16:37:21 +01:00
6a4d1af606 swap set48, 64 2025-02-26 14:27:54 +01:00
d2aaf0bf6e config++ 2025-02-26 12:22:52 +01:00
98ed400e1a config updates 2025-02-26 12:17:59 +01:00
fd336e8ab0 fix wrong minia 2025-02-26 10:52:59 +01:00
ColinSeibel
9182fd93e6
scripts/test_fuzzer.sh: correct working directory (#3024) 2025-02-26 09:51:09 +01:00
dependabot[bot]
a917cc046f
Update fastbloom requirement from 0.8.0 to 0.9.0 (#3021)
---
updated-dependencies:
- dependency-name: fastbloom
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-25 16:32:06 +01:00
56c046ecf6 better handling for indices 2025-02-25 13:53:53 +01:00
cb20424cec keep worst observed case, precise isns -> time calculation 2025-02-24 18:35:53 +01:00
WorksButNotTested
7121defff9
Update dockerfile (#3020)
* Fix just

* Update dockerfile

* Changes to test all architectures for qemu-user fuzzers

* Update version of QEMU

* Fix qemu on aarch64

* Fix qemu on i386

---------

Co-authored-by: Your Name <you@example.com>
2025-02-24 16:13:34 +01:00
Dominik Maier
e5ba51aae4
More LibAFL_QEMU Launcher things (#3000)
* More LibAFL_QEMU Launcher things

* Fix CI

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-24 16:12:37 +01:00
63f6f02ba9 snakefile clean 2025-02-21 19:30:18 +01:00
1df4bba604 config updates 2025-02-21 18:36:32 +01:00
800f2c8788 feedback for job woet 2025-02-21 18:29:44 +01:00
Celian G.
40c0a8c57c
Improved calling convention support for x86, x86_64, arm and aarch64 for libafl-qemu (#3013)
* Improved calling convention support for x86, x86_64, arm and aarch64

* fix

* fix write_function_arguments

* fix argument_error

* follow clippy advice

* last change?

* fix guestaddr issue

* add code block for cargo-fmt

* default to default convention

* fix mistake

* add pub

* fix

* changes after review

* last change?

---------

Co-authored-by: celian <cglenaz>
2025-02-21 18:04:45 +01:00
ca8d9fdf0a abb woet increases are interesting 2025-02-21 14:24:34 +01:00
Dominik Maier
7c83be2408
Add auto format to settings.json.default, format documentation and macros (#3019)
* Add auto format to settings.json.default

* Add more nightly rustfmt features
2025-02-21 13:31:31 +01:00
Dominik Maier
14eee111c2
Fix Clippy for Rust 1.85 (#3017)
* Fix latest Clippy

* fixed template

* How did I not see this
2025-02-21 13:15:12 +01:00
Dominik Maier
5746df835e
Add precommit script (#3018)
* Add precommit script

* Merge stuff
2025-02-21 12:57:44 +01:00
Dominik Maier
df7e51ed42
Add PR description section to PR template (#3016)
* Add PR description place

* remove PR
2025-02-21 12:24:12 +01:00
Dongjia "toka" Zhang
d40f18f377
Fix finish_stage call (#3014)
* fixer

* clp

---------

Co-authored-by: toka <toka@tokas-MacBook-Air.local>
2025-02-21 12:23:00 +01:00
66e299cfce intermediat snapshots _at_xh 2025-02-21 10:13:47 +01:00
6d1d7482ee ensure fuzz-length u32 2025-02-21 10:13:07 +01:00
EvianZhang
1debeb74a7
Add statsd monitor documentation (#2996)
* Initial commits

* Complete statsd docs

* Add docs about optionally enabled StatsD monitor
2025-02-21 09:24:49 +01:00
Dongjia "toka" Zhang
d3bae6a503
Add try_insert for SerdeAnyMap (#3012)
* add

* use hashbrown method

---------

Co-authored-by: toka <toka@tokas-MacBook-Air.local>
2025-02-20 19:27:35 +01:00
EvianZhang
7bf7e4c2dc
Add logics monitors (#3011)
* Add logics monitors

* Re-export logics monitors
2025-02-20 13:43:16 +01:00
Valentin Huber
1eef4ffb58
Introduce ListInput (#2972)
* Introduce ListInput

* Add remove mutators for ListInput

* Merge ListInput and MultipartInput

* Reimplement MultipartInput as a special case of ListInput

* Revert changes to Cargo.toml

* Add collection of generic listinput mutators

* Fix example

* Add note to MIGRATION

* Split list and multi into separate modules

* Fix docs

* Using string names again in the multi example fuzzer

* Remove unnecessary code

* Fix fuzzer

* Use key instead of name for MultipartInput key

* Prettier code in example fuzzer

* Do not convert slice to vec manually
2025-02-20 13:41:53 +01:00
Dongjia "toka" Zhang
98ef505a0e
Add add_metadata_checked method (#3008)
* new api

* found a bug :>
2025-02-19 20:24:15 +01:00
Dongjia "toka" Zhang
9f28672ea1
Fix ReplayStage (#3007) 2025-02-19 18:06:49 +01:00
Dongjia "toka" Zhang
61568a9be1
Restartable trait (#3004)
* separate into Restartable

* typo

* fixes, blanket impl

* aa

* lol

* aa

* fixer

* lol
2025-02-19 15:06:31 +01:00
dae46ea26b enable fallback interrupt randomization 2025-02-19 12:32:01 +01:00
Dongjia "toka" Zhang
0e4c6722f0
Replay stage (#3003)
* replay stage

* seems to be working

* a

* rever

* rev

* rdy for merge

* fmt

* lol
2025-02-18 19:55:02 +01:00
bbf99eca8b profile woets 2025-02-18 16:27:53 +01:00
64d1151e96 dump intermediate cases 2025-02-18 16:25:57 +01:00
Dongjia "toka" Zhang
70eb8158e5
Refactor stages (#3002)
* refactor

* miss

* lol

* revivet tests

* aa

* ?

* a

* fuck

* fuck

* a

* m

* fuck
2025-02-18 14:25:21 +01:00
Romain Malmain
a682c36c84
Fix build for libfuzzer_libpng in ubuntu 24 (#2987)
* fix justfile for ubuntu libpng
2025-02-18 11:58:31 +01:00
Dominik Maier
641db5f19b
Change type generic of ValueInput from I to T (#3001) 2025-02-18 03:07:00 +01:00
107ccf03a8 config updates 2025-02-17 18:35:02 +01:00
WorksButNotTested
f5a01ee20d
Asan guest fix (#2986)
* Check for initialization of libgasan.so on first_exec

---------

Co-authored-by: Your Name <you@example.com>
2025-02-17 17:06:42 +01:00
Dongjia "toka" Zhang
91c46d1a33
Update CONTRIBUTING.md to forbid cyclic dependency (#2999) 2025-02-17 17:00:23 +01:00
Dongjia "toka" Zhang
ae3ea23607
PR Template (#2997) 2025-02-17 16:05:33 +01:00
forky2
a30cce1d88
Fixes #2966 and #2967: Ensure DRCOV unique IDs and max 4GiB ranges. (#2968)
* Fixes #2966 and #2967: Ensure DRCOV unique IDs and max 4GiB ranges.

* Formatter.
2025-02-17 14:51:15 +01:00
Marco C.
47f7978b91
Bump Libipt 0.3, add HW breakpoint support (#2984)
* Decode with callback

* WIP restore intelpt module

* Fix build_target if target_dir doesn't exist

* WIP itelpt qemu/kvm example: bootloader

* qemu config refactoring

* Fix intel_pt_command_executor target dir

* * QEMU error refactoring*
* back to one QEMU init function
* other small things

* update test

* Bump libipt

* waitpid_filtered to ignore SIGWINCH

* Fix warnings unused manifest key: *.version

* Add export_raw feature to libafl_intelpt

* derive Debug for IntelPTHook

* Clippy

* Light refactor of EmulatorModules

* qemu is now a parameter to EmulatorModule callbacks and most function hooks.
* EmulatorModules is initialized before QEMU is initialized.

* Update target program ELF offsets

* fmt

* * asan fixed size accesses working with generics
* continue to propagate qemu argument as hook first parameter
* use pre_syscall* and post_syscall* everywhere
* fix some clippy stuff

* fmt

* Add comment to KVM pt_mode check

* refactor

* Add intel_pt_export_raw feature in libafl

* fix fuzzers

* * refactor asan and asanguest modules to avoid custom init of QEMU and use the module interface instead.
* adapt qemu_launcher example to fully work with emulator, since qemu must now be initialized by emulator.

* fmt

* clippy

* fix qemu_coverage

* fmt

* forgot qemu args in launcher

* map_error instead of unwrap

* use correct args

* Update to new libafl_qemu

* adapt api

* borrow checker friendly join_split_trace

and copy trace before deocde to prevent decoding failures

* testing stuff

* Set ip_filters (also) with builder

* Move trace to file

* Store a pt_builder in module

enable the setting of filters and other pt settings

* baby_bootloader target

* Best bootloader ever

* new builder?

* use closure for qemu config from emulator builder.

* better format

* clippy + fmt

* Fix build target

Create target directory if doesn't exist

* Remove filter on speculatively exec blocks

since also committed blocks can have this flag

* Add current ip_filters getter

* Fix possibile infinite loop in trace decode

* HW breakpoint + snapshot

* add snapshot and exit at first objective

* prefer raw pointers to slice_from_raw_parts_mut

since the latter is highly unsafe and allows more potentially dangerous reordering

* Add cpu option to QEMU config

* Add cpu option and minor improvements

* fix cargo run causing recompile

* no default devices

* windows clippy fix

* Exclude intel_pt feature from CI as all systemmode feats

* Add qemu_intel_pt_bootloader to CI

* Fix NopPageFilter

* Fix qemu_config

* Restore HW breakpoints

* Lints

* return Result for hw bp set/remove

* mark join_split_trace as unsafe

* Put the qcow2 in a tmpfs ramdisk

10x exec/sec

* Post merge fixes

* Try out libipt 0.3 alpha

* Try out libipt 0.3 alpha also in hook

* Clippy

* New libipt

* Post merge fixes

* Bump libipt

* Drive cache None

* Post merge fixes

* Use SectionInfo from libipt

* No slice::from_raw_parts_mut, just use raw pointer

* Cache the decoder builder

* Update qemu-bridge

* Add qemu -append param

* Move linux specific code to a mod, less #[cfg]s

* Add qemu initrd config

* Add qemu monitor tcp

* Add not enough ip filters message

* Fix wrong must_use

* Prevent possible infinite loop in block decoding in debug mode

* Clippy

* fix CI?

* Revert, keep libipt 0.3 and hw bp

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Marco Cavenati <marco@lenovo300e>
2025-02-17 14:50:07 +01:00
Romain Malmain
530a3cc6aa
Better error for libafl_cc when binaries are not found (#2988)
* better error when libafl_cc does not work as expected

* better msg, clippy
2025-02-17 14:47:38 +01:00
dependabot[bot]
d382b8381e
Update errno requirement from 0.2 to 0.3 (#2994)
Updates the requirements on [errno](https://github.com/lambda-fairy/rust-errno) to permit the latest version.
- [Release notes](https://github.com/lambda-fairy/rust-errno/releases)
- [Changelog](https://github.com/lambda-fairy/rust-errno/blob/main/CHANGELOG.md)
- [Commits](https://github.com/lambda-fairy/rust-errno/compare/v0.2.0...v0.3.10)

---
updated-dependencies:
- dependency-name: errno
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-17 13:42:41 +01:00
dimeko
94d6c51363
chore: adds check for riscv64 and riscv32 archs (#2993) 2025-02-17 13:03:09 +01:00
henri2h
9a2a42ccca
Fix libafl_unicorn CI (#2991)
* fix: clippy

* fix: allow specifying thumb mode or not

* fix: timeout for testcase
2025-02-17 10:45:07 +01:00
Dominik Maier
53004f93d6
Improvements for QEMU_Launcher (#2983)
* Improvements for QEMU_Launcher

* fix
2025-02-17 02:45:02 +01:00
Dongjia "toka" Zhang
8b49d81406
Better addr2line (#2989)
* better addr2line

* delete unused

* more

* fixer?

* lol

* class

* mm

* take care of non pie binary or pie binary

* user mode only
2025-02-16 19:18:09 +01:00
henri2h
0aba2c4520
Add support for Unicorn engine (#1054)
* feat: unicorn support

* feat: update

* fix: remove unused files

* fix: clean

* fix: remove undeeded parameters

* fix: typo

* moved to justfile

* use log::debug!

* fix cargo and created justfile

* feat: add CI

* add runs on

* fix: CI

* fix: CI

* fix: don't use fork executor

* not needed anymore

* fix: CI

* fix: CI

* remove extra space
2025-02-15 04:15:16 +01:00
mkravchik
b3fe744e57
Pr/fasan multithreading fixes upstream (#2955)
* Fixing the test_harness library name

* Fasan works, but testing of all features is pending

* Tests pass, before fixing clippy and fmt

* CLippy+fmt

* CLippy+fmt+tests running on linux

* Clippy

* Not stalkering the fuzzer. In the correct way

* Removing the instrumentation upon crash. Proper hooking of UnmapViewOfFile

* Fixes after the merge from the upstream (before 0.15.0). Still need to add the observer, clippy, fmt, and at least linux compilation

* Adding the helper observer and using it in the test

* Removing the observer from the wrong location

* Adapting to the new helper ownership model

* Adding an observer to shut down instrumentation upon crash

* Clippy + fmt

* Using mimalloc everywhere

* Deactivating before activating with the harness. Otherwise, gets stuck on Linux.

* Fixing imports for windows

* Using the new way of passing the handler

* Using frida_helper_shutdown_observer

* Clippy+fmt

* no-std, clippy

* Fmt

* Stable thread_id

* Clippy 18

* More clippy

* Formatting toml

* Fixing apples

* Fixing apples 2

* Fixing apples 3

* Upping to 0.16.7 (necessary for Windows)

* Clippy+fmt

* Enabling the allocator test after the fix and clarifying the importantce of the static runtime linking.

* Moving has_tls to bolts

* Proper handling of no-std, hopefully

* Another attempt to fix win no-std

* Not mine clippy complaint...

* Not mine clippy complaint #2...

* Dlmalloc not used, removing from dependencies

* Restoring target in config.toml (otherwise fails CI on Linux)

* lots of digging around, pray for us

* fixup?

* Revert "lots of digging around, pray for us"

This reverts commit 706c27201918e906e3401cd0d9e76546f889d1f5.

* Revert "fixup?"

This reverts commit 1d7c5d4fb5b1bd31f5e0c07492aa8ed64c6822f3.

* Revert artifact

* Revert fixups

* Removing unused

* Reverting to upstream/main

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-14 13:45:38 +01:00
Dominik Maier
f9715392af
Try to solve corpus issue related to #2981 (#2982)
* Try to solve corpus issue related to #2981

* clippy
2025-02-14 02:07:14 +01:00
Dongjia "toka" Zhang
c53e51584b
Separate addr2line code from asan module (#2980) 2025-02-13 17:56:17 +01:00
7d1e4fd171 plotting + minia fix 2025-02-13 16:38:29 +01:00
Dongjia "toka" Zhang
7202e2a26e
Replace "cargo make" to "just" in md files (#2979)
* justify

* justify
2025-02-13 14:35:38 +01:00
Dongjia "toka" Zhang
b067435862
Align addresses before calling qemu.unmap in Snapshot module (#2978)
* alignment

* a
2025-02-13 14:17:48 +01:00
Romain Malmain
cb471a9282
Move to just (binary_only / full_system) (#2949)
* just port for binary only / systemmode fuzzers

* introduce just libraries, with pre-initialized variables and common recipes

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-13 12:42:38 +01:00
Dongjia "toka" Zhang
99e763ff7d
Fix libafl_targets macros for windows(#2976) 2025-02-13 12:18:04 +01:00
Dongjia "toka" Zhang
33db263260
Fix brk() handling for snapshot module (#2970)
* drop grown address

* this clippy lint literally makes 0 sense!

* i hate you rust

* mm

* don't use drop! add comments for why alignment is not necessary
2025-02-13 11:33:24 +01:00
Dominik Maier
bdcc0c56e4
Remove outdated comment in QEMU_Launcher (#2975) 2025-02-13 02:23:08 +01:00
EvianZhang
f3887697ba
Use expect instead of allow for clippy cast_precision_loss (#2974) 2025-02-13 01:55:05 +01:00
EvianZhang
5281b41abb
Add StatsD monitor (#2969)
* Add StatsD monitor

* Fix

* Use f64 instead of fractal
2025-02-13 01:15:27 +01:00
Dongjia "toka" Zhang
0736c56647
Add getter method to QemuMappingsViewer (#2973) 2025-02-12 18:34:24 +01:00
4d29735354 hash notify value, config fixes 2025-02-12 17:24:16 +01:00
558b464c1a all new benchmark scripts 2025-02-12 17:03:30 +01:00
Dongjia "toka" Zhang
cb3abf27a3
Add a functionality to see the current qemu mappings. (#2971)
* add

* a

* take qemu

* fix for fuzzers
2025-02-12 16:56:36 +01:00
WorksButNotTested
739156cb23
Add SnapshotModule to qemu_launcher (#2887)
* Add SnapshotModule to qemu_launcher

---------

Co-authored-by: Your Name <you@example.com>
2025-02-11 18:42:20 +01:00
WorksButNotTested
4cb4b6df77
Change qemu_cmin to use snapshots (#2939)
* Change qemu_cmin to use snapshots

* Use features to support both fork and snapshot modes

---------

Co-authored-by: Your Name <you@example.com>
2025-02-11 18:36:17 +01:00
Dominik Maier
b7fcfdd192
Change combine_monitors macro to be tuple_list of Monitors (#2963)
* Make Monitors tuple_list

* fix

* no_std

* unused

* more
2025-02-11 02:40:53 +01:00
Dominik Maier
c62c6a7ecc
Move statistics to monitors/stats (#2962)
* Move statistics back to monitors/stats

* More fun

* more stats

* more
2025-02-11 01:07:17 +01:00
dependabot[bot]
e5ae6c361f
Update strum requirement from 0.26.3 to 0.27.0 (#2959)
Updates the requirements on [strum](https://github.com/Peternator7/strum) to permit the latest version.
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/compare/v0.26.3...v0.27.0)

---
updated-dependencies:
- dependency-name: strum
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-10 21:22:43 +01:00
dependabot[bot]
a682deb31a
Update color-backtrace requirement from 0.6.1 to 0.7.0 (#2960)
Updates the requirements on [color-backtrace](https://github.com/athre0z/color-backtrace) to permit the latest version.
- [Changelog](https://github.com/athre0z/color-backtrace/blob/master/CHANGELOG.md)
- [Commits](https://github.com/athre0z/color-backtrace/compare/v0.6.1...v0.7.0)

---
updated-dependencies:
- dependency-name: color-backtrace
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-10 18:43:42 +01:00
dependabot[bot]
5ebb3913d8
Update strum_macros requirement from 0.26.4 to 0.27.0 (#2961)
---
updated-dependencies:
- dependency-name: strum_macros
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-10 18:24:42 +01:00
EvianZhang
800b8b417d
Add global stats cache (#2956)
* Add global stats cache

* Fix

* Make clippy happy

* Merge manager files; Implement default for GlobalStats

* fmt code

* Use &Cow to avoid unnecessary clone

* Avoid push_str without cleanup
2025-02-10 16:11:36 +01:00
Dongjia "toka" Zhang
404227d1a3
Don't panic inside sig handler (#2958)
* fix_handler

* hello

* fmt

---------

Co-authored-by: Your Name <you@example.com>
2025-02-10 10:56:07 +01:00
Dongjia "toka" Zhang
2c741c8f38
Move to Just (#2952)
* move to just

* fuzzbench

* shell check

* version

* rme

* fixer

* fixing

* libpng friends

* pwd

* ps

* ps

* no fail fast.. for now

* windows

* l

* no powershell

* a

* fk

* fixer

* a

* Revert "fixer"

This reverts commit 76ae72d68686ead01ef914b658c5d8dac5aaee32.

* plzplz

* aaaa

* aa

* aa

* use absolute path, use LIBAFL_CC and LIBAFL_CXX

* why tabs????

* this job is not fun

* aa

* tmate debug

* disable cacheing

* del

* deldelg

* rename

* aaaa

* lol

* aaa

* lol

* lol

* 2nd tmate ...

* a

* lol

* lll

* shell ck

* please i'm about to cry

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-02-09 18:44:50 +01:00
Dongjia "toka" Zhang
89e470250f
Properly use in_handler (#2957)
* properly use it

* a

* a

* typo
2025-02-09 15:08:09 +01:00
Addison Crump
83d88546d3
Better type_eq (#2946)
* typeid that doesn't suck

* actually, that's not const!

* format, move phantomdata to alloc feature block

* a

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-08 14:12:12 +01:00
EvianZhang
abe955137f
Remove base-pattern for Monitor (#2953)
* Remove base-pattern for Monitor

* Fix runtime parameter for log_record

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-08 14:08:00 +01:00
EvianZhang
075fb0daa2
Fix clippy (#2954) 2025-02-08 13:10:55 +01:00
EvianZhang
ce01f4a427
Move start_time to ClientStatsManager (#2948)
* Move start_time to ClientStatsManager

* Remove unnessary &self

* Make clippy happy

* Make clippy happy
2025-02-07 16:39:39 +01:00
Dongjia "toka" Zhang
c03dfd9daf
Revert "Move to just (#2924)" (#2951)
This reverts commit 00582d849478ed4c2cd5ba5c7c9f46359555bd08.
2025-02-07 15:29:02 +01:00
Celian G.
64554d68bb
Small improvements for Qemu (#2938)
* Remove uneeded Executor trait from handlers functions + set inproc_qemu_crash_handler to pub

* Add some documentation for QemuHooks

---------

Co-authored-by: celian <cglenaz>
2025-02-07 13:28:11 +01:00
809f3b0d6a config changes 2025-02-07 12:43:42 +01:00
Dongjia "toka" Zhang
00582d8494
Move to just (#2924)
* move to just

* fuzzbench

* shell check

* version

* rme

* fixer

* fixing

* libpng friends

* pwd

* ps

* ps

* no fail fast.. for now

* windows

* l

* no powershell

* a

* fk

* fixer

* a

* Revert "fixer"

This reverts commit 76ae72d68686ead01ef914b658c5d8dac5aaee32.

* plzplz

---------

Co-authored-by: Your Name <you@example.com>
2025-02-07 11:26:33 +01:00
EvianZhang
45205d4dc6
Update MIGRATION (#2947) 2025-02-07 09:40:32 +01:00
EvianZhang
ab50afe8e4
Add statistics. Move client stats from Monitor to EventManager (#2940)
* Add statistics entity. Move client stats from Monitor to EventManager

* Fix warning in no_std

* Make rustfmt happy

* Fix more

* Fix with feature tcp_manager on

* Rename more introspection monitor; Remove unnecessary client_stats

* Fix unused import for no_std

* Fix unused import for prometheus_monitor feature on

* Cleanup docs
2025-02-06 16:58:24 +01:00
dependabot[bot]
0573bbb159
Update capstone requirement from 0.12.0 to 0.13.0 (#2930)
Updates the requirements on [capstone](https://github.com/capstone-rust/capstone-rs) to permit the latest version.
- [Release notes](https://github.com/capstone-rust/capstone-rs/releases)
- [Changelog](https://github.com/capstone-rust/capstone-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/capstone-rust/capstone-rs/compare/capstone-v0.12.0...capstone-v0.13.0)

---
updated-dependencies:
- dependency-name: capstone
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-05 15:25:57 +01:00
fourdim
7b5b7d9ae4
Fix the python binding configuration (#2937) 2025-02-05 15:18:16 +01:00
Dongjia "toka" Zhang
c09feeba4e
Don't write pointers to the crash handlers at every execution (#2935)
* make it safe

* aa

* forgot to put it back

* stateful

* comment

* lol

* aa

* aa

* aa

* win

* lol

* lol

* a

* a

* i hate rust

---------

Co-authored-by: Your Name <you@example.com>
2025-02-05 14:00:09 +01:00
Romain Malmain
8398f8f99a
Qemu signal refactoring (#2920)
* qemu signal refactoring

* udpate qemu

* clippy, moving things around

* update bindings

* nostd

* cfg

* fmt

* nostd

* clippy

* fmt

* aaa

* windowsssssss

* systemmode

* reimport fix

* remove llmp from replay mode

* lol

* fixer

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-04 14:43:26 +01:00
Dongjia "toka" Zhang
defb475d28
Fix EdgeCoverageModuleBuilder (#2931) 2025-02-04 14:34:11 +01:00
EvianZhang
a27da1b8be
Change Monitor API for more flexibility (#2927)
* Change Monitor API for more flexibility

* Make clippy happy

* Fix broken doc link
2025-02-04 13:45:28 +01:00
Dhanvith Nayak
72986fc129
Deduplicate OnDisk Corpus (#2827)
* testcase name logic

* implement locking

* implement logic for removing testcase

* minor modifications

* minor modifications to remove_testcase()

* extract generate_name() from trait Input (broken)

* Revert "extract generate_name() from trait Input (broken)"

This reverts commit 9e217be2810a8c33970846cdd380f542975cc05b.

* fix ci errors

* remove CorpusId from generate_name() calls

* toml formatting

* write from file instead of fs

* fmt and clippy

* fix windows clippy

* handle renaming of testcase

* fix failing cmplog test

* overwrite lockfile on remove testcase

* format

* bring back corpus id in generate_name

* missed windows executors hook

* fix failing tests

* some more errors

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-02-04 07:41:00 +01:00
Dominik Maier
5bd6a6f754
Revert "QASan: remove chunk_struct (#2899)" (#2928)
This reverts commit ba0da5121b54c89d5ad3c06189959afbbeb64d23.
2025-02-03 14:47:13 +01:00
Valentin Huber
500e01816d
Rename BoolMutator to BoolInvertMutator (#2929)
* Rename BoolMutator to BoolInvertMutator

* Fix name of BoolInvertMutator
2025-02-03 13:33:39 +01:00
Valentin Huber
6243b684f8
Introduce BoolMutator (#2926) 2025-02-01 21:24:24 +01:00
Dongjia "toka" Zhang
6648bc90d2
Collect envs in AsanModuleBuilder::default() (#2921)
* collect envs in AsanModuleBuilder::default

* migration

* fmt
2025-02-01 09:57:29 +01:00
Dominik Maier
84702d12a8
Make sure EM and Z remain consistent in InProcessExecutor (#2873)
* Make sure EM and Z remain consistent in InProcessExecutor

* first make them compile

* a

* hah

* fix intel pt

* decouple fuzzer from em

* lol

* 3

* fix tcp

* fix

* fix

* fix

* fixer

* std

* fixer

* plz

* plzplzplz

* plzplzplzplz

* mm

* more

* symbol

* a

* a

* mm

* mmm

* mmmm

* mmmmm

* ff

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-02-01 08:23:40 +01:00
Dongjia "toka" Zhang
6cd97e7105
Decouple fuzzer functions from event manager (#2915)
* decouple fuzzer from em

* lol

* 3

* fix tcp

* fix

* fix

* fix

* fixer

* std

* fixer

* plz

* plzplzplz

* plzplzplzplz

* mm

* more

* symbol

* a

* a

* mm

* mmm

* mmmm

* mmmmm

* ff
2025-02-01 07:52:42 +01:00
Dongjia "toka" Zhang
ace2a76ece
Update rand_core (#2919)
* a

* upd lain
2025-01-31 19:26:32 +01:00
Romain Malmain
75feedd1a0
Add builder and tests for QASAN (#2898)
* Add tests for QASAN from aflplusplus

* refactor asan module to use the builder pattern

* move injection tests to the new tests directory
2025-01-31 15:43:50 +01:00
Dongjia "toka" Zhang
37fc43f53c
0.15.1 (#2917)
* 0.16.0

* 0.15.1
2025-01-30 18:53:00 +01:00
Dongjia "toka" Zhang
5c248d7da3
Add license file symlinks (#2916)
* license

* more

* incl

* FMT
2025-01-30 18:03:52 +01:00
Railroad6230
85c1d03425
Rename libafl_bolts::rands::Rand::zero_upto to below_or_zero. (#2911)
Hi LibAFL!

I was playing with the [`Rand`] trait when I realized that the
documentation of [`Rand::zero_upto`] did not match what I was expected:

fd6271fa35/libafl_bolts/src/rands/mod.rs (L139-L142)

When using the following RNGs, [`Rand::zero_upto`] never returns the upper bound `n` as it would have been expected according to the documentation:

 - `RomuDuoJrRand`
 - `RomuTrioRand`
 - `Sfc64Rand`
 - `XkcdRand`
 - `XorShift64Rand`
 - `Xoshiro256PlusPlusRand`

The default implementation of [`Rand::zero_upto`] is to use [`fast_bound_usize`],
which excludes the given upper bound, thus I believe here that the default implementation
of [`Rand::zero_upto`] is wrong.

As discussed here: https://github.com/AFLplusplus/LibAFL/pull/2911#issuecomment-2623773829,
we believe that renaming the method would be better than changing the actual
implementation.

[`Rand`]: fd6271fa35/libafl_bolts/src/rands/mod.rs (L108)
[`Rand::zero_upto`]: fd6271fa35/libafl_bolts/src/rands/mod.rs (L139-L142)
[`fast_bound_usize`]: fd6271fa35/libafl_bolts/src/rands/mod.rs (L100-L103)
2025-01-30 14:16:23 +01:00
Railroad6230
5c5f6affcb
Fix Lehmer64 implementation of next. (#2912)
The implementation of [`Lehmer64Rand::next`] performs a mul on `u128`, which
is not checked against overflows. It leads to panic in debug mode.


[`Lehmer64Rand`]: fd6271fa35/libafl_bolts/src/rands/mod.rs (L373-L376)

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-01-30 12:26:46 +01:00
Dongjia "toka" Zhang
d8df9b4910
Fix Clippy (#2913)
* clp

* lol

* this is false positive

* a

* clippy all

* aa
2025-01-30 11:17:01 +01:00
149dd4b36a copter 20ms minar 2025-01-29 16:55:29 +01:00
Dongjia "toka" Zhang
fd6271fa35
Delete useless trait bounds from share_objectives feature (#2908)
* fix

* a
2025-01-29 13:55:38 +01:00
Dongjia "toka" Zhang
5002336fad
Delete evaluate_input_events (#2906) 2025-01-28 19:06:43 +01:00
Dongjia "toka" Zhang
2ec534a39c
Make drcov_dump_address.rs accept list of directories (#2904)
* accept folders

* lol

* use walkdir instead of my impl
2025-01-28 19:06:27 +01:00
Dongjia "toka" Zhang
6b965816cd
tips (#2903) 2025-01-28 17:06:41 +01:00
Dongjia "toka" Zhang
bb4b1f1b33
LLVM 20 update (#2902)
* LLVM 20

* clang format
2025-01-28 14:41:13 +01:00
EvianZhang
f30b05419b
Add combined monitor (#2900)
* Add combined monitor

* Sync start_time when initializing

* Use clone_from instead of clone to make clippy happy
2025-01-28 12:13:41 +01:00
s1341
7c84a7903a
Frida updates and FASAN fixes (#2838)
* Frida updates and FASAN fixes

* fmt

* Fixes

* clippy

* fmt

* Clippy

* Update to frida 0.16.2

* fix windows hooks

* Fix

* Fmt

* windows fix

* Bump frida version to 0.16.3

* Get rid of call to LLVMFuzzerInitialize

* bump version 0.16.5; use find_global_export_by_name

* allow unused_macro_rules

* Don't do stdout_file on windows

* fmt

* Add tmate to debug

* fix windows frida_libpng

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-01-28 11:48:52 +02:00
Romain Malmain
ba0da5121b
QASan: remove chunk_struct (#2899) 2025-01-28 01:46:09 +01:00
Romain Malmain
b320a8dbab
Add PC to QEMU's read / write callbacks + logger module (#2896)
* Logger module (only read/write for now)

* add pc to rw callbacks

* regen bindings
2025-01-27 15:01:20 +01:00
f7e61665be refactoring 2025-01-27 13:56:43 +01:00
Dongjia "toka" Zhang
133a0ffe7a
Merge LlmpEventManager and LlmpRestartingEventManager (#2891)
* add

* add 2

* feature

* fix nyx launcher

* a bit of doc

* addressing comments
2025-01-26 13:43:04 +01:00
Romain Malmain
1addbd04b9
Expose qemu's image_info for qemu usermode (#2889)
* image info for qemu usermode

* must use

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2025-01-24 20:05:38 +01:00
Romain Malmain
4083f0ba73
Fix drcov path parsing (#2884)
* fix drcov path parsing

* refactoring of drcov tool

* add the possibility to sort addresses in drcov tools

* more aggressive clippy. it now catches more warnings as errors than before

* reduce the number of unfixable warnings displayed.
2025-01-24 18:21:51 +01:00
WorksButNotTested
c5b7c7c235
Add SnapshotModule to qemu_coverage tool (#2885)
Co-authored-by: Your Name <you@example.com>
2025-01-23 11:23:37 +01:00
Romain Malmain
e84429012b
Add a qemu_coverage test in ci (#2883)
* add a qemu_coverage test in ci

* update CI path for changes in qemu-related code
2025-01-22 16:59:46 +01:00
Romain Malmain
2cc2298e98
Fix qemu_coverage v2 (#2882) 2025-01-22 16:00:20 +01:00
Romain Malmain
d9e8b59cb6
Fix qemu cov (#2875)
* fix drcov module hooks setup
2025-01-22 14:05:25 +01:00
Dongjia "toka" Zhang
2842f95e2a
Dedup StdOut/StdErr observer pt.2 (#2876)
* dedup stdout stdin

* mm

* Claude was not enough

* but was good enough

* ok

* okok

* okokok

* shorter now

* lol

* fixer
2025-01-21 16:53:02 +01:00
Dongjia "toka" Zhang
6eabb79920
Dedup stdout/stdin observer (#2871)
* dedup stdout stdin

* mm

* Claude was not enough

* but was good enough

* ok

* okok

* okokok

* shorter now
2025-01-21 15:17:07 +01:00
Dominik Maier
7e18887a32
Remove shmem associated type (#2870)
* reduce shm trait bound

* Rename to SendExiting

* alpha beta gamam

* alphabet

* work

* std only

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-01-20 20:28:19 +01:00
Dongjia "toka" Zhang
72adb483b5
0.15.0 (#2848)
* libafl pre-release edition

* oops

* aaa
2025-01-20 17:44:55 +01:00
Dongjia "toka" Zhang
6ee26a8afa
Decouple address_filters() from EmulatorModuleTuple into HasAddressFilters (#2869)
* 1

* fixe
2025-01-20 17:44:44 +01:00
Romain Malmain
8089b18d34
Remove ShMemProvider bound from struct definitions (#2861)
* No more ShMemProvider bound constraint in struct definition whenever possible

* Introduce StdShMem

* Update CONTRIBUTING.md
2025-01-20 17:25:55 +01:00
WorksButNotTested
348bfdc7d7
Add support for env_logger for qemu binary only fuzzers (#2817)
Co-authored-by: Your Name <you@example.com>
2025-01-20 09:46:47 +00:00
h1k0
9a64a53d12
Qemu launcher bugfix (#2858)
* Fixed the issue where compilation failed under the simplemgr configuration.

* Fixed the issue where the crash handler would fail during rerun.

* update fmt

---------

Co-authored-by: h1k0 <h1k0naka@outlook.com>
2025-01-20 00:01:01 +00:00
Dominik Maier
a949452453
Rename ResizableMutator, make it generic (#2859)
* Rename ResizableMutator, make it generic

* fix

* more fix

* reorer

* fmt, fixes

* fixes

* more commit

* fmt
2025-01-19 17:17:50 +00:00
Dhanvith Nayak
2a36b78fd6
Share objectives between nodes (#2754)
* add support to share new objectives in CentralizedEventManager

* handle received Objectives

* remove duplicate event fires in centralized event manager

* share input on share_objectives feature (broken)

* split impl LlmpEventManager based on share_objectives

* reduce code duplication in impl LlmpEventManager (broken)

* fix traits error (temp)

* fix mismatched types

* fix cargo format issue

* merge duplicated functions into single impl in llmp/mod.rs

* merge duplicate impl blocks in stages/sync.rs

* fix clippy warnings

* deduplicate handle_in_client

* cleanup unnecessary code

* handle objectives in tcp eventmanager

* handle objectives in llmp eventmanager (broken)

* handle objectives in llmp eventmanager

* fix doc test

* format

* clippy

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-01-19 17:00:24 +01:00
Dominik Maier
f2eefeb52a
Fix libafl-jumper for powerpc (#2866) 2025-01-19 13:15:48 +00:00
Dominik Maier
51d371acba
Revert "Set rust-analyzer.cargo.allTargets to False in setings.json.default (…" (#2867)
This reverts commit da854587d719fb0ece6c966afbb7a4bc5677cd11.
2025-01-19 13:57:32 +01:00
Dongjia "toka" Zhang
2afa947652
Fix CI (#2865)
* chg

* ci
2025-01-18 16:36:20 +01:00
Dongjia "toka" Zhang
da854587d7
Set rust-analyzer.cargo.allTargets to False in setings.json.default (#2864) 2025-01-18 13:32:57 +01:00
Konstantin Bücheler
faeed19c43
Add NyxCmpObserver and nyx_launcher example fuzzer (#2826)
* Add NyxCmpObserver to libafl_nyx

* Add nyx_launcher example fuzzer

* Cargo Format/Clippy

* Adapt to naming scheme

* Taplo fmt

* Add hex decode function to remove hex dependency

* Add nyx_launcher to CI

* Remove UsesState

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-01-18 13:21:04 +01:00
Dongjia "toka" Zhang
2e26af90db
Better error message in testcase_score.rs pt.2 (#2863)
* msg

* l
2025-01-18 13:07:14 +01:00
Dongjia "toka" Zhang
019c71a368
Better error for missing TopRatedsMetadata (#2860) 2025-01-17 21:42:51 +01:00
Romain Malmain
f8ad61e14a
Remove Input associated type (#2854)
* Completely remove Input as an associated type in multiple traits

* Unify usage of Input as generic instead 

* Remove many unused bounds, in particular HasCorpus

* fix multiple generic ordering

* update and fix CONTRIBUTING.md

* update MIGRATION

* use the same generic input type for new / with_max_iterations to make typing easier in most cases.

* Restore libafl_libfuzzer test in CI
2025-01-17 14:53:51 +01:00
h1k0
d4add04f87
Add comments for EmulatorModule trait (#2842)
* Add comments for EmulatorModule trait

---------

Co-authored-by: h1k0 <h1k0naka@outlook.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2025-01-16 17:49:22 +01:00
Valentin Huber
93c5adde4d
Remove MapObserver dependency from observer-dependent stages and schedulers in favour of generic hashing (#2851)
* Introdue SimpleHash separate from MapObserver

* Move to Hash for hashing

* Fix docs, remove even more restrictions

* fix libafl_targets

* fix fuzzer

* Remove broken and unnecessary derive

* Remove unnecessary trait restriction

* Remove unnecessary import

* Add changes to MIGRATION.md

* Remove more unnecessary imports
2025-01-16 16:34:58 +00:00
Railroad6230
15aa498d5e
Fix #2853: split HasMutatorBytes trait into two traits. (#2856)
(See #2853.)

This commit attempts to improve the [`HasMutatorBytes`] trait to allow it to
be used along with input types that cannot be resizable.

[`HasMutatorBytes`] is split into two traits:

 - [`HasMutatorBytes`]: requires `bytes` and `bytes_mut`.
 - `HasMutatorResizableBytes`: requires [`HasMutatorBytes`], and also requires
   a few other methods for resizing / shrinking the underlying input type.


N.B.: I believe that if merged, this would introduce a breaking change.

[`HasMutatorBytes`]: 198cd5dbc5/libafl/src/inputs/bytes.rs (L26)
2025-01-16 17:06:19 +01:00
Valentin Huber
198cd5dbc5
Fix formatting in MIGARTION.md (#2855) 2025-01-16 14:16:47 +01:00
bernhl
c9531aa242
Remove unecessary HasTargetBytes constraint (#2852) 2025-01-16 10:51:18 +01:00
Dongjia "toka" Zhang
cfe051e5d9
Remove UsesState from libafl-fuzz (#2849) 2025-01-15 20:18:24 +01:00
Dongjia "toka" Zhang
9fd5af76c3
Highlight contributing.md (#2850) 2025-01-15 19:08:30 +01:00
Dongjia "toka" Zhang
435ca021cc
No uses for EventManager (#2831)
* the first step of the last step

* wip

* 99% done

* 99.9% done

* 99.99

* Hello from windows

* aaa

* 99.999

* aa

* 1

* 2

* 3

* 4

* 5

* plz

* plzplzplz

---------

Co-authored-by: Your Name <you@example.com>
2025-01-15 16:56:40 +01:00
Valentin Huber
ba09cb0706
Add OnDiskJsonAggregateMonitor (#2845)
* Add OnDiskJsonAggregateMonitor

* Fix formatting

* Remove unnecessary trait bounds

* Remove unnecessary import restriction

* Remove unnecessary imports

* fix formatting
2025-01-15 13:40:26 +01:00
Dongjia "toka" Zhang
dc39aadb05
Revert "Don't fail fast for now" (#2844)
* Revert "Don't fail fast for now (#2843)"

This reverts commit 332ddf46554336eeb538a42accbc7c0a11b03f0f.

* aa
2025-01-15 11:26:41 +01:00
Dongjia "toka" Zhang
332ddf4655
Don't fail fast for now (#2843) 2025-01-15 10:40:40 +01:00
Sharad Khanna
00c6970d24
Fix libafl_targets cmplog linking (#2840) 2025-01-14 21:04:44 +01:00
Dongjia "toka" Zhang
cd19a72d03
Put debugging.md for better visibility (#2839) 2025-01-14 17:37:55 +00:00
jejuisland87654
a844e5e07d
Remove unecessary default features for sub crates using LibAFL (#2836)
* remove unecessary default features

* fix format
2025-01-14 16:11:43 +00:00
Romain Malmain
a45e44764f
Remove UsesInput from libafl qemu (#2832)
* remove UsesInput from libafl_qemu

* Insert I bound instead of ugly Corpus::Input stuff

* Uses a C generic for Commands

* adapt nyx api to new generics

* add qemu linux fuzzers to CI for building.
2025-01-14 10:24:28 +01:00
s1341
8adb2aa7b5
libafl_ar: fix error message (#2833) 2025-01-14 10:34:52 +02:00
Romain Malmain
d8460d14a2
More Nyx hypercalls supported in libafl qemu. add tests for filters. (#2825)
* more nyx hypercalls implemented, among them:
- panic hypercall
- range filtering hypercall

* fixed some nyx hypercalls behavior.

* added generic read / write to qemu memory

* port linux kernel example to also have nyx API, add better filtering as well.

* make nyx api structs volatile to avoid optimization issues

* Introduce a method create a Vec in place, using a closure.

* use new vec_init function in relevant places.

* removed unused unsafe keywork

* add more allocated memory r/w callbacks

* add more safety notes

* move emulator hooks to separate struct

* update QEMU version
2025-01-13 17:32:23 +01:00
Dominik Maier
02566b33cd
Make Stats stage send stats again (#2830)
* Make Stats stage send stats again

* re-remove stats mod

* clp, fmt

* clip
2025-01-13 15:06:26 +00:00
Dongjia "toka" Zhang
fd06e5ced0
Remove CustomBufHandlers (#2829)
* rem

* fix

* fixer
2025-01-13 16:00:41 +01:00
Dongjia "toka" Zhang
aa0391ef8d
No Uses* from executor (#2766)
* first step

* wip

* lol

* making progress, slowly

* add

* a bit more

* progress

* 80%done

* 90% done

* done from linux

* Hello from windows

* 1

* 2

* 3

* 4

* 5

* 6

* 7

* Hello from windows

* 9

* 10

* 11

* 11

* 12

* 13

* aa

* fixer

* a

* oops

---------

Co-authored-by: Your Name <you@example.com>
2025-01-11 15:25:15 +01:00
Marco C.
ca647f0c30
CI check-md-links fix (#2824)
Use ubuntu-22.04 and restore the action instead of the script
2025-01-09 12:04:01 +01:00
cube0x8
1a9e25145d
Fix snapshot reset function when brk shrunk below the snapshotted value (#2812)
* added change_brk function for correctly handling SYS_brk

* we need to update h.brk with the new brk_val

* map back pages if brk shrunk below the snapshotted value

* fmt and clippy

* use GuestAddr instead of u64

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2025-01-09 00:30:39 +01:00
Dominik Maier
f7745155c9
Upgrade all Windows crates (#2823)
* Upgrade all win crates

* wtf

* fix
2025-01-09 00:25:33 +01:00
dependabot[bot]
fbd76721a1
Update prometheus-client requirement from 0.22.3 to 0.23.0 (#2819)
Updates the requirements on [prometheus-client](https://github.com/prometheus/client_rust) to permit the latest version.
- [Release notes](https://github.com/prometheus/client_rust/releases)
- [Changelog](https://github.com/prometheus/client_rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_rust/compare/v0.22.3...v0.23.0)

---
updated-dependencies:
- dependency-name: prometheus-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-08 13:42:46 +01:00
dependabot[bot]
e44c23b71c
Update windows-result requirement from 0.2.0 to 0.3.0 (#2822)
---
updated-dependencies:
- dependency-name: windows-result
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-08 13:42:25 +01:00
Valentin Huber
9b8b552f27
Make more int mutator types public (#2821) 2025-01-07 17:02:13 +01:00
Dominik Maier
719a3c0f07
Continue loading inputs even if some fail to deserialize (#2820)
* Continue loading inputs even if some fail to deserialize

* fmt

* fix
2025-01-07 15:07:46 +01:00
Romain Malmain
9f8f47233c
Add migration notes for libafl qemu's Emulator configuration changes (#2818)
* add migration notes for libafl qemu latest changes
2025-01-06 17:34:45 +01:00
Romain Malmain
17336dcf57
Nyx hypercall API support for LibAFL QEMU (#2801)
* Nyx hypercall API support

* fix linux kernel fuzzer

* hash_me -> hash_64_fast

* fix multiple bug in kernel harness

* do not check libmozjpeg's C files format.
2025-01-06 16:58:57 +01:00
cc2a2e6422 fix edge fuzzing 2025-01-06 15:52:48 +01:00
Romain Malmain
7c8708d4b1
Refactor of Qemu configuration (#2707)
* Qemu config refactoring.

* QEMU error refactoring.

* Single QEMU init function.

* Light refactor of EmulatorModules.

* Qemu is now a parameter to EmulatorModule callbacks and most function hooks.

* EmulatorModules is initialized before QEMU is initialized.

* refactor asan and asanguest modules to avoid custom init of QEMU and use the module interface instead.

* asan fixed size accesses working with generics.

* use pre_syscall_* and post_syscall_* everywhere for consistency.

* adapt qemu_launcher example to fully work with Emulator, since Qemu must now be initialized by Emulator.

* start writing Emulator / EmulatorBuilder / QemuConfig doc.

* fix broken intel pt doc.
2025-01-06 15:04:40 +01:00
WorksButNotTested
5a3cbc18a7
Changes to use InMemoryCorpus (#2816)
Co-authored-by: Your Name <you@example.com>
2025-01-06 11:22:08 +01:00
Dominik Maier
742773bc17
Add BoolValueFeedback (#2815)
* Add BoolValueFeedback

* No_std

* clippy

* Fix tests

* More clip

* fix no_std tests
2025-01-06 04:25:36 +01:00
Dominik Maier
4b4a22bc44
Cargo Format (#2814)
* Initial commit: ValueBloomFeedback

* Add test, fix feedback

* Remove unneeded feedback

* fix

* more commit

* Cargo fmt

* fmt
2025-01-06 02:11:47 +01:00
Dominik Maier
2a3f5a5942
Add Bloomfilter-based Feedback for Values (#2813)
* Initial commit: ValueBloomFeedback

* Add test, fix feedback

* Remove unneeded feedback

* fix

* more commit
2025-01-06 02:03:18 +01:00
Dominik Maier
6e921cf870
More clippy (#2811)
* More clippy

* clip
2025-01-05 15:56:27 +01:00
Dominik Maier
b3b216386e
Another clippy bugfix (#2806) 2025-01-03 16:05:02 +01:00
WorksButNotTested
da55e70aa3
qemu_launcher: Fix command line parsing of ranges (#2804)
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-01-03 16:04:41 +01:00
Dominik Maier
d39ded5b29
Fix and/or mute more clippy lints, deprecation warnings in Pyo3 (#2805) 2025-01-03 15:17:46 +01:00
jejuisland87654
7543a54d0d
Add dynamic frida runtime list called FridaRuntimeVec (#2799)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2025-01-02 16:33:47 +01:00
henri2h
187e06cb11
Specify that InProcessForkExecutor should abort on panic (#2803)
* Revert "New year new clippy (#2797)"

This reverts commit deb76555b75ca2ccac83b83a6db1a276c07080b5.

* Mention that program should panic when using InProcessForkExecutor

* Reapply "New year new clippy (#2797)"

This reverts commit 529213ef6334fc18e1898f3cfbd8bed24c312522.
2025-01-02 23:57:57 +09:00
Dominik Maier
deb76555b7
New year new clippy (#2797)
* New year new clippy

* More clipy

* fix
2025-01-01 20:57:43 +01:00
AshrafIbrahim03
92db678995
Added expect error message to TimeFeedback where there used to be an unwrap (#2777)
* Added expect error message to TimeFeedback where there used to be an unwrap

* Changed error message handling

* fixed cargo clippy

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-12-30 20:47:04 +01:00
Mehtab Zafar
8cd069cf3e
Optimize event serialization with pre-allocated buffer (#2794)
* Optimize event serialization with pre-allocated buffer

- Added event_buffer field to LlmpEventManager
- Used to_slice instead of to_allocvec
- Pre-allocated buffer size is 4KB

Fixes #1082

* Fallback to to_allocvec in case of event_buffer overflow

Also combined the shared logic between compressed & uncompressed event
firing while keeping the same behavior

* Made the initial event_buffer size to a const

Also removed the unnecessary event_buffer.clear(), since we are already
resizing it
2024-12-30 20:45:48 +01:00
David CARLIER
930951827f
bolts limit ashmem concept to Linux/Android only. (#2795) 2024-12-30 16:02:52 +01:00
Valentin Huber
d8ec991b48
Add bloom filter for duplicate execution of the same inputs (#2771)
* fixing empty multipart name

* fixing clippy

* New rules for the contributing (#2752)

* Rules

* more

* aa

* Improve Flexibility of DumpToDiskStage (#2753)

* fixing empty multipart name

* fixing clippy

* improve flexibility of DumpToDiskStage

* adding note to MIGRATION.md

* Update bindgen requirement from 0.70.1 to 0.71.1 (#2756)

Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.70.1...v0.71.1)

---
updated-dependencies:
- dependency-name: bindgen
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* No Use* from stages (#2745)

* no from stage

* fixer

* doc fix

* how was this working????

* more fixes

* delete more

* rq

* cargo-fuzz

* m

* aa

* Update CONTRIBUTING.md MIGRATION.md (#2762)

* No Uses* from `fuzzer` (#2761)

* go

* fixing stuf

* hello from windows

* more

* lolg

* lolf

* fix

* a

---------

Co-authored-by: Your Name <you@example.com>

* Remove useless cfgs (#2764)

* Link libresolv on all Apple OSs (#2767)

* Somewhat ugly CI fix... (#2768)

* Maybe fix CI

* does this help?

* Very dirty 'fix'

* Add Input Types and Mutators for Numeric Types (#2760)

* fixing empty multipart name

* fixing clippy

* New rules for the contributing (#2752)

* Rules

* more

* aa

* Improve Flexibility of DumpToDiskStage (#2753)

* fixing empty multipart name

* fixing clippy

* improve flexibility of DumpToDiskStage

* adding note to MIGRATION.md

* Introduce WrappingMutator

* introducing mutators for int types

* fixing no_std

* random fixes

* Add hash derivation for WrappingInput

* Revert fixes that broke things

* Derive Default on WrappingInput

* Add unit tests

* Fixes according to code review

* introduce mappable ValueInputs

* remove unnecessary comments

* Elide more lifetimes

* remove dead code

* simplify hashing

* improve docs

* improve randomization

* rename method to align with standard library

* add typedefs for int types for ValueMutRefInput

* rename test

* add safety notice to trait function

* improve randomize performance for i128/u128

* rename macro

* improve comment

* actually check return values in test

* make 128 bit int randomize even more efficient

* shifting signed values

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>

* Add HashMutator

* Fix docs

* Fix docs again

* introducing bloom filter

* fix tests

* Implement evaluate_filtered

* Add macros to libafl_bolts tuples for mapping and merging types (#2788)

* Add macros

* Use the macros for havoc_mutations

* Fix docs

* improve merge_tuple_list_type to accept n items

* libafl_cc: Automatically find llvm_ar path (#2790)

* imemory_ondisk: Don't fail write under any circumstances if locking is disabled (#2791)

* imemory_ondisk: Don't fail write under any circumstances if locking is disabled

* fmt

* inmemory_ondisk: Add a log message on failure

* clippy'

* micro optimization

* Revert changes to global Cargo.toml

* Hide std-dependent dependency behind std feature

* Fix example fuzzer

* Rename constructor for filtered fuzzer

* Reorder generics alphabetically

* Rename HashingMutator, add note to MutationResult about filtered fuzzers

* Improve StdFuzzer according to feedback

* rename hashing mutator

* Fix english in comment

* Cleanup of old PRs that break the CI

* Fix more CI bugs

* Code cleanup

* Remove unnecessary comments

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Sharad Khanna <sharad@mineo333.dev>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: s1341 <s1341@users.noreply.github.com>
2024-12-28 15:22:31 +01:00
s1341
2a79ee5b4f
frida: Deduplicate with IfElseRuntime (#2792)
* frida: Deduplicate with IfElseRuntime

* clippy'

* get rid of cfg

* fmt

* documentation

* fix lint

* fix lint

* debug: add tmate

* debug: add tmate

* frida_windows_gdiplus: move to mimalloc on windows

* remove tmate
2024-12-25 14:42:54 +02:00
s1341
9b4cd51c63
imemory_ondisk: Don't fail write under any circumstances if locking is disabled (#2791)
* imemory_ondisk: Don't fail write under any circumstances if locking is disabled

* fmt

* inmemory_ondisk: Add a log message on failure

* clippy'

* micro optimization
2024-12-24 14:22:01 +01:00
s1341
6927d61a89
libafl_cc: Automatically find llvm_ar path (#2790) 2024-12-24 11:00:44 +02:00
Valentin Huber
54202c3ef3
Add macros to libafl_bolts tuples for mapping and merging types (#2788)
* Add macros

* Use the macros for havoc_mutations

* Fix docs

* improve merge_tuple_list_type to accept n items
2024-12-23 13:25:14 +01:00
Valentin Huber
03f7fc93ad
Fix empty multipart (#2789) 2024-12-23 11:39:51 +01:00
Valentin Huber
25386bfb5f
Use #[expect(…)] instead of #[allow(…)], remove unnecessary allows (#2784)
* Use expect instead of allow, remove unnecessary allows

* Remove more whitelist lint warnings

* tranisitioning more subprojects

* Re-add some necessary allows

* Re-add more required allows

* Some more windows clippy fixes

* Re-add more whitelist items for expect

* More clippy whitelist fun

* Reset changes to generated files

* Reset generated files to correct version

* Move libafl_concolic to expect instead of allow

* Move libafl_frida to expect from allow

* Move libafl_libfuzzer to expect from allow

* Remove more whitelist items for macOS

* Fix unknown clippy allow

* Remove more unnecessary allow statements

* moving fuzzers

* Remove mistakenly added subdirs

* fixing imports

* Remove more unnecessary whitelisted lints

* Fix test for /home/ubuntu/LibAFL/fuzzers/inprocess/libfuzzer_libpng_accounting

* More clippy improvements for libafl_qemu

* fmt

* Some pedantic options

* Fix more stuff

* Remove Little-CMS again

* Add note to static_mut_refs

* Reset the changed testing routine since it is unnecessary
2024-12-20 16:55:35 +01:00
Celian G.
09950ccc34
Update last found time when evaluating an input (#2782)
Co-authored-by: celian <cglenaz>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-12-19 14:51:59 +01:00
Valentin Huber
5d70216cc7
Remove MutVecInput and MappedInput in Favour of Impls on References (#2783)
* Remove MutVecInput and MappedInput

* Rename mapping mutators

* Update MIGRATION.md

* Fix test in docs

* Rename mapping mutators mappers

* Fix MIGRATION.md

* Fix docs link
2024-12-19 14:35:17 +01:00
cube0x8
e46cf8a851
LibAFL_QEMU: Fix incorrect handling of brk syscall when shrinking the heap (#2776)
* added libafl_get_initial_brk API to properly handle brk growing and shrinking

* cargo fmt

* updated qemu revision

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-12-19 10:40:16 +01:00
cube0x8
df3384d868
Separate Prometheus metrics into global and per-client categories with refactoring (#2781)
* separated global from per-client stats. refactoring

* cargo +nighlty fmt

* derive(Default) for PrometheusStats
2024-12-19 10:38:43 +01:00
Mehtab Zafar
358a5ea7f7
Cleanup clippy warnings in example fuzzers (#2770)
* cleanup warnings in fuzz_anything

* Refactor: Removed MatchNameRef from tuple import

* Used addr_of! macro instead of taking direct reference

* Remove unecessary unsafe block when getting references to SIGNALS array

* Switched from StdMapObserve to ConstMapObserver to create observer

Also updated signals_set to directly modify SIGNALS array

* Format code using fmt_all.sh
2024-12-19 08:33:13 +01:00
Valentin Huber
57cecca927
Remove outdated doc (#2778) 2024-12-18 16:53:14 +01:00
Marco C.
365ee1c850
Add Makefile.toml to intel_pt_baby_fuzzer (#2779)
* Add intel_pt_babyfuzzer Makefile

* ad cargo make to readme
2024-12-18 16:52:34 +01:00
79d3f89254 centralise target symbols 2024-12-18 16:28:51 +01:00
Mrmaxmeier
d9ddf82499
libafl_{cc,derive}: Bump MSRV to 1.82 for home crate update (#2775)
* libafl_{cc,derive}: Bump MSRV for `home` crate update

With the upcoming 2024 edition we should also set `resolver = "3"` in
the workspace's Cargo.toml to opt into a new MSRV-aware dependency
resolver. This would fix the breakage we encountered with dependencies
that bump their MSRV in a minor version update.

* libafl_cc: apply clippy suggestion
2024-12-18 05:08:32 +09:00
Marco C.
b7c7465be4
Revert #2768 fix bitbybit CI by locking bitbybit <1.3.3 (#2772)
* lock bitbybit < 1.3.3 and revert #2768

* lock to 1.3.2
2024-12-17 21:37:31 +09:00
WorksButNotTested
f9b643e7b3
Fix gdb-qemu (#2773)
Co-authored-by: WorksButNotTested
2024-12-17 11:34:26 +01:00
a13dca6f39 abstract SystemTraceData 2024-12-16 16:00:18 +01:00
Valentin Huber
61e3f0b3a4
Add Input Types and Mutators for Numeric Types (#2760)
* fixing empty multipart name

* fixing clippy

* New rules for the contributing (#2752)

* Rules

* more

* aa

* Improve Flexibility of DumpToDiskStage (#2753)

* fixing empty multipart name

* fixing clippy

* improve flexibility of DumpToDiskStage

* adding note to MIGRATION.md

* Introduce WrappingMutator

* introducing mutators for int types

* fixing no_std

* random fixes

* Add hash derivation for WrappingInput

* Revert fixes that broke things

* Derive Default on WrappingInput

* Add unit tests

* Fixes according to code review

* introduce mappable ValueInputs

* remove unnecessary comments

* Elide more lifetimes

* remove dead code

* simplify hashing

* improve docs

* improve randomization

* rename method to align with standard library

* add typedefs for int types for ValueMutRefInput

* rename test

* add safety notice to trait function

* improve randomize performance for i128/u128

* rename macro

* improve comment

* actually check return values in test

* make 128 bit int randomize even more efficient

* shifting signed values

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-12-15 15:00:41 +01:00
Dominik Maier
65e544a417
Somewhat ugly CI fix... (#2768)
* Maybe fix CI

* does this help?

* Very dirty 'fix'
2024-12-15 14:40:58 +01:00
Sharad Khanna
5324799935
Link libresolv on all Apple OSs (#2767) 2024-12-14 19:54:19 +01:00
Dongjia "toka" Zhang
be21fae490
Remove useless cfgs (#2764) 2024-12-12 22:02:34 +01:00
Dongjia "toka" Zhang
cc442f4dc8
No Uses* from fuzzer (#2761)
* go

* fixing stuf

* hello from windows

* more

* lolg

* lolf

* fix

* a

---------

Co-authored-by: Your Name <you@example.com>
2024-12-12 20:40:28 +01:00
Dongjia "toka" Zhang
afc02ee3c2
Update CONTRIBUTING.md MIGRATION.md (#2762) 2024-12-12 19:20:05 +01:00
Dongjia "toka" Zhang
3446ad974c
No Use* from stages (#2745)
* no from stage

* fixer

* doc fix

* how was this working????

* more fixes

* delete more

* rq

* cargo-fuzz

* m

* aa
2024-12-12 16:50:17 +01:00
dependabot[bot]
c176fee1e0
Update bindgen requirement from 0.70.1 to 0.71.1 (#2756)
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.70.1...v0.71.1)

---
updated-dependencies:
- dependency-name: bindgen
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-11 16:56:31 +01:00
Valentin Huber
c61460a4f5
Improve Flexibility of DumpToDiskStage (#2753)
* fixing empty multipart name

* fixing clippy

* improve flexibility of DumpToDiskStage

* adding note to MIGRATION.md
2024-12-08 21:46:38 +01:00
Valentin Huber
c2a9018631
Fixing Empty MultipartInput Names Part 2 (#2751)
* fixing empty multipart name

* fixing clippy
2024-12-06 21:22:05 +01:00
Dongjia "toka" Zhang
e602d26e5e
New rules for the contributing (#2752)
* Rules

* more

* aa
2024-12-06 21:19:34 +01:00
Marco C.
6a87a9d6d6
Intel PT minor fixes and improvements (#2749)
* Fix build target

Create target directory if doesn't exist

* Remove filter on speculatively exec blocks

since also committed blocks can have this flag

* Add current ip_filters getter

* Fix possibile infinite loop in trace decode

* Add comment about target_path
2024-12-06 19:14:08 +01:00
Valentin Huber
42ba65e864
Fix empty multipart name (#2750) 2024-12-06 18:32:58 +01:00
8d7e32559f type fixing 2024-12-06 16:10:25 +01:00
dependabot[bot]
0569960522
Update cargo_toml requirement from 0.20.5 to 0.21.0 (#2747)
Updates the requirements on [cargo_toml](https://gitlab.com/lib.rs/cargo_toml) to permit the latest version.
- [Commits](https://gitlab.com/lib.rs/cargo_toml/commits/main)

---
updated-dependencies:
- dependency-name: cargo_toml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-06 13:06:28 +01:00
b12811e1ef WIP: type fixing 2024-12-04 15:04:38 +01:00
jejuisland87654
8a91a2e5df
remove another unecessary HasTargetBytes constraint (#2743) 2024-12-04 14:09:34 +01:00
1430532b38 fix build 2024-12-04 13:03:38 +01:00
Valentin Huber
2758a1c2fb
Make MmapShMem::new take a AsRef<Path> instead of a byte array (#2742)
* Make MmapShMem take a AsRef<Path> instead of a byte array

* Make the test actually test if MmapShMem::persist works

* 0.14.1 (#2698)

* 0.14.1

* fixer

* don't build nyx

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>

* Intel PT minor fixes/improvements (#2724)

* waitpid_filtered to ignore SIGWINCH

* Fix warnings unused manifest key: *.version

* Add export_raw feature to libafl_intelpt

* derive Debug for IntelPTHook

* Clippy

* Update target program ELF offsets

* Add comment to KVM pt_mode check

* refactor

* Add intel_pt_export_raw feature in libafl

* map_error instead of unwrap

* borrow checker friendly join_split_trace

and copy trace before deocde to prevent decoding failures

* Set ip_filters (also) with builder

* Move trace to file

* Fix Cargo.toml docs

* Ignore blocks with no instruction

most likely they are filtered out

* Fix assertion in snapshot module for pages that are equal to SNAPSHOT_PAGE_SIZE (#2738)

Co-authored-by: Scott Powell <scott.powell@str.us>

* Remove non_basic const_panic features (#2739)

* Remove non_basic const_panic features

* fmt

* Make FridaInProcessExecutor compatible with TargetBytesConverter, decouple input type from FridaRuntime trait (#2741)

* decouple input type from FridaRuntime trait

* fmt

* fmt2

* remove HasTargetBytes requirement from FridaInProcessExecutor

* fmt

* restore comment

* fix clippy comment error

* adding entry to MIGRATION.md

* only running persist test on unix

* move cfg dependent imports to function

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Marco C. <46560192+Marcondiro@users.noreply.github.com>
Co-authored-by: Scott <55210664+scottmpowell@users.noreply.github.com>
Co-authored-by: Scott Powell <scott.powell@str.us>
Co-authored-by: jejuisland87654 <jejuisland87654@gmail.com>
2024-12-04 00:56:24 +01:00
Dominik Maier
85796f952b
drcov_merge: Make inputs seperated by space (#2740)
* drcov_merge: Make inputs seperated by space

* More doc
2024-12-04 00:14:58 +01:00
jejuisland87654
1809c31a46
Make FridaInProcessExecutor compatible with TargetBytesConverter, decouple input type from FridaRuntime trait (#2741)
* decouple input type from FridaRuntime trait

* fmt

* fmt2

* remove HasTargetBytes requirement from FridaInProcessExecutor

* fmt

* restore comment

* fix clippy comment error
2024-12-03 23:44:19 +01:00
c13537a620 WIP: port to 0.14.1 2024-12-03 15:32:17 +01:00
Dominik Maier
ffbb7a0f42
Remove non_basic const_panic features (#2739)
* Remove non_basic const_panic features

* fmt
2024-12-03 11:51:40 +01:00
Scott
0dabc34329
Fix assertion in snapshot module for pages that are equal to SNAPSHOT_PAGE_SIZE (#2738)
Co-authored-by: Scott Powell <scott.powell@str.us>
2024-12-03 10:34:56 +01:00
64bff97993 add debug stages 2024-12-03 09:29:29 +01:00
2427ae4703 update helper-scripts 2024-12-03 09:27:28 +01:00
Marco C.
36734083f9
Intel PT minor fixes/improvements (#2724)
* waitpid_filtered to ignore SIGWINCH

* Fix warnings unused manifest key: *.version

* Add export_raw feature to libafl_intelpt

* derive Debug for IntelPTHook

* Clippy

* Update target program ELF offsets

* Add comment to KVM pt_mode check

* refactor

* Add intel_pt_export_raw feature in libafl

* map_error instead of unwrap

* borrow checker friendly join_split_trace

and copy trace before deocde to prevent decoding failures

* Set ip_filters (also) with builder

* Move trace to file

* Fix Cargo.toml docs

* Ignore blocks with no instruction

most likely they are filtered out
2024-12-03 07:43:17 +00:00
Dongjia "toka" Zhang
95d87bd7d8
0.14.1 (#2698)
* 0.14.1

* fixer

* don't build nyx

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-12-02 21:06:29 +01:00
Dongjia "toka" Zhang
2102ae13d1
Clean cfgs in executors/command.rs (#2735)
* clean

* triple tick
2024-11-29 19:36:40 +01:00
Valentin Huber
bdde109867
Make Launcher use ClientDescription instead of CoreId (#2676)
* launcher now uses client_id instead of core_id

* adding overcommit to an example fuzzer

* Replace addr_of with &raw across the codebase (#2669)

* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu

* Introduce workspace (again) (#2673)

* Trying to redo workspace deps again after #2672

* unused

* clippy

* Replace addr_of with &raw across the codebase (#2669)

* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu

* Introduce workspace (again) (#2673)

* Trying to redo workspace deps again after #2672

* unused

* clippy

* fixing formatting issues

* cloning values to make borrow checker happy

* simplifying cfg constraints, removing excessive clippy allows

* printing clang version that is used to find inconsistencies between CI and local formatting

* some fixes according to the CI

* Specifying types

* improved logging for formatter

* more attempts at logging for the CI formatting

* fixing setting LLVM version in formatting in CI

* fixing cippy allows

* renaming launcher's ClientID to ClientDescription

* Lower capped RAND generators (#2671)

* Lower capped rand generators

* Updated all references to RAND generators

* Formatting updates

* New RAND bytes generator constructor

* Revert "Updated all references to RAND generators"

This reverts commit 9daad894b25ec3867daf93c4fe67c03abec1d8c6.

* Revert "Formatting updates"

This reverts commit ff2a61a366c48b3f313878f62409e51b1e1ed663.

* cargo nightly format

* Added must_use to with_min_size

* fix error '#' is not followed by a macro parameter (#2678)

* Use version.workspace (#2682)

* LibAFL_QEMU: Don't return a generic Address from Register reads (#2681)

* LibAFL_QEMU: Make ReadReg always return GuestReg type

* Don't return a generic address

* fix fuzzers

* fix mips

* Add DrCovReader to read DrCov files and DrCov dumper and merge utils (#2680)

* Add DrCov Reader

* Removed libafl_jumper deps

* Fix DrCovWriter, add dump_drcov_addrs

* Taplo

* Move frida from usize to u64

* DrCov usize=>u64

* Better error print

* More u64

* ?

* debug

* clippy

* clippy

* Add Merge option to DrCovReader

* Add drcov_merge tool

* Move folder around

* DrCov

* More assert

* fmt

* Move around

* Fix print

* Add option to read multiple files/full folders

* Fix build_all_fuzzers.sh for local runs (#2686)

* Add Intel PT tracing support (#2471)

* WIP: IntelPT qemu systemmode

* use perf-event-open-sys instead of bindgen

* intelPT Add enable and disable tracing, add test

* Use static_assertions crate

* Fix volatiles, finish test

* Add Intel PT availability check

* Use LibAFL errors in Result

* Improve filtering

* Add KVM pt_mode check

* move static_assertions use

* Check for perf_event_open support

* Add (empty) IntelPT module

* Add IntelPTModule POC

* partial ideas to implement intel pt

* forgot smth

* trace decoding draft

* add libipt decoder

* use cpuid instead of reading /proc/cpuinfo

* investigating nondeterministic behaviour

* intel_pt module add thread creation hook

* Fully identify deps versions

Cargo docs: Although it looks like a specific version of the crate, it actually specifies a range of versions and allows SemVer compatible updates

* Move mem image to module, output to file for debug

* fixup! Use static_assertions crate

* Exclude host kernel from traces

* Bump libipt-rs

* Callback to get memory as an alterantive to image

* WIP Add bootloader fuzzer example

* Split availability check: add availability_with_qemu

* Move IntelPT to observer

* Improve test docs

* Clippy happy now

* Taplo happy now

* Add IntelPTObserver boilerplate

* Hook instead of Observer

* Clippy & Taplo

* Add psb_freq setting

* Extremely bad and dirty babyfuzzer stealing

* Use thread local cell instead of mutex

* Try a trace diff based naive feedback

* fix perf aux buffer wrap handling

* Use f64 for feedback score

* Fix clippy for cargo test

* Add config format tests

* WIP intelpt babyfuzzer with fork

* Fix not wrapped tail offset in split buffer

* Baby PT with raw traces diff working

* Cache nr_filters

* Use Lazy_lock for perf_type

* Add baby_fuzzer_intel_pt

* restore baby fuzzer

* baby_fuzzer with block decoder

* instruction decoder instead of block

* Fix after upstream merge

* OwnedRefMut instead of Cow

* Read mem directly instead of going through files

* Fix cache lifetime and tail update

* clippy

* Taplo

* Compile caps only on linux

* clippy

* Fail compilation on unsupported OSes

* Add baby_fuzzer_intel_pt to CI

* Cleanup

* Move intel pt + linux check

* fix baby pt

* rollback forkexecutor

* Remove unused dep

* Cleanup

* Lints

* Compute an edge id instead of using only block ip

* Binary only intelPT POC

* put linux specific code behind target_os=linux

* Clippy & Taplo

* fix CI

* Disable relocation

* No unwrap in decode

* No expect in decode

* Better logging, smaller aux buffer

* add IntelPTBuilder

* some lints

* Add exclude_hv config

* Per CPU tracing and inheritance

* Parametrize buffer size

* Try not to break commandExecutor API pt.1

* Try not to break commandExecutor API pt.2

* Try not to break commandExecutor API pt.3

* fix baby PT

* Support on_crash & on_timeout callbacks for libafl_qemu modules (#2620)

* support (unsafe) on_crash / on_timeout callbacks for modules

* use libc types in bindgen

* Move common code to bolts

* Cleanup

* Revert changes to backtrace_baby_fuzzers/command_executor

* Move intel_pt in one file

* Use workspace deps

* add nr_addr_filter fallback

* Cleaning

* Improve decode

* Clippy

* Improve errors and docs

* Impl from<PtError> for libafl::Error

* Merge hooks

* Docs

* Clean command executor

* fix baby PT

* fix baby PT warnings

* decoder fills the map with no vec alloc

* WIP command executor intel PT

* filter_map() instead of filter().map()

* fix docs

* fix windows?

* Baby lints

* Small cleanings

* Use personality to disable ASLR at runtime

* Fix nix dep

* Use prc-maps in babyfuzzer

* working ET_DYN elf

* Cleanup Cargo.toml

* Clean command executor

* introduce PtraceCommandConfigurator

* Fix clippy & taplo

* input via stdin

* libipt as workspace dep

* Check kernel version

* support Arg input location

* Reorder stuff

* File input

* timeout support for PtraceExec

* Lints

* Move out method not needing self form IntelPT

* unimplemented

* Lints

* Move intel_pt_baby_fuzzer

* Move intel_pt_command_executor

* Document the need for smp_rmb

* Better comment

* Readme and Makefile.toml instead of build.rs

* Move out from libafl_bolts to libafl_intelpt

* Fix hooks

* (Almost) fix intel_pt command exec

* fix intel_pt command exec debug

* Fix baby_fuzzer

* &raw over addr_of!

* cfg(target_os = "linux")

* bolts Cargo.toml leftover

* minimum wage README.md

* extract join_split_trace from decode

* extract decode_block from decode

* add 1 to `previous_block_ip` to avoid that all the recursive basic blocks map to 0

* More generic hook

* fix windows

* Update CI, fmt

* No bitbybit

* Fix docker?

* Fix Apple silicon?

* Use old libipt from crates.io

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Dominik Maier <domenukk@gmail.com>

* libafl-fuzz: introduce nyx_mode (#2503)

* add nyx_mode

* fix frida ci?

* damn clippy

* clippy

* LibAFL: Remove `tui_monitor` from default features (#2685)

* No Usermode default

* no tui

* gg

* try fix CI

* fmt

---------

Co-authored-by: Dominik Maier <dmnk@google.com>

* Actually make ConstMapObserver work, introduce `nonnull_raw_mut` macro (#2687)

* Actually make ConstMapObserver work

* fixes

* does that work?

* mas

* Feature: libafl-fuzzfuzzbench (#2689)

* fuzzbench

* clippy

* fmt

* fix unicorn CI?

* Move bitfields to bitbybit (#2688)

* move to bitbybit

* Restore bitbybit dependent code

* Clippy

* Fix NautilusContext::from_file for python files (#2690)

* Bump to 0.14.0 (#2692)

* Fix versions in libafl and libafl_intelpt for crates.io (#2693)

* Fix versions in libafl and libafl_intelpt for crates

* Add libafl_intelpt to publish

* StdMOptMutator:🆕 remove unused type parameter (#2695)

`I` is unused in `::new` and thus requires callers to explicitly specify
any type as it can't be determined by type inference.

Clippy's `extra_unused_type_parameters` should pick this up, but is
tuned a bit too conservative in order to avoid false positives AFAICT.

* Move test_harness from source directory to OUT_DIR (#2694)

* remove test_harness from source directory

* fmt

* Add package.metadata.docs.rs for libafl_intelpt (#2696)

* libafl-fuzz: fix cmplog running on inputs more than once (#2697)

* libafl-fuzz: fix cmplog running on inputs more than once

* fmt

* fix afl++ cmplog header

* update to latest afl stable commit

* Libafl workspace internal deps in workspace Cargo.toml (#2691)

* Add internal deps to workspace

* libafl: use workspace internal deps

* libafl_bolts: use workspace internal deps

* 0.14.0

* use workspace internal deps

* Fix tui monitor for example fuzzers (#2699)

* Fix tui monitor for example fuzzers

* New clippy lint

* fix

* Update pyo3-build-config requirement from 0.22.3 to 0.23.1 (#2701)

Updates the requirements on [pyo3-build-config](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.22.3...v0.23.1)

---
updated-dependencies:
- dependency-name: pyo3-build-config
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* bolts: fix build for tiers 3 platforms. (#2700)

cater to platforms knowingly support this feature instead.

* Pre init module hooks (#2704)

* differenciate pre qemu init and post qemu init hooks

* api breakage: Emulator::new_with_qemu is not public anymore.

* Fix edge module generators (#2702)

* fix generators

* fix metadata removal for ExecutionCountRestartHelper (#2705)

* Ignore pyo3 update (#2709)

* libafl-fuzz: feature-flag nyx mode (#2712)

* Bump ctor dependency to make nightly compile again (#2713)

* Batched timeout doc (#2716)

* timeout doc

* clp

* FMT

* More batched timeout doc (#2717)

* timeout doc

* clp

* FMT

* more

* fixing an overexited cast

* renaming variables

* removing unnecessary brackets

* fixing imports

* fixing imports

* renaming more variables

* even more variable renaming

* removing duplicate clap short options

* reverting mistaken variable renaming

* comparing the actual cores instead of an enumeration index

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Subhojeet Mukherjee, PhD <57270300+CowBoy4mH3LL@users.noreply.github.com>
Co-authored-by: jejuisland87654 <jejuisland87654@gmail.com>
Co-authored-by: Marco C. <46560192+Marcondiro@users.noreply.github.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Aarnav <aarnav@srlabs.de>
Co-authored-by: Dominik Maier <dmnk@google.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: Mrmaxmeier <3913977+Mrmaxmeier@users.noreply.github.com>
Co-authored-by: Sharad Khanna <sharad@mineo333.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David CARLIER <devnexen@gmail.com>
Co-authored-by: Henry Chu <henrytech@outlook.com>
2024-11-29 19:36:13 +01:00
Mohammad Omidvar
0d0bbf0c5d
Make exit status interpretable by CommandConfigurator (#2723)
* Make exit status interpretable by CommandConfigurator

* Fix import issues

* Fix default implementation for non-unix environment

* Make docs only available on unix if the entry is only for unix

* Revert "Fix default implementation for non-unix environment"

This reverts commit 5457f6f7376c2a3a4d4c8459de46d6b54bb0d44f.

* Fix the invalid link in the example
2024-11-27 20:02:35 +01:00
Romain Malmain
94fa4014ac
Update pyo3 to version 0.23.2 (#2732)
* update pyo3 to latest version

* add python bindings to workspace

* make pyo3 stuff dependent of workspace again

* adapt implementation for the newest version of pyo3
2024-11-27 19:01:31 +01:00
Dongjia "toka" Zhang
f30cd2a8ab
Run miri test only if it has labels (#2734)
* stuf

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml
2024-11-27 15:35:53 +01:00
Valentin Huber
e9af21cf71
Adding function to manually name a Mmap ShMem (#2729)
* adding function to manually name a mmap shmem

* fixing tests

* making code more readable

* Add MIGRATION.md (#2727)

* updating MIGRATION.md

* removing unnecessary assignment

* fixing typo in MIGRATION.md

* fixing formatting

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-11-26 20:08:31 +01:00
Mrmaxmeier
6ce447ee17
Specify minimum supported rust version and check in CI (#2726) 2024-11-26 17:58:01 +01:00
Dongjia "toka" Zhang
b3ca9a7c06
Delete with_observers (#2730)
* delete with_observers

* import

* doc

* a

* fix markdown
2024-11-26 17:54:21 +01:00
Dongjia "toka" Zhang
49d1b18010
Fix negative stability (#2731)
* fix

* FMT
2024-11-26 17:10:31 +01:00
golem9247
41c1c545b2
update baby_fuzzer example to 0.14 (#2728)
Move InProcessExecutor
2024-11-26 16:16:30 +01:00
Dongjia "toka" Zhang
3a6694c90b
Add MIGRATION.md (#2727) 2024-11-26 15:33:47 +01:00
Addison Crump
e53dd4e6cc
Fixup serdeany_autoreg (#2721)
* fixup serdeany_autoreg

* missed a spot

* remove explicit checks in ps1 as this is set by Cargo.toml
2024-11-24 03:00:54 -03:00
Marco C.
959ecb32e9
Bump libipt, fix tui in intel_pt baby fuzzer (#2714)
* Bump libipt, fix tui in intel_pt baby fuzzer

* libipt = "0.2.0"

* Use end_ip for previous block instead of ip + 1
2024-11-22 11:58:23 -03:00
Dongjia "toka" Zhang
a8d2e8711b
More batched timeout doc (#2717)
* timeout doc

* clp

* FMT

* more
2024-11-21 16:18:45 +01:00
Dongjia "toka" Zhang
391147c950
Batched timeout doc (#2716)
* timeout doc

* clp

* FMT
2024-11-21 15:52:12 +01:00
Dominik Maier
f3ab3c744e
Bump ctor dependency to make nightly compile again (#2713) 2024-11-20 18:18:38 -03:00
Aarnav
6e707d15bb
libafl-fuzz: feature-flag nyx mode (#2712) 2024-11-20 17:06:07 -03:00
Dongjia "toka" Zhang
e7f48889e7
Ignore pyo3 update (#2709) 2024-11-19 18:45:20 +01:00
Henry Chu
7623aa46f9
fix metadata removal for ExecutionCountRestartHelper (#2705) 2024-11-19 14:36:19 +01:00
Romain Malmain
b3d3c38b29
Fix edge module generators (#2702)
* fix generators
2024-11-18 19:48:31 +01:00
Romain Malmain
b324e88631
Pre init module hooks (#2704)
* differenciate pre qemu init and post qemu init hooks

* api breakage: Emulator::new_with_qemu is not public anymore.
2024-11-18 19:47:14 +01:00
David CARLIER
f74a965ead
bolts: fix build for tiers 3 platforms. (#2700)
cater to platforms knowingly support this feature instead.
2024-11-18 13:36:41 -03:00
dependabot[bot]
b4a69d15d0
Update pyo3-build-config requirement from 0.22.3 to 0.23.1 (#2701)
Updates the requirements on [pyo3-build-config](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.22.3...v0.23.1)

---
updated-dependencies:
- dependency-name: pyo3-build-config
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-18 13:35:31 -03:00
Dominik Maier
b3d73b2919
Fix tui monitor for example fuzzers (#2699)
* Fix tui monitor for example fuzzers

* New clippy lint

* fix
2024-11-16 08:28:11 +01:00
Marco C.
eb2ac10d1e
Libafl workspace internal deps in workspace Cargo.toml (#2691)
* Add internal deps to workspace

* libafl: use workspace internal deps

* libafl_bolts: use workspace internal deps

* 0.14.0

* use workspace internal deps
2024-11-15 18:13:39 +01:00
Aarnav
cef902caff
libafl-fuzz: fix cmplog running on inputs more than once (#2697)
* libafl-fuzz: fix cmplog running on inputs more than once

* fmt

* fix afl++ cmplog header

* update to latest afl stable commit
2024-11-15 16:57:21 +01:00
Dongjia "toka" Zhang
517fc334e2
Add package.metadata.docs.rs for libafl_intelpt (#2696) 2024-11-15 13:51:20 +01:00
Sharad Khanna
8df9e68677
Move test_harness from source directory to OUT_DIR (#2694)
* remove test_harness from source directory

* fmt
2024-11-14 12:47:45 -03:00
Mrmaxmeier
8f320d4314
StdMOptMutator:🆕 remove unused type parameter (#2695)
`I` is unused in `::new` and thus requires callers to explicitly specify
any type as it can't be determined by type inference.

Clippy's `extra_unused_type_parameters` should pick this up, but is
tuned a bit too conservative in order to avoid false positives AFAICT.
2024-11-14 12:46:28 -03:00
317fbc8e3f add emergency_copter 2024-11-14 14:38:49 +01:00
0a233aad48 plot stgsize + observe_hitcounts-- 2024-11-14 13:22:04 +01:00
Andrea Fioraldi
b9cfcf0771
Fix versions in libafl and libafl_intelpt for crates.io (#2693)
* Fix versions in libafl and libafl_intelpt for crates

* Add libafl_intelpt to publish
2024-11-14 00:06:36 +01:00
Andrea Fioraldi
d339a58f7c
Bump to 0.14.0 (#2692) 2024-11-13 23:10:35 +01:00
jejuisland87654
8d81e3480e
Fix NautilusContext::from_file for python files (#2690) 2024-11-13 16:45:18 -03:00
Marco C.
b7889a5996
Move bitfields to bitbybit (#2688)
* move to bitbybit

* Restore bitbybit dependent code

* Clippy
2024-11-13 16:28:25 -03:00
Aarnav
d334860148
Feature: libafl-fuzzfuzzbench (#2689)
* fuzzbench

* clippy

* fmt

* fix unicorn CI?
2024-11-13 13:32:21 +01:00
Dominik Maier
7938acc4ce
Actually make ConstMapObserver work, introduce nonnull_raw_mut macro (#2687)
* Actually make ConstMapObserver work

* fixes

* does that work?

* mas
2024-11-13 00:35:46 -03:00
Dongjia "toka" Zhang
d5db2c0e3f
LibAFL: Remove tui_monitor from default features (#2685)
* No Usermode default

* no tui

* gg

* try fix CI

* fmt

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-11-12 22:55:02 -03:00
Aarnav
87f5f21e01
libafl-fuzz: introduce nyx_mode (#2503)
* add nyx_mode

* fix frida ci?

* damn clippy

* clippy
2024-11-12 22:51:07 -03:00
Marco C.
f7f8dff6cd
Add Intel PT tracing support (#2471)
* WIP: IntelPT qemu systemmode

* use perf-event-open-sys instead of bindgen

* intelPT Add enable and disable tracing, add test

* Use static_assertions crate

* Fix volatiles, finish test

* Add Intel PT availability check

* Use LibAFL errors in Result

* Improve filtering

* Add KVM pt_mode check

* move static_assertions use

* Check for perf_event_open support

* Add (empty) IntelPT module

* Add IntelPTModule POC

* partial ideas to implement intel pt

* forgot smth

* trace decoding draft

* add libipt decoder

* use cpuid instead of reading /proc/cpuinfo

* investigating nondeterministic behaviour

* intel_pt module add thread creation hook

* Fully identify deps versions

Cargo docs: Although it looks like a specific version of the crate, it actually specifies a range of versions and allows SemVer compatible updates

* Move mem image to module, output to file for debug

* fixup! Use static_assertions crate

* Exclude host kernel from traces

* Bump libipt-rs

* Callback to get memory as an alterantive to image

* WIP Add bootloader fuzzer example

* Split availability check: add availability_with_qemu

* Move IntelPT to observer

* Improve test docs

* Clippy happy now

* Taplo happy now

* Add IntelPTObserver boilerplate

* Hook instead of Observer

* Clippy & Taplo

* Add psb_freq setting

* Extremely bad and dirty babyfuzzer stealing

* Use thread local cell instead of mutex

* Try a trace diff based naive feedback

* fix perf aux buffer wrap handling

* Use f64 for feedback score

* Fix clippy for cargo test

* Add config format tests

* WIP intelpt babyfuzzer with fork

* Fix not wrapped tail offset in split buffer

* Baby PT with raw traces diff working

* Cache nr_filters

* Use Lazy_lock for perf_type

* Add baby_fuzzer_intel_pt

* restore baby fuzzer

* baby_fuzzer with block decoder

* instruction decoder instead of block

* Fix after upstream merge

* OwnedRefMut instead of Cow

* Read mem directly instead of going through files

* Fix cache lifetime and tail update

* clippy

* Taplo

* Compile caps only on linux

* clippy

* Fail compilation on unsupported OSes

* Add baby_fuzzer_intel_pt to CI

* Cleanup

* Move intel pt + linux check

* fix baby pt

* rollback forkexecutor

* Remove unused dep

* Cleanup

* Lints

* Compute an edge id instead of using only block ip

* Binary only intelPT POC

* put linux specific code behind target_os=linux

* Clippy & Taplo

* fix CI

* Disable relocation

* No unwrap in decode

* No expect in decode

* Better logging, smaller aux buffer

* add IntelPTBuilder

* some lints

* Add exclude_hv config

* Per CPU tracing and inheritance

* Parametrize buffer size

* Try not to break commandExecutor API pt.1

* Try not to break commandExecutor API pt.2

* Try not to break commandExecutor API pt.3

* fix baby PT

* Support on_crash & on_timeout callbacks for libafl_qemu modules (#2620)

* support (unsafe) on_crash / on_timeout callbacks for modules

* use libc types in bindgen

* Move common code to bolts

* Cleanup

* Revert changes to backtrace_baby_fuzzers/command_executor

* Move intel_pt in one file

* Use workspace deps

* add nr_addr_filter fallback

* Cleaning

* Improve decode

* Clippy

* Improve errors and docs

* Impl from<PtError> for libafl::Error

* Merge hooks

* Docs

* Clean command executor

* fix baby PT

* fix baby PT warnings

* decoder fills the map with no vec alloc

* WIP command executor intel PT

* filter_map() instead of filter().map()

* fix docs

* fix windows?

* Baby lints

* Small cleanings

* Use personality to disable ASLR at runtime

* Fix nix dep

* Use prc-maps in babyfuzzer

* working ET_DYN elf

* Cleanup Cargo.toml

* Clean command executor

* introduce PtraceCommandConfigurator

* Fix clippy & taplo

* input via stdin

* libipt as workspace dep

* Check kernel version

* support Arg input location

* Reorder stuff

* File input

* timeout support for PtraceExec

* Lints

* Move out method not needing self form IntelPT

* unimplemented

* Lints

* Move intel_pt_baby_fuzzer

* Move intel_pt_command_executor

* Document the need for smp_rmb

* Better comment

* Readme and Makefile.toml instead of build.rs

* Move out from libafl_bolts to libafl_intelpt

* Fix hooks

* (Almost) fix intel_pt command exec

* fix intel_pt command exec debug

* Fix baby_fuzzer

* &raw over addr_of!

* cfg(target_os = "linux")

* bolts Cargo.toml leftover

* minimum wage README.md

* extract join_split_trace from decode

* extract decode_block from decode

* add 1 to `previous_block_ip` to avoid that all the recursive basic blocks map to 0

* More generic hook

* fix windows

* Update CI, fmt

* No bitbybit

* Fix docker?

* Fix Apple silicon?

* Use old libipt from crates.io

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-11-12 22:34:46 -03:00
Dongjia "toka" Zhang
5eff9c03d3
Fix build_all_fuzzers.sh for local runs (#2686) 2024-11-12 22:19:26 -03:00
Dominik Maier
7fada7d985
Add DrCovReader to read DrCov files and DrCov dumper and merge utils (#2680)
* Add DrCov Reader

* Removed libafl_jumper deps

* Fix DrCovWriter, add dump_drcov_addrs

* Taplo

* Move frida from usize to u64

* DrCov usize=>u64

* Better error print

* More u64

* ?

* debug

* clippy

* clippy

* Add Merge option to DrCovReader

* Add drcov_merge tool

* Move folder around

* DrCov

* More assert

* fmt

* Move around

* Fix print

* Add option to read multiple files/full folders
2024-11-12 22:18:57 -03:00
Dominik Maier
0ef0684e43
LibAFL_QEMU: Don't return a generic Address from Register reads (#2681)
* LibAFL_QEMU: Make ReadReg always return GuestReg type

* Don't return a generic address

* fix fuzzers

* fix mips
2024-11-12 22:14:35 -03:00
Marco C.
f3aa88b400
Use version.workspace (#2682) 2024-11-12 15:45:35 +01:00
Valentin Huber
ae9ab80ad9
Fixing version pinning in CI (#2679) 2024-11-12 00:49:58 +01:00
jejuisland87654
4269be1c08
fix error '#' is not followed by a macro parameter (#2678) 2024-11-11 19:43:27 +01:00
Subhojeet Mukherjee, PhD
e25094eb4f
Lower capped RAND generators (#2671)
* Lower capped rand generators

* Updated all references to RAND generators

* Formatting updates

* New RAND bytes generator constructor

* Revert "Updated all references to RAND generators"

This reverts commit 9daad894b25ec3867daf93c4fe67c03abec1d8c6.

* Revert "Formatting updates"

This reverts commit ff2a61a366c48b3f313878f62409e51b1e1ed663.

* cargo nightly format

* Added must_use to with_min_size
2024-11-11 19:36:55 +01:00
cd3c101e87 define critical benchmark sets 2024-11-11 15:45:36 +01:00
0c80801e9f define benchmark sets 2024-11-11 15:36:29 +01:00
2a61f51a69 keep more cases when pruning, try more non-favored cases 2024-11-11 13:50:44 +01:00
79f0aab769 config_stg_abbpath 2024-11-10 10:31:03 +01:00
b7710c7d8a rate-limit UserStats + tolerate pending notifications for 1ms 2024-11-10 10:21:36 +01:00
Valentin Huber
e32b3eae93
Introducing Launcher::overcommit, improving CI formatting (#2670)
* introducing Launcher::overcommit

* removing unnecessary cfg restrictions and clippy allows

* improving warning for wrong clang-format version

* installing black in the format CI

* Enforcing python formatting in CI

* extending formatting using black on all python files

* printing diff on black failure

* preferring python's black over system black

* moving to LLVM 19 for formatting
2024-11-09 19:13:51 +01:00
Dominik Maier
8617fa6603
Introduce workspace (again) (#2673)
* Trying to redo workspace deps again after #2672

* unused

* clippy
2024-11-09 19:11:01 +01:00
Dominik Maier
21f8b1d147
Replace addr_of with &raw across the codebase (#2669)
* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu
2024-11-08 17:19:55 +01:00
280025b505 add config_stg_aggregate 2024-11-08 16:10:26 +01:00
6dc55d6cc9 update all_bins 2024-11-08 16:04:14 +01:00
825d80b88d aggresive pruning 2024-11-08 16:00:23 +01:00
2bc7872a51 configure sched_stg_edge 2024-11-08 15:43:04 +01:00
ab6026535c rate-limit testcase printing 2024-11-08 11:05:36 +01:00
Aarnav
d1c746a0a2
Set rlimit to inifinity for core dumps if AFL_DEBUG=1 (#2643)
* forkserver: set rlimit to inifinity for core dumps if AFL_DEBUG=1

* move coredump rlimit to a separate func

* update docs
2024-11-06 14:11:58 +01:00
e6ec643781 fix release-detection for api -> isr -> app, fix crash on empty trace 2024-11-06 12:51:39 +01:00
bernhl
cfe124043e
Add memfd shmem backend (#2647) 2024-11-06 11:37:43 +01:00
Dominik Maier
36a24ab418
Custom Executor Example (#2570)
* [WIP] Custom Executor Example

* readme

* src/main.rs

* Finish

* fix warnings

* reame

* CI
2024-11-05 16:49:07 +01:00
Dominik Maier
b5c9bffe50
Core::errors::Error is stable now (#2664) 2024-11-05 16:48:31 +01:00
Dhanvith Nayak
8de9dcaff7
Clean up clippy warnings in fuzzers/binary_only/* (#2662)
* clean clippy warnings from fuzzers/binary_only/*

* handle unused Results in fuzzers/binary_only/*

* format fuzzers/binary_only/qemu_cmin

* use unchecked memory write in qemu fuzzer examples

* create file_null in fuzzbench_fork_qemu
2024-11-05 15:22:14 +01:00
dependabot[bot]
4581c50023
Update hashbrown requirement from 0.14.5 to 0.15.1 (#2660)
---
updated-dependencies:
- dependency-name: hashbrown
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-05 14:46:40 +01:00
Valentin Huber
4431f069e5
Fix crossover mutators for empty multipart inputs (#2663) 2024-11-05 14:45:56 +01:00
Dongjia "toka" Zhang
87e4a845e0
Reenable libfuzzer_stb_image_sugar test (#2659) 2024-11-04 22:46:12 +01:00
Dongjia "toka" Zhang
e0c5304e32
Don't use workspace dependencies (#2652)
* rev

* postcard

* serde

* fmt

* a

* dependabot

* postcard again

* hashbrown

* upd

* add

* serde?
2024-11-04 17:47:40 +01:00
jejuisland87654
1e0b5581e5
better definition for PROFILE_DIR in all Makefile.toml files (#2658) 2024-11-04 17:09:12 +01:00
dependabot[bot]
cbe89b096d
Update ratatui requirement from 0.28.1 to 0.29.0 (#2657)
Updates the requirements on [ratatui](https://github.com/ratatui/ratatui) to permit the latest version.
- [Release notes](https://github.com/ratatui/ratatui/releases)
- [Changelog](https://github.com/ratatui/ratatui/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ratatui/ratatui/compare/v0.28.1...v0.29.0)

---
updated-dependencies:
- dependency-name: ratatui
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-04 17:08:04 +01:00
dependabot[bot]
51393242d8
Update dynasmrt requirement from 2.0.0 to 3.0.1 (#2653)
* Update dynasmrt requirement from 2.0.0 to 3.0.1

Updates the requirements on [dynasmrt](https://github.com/CensoredUsername/dynasm-rs) to permit the latest version.
- [Changelog](https://github.com/CensoredUsername/dynasm-rs/blob/master/doc/releasenotes.md)
- [Commits](https://github.com/CensoredUsername/dynasm-rs/compare/v2.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: dynasmrt
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix for update

* fix

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Toka <tokazerkje@outlook.com>
2024-11-04 16:32:20 +01:00
6902e21c6a update demo-list 2024-11-04 16:27:49 +01:00
dependabot[bot]
d7ce89d78d
Update goblin requirement from 0.8.2 to 0.9.2 (#2655)
Updates the requirements on [goblin](https://github.com/m4b/goblin) to permit the latest version.
- [Changelog](https://github.com/m4b/goblin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/m4b/goblin/commits)

---
updated-dependencies:
- dependency-name: goblin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-04 16:23:27 +01:00
Romain Malmain
49ea0b03a6
Compile-time edge module compilation check, native support for ConstMapObserver (#2592)
* compile-time edge module compilation trick

* clippy

* possible since rust 1.79

* split edge module in submodules

* Update frida to 0.14.0 (#2596)

* update frida crate to the latest version

* adapt libafl_frida to the latest version of frida

* tracers and generators private modules

* do not use star export.

* same for drcov

* forgot a file...

* first draft of generic-based edge module for ConstantLengthMapObserver.

* integration of OwnedSizedSlice.

replaced OwnedSlice in ConstMapObserver by the new OwnedSizedSlice.

* fix serde stuff

* no std

* import

* fixed qemu_cmin with new constant map abstraction.

* fix const map

* fix clippy from another pr...

* fix non-null usage

* fix ci?

* new feature stuff

* fixes

* minor fixes

* fmt

* non null

* im stupid

* fmt

* fix fuzzer

* fix fuzzers

* sized slice

* fuzzer fixes

* ptr::NonNull -> NonNull

* shorter trait length

* fmt
2024-11-04 14:34:52 +01:00
Marco C.
56a5463ae4
Use a proper pre-commit hook for taplo fmt (#2650)
* Add taplo to pre-commit

* Use a proper pre-commit hook for taplo fmt
2024-11-04 14:17:02 +01:00
Yufei Li
97a8e4c294
Add RISCV support in libafl_qemu.h (#2380)
* Add riscv support in libafl qemu header

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-11-04 11:10:25 +01:00
328e762dd5 save per-instance crashes 2024-11-04 10:03:39 +01:00
ed90c12922 revert trace_job_response_times 2024-11-04 09:51:29 +01:00
Romain Malmain
99a156f783
Implement From LibAFL Error for Qemu Error (#2641)
* impl from qemu error for libafl error

* new error for frontends like qemu or frida

* exhaustive match

* frontend -> runtime
2024-11-03 21:09:16 +01:00
Valentin Huber
d4fbe1754f
Move ShMem persisting flag to a new constructor (#2649)
* moving shmem persisting to take an owned value, adding test

* clean code updates

* adding imports conditionally

* fixing tests

* moving persistent mmap shmem to custom constructor

* excluding miri properly

* fixing formatting
2024-11-03 03:13:10 +01:00
660cf60fc5 skip error dumping 2024-11-02 11:52:56 +01:00
bc165eb094 update bench-config 2024-11-02 11:39:53 +01:00
79be3c8eca config 2024-11-02 11:37:29 +01:00
Marco C.
89cff63702
Add taplo to pre-commit (#2646) 2024-10-31 17:55:10 +01:00
Romain Malmain
6d55626a48
libafl_qemu: update qemu to v9.1.1 (#2636)
* update qemu to v9.1.1

* adapting stuff to qemu 9.1

* fix for new qemu gen_callN and x86 decoder

* remove outdated qemu configuration option
2024-10-31 17:54:37 +01:00
Dominik Maier
c86e116d9a
Remove serde_json dependency from libafl_bolts (#2639)
* Remove serde_json dependency from libafl_bolts

* more like a serialize err

* Fix nautilus json
2024-10-31 14:16:53 +01:00
Romain Malmain
47120834dc
libafl_qemu: do not test slirp in ci for usermode (#2644) 2024-10-30 17:47:37 +01:00
e58d4ba6ff tune detection of irregular task instances 2024-10-30 16:18:12 +01:00
894c11935f display stats 2024-10-30 15:27:48 +01:00
7c71e683d8 don't remove all items from corpus 2024-10-30 14:45:32 +01:00
Romain Malmain
9da113e7a8
Fix RISC-V port issues (#2642)
fix riscv{32,64} stuff
2024-10-30 14:10:50 +01:00
s1341
af06d75d3e
frida: bump version (#2640)
* frida: bump version

* frida_windows: fix
2024-10-30 12:31:40 +01:00
saibotk
83c87acd5b
libafl_qemu: Add RISCV support (#2367)
* libafl_qemu: Add RISCV support

Adds the following targets (as features):
- riscv32
- riscv64

Added `RISCVCPU` and `CPURISCVState` to the bindings allow list.

Added riscv.rs to the arch module, with all necessary functions and
registers implemented and mapped.
The registers are the same as the ones found in qemus gdbstub xml found
after a build.

Additionally we added all syscall numbers for riscv 64 bit (already
supported by the `syscall_numbers` crate) and also added the missing
ones for riscv 32 bit. We compared both lists and their differences /
equalities with a simple python script and generated a list of the
missing ones, to be complete.
We might PR those to the `syscall_numbers` crate later on.

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-10-30 10:33:03 +01:00
Dominik Maier
6eb2dafd34
Feature: Make executors and feedbacks easier to use outside of the fuzzing loop (extends #2511) (#2637)
* feat(libafl_core): make executors and feedbacks more cleanly usable outside of LibAFLs Fuzzer loop

* cargo +nightly fmt

* updated type constraints

* reformatted and final type constraint fixes

* made unicode extraction stage useful separately

* fix libafl_cc error message

* fix state type constraint to be constrained on the method

* removed unnecessary observer constraint

* renamed unused variables

* fix unnecessary error wrapping in helper functions

* converted unicode conversion stage into associated function and fixed nautilus changes

* more update

* Remove extra I

* more fmt

* bounds?

* less bounds

* more less bounds

* different trait bounds again

* more less generics

* fix unicode

* fix list

* remove unneeded bound

---------

Co-authored-by: Lukas Dresel <Lukas-Dresel@users.noreply.github.com>
Co-authored-by: Toka <tokazerkje@outlook.com>
2024-10-29 18:35:17 +01:00
0e7de2d109 imports 2024-10-29 18:23:02 +01:00
f1affaabff impl RemovableScheduler for GenerationScheduler 2024-10-29 18:21:46 +01:00
0a6888d06a add pruning message 2024-10-29 18:10:16 +01:00
d88cefb894 add experimental corpus pruning 2024-10-29 18:08:18 +01:00
4d0ec2e427 typo 2024-10-29 16:01:25 +01:00
a613156a32 micro fixes 2024-10-29 15:59:15 +01:00
013f3db487 implement STGSnippetStage, fix missing metadata 2024-10-29 14:07:52 +01:00
Aarnav
0f744a3abb
Add Python Grammar Loader for Nautilus (#2635)
* add python grammar loader for Nautilus

* fmt

* fmt toml

* add python to macos CI deps

* install python

* fmt

* ci

* clippy

* fix workflow

* fmt

* fix baby nautilus

* fix nautilus sync

* fmt

* fmt

* clippy

* typo

* fix miri

* remove pyo3 from workspace to packages which need it and make it optional

* go back to AsRef<Path> for nautilus grammar loading

* replace hardcoded python flags for macos build

* typo

* taplo fmt

* revert formatting of libafl_qemu_arch

* ci

* typo

* remove expects in NautilusContext::from_file and make them Results

* remove not(miri) clause in test

* try and fix python build fir ios and android

* again

* android

* tmate

* fix android build

* document load_python_grammar

* log if python or json when loading nautilus grammar

* make nautilus optional

* add nautilus as feature to forkserver_simple_nautilus
2024-10-29 11:32:59 +01:00
Aarnav
58fad2befd
libafl-fuzz: separate frida build + cmplog debug (#2591)
* libafl-fuzz: separate frida build

* cmplog debug

* update

* merge AflStatsStage
move time_tracker stage to LibAFL

* mandate track_hit_feedbacks feature for AflStatsStage

* afl_stats do not hardcode TimeoutFeedback and CrashFeedback names

* typo

* typo

* fix generics order

* add verify timeouts stage

* libafl: introduce set_timeout func to dynamically set timeouts for executor
libafl-fuzz: add verify_timeout stage

* add missing set_timeout implementations

* libafl-fuzz: move set_timeout and timeout from Executor to HasTimeout

* libafl-fuzz: add removed gitignore

* remove timeout from libafl_nyx::Executor and move it to NyxHelper

* clippy

* fix HasTimeout for QemuExecutor

* libafl-fuzz: remove observer handle usage in verify_timeouts
misc: remove prelude imports

* libafl-fuzz: fix foreign_sync_dirs option

* fmt && clippy

* clippy && fmt

* missing doc

* clippy

* bruh

* damned doc build

* trait fix

* impl HasTimeout for InProcessExecutor only if std

* clippy

* fix typo

* fix nostd build

* clippy

* remove most HasTimeout implementations for now

* typo

* remove redundant import

* misc

* fmt

* simplify trait bounds

* add old AflStatsStage back and rename it to StatsStage

* fix ci

* make set_timeout and timeout of HasTimeout inline

* fmt

* add gitignore

* serde_any fix

* tmate

* misc

* remove tmate

* test

* coordinate between capture_timeout and verify_timeout

* makefile

* fix

* fix

* fmt

* increase cmplog timeout

* semantic

* debug

* debug

* remove dbeug

* only test libafl-fuzz on CI for now

* better seed for cmplog?

* remove preflight check for now

* set Input type in forkserver

* debug

* tmate

* fix capture_timeout

* revert workflow

* run only libafl-fuzz

* remove pre-flight

* re-enable fuzzers on CI

* move capture_timeouts and verify_timeouts to main lib

* run fmt

* add note for verify timeouts

* add note in verify timeouts stage

* typo

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-10-28 11:40:04 +01:00
3d0c0247b7 trace mem bytes read 2024-10-28 08:12:30 +01:00
d89d5e3e5e introduce JobInstance, TaskJob 2024-10-28 08:10:45 +01:00
Dominik Maier
42b306a39f
Fix LibAFL-fuzz build (#2634) 2024-10-26 02:03:22 +02:00
WorksButNotTested
03af6aaf0c
Frida scripting support (#2506)
Co-authored-by: Your Name <you@example.com>
2024-10-25 17:18:25 +02:00
Marco C.
053d125254
fix clippy redundant field names in struct initialization (#2633) 2024-10-25 16:07:34 +02:00
Marco C.
b9e6363826
Avoid using feature flags and env variable to set the same parameter pt.1 emulation_mode (#2512)
* Remove emulation_mode env variable and custom cfg

* Using only the feature flag simplifies things a bit and allow the usage of optional dependencies

* Do not use --all-features on libafl_qemu

* Add missing target_os = "linux"
2024-10-25 15:16:55 +02:00
Dominik Maier
e27ec269ce
Add TargetBytesConverter to allow Nautilus for ForkserverExecutor (#2630)
* Add TargetBytesConverter to allow Nautilus for ForkserverExecutor

* ci

* ci

* More

* fmt
2024-10-24 14:10:26 +02:00
Reverier Xu
261b6b5a52
minor: fix mutable reference warning in examples (#2631) 2024-10-24 12:25:39 +02:00
Langston Barrett
dfd5609c10
bolts: Simplify definition of nonzero! macro (#2624)
* bolts: Simplify definition of `nonzero!` macro

* Non-Usize NonZero

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-10-24 00:28:47 +02:00
d8a15adb1d move codepieces 2024-10-22 14:25:51 +02:00
c5c9a052e4 remove interval_name from interval, fix snakefile showmap 2024-10-22 09:05:21 +02:00
Romain Malmain
d96d833760
Support on_crash & on_timeout callbacks for libafl_qemu modules (#2620)
* support (unsafe) on_crash / on_timeout callbacks for modules

* use libc types in bindgen
2024-10-21 17:59:04 +02:00
f9f59211fb do not use error as objective for showmap 2024-10-21 17:29:56 +02:00
a7f24da786 show function ranges 2024-10-21 17:14:14 +02:00
8417613cb2 save stats per abb 2024-10-21 17:13:38 +02:00
Dongjia "toka" Zhang
f0da4d15da
Fix Generator (#2627)
* no min but max

* import

* large stack arrays ?
2024-10-21 16:27:25 +02:00
Dongjia "toka" Zhang
fda1596ee2
Use nonzero! macro (#2589)
* nonzero_lit

* nonzero

* std instead of core

* a

* l

* test

* import

* api

* api

* aaaaa

* apiapi

* api

* api

* api

* mm

* api

* non zero

* FMT

* pls

* nnnaaasdfadsfafdsa

* pls

* MM

* fix

* a

* sat add

* aa

* mistake

* unreachable

* no generic

* api change

* a
2024-10-18 23:33:03 +02:00
926ad96b8e print hash on graph nodes 2024-10-18 15:04:47 +02:00
d4e6de3e80 shrink moving average window size to ~5 min 2024-10-18 13:18:44 +02:00
735fc3e144 collect first n error inputs as objectives, fix configs 2024-10-18 13:08:13 +02:00
bf827c077f use moving average success rate for interrupt mutation frequency 2024-10-18 11:09:44 +02:00
Romain Malmain
3b31b4d796
libafl_qemu: unset thumb bit for breakpoints (#2619)
* unset thumb bit for breakpoints
2024-10-17 09:42:56 +02:00
Romain Malmain
23e966c702
Fix CI apt-get install (#2618) 2024-10-16 13:17:34 +02:00
Romain Malmain
31e31b662d
Adapt qemu linux fuzzers to latest LibAFL version (#2616) 2024-10-16 10:41:37 +02:00
3a126cb0a8 target_symbols.csv++ 2024-10-15 17:02:08 +02:00
Dominik Maier
4710915b61
Revert "Revert "Fix pipe I/O in forkserver"" (#2614)
* Revert "Revert "Fix pipe I/O in forkserver (#2602)" (#2612)"

This reverts commit 888c608e5e56e2df55271dab262bb0eac400a416.

* More expressive errors

* fix testcase
2024-10-15 16:31:25 +02:00
875f87f0c6 fix detection of releases by api call 2024-10-15 16:22:42 +02:00
Romain Malmain
d48a7d508d
Centralize clippy lints in workspace (#2606)
* centralize clippy definition

* fmt

* add update bindings script

* add a checked and unchecked version of memory read to qemu stuff

also, a lot of clippy thing

* update binding position

* rm old script, new one is a bit better

* update doc

* macos clippy

* adapt fuzzers

* windows clippy

* fix fuzzer

* windows clippy

* remove old allowed clippy

* remove some allowed clippy

* use default features for serde_json in gramatron

* better error handler for failed rw to memory
2024-10-15 13:31:01 +02:00
Dongjia "toka" Zhang
453d733a35
Use .vscode/settings.json.default (#2615)
* .gitignore .vscode

* vscode

* vscode

* ignore
2024-10-14 15:45:17 +02:00
Dongjia "toka" Zhang
888c608e5e
Revert "Fix pipe I/O in forkserver (#2602)" (#2612)
This reverts commit ea4a281d535cce1b522ed0fb328f02b016a4b4ea.
2024-10-14 14:17:40 +02:00
Henry Chu
ea4a281d53
Fix pipe I/O in forkserver (#2602)
* Fix read_st_size in forkserver

* fixed read_st, read_st_size, and write_ctl

with read_exact and write_all

* Cleanup redundant return values in forkserver pipe I/O

* Forkserver: avoid using read_exact/write_all for reading/writing integers

* Forkserver: avoid initializing the vec twice when reading a chunk of bytes

* Fix code formatting
2024-10-14 11:49:06 +02:00
Dominik Maier
da8f17f29e
Add AFLStats to QEMU_Launcher TUI (#2611)
* Remove prelude from qemu_launcher

* QEMU_Launcher: Add stats to TUI

* More tui
2024-10-14 11:06:21 +02:00
Dominik Maier
1ad64e7ae7
Remove prelude from qemu_launcher (#2610) 2024-10-14 10:53:02 +02:00
Dominik Maier
d29b657bf4
Add LibAFL_Jumper util (#2594)
* Add jumper

* Hex Hex

* Fix hex decoding

* Cleanup readme

* Build with musl

* add mips delay slot back

* Added linker script

* More jump

* clippy

* taplo
2024-10-12 13:16:33 +02:00
Dominik Maier
cad9e2717e
Remove prelude from default features (#2608)
* Remove prelude from default features

* Prelude

* something
2024-10-12 13:16:22 +02:00
Romain Malmain
18fb6a4197
[libafl-qemu-bridge] fix rpath regex for Ubuntu (#2609) 2024-10-11 18:56:51 +02:00
Dominik Maier
66a8682c9e
Add DrCov &.rerun options to QEMU_Launcher (#2607)
* Move all target-specific code to harness.rs

* Add IfModule to LibAFL_Qemu

* More more

* Added DrCov tracing

* Add DrCov rerun to launcher

* fixes
2024-10-11 16:02:01 +02:00
Dominik Maier
2bfed2d488
Move all target-specific code to harness.rs (#2605) 2024-10-11 12:41:42 +02:00
Dominik Maier
830941ce3a
Rename LibAFL_GdiPlus to _Windows_ (#2604)
* Rename LibAFL_GdiPlus to _Windows_

* Readme more
2024-10-11 10:52:39 +02:00
8f0e54053b WIP: try removing interrupts within min interarrival 2024-10-10 17:56:08 +02:00
2ca6fdf538 simplify stored execution times per testcase 2024-10-10 16:33:19 +02:00
Dongjia "toka" Zhang
19ccb0807c
Don't do generalization on larger inptus (#2603) 2024-10-10 16:13:08 +02:00
bae801c620 remove shortcut from benchmark features 2024-10-10 15:24:54 +02:00
04cfa7cea2 report interrupt mutation statistics 2024-10-10 15:15:23 +02:00
7586c51f6f disable release warnings 2024-10-10 15:14:56 +02:00
6d197274dd snakemake: increase build efficiency 2024-10-10 15:14:13 +02:00
Henry Chu
a69cd98432
Make ASAN log dumping optional (#2600) 2024-10-10 09:44:26 +02:00
jejuisland87654
efa99ee3c9
Fix error[E0308]: mismatched types for libafl_qemu_init (#2593) 2024-10-09 17:17:51 +02:00
Romain Malmain
c03653f7be
Remove useless allocation in colorization stage (#2598)
* do not allocate here

* clippy
2024-10-09 17:16:53 +02:00
cube0x8
1e4d38d744
Fix file sync timing and prevent crash on missing SyncFromDiskMetadata (#2595)
* max_time is the current_time(); SyncFromDiskMetadata might not be in state

* using metadata_or_insert_with
2024-10-09 17:16:32 +02:00
cube0x8
2b05e0a1fd
Do not start another logger in prometheus (#2599) 2024-10-09 17:15:56 +02:00
d4ee679d0e fix trace seection when no instance was found, comments++ 2024-10-09 16:16:12 +02:00
Romain Malmain
c1ddcb2eed
Update frida to 0.14.0 (#2596)
* update frida crate to the latest version

* adapt libafl_frida to the latest version of frida
2024-10-09 11:13:43 +02:00
Dongjia "toka" Zhang
c12c6f31e2
Change fuzzbench_qemu fuzzer (#2520)
* change fuzzbench_qemu

* real test

* fix qemu crash hook

* update bindings

* fix fork executor, reduce trait bound overhead

* make EdgeModule depend on observer to get ptrs.

* do not make EdgeCoverageModule::new public

* map observer as builder call

* adapt examples with new edge coverage module builder.

* TMP: everyone is a variable length map observer

* reuse profile path script

* fix absolute paths

* remove some dependencies to make pipeline faster

* compile-time builder initialization check

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-10-08 15:18:13 +02:00
Romain Malmain
7344fdf059
Re-add drcov for both usermode and systemmode. (#2573)
* re-add drcov for both usermode and systemmode.
2024-10-07 14:20:11 +02:00
Dominik Maier
27677a6461
LibAFL_QEMU: Don't require extra_tokens. (#2576)
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-10-07 13:39:55 +02:00
Romain Malmain
1fbb18cb99
Versioning unification, dependencies update, logging optimization (#2560)
* versioning unification: use x.y.z format everywhere

* do not compile low-level logs (< info level) by default in fuzzers

* update dependencies to the latest versions

* add members to workspace.

* use workspace for common dependencies

* add vscode native support

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-10-07 12:03:29 +02:00
Dominik Maier
4fc136cd1c
Rand below should take a NonZero parameter (#2519)
* Rand below should take a NonZero parameter

* More

* more

* More

* fix build

* bit of clippy

* more clippy

* more clippy

* More clippy

* More more

* more nonzero

* fix multipart

* Cleanup, more unsafe

* fix

* fix unicode

* clippy, fmt

* more

* More safer and more better

* MaxStackPow

* fix merge fails

* make random_slize_size faster

* fix

* more

* fix
2024-10-04 02:16:10 +02:00
Romain Malmain
15157e0b72
Discard no tc mm (follow-up) (#2584)
* forgot to set the flags
2024-10-03 20:26:28 +02:00
Romain Malmain
9a50868058
Discard non-new testcase events for multi-machine messages (#2583)
* discard non-new testcase events

* clippy
2024-10-03 18:46:26 +02:00
Romain Malmain
9ceb9917a5
Do not embed client exec count in testcase and objective (#2582)
* do not include exec count in testcase

* remove exec count from objective as well

* fmt
2024-10-03 16:42:11 +02:00
Marco C.
9b0eccf73b
Do not require Sized for OwnedRefMut as_ref/as_mut (#2581) 2024-10-03 13:35:00 +02:00
Romain Malmain
76d52bcf49
Addr filter update helper functions (#2575)
* add filter update helpers

* fmt
2024-10-02 14:26:46 +02:00
Dongjia "toka" Zhang
cbce7ffdfd
No Uses* for Feedbacks (#2578)
* add from addison's change

* fixing

* one left

* adding

* 444444

* okoko

* no prelude

* i hate rust

* stuff

* no std/win

* getting closer

* a

* a

* aa

* a

* a

* libafl_fuzz

* toml

* tutorial

* libafl_libfuzzer
2024-10-02 14:07:08 +02:00
Dongjia "toka" Zhang
a212d66afe
No Uses* for Observers (#2568)
* first

* Round 2

* Round 3

* Round 4

* Round 5

* Round 6

* Round 7

* Round 8

* clp

* from windows

* roll back

* baby building

* doc

* no deref

* frida

* api

* a

* impl HasLen

* libafl-fuzz and fmt

* asan error

* Cargo toml

* who cares abotu freebsd seriously?????

* aaaa

* qemu stuf

* fixing what i can fix

* nyx

* more for qemu stuf

* fixup libfuzzer

* fix baby swap

* AsIterMut

* UsesObservers eliminated

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-10-01 17:51:09 +02:00
Romain Malmain
173aeddbcc
libafl multimachine: disable ratelimiting (#2558)
* disable rate limiting for now

* fix

* clippy

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-09-30 15:57:10 +02:00
Romain Malmain
17def0390d
fix (#2571) 2024-09-30 13:12:23 +02:00
Dominik Maier
82110472d6
Mark unsafe functions unsafe, as Ferris intended (#2559)
* Mark unsafe functions unsafe, as Ferris inteded

* More

* more safety?

* more fix

* actually safe

* More cleanup

* More fix

* more unsafe

* fix imports

* more unsafe

* fixes

* bring back the memories
2024-09-28 16:46:39 +02:00
20urc3
afb682bff2
Update README.md (#2518)
* Update README.md

Re-structure the first page to be a bit more appealing
- Regrouping getting started and fuzzer example in one sub-section
- Separate installation guide in a different sub-section
- Moving 'Why LibAFL'' further in the page
- Removing spacing/newline to group info together

* Update README.md

- Fixing typo
- Improving layout

* Update README.md

Cleaner readme
- overview and why libafl merged 
- resources and quick started cleaned

* Update README.md

- Build instruction before getting started

* Update README.md

* Update README.md

- Separate Why LibAFL and Overview section

* Update README.md

* Update README.md

* Update README.md

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-09-27 18:30:30 +02:00
Dominik Maier
d72fa6ca6f
Cleanup the README a bit more (#2569)
* Move fuzzers around some more

* back to baby

* this was missing..

* shuffeling shuffeling

* shuffeling

* md

* cleanup

* oops

* Move foldername to underscore

* more doc

* Add links

* cleanup
2024-09-27 18:18:50 +02:00
Dominik Maier
4b99c69e51
Move fuzzers around some more (#2566)
* Move fuzzers around some more

* back to baby

* this was missing..

* shuffeling shuffeling

* shuffeling

* md

* cleanup

* oops

* Move foldername to underscore

* more doc
2024-09-27 18:14:13 +02:00
66a87835be feedback: ignore abbs outside select interval 2024-09-27 16:23:30 +02:00
5ffac514ca rework release detection with nested interrupts 2024-09-27 15:24:06 +02:00
Dongjia "toka" Zhang
23168af003
Delete redundant elapsed_since_signal from Batch timeout (#2567) 2024-09-27 14:36:44 +02:00
Dongjia "toka" Zhang
79b8390214
No Uses* for Corpus, Mutators (#2547)
* wip

* this shit is crazy

* from windows

* fmt

* fuck

* fmt

* aa

* reduce generics for generator

* do stuff for mutators, too

* aa

* a

* fmt

* idk

* getting things compiling

* fix merge

* idk

* fuzzers

* nire

* more

* a

* frida win

* cmin

* mm

* qemu?

* del ubuntu dep

---------

Co-authored-by: Your Name <you@example.com>
2024-09-26 20:03:03 +02:00
Romain Malmain
79cd1afec0
Move linkspector config file out of workflow dir (#2565) 2024-09-26 18:37:38 +02:00
Romain Malmain
42b3199807
Change action for MD link checks (#2563)
* change MD link action checker

* fix md files
2024-09-26 16:29:32 +02:00
Dominik Maier
0c2b821d37
Clippy more (#2562) 2024-09-26 14:32:52 +02:00
Romain Malmain
c944a70056
Linux kernel fuzzing example (#2496)
* linux kernel (x509_cert) and process fuzzing example

* rework filters

* update to latest qemu

* working for process and kernel fuzzing

* new i2s mutator for binary only fuzzers

* refactoring modules with new filtering interface

* add state as parameter of harness

* hide unused global in usermode

* Script for stub bindings generation

* do not try to check whether it is worth generating the bindings, always
  generate when the env variable is on.

* add taplo to fmt_all.sh

* Moved fuzzers (again) in a target-centric way.

* fix rust 2024 warnings.

* new libafl_qemu harness structure.

* rename qemu_systemmode into qemu_baremetal

* fix qemu baremetal makefile

* fix formatter

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-09-26 14:29:33 +02:00
Nils Bars
5ab7a07f14
Only track stability for runs that did not timeout (#2561) 2024-09-26 14:12:33 +02:00
Dongjia "toka" Zhang
3d1f0bfb0d
Fix CI (#2557)
* libafl-fuzz: fix id collision in Solution corpora

* libafl-fuzz: use dynamic map size

* print

* use PROJECT_DIR

* tmate

* idk

* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* a'

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
2024-09-25 15:45:48 +02:00
Dan Blackwell
4e54182b35
Use const to Inform CmpLog Replacements (#2528)
* Add some knowledge of const parameters in cmplogs

* Careful with the CmpLog unions and clean macros

* Fix for macros?

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-09-24 17:16:07 +02:00
Dominik Maier
36a082048d
CI for libafl-fuzz (#2554) 2024-09-24 16:18:06 +02:00
Dominik Maier
2bc211cc86
Make map size mismatch return a proper error instead of abort (#2553)
* Make map size mismatch return a proper error instead of abort

* More illegal state
2024-09-24 15:09:39 +02:00
Dominik Maier
c559b856e6
Clippy for LibAFL_QEMU (#2552) 2024-09-24 15:05:16 +02:00
Sharad Khanna
629a560f3b
MacOS frida ASAN fix (#2510)
* Add asan fix

* fmt

* ASAN linux fix

* Revert fmt

* Fix libafl_cc

* do fmt

* revert libaflcc

* clippy + fmt

* clippy

* change assert

* fix unpoison + other issues

* fmt

* format toml

* explore submaps

* fmt
2024-09-24 07:56:27 +03:00
Andrea Fioraldi
72893797b4
Fix panic in mmap shmem when full_file_name is less than MAX_MMAP_FILENAME_LEN (#2536)
* Fix panic in mmap shmem

* duh

* clippy

* fix null bytes

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-09-24 03:37:03 +02:00
Nils Bars
bacbffa6c1
Keep num_covered_map_indexes in sync with history map if block listing flaky entries (#2542) 2024-09-24 03:31:32 +02:00
Dominik Maier
f0d85aaaa5
No more (direct) mutable references to mutable statics (#2550)
* No more (direct) mutable references to mutable statics

* More

* Fix build, but it's unsafe dude

* more

* fmt

* More fix

* more?
2024-09-24 03:29:49 +02:00
Dominik Maier
691fd1f8cb
Make LibAFL-fuzz build on MacOS (#2549)
* Make LibAFL-fuzz build on MacOS

* Works on MacOS

* Update AFL++

* libafl-fuzz: fix CI cmplog (#2548)

* undo

* clippy

* clippy

---------

Co-authored-by: Aarnav <aarnavbos@gmail.com>
2024-09-24 03:25:20 +02:00
Dongjia "toka" Zhang
967449e3cb
Fix CI (somewhat) (#2546)
* fix ci

* a

* order

* libafl-fuzz: fix CI cmplog (#2548)

---------

Co-authored-by: Aarnav <aarnavbos@gmail.com>
2024-09-24 03:18:15 +02:00
Aarnav
7432bd0f59
libafl-fuzz: fix libafl-fuzz scheduler (#2545) 2024-09-23 18:56:09 +02:00
Aarnav
085db55f19
libafl-fuzz: fix not loading seeds recursively from directories (#2532)
* libafl-fuzz: fix not loading seeds recursively from directories

* add walk_initial_inputs to State

* libafl-fuzz: add afl++ style seed filename when copying initial files

* typo
2024-09-23 18:55:01 +02:00
Dongjia "toka" Zhang
cbfd194723
Reducing type parameters and bounds from Scheduler (#2544)
* actually reducing type parameters

* no std

* aa

* aa

* a
2024-09-23 17:01:21 +02:00
Dominik Maier
35779863c4
Bring back placeholder value in CommandExecutor to fix #2541 (#2543) 2024-09-23 15:59:06 +02:00
Dominik Maier
173a9ad8ea
Fix ForkserverExecutorBuilder::shmem_provider (#2539) (#2540)
* Fix ForkserverExecutorBuilder::shmem_provider (#2539)

* fmt
2024-09-23 14:15:11 +02:00
Dongjia "toka" Zhang
93fdbb604c
No Uses* (again) (#2537)
* ihatethislanguageihatethislanguageihatethislanguageihatethislanguage

* 1

* a

* fuck

* FMTFMTFMTFMTFMTFMT

* 👍

* afasdfadsfs

* lol

* aa

* a bit more
2024-09-23 14:03:24 +02:00
Valentin Huber
e370e2f852
Code Cleanup of #2422 (#2534)
* code cleanup

* removing another unnecessary borrow

* cleaning up the cleanup
2024-09-20 17:39:09 +02:00
Valentin Huber
2c676f0352
Add MappedInputs to allow havoc muations for custom (sub-)inputs (#2422)
* introducing MappingMutator

* extending mapping mutators

* adding example fuzzer

* making crossover mutators more flexible.

* moving example fuzzer

* fixing dependency paths

* formatting

* fixing no std error

* fixing broken docs link

* fixing import paths

* fixing imports

* more format fixing

* adding new example fuzzer to CI

* fixing further imports

* fixing formatting

* formatting fixes

* improving docs for the example fuzzer

* adding documentation and tests to mapping mutators

* make extraction function for mapped crossover mutators more general

* adding MutVecFunctionMappingMutator

* Introducing WrapsReference

* code cleanup for mapping mutators

* adding tests and docs to mapping mutators

* reformatting comments

* fixing merging of mutators in example fuzzer

* formatting

* formatting v2

* cleanup according to PR comments

* adding type constraint to MappedInput helper functions to remove the need to specify types

* matching functions passed to mapped_havoc_mutations

* removing unnecessary constraints

* mapping mutators now contain the name of their inner mutator

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-09-18 23:23:04 +02:00
Dongjia "toka" Zhang
5b7d307a6a
Add avoid_crash option to scheduler (#2530)
* chg

* add avoid_crash

* a

* clp

* just use .00 at this point

* libafl-fuzz chg
2024-09-18 17:57:40 +02:00
Dongjia "toka" Zhang
902571c0c7
Delete pruning.rs (#2533)
* set AFL_MAP_SIZE

* delete it
2024-09-18 17:35:31 +02:00
Dongjia "toka" Zhang
4e302a2115
Set AFL_MAP_SIZE in forkserver (#2531)
* set AFL_MAP_SIZE

* aaaaaaa
2024-09-18 17:03:48 +02:00
Dongjia "toka" Zhang
cf87895aaa
Change qemu signature (again) (#2529) 2024-09-18 14:48:53 +02:00
fb3837f725 fix out of bounds interrupt mutation 2024-09-17 17:09:48 +02:00
Dongjia "toka" Zhang
4c5df53c6d
Change Qemu hook signature (#2527) 2024-09-17 17:05:11 +02:00
Nereuxofficial
69941f258e
Small improvements to the devcontainer (#2522)
* feat: revert now unecessary workaround, use rust-lang.rust-analyzer

* fix: specify llvm version and symlink llvm. Thanks @tokatoka

* fix: pass the llvm version to createAliases.sh

* fix: shell script lints

* fix: shell script lints

* feat: use cargo binstall to make the container build faster
2024-09-16 22:53:28 +02:00
a9ce2d787b fix flags 2024-09-16 15:58:19 +02:00
Marco C.
37f2d2dd0a
Move cfg to avoid unused import error (#2526) 2024-09-16 15:19:01 +02:00
0d89787728 use smaller seeds for testing 2024-09-16 14:52:42 +02:00
Dominik Maier
a168d76b14
Tiny clippy (#2525) 2024-09-16 12:21:58 +02:00
20urc3
71ed5c7227
Update how exec/sec is displayed (#2524)
- Only display 1 digit after . for value above 1k
- Only display 2 digits after . for value above 1m

3.254k exec/sec becomes => 3.2k exec/sec
3.254M exec/sec becomes => 3.25M exec/sec
2024-09-13 21:03:18 +02:00
5b662397be fix array index 2024-09-12 16:02:11 +02:00
b390315a5d fix ambiguity 2024-09-12 15:48:46 +02:00
26452d9a0d config generation 2024-09-12 13:43:53 +02:00
8165fd7cfc refactor interrupt mutation 2024-09-12 13:19:28 +02:00
835d1e1a79 seed 10k 2024-09-12 09:18:02 +02:00
Dominik Maier
8ccff4b77f
Add StdState::nop() for simple state creation, make CI happy again on latest nightly. (#2521)
* Make CI happy again on latest nightly

* Fix build

* Unneeded comment

* fix tests

* clippy
2024-09-12 00:33:55 +02:00
e6cf64541d better seeding + trace cutout 2024-09-10 16:18:25 +02:00
6a98489e32 fixes++ 2024-09-10 11:22:46 +02:00
90acd4fc9f fix scripts 2024-09-10 11:11:37 +02:00
db037f5015 fix empty interrupt config 2024-09-10 10:45:37 +02:00
7896342ed9 fix target names 2024-09-10 10:40:52 +02:00
7139a94a1b adapt scripts 2024-09-09 16:07:03 +02:00
7ad2f6fa6b rename keys 2024-09-09 16:06:41 +02:00
5648faefa7 fix all_bins 2024-09-09 12:55:30 +02:00
3bb42150d3 unify fuzzing with and without interrupts 2024-09-09 12:51:23 +02:00
740ce09d31 configurable interrupt sources 2024-09-09 10:56:39 +02:00
Dominik Maier
25624d8eec
Rename HasCurrentStage to HasCurrentStageId for consistency (#2514) 2024-09-08 10:21:49 +02:00
ThomasTNO
70f1c13a4f
Remove redundant line (#2516)
* Remove redundant line

* No need to mut this value
2024-09-08 02:37:23 +02:00
ThomasTNO
a5584bf23a
Fix typo in error message (#2515) 2024-09-07 14:23:12 +02:00
Dongjia "toka" Zhang
1172b5e5e0
Fix build and remove dump_state feature (#2513)
* fix

* remove dump_state
2024-09-06 14:22:33 +02:00
288abeb6bf prepare multiple interrupt sources 2024-09-06 08:38:30 +02:00
Dongjia "toka" Zhang
b37f9d4b27
Better error when non required pass failed to build (#2509) 2024-09-05 19:17:21 +02:00
Dongjia "toka" Zhang
49b0d7557a
Fix merge failure (#2508) 2024-09-05 14:49:37 +02:00
ee737b9eb8 improve benchmark scripts and excution fixes 2024-09-05 09:55:21 +02:00
Romain Malmain
203d3d340a
Multi machine follow-up (#2334)
* improved tree generator.
possibility to dump state on exit.

* warnings.

* clippy

* clippy

* aaaaaa

* aaaaaa

* make nix mandatory for unix

* stddddddd

* stddddddd

* stddddddd

* aaa

* clippy

* doc

* aaa

* aaa

* aaa

* aaa

* fix

* aaaaaaaa

* dump state

* aaa

* aaa

* aaa

* more minimal dump

* aaa

* aaa

* aaa

* simpler tc dump

* pub

* more pub

* revert a bit

* release by default

* delete Makefile.toml

* release

* dump execs

* merge

* delete stuff

* aa

* ff

* dig

* FMT cargo stuf

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-09-04 18:42:54 +02:00
6929073069 update benchmark script 2024-09-02 16:26:58 +02:00
8adc1e2624 debug msg ++ 2024-09-02 15:53:59 +02:00
Sharad Khanna
1113879a34
Fix i2srandreplace (#2504) 2024-08-30 14:15:26 +02:00
06b523fb9f fix release-resposne matching bug 2024-08-30 14:02:21 +02:00
a613a803ca detect job releases during race-conditions 2024-08-29 11:24:32 +02:00
2c00f82d39 fix task releases with nested interrupts 2024-08-28 14:16:03 +02:00
461731cc5a fix: fallback to 0 response-time if target job did not finish 2024-08-27 13:15:38 +02:00
Sharad Khanna
a8bccf9f25
Minimizer fix (#2500)
* Clear potentially out of date id

* fmt

* add mut
2024-08-27 04:26:36 +02:00
Aarnav
3ca906b7d3
Libafl-fuzz: fix unicorn mode (#2502)
* libafl-fuzz: fix unicorn mode not using a deferred forkserver
libafl-fuzz: simplify handling args for harness

* fix unicorn_mode

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-08-26 19:30:38 +02:00
Dominik Maier
e2cc78f274
Better documentation headers (clippy) (#2501)
* Better documentation headers (clippy)

* more doc

* more fixes

* Even more

* more

* even more

* concrete

* fmt

* even more more

* tiny typo

* more

* more

* More

* more

* more docs?

* more docs
2024-08-26 16:31:22 +02:00
0b4e9bdab7 add time helper function 2024-08-26 15:50:59 +02:00
11028d7aae change interrupt randomization rule 2024-08-26 15:46:11 +02:00
ae6b3c0650 maybe fix interrupt bytes not changing 2024-08-26 15:45:32 +02:00
8e885f6e85 fix some helper-scripts 2024-08-26 15:20:48 +02:00
9d83ddbd69 low prio warnings-- 2024-08-26 15:18:46 +02:00
c785e0db86 fix jobs with response==release 2024-08-26 15:18:46 +02:00
f14d486ccf skip mutation of 0 size inputs 2024-08-26 15:10:12 +02:00
a18a5f9bcf fix everything interesting 2024-08-26 15:10:12 +02:00
Aarnav
07db74b416
Libafl-fuzz: introduce unicorn mode (#2499)
* libafl-fuzz: introduce unicorn mode

* taplo format

* libafl-fuzz: fix qemumode

* taplo format
2024-08-26 11:32:44 +02:00
Marco C.
a388012429
Do not use caret requirements (#2498) 2024-08-24 00:02:37 -05:00
Romain Malmain
1f55458293
Fix fmt & remaining md links (#2497) 2024-08-22 19:08:44 -05:00
Alexander Qi
0018f7e406
bolts: Support dump_registers on Windows/x86 and Windows/aarch64 and fix sig_ign on Windows/x86 (#2494)
* bolts: Support dump_registers on Windows/x86

* bolts: Support dump_registers on Windows/aarch64

* bolts: Fix sig_ign() on Windows/x86

* bolts: Fix format of dump_registers under Windows

* bolts: Add test for dump_register under Windows
2024-08-22 18:22:24 -05:00
Marco Grassi
1dfd225b1b
Fix fuzzer links in the libafl book (#2493)
* the rustup official command to update is 'rustup update' not 'rustup upgrade', although to catch mistakes, 'rustup upgrade' also fallback to update

* fix references to baby_fuzzer and baby_fuzzer new location

* modernize a bit the manifests and code snippets for the baby_fuzzer to make the experience more consistent with the current rust compiler

* fix another reference path for baby fuzzers

* fix frida fuzzers locations in the book

* fix the concolic hybrid fuzzers location in the book

* fix baby_no_std location in the book

* fix nyx fuzzers location in the book

* Revert "modernize a bit the manifests and code snippets for the baby_fuzzer to make the experience more consistent with the current rust compiler"

This reverts commit c58bfbfffd06a3afa8338043dde6ed59b03d8178.
2024-08-22 18:15:36 -05:00
Romain Malmain
8d0ad23856
Check markdown links validity in CI (#2495)
* add markdown link check in ci

* fix broken links when possible.
configuration file for md checker.

* accept code 200...

* more fixes

* more fixes

* more fixes
2024-08-22 18:15:15 -05:00
Dongjia "toka" Zhang
f856092f3d
Fix libxml2 on fuzzbench (#2492)
* fix

* fmt

* fuck

* from windows

* fix

---------

Co-authored-by: Your Name <you@example.com>
2024-08-21 16:41:18 +02:00
Romain Malmain
4b87d7f4eb
Custom QEMU emulator typed builder + ExitHandler / Commands refactoring (#2486)
* Add a custom typed builder for Emulator

* Unify qemu_init for usermode and systemmode

* Remove env from qemu init args (it is unused in QEMU in practice)

* expose thread hooks to systemmode

* rename qemu_config to config

* Replace ExitHandler by EmulatorDriver

* Reorder generics alphabetically for Qemu{,Fork}Executor

* Moved snapshot manager to Emulator to continue centralizing mains objects in the same structure

* Reimplementation of CommandManager working with enums instead of tables

* Macro has been adapted to do this work automatically

* Moved snapshot stuff to dedicated module

* Removed many Rc<RefCell<...>>, now useless with the removal of vtables

* Builder given by Emulator via `Emulator::builder`. Reduced trait bound overhead
2024-08-21 16:36:45 +02:00
Marco Grassi
16aa218457
Fix rustup command in the LibAFL book (#2491) 2024-08-20 22:49:32 -05:00
bd7ddaffbd fix releases 2024-08-20 12:20:55 +02:00
6995cd053b fix snakefile 2024-08-19 16:28:11 +02:00
e9fb73e65b WIP: per-task response times 2024-08-19 16:08:45 +02:00
Dongjia "toka" Zhang
eb3dff07b6
Add more missing ngram8 cfgs (#2490)
* fix dump cfg

* add missing cfg

* more

* taplo fmt
2024-08-19 14:39:21 +02:00
Dongjia "toka" Zhang
7a5c695401
Add missing ngram8 cfg (#2489)
* fix dump cfg

* add missing cfg
2024-08-19 14:23:47 +02:00
bf7ad374a0 stupid bug fix
stupid bug fix
2024-08-19 10:22:31 +02:00
de9c0a6d1e WIP: input snippet mutation 2024-08-16 09:58:21 +02:00
Addison Crump
f3433767be
Make pcs_init compatible with multiple DSOs (#2488)
* make pcs_init compatible with multiple DSOs

* clippy
2024-08-15 15:56:41 +02:00
3b6cd3bc45 fix bug causing skipped mutation when part size is 0 2024-08-15 09:38:52 +02:00
Marco C.
21051dc26f
qemu: Add QemuConfig to set qemu args via a struct (#2339)
* Add QemuConfig to set qemu args via a struct

* Add derive macro to automate the qemu string args generation

* fix tests
2024-08-14 15:30:14 +02:00
Romain Malmain
6979032ad9
Qemu generics cleanup (#2484)
* cleanup generics

* remove most extern C

* update qemu to latest revision

* executor trait bounds minimization
2024-08-14 12:55:43 +02:00
72f9de45d0 fix cargo.toml 2024-08-14 09:41:02 +02:00
46aa6cec0f reads behind config flag 2024-08-14 09:10:30 +02:00
b9f0151e87 repeat interrupt mutations 2024-08-14 08:55:23 +02:00
712ac137d7 logging and reporting 2024-08-14 08:50:34 +02:00
920a996d95 multipart seed reading 2024-08-14 08:42:33 +02:00
Romain Malmain
13ba32ed2a
Unify qemu executor (#2483)
* Remove stateless qemu executor

* All harnesses take a reference to an emulator as parameter now

* harness takes an emulator as first parameter, and input as second parameter (opposite of previous definition)

* bump libafl qemu dependencies to the latest version
2024-08-13 19:44:10 +02:00
Romain Malmain
00806b177d
Qemu native hooks refactoring (#2480)
* qemu native hooks refactoring (companion patch of qemu-libafl-bridge#82)

* update stubs
2024-08-13 18:40:51 +02:00
Aarnav
2287afc59b
libafl-fuzz: Introduce Support for QEMU mode (#2481)
* libafl-fuzz: simplify Makefile.toml

* Re-introduce support for old AFL++ forkserver

* clippy

* libafl-fuzz: add support for QEMU mode

* libafl-fuzz: simplify Makefile
2024-08-13 07:13:59 -05:00
3db17ceb98 WIP: store memory reads 2024-08-12 15:31:56 +02:00
05c17d3159 report state space exporation 2024-08-12 12:07:31 +02:00
Niklas Gögge
799c634fef
Implement FeedbackFactory for {Const,Not}Feedback (#2478)
* libafl: Impl FeedbackFactory for NotFeedback

* libafl: Impl FeedbackFactory for ConstFeedback
2024-08-09 12:24:46 +02:00
Dongjia "toka" Zhang
9b32f85124
Fix dump cfg pass (#2476) 2024-08-06 18:47:49 +02:00
Romain Malmain
723f4a1cb0
Fix various QEMU bugs (#2475)
* Update LibAFL QEMU to the latest version (V9.0.2 update, important bug fixes, ... - check the dedicated repo for more info)
* fix bug in hook execution, causing first execution hooks to be run multiple times.
2024-08-05 23:48:35 +02:00
Max Ammann
3bebbe0dac
Update AsanBacktrace documentation (#2377)
* Add AsanBacktrace documentation

* Update stacktrace.rs
2024-08-05 22:10:46 +02:00
Aarnav
949a25a29a
It's frida time for libafl-fuzz (#2469)
* libafl-fuzz: misc nit in check_autoresume

* libafl-fuzz: add FRIDA mode

* libafl-fuzz: improve Makefile

* libafl-fuzz: fix Ci

* libafl-fuzz: clang-format test-cmpcov.c

* libafl-fuzz: no cmplog for persistent frida

* libafl-fuzz: minor CI fix

* libafl-fuzz: fix frida persistent mode

* libafl-fuzz: add frida seeds

* misc: typo
2024-08-05 18:10:45 +02:00
f8d9363e7e update snakefile 2024-08-04 09:46:39 +02:00
ade004cffb update targets 2024-08-04 09:40:53 +02:00
David CARLIER
291fdeb85e
bolts: fix openbsd build (#2467)
Co-authored-by: dcarlier <dcarlier@openbsdvbox.chello.ie>
2024-08-01 08:14:09 +02:00
Addison Crump
7ee5962288
remove libfuzzer-best recommendation (#2466) 2024-07-31 17:08:34 +02:00
Aarnav
6d4f071eaa
Misc libafl-fuzz improvements (#2463)
* libafl-fuzz: ignore seeds that are not regular files

* libafl-fuzz: remove 4 dict files limit

* libafl-fuzz: clippy

* libafl-fuzz: add -t option

* libafl-fuzz: fix typo in seed feedback
2024-07-31 14:54:11 +02:00
Dominik Maier
8fb80c3f3a
libafl_qemu: Continue build with outdated LLVM, ignore TUI race conditions (#2461)
* libafl_qemu: Continue build with outdated LLVM

* Ignore race condition

* ignore more race conditions, remove useless clones

* fix fixes
2024-07-30 14:48:17 +02:00
Romain Malmain
c319fe2033
Cheap reader for bytes slice (#2261)
* initial draft implementation

* change name to follow rust convention.

* revert use of HasTargetBytes instead of HasMutatorBytes for BytesSubInputMut

* clippy

* nostd

* clippy

* clippy

* * HasLen required if implementing HasTargetBytes.
* Added a checked version of the read to slice.

* clippy

* fix name.
better doc.

* added a common bytes trait for HasTargetBytes and HasMutatorBytes.

* change interface

* fix tests

* clippers

* use byte slice for subbytes

* adapt to main

* fix doc

* mut sub slice version. return subinput to old state, and add subslice stubs

* better api, doc fixes.

* Don't clone, reshuffle

* Move and rename

* Uh-oh

* move to bolts. rename things.

* nostd

* format

* alloc

* fix doc

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dominik Maier <dmnk@google.com>
2024-07-30 13:46:40 +02:00
Dominik Maier
211809dddb
Cmplog bytes without alloc (#2442)
* Cmplog bytes without alloc

* fixes

* clippy

* remove wrong %
2024-07-30 13:42:48 +02:00
Dominik Maier
c4c0fb6750
Update pyo3 (#2459)
* Update pyo3

* Update pyo3 to 0.22

* Fix qemu python

* clippy

* fmt

* nautilus python

* More pyo3

* Make signature more legible
2024-07-29 22:55:28 +02:00
Dominik Maier
651ea027b9
Speedup CI by moving checkout back (#2457)
* Speedup CI by moving checkout back

* apparently not legal

* better?
2024-07-29 17:48:46 +02:00
Aarnav
a863720320
libafl-fuzz: Increase cmplog CI timeout (#2458)
* libafl-fuzz: increase cmplog CI test timeout

* libafl-fuzz: fix cmplog CI
2024-07-29 17:39:34 +02:00
Aarnav
e55cbee107
libafl-fuzz: Fix invalid short param for input_ext (#2456) 2024-07-29 16:33:46 +02:00
Dominik Maier
75af67f1e0
Fix CI after Rust 1.80, update to Ubuntu 24.04 (#2449)
* 0.13.2 (for real this time)

* More 0.13.2

* Make sure this never bites us

* Update ahash

* Fix CI after rust 1.80

* Does 18 work?

* Trying to fix this?

* lol regex

* noble

* works?

* fix llvm-config

* fmt

* Windows?

* more fix?

* more fix

* remove pip

* Add find_python3_version support to libafl_cc

* llvm-config

* more curl

* windows has no apt lol

* more
2024-07-29 15:31:41 +02:00
David CARLIER
bab50f23c5
bolts: fix build warning with missing doc comment for haiku (#2455) 2024-07-28 22:21:06 +02:00
Dominik Maier
6df1b34375
Add Taplo check to CI (#2451)
* Add Taplo check to CI

* more taplo

* Try to make this easier
2024-07-26 18:38:50 +02:00
kvalerio
09a8b1dd80
Revive dead link 🧟 (#2452)
* dead link

* deadlink
2024-07-26 18:37:44 +02:00
Dominik Maier
e83dc792da
0.13.2 (for real this time) (#2448)
* 0.13.2 (for real this time)

* More 0.13.2

* Make sure this never bites us

* Update ahash
2024-07-26 13:41:05 +02:00
Mrmaxmeier
afbdc02c54
Format all tomls with taplo fmt (#2436)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-07-26 10:03:10 +02:00
Aarnav
76e1b4cb1e
Fix cmplog implementation (#2439)
* fix cmplog implementation
only set testcase filepath if filepath is none

* libafl-fuzz: fix minor CI

* add missing fields to AFLppCmpLogOperands

* libafl-fuzz: pin CI AFL version to a commit
fix extended_cmplog_instrumentation

* libafl-fuzz: fix CI

* this should not panic

* aaa

* libafl-fuzz: fix cmplog CI

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-07-25 18:10:21 +02:00
Saketh Reddy
c857b8dd77
Fix markdown issue in fuzzers/libpng/libfuzzer_libpng_cmin/README.md (#2437)
Adds a single `
2024-07-23 16:45:58 +02:00
Dongjia "toka" Zhang
7391c6040b
always update textcase.file_path (#2432) 2024-07-23 15:02:03 +02:00
Mrmaxmeier
c44d361828
CI: Update actions and fix warnings (#2435)
* CI: update to checkout@v4 action

Not sure why they decided to bump a major version. It seems like this is
unnecessary churn: https://github.com/actions/checkout/pull/1436#issuecomment-1737711301

* CI: replace archived `actions-rs/toolchain`

It's been unmaintained for four years and has been throwing warnings in
CI:

> The `set-output` command is deprecated and will be disabled soon.

* CI: Bump `cargo-install` action.

This should fix the remaining warnings in CI?

* CI: mdbook-linkcheck: workaround for build error
2024-07-23 12:44:34 +02:00
Zofyan
0dc94a48c5
Added implementation of tolower in libqasan (based on BIONIC's implementation). This is to make LibAFL more compiler agnostic as this function can be named differently sometimes. (#2421)
Co-authored-by: Sofyan Aarrass <s.aarrass@secura.com>
2024-07-22 15:45:32 +02:00
Niklas Gögge
0999ac5003
libqasan: Add missing return to qasan_swap (#2416) 2024-07-22 15:45:13 +02:00
Aarnav
e6b94f3715
Feature/libafl fuzz misc (#2430)
* libafl-fuzz: add cmplog to CI
libafl-fuzz: add option to specify custom rng sed
libafl-fuzz: add help messages to CLI, add file extension support
libafl-fuzz: adhere to AFL++ cmplog bin path format
libafl-fuzz: avoid races when writing to fuzzer_stats
libafl-fuzz: add time tracking for CalibrationStage, MutationalStage and SyncFromDiskStage

* libafl-fuzz: fix libafl paths

* libafl-fuzz: remove redundant cmplog check

* libafl-fuzz: ingore UnstableMapEntries when using queue scheduler in afl_stats.rs
libafl-fuzz: track max_depth for QueueScheduler
libafl-fuzz: fix custom input file

* libafl-fuzz: fix Makefile

* clippy
2024-07-22 15:43:47 +02:00
s1341
695184169e
frida: make hooks thread local (#2429)
* frida: make hooks thread local

* Fmt

* clippy
2024-07-22 14:09:08 +02:00
Dongjia "toka" Zhang
f6151f4507
0.13.2 (#2423)
* 0132

* fix
2024-07-19 23:00:37 +02:00
Romain Malmain
82f11c22ad
Various CI improvements + fix wrong format check in CI (#2417)
use of LLVM 19 by default
    LLVM version should be much easier to switch from now on
    a lot of code repetition has been deleted
    removed llvm-related github action
    fix format check
    other small things

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-07-19 22:32:50 +02:00
Scott
747385ae7d
update function from _libafl_exit_call2 to _libafl_sync_exit_call2 (#2392)
Co-authored-by: Scott Powell <scottmpowell@protonmail.com>
2024-07-19 19:01:54 +02:00
Romain Malmain
1205c2144c
Restructure the fuzzers folder (#2409)
* move fuzzers in subfolders

* add readme

* remove redundent fuzzers
2024-07-19 18:24:24 +02:00
Aarnav
c22a62c32a
libafl-fuzz: add IndexesLenMinTimeScheduler back (#2426) 2024-07-18 16:47:00 +02:00
Dongjia "toka" Zhang
78a30c4403
Fix baby fuzzer tui (#2425) 2024-07-18 14:56:21 +02:00
Dongjia "toka" Zhang
56d70accf5
Fix cmin (#2420)
* fix minimizer

* clp
2024-07-18 11:11:37 +02:00
Dongjia "toka" Zhang
4f970baa7b
Change Corpus Pruning algorithm (#2418)
* push

* upd

* add last found time

* add common as prerequisite

* clp

* aa

* more clp

* fix how to get corpus id

* pruning

* aa

* no std

* fix

* working?

* push
2024-07-18 11:11:14 +02:00
Dongjia "toka" Zhang
536f00a056
Don't panic even if bitmap is zero in calibrate.rs (#2419) 2024-07-17 18:26:17 +02:00
Romain Malmain
c96ea616fe
Qemu helpers & hooks refactoring (#2267)
* Helper is now called Module.

* Emulator now contains hooks state.

* Emulator is managed by QemuExecutor.

* QEMU hooks have been completely refactored on the rust side.

* Generics cleanup.
2024-07-17 11:46:42 +02:00
Axel Souchet
f5e47c33fb
Documentation fix in 'Design' > 'Architecture'. (#2412) 2024-07-17 11:08:29 +02:00
Aarnav
b9da7dd87f
Introduce Persistent Record for libafl-fuzz (#2411)
* libafl-fuzz: fix PERSISTENT_SIG and DEFERRED_SIG

* libafl-fuzz: add AFL_PERSISTENT_RECORD

* libafl-fuzz: update README
2024-07-17 00:35:06 +02:00
Dominik Maier
713652e5d8
Better errors for empty registry in AnyMap (#2405)
* Better errors for empty registry

* Make errors non-panic

* clippy
2024-07-16 18:10:18 +02:00
Dongjia "toka" Zhang
f00470ddaa
Corpus pruning stage (#2399)
* push

* upd

* add last found time

* add common as prerequisite

* clp

* aa

* more clp

* fix how to get corpus id

* pruning

* aa

* no std

* fix
2024-07-16 18:04:23 +02:00
__gsch
d8e53d5b65
impl HasEventManagerId for LlmpRestartingEventManager (#2406) 2024-07-16 14:06:56 +02:00
Aarnav
791598228e
fix incorrect interval check in sync from disk stage (#2408)
* fix incorrect interval check in sync from disk stage

* simplify check
2024-07-16 13:52:25 +02:00
Dongjia "toka" Zhang
074a16f844
Fix autotokens (#2407) 2024-07-16 13:04:24 +02:00
Dominik Maier
4370a84bd2
Expose find_new_files_rec in libafl_bolts::fs (#2404) 2024-07-16 04:47:03 +02:00
Dominik Maier
dc93f6c186
Rename load_new_from_drectory to find_new_files_rec (#2403) 2024-07-16 03:35:36 +02:00
Dominik Maier
7850b9bce6
Address recursion Clippy in sync.rs (#2402) 2024-07-16 03:26:45 +02:00
Aarnav
aa21815a97
Introduce libafl-fuzz (#2362)
* Introduce libafl-fuzz

* fix corpus file path

* simplify SeedFeedback

* fix incorrect comment

* add clap::ValueEnum to PowerSchedule as an optional derive if clap is enabled

* UnixShMemProvider replaced with StdShMemProvider for libafl-fuzz

* remove io_error_more feature constraint

* libafl-fuzz: make Ok(()) unreachable in CentralizedLauncher

* libafl-fuzz: make harness_input_stdin to harness_input_type with &'static

* libafl-fuzz: move each feedback to it's own file

* make run_fuzzer_with_stage into a function.
use CachedOnDiskCorpus instead of OnDiskCorpus for Corpora
remove utils file

* remove unecessary clone

* libafl-fuzz: cleanup AFLStatsStage

* move peak_rss_mb to libafl_bolts

* parse envs by hand

* add sensible defaults for map size and broker port

* fix test.sh and corpus_id padding

* add Makefile.toml

* libafl-fuzz update test suite

* libafl-fuzz: clippy

* rename peak_rss_mb to peak_rss_mb_children

* remove minor version constraint for clap

* libafl-fuzz: fix ELF check and instrumentation check in check_binary

* libafl-fuzz: improve Makefile.toml

* simplify fuzzer and cleanup typos

* libafl-fuzz: load corpus entries in a multicore fashion

* libafl-fuzz: create output dir if not exists (non-racey)

* libafl-fuzz: add sequential scheduling support
libafl-fuzz: add cmplog options
libafl-fuzz: add test-cmplog.c to CI

* rename peak_rss_mb_children to peak_rss_mb_child_processes

* fix race condition in SyncFromDiskStage, add interval based checking and support for multiple directories.
libafl-fuzz: add support for syncing with foreign fuzzers

* update README

* implement AflScheduler for QueueScheduler.
Add queue_cycles field to
AflScheduler

* libafl-fuzz: remove dependecy on SchedulerMetadata for AflStatsStage

* clippy

* remove queue_cycles from AflScheduler into int's own trait.
libafl-fuzz: simplify map observer tracking

* clippy

* libafl-fuzz: disable cmplog check in CI for now

* add missing constraints for libafl_qemu executor

* clippy

* libafl-fuzz: improve Makefile
libafl-fuzz: clippy

* libafl-fuzz: misc

* misc typos, beautify

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-07-16 02:10:20 +02:00
Romain Malmain
e8de3591bf
Fix cfg clippy for libafl_qemu (#2397)
* optional final comma

* fix systemmode
2024-07-16 00:37:54 +02:00
Dominik Maier
9d5be4ede1
clippy_nyx (#2401) 2024-07-15 23:49:56 +02:00
Dongjia "toka" Zhang
8919024e83
New clippy script (#2400)
* claude.ai

* aaa

* ps1

* set -e

* nightly

* nightly default

* components?
2024-07-15 19:17:21 +02:00
Addison Crump
50a4a0abd9
Template out libafl_libfuzzer (#2398)
* template out libafl_libfuzzer

* fix some final path oddities

* missed a spot
2024-07-15 19:10:51 +02:00
Aarnav
fed61eb6b8
Fix qemu_launcher by moving stop request handling to fuzz_one (#2394)
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-07-15 15:41:51 +02:00
Dominik Maier
ea3e70b6e5
Remove release_max_level_info from log (#2396) 2024-07-15 14:55:13 +02:00
Dongjia "toka" Zhang
7969e7ae51
Another attempt to add interesting crashing input on crash (#2391)
* aa

* why??????????????

* ppp

* aa

* aa

* abcde

* fixer

* ppp

* aa

* fix from windows

* sugar

* ff

* ??

* a

* to log::error

* exclude

* exclude libafl_qemu clippy on windows

* pp

* aa

---------

Co-authored-by: Your Name <you@example.com>
2024-07-15 13:58:39 +02:00
Romain Malmain
539ac91ce0
fix qemu ci not running aggressively enough (#2395) 2024-07-15 13:55:35 +02:00
Valentin Huber
4f7444395a
Add function to make mmap shmem available for child processes (#2390) 2024-07-13 13:22:32 +02:00
Dominik Maier
79cbc16800
Replace uses std HashMap with hashbrown for consistency (#2387)
* Replace uses std HashMap with hashbrown for consistency

* fix

* more fix

* Hashbrownify libfuzzer_runtime

* more
2024-07-12 17:42:07 +02:00
Dominik Maier
7feeb00546
Fix docs (follow-up to #2385) (#2388)
* Fix docs (follow-up to #2385)

* More fix

* fix fuzzer

* More docs
2024-07-12 16:13:43 +02:00
Dominik Maier
3c93b96b70
Introduce TuiMonitor builder, clean up monitor docs and names (#2385)
* Introduce TuiMonitor builder

* Some random docs

* More documentation for monitors

* fixed critical whitespace

* Rename all-caps TOML and JSON to Toml and Json in monitors

* actually rename

* more
2024-07-12 15:27:45 +02:00
Dominik Maier
24aa640df7
Clarify two more comments (#2384)
* Make language clearer

* Two more comments
2024-07-12 13:07:19 +02:00
Dominik Maier
d4101a671c
Make language clearer (#2383) 2024-07-12 13:04:49 +02:00
Dominik Maier
fa4241f4f8
Make atheris load multiple tokens files (#2382) 2024-07-12 12:46:42 +02:00
Dominik Maier
081c218737
More Clippy (#2381)
* More Clippy

* This looks nicer indeed
2024-07-12 11:05:03 +02:00
Nereuxofficial
4931db6469
doc: Listing mutators in the module documentation (#2369)
* doc(libafl_nyx): More detailed README

* doc(libafl): Documentation about mutators

* doc(libafl): fix Reference to MOpt

* doc(libafl): Improved note about Mopt

* doc: More documentation for different mutators
2024-07-11 15:35:36 +02:00
Dongjia "toka" Zhang
2565fa8bf5
Delete Makefile.toml from Multi machine exmaple (#2379)
* delete

* aa
2024-07-11 14:51:18 +02:00
Max Ammann
dbbd54169d
Add documentation for InProcessForkExecutor for fuzzing rust (#2378) 2024-07-11 13:26:30 +02:00
Dominik Maier
d9a042e094
More expressive error for llvm_config version (#2376) 2024-07-10 16:46:52 +02:00
Dominik Maier
264c2f021e
Update all which dependencies (#2375) 2024-07-10 15:38:56 +02:00
Dominik Maier
2b43d86296
Update clap across the repo (#2374) 2024-07-10 15:35:25 +02:00
Dominik Maier
977a597e9a
More Clippy (#2370) 2024-07-10 10:44:21 +02:00
Dominik Maier
721fd3b14e
Make tokens more token-y (less dictionary-y) (#2371) 2024-07-09 17:37:37 +02:00
saibotk
40f9cc946c
fix(tui): Make client bottom layouts visible again (#2368)
The length constraint on the bottom areas was set to 0 and thus those two blocks were invisible.
We adjusted those to the correct values to show all lines & also removed the unnecessary extra chunk layout variable.
2024-07-09 16:27:48 +02:00
Nereuxofficial
571c4c111e
Wrap metadata elements in Cow (#2364)
* feat: Wrap metadata elements in Cow

* fix(libafl_bolts): Compile Error due to wrong type

* cleanup(libafl_bolts): Remove unnecessary import

* cleanup(libafl_bolts): Removed unnecessary alloc

* fix(libafl_bolts): Fixed type_repr_owned

* cleanup(libafl_bolts): unused import
2024-07-07 16:30:12 +02:00
Andrea Fioraldi
2356ba5754
Fix missing -use_value_profile flag in libafl_libfuzzer (#2363)
* Add -use_value_profile to libafl_libfuzzer

* clippy
2024-07-05 14:09:07 +02:00
0e5bf879e4 fix try_force_new_branches 2024-07-04 12:49:09 +02:00
Dominik Maier
d7b5d55408
Make sure inmemory_ondisk corpus catches filesystem errors correctly (#2361)
* Make sure inmemory_ondisk corpus catches filesystem errors correctly

* clip

* change names to be clearer
2024-07-03 16:25:12 +02:00
Nereuxofficial
ed3bd003a4
fix: Added corpus for dynamic_analysis fuzzer (#2360)
* doc: fixed instruction in CONTRIBUTING.md

* Added note for windows users

* fix: Added corpus for dynamic_analysis fuzzer

* fix for calling the clippy script on windows

* Fixed path oversight in previous commit
2024-07-03 11:51:52 +02:00
Nereuxofficial
030e5066b6
doc: fixed instruction in CONTRIBUTING.md (#2359)
* doc: fixed instruction in CONTRIBUTING.md

* Added note for windows users

* fix for calling the clippy script on windows
2024-07-02 19:32:11 +02:00
Aarnav
eff40320eb
Add Stoppable trait to State which exposes an API to stop the fuzzer (#2325)
* add HasStopNext to State which exposes an API to stop the fuzzer. Stops the fuzzer in fuzz_loop or
fuzz_loop_for when set to true

* fix import

* rename HasStopNext to HasShouldStopFuzzing and stop_next to should_stop_fuzzing

* added HasShouldStopFuzzing trait constraint for libafl_libfuzzer_runtime fuzzer

* rename HasShouldStopFuzzing to Stoppable and add it as a type constraint in libafl_libfuzzer report.rs

* rename should_stop_fuzzing -> should_stop

* introduce Event::Stop

* fix prelude import

* Call send_exiting when processing Event::Stop in restartable managers

* fix clippy

* introduce on_shutdown function in EventProcessor, a function to exit
without saving state gracefully. In contrast with on_restart.

* call manager.on_shutdown when stopping in fuzz_loop due to state.should_stop

* Add missing on_shutdown implementations
Check after every stage in Stages::perform_all if should exit and do so.

* remove specialization

* fix doc

* introduce EventProcessor constraint in libafl_libfuzzer_runtime
run clippy in libafl_libfuzzer_runtime

* fix CentralizedEventManager's on_shutdown not calling inner.on_shutdown

* fix bugs in CentralizedLauncher that wouldn't allow children to terminate properly

* don't call send_exiting when processing Event::Stop since it will be called when calling on_shutdown anyways

* clippy

* add set_exit_after so broker does not need to inner_mut to set exit_cleanly_after

* return Cow<str> from Event::name_detailed instead of a String

* fix missing import in libafl_libfuzzer_runtime

* add initate_stop and reset_stop to Stoppable trait to superceed should_stop_mut

* clippy

* typo

* rename initate_stop to request_stop, should_stop to stop_requested and reset_stop to discard_stop_request

* fix missing import

* windows clippy fix

* fix broker typo
2024-07-02 17:45:20 +02:00
Dongjia "toka" Zhang
762b6e008e
Make llvm pass build feature dependent (#2357)
* push

* everybody is default

* fix

* fix
2024-07-02 17:37:07 +02:00
d569df29a3 build fixes 2024-07-02 09:34:56 +02:00
47724ad1c3 stg try_force_new_branches 2024-07-02 09:34:35 +02:00
Dongjia "toka" Zhang
7c95afc42f
Rename some functions in fuzzer.rs (#2355)
* rename

* fmt
2024-07-01 21:47:10 +02:00
Marco C
140f84441a
LibAFL QEMU fix Doc-tests (#2354)
Explicitly mark the README snippet as bibtex to avoid cargo trying to run it as Rust
2024-07-01 14:29:33 +02:00
810ec36115 refactor 2024-07-01 13:28:38 +02:00
Andrea Fioraldi
35d8e67992
Fix libafl_libfuzzer publish (#2353) 2024-06-30 20:38:03 +02:00
Andrea Fioraldi
12c6cc186b
LibAFL QEMU readme (#2351) 2024-06-30 17:24:02 +02:00
Nereuxofficial
d564656f1c
Improved documentation for fuzzers/cargo_fuzz and dynamic_analysis (#2350)
* Improved documentation for fuzzers/cargo_fuzz and dynamic_analysis

* revert line breaks in markdown files
2024-06-30 14:31:34 +02:00
Dongjia "toka" Zhang
bb579e624e
0.13.1 (#2343) 2024-06-29 12:41:56 +02:00
Dongjia "toka" Zhang
234ea049a0
Delete introspection feature from libafl_libfuzzer (#2349)
* fix

* a

* delete it
2024-06-28 23:02:32 +02:00
Dominik Maier
602bce446f
Fix LLVMFuzzerCustomMutator with different sizes (#2347)
* Fix LLVMFuzzerCustomMutator with different sizes

* removed needles extra thingy

* clippy

* more clip
2024-06-28 16:40:41 +02:00
77799f77a9 move cli parsing, use multibyteinput 2024-06-28 14:38:25 +02:00
Dongjia "toka" Zhang
50d75422c8
Fixing receiver_left()/memory leak in llmp.rs (#2344)
* fixer

* real fix
2024-06-27 16:52:05 +02:00
Dominik Maier
8031111660
Make ddg map compilation optional (#2341)
* Make ddg map compilation optional

* undo

* undo
2024-06-27 01:19:45 +02:00
Dominik Maier
ea6e440762
Re-Rename Retrying Restart Helper (#2340) 2024-06-26 23:49:22 +02:00
Dominik Maier
3616cc6a55
Fix unsafe_stable_anymap, rename to stable_anymap (it's safe) (#2338)
* doesn't work poc

* Works

* make this work with or without feature

* start time

* Fix fixes

* Fix more build

* fix build

* reset changes in fuzzbench fuzzer

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-06-26 22:44:01 +02:00
Marco C
abdb7c2996
bolts: fix warning about error_in_core now stable (#2337)
the feature `error_in_core` has been stable since 1.81.0-nightly and no longer requires an attribute to enable
2024-06-25 16:48:16 +02:00
Dongjia "toka" Zhang
2d1e429482
baby_fuzzer_wasm fix (#2336)
* fixer

* a
2024-06-24 17:31:25 +02:00
David CARLIER
6db68970ee
bolts: haiku build fix. (#2335) 2024-06-24 00:59:39 +02:00
Aarnav
b2635df524
Make LlmpEventManager call pre_exec hook (#2333) 2024-06-23 14:39:34 +02:00
Dongjia "toka" Zhang
e3dd7cf0dc
Don't restart in deterministic stages. Don't restart where there's no restart safety. Make stage names unique (#2331)
* push

* fuck

* add

* add

* api

* api

* add multi machine to workspace

* doc

* api

* api

* add

* more

* fix

* stats

* rev

* fix

* fix

* real fix

* add

* fmt

* add

* add

* fix

* a

* add

* revert workflow

---------

Co-authored-by: Your Name <you@example.com>
2024-06-20 17:38:15 +02:00
Dominik Maier
042840dba1
Call all Ids id, not idx (#2319)
* All Ids should be id not idx

* More

* fix

* win?

* win?

* win?

* fix

* more fix

* desyscall?

* more

* fmt

* std

* make id less id-y

* fmt

* fix

* cleanup

* fixes all around

* fix

* Fix the broken stuff from refactoring

* remove unused

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-20 14:46:47 +01:00
acf9b04e70 remove unused code 2024-06-20 13:25:21 +02:00
6cb2be4408 add TimeProbMassScheduler 2024-06-20 10:15:01 +02:00
3a7c0da037 fast snapshots by default 2024-06-19 14:22:12 +02:00
5fad373199 update to 0.13.0 API 2024-06-19 13:30:36 +02:00
Dongjia "toka" Zhang
a2da080fa6
Delete wrong exec count increment (#2330) 2024-06-19 11:57:27 +02:00
Dominik Maier
e64f0fb536
Address comments from #2302 (#2322)
* Address comments from #2302

* secure?

* cleanup

* early exit ftw

* address clippy

* Fix all the things
2024-06-18 14:58:37 +01:00
学儿思
5519ee7d77
Fix typos (#2327) 2024-06-18 15:57:27 +02:00
Dongjia "toka" Zhang
b6bb604c71
Fix sync stage (#2326)
* f

* a

---------

Co-authored-by: Skynet 2 <name@domain.example>
2024-06-18 15:32:24 +02:00
Romain Malmain
fa17f47115
Tree-shaped multi-machine fuzzing (#2302)
* tree-shaped multi-machine fuzzing

* forgot main file

* aaa

* moving things around

* fix

* working?

* remove debug panic

* aaa

* aaa

* fmt

* normal centralized adapted

* removed old useless code

* cleanup

* llmp hooks

* working multi machine apparently?

* aaa

* cleanup (#2305)

* added old message dispatch.
thread safety stuff

* testing things around

* opti opti opti

* :)

* fuzz

* limit the amound received at once to avoid congestion

* remove useless corpus
mv to sqlite
less warnings

* aaa

* ;

* big opti

* adding cfgs

* fix

* fixer

* fix

* s

* clippy and reduce generics

* debugging

* fix

* more robust disconnection

* aaa

* aaa

* aaa

* nostd

* more nostd

* clippy

* not in ci

* unused

* aaa

* doc

* clippy

* clippy

* clippy

* no crash in libpng

* aaa

* aaa

* aaa

* aaa

* graph generator

* fix

* fix

* windows fix all

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-17 23:23:01 +02:00
Dongjia "toka" Zhang
a4070deee1
fix win build (#2321)
Co-authored-by: Your Name <you@example.com>
2024-06-17 18:19:44 +02:00
dependabot[bot]
7792d87e32
Update meminterval requirement from 0.3 to 0.4 (#2317)
---
updated-dependencies:
- dependency-name: meminterval
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-17 17:48:15 +02:00
Romain Malmain
609a4ad7fe
Add Romain Malmain to maintainers list (#2318) 2024-06-17 16:32:46 +01:00
学儿思
c9cf8af14d
Fix typos (#2320) 2024-06-17 16:27:32 +01:00
df7333b764 WIP: merge 2024-06-17 14:17:06 +02:00
a7becb403e update helper scripts 2024-06-17 10:31:48 +02:00
Dongjia "toka" Zhang
51db18eea8
Format desyscall (#2316)
* f

* clippy and stuff

* no apple
2024-06-16 12:20:08 +01:00
Andrea Fioraldi
888079aea5
Fix publish errors (#2313)
* Fix publish errors

* publish.sh

* remove include_str readme in libafl_qemu

* execute libafl_qemu_build::maybe_generate_stub_bindings() only if in cargo doc
2024-06-15 15:26:31 +01:00
Valentin Huber
5a2652b984
Adding StdXObserver Docs (#2311)
* Adding StdXObserver Docs

* fixing docs

* code cleanup

* moving example

* improving exclusion rules

* adding impls for features

* adding test exclusions

* excluding miri from OS including tests

* fixing CI

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-14 19:41:21 +02:00
Dongjia "toka" Zhang
c3930b39fc
Fix CI (#2312) 2024-06-14 14:16:31 +02:00
b86ac4cac6 fix build 2024-06-14 14:06:21 +02:00
5e29f4b909 always dump error case during fuzzing 2024-06-14 14:00:09 +02:00
1146c2c1e5 two-way isr edges, graceful parsing error handling 2024-06-14 13:56:36 +02:00
lazymio
18a25d3b3d
Fix debug assert on map_state.num_covered_map_indexes (#2310) 2024-06-14 13:29:38 +02:00
Dongjia "toka" Zhang
c415b4d5f6
0.13.0 (#2253)
* 0.13

* z3

* capstone

* fixer

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-06-13 23:35:35 +02:00
clesmian
2265d672fc
Allow trailing comma in feedback macros (#2308)
Co-authored-by: Leon Weiß <leon.weiss@rub.de>
2024-06-13 23:35:20 +02:00
Dongjia "toka" Zhang
e12412fed6
Fix Stdout/err Observer? (#2301) 2024-06-13 13:33:36 +02:00
Aarnav
901572556f
Add support for cycling PowerSchedule on completion of a queue cycle in WeightedScheduler (#2300)
* add support for cycling PowerSchedule on completion of a queue cycle in WeightedScheduler

* improve doc

* make fn cycle_schedule private

* rename cycle_schedules to cycling_scheduler
2024-06-13 10:25:25 +01:00
Andrea Fioraldi
09faec15f4
Add libdesyscall (#1221)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-12 11:28:31 +02:00
Dongjia "toka" Zhang
0ed295842b
Use filename for MmapShMemProvider (#2303)
* fixer

* comment

* a

* bb

* apple
2024-06-11 20:15:11 +02:00
mkravchik
03d8d2eb08
Fixing Frida ASAN tests on Windows (#2299)
* libafl_frida unit tests passing with ASAN

* Clippy+fmt

* Clippy

* Setup VS environment before building
2024-06-11 13:22:46 +02:00
Valentin Huber
df40db5ae8
Fix closing mmap on provider::release_shmem (#2298) 2024-06-10 17:59:51 +02:00
Dongjia "toka" Zhang
f4699ba385
Make adaptive serialization into default (#2296)
* no adaptive

* add another api

* allow unused
2024-06-09 00:10:30 +02:00
Dongjia "toka" Zhang
454176427b
Windows clippy (#2295)
* add

* real one

* fuck

* abc

* def

* ghi

* jkl

* fix

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-06-08 20:32:40 +02:00
Dominik Maier
93085782d6
Rename string stages to unicode stages for consistency (#2293) 2024-06-08 16:59:49 +01:00
Dongjia "toka" Zhang
e905743ef6
Update issue template(#2294) 2024-06-08 17:42:33 +02:00
Dongjia "toka" Zhang
30ae963c45
Fix CI (#2292)
* p

* a

* p

* a

* delete transfered

* b

* bring back transferred

* ??

* xx

* conditional

* ?

* debug

* a

* 🤬🤬🤬🤬🤬🤬🤬

* a

* a

* comment
2024-06-08 16:25:49 +01:00
Romain Malmain
8ef4e2aff0
Do not fmt little cms files (#2291) 2024-06-08 13:19:58 +01:00
Dominik Maier
ba84170777
Fix docs on crates.io for LibAFL_Frida, introduce auto-download feature (#2270)
* Fix docs on crates.io for LibAFL_Frida, introduce auto-download feature

* remove it more

* more testing

* more features

* more CI

* CI?

* CI?

* More fix?

* nicer

* More fix?

* test?

* more try?

* why?

* more more
2024-06-08 13:02:59 +01:00
Dongjia "toka" Zhang
e99fcad326
Run ./scripts/fmt_all.sh in CI (#2290)
* pppp

* fix

* xx

* add clang18

* fix

* chg

* purge existing clang..

* tmate

* trigger

* bruh

* finally..

* Don't fmt when not in cargo-fmt

* fix

* aaaaaa

* fuck
2024-06-08 01:41:39 +02:00
Dongjia "toka" Zhang
1e2fac6f53
abort() when the weakly defined LLVMFuzzerTestOneInput is linked(#2289) 2024-06-07 23:54:19 +02:00
Romain Malmain
14263b9c69
Rusty LibAFL fmt (#2271) 2024-06-07 23:41:50 +02:00
Marco Neumann
b1bec42044
fix: libafl_libfuzzer build script (#2282)
- features check was inverted
- print helpful message when `llvm-nm` wasn't found, which happens to be
  the case on _stable_

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-07 23:37:08 +02:00
Aarnav
477941e0e2
change Stability calculation formla to AFL++'s (#2275)
* change Stability calculation formla to AFL++'s

* clippy

* use MapFeedbackMetadata instead of recalculating filled entries in map

* calculate filled entries if MapFeedbackMetadata is not available

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-07 14:56:37 +02:00
Dongjia "toka" Zhang
2cc33464fa
Cleanup for #2280 (#2286)
* cleanup

* ppppp

* a

* b
2024-06-07 14:56:14 +02:00
Dongjia "toka" Zhang
1b008ae2e4
Delete 'static from libafl::events (#2285) 2024-06-07 13:45:36 +02:00
Kevin Phoenix
bc5ae151bc
libafl_qemu_build: Disable docs in user mode (#2272) 2024-06-06 18:57:13 +01:00
Aarnav
a455ad27a9
Fix WeightedScheduler reporting incorrect queue cylces (#2281)
* fix WeightedScheduler reporting incorrect queue cylces

* check if runs_in_cycle equals or greater instead of just equals

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-06-06 18:50:29 +01:00
Romain Malmain
af12b4ba24
LLmp hooks (#2280)
* llmp hooks

* separate llmp broker from inner state to allow doing more stuff
2024-06-06 16:07:55 +02:00
69d0c6f9bb build fix 2024-06-06 14:50:02 +02:00
b9e388d9d5 timeshift variable, handle nested isr+api, bump max_interrupts 2024-06-06 14:39:45 +02:00
Romain Malmain
399fbccea2
Closure builder for inner managers of centralized. (#2279)
* generic inner manager for centralized, with builder closures.

* moved options inside the function

* removed useless bound

* unused import

* remove useless clone bound.

* make clearer what is secondary node

* same inner manager for main and secondary

* fix example
2024-06-05 19:12:21 +02:00
Aarnav
7dd345d18c
Enforce max_input_size and min_input_size in Forkserver (#2273)
* enforce minimum and maximum input size for Forkserver's shared memory map and file based testcases

* explicit conversion to OwnedSlice

* clippy

* error if min_input_size > max_input_size when building forkserver
2024-06-05 16:16:30 +02:00
Dongjia "toka" Zhang
6373a1e1b3
Use Self::State as much as possible and remove unnecessary type bounds (#2263)
* use Self::State as much as possible

* makeing progress, little by little

* more

* add

* more and more

* more

* more

* mre

* fix

* a

* pp

* fix

* fix

* more

* version

* fix cargo fuzz
2024-06-05 15:16:43 +02:00
Dongjia "toka" Zhang
a7bb5196ea
Revert "Revert "Add always_interesting option to llmp mgr (#2262)" (#2274)" (#2278)
This reverts commit 620835a73f4a1163177d2b11b61625177c737cd5.
2024-06-05 15:10:32 +02:00
Dongjia "toka" Zhang
620835a73f
Revert "Add always_interesting option to llmp mgr (#2262)" (#2274)
This reverts commit 0f9c82f893b0bb8e91b78c5c17f8d1c8d452669e.
2024-06-04 18:53:01 +02:00
Dominik Maier
1556cba426
Update ratatui to 0.26 (#2269)
* Update ratatui to 0.26

* more build infos

* fix introspection
2024-06-03 15:23:12 +02:00
dependabot[bot]
2a82e9c40f
Update winsafe requirement from 0.0.20 to 0.0.21 (#2268)
Updates the requirements on [winsafe](https://github.com/rodrigocfd/winsafe) to permit the latest version.
- [Commits](https://github.com/rodrigocfd/winsafe/compare/v0.0.20...v0.0.21)

---
updated-dependencies:
- dependency-name: winsafe
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-03 14:27:21 +02:00
Dominik Maier
58c39680c9
Move Nautilus to LibAFL, remove AGPL dependencies (#2265)
* Copy choose method for unbounded iterators

* Add choose method for unbounded iterators

* Copy&paste in nautilus grammartec

* cargo

* fmt

* Initial Nautilus in LibAFL

* missing link

* clippy

* clippy

* more clippy

* docs

* docs

* more docs

* remove nautilus default

* fix doctest

* fmt

* less vec

* test

* less flakey

* clippy

* clippy
2024-06-03 14:18:52 +02:00
c7bf1be8b1 target_symbols.csv++ 2024-06-03 08:31:57 +02:00
Dongjia "toka" Zhang
0f9c82f893
Add always_interesting option to llmp mgr (#2262)
* always add

* change launcher...
2024-05-31 15:18:51 +02:00
Aarnav
7b90873305
introduce CustomFilenameToTestcaseFeedback (#2256)
* introduce CustomTestcaseFilenameFeedback

* rename CustomTestcaseFilenameFeedback to CustomFilenameToTestcaseFeedback

* rename custom_testcase_filename to custom_filename

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-05-30 19:05:53 +02:00
Romain Malmain
1102ea0fe7
Better RW errors for QEMU (#2260)
* better error for rw in qemu.

* fix python

* clippy

* Fix error in fuzzers

* Fix error in fuzzers

* fix systemmode error

* import
2024-05-30 15:14:17 +02:00
Dongjia "toka" Zhang
e912216a37
Add remove_from_all method to Corpus trait (#2259)
* add remove_from_all

* a

* a

* aaaaaaa

* make remove_from_all to remove
2024-05-30 11:53:32 +02:00
2cbd9de2eb change interrupt mutation 2024-05-29 15:49:52 +02:00
4c8a435cfd fix corpuscase dump 2024-05-29 12:32:34 +02:00
Mrmaxmeier
b96b9be674
tutorial fuzzer: switch lain fork to AFLplusplus/lain (#2257) 2024-05-28 20:45:18 +02:00
Mrmaxmeier
7fe43a28e8
fix duplicate package warning (#2258)
warning: skipping duplicate package `fuzzbench` found at `~/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/058e15f/fuzzers/fuzzbench`
2024-05-28 20:45:04 +02:00
Addison Crump
058e15f547
Implement tuple mapping (#2247)
* implement tuple mapping

* docs, clippy magic

* clippy >:(

* rename for clarity
2024-05-28 18:11:41 +02:00
Romain Malmain
65af5a7f78
Fix libnyx, library upgrades (#2254)
* try this thing

* this?

* use new mmap signature in nix.

* fix import

* fix to work with addr2line v0.23.

* remove unused flag

* update strum also for dependency...

* clippy

* clippy

* update lain git hash

* bump many outdated crates

* fix hash
2024-05-28 17:15:08 +02:00
Dominik Maier
c3f67daefb
Fix nix update (#2252) (#2255) 2024-05-28 13:16:09 +02:00
Romain Malmain
963afc3e5c
Pre-commit hooks (#2241)
* add pre-commit hook.
example of hook with fmt check.

* Add `CONTRIBUTING.md`.
2024-05-28 11:45:13 +02:00
Aarnav
bce0f08294
Introduce feedbacks hit tracking for testcases (#2248)
* introduce feedbacks hit tracking for testcases

* make Testcase::hit_feedbacks into Cow<&str> instead of String
rename get_hit_feedbacks to append_hit_feedbacks
update documentation

* simplify ConstFeedback

* rename Feedback::last_result to prev_result

* impl TODO prev_result for NewHashFeedback, ListFeedback, TransferredFeedback, NautilusFeedback

* rename prev_result to last_result

* add docs

* introduce Objectives hit tracking

* update docs

* update Cargo.toml docs

* update docs

* track Feedbacks & Objectives hit in Fuzzer::add_input

* fmt

* clippy

* fix type error in OomFeedback::last_result

* impl last_result for AsanErrorsFeedback

* add track_hit_feedbacks as a feature to libafl_libfuzzer_runtime

* fix clippy

* change return type of Feedback::last_result to a Result

* remove expect in NewHashFeedback::is_interesting

* move Error::premature_last_result to libafl from libafl_bolts
2024-05-28 11:43:05 +02:00
dependabot[bot]
e4446b908c
Update nix requirement from 0.27 to 0.29 (#2252)
---
updated-dependencies:
- dependency-name: nix
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-28 11:42:46 +02:00
dependabot[bot]
2670049c2b
Update addr2line requirement from 0.22 to 0.23 (#2251)
Updates the requirements on [addr2line](https://github.com/gimli-rs/addr2line) to permit the latest version.
- [Changelog](https://github.com/gimli-rs/addr2line/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/addr2line/compare/0.22.0...0.23.0)

---
updated-dependencies:
- dependency-name: addr2line
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-28 11:42:34 +02:00
Romain Malmain
4d45100a63
Fix libafl_qemu.h (#2250)
* fix header for gcc

* fix comment
2024-05-28 11:39:24 +02:00
Valentin Huber
7c9bd1157c
Adding DiffExitKindFeedback (#2246)
* adding DiffExitKindFeedback

* refactoring

* fixing CI
2024-05-24 16:12:32 +02:00
Dongjia "toka" Zhang
e6eb6c48d2
LibAFL Dynamic Analysis (#2208)
* aa

* push

* push

* push

* claude ai

* push

* add

* add stuff

* upd

* rdm

* fix

* ci

* fix

* fix

* fixing

* feature

* revert

* no submodules

* ci
2024-05-24 14:43:27 +02:00
Dominik Maier
07dca4b59b
LibAFL_Libfuzzer: Add clippy warnings (#2244)
* clip

* More clippyness
2024-05-24 14:00:09 +02:00
Romain Malmain
5fbe2415e1
Generic QEMU snapshot checking (#2240)
* generic snapshot checking.
2024-05-23 22:57:13 +02:00
Dominik Maier
1fafaf6454
Make every Builder ::builder(), so BobTheBuilder::new() becomes BobThe::builder() (#2242)
* Make every builder ::builder()

* Fix no_std

* More

* Fix clippy, stuff

* More fun

* Make NopShMem do something

* Alloc

* more fmt

* Remove UB in tinyinst executor builder

* Make builder order not matter for tinyinst

* More better

* fix

* docs

* fmt

* more fmt

* clippy

* fix fixes

* tiny thing

* more betterg

* more more

* more builder

* more builder

* more nyx

* undo breaking clippy

* clip
2024-05-23 18:56:39 +02:00
35c99fba3a increase max abb count 2024-05-23 16:44:56 +02:00
Dominik Maier
b97a9a1398
Rename peek_next_free_id to peek_free_id (that it's the next is obvious) (#2243) 2024-05-23 15:44:32 +02:00
ffedc1fd41 revert changes to interrupt injection 2024-05-23 10:28:34 +02:00
7701fff969 config fix 2024-05-23 10:25:23 +02:00
de5c16e601 plot micro fixes 2024-05-23 10:16:28 +02:00
83e9a29d12 skip dumping every trace 2024-05-23 10:15:25 +02:00
Dominik Maier
e317ad045e
Introduce StageId (extends #2201) (#2239)
* Factor out `StageStack` from `StdState`

Refactoring for the sake of abstraction and maintainability.

Previously, the `stage_idx_stack` and `stage_depth` fields of
`StdState` had an implicit relationship to one another. This commit
reifies this relationship into a new `struct`. Its fields are hidden
from everything else in `StdState`. It `impl`s `HasCurrentStage` and
`HasNestedStageStatus`, which `impl`s now no longer have mutable access
to the whole state. The `impl`s for `StdState` just forward to these
ones.

Hopefully, this refactoring would make it easier to `impl State` for
other types in the future.

* Create `StageIdx` newtype

Like `CorpusId`, this is just a thin wrapper around `usize`.

* unused import

* Rename a few functions to be more about indices

* Rename Index to Id, fmt

* Move StageId around

---------

Co-authored-by: Langston Barrett <langston.barrett@gmail.com>
2024-05-23 00:53:26 +02:00
35716cc4be fix initial corpus 2024-05-22 22:36:00 +02:00
915da3fb42 fix config 2024-05-22 22:27:04 +02:00
5901e3d9c5 prioritize long tarces 2024-05-22 22:18:56 +02:00
bde16f8297 scheduler, mutator changes 2024-05-22 21:54:07 +02:00
c533b7e184 change interrupt injection timing, stg scheduler 2024-05-22 13:52:13 +02:00
Aarnav
1ed1c4eb31
Add peek function to Corpus (#2238)
* add peek function to Corpus

* send 0 as next peek in NopCorpus

* rename peek to peek_next_free_id

* fix clippy

* add peek_next_free_id to libafl_libfuzzer

* impl peek_next_free_id for ArtifactCorpus
2024-05-22 13:30:47 +02:00
cube0x8
4b67b55b29
Second round of usermode snapshot fixes (#2140)
* Added brk callback for snapshot. Added filter feature for snapshot

* cargo fmt

* clippy

* Update imports

* update bindings

* updated bindings

* Added additional check of brk syscall result

* change snapshot restore debug level from info to debug

* add warning comment

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-05-22 13:30:09 +02:00
Dongjia "toka" Zhang
336d7fcc4f
Refactor events/llmp.rs (#2234)
* push

* refactor

* FMT

* fixes

* aaaaaa

* done

* aa

* docdoc

* rename

* no std

* nautilus

* feature fix

* aa

---------

Co-authored-by: Your Name <you@example.com>
2024-05-22 12:58:44 +02:00
cube0x8
47d15ade81
Instrumentation filters remove generic bound (#2053)
* Removed S: UsesInput bound for HasInstrumentationFilter

* cargo fmt

* Removed S generic leftovers

* cargo fmt

* fix systemmode

* unused imports

* more verbose error.

* clippy

* debug test

* still debugging

* debug ci

* sudo

* debug

* debug

* debug

* add g++

* build-essential

* more deps...

* restore to sane state.

* remove useless comment.

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-05-22 12:58:10 +02:00
Dominik Maier
684b31279e
Add BytesSubInput to mutate sub-parts of a bytes-backed input (#2220)
* Add BytesSubMutator that allows us to mutate sub-parts of a bytes-backed input

* no_std

* fix string mutator

* make build

* Fix clippy on macOS

* Docs

* More docs

* Better docs

* --amend

* Renamed bsi to sub_input. Too much BSI

* More more

* balance backticks

* Make splicing usable with sub_input (not that it makes sense)

* More annotations

* more input annotations?

* Implement HasMutatorBytes for &mut Vec

* clippy

* Use a wrapper type instead

* Add wrapper type for Vec as well

* Remove the duplicate BytesInput... lol
2024-05-22 01:50:07 +02:00
5342812cf7 build fixes 2024-05-21 18:50:55 +02:00
71ff7487e6 add feature dependencies 2024-05-21 18:48:46 +02:00
54fa7cce62 add edge filter 2024-05-21 18:47:12 +02:00
b9b6e1fc12 fix snakefile 2024-05-21 18:33:15 +02:00
e9c27b3065 fixes timing, scheduler 2024-05-21 18:24:23 +02:00
2886aafb65 remove dead code, restructure features 2024-05-21 16:06:53 +02:00
Dongjia "toka" Zhang
19ef29ed60
New forkserver (#2213)
* step 1

* done

* cmplog?

* targets

* check if working and add env_logger

* typo
2024-05-21 15:20:28 +02:00
Valentin Huber
b7e10ca7af
Making StdOutObserver and StdErrObserver implement Observer (#2236)
* making stdout and stderr observers implement observer

* fixing imports
2024-05-21 13:19:02 +02:00
3ed8ccd0c7 exclude QemuSystemStateObserver when not needed 2024-05-21 13:03:55 +02:00
7d8717ff15 remove shortcut cases and assertions from state 2024-05-21 12:59:56 +02:00
87ddf4a77d work around rare non-started abbs 2024-05-21 12:43:03 +02:00
3444fdd8ec fix interrupt shifter, isr tracer 2024-05-21 12:32:00 +02:00
f13412c175 fix interrupt shifter 2024-05-21 09:03:11 +02:00
ede6cf48a4 fix build 2024-05-21 01:57:23 +02:00
5edb6e5677 fix snakefile 2024-05-21 01:51:54 +02:00
21c97c8484 WIP: fix isr_starter 2024-05-21 00:22:50 +02:00
Dominik Maier
123f508fcc
Clean up samplig_rate, add docs (#2228)
* Clean up samplig_rate, add docs

* clippy
2024-05-20 14:24:24 +02:00
dependabot[bot]
aa47a5c5e6
Update addr2line requirement from 0.21 to 0.22 (#2230)
Updates the requirements on [addr2line](https://github.com/gimli-rs/addr2line) to permit the latest version.
- [Changelog](https://github.com/gimli-rs/addr2line/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/addr2line/compare/0.21.0...0.22.0)

---
updated-dependencies:
- dependency-name: addr2line
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-20 14:21:37 +02:00
dependabot[bot]
d6827b5aa2
Update goblin requirement from 0.7 to 0.8 (#2232)
Updates the requirements on [goblin](https://github.com/m4b/goblin) to permit the latest version.
- [Changelog](https://github.com/m4b/goblin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/m4b/goblin/commits)

---
updated-dependencies:
- dependency-name: goblin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-20 14:21:25 +02:00
dependabot[bot]
767f5dffec
Update erased-serde requirement from 0.3.21 to 0.4.5 (#2233)
Updates the requirements on [erased-serde](https://github.com/dtolnay/erased-serde) to permit the latest version.
- [Release notes](https://github.com/dtolnay/erased-serde/releases)
- [Commits](https://github.com/dtolnay/erased-serde/compare/0.3.21...0.4.5)

---
updated-dependencies:
- dependency-name: erased-serde
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-20 14:19:22 +02:00
b9d6f41ac6 WIP: deprecate graph and use STG 2024-05-20 10:54:43 +02:00
s1341
864c2259e7
launcher: add launch_delay option (#2227)
* launcher: add launch_delay option

* Centralized too

* Use in test

* Undo

* Windows too

* Format

* Fix cfg guard
2024-05-20 10:06:33 +03:00
s1341
f324c60b02
Add testcase sampling rate (#2226)
* fuzzer: Add with_sampling_rate

* Format

* Fix clippy
2024-05-20 09:34:31 +03:00
Sharad Khanna
79f3b69fa8
Fix hook_func and implement deinit (#2180)
* Hook fix

* Implement deinit to pass tests

* Fix aarch64 errors as well as signficantly speed up startup on macos

* fmt

* Fix cmplog_rt

* Fix windows ci

* ci fix 2

* Fix clippy

* Revert hook implementation to new impl

* Add nolinkage option for hooks and fix some comments

* fmt

* Move hooking mechanism to entirely static mut

* fmt

* Fix clippy

* fix windows

* fmt

* Overall the function hook macro to ensure that the original function is correct and not the same function in a different library. Also change static muts to OnceLock
2024-05-20 07:41:44 +03:00
Dominik Maier
6a9ea73865
Confuse clippy less (#2223) 2024-05-20 04:03:23 +02:00
Dominik Maier
117741e1b1
Run Clippy on macOS (#2222)
* macos clippy

* Fix clippy on macOS
2024-05-20 02:58:42 +02:00
dependabot[bot]
cc71979826
Update hostname requirement from ^0.3 to ^0.4 (#2206)
Updates the requirements on [hostname](https://github.com/svartalf/hostname) to permit the latest version.
- [Release notes](https://github.com/svartalf/hostname/releases)
- [Changelog](https://github.com/svartalf/hostname/blob/master/CHANGELOG.md)
- [Commits](https://github.com/svartalf/hostname/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: hostname
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-20 02:32:36 +02:00
Dominik Maier
30f65512d8
Remove unused dependencies (#2221)
* Remove unused dependencies

* Add guard
2024-05-20 02:30:53 +02:00
Romain Malmain
2e5e2056b2
Faster fmt_all.sh (#2218)
* parallel fmt

* fix shellcheck

* fix shellcheck

* add check mode
2024-05-19 20:07:38 +02:00
Dominik Maier
31e1eee96e
Rename CurrentCorpusIdx -> CurrentCorpusId (#2216)
* Rename CurrentCorpusIdx -> CurrentCorpusId

* why ripgrep do you not find these

* ripgrep, why?
2024-05-19 18:12:45 +02:00
Dominik Maier
cf01d04151
Report 100% stability if no unstable edges are found (extends #2215) (#2217)
* Report 100% stability if no unstable edges are found

* Use metadtata

---------

Co-authored-by: sadeli413 <sadeli0x19d@gmail.com>
2024-05-19 14:41:28 +02:00
Romain Malmain
dfd3b3278e
QEMU command system refactoring (#2189)
* implemented generic command builder

* Added builder to `Emulator`.
2024-05-18 20:43:56 +02:00
cube0x8
3a087301ac
Fixed infinite loop on SyncDiskStage (#2193)
* Fixed infinite loop on SyncDiskStage

* cargo fmt

* added debug messages

* Add left to sync to metadata. Replace HashSet with Vec

* added check on state metadata to not crash in case it's None (start fuzzing without files to sync)

* fmt & clippy

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-18 20:25:38 +02:00
Max Ammann
6040133080
Use MultiMonitor when fuzzing in non-forking mode (#2192) 2024-05-18 20:24:41 +02:00
dependabot[bot]
8d54ee2c80
Update pyo3-build-config requirement from 0.18 to 0.21 (#2205)
Updates the requirements on [pyo3-build-config](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.18.0...v0.21.2)

---
updated-dependencies:
- dependency-name: pyo3-build-config
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-18 20:22:35 +02:00
Aarnav
baf07445e4
add AFL stage names for calibration, colorization, power and sync stages (#2209)
* add AFL stage names for calibration, colorization, power and sync stages

* clippy

* add missing name field in sync stage

* use consts instead of hardcoding in functions.
change set_name to with_name for PowerMutationalStage
remove irrelevant fn transforming

* make AFL++ name default for all stages
2024-05-18 14:49:38 +02:00
Dongjia "toka" Zhang
22d8e92b08
Ci fix (#2212)
* bbb

* ccc
2024-05-18 13:42:03 +02:00
Dongjia "toka" Zhang
f8f9da2a15
Trying to fix CI (#2211)
* test

* aaa

* 4.38

* 4.37
2024-05-18 00:13:11 +02:00
8f652f754c WIP: complet rework of STG 2024-05-17 15:57:44 +02:00
Dongjia "toka" Zhang
d05adf7f6e
Delete leftover println! (#2203) 2024-05-17 13:35:38 +02:00
dependabot[bot]
0777873aae
Update prometheus-client requirement from 0.21 to 0.22 (#2197)
Updates the requirements on [prometheus-client](https://github.com/prometheus/client_rust) to permit the latest version.
- [Release notes](https://github.com/prometheus/client_rust/releases)
- [Changelog](https://github.com/prometheus/client_rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_rust/compare/v0.21.0...v0.22.2)

---
updated-dependencies:
- dependency-name: prometheus-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-16 14:27:37 +02:00
Dongjia "toka" Zhang
e31658b914
Change when to setup the ctrl c handler. (#2198)
* copy

* fmt

* aa

* a

* Goodbye z3, i hope i won't build you forever

* doc

* fmt

* fix

* aa
2024-05-16 14:27:14 +02:00
dependabot[bot]
41d41f25bf
Update reqwest requirement from 0.11 to 0.12 (#2196)
Updates the requirements on [reqwest](https://github.com/seanmonstar/reqwest) to permit the latest version.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.0...v0.12.4)

---
updated-dependencies:
- dependency-name: reqwest
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-16 14:11:52 +02:00
dependabot[bot]
7cf821bd82
Update toml requirement from 0.4.2 to 0.8.13 (#2195)
---
updated-dependencies:
- dependency-name: toml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-16 14:06:53 +02:00
dependabot[bot]
b871037e70
Update cargo_toml requirement from 0.16 to 0.20 (#2194)
Updates the requirements on [cargo_toml](https://gitlab.com/lib.rs/cargo_toml) to permit the latest version.
- [Commits](https://gitlab.com/lib.rs/cargo_toml/compare/v0.16.1...v0.20.2)

---
updated-dependencies:
- dependency-name: cargo_toml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-16 14:06:37 +02:00
Dominik Maier
34ec907456
Fix libafl_sugar docs build (#2188)
* Fix libafl_sugar docs build

* doc redoc

* fmt
2024-05-16 00:19:09 +02:00
Dongjia "toka" Zhang
c7303ace53
Static analysis pass (#2178)
* copy

* fmt

* aa

* a

* Goodbye z3, i hope i won't build you forever

* doc

* fmt
2024-05-15 16:50:20 +02:00
dependabot[bot]
6fe888d2bb
Update libloading requirement from 0.7 to 0.8 (#2183)
Updates the requirements on [libloading](https://github.com/nagisa/rust_libloading) to permit the latest version.
- [Commits](https://github.com/nagisa/rust_libloading/compare/0.7.0...0.8.3)

---
updated-dependencies:
- dependency-name: libloading
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-15 15:18:52 +02:00
dependabot[bot]
70333aaf94
Update typed-builder requirement from 0.16 to 0.18 (#2184)
---
updated-dependencies:
- dependency-name: typed-builder
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-15 15:18:14 +02:00
dependabot[bot]
e70b23fc6b
Update serde_yaml requirement from 0.8 to 0.9 (#2185)
Updates the requirements on [serde_yaml](https://github.com/dtolnay/serde-yaml) to permit the latest version.
- [Release notes](https://github.com/dtolnay/serde-yaml/releases)
- [Commits](https://github.com/dtolnay/serde-yaml/compare/0.8.0...0.9.34)

---
updated-dependencies:
- dependency-name: serde_yaml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-15 15:17:38 +02:00
dependabot[bot]
167d25c3af
Update winsafe requirement from 0.0.18 to 0.0.20 (#2186)
Updates the requirements on [winsafe](https://github.com/rodrigocfd/winsafe) to permit the latest version.
- [Commits](https://github.com/rodrigocfd/winsafe/compare/v0.0.18...v0.0.20)

---
updated-dependencies:
- dependency-name: winsafe
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-15 15:17:17 +02:00
Sönke
e14eb26e8b
Add client_stats to OnDiskJSONMonitor (#2181) 2024-05-15 01:54:27 +02:00
Romain Malmain
b127f0579d
Regenerate QEMU binding stubs only for newer versions of the nightly compiler (#2177)
* Regenerate binding stubs only for newer versions of the nightly compiler.

* fmt

* clippy
2024-05-15 01:42:59 +02:00
s1341
19087f3dab
Windows frida support (#1607)
* WIP: windows frida

* frida-windows: fix hooks not present on windows

* windows: allow building using cargo xwin

* frida-windows: fmrt

* frida-windows: cleanup and allow asan/drcov on windows

* frida-windows: fmt

* frida-windows: fix clippy

* frida-windows: handle unknown exceptions gracefully

* frida-windows: rework shadow mapping algo

* frida-windows: add hook functions

* frida-windows: hook functions; fix stack register

* minibsod: enable for windows

* check_shadow: fix edge casees

* asan_rt: rework and add hooks for windows

* inprocess: add minibsod on windows

* Fix warnings

* minibsod: disable test on windows

* WIP: HookRuntime

* Cleanup after merge

* Bump frida-gum version

* Fix conflict marker; update frida

* Make winsafe windows-specific

* Fmt

* Format

* Better detection of clang++ (using cc)

* Make AsanErrors crate public so we can use it in tests

* Add helper to get immediate of operand

* Use HookRuntime to hook asan functions

Tests now passing

* fmt

* Implement recurisve jmp resolve

* Fix reversed logic

* windows_hooks: Don't die if functions are already replaced

* Allow utils to work on windows

* Enable allocator hooking on windows

* Warnings; add trace to free

* Make ASAN tests run windows (with cargo xwin compilation)

* Fmt

* clang-format

* clang-format

* Add more tests

* Fix partial range access bug in unpoisoning/shadow_check

* Merge main

* Fix check_shadow and implement unit tests

* Fix hooking and PC retrieval

* WIP: Working gdiplus fuzzing with frida-ASAN, no false positives

* LibAFL Frida asan_rt and hook_rt fixes for frida_windows (#2095)

* Introduce aarch64

* MacOS fix - MemoryAreas is broken on MacOS and just loops

* Introduce working aarch64 ASAN check

* Implement large blob

* Fix hook_rt for arm64

* Fix poison/unpoison

* Fix shadow check

* Update x86-64

* Fix aarch64 unused import

* Remove extraneous println statement

* merge main

* Fixes

* alloc: add tests, pass the tests

* HookRuntime before AsanRuntime, and don't Asan if Hooked

* hook_rt: Fixes

* Frida windows check shadow fix (#2159)

* Fix check_shadow and add additional tests

* add some additional documentation

* Revert to Interceptor based hooks

* fixes

* format

* Get rid of hook_rt; fixes

* clang-format

* clang-format

* Fix with_threshold

* fixes

* fix build.rs

* fmt

* Fix offset to RDI on stack

* Fix clippy

* Fix build.rs

* clippy

* hook MapViewOfFile

* fmt

* fix

* clippy

* clippy

* Missing brace

* fix

* Clippy

* fomrrat

* fix i64 cast

* clippy exclude

* too many lines

* Undo merge fails

* fmt

* move debug print

* Fix some frida things

* Remove unused frida_to_cs fn for aarch64

* name

* Don't touch libafl_qemu

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Sharad Khanna <sharad@mineo333.dev>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dominik Maier <dmnk@google.com>
2024-05-14 10:45:56 +02:00
dependabot[bot]
dce0761b11
Update capstone requirement from 0.11.0 to 0.12.0 (#2170)
Updates the requirements on [capstone](https://github.com/capstone-rust/capstone-rs) to permit the latest version.
- [Release notes](https://github.com/capstone-rust/capstone-rs/releases)
- [Changelog](https://github.com/capstone-rust/capstone-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/capstone-rust/capstone-rs/compare/capstone-v0.11.0...capstone-v0.12.0)

---
updated-dependencies:
- dependency-name: capstone
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-13 21:09:02 +02:00
dependabot[bot]
9fa5f72080
Update serial_test requirement from 2 to 3 (#2171)
Updates the requirements on [serial_test](https://github.com/palfrey/serial_test) to permit the latest version.
- [Release notes](https://github.com/palfrey/serial_test/releases)
- [Commits](https://github.com/palfrey/serial_test/compare/v2.0.0...v3.1.1)

---
updated-dependencies:
- dependency-name: serial_test
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-13 20:59:46 +02:00
dependabot[bot]
5662105e75
Update which requirement from 4.4 to 6.0 (#2172)
Updates the requirements on [which](https://github.com/harryfei/which-rs) to permit the latest version.
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/4.4.0...6.0.1)

---
updated-dependencies:
- dependency-name: which
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-05-13 20:59:36 +02:00
Dominik Maier
667ce328fc
Fix MacOS CI race condition (#2176) 2024-05-13 20:57:45 +02:00
Dominik Maier
6b76b6ea98
Revert "Update zip requirement from 0.6 to 1.2 (#2169)" (#2174)
This reverts commit c621a5e4753ad6bce4b02084971d14d6d6b4e02a.
2024-05-13 20:25:54 +02:00
Romain Malmain
b0d95676f9
Fix regex fixing generated bindings for QEMU (#2163)
* Fix regex fixing generated bindings

* Do not write 2 times bindings to filesystem

* Update stub bindings

* fmt

* clippy

* fmt

* use `unsafe extern "C"` instead of `extern "C"`.
2024-05-13 17:41:56 +02:00
dependabot[bot]
c621a5e475
Update zip requirement from 0.6 to 1.2 (#2169)
Updates the requirements on [zip](https://github.com/zip-rs/zip2) to permit the latest version.
- [Release notes](https://github.com/zip-rs/zip2/releases)
- [Changelog](https://github.com/zip-rs/zip2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zip-rs/zip2/compare/v0.6.4...v1.2.3)

---
updated-dependencies:
- dependency-name: zip
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-13 17:22:16 +02:00
Dongjia "toka" Zhang
7a464c4c87
Dependabot (#2168) 2024-05-13 17:21:00 +02:00
Dongjia "toka" Zhang
bf4d1de7cd
Remove observer_stdout/observer_stderr from Observer trait (#2167)
* stuff

* upd

* cargo test

* doc

* fmt

* nyx stuff
2024-05-13 17:10:55 +02:00
Dominik Maier
5872d24021
Clippy for apple after #2162 (#2166) 2024-05-13 14:30:09 +02:00
Romain Malmain
edb6b509c2
Generate stub bindings less aggressively. (#2164)
Emit warning when using runtime files for an incompatible architecture.
2024-05-13 11:58:19 +02:00
David CARLIER
1cf3df665a
Switch MiniBSOD to mach crate for Apple (#2162) 2024-05-12 18:37:11 +02:00
Kevin Phoenix
3328f06de4
Add qemu runtime defs for aarch64 (#2151) 2024-05-12 15:39:55 +02:00
Langston Barrett
f17a45dcc3
bolts: Fix feature name in assert (serde{,any}_autoreg) (#2160) 2024-05-12 13:20:03 +02:00
Dongjia "toka" Zhang
7c9ac6d4b5
Revert "Adding ExitCodeObserver and ExitSignalObserver (#2138)" (#2157)
This reverts commit ee7dafae4100397698e5266465919bfdbc40af51.
2024-05-08 15:26:07 +02:00
Valentin Huber
ee7dafae41
Adding ExitCodeObserver and ExitSignalObserver (#2138)
* Adding ExitCodeObserver and ExitStatusObserver

* Introducing ExitKind::Interrupted
2024-05-08 15:17:24 +02:00
Addison Crump
614b149cae
Fix cfg uses across codebase (#2154)
* start fixup of cfgs

* whoops

* remaining issues

* maybe fixup macos

* apparently that is ios code?

* fix no_std

* Re-enable tcp_compression

* fix tcp broker

* remove tcp_debug flag

* fmt

* clippy

* less unwrap while we're at it

* doc

* add back pub star uses for libafl_qemu

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-05-08 14:31:10 +02:00
Max Ammann
f6d2eaacb4
Fix libafl_libfuzzer's compatibility with LLVM 14 (#2136)
* Always use Rust's nm instead of host system one

* Fix formatting

* Fix formatting
2024-05-08 13:53:12 +02:00
ba3850cf4d remove stg feedback from systemstate flag 2024-05-08 12:49:40 +02:00
3f9a2ed6c0 trace executed abbs, instead of states 2024-05-08 12:30:10 +02:00
David CARLIER
695efeab42
bolts: Fix minibsod build on apple (#2155) 2024-05-08 05:31:13 +02:00
Dominik Maier
c97c8cf83e
Rename Handler -> Handled, various other cleanups after #2142 (#2152)
* Handle name cleanup after #2142

* Handleable -> CanBeHandled

* CanBeHandled -> Handled

* clippy

* forgot one

* Handled more
2024-05-07 19:23:13 +02:00
Addison Crump
c1a55982b6
Stable type_eq (#2150)
* stable type eq

* whoops, wrong section

* satiate clippy

* remove extraneous comment

* explain

* bonus inline
2024-05-07 17:09:15 +02:00
Dongjia "toka" Zhang
e7e820868c
Change special exitcode from 137 to 9 in simple.rs too (#2153) 2024-05-07 14:31:19 +02:00
Romain Malmain
bed500471a
QEMU generic memory iterator (#2148)
* QEMU generic memory iterator + Refactoring

* Generic Memory Iterator (systemmode only for now): It is now possible to iterator over memory ranges, independently of the address kind

* Refactoring or Emulator / Qemu structures: they are now handled separately in different files

* Refactoring of Exit Handlers: Result / Error structs have been clarified

* Simple handler for signals

* add new `check-cfg` calls for libafl qemu
2024-05-07 10:46:15 +02:00
cube0x8
a16fb88f3e
Add null ptr to devices vec (QEMU systemmode) (#2141) 2024-05-06 23:19:30 +02:00
88c5c8a19f feedback for aggregated traces 2024-05-06 16:00:11 +02:00
Dongjia "toka" Zhang
4562f19bdc
Qemu ctrl c exit (#2147)
* fix

* ignore

* fix

* aaa

* bbb
2024-05-06 15:42:43 +02:00
0393f18a47 add stg edge feedback 2024-05-06 14:46:35 +02:00
Dongjia "toka" Zhang
b0d592dc3a
Add to how to leave tui screen (#2146) 2024-05-05 17:21:15 +02:00
Dongjia "toka" Zhang
d4ff7b86b1
Add windows test & ci & fix (#2144)
* fix

* ignore

* fmt

* a
2024-05-05 14:53:27 +02:00
Dongjia "toka" Zhang
502929d967
Separate map observers (#2143)
* rename

* rename

* fmt

* fix

* fmt

* separate observers

* doc fx
2024-05-04 23:11:00 +02:00
Dongjia "toka" Zhang
b0ac25a7b5
Rename Reference to Handle (#2142)
* rename

* rename

* fmt

* fix

* fmt
2024-05-04 18:16:28 +02:00
Dongjia "toka" Zhang
41ff7438eb
Fix incrementing found_objective(#2139) 2024-05-03 23:30:14 +02:00
Langston Barrett
382673b173
GenStage: A stage for generational (e.g., black-box) fuzzers (#2137)
* GenStage: A stage for generational (e.g., black-box) fuzzers

* mv stages/{gen,generation}.rs

* Fix doc link

* `GenStage`: Alphabetize type parameters

* Fighting rustdoc
2024-05-03 19:18:14 +02:00
Dongjia "toka" Zhang
f75c5ff4d3
Add found_objectives metadata (#2093)
* try

* add stuff

* clp

* Move to counter, remove penalization

* fix

* even milder

* fix

* clp

* no score

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-05-03 16:37:05 +02:00
3453d02b1d fix fuzzing loop returning nothing 2024-05-03 13:28:49 +02:00
d93ed809f1 improve stg parsing 2024-05-03 13:28:15 +02:00
Valentin Huber
7fe0c576db
Make CommandExecutor Generic on the specific Input (#2129) 2024-05-02 15:39:06 -04:00
Dongjia "toka" Zhang
2e81dc6c59
Fix DDFuzz instrumentation (#2134) 2024-05-02 20:00:51 +02:00
Romain Malmain
02ef0c4dda
fix qemu systemmode fuzzers exit code (#2133) 2024-05-02 16:27:07 +02:00
Stefan Zabka
ec944a0ea4
Allow setting stdout_file in non-fork launcher (#2127)
* fix(launcher.rs): hide file output behind appropriate feature flag

discovered while debugging #2111

* fix(launcher.rs): implement stdout/stderr piping for non-forking unix

* hide all accesses to stdout_file in cfg blocks

* Conditionally add stdout_file config in frida_gdiplus
2024-05-02 10:24:36 -04:00
Romain Malmain
2302f1b35c
Fix QEMU doc not building (again) (#2130)
* fix doc not building.
2024-05-02 15:17:35 +02:00
Dongjia "toka" Zhang
359e94ec97
ctrl c handler fix for non-fork mode (#2132)
* poc

* ai suggestion

* rename this

* aaaa

* fmt

* simplify

* delete blob

* ignore

* fixup?

* some progress on cow-ification

* some more

* clippy fixes, finalise tests

* whoops, missed a spot

* no std compat

* api change: Named now requires alloc feature

* doc fix

* missed a spot

* additional fixes

* libfuzzer fixes

* fix tutorial

* fix

* add

* aa

* fix tutorial

* fix

* Rename

* fix

* aa

* fmt

* aa

* aa

* another closure

* clp

* fix stuff

* fix non fork

* fmt

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-05-02 14:43:25 +02:00
cube0x8
c79cdc89ac
add mmap hooks to libqasan (#2122)
* add mmap hooks to libqasan

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-05-02 10:39:33 +02:00
Romain Malmain
935100e7a7
Qemu update to latest version + various fixes (#2119)
* Fix maps iterator

* Added paranoid debug feature.

* Fix snapshot bugs.

* Update qemu-libafl-bridge.

* Added auto-generation of `x86_64_stub_bindings.rs` .

* Fix sync_exit calling to stopped CPU.
2024-05-02 09:31:54 +02:00
Dongjia "toka" Zhang
2f7c19e2b1
Change centralized launcher signature (#2094)
* poc

* ai suggestion

* rename this

* aaaa

* fmt

* simplify

* delete blob

* ignore

* fixup?

* some progress on cow-ification

* some more

* clippy fixes, finalise tests

* whoops, missed a spot

* no std compat

* api change: Named now requires alloc feature

* doc fix

* missed a spot

* additional fixes

* libfuzzer fixes

* fix tutorial

* fix

* add

* aa

* fix tutorial

* fix

* Rename

* fix

* aa

* fmt

* aa

* aa

* another closure

* clp

* fix stuff

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-04-30 19:44:57 +02:00
Dongjia "toka" Zhang
b23180394b
Fix Ctrl-C Handler (#2124)
* fix

* fix

* win

* win clp

* a

* FMT

* aaaaaaaaaaa

* aa

---------

Co-authored-by: Your Name <you@example.com>
2024-04-30 17:18:39 +02:00
clesmian
61ac4ea7be
Improve OnDiskTOMLMonitor (#2125)
* Allow for more frequent updates of TOML monitor

* Don't skip first client

* Reduce code duplication

* Immediately write first TOML file

* Rust fmt

* Use same client numbering as other monitors

* Fmt
2024-04-30 09:05:33 -04:00
Gregory Petrosyan
b49ab999e3
libafl_bolts: rands super mega ultra giga house cleaning of doom (#2123)
* rands: simpler rand_trait code, remove useless test

* rands: provide and use proper random_seed()

* rands: add missing golden tests

* Don't use current_nanos() for seeding

* rands: remove RandomSeed trait
2024-04-29 11:00:44 -04:00
Dongjia "toka" Zhang
50f14d44fa
Restrict more on edges map API (#2117)
* fix

* fix

* feature guard

* use

* cannnot find

* fmt

* more

* fix

* fix

* more

* fucking fmt just shut

* rename and change stuff

* fix

* fix

* fixxxxxxxxxx
2024-04-29 16:28:40 +02:00
Langston Barrett
b0248461e2
Allow for AsIter(Mut)/AsSlice(Mut) to be implemented in safe Rust (#2120)
* Generalize `AsIter` to allow iterating over contents of a `RefCell`

Towards `MapObserver`s in safe Rust.

* Helpers for `RefCellValueObserver`

* MapObserver: Return owned Self::Entry from .get()

`Self::Entry` is `Copy`, so there's not much value in returning a
reference from `get()`. Futhermore, returning a reference limits the
possible implementations of `MapObserver`, because it forces the
borrow/reset to outlive the body of the method.

* MapObserver: Replace `.get_mut()` with `.set(idx, val)`

Like the previous commit, this is intended to expand the possible
implementations of `MapObserver` to types with interior mutability,
which can't necessarily loan out their content.

* Make `RefCellValueObserver` into a safe `MapObserver`

* as iter mut

* as slice (mut): allow for non-& refs

* nostd

* CI round 1

* cleanup + AsSlice defs for RefCellValueObserver

* clippy fixes

* avoid unnecessary imports

* whoops, too aggressive

* use deref instead of as slice

* whoops

* fix as slice conditional importing in stable

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-04-27 18:36:56 +02:00
Addison Crump
28c43b332f
Match by Ref fix (#2105)
* match by ref fix

* impl Named for Reference

* rename

* magic indexing

* whoops

* docs, clippy

* some additional CI complaints

* other libafl_qemu fixes

* missed an alloc feature

* a smattering of fixes

* use from not direct construction

* tinyinst fix

* horrible double-mutability things

* fixup nyx

* from not new

* forkserver_simple fixes

* dogfood: forkserver

* mmmm yummy dogfood

* round one CI fixes

* clippy appeasement

* deref generic impl to simplify usage

* adaptive serialization (ouch)

* remaining clippy items

* I am tired

* new not with

* fixup: aflpp tracing was not actually constructable

* fix tmin

* reduce complexity of map feedback now that we do not need to constrain

* frida fixes

* fix concolic

* type_ref => reference
2024-04-27 18:08:09 +02:00
Dongjia "toka" Zhang
084b9b5878
Batch timeout fix (#2109)
* fix

* FMT

* unused
2024-04-26 17:10:36 +02:00
Aarnav
32963be453
add crash_exitcode to Forkserver to accomodate AFL_CRASH_EXITCODE (#2107)
* add crash_exitcode to Forkserver to accomodate AFL_CRASH_EXITCODE

* make crash_exitcode i8

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
2024-04-26 16:24:25 +02:00
Addison Crump
c2e0e8ddbe
Add recv_blocking_with_flags (#2102)
* add recv_blocking_with_flags

* rollback, whoops
2024-04-26 16:22:32 +02:00
Dongjia "toka" Zhang
abcb2bf33e
Remove jobs dependency in CI (#2108) 2024-04-25 16:07:38 +02:00
Addison Crump
4c95d9029a
Split android and ios tests (#2106)
* split android and ios tests

* whoops
2024-04-25 12:23:46 +02:00
Romain Malmain
dd0fbff819
Small refactoring of libafl_qemu structure (#2098)
* Architecture-specific stuff is now in the `arch` directory

* Helpers are now in the `helpers` directory

* `emu.rs` has been moved as `emu/mod.rs` for consistency with the rest of the repository
2024-04-24 21:47:29 +02:00
Dongjia "toka" Zhang
c622a28eba
Rename from ReReference to Reference (#2099) 2024-04-24 15:06:33 +02:00
Gregory Petrosyan
1e8667a9f9
libafl_bolts: more rands improvements (#2096)
* rands: add missing inline directives

See:
- https://nnethercote.github.io/perf-book/inlining.html
- https://users.rust-lang.org/t/enable-cross-crate-inlining-without-suggesting-inlining/55004/6

* rands: better fast_bound() signature
2024-04-24 14:01:37 +02:00
Stefan Zabka
0f42efa12b
refactor(snapshot.rs): use const generics (#2069)
* refactor(snapshot.rs): use const generics

* Add docs to read hooks

---------

Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-04-24 11:58:46 +02:00
Dongjia "toka" Zhang
176659821a
Add TypeRefCreator trait (#2065)
* poc

* ai suggestion

* rename this

* aaaa

* fmt

* simplify

* delete blob

* ignore

* fixup?

* some progress on cow-ification

* some more

* clippy fixes, finalise tests

* whoops, missed a spot

* no std compat

* api change: Named now requires alloc feature

* doc fix

* missed a spot

* additional fixes

* libfuzzer fixes

* fix tutorial

* fix

* add

* aa

* fix tutorial

* fix

* Rename

* fix

* aa

* fmt

* aa

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-04-23 19:03:30 +02:00
6774a778c3 add wip stg tracer 2024-04-23 16:53:55 +02:00
Aarnav
76a95bc5fd
Introduce AFL_EXIT_ON_SEED_ISSUES (#2085)
* introduce load_initial_inputs_disallow_solution to exit if a solution is found during seed loading

* fmt

* rename CorpusError to Corpus

* add LoadConfig to simplify configuration for loading initial inputs

* Rename Error::Corpus to Error::InvalidCorpus
Add documentation to LoadConfig struct
fix nostd for LoadConfig

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
2024-04-23 15:53:18 +02:00
Josef Haider
d34965192d
Add FeedbackFactory implementations for CrashFeedback, CombinedFeedback and DiffFeedback. (#2060)
* Add FeedbackFactory implementations for CrashFeedback, CombinedFeedback and DiffFeedback

* remove redundant type CrashFeedbackFactory
2024-04-23 15:48:52 +02:00
Gregory Petrosyan
e1b8c9b5d8
libafl_bolts: improvements to the rands module, add next_float (#2086)
* rands: use splitmix64 for seeding

Seeding with splitmix64 is a good way to avoid starting with
low-entropy PRNG states, and is explicitly recommended
by the authors of both xoshiro256++ and Romu.

While at it, give the xoshiro256++ PRNG its proper name.

* rands: use fast_bound() to generate number in range

* rands: add top-level choose()

* rands: add Rand::next_float()

* rands: add Rand::coinflip() helper

* libafl: unbreak tests that relied on direct seeding

* rands: add SFC64 PRNG

SFC64 is a well-established and well-understood PRNG designed by
Chris Doty-Humphrey, the author of PractRand. It has been tested
quite a lot over the years, and to date has no known weaknesses.

Compared to xoshiro256++, it is slightly faster and is likely to
be a more future-proof design (xoshiro/xoroshiro family of generators
come with quite long history of [flaws][1] found over the years).

Compared to Romu, it is slightly slower, but guarantees absense
of bias, minimum period of at least 2^64 for any seed, and
non-overlapping streams for different seeds.

[1]: https://tom-kaitchuck.medium.com/designing-a-new-prng-1c4ffd27124d
2024-04-23 15:37:28 +02:00
Dongjia "toka" Zhang
5ff709f241
Symcc Update (#2047)
* symcc upd

* upda

* fix

* fmt

* mm

* psu

* psh

* fix

* fix

* fix

* tmate

* can't make it work

* i really hate you llvm

* real name

* mm
2024-04-23 13:34:46 +02:00
Romain Malmain
2046cfe82d
Checkout before filter (#2092) 2024-04-23 09:45:45 +02:00
Dongjia "toka" Zhang
ea6a36b0a5
fix (#2091) 2024-04-22 21:55:55 +02:00
Dongjia "toka" Zhang
0f3ad288e7
Fix #1932 (#2089)
* fix

* Stupid lint

* increase rate

* fix
2024-04-22 19:27:13 +02:00
Romain Malmain
98863fbff5
Only run QEMU tests if there is a QEMU-related change. (#2090)
* Only run QEMU tests if there is a change.

* fmt.
2024-04-22 19:14:23 +02:00
Romain Malmain
fef6c8d1b1
Run qemu_systemmode tests with self-hosted runners (#2018)
* run qemu fuzzers (qemu_systemmode only for now) in self-hosted runners

* Remove qemu-related fuzzers to general fuzzers

* fix

* Install dependencies before anything else

* Do not use sudo

* Install sudo

* Revert "Install dependencies before anything else"

This reverts commit 107addad5d9f68dec5a9af50831112cd72c28f4d.

* added qemu specific prerequisites

* add -y flag

* Format with nightly

* Do not use nightly only.
Install fmt and clippy for stable as well.

* Install qemu-img for qemu

* fix qemu-img install

* apt update

* Changed timeout.

* Fix qemu_systemmode test

* fmt

* clippy + decorrelate build and run for qemu_systemmode.

* fix fuzzer

* clippy

* add sqlite3-dev to package prerequisites.

* add arm-none-eabi-gcc

* fix profile dir

* fix condition.

* Run less QEMU stuff faster

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
2024-04-22 18:17:22 +02:00
Tobias Mayer
fe64d10a5c
Fix typo in setup_libxml2.sh (#2088)
exit for a non-zero exit code
2024-04-22 14:37:41 +02:00
Dongjia "toka" Zhang
2df71e7a36
Faster cargo check (#2084)
* speed up cargo check

* fix

* composite

* plural

* wrong name

* go brrrrrrrr

* bash

* aaaaa

* why not even more?

* more composite

* fix

* miri

* test for llvm >= 16

* v2

* v2

* naaaa

* JUST MORE INSTANCES

* aa

* fix

* no bash for windows

* reduce a bit as some guys are delayed

* no deps
2024-04-20 10:50:43 +02:00
Addison Crump
fd364d15fe
cargo-fuzz testing (#2081)
* Build cargo-fuzz end to end

* Workaroudn failing CI

* Fix toml

* Build

* Exclude from workspace

* Fix version

* Fix workspace

* Fix workspace

* FIx workspace

* Fix path

* Set path correctly

* Install llvm-tools

* Test with distro llvm installed

* Use build

* complete

* remove from includes

* add back fuzzer tests, format

* add test for whether all fuzzers are actually tested in pipeline

* whoops

* I hate CI I hate CI I hate CI

* revert removal of llvm

* sh compatibility

* sigh

---------

Co-authored-by: Max Ammann <max@maxammann.org>
2024-04-19 23:55:28 +02:00
Dongjia "toka" Zhang
ea549b9cfe
Add a warning to say never use EDGES_MAP.len() (#2083)
* Revert "Revert splitting libafl_edges_map_max and libafl_edges_map_in_use (#2…"

This reverts commit c68b3816fb680b635f99c337f78185e699864705.

* all

* more

* add

* add
2024-04-19 23:26:00 +02:00
Dongjia "toka" Zhang
e8cc1ba93d
Revert "Revert splitting libafl_edges_map_max and libafl_edges_map_in_use" (#2082)
* Revert "Revert splitting libafl_edges_map_max and libafl_edges_map_in_use (#2…"

This reverts commit c68b3816fb680b635f99c337f78185e699864705.

* all

* more
2024-04-19 19:03:58 +02:00
edwin1729
c238b69498
Implement Hash for MapObserver (#1989)
* MapObserver implements Hash

* Rename the hash utility function (in MapObserver) to hash_easy

* Use hash_slice as a helper function to impl Hash trait

* define_python_map_observer macro implements Hash trait

* Also rename hash_easy to hash_simple

* Rename hash_slice to hash_helper

* hash_helper is used to define the implementation of hash function/trait

* Factor out the Hash trait and function for runtime library structs (#1977)

* Simplify hash_simple (of trait MapObserver) (#1977)

 * Use hash_one function to make hash_simple a one-liner

* remove hash_helper

---------

Co-authored-by: Edwin Fernando <ef322@ic.ac.uk>
Co-authored-by: Addison Crump <addison.crump@cispa.de>
2024-04-19 15:06:14 +02:00
Addison Crump
04cd792df2
fix libfuzzer by simply adding the needed feature (#2080) 2024-04-19 13:35:35 +02:00
Dongjia "toka" Zhang
c68b3816fb
Revert splitting libafl_edges_map_max and libafl_edges_map_in_use (#2079)
* fix

* aa

* push

* fix

* fmt
2024-04-19 13:24:25 +02:00
Tobias Mayer
d7ac802fb2
Update libafl_nyx to newest qemu-nyx and nyx-packer, fixing some problems with build_nyx_support.sh. Providing Makefile for bug in qemu-nyx (#2070)
Co-authored-by: ganbarutobi <ganbarutobi@gmail.com>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
2024-04-19 10:41:55 +02:00
Addison Crump
276bfc6386
tee not pipe (#2078) 2024-04-18 18:23:57 +02:00
Romain Malmain
84a432dab2
fix import (#2076) 2024-04-18 15:43:21 +02:00
mkravchik
2b18562b08
Fixing the inconsistency btw #2012 and #2066 (#2074) 2024-04-18 13:33:29 +02:00
Romain Malmain
39c32d55e7
Fix main not passing CI tests (#2075)
* Fix sancov import

* fmt

* fmt
2024-04-18 13:33:18 +02:00
mkravchik
886519b10c
Pr/fixing forkserver libafl cc (#2066)
* Fixing forserver_libafl_cc

* Adding tests and showing user stats

* Restoring the map truncation

* Fmt

* small fix

* fix

* fix

* fix

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-04-17 18:28:34 +02:00
Dongjia "toka" Zhang
c50af44099
Split edges_map_size and edges_map_size_alloc (#2012)
* two sizes

* rename

* build.rs

* rename

* capital

* FMT

* macro

* fuck

* fff
2024-04-17 17:58:08 +02:00
Addison Crump
467c6d7582
missed a spot (#2063) 2024-04-17 16:24:15 +02:00
Dongjia "toka" Zhang
7595b2e5c9
Debugging tips upd (#2062) 2024-04-17 16:01:33 +02:00
Addison Crump
edcff3889c
fixup: fix some missing tracking hints (#2058) 2024-04-17 14:34:06 +02:00
Dongjia "toka" Zhang
8bce605503
DDFuzz (#2056)
* push

* add

* book

* ddg

* works
2024-04-16 16:51:28 +02:00
Romain Malmain
bc3ef5952b
Rework of libafl_qemu configuration (#2054)
* LibAFL QEMU can now be dynamically linked
* LibAFL QEMU reconfiguration happens less frequently (now using a signature check)
* Possibility to have custom rpath in QEMU
2024-04-16 11:35:15 +02:00
Dongjia "toka" Zhang
da6118e61e
Debugging tips (#2048)
* push

* add

* book
2024-04-15 13:40:54 +02:00
David CARLIER
4ec50d6a10
bolts: core affinity simplification for freebsd (#2049)
since 13.1 (EOL since mid-2023) , supports the sched affinity api like linux/dragonflybsd.
2024-04-14 10:29:32 +02:00
Dongjia "toka" Zhang
0c68ff033f
Readme Update (#2046) 2024-04-12 23:29:23 +02:00
Dongjia "toka" Zhang
cbb323f26c
LibAFL 0.12 (#1823) 2024-04-12 18:42:14 +02:00
Addison Crump
3d702f403b
Implement CanTrack tracking enforcement through rust types (#1886)
* sample implementation of tracking enforcement (incomplete)

* helpful compiler output

* make it look like a real compiler output

* ensure that the macro may be used outside of libafl

* separate index/novelty tracking funcs

* default const generic values so that we don't need to change this everywhere

* fix tests

* rollback unnecessary specification of stdmapobserver

* register metadata in doc tests

* doc fixes

* doc cleanup

* doc cleanup 2

* reduce implementor overhead to zero

* renaming/docs fixes

* asref isn't reflexive??

* generalization stage updates

* add better documentation about require_{indices,novelties}_tracking

* remaining generic updates

* round one CI pass (knowingly introduces breaking changes)

* typo

* round 2 clippy

* rollback: libafl_frida changes

* fmt

* moar porting

* fix remaining fuzzers

* fix windows build, maybe

* fixup libafl_libfuzzer

* fmt nighlty all the things

* attempt to fix some broken additions

* fix fmt

* oops

* fix new invocation

* minimizer scheduler fixes

* fix accounting

* rename

* fix

* Fix build

* Sort generics

* Move more generics into the right place

* Rename A -> C

* Fix test

* Fix test some more

* Fix doc some more

* critical formatting

* More A->C

* CanTrack harder

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-04-12 18:33:52 +02:00
Romain Malmain
ec935bf95f
Fix GuestMaps iterator in LibAFL QEMU. (#2041)
* Fix maps iterator.

* Use native QEMU structs instead of pointer casting.

* Update stub bindings.

* Maps operations stored in usermode.
2024-04-12 14:40:53 +02:00
Maurice
8b9b5a8767
Introduce StdOutToMetadataFeedback and StdErrToMetadataFeddback (#2042)
* introduce `StdOutFeedback` and `StdErrFeddback`

* hide behind "std" feature flag

* update

* update
2024-04-12 14:26:47 +02:00
Dominik Maier
2f618b62d7
Rename HasAFLSchedulerMetadata to simply AflScheduler (it doesn't hold a Metadata at all) (#2043) 2024-04-12 13:24:00 +02:00
Dominik Maier
0f778b5892
Order differential generics alphabetically (#2044) 2024-04-12 12:14:49 +02:00
Maurice
631b1746e2
libafl_nyx: Add support for StdOutObserver (#2033)
* libafl_nyx: Add support for `StdOutObserver`

* reset file offset

* update example fuzzers

* fix
2024-04-11 18:24:32 +02:00
Romain Malmain
94a2a2363a
Add CPUArchStatePtr to backdoor signature (#2038) 2024-04-11 17:30:59 +02:00
Dongjia "toka" Zhang
287d1ac7c7
Add HasAdaptiveSerializer trait. (#2040)
* fix

* revert test

* add

* a

* check
2024-04-11 15:36:08 +02:00
Stefan Zabka
48463d079b
Fix error handling in libafl_qemu_build (#2036)
* fix(libafl_qemu_build): assert command success

* fix(libafl_qemu_build): make sure linker_interceptor.py picks up correct compiler

Currently linker_interceptor.py uses 'cc' as the __LIBAFL_QEMU_BUILD_CC environment variable is never set

* remove redudant arg
2024-04-10 18:36:36 +02:00
Dongjia "toka" Zhang
0d5c6219d8
Dedup CentralizedEventManager's serialize_observers() (#2034)
* why

* clp
2024-04-10 16:13:03 +02:00
WorksButNotTested
374f8735fa
Implement user-space QEMU ASAN (#1806)
* Implement user-space QEMU ASAN

* Fix wrong cfgs

* fmt

* merge conflicts in libafl qemu

* A few more fixes to qemu_launcher

* Change commit of qemu-libafl-bridge

* Fix clippy in qemu_launcher

* Fix commit id again

* Empty commit to trigger CI

* Fix path to fuzzer for test in qemu_launcher?

* Revert location of target binary and show the full error log from qemu_launcher test

* Appease the clippy gods

* Empty

* Fix format

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-04-10 01:11:28 +02:00
Aarnav
47c41c2925
Introduce disabled testcases for splicing (#1932)
* introduce disabled field to Testcase

* separate executor's processing of execution (adding to corpus/solution/discarding) and execution of input

* introduce add_disabled_input function

* enable splicing mutators to fetch disabled inputs

* reset modified example

* clean up

* update docs

* update docs for count_with_disabled

* fix random_corpus_id for splicing mutator not considering disabled entries

* fmt

* update docs

* clippy

* fix corpus_btreemap not working

* fix clippy warnings

* fix python bindings

* typo in count_with_disabled implementations

* fix certain splicing mutators not considering disabled inputs

* rename count_with_disabled to count_all

* introduce count_disabled function

* update docs for count_all, count_disabled and count

* * introduce get_from_all and nth_from_all for corpus implementations so get() and nth() do not silently fetch disabled entries.
* remove boolean flag from random_corpus_id which allowed inclusion of disabled ids and make it into a new function random_corpus_id_with_disabled
* update docs

* remove boolean is_disabled flag from corpus::insert and make it into a separate function insert_disabled

* rename do_insert to _insert

* make get_from_all inline for cached and inmemory

* add missing functions implementation for PythonCorpus
prevent writing feedback when adding disabled testcases

* fix nth_from_all overfetching enabled corpus entries

* fix clippy & rename execute_with_res to execute_no_process

* refactor _insert for corpus_btreemap

* make LibfuzzerCorpus and ArtifactCorpus to accomodate disabled entries

* fix typo

* fix missing docs for map field

* fix clippy

* test

* (hopefully) fix CachedOnDiskCorpus using incorrect corpus when caching testcase

* fix typo in inmemory_ondisk leading to fetching disabled entry from enabled corpus

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-04-10 01:03:00 +02:00
David CARLIER
d3b3d5d462
bolts: add time ticks method for arm (#2032) 2024-04-10 01:01:27 +02:00
Dongjia "toka" Zhang
c4f076356f
Fix the OOM exit code from 137 to 9 (#2029)
* i don't know if there really exit 137

* change message

* not 137 but 9
2024-04-09 17:16:25 +02:00
Romain Malmain
33c6ea1ae4
Fix libafl_qemu python bindings and example (#2030) 2024-04-09 16:09:47 +02:00
Mrmaxmeier
f252469d86
CI: A few updates and fixes (#2023)
* CI: Don't run cargo clean in order to preserve build caches

* CI: run yaml formatter >:)

* CI: try sharing build caches between similar jobs

* CI: it looks like the `ucd-generate` tool is not used anymore

* CI: Sneak in merge queue support :)

* CI: split out `cargo fmt --check` job

* libafl_qemu injections: be more resilient about mapping paths
2024-04-09 12:55:07 +02:00
Dominik Maier
2cc560e727
Tiny clippy fix for qemu_launcher fuzzer (#2026) 2024-04-09 12:49:42 +02:00
Dominik Maier
ef25aef471
Fix docs for frida (see #2025) (#2027) 2024-04-09 12:48:24 +02:00
Dominik Maier
7479726c3e
Un-Unfix libafl_qemu fixes after #2020, remove python CI (#2024)
* Un-Unfix libafl_qemu fixes after #2020

* remove CI for removed python bindings
2024-04-08 22:06:40 +02:00
Dongjia "toka" Zhang
ed5a10d0b5
Inter-job dependency on ubuntu ci (#2021)
* inter-job dependency.

* conc
2024-04-08 19:42:59 +02:00
Dominik Maier
a0a6d0e5cc
Fix yml file for CI (#2022) 2024-04-08 19:42:37 +02:00
Dominik Maier
f19302c9b1
Bring back python bindings for sugar,qemu (partially revert #2005) (#2020)
* Bring back python bindings for sugar,qemu (partially revert #2005)

* sugarman, won't you hurry

* Test?
2024-04-08 19:36:54 +02:00
Dongjia "toka" Zhang
e8fe5bb614
Move HasMetadata/HasNamedMetadata trait to libafl_bolts (#2016)
* move around

* fmt

* rev

* fmt

* doc job

* name

* move to libafl

* separate even more

* miri
2024-04-08 19:24:56 +02:00
Dominik Maier
ff938261df
Fix Clippy on MacOS for qemu, accept some clippy::missing_transmute_annotations suggestions (#2009)
* Fix Clippy/CI

* Ignore transmute annotations in pybind

* fix

* more clippy

* more clippy

* fix fixes
2024-04-08 16:24:10 +02:00
Dongjia "toka" Zhang
fa58dff4b7
concurrency (#2017) 2024-04-08 15:20:42 +02:00
Andrea Fioraldi
e29897dd44
Fix GuestMaps in userspace LibAFL QEMU (#2013) 2024-04-08 08:30:23 +02:00
Dongjia "toka" Zhang
159da0d311
Change when weighted scheduler make new table & don't update global metadata in on_remove/on_replace (#2011)
* fix

* backtick
2024-04-07 17:24:27 +02:00
Dongjia "toka" Zhang
527b892c1d
Separate fuzzer test in CI (#2010)
* ci

* ci

* ci

* aa

* aa

* a

* a

* a

* fix

* no fail fast

* system

* what is this lint...

* a

* clp

* disk

* ok no fastfail

* no qemu for now, reenable monday
2024-04-06 21:01:57 +02:00
Dongjia "toka" Zhang
4901846588
Remove python bindings (#2005)
* delete python bindings

* fix

* example

* fix
2024-04-06 15:16:46 +02:00
Tobias Mayer
24fd098e66
Update Dockerfile to work for nyx (#2008)
Missing file to build libafl_nyx in Docker
2024-04-06 04:48:50 +02:00
Dongjia "toka" Zhang
17aae94efc
Move some C functions to Rust from sancov_cmp.c (#2003)
* some

* a

* clp

* aa

* just new line

* fix

* fxi

* fix
2024-04-06 01:03:01 +02:00
Dongjia "toka" Zhang
90c627a7e7
revert large map (#2004) 2024-04-05 17:06:47 +02:00
Dominik Maier
1c85c3af13
Add option to enabled/disable client stats and fix #1771 (#2001)
* Add option to enabled/disable client stats and fix #1771

* more fix

* fix map_density

* even more fix

* remove need for vec in Aggregator::aggregate

* fix json weirdness - remove individual clients (is that all right? )

* Make pretty
2024-04-05 14:23:56 +02:00
Dongjia "toka" Zhang
98d3dfe821
Replace LLMP client timeout with client deregistration (#1982)
* wip

* done

* fix

* fix

* some fixes

* stuff

* fmt

* stuff

* use

* not 1337

* comment

* move functions around

* fix

* fix

* doc

* mistake

* aa

* fixer

* wipe out restarter id

* denig

* fix

* fix

* include

* fix

* fix

* fix

* clp

* fix

* fix

* error log
2024-04-04 21:01:11 +02:00
Dominik Maier
e64233e203
LLMP: Fix page-size where allocated message is larger than the current map (#1997) 2024-04-03 13:27:19 +02:00
Romain Malmain
50be2f4aaf
Fix of libafl qemu runtime files (#1996)
* Change naming and fix LibAFLQEMU header file. Fix and document LibAFL QEMU Windows ASM file.

* fmt
2024-04-03 11:57:48 +02:00
Dominik Maier
d90d232e7a
Frida: Move ASAN_ERRORS values into a Mutex for shared access (#1995)
* Move ASAN_ERRORS values into a Mutex for shared access

* Fix frida doc

* oops

* clippy
2024-04-03 11:47:09 +02:00
f26582ed75 un-hardcode rtos api functions 2024-04-03 10:19:37 +02:00
Dongjia "toka" Zhang
2137ad0f8f
Don't resume in std mutational stage (#1946)
* fix

* fix

* fix

* fix

* FMT

* don't resume in mutational stage
2024-04-02 13:26:47 +02:00
Dominik Maier
44dca17a6c
Tiny Frida doc fix (#1994) 2024-04-02 13:25:59 +02:00
Romain Malmain
cca4e3daa9
Make inputs in libafl_qemu generic (#1991)
* fix non-generic input in libafl_qemu

* Update setup_libxml2.sh of nyx_libxml2_standalone fuzzer (#1990)

On testing this on my machine not all neccessary files for fuzzing with nyx where provided by the setup. Compared to the nyx_libxml2_parallel fuzzer this packer generation line was missing.
After adding this the fuzzer was able to start.

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Tobias Mayer <arbeitskraftmayer@gmail.com>
2024-04-02 12:30:12 +02:00
Dominik Maier
aaafe1fc6c
Use new Rust CStr constant (#1993) 2024-04-02 10:28:20 +02:00
Tobias Mayer
63a6d1aac0
Update setup_libxml2.sh of nyx_libxml2_standalone fuzzer (#1990)
On testing this on my machine not all neccessary files for fuzzing with nyx where provided by the setup. Compared to the nyx_libxml2_parallel fuzzer this packer generation line was missing.
After adding this the fuzzer was able to start.
2024-04-02 10:19:22 +02:00
Dominik Maier
26122b20a0
Add unsafe to AsanErrorsObserver, fix UBs, fix Frida Version missmatch (#1987)
* Add unsafe to AsanErrorsObserver, fix UBs, fix Frida Version missmatch

* Clippy

* simpler API

* fix build

* fix
2024-04-02 10:17:59 +02:00
ToSeven
10f373d587
fix AFL-Style UI errors when allowing the introspection feature (#1986) 2024-04-01 14:09:15 +02:00
Andrea Fioraldi
45d47214c2
Fix OOM restarts with LlmpShouldSaveState (#1974)
* LlmpSaveState and OOM restarts

* clippy

* clippy

* rename
2024-03-30 17:05:03 +01:00
Romain Malmain
69d7d7b1e3
Add backdoors to portable header file of LibAFL QEMU. (#1978)
* Added backdoors to portable header file.

* fix arm macros.

* copy `libafl_qemu.h` in target directory.

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-03-30 17:04:52 +01:00
Romain Malmain
50e0f80d1e
Refactoring of qemu_systemmode fuzzers (#1980)
* Added backdoors to portable header file.

* fix arm macros.

* copy `libafl_qemu.h` in target directory.

* Merged all qemu_systemmode examples into one, settable with features.
Automatic building using `Makefile.toml`

* fix typo.

* added test of QEMU systemmode fuzzers.

* replace test by build for now.
2024-03-30 17:04:37 +01:00
Dongjia "toka" Zhang
0cafa5c72d
Don't use unwrap() in the crash handler (#1979)
* don't

* win

* fix

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-03-30 17:04:28 +01:00
Marco C
15aabfe65d
Clean up warnings in baby_fuzzers (#1981) 2024-03-29 15:14:17 +01:00
s1341
1fc5ba63fa
batch_timeout: fix overflowing subtraction (#1976) 2024-03-28 16:50:12 +01:00
c013628017 fix scheduler for storage changes 2024-03-28 14:14:34 +01:00
am009
c221108916
Add MutatedTransform to the input type in TMinMutationalStage (#1251) (#1971)
* Support `MutatedTransform` in `TMinMutationalStage`.

* Run `MutatedTransformPost` for the replaced testcase.

* Add clone trait bound for `MutatedTransformPost`.

* Return an error instead of using unwrap.
2024-03-27 18:59:45 +01:00
730fbcf6d4 fix capture in api calls 2024-03-27 15:24:44 +01:00
Dongjia "toka" Zhang
f0ee6e0587
Make fuzzer examples's argument parser tell that --input is mandatory (#1973)
* add

* not ture

* fmt
2024-03-26 20:02:42 +01:00
Dongjia "toka" Zhang
cd12546748
Fix llvm api so it works with older LLVM version (#1964)
* aa

* fix

* fix

* fmt

* fmt
2024-03-26 19:26:19 +01:00
Dongjia "toka" Zhang
91778961da
Inline cmplog internal functions code (#1972)
* fmt

* aa

* sattic

* win

* frida

* expose API

* fmt

* frida
2024-03-26 17:42:03 +01:00
Dongjia "toka" Zhang
53bfae0a08
Increase llmp timeout & Print PID in logger (#1970)
* increase timeout & print pid for logger

* log

* aa

* rename stuff
2024-03-25 19:15:46 +01:00
Dongjia "toka" Zhang
7170b5391b
Fix UpdateExecStats not sent to the main broker in centralized 2024-03-25 16:39:30 +01:00
Dongjia "toka" Zhang
3cc8ea0336
Fix EventManagerHook (#1968) 2024-03-25 13:04:41 +01:00
Romain Malmain
4d3c6a3b9a
Fix libafl_qemu fuzzers not building in Docker (#1966)
* fixed rustup component added before switching to nightly.
added missing libafl_qemu source files.

* removed touch.
2024-03-24 11:07:33 +01:00
Maurice
f448b6fb24
libafl_nyx: Add bounds check for Nyx input buffer (#1963) 2024-03-23 18:31:07 +01:00
Maurice
a0d4a5b240
libafl_nyx: Add documentation to NyxSettings fields 2024-03-23 15:20:35 +01:00
Romain Malmain
44c841ffb1
WIP: QEMU exit handler (#1745)
* Added paging filtering.
Reworked address range filtering to fit with new generic code.

* Fix: renamed remaining QemuInstrumentationFilter instances.

* Renamed sync breakpoint to sync exit.

* Split emu in systemmode.rs / usermode.rs for specific code.
EmuExitHandler implementation.

* sync_backdoor.rs removal.
Formatting.

* Updated `bindgen` and `which`.
Adapting code to work with update.

* fix: reconfigure cleanly if prior configure was interrupted abruptly.

* Enable sanitizers in QEMU during debug.

* Added target-usable files.

* Added breakpoint structure.

* Adapted other files to work with ExitHandler.

* Adapted existing fuzzer to work with new exit handler.

* fix: use get to avoid crashes.

* Updated README to indicate cargo-make should be installed.

* Added QEMU internal exit handler.

* Adapted qemu_systemmode example with new exit handler.

* Fixed fuzzers to work with new exit handler.

* Trying to fix CI (#1739)

* test

* dummy

* dummy

* Added new examples.

* Forgot to add build scripts.

* format

* format

* clang-format

* python emulator adaptation.

* fixed python bindings.

* clippy fixes.

* python bindings.

* fix qemu_sugar.

* fix fuzzbench.

* fixed import issues.

* misc fixes.

* renamed crate.

* Updated x86_64 stub bindings.

* Fixed static naming.

* binding fmt

* clippy

* clippy

* Removed useless return statement.

* removed advice to install cargo-make in individual repositories.

* symcc_update (#1749)

* Remove unused create_anymap_for_trait macro (fixes #1719) (#1752)

* Fix `as_object` UB discussed in #1748 (#1751)

* Fix as_object UB discussed in #1748

* More cleanup, more less UB

* Fix fixes

* Added uninit_on_shmem api

* clippy

* fmt

* trying to fix fuzzers, libfuzzer wrapper

* Add OwnedRefMit::owned constructor, libfuzzer fix

* Some more fixes

* Add BacktaceObserver::owned fn

* fmt

* more fmt

* Ignore SigPipe by default (#1741)

* Ignore SigPipe by default

* Fix no_std

* fmt

* Fix incorrect imports (#1758)

* Fix incorrect imports

https://doc.rust-lang.org/core/simd/trait.SimdOrd.html

* Fix

* Try fix ci

* Documentation fixes (#1761)

* Documentation fixes

* Fix InProcessExecutor url

* Update all urls to latest

* Miri ignores for M1 regex (#1762)

* Enabling DrCov on Windows (#1765)

* Enabling DrCov for Windows

* Dedup common code in scheduler (#1702)

* dedup common code in scheduler

* del eco

* fixing

* fix

* replace `Emulator::new_empty` by `Emulator::get` calls outside of `emu.rs` for safety. (#1763)

* Add mute_inprocess_target fn, SimpleFdLogger::set_logger, and more (#1754)

* Add mute_inprocess_target fn, SimpleFdLogger::set_logger, set_error_print_panic_hook

* Trying to fix #1753

* typo

* More fix

* Fix test?

* more testcase fixes

* Fix: renamed remaining QemuInstrumentationFilter instances.

* Split emu in systemmode.rs / usermode.rs for specific code.
EmuExitHandler implementation.

* format

* format

* format

* Replace sync_exit with sync_backdoor.

* Rework command system.

* fix bad import.

* format.

* cargo fmt

* disable af-xdp as well to avoid linking errors.

* End of merging.

* format.

* Adaptation for usermode.

* format.

* injection support.

* usermode fixes.
format.

* clippy

* clippy + format

* Do not unwrap emu + format.

* fix: entry_point breakpoint

* inital commit.

* clippy

* tests

* clippy

* adapt example

* systemmode.

* renaming

* fmt

* fix lints.

* more lint fix.

* even more lint fixes.

* always more lint fixes.

* lint fix.

* allow unused qualifications for crate when it could be confusing.

* Still lint fixes.

* Lint fixes on generated code.

* Some lint fixes.

* merge continue.

* renamed modules as well.

* fixing merge.

* systemmode compiling.

* fmt

* fix early emulator drop.

* fmt

* fix cast to c_void of the wrong object.

* Added global enum for snapshot managers.
Some renaming.

* move things around.

* WIP: generic inclusion of QEMU Executor in exit handler.

* * Moved extern calls to `libafl_qemu_sys`
* Replaced old `Emulator` by `Qemu` and only kept C functions wrappers
* Now `Emulator` is for higher-level interactions with QEMU. Kept old functions for compatibility calling to `Qemu` functions
* A direct side effect of this slit is the removal of the `IsEmuExitHandler` trait dependency added in many parts of the code.
* Removed old dirty casting for `QemuExecutor` helpers and used the brand-new access to `QemuExecutorState` instead.
* Minor changes to `Qemu` and `Emulator` `get` methods for cleaner getters.

* Add missing `Qemu` function.

* Updated `qemu_systemmode` example.

* Adapted QEMU fuzzers + renaming.

* Fixed python.

* fix libafl_sugar with new implementation.

* fix dangling RefCell.
adapt new examples.
TODO: merge `libafl_systemmode.*` examples.

* clippy.

* fix more fuzzers.

* clippy.

* Implement `HasInstrumentationFilter` generically.
Updated `StdInstrumentationFilter` accordingly.

* Renamed breakpoint functions for QEMU.
`qemu.run()` handling.

* Removed OnceCell / RefCell in signature.
more explicit `MmapPerms` method names.

* minor code refactoring

* Emulator::run_handle refactoring

* deprecated Emulator functions calling directly to QEMU functions.

* IsSnapshotManager -> SnapshotManager

* IsEmuExitHandler -> EmuExitHandler + fmt

* Generic register when it makes sense.

* reverted IsSnapshotManager -> SnapshotManager because of a collision.

* fix syntax + clippy

* fmt

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: lazymio <mio@lazym.io>
Co-authored-by: Bet4 <0xbet4@gmail.com>
Co-authored-by: mkravchik <mkravchik@hotmail.com>
2024-03-22 18:03:29 +01:00
Maurice
50843b19d1
libafl_nyx: Allow custom input buffer size to be passed to NyxHelper (#1960)
* add option to specify input buffer size

* fix typo

* use `libafl::Error` as default error type

* derive `TypedBuilder` for `NyxSettings`

* update nyx_libxml2_standalone

* update nyx_libxml2_parallel

* update nyx_libxml2_standalone

* update nyx_libxml2_standalone

* update nyx_libxml2_parallel
2024-03-21 22:53:01 +01:00
Dongjia "toka" Zhang
6b94db2260
Use OwnedPtr in ListObserver (#1961)
* aaa

* clp
2024-03-21 19:46:42 +01:00
Dongjia "toka" Zhang
15f4613894
More usable ListFeedback (#1959)
* real list feedback

* add

* fox

* obs

* fix

* FMT

* more

* fmt

* rev
2024-03-21 16:21:15 +01:00
Dominik Maier
7abc26ebc9
Change AnyMap API, add unsafe_ assert (#1958)
* Change AnyMap API, add unsafe_ assert

* clippy

* Add anymap serialize test

* Add test

* fmt
2024-03-20 14:45:23 +01:00
Dominik Maier
14fd3040bd
Remove hash for AnyMap (since it's a hashmap already) (#1951) 2024-03-19 20:41:15 +01:00
Dominik Maier
2efa747292
SerdeAnyMap: add unsafe_stable_anymap feature that uses type_name instead of TypeId::of (#1952)
* Test: Use type_name instead of type_id in AnyMap

* Hide behind 'unsafe_stable_anymap' feature

* nostd?

* rename fn

* cleanup a bit
2024-03-19 20:15:31 +01:00
am009
5eab4fb78b
Update tinyinst_simple to support Linux (#1316) (#1955)
* Make fuzzers/tinyinst_simple support Linux (#1316)

Fix a documentation error for `MmapShMemProvider`.

* Support shmem for `fuzzers/tinyinst_simple` on Linux.

Format code.

* Fix CI to install cxxbridge-cmd.

* Add `CARGO_TARGET_DIR` in makefile to fix CI.
2024-03-19 20:15:07 +01:00
Michael Chen
fde9cda5ee
Gramatron: Upgrade automaton files (#1956)
`auto.postcard` file is following `postcard@0.7` wire format, which is
not compatible with the `postcard@1.0` dependency. `auto.json` is out of
date with the latest `Trigger` struct definition. Regenerated both using
the data from `auto.postcard`
2024-03-19 20:09:47 +01:00
Romain Malmain
928cf80782
fix unwrap. (#1954) 2024-03-18 18:51:19 +01:00
Dongjia "toka" Zhang
0f26f6ea32
Remove useless feedback (#1953)
* stuff

* FMT

* remove stuff
2024-03-18 16:41:43 +01:00
Dominik Maier
a0143d02a6
Rename OSError -> OsError and merge with redundant Error::File (#1944)
* OSError -> OsError

* Move File errors to io Errors

* Removing File errors

* fixes :)

* More format

* fix libfuzzer runtime
2024-03-18 08:46:48 +01:00
Stefan Zabka
fbd0d497d4
Refactor(build.rs): extract common code between branches (#1950) 2024-03-17 21:31:30 +01:00
Dongjia "toka" Zhang
44a37da680
Use const_assert not assert (#1949)
* stuff

* FMT
2024-03-16 03:33:20 +01:00
Dongjia "toka" Zhang
c6420c0987
Separate fuzzbench fuzzers's test (#1947)
* separate fuzzbench test

* upd
2024-03-15 19:44:22 +01:00
Dongjia "toka" Zhang
34b4a6ac1d
Better error message instead of "No entries in corpus" 2024-03-15 19:19:55 +01:00
Dongjia "toka" Zhang
c6875b8cf6
Fix self.iterations underflow (#1942)
* fix

* fix

* FMT
2024-03-15 19:13:58 +01:00
Dongjia "toka" Zhang
e30ff57456
Update exec counts in objective (#1945)
* fix

* fix

* update exec count
2024-03-15 18:52:53 +01:00
Dongjia "toka" Zhang
5cc0180835
Fix self.restart_helper.execs_since_progress_start in calibration stage (#1943)
* fix

* fix
2024-03-15 18:31:44 +01:00
Dongjia "toka" Zhang
ee6385c25b
Fire events in append_metadata not in is_interesting (#1936)
* stuff

* ok

* Recalc filled slightly differently... (#1939)

* Recalc filled slightly differently...

* Make requested changes as per PR review

* unused

* fix

---------

Co-authored-by: Dan Blackwell <danblackwell95@yahoo.co.uk>
2024-03-15 13:24:26 +01:00
Romain Malmain
b3ddab3bce
fix libafl_qemu_sys unnecessarily rebuilding. (#1938) 2024-03-14 18:25:19 +01:00
Dominik Maier
04d87ccc89
Remove (almost) unused stage_idx (#1929)
* Remove (almost) unused stage_idx

* Fix text-based test

* fixed critical whitespace

* clippy

* more fmt

* fix push stage
2024-03-14 13:14:57 +01:00
am009
93f67aa405
Fix os error printing in unix_shmem (#1406) (#1935)
Use `std::io::Error::last_os_error` instead of `libc::perror` for error printing in unix_shmem.
Add a new enum item `OSError` to enum Error.
2024-03-14 13:07:04 +01:00
Dongjia "toka" Zhang
afa2965f3c
Remove some arguments from pre_exec/post_exec in ExecutorHook (#1933)
* refactor

* no std, fmt

* win mac

* state

* frida

* ctx

* trait bound

* clip
2024-03-13 18:49:09 +01:00
Dominik Maier
4f3d9d2e50
Tiny optimization for into_vec (#1931)
* Tiny optimization for into_vec

* fix bug
2024-03-13 16:52:15 +01:00
Dongjia "toka" Zhang
44aec56f7e
remove more args (#1934) 2024-03-13 16:17:46 +01:00
Dominik Maier
2763d945a3
Cleanup last redundant corpus_idx usages (#1930)
* Cleanup last redundant corpus_idx usages

* More cleanup
2024-03-13 01:24:11 +01:00
Romain Malmain
9b96149f6c
Do not build doc with all features. (#1928)
Add documentation about default features for documentation.
2024-03-12 23:08:37 +01:00
Dongjia "toka" Zhang
5f67b9fbc4
Event Manager handle_in_client hooks (#1916)
* event manager hooks

* tcp

* fix

* FMT

* fix

* fix
2024-03-12 14:39:16 +01:00
Stefan Zabka
fe1c7a34b7
Dockerfile: setup for building libafl_qemu in Docker (#1899)
* fix(Dockerfile): add build_linux.rs to libafl_qemu and libafl_qemu_sys

* fix(Dockerfile): workaround for llvm.sh failing on bookworm

Revert this once https://github.com/llvm/llvm-project/issues/62475 has been resolved

* fix(libafl_qemu): add unsafe to callbacks

* chore(devcontainer): update devcontainer to work with newer VSCode versions

* revert(libafl_qemu): revert unsafe keyword

* fix(devcontainer): move settings and extension under customizations.vscode

* fix(devcontainer): use postCreateCommand instead of initializeCommand
2024-03-12 01:00:35 +01:00
Dominik Maier
dd410c590a
Allow dyn in StagesTuple, add Current Testcase API, Untraitify Progress (#1915)
* Move into_vec to extra trait

* fix no_std

* First step towards stages tuples as vecs

* Allow dyn in StagesTuple, add Current Testcase API, un-traitify Progress, cleanups

* Move from generics to impl keyword, more replacements with better API

* rename fn

* Fix additional stages, more cleanup, rename progress to retries

* Fix more fixes

* Fixes

* Rename ProgressHelper -> RestartHelper

* Fix sugar, python, add perform_restartable

* fixes

* remove prelude bs

* rename to restart_progress_should_run

* more cleanup, remove tests I don't understand (sorry)

* fix docs

* more fix

* fix miri

* unsafe safety annotations

* more comments

* last docs

* Mixed_attributes only allowed for bindgen
2024-03-12 00:58:07 +01:00
Mohammad Omidvar
61046c4157
Fix reproducibility of the docker image (#1924)
Add `--locked` flag when installing `sccache` in the first stages to ensure the image gets built when the base image's Rust version satisfies `sccache`'s MSRV.

Fixes #1923 🐛

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-03-11 19:15:54 +01:00
Dongjia "toka" Zhang
9b780cc0a7
Fix UB in anymap.rs and other minor warnings. (#1926)
* fix

* clippy

* fix
2024-03-11 18:15:56 +01:00
7e79f4051d clean trace from ISRs without effect, prevent race-conditions 2024-03-09 13:41:26 +01:00
6793d48dbd extract ABBs 2024-03-08 14:04:23 +01:00
Romain Malmain
e745401a39
Update QEMU version. (#1922)
* update QEMU version.

* clippy
2024-03-08 13:15:00 +01:00
Aarnav
d6fe67c3c8
Introduce multicore loading for the initial seed corpus (#1905)
* introduce multicore load initial corpus

* update fuzzers/libfuzzer_libpng_norestart to use multicore corpus loading

* run clippy

* use CoreId and Cores in state if std

* misc. typos

* adapt multicore load initial inputs to allow resumable corpus loading
in case of crashes or timeouts during corpus loading.

* add std feature flag to multicore_inputs_processed

* fix doc comment

* run fmt for example fuzzer

---------

Co-authored-by: aarnav <aarnav@srlabs.de>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-03-08 02:56:08 +01:00
Dongjia "toka" Zhang
1b9f4ea29c
Fix batched timeout (#1920)
* fix ptr

* fix ptr

* fix

* One less windows warning

* One less windows warning
2024-03-07 23:52:56 +01:00
Romain Malmain
781e830923
fix cast to c_void of the wrong object. (#1921) 2024-03-07 21:28:28 +01:00
Mrmaxmeier
6747a7dc2f
token mutations: avoid a few infallible unwraps (#1919) 2024-03-07 18:26:59 +01:00
Mrmaxmeier
e48c8c0e23
fuzzbench_ctx: fix duplicate package warning (#1918)
Cargo previously complained when loading libafl as a git dependency:

warning: skipping duplicate package `fuzzbench` found at
`~/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/55a300d/fuzzers/fuzzbench`
2024-03-07 17:56:40 +01:00
Dongjia "toka" Zhang
9a2e7b0e64
Fix redundant xor in Ngram calculation (#1901)
* fix double xor

* tmp

* clp

* no notnightly

* fix

* plural
2024-03-07 14:49:01 +01:00
Stefan Zabka
2ac075024b
fix(Dockerfile): allow running commands with docker run (#1894)
* fix(Dockerfile): allow running commands with docker run

According to
<https://gitlab.com/gitlab-org/gitlab-runner/-/issues/2109#note_47480476>
adding the "-c" to the ENTRYPOINT is necessary to be able to run
commands like `docker run libafl "cargo build"`

* fix(Dockerfile): restore ability to docker run without command

As `bash -c` always requires a string, the previous commit
removed the ability to just `docker run -it libafl` and
get a shell.
This commit restores that ability
2024-03-06 19:14:18 +01:00
Dongjia "toka" Zhang
969aa12c7e
aa (#1913) 2024-03-06 19:05:32 +01:00
Romain Malmain
3b3e2f6efa
Improve readability of InProcessExecutor-related code (#1912)
* inital commit.

* clippy

* tests

* clippy

* adapt example

* systemmode.

* renaming

* fmt

* fix lints.

* more lint fix.

* even more lint fixes.

* always more lint fixes.

* lint fix.

* allow unused qualifications for crate when it could be confusing.

* Still lint fixes.

* Lint fixes on generated code.

* Some lint fixes.

* renamed modules as well.

* Separated inner from InProcessExecutor.

* fix

* unused import

* unused import

* fix import

* fix import
2024-03-06 00:30:35 +01:00
Romain Malmain
55a300d508
Make executor state available to the harness V2 (#1900)
* inital commit.

* clippy

* tests

* clippy

* adapt example

* systemmode.

* renaming

* fmt

* fix lints.

* more lint fix.

* even more lint fixes.

* always more lint fixes.

* lint fix.

* allow unused qualifications for crate when it could be confusing.

* Still lint fixes.

* Lint fixes on generated code.

* Some lint fixes.

* renamed modules as well.
2024-03-05 19:28:46 +01:00
Rayhan Faizel
44b0b0ad82
libafl_targets/src/cmplog.c: Fix warning for deprecated syscall() in macOS (#1911) 2024-03-05 19:04:20 +01:00
Dan Blackwell
cd8003ee69
Fix for #1881, ProbabilitySamplingScheduler seems to be inverted (#1884)
* Fix for #1881, ProbabilitySamplingScheduler seems to be inverted

* Run 'cargo +nightly fmt'

* Added debug_assert as negative and infinite probability values would break the current implementation of next()

---------

Co-authored-by: Dan Blackwell <danblackwell@eduroam-int-dhcp-97-192-218.ucl.ac.uk>
Co-authored-by: Dan Blackwell <danblackwell@ML-W0NYVW4XCK.local>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-03-05 19:04:13 +01:00
Dongjia "toka" Zhang
e3f837d712
Fix inconsistent settings of client_timeout (#1897)
* a

* fix client timeout

* revert

* more

* std

* import

* import

* sdt

* FMT

* backtick again
2024-03-05 17:58:44 +01:00
Dongjia "toka" Zhang
1a0e692f33
Print PID when you create a new Llmp Sender. (#1898)
* aaaa

* FMT

* adding std
2024-03-05 16:02:47 +01:00
Dongjia "toka" Zhang
95bed5b016
Fix the centralize disconnection bug. (#1896)
* fixing the first bug

* backtick
2024-03-05 15:49:35 +01:00
Romain Malmain
d96a1426d5
Fix lint errors (#1909)
* fix lints.

* more lint fix.

* even more lint fixes.

* always more lint fixes.

* lint fix.

* allow unused qualifications for crate when it could be confusing.

* Still lint fixes.

* Lint fixes on generated code.

* Some lint fixes.
2024-03-05 14:16:26 +01:00
a045b7bcd6 track api calls and isrs 2024-03-05 09:56:13 +01:00
Dominik Maier
b7efe8eb7d
Implement MutatorTuple for Vecs to allow Dynamic Mutator Choices (#1893)
* Implement MutatorTuple for Vecs to allow Dynamic Mutator Choices

* fix test

* clippy

* Move into_vec to extra trait

* fix no_std

* more nostd

* no_std
2024-03-04 22:48:38 +01:00
Addison Crump
f3c37db2b7
TransferFeedback for determining if a testcase was from another node (#1906)
* impl TransferFeedback

* whoops, fix build

* fix doc

* fix build for tcp manager

* fix fr
2024-03-04 15:33:46 +01:00
Addison Crump
035c01b4a1
update libfuzzer docs about macos (#1903) 2024-03-01 18:26:22 +01:00
Dongjia "toka" Zhang
1a41e65a5b
Sancov based ngram & ctx implementation (#1864)
* ngram

* ctx

* push stuff

* passing cargo check

* save stuf

* add

* no default

* fuzzbench ready

* formatt

* aaaaaaaa

* adaptive map

* add all

* chg

* fix

* deleting stuff

* fmt

* clang18

* fuck

* save space

* fix?

* feature name

* fucking nightly only

* harness

* fix libafl_cc

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-03-01 13:59:13 +01:00
Addison Crump
8c773a6b85
Implement RetryProgress for limiting retry attempts in stages (#1890)
* do that again but smarter

* remember to register

* appease the clippy

* cleanup

* autofix clippy

* more clippy fixes

* more clippy...

* small clippy fix

* with_tries => with_retries

* most recent suggestions

* final clippy... hopefully
2024-02-28 14:12:28 +01:00
Addison Crump
7a4fb06d02
make nopstate public so that it can be used as reproducer (#1888) 2024-02-27 16:48:08 +01:00
5d9bcba0e6 break on all api functions 2024-02-26 08:40:07 +01:00
Dongjia "toka" Zhang
1dcfe8ef56
Make the map size larger for some of the example fuzzers (#1879) 2024-02-23 17:19:00 +01:00
Dongjia "toka" Zhang
19f5081bd8
Add several warnings when starting forkserver (#1877) 2024-02-22 14:58:51 +01:00
Dongjia "toka" Zhang
b97598d239
Windows fix (#1876)
* win fix

* just some ci

* test

* revert

* aaaaa

* bbbbbb
2024-02-22 14:56:30 +01:00
Dongjia "toka" Zhang
2bfe91e4bd
Fix a corner case where bitmap_size = 0 leads to panic (#1875) 2024-02-19 22:42:44 +01:00
Dominik Maier
263af87652
Less useless allocs for monitor display (#1874)
* Less useless allocs for monitor display

* More less String

* Lol who needs generics

* clippy

* remove &String
2024-02-19 21:15:11 +01:00
w1tcher
f48e281be8
Fix TuiUI deadlock under multi-threading (#1871)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-02-19 17:20:08 +01:00
sadeli413
ef16e645b7
Support raw byte grammar in NautilusContext (#1868)
* Support raw byte grammar in NautilusContext

* Add `use` statement in doc comment
2024-02-19 16:46:28 +01:00
Dominik Maier
fafe8f5ce8
Fixing clippy some more (#1872)
* Fixing clippy some more

* more commit

* Git gud

* remove more useless imports
2024-02-19 16:46:06 +01:00
Dominik Maier
578a22a3d9
Revert "Companion patch to qemu-libafl-bridge #46 (#1830)" (#1865)
This reverts commit b999b4aac591818d4342773ff48e98f2896f141e.
2024-02-16 20:50:18 +01:00
Sameer Puri
50892ddc75
Finalize macOS support for libafl_libfuzzer (#1843)
* libafl_targets: on macOS, do not provide a default implementation for weak functions

* libafl_libfuzzer: update README to talk about macOS specifics

* libafl_targets: allow __sanitizer_cov_pcs_init to be called more than once

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-02-15 22:45:15 +01:00
Dominik Maier
0a995f241c
Cleanup Pointer Clippy Lints (#1861)
* Fix pointer clippy lints

* More clippy

* fix build

* fix
2024-02-15 16:31:18 +01:00
cube0x8
b999b4aac5
Companion patch to qemu-libafl-bridge #46 (#1830)
* fixing qemu-libafl-bridge #46

* cargo fmt

* updated QEMU revision

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-02-15 16:30:05 +01:00
Rubens Brandão
97a83aba3b
feature(libqasan): add strndup (#1860)
* feature(libqasan): add asprintf and vasprintf

* feature(libqasan): add asprintf and vasprintf to hotpatch

* feature(libqasan): add strndup
2024-02-15 16:13:46 +01:00
Rubens Brandão
d6d6a23f69
feature(libqasan): add asprintf and vasprintf (#1844)
* feature(libqasan): add asprintf and vasprintf

* feature(libqasan): add asprintf and vasprintf to hotpatch

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-02-15 13:56:35 +01:00
Romain Malmain
5151f1e35c
fix qemu linking error. (#1846)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-02-15 00:29:33 +01:00
Dongjia "toka" Zhang
49ad380068
fix (#1859) 2024-02-14 23:28:20 +01:00
Dongjia "toka" Zhang
db88412738
Make cmp_extend_encoding panic-less (#1857)
* Add a panic check for aflpp

* aa

---------

Co-authored-by: novafacing <rowanbhart@gmail.com>
2024-02-14 11:46:09 +01:00
mkravchik
c837d0df7a
Pr/xxh3 rrmxmx mixer fix (#1828)
* Fixing the mixer according to the xxHash implementation

* Using Rust xxhash-rust instead of handwritten implementation

* Fixing the mixer according to the xxHash implementation - linking directly, not relying on bolts option

* clippy+fmt

* Removing rotation, as it causes issues

* Not using xxhash directly, relying on bolts

* Fmt
2024-02-14 11:45:47 +01:00
tbethe
b9650045f6
Getter for mutable reference to forkserver (#1849)
* Getter for mutable reference to forkserver

* Whoops

---------

Co-authored-by: Timme Bethe <git@timmebethe.nl>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-02-13 16:10:26 +01:00
Dongjia "toka" Zhang
cefb73861f
Fix token mutation crash (#1855)
* clippy

* token mutation fix
2024-02-13 16:10:02 +01:00
Dongjia "toka" Zhang
973c4358e6
clippy (#1851) 2024-02-13 13:19:00 +01:00
RobertBuhren
af97033d85
Fix x86_32 build: Don't build functions using uint128_t data type on x86_32 (#1854) 2024-02-13 12:49:52 +01:00
3817892ff1 Fix graph output formatting 2024-02-13 08:28:53 +01:00
Dominik Maier
dede78159c
Remove unused shmem structs, update Nix (#1845)
* Remove unused shmem structs

* More unused stuff

* Unified crate versions, updated docker rust version

* clean up nix 27 mess?

* Windows?

* Fix frida

* Fix frida

* fix fuzzers with nix
2024-02-11 17:45:09 +01:00
Niklas Gögge
15c98de52f
fuzzers: Fix qemu_launcher zlib include path (#1841) 2024-02-08 13:08:36 +01:00
beee8d8cb7 rewrite info dumps as macros 2024-02-08 10:08:25 +01:00
Rubens Brandão
40c8645ed3
Fix libafl_qemu libqasan Makefile (#1835)
* fix libafl_qemu libqasan Makefile

* remove make clean from libafl_qemu libqasan build

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-02-07 15:36:36 +01:00
Andrea Fioraldi
41d24ca375
Fix broken closure hooks in libafl_qemu (#1839)
* Fix broken crash hook

* fix hooks

* clippy

* pin
2024-02-07 15:03:27 +01:00
Romain Malmain
9b82af4539
Configurable LLMP client timeout (#1838)
* LLMP client timeout is now configurable.

* fix example.

* Fix for no-std case.
Make default timeout private.

* Fix import.
2024-02-06 18:35:27 +01:00
Addison Crump
c3473e5631
use truncate, not pop (#1837) 2024-02-05 20:48:17 +01:00
Addison Crump
054d0a6b19
OptionalStage is a nested stage, fix stage ID handling (#1836) 2024-02-05 17:51:01 +01:00
Dominik Maier
7d9559b570
Fix Benches (#1833) 2024-02-05 17:19:23 +01:00
Romain Malmain
99a70e5771
Update qemu-libafl-bridge with upstream. (#1829)
QEMU update to v8.2.1
2024-02-05 14:24:02 +01:00
Rubens Brandão
241b93036e
Fix libafl_qemu hooks references (#1825)
* fix libafl_qemu hooks references

* restrict the fatptr transmutation
2024-02-02 21:52:58 +01:00
Nereuxofficial
5c18dca792
Fixed Link in baby_fuzzer_nautilus (#1824) 2024-02-01 12:07:13 +01:00
Rubens Brandão
c96d103b37
HookId trait and types in libafl_qemu (#1796)
* libafl_qemu fix remove_hook

* libafl_qemu specialize hooks into separated types

* libafl_qemu generalize HookState to allow any HookId implementation

* fmt: external C qemu hook functions

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2024-02-01 10:55:55 +01:00
Sameer Puri
13dd1cc4ec
libafl_libfuzzer: macOS build support (#1711)
* libafl_libfuzzer: macOS support

* make clippy happy

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-01-31 02:41:08 +01:00
Dongjia "toka" Zhang
a4f753b0f0
Merge TimeoutForkserverExecutor into ForkserverExecutor (#1819)
* delete timeout forkserver

* clippies

* name

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-01-30 17:34:39 +01:00
Karthik Prakash
519ea435ed
LibAFL_libFuzzer: Default ignore_* flags to true when tui=1 (#1820)
* default `ignore_*` flags to true if `tui=1`

* update docs

* refactor code to use `Option<bool>` instead of extra struct members
2024-01-30 16:25:59 +01:00
Dominik Maier
8b0068e39d
Fix Clippy (#1822) 2024-01-30 16:25:10 +01:00
Dominik Maier
244c6b0da5
QEMU: Fix injections build for hexagon, disable on system mode (#1821)
* Fix CI for Clippy, QEMU

* Clippy, fixes for system mode

* clippy

* clippy

* fixing new clippy
2024-01-30 04:25:14 +01:00
Karthik Prakash
07f9a9d06a
Remove create_serde_registry_for_trait macro (#1815)
* remove `create_serde_registry_for_trait` macro

* fix `clippy` errors

* fix formatting
2024-01-28 17:51:50 +01:00
Dominik Maier
e7df233dc1
QEMU: add injections mode default (#1818) 2024-01-28 17:12:20 +01:00
Marco Vanotti
e6184936ce
Expose PCs table to map coverage bitmap entries to the corresponding code (#1812)
This table allows users to map between coverage bitmap entries and the
corresponding code in memory.
2024-01-25 16:51:13 +01:00
Rubens Brandão
59945fbcc9
Fix typo on qemu_launcher options help message (#1816) 2024-01-25 13:50:20 +01:00
Harrison Green
e117b7199c
Allow testcase removal during fuzz loop (#1717) 2024-01-24 17:56:24 +01:00
Dominik Maier
6a0ba7b647
Add SimpleMgr feature to qemu_launcher (#1790) 2024-01-24 17:54:52 +01:00
Dominik Maier
0cb7b25f39
Replace static borrows with addr_of!, rust 2024 compatibility (#1800)
* Less UB

* fmt

* fix warning

* clippy fixes

* addr_of_mut allthethings

* removed duplicate import

* fix imports

* remove comment

* more windows

* fmt

* fix tests

* fixes

* qemu

* fix more cases, qemu

* fix

* fmt
2024-01-24 17:47:55 +01:00
Dongjia "toka" Zhang
bb443027f7
Observer fix (#1807)
* fix

* Increase default edgemap size for libafl_cc and libafl_targets (#1798)

* fmt

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2024-01-24 03:30:22 +01:00
Sharad Khanna
1458c3efff
Fix build issues in frida cmplog for aarch64 (#1813)
* Fix build issues for aarch64

* cargo fmt
2024-01-24 01:18:31 +01:00
Romain Malmain
a0e30d01d3
QEMU: safe linking of extern "C" declarations (#1810)
* safe linking initial commit

* Fix static declaration.

* Works also for static variables, even for thread-unsafe types.

* Remove warnings.

* fixed visibility for function.

* remove `rustversion` from dependencies.
2024-01-23 22:38:06 +01:00
Dongjia "toka" Zhang
2ac154d473
Refactor InProcessExecutor, merge timeout executors (#1789)
* move windows, inprocess fork to a different file, try new hook mechanism for the executor

* fix

* even more

* more

* more

* fix

* fix

* macosgit add -ugit add -u

* windows!

* windows!

* aa

* aa

* macos

* std

* wtf unresolved?

* Copy, Clone

* why you just don't have the same API!

* inproc

* next; inprocess

* windows?

* ci

* ci

* ci

* unused

* ci

* unused

* no_std

* windows no std

* fix

* inprocess

* fix

* windows

* fuzzers

* macos , book

* fix

* aa

* allow

* fix

* stop suggesting wrong lint AAAAAAAAAAAAAAAAA!!!

* stop suggesting wrong lint AAAAAAAAAAAAAAAAA!!!

* win

* fix

* wip

* wip2

* windows done?

* remove TimeoutExecutor

* ci

* ci

* miri

* fixfi

* compile on windows

* a

* clp

* no_std stuff

* windows no_std

* mac stuff

* m

* a

* ci

* ci

* deleting timeoutexecutor, gradually

* fucking macos

* ci

* test

* ci

* ci

* batch mode constructor

* fix

* ci

* aa

* miri

* aaa

* tmate again

* fix windows stuff

* final fix

* another win fix

* add

* let's add the new fix later

* more

* fi

* parse

* win clippy

* win no std

* safety

* fix

* DEFAULT

* final fix

* libafl_libfuzzer

* comments

* fix

* fix fuzzres

* fixxxxx

* fixxxxx

* last fix

* change name
2024-01-23 22:35:14 +01:00
Josef Haider
058d2c0825
Remove unnecessary PartialEq trait constraint on DiffFeedback observers (#1811) 2024-01-22 20:23:32 +01:00
expend20
72c862171e
POC attempt to make cmplog work on x64 (#1713)
* POC attempt to make cmplog work on x64

windows POC seems working

unix POC seems working :)

* no register collisions
* rsp-related ref support

iced optional dep

iced depends on cmplog

warnings

one more warning

comments cleanup

ci unbreak

rebase windows unbreak

rebase unix unbreak

unix only

fmt check

clang formatting

clang formatting again

make clippy happy

formatting

double import

windows unbreak

hashmap is conditional

leftover definition

tutorial related formatter

review fixes

comments

.asm fuzz targets for cmplog on Windows

more tests

rip-relative reference support without index register form

proper ignore rip-related references and ignore 8 bit comparisons

another try_into packing

* harness modification reverted

* dummy commit to restart CI

* review comments

---------

Co-authored-by: sbarsky <sbarsky@denuvo.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-01-19 11:52:15 +01:00
WorksButNotTested
e615cb4aed
Disable QemuInjectionHelper if not configured (#1804)
Co-authored-by: Your Name <you@example.com>
2024-01-18 18:53:42 +01:00
Dongjia "toka" Zhang
df8fa71aa7
Revert "Increase default edgemap size" (#1803) 2024-01-18 14:58:29 +01:00
Dongjia "toka" Zhang
001e132186
Fix windows after #1350 (#1801)
* fix

* apt update

* apt update

* a

* split even more

* tmate

* ci

* can't fix this shit

* s
2024-01-17 18:51:56 +01:00
2ac7874895 fix build 2024-01-16 15:53:57 +01:00
David CARLIER
61718c4e88
bolts: fix static mutable use (#1793) 2024-01-16 14:32:42 +01:00
Dongjia "toka" Zhang
c240cdec38
Increase default edgemap size for libafl_cc and libafl_targets (#1798) 2024-01-14 01:25:22 +01:00
Dongjia "toka" Zhang
e72ad4ba2d
remvoe it (#1797) 2024-01-14 01:23:53 +01:00
Dongjia "toka" Zhang
3ed231db69
Don't use assert fail when building on libafl_libfuzzer on windows (#1792)
* fix

* fix

* clippy

* clippy
2024-01-13 16:02:10 +01:00
mkravchik
6a72f8a1ad
libafl_frida: Add tests for ASan for Unix platforms (#1781)
* First draft of a Asan tests. As of now, unix-only. This is a WIP, as 1) destroying Gum causes segmentation fault and thus a single test is supported by using a static Gum object. Ideally, this should be fixed and a new Gum instance would be created for each test. 2) 70 identical errors are reported by Asan instead of a a single one. Apart from that, the draft fixes a number of errors found in Asan

* Fmt fixes

* PR comments addressed

* Not crashing upon Asan errors while testing

* More PR comments: removing env_logger, renaming harness to test_harness

* Revert "More PR comments: removing env_logger, renaming harness to test_harness"

This reverts commit 2d3494b3f56e0a5ef23566cb9a884e8c57867b57.

* More PR comments: removing env_logger, renaming harness to test_harness

* Checking for clang presence and failing the test if harness not found

* Fmt

* Running multiple Asan tests

* Cpp Fmt

* clang-format

* More clippy complaints and Apple compilation

* Last clippy complaints (ran scripts/clippy.sh)

* Fixing unused MacOS function

* Fixing unused MacOS imports
2024-01-11 13:26:00 +01:00
Andrea Fioraldi
aaeeead574
Remove Aggregated label in stats (#1788)
* Remove Aggregated label in stats

* introspection

* fix monitor aggregate propagation
2024-01-10 21:05:19 +01:00
mkravchik
b93a5bb414
Pr/fix qemu launcher build - fixes 1785 (#1786)
* Fixing qemu_launcher build (#1785)

* Fixed the instructions for using the injection feature
2024-01-10 13:17:53 +01:00
van Hauser
0f2cf80085
libafl_qemu injections (#1743)
* nits

* first steps

* different approach

* fixes

* remove temps

* remove temp

* initial import

* more tests

* bug hunt

* cleanup

* yaml function target 0x.... support

* final

* update doc

* other work

* Clippy, fmt

* Removed lazystatic dependency

* More small cleanups

* optimize to_lowercase

* move funtionality to libafl_qemu

* add missing file

* ready

* remove qemu_injections

* move test files to test directory

* doc update

* add todos

* fixes

* add file comment

* add test and other platform support

* fix clippy

* Replace Emulator::new_empty by Emulator::get.
Fix visibility identifier.

* clippy

* let's try this

* cpu_target?

* fmt

* cleanup build system, enable missing fuzzers

* fix qemu_launcher

* enable hexagon in qemu_launcher

* Removed useless `any` predicate in cfg attribute.
Replaced wrong types in `syscall_hook` signature.

* format

* move to read_function_argument

* add hexagon injections support

* enable injections fuzzing everywhere

* unify error msg

* Fix build, add initial toml support

* intermediate push, wip

* fix build

* More WIP

* Fix build

* Clippy

* fix qemu

* Fix arm

* fix more wrong things

* fix testcase

* try to fix it again?

* more release?

* make makefile independent of dev/release

* trying more fix?

* More ugly more works

* more trying to fix the testcase

* allow yml as filename too

* more docs

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2024-01-09 19:56:19 +01:00
Addison Crump
ba8ca6723b
Resumable stages redux (#1780)
* initial stage refactor

* repair test

* redqueen

* fixup python bindings

* docs and clippy fixes

* misc hidden changes

* Status => Progress

* fix remaining fuzzers

* fix libafl_libfuzzer

* implement resume for nested stages

* deep testing for stage resumeability

* refactor: use let-else, docfix

* refactor in fuzzbench_forkserver_cmplog

* fmt

* actually use progress

* HasStageStatus => HasCurrentStage
2024-01-09 15:18:14 +01:00
Dongjia "toka" Zhang
3d126f21cc
aggregator fixer (#1783) 2024-01-08 19:36:41 +01:00
Dominik Maier
88f3ff4a28
Clang-format latest (#1651)
* Clang-format latest

* add

* rdm

* CHATGPT

* CHATDUMB

* different action

* no

* fix

* ci

* ci

* ci

* fuck

* dir

* checkout?

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* don't use shit

* ci

* ci

* ci

* FMT

---------

Co-authored-by: toka <tokazerkje@outlook.com>
2024-01-05 23:32:06 +01:00
Gheorghiță Mutu
48c9fed2da
[libafl_targets] # fix typo in windows_asan feature (#1779) 2024-01-05 23:31:57 +01:00
Dongjia "toka" Zhang
0a72d8abbc
Add header (#1777)
* add

* rdm

* CHATGPT

* CHATDUMB

* different action

* no

* fix

* ci

* ci

* ci

* fuck

* dir

* checkout?

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* don't use shit

* ci

* ci

* ci
2024-01-05 19:35:36 +01:00
Dominik Maier
207e7dbdff
Move Clippy to extra CI steps (#1370)
* Move Clippy to extra CI steps

* clippy?

* Last try with nightly

* no clue why but hey

* cleanup

* more

* revert

* check ubuntu works

* f

* debug

* clippy_ci

* remove tmate

* regex

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2024-01-04 21:50:14 +01:00
Dongjia "toka" Zhang
989dd4d89a
More concolic fix (#1776)
* more

* revert
2024-01-04 21:28:11 +01:00
Dongjia "toka" Zhang
616e507593
Update symcc for #1768 (#1775) 2024-01-04 14:25:47 +01:00
Addison Crump
99fd69acdc
Multipart Input support (#1617)
* initial commit: multipart

* document + wrap up baby fuzzer

* oops

* core

* add from method, option to iter

* improve example; use minmap; fix initial_mut

* bindings

* clippy, again

* moar clippy

* fmt

* drop rand dep because we don't need it, actually

* docfix

* ok actually fix docs pls
2024-01-04 01:51:29 +01:00
Dongjia "toka" Zhang
75fcd47044
Recover useful CmpLog updates from #1630 (#1684)
* add

* ci

* wip

* make type name more clear

* last

* add

* more fix

* chg

* fmt

* save changes

* fix_handler

* cfg

* win

* fix

* toml

* f

* more

* fix all the stuff

* fix

* revert fuzzers/fuzzbench to origin/main
2024-01-03 23:44:32 +01:00
Konstantin Bücheler
9b2a17896f
Fix export of afl-clang-fast if already in PATH (#1773) 2024-01-03 23:22:42 +01:00
Dongjia "toka" Zhang
8164bfca96
Fix sigint handlers (#1772)
* fix_handler

* cfg

* win

* fix

* toml

* f

* more

* rename and write_volatile
2024-01-04 04:57:41 +09:00
Romain Malmain
b8d48013c0
updated QEMU. Adapted emu.rs to fit new interface. (#1774)
* updated QEMU. Adapted emu.rs to fit new interface.

* format
2024-01-03 20:10:20 +01:00
Dominik Maier
d143cac663
Fix atheris fmt, clippy (#1769) 2024-01-02 23:12:37 +01:00
Dominik Maier
925b33889f
LibAFL Atheris Compatibility (#1576)
* Made changes to libafl_atheris/src/lib.rs to work with Atheris

* Removed unused imports

* Ran  on libafl_atheris

* Fixed issue with using extra_counters and issue with using println

---------

Co-authored-by: eceo902 <evan.seeyave@gmail.com>
Co-authored-by: Evan <53020947+eceo902@users.noreply.github.com>
2024-01-02 22:18:34 +01:00
Bet4
4f93d7e894
Check canonicalized_module_path before used (#1767) 2024-01-02 18:16:02 +01:00
David CARLIER
440e57dd6f
afl_cc llvm 18 build fixes (#1759) 2024-01-02 14:13:52 +01:00
Dominik Maier
a07563def0
Add mute_inprocess_target fn, SimpleFdLogger::set_logger, and more (#1754)
* Add mute_inprocess_target fn, SimpleFdLogger::set_logger, set_error_print_panic_hook

* Trying to fix #1753

* typo

* More fix

* Fix test?

* more testcase fixes
2024-01-01 23:14:59 +01:00
Romain Malmain
38e16fbade
replace Emulator::new_empty by Emulator::get calls outside of emu.rs for safety. (#1763) 2024-01-01 18:49:11 +01:00
Dongjia "toka" Zhang
2717018601
Dedup common code in scheduler (#1702)
* dedup common code in scheduler

* del eco

* fixing

* fix
2024-01-01 18:22:03 +01:00
mkravchik
df96bb02ee
Enabling DrCov on Windows (#1765)
* Enabling DrCov for Windows
2023-12-27 11:10:04 +02:00
Dominik Maier
9ad7d9bb64
Miri ignores for M1 regex (#1762) 2023-12-27 00:36:21 +01:00
Bet4
ce71858100
Documentation fixes (#1761)
* Documentation fixes

* Fix InProcessExecutor url

* Update all urls to latest
2023-12-26 11:27:07 +01:00
lazymio
ea5ea3410c
Fix incorrect imports (#1758)
* Fix incorrect imports

https://doc.rust-lang.org/core/simd/trait.SimdOrd.html

* Fix

* Try fix ci
2023-12-23 23:12:20 +09:00
Dominik Maier
16a152267e
Ignore SigPipe by default (#1741)
* Ignore SigPipe by default

* Fix no_std

* fmt
2023-12-22 16:50:36 +01:00
Dominik Maier
c93291ab57
Fix as_object UB discussed in #1748 (#1751)
* Fix as_object UB discussed in #1748

* More cleanup, more less UB

* Fix fixes

* Added uninit_on_shmem api

* clippy

* fmt

* trying to fix fuzzers, libfuzzer wrapper

* Add OwnedRefMit::owned constructor, libfuzzer fix

* Some more fixes

* Add BacktaceObserver::owned fn

* fmt

* more fmt
2023-12-22 16:49:01 +01:00
Dominik Maier
4e7d2caa9f
Remove unused create_anymap_for_trait macro (fixes #1719) (#1752) 2023-12-22 16:48:43 +01:00
fc331fc6d8 consolidate outputs 2023-12-22 12:57:51 +01:00
90cae14958 new cli 2023-12-22 12:57:51 +01:00
6e0b49bf9b switch address data type, simplify synbol resolution 2023-12-22 12:57:51 +01:00
aba83dfb6f minor fixes 2023-12-22 12:57:51 +01:00
5648255542 fixup graph cycles 2023-12-22 12:57:51 +01:00
d179343a63 add delay list overflow 2023-12-22 12:57:51 +01:00
61ff3e3196 WIP: quick-fix for missing metadata 2023-12-22 12:57:49 +01:00
38e5767775 filter interrupt abbs 2023-12-22 12:56:54 +01:00
3fcb9a74e0 add graph printing 2023-12-22 12:56:54 +01:00
4e18b8fdab fix graph dump build 2023-12-22 12:56:54 +01:00
3a601fe250 hack async activation detection 2023-12-22 12:56:54 +01:00
bf42de5698 fix api regression 2023-12-22 12:56:54 +01:00
82908badfd add simple iteration counter 2023-12-22 12:56:54 +01:00
086a575f44 add delay list to RefinedFreeRTOSSystemState 2023-12-22 12:56:54 +01:00
e31c01b2af capture delay list 2023-12-22 12:56:54 +01:00
6dafc4f9d6 update to 0.11.1 2023-12-22 12:56:54 +01:00
92da68af6f small build fixes 2023-12-22 12:56:54 +01:00
53ef9ae96e port to libafl 0.10.1 2023-12-22 12:56:54 +01:00
900ce0bc92 remove dead code 2023-12-22 12:56:54 +01:00
e9f2792488 igonre archives 2023-12-22 12:56:54 +01:00
2d70cff21e eval script wrangeling 2023-12-22 12:56:54 +01:00
5ddb7192ba HACK: interrupt limit for random fuzzing 2023-12-22 12:56:54 +01:00
711fd36200 plot enpoints 2023-12-22 12:56:54 +01:00
81cbddc1be paralellize plots 2023-12-22 12:56:54 +01:00
8c6f8c861f update plot script 2023-12-22 12:56:54 +01:00
47d7ff3c48 tweak time outputs 2023-12-22 12:56:54 +01:00
f2244c96b0 add run_until_saturation 2023-12-22 12:56:54 +01:00
a970954a40 update snakefile 2023-12-22 12:56:54 +01:00
db6df36110 fix empty iterator crash, restart 2023-12-22 12:56:54 +01:00
884a19cf9d set up configurations 2023-12-22 12:56:54 +01:00
e130155204 add missing use 2023-12-22 12:56:54 +01:00
a6052ddad7 randomize interrupts until wort 2023-12-22 12:56:54 +01:00
dd6be70a01 Test: remove pc from hash 2023-12-22 12:56:54 +01:00
0e5dc21cd6 Test: hash notification states 2023-12-22 12:56:54 +01:00
ee15313d96 allow plotting from remote mount 2023-12-22 12:56:54 +01:00
4e08db297a update snakefile 2023-12-22 12:56:54 +01:00
8395ca1000 small fixes 2023-12-22 12:56:54 +01:00
e2aee4af17 WIP: add simple interrupt time randomizer 2023-12-22 12:56:54 +01:00
fef550ecb6 update target_symbols 2023-12-22 12:56:54 +01:00
fc0f1807a9 skip unchanged interrupts 2023-12-22 12:56:54 +01:00
2032f1420d fix staeg setup 2023-12-22 12:56:54 +01:00
fb95bc9e3c fix use 2023-12-22 12:56:54 +01:00
063a4c9216 WIP: move interrupt mutation to new stage 2023-12-22 12:56:54 +01:00
e673d02b70 wip: interrupt placement 2023-12-22 12:56:54 +01:00
f88bd8044b add interrupt mutator 2023-12-22 12:56:54 +01:00
0318891ef6 plot min and max lines 2023-12-22 12:56:54 +01:00
db492f4525 plot lines instead of points 2023-12-22 12:56:54 +01:00
356d05bf26 fixes 2023-12-22 12:56:54 +01:00
147f8c3f69 revert changes 2023-12-22 12:56:54 +01:00
8be9d9146a add generation based genetic testing 2023-12-22 12:56:54 +01:00
d005a8e044 snakefile: dump cases, fix random fuzzing 2023-12-22 12:56:54 +01:00
6a8e9c80c1 add a new scheduler for systemtraces 2023-12-22 12:56:54 +01:00
5db99e4e68 fix snakefile, symbols 2023-12-22 12:56:54 +01:00
99daee7b14 seed rng from SEED_RANDOM 2023-12-22 12:56:54 +01:00
f075988643 determinism fixes, scheduler precision, restarts 2023-12-22 12:56:54 +01:00
c49edd729d switch to native breakpoints 2023-12-22 12:56:54 +01:00
090b006a50 fix interrupt config 2023-12-22 12:56:54 +01:00
d4407b331d fix rng seed 2023-12-22 12:56:54 +01:00
9ea825bbf9 configure restarting manager 2023-12-22 12:56:54 +01:00
7f6ef95496 add micro_longint 2023-12-22 12:56:54 +01:00
98328ae50f fuzz multiple interrupts 2023-12-22 12:56:54 +01:00
c024001243 rework plotting 2023-12-22 12:56:54 +01:00
0abb6a0d41 add interrupt fuzzing 2023-12-22 12:56:54 +01:00
bd3362309f dump time for showmap 2023-12-22 12:56:54 +01:00
e3b05df3c0 add plotting to snakefile 2023-12-22 12:56:54 +01:00
8387b61622 add feed_longest to record random cases 2023-12-22 12:56:54 +01:00
0b6d8a93b8 plotting: respect types 2023-12-22 12:56:54 +01:00
deee67fd3b change feedback order 2023-12-22 12:56:54 +01:00
a531d27464 fix build 2023-12-22 12:56:54 +01:00
cfb8ebd0ad fix feedbacks 2023-12-22 12:56:54 +01:00
ba5c3c8037 benchmark using snakemake 2023-12-22 12:56:54 +01:00
96e79144c2 trace_abbs and dump path 2023-12-22 12:56:54 +01:00
7a3aaba0a3 add graph feedback 2023-12-22 12:56:54 +01:00
fc355f5fd1 update input sizes, dump worstcase, benchmarking 2023-12-22 12:56:54 +01:00
5a2d75a317 remove address translations, extend plots 2023-12-22 12:56:54 +01:00
cf68ad4a85 add hists to plot script 2023-12-22 12:56:54 +01:00
dcd899b789 speed up random generation 2023-12-22 12:56:54 +01:00
27877bde97 write out times over time 2023-12-22 12:56:54 +01:00
091ce4b24f add sytemstate sceduler, fuzz until time 2023-12-22 12:56:54 +01:00
f26eed2178 re-add system state fuzzing 2023-12-22 12:56:54 +01:00
85718c1280 add virtual edge to longest runs 2023-12-22 12:56:54 +01:00
76f6114b50 do not force generated inputs 2023-12-22 12:56:54 +01:00
ea7edb2001 debug stuff 2023-12-22 12:56:54 +01:00
180edbb7d5 random seeds, better plots 2023-12-22 12:56:54 +01:00
e70a816f49 add more benchmarks 2023-12-22 12:56:54 +01:00
1976150a45 exectime increase feedback 2023-12-22 12:56:54 +01:00
f1552f95a0 rename bin, allow random fuzzing 2023-12-22 12:56:54 +01:00
00b68edfb3 benchmark with duration 2023-12-22 12:56:54 +01:00
25e81498f5 add benchmark scripts 2023-12-22 12:56:54 +01:00
fab1b1ef9f add systemstate feature and dump times 2023-12-22 12:56:54 +01:00
7fa6fd7f85 fix multicore build 2023-12-22 12:56:54 +01:00
a5b333f635 ignore artifacts 2023-12-22 12:56:54 +01:00
5c80cb780f minimal changes 2023-12-22 12:56:54 +01:00
7f362f5907 add interrupt injection 2023-12-22 12:56:54 +01:00
e2f4744823 input length and read input pointer 2023-12-22 12:56:54 +01:00
c3b2777acb draft: add graph feedback 2023-12-22 12:56:54 +01:00
3435a79e26 add TimeMaximizerCorpusScheduler 2023-12-22 12:56:54 +01:00
25a58ddbe1 add last api callsite to system state 2023-12-22 12:56:54 +01:00
b678f9f18b libafl_qemu: add jmp instrumentation 2023-12-22 12:56:51 +01:00
b3416fe0c5 WIP: add systemstate tracking 2023-12-22 12:54:16 +01:00
66c4cb5316 add arguments 2023-12-22 12:54:16 +01:00
693ba3b942 get time from ClockTimeFeedback 2023-12-22 12:54:16 +01:00
0a703f6ff5 fixup 2023-12-22 12:54:16 +01:00
03fbe41dbb WIP: port fret 2023-12-22 12:54:16 +01:00
Dongjia "toka" Zhang
9993cf1000
symcc_update (#1749) 2023-12-22 02:29:46 +09:00
Romain Malmain
830faec95f
QEMU filtering rework + paging filtering (#1705)
* Added paging filtering.
Reworked address range filtering to fit with new generic code.

* Fix: renamed remaining QemuInstrumentationFilter instances.

* Fix: clippy + format

* Updated qemu-libafl-bridge

* Fix QEMU userspace crash handler (#1706)

* Fix QEMU userspace crash handler

* no_std

* libafl_cc custom llvm_config lookup for solaris/illumos (#1708)

* fix simd (#1709)

* Updated qemu

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: David CARLIER <devnexen@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-12-21 15:51:14 +01:00
David CARLIER
ea61b79012
bolts/minibsod add openbsd arm64 support (#1724)
* bolts/minibsod adding openbsd arm64 part.

* disable core ids test on freebsd
2023-12-21 14:25:25 +01:00
Dongjia "toka" Zhang
a98805b4ca
Another attemp to fix CI (#1744)
* fixing?

* more

* delete macos build_and_run fuzzers as its runtime exceeds 360minutes and can't fix it
2023-12-21 04:43:01 +09:00
Dominik Maier
68e7b203f5
Add file descriptor logger (#1742)
* Add file descriptor logger

* clippy

* Fix closing fds

* fix no_std, fmt

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-12-20 16:53:33 +01:00
Dongjia "toka" Zhang
57a64e805f
Trying to fix CI (#1739)
* test

* dummy

* dummy
2023-12-20 16:48:02 +09:00
Dongjia "toka" Zhang
78060ea308
0.11.2 (#1735) 2023-12-18 14:33:14 +01:00
van Hauser
63e1523358
small fixes and enhancements (#1731)
* nits

* first steps

* different approach

* fixes

* remove temps

* remove temp

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-12-17 20:19:15 +09:00
Addison Crump
ef8ebd5239
fixup: don't download unicode categories data (#1732)
* fixup: don't download unicode categories data

* whoops, document

* fmt

* ci

---------

Co-authored-by: toka <tokazerkje@outlook.com>
2023-12-17 19:09:59 +09:00
iximeow
2726a59711
use yaxpeax-x86 version from crates.io instead of direct git dep (#1733) 2023-12-17 15:54:12 +09:00
Dongjia "toka" Zhang
7894efe728
Last cleanup after decapstone (#1727)
* Last clenup

* more

* more
2023-12-16 19:51:42 +09:00
Sharad Khanna
fce5fd9a2b
Remove capstone from frida [aarch64] (#1723)
* Partially finish ASAN and CmpLog changes

* Fix handle_trap, report_error, and remove capstone

* Fix a few bugs. Can now detect UAFs properly

* Some small changes

* Make API more consistent with x86

* Fix printing

* Remove unneeded inputs, final changes

* formatting

* Fix x86 build

* Formatting
2023-12-16 16:10:40 +09:00
Dongjia "toka" Zhang
a0a4dd60bb
Remove capstone from frida [x86_64] (#1720)
* init

* more

* just fixing stuff
2023-12-16 02:39:11 +09:00
Dongjia "toka" Zhang
ee447468c6
message (#1726) 2023-12-16 00:13:21 +09:00
Andreas
2f036b72e4
Make inner value of llmp Flags pub (#1725) 2023-12-15 20:58:05 +09:00
Andrea Fioraldi
002656b076
Fix #1721 (#1722) 2023-12-11 15:26:53 +01:00
Dongjia "toka" Zhang
c2db7ad162
Add Resource (#1718) 2023-12-07 13:54:56 +01:00
mkravchik
b336411516
Adding support for shutdown upon Ctrl+C on Windows for LLMP (#1704)
* Adding support for shutdown upon Ctrl+C on Windows for LLMP

* PR comments and clippy suggestions addressed

* Enable CI for PR branches and manually triggered CI

* Removed an empty line that broke compilation on some platforms

* Trying to fix nostd compilation

* Trying to fix nostd compilation for nightly toolchain

* Removing use that is unused on some platforms

* Trying to fix build on the nightly toolchain

* Trying to fix build on the nightly toolchain, take 2

* Unifying LlmpShutdownSignalHandler

* Fmt fix

* Making the handler pub(crate)

* Nightly toolchain fmt fixes

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-12-05 21:03:00 +01:00
tbethe
686d29a3cb
Don't reset child_pid in forkserver executors (#1715)
Child pid is no longer reset after a run in persistent mode

Co-authored-by: Timme Bethe <git@timmebethe.nl>
2023-12-05 20:38:17 +01:00
Dongjia "toka" Zhang
fad59987d9
Better SigInt handler (#1710)
* fix simd

* better exit

* chg

* more

* more

* use

* change to proper name

* w

* aaaaaaa

* delete

* just separate them

* shell check
2023-12-04 20:06:11 +01:00
Dongjia "toka" Zhang
210315da0f
fix simd (#1709) 2023-12-03 16:19:12 +01:00
David CARLIER
108c04a8d2
libafl_cc custom llvm_config lookup for solaris/illumos (#1708) 2023-12-03 10:23:33 +01:00
Andrea Fioraldi
517d6962bd
Fix QEMU userspace crash handler (#1706)
* Fix QEMU userspace crash handler

* no_std
2023-12-01 13:26:10 +01:00
Andrea Fioraldi
5d83c9399a
Fix bp in QEMU thumb mode on arm64 systems (#1701) 2023-11-29 10:37:10 +01:00
Andrea Fioraldi
bc458864f1
Fix libafl_qemu edge hooks src addr (#1700) 2023-11-28 17:16:15 +01:00
Rowan Hart
5d5ee40329
Add Features for C Targets (#1663)
* Allow disabling C targets for platforms that dont support them when using cmp observers

* Make sancov depend on coverage
2023-11-27 22:34:41 +01:00
David CARLIER
c84629a2f8
bolts: fix solaris cpu binding (#1699)
Seems `PS_MYID` to save one syscall was not really working, explicit current id makes the test always pass.
2023-11-27 22:34:12 +01:00
Andrea Fioraldi
1545514ed8
JIT fast path for edge cov hooks in libafl_qemu (#1696)
* JIT fast path for edge cov hooks in libafl_qemu

* fix

* fmt

* fix

* unify hooks as opt
2023-11-27 13:20:20 +01:00
Dongjia "toka" Zhang
00740190a7
Delete update_rust_toolchains.yml (#1698) 2023-11-26 21:01:55 +01:00
Mrmaxmeier
84a87f1da8
bolts: support dump_registers for x86 linux (#1694)
* bolts: support dump_registers for x86 linux

* bolts: fix write_crash fault addr for linux/x86
2023-11-26 16:39:16 +01:00
Romain Malmain
bd12e060ca
Update qemu-libafl-bridge (#1697)
Update to last version of qemu-libafl-bridge
2023-11-24 20:19:57 +01:00
Dongjia "toka" Zhang
16af5debbe
Fix aggreagator ui (#1693)
* fix

* more

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-11-24 13:50:57 +01:00
Romain Malmain
b4e987a640
Clippy fix for Refactor QEMU hooks (#1695)
* clippy

* format

* clippy
2023-11-24 13:15:33 +01:00
Andrea Fioraldi
f1aee3c376
Refactor QEMU hooks (#1690)
* Rewrite QEMU Asan

* fake sys

* New hooks

* edge cov helper

* opaque raw hook

* new hooks

* EMulator::get

* new asan

* fix fuzzers

* fix types

* fix

* fix

* fix

* merge fix

* fix
2023-11-23 18:57:15 +01:00
Romain Malmain
43c9100f59
QEMU Synchronous Exit + Syx Snapshot update (#1681)
* Fix: typo in variable name.

* Fix: thread-safe static for emulator initialization.

* Initial support for synchronous exit from QEMU.

* New commands for the sync exit feature.
Supports physical and virtual address requests.
Updated for new SyxSnapshot naming.

* update qemu commit and fix some things

* - Removed lazy_static dependency
- Compiles for usermode
- Format

* Fix warnings

* Fixed sync_exit for missing architectures

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-11-23 17:35:32 +01:00
Dongjia "toka" Zhang
28f34e076e
Reduce deps (#1692) 2023-11-23 17:21:13 +01:00
Dongjia "toka" Zhang
903a242e3e
Fix unused import (#1691) 2023-11-22 21:04:05 +01:00
Dongjia "toka" Zhang
4a94bcb806
Monitor refactor + add aggregator (#1671)
* push

* decouple clients_stats_mut_for

* coding done

* push

* more

* upd

* fix

* aa

* don't change harness
2023-11-22 20:38:59 +01:00
Dongjia "toka" Zhang
cad2ff6319
Fix scheduled ci (#1688)
* fix

* small z
2023-11-22 11:46:15 +01:00
Dongjia "toka" Zhang
9a1173d4a6
scalability monitor 2nd (#1685)
* tekito

* monitor

* fix

* all

* ci

* ci
2023-11-21 23:54:19 +01:00
Dongjia "toka" Zhang
9345b80256
Schedule rust update in build_and_test.yml (#1687)
* ci cron

* correct regex
2023-11-21 23:49:36 +01:00
s1341
ba394c4acc
Fix LLMP map reuse overflow for slow brokers (#1679)
* Attempt to fix llmp refcounting

* readers->readers_count

* Removed refcounting for now, fixed

* fixes

* fixes

* add extra debug assert, remove duplicate line

* semicolons are pain :)

* Add comment

* oooooops, bugfix

* fmt

* Fix calcualtion in in_shmem

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-11-21 16:48:17 +01:00
Dongjia "toka" Zhang
379e2ae89b
Scalability introspector + State refactor (#1674)
* check

* clippy fmt fixing all the stuff

* restore Cargo.toml

* a

* ci

* ci

* a

* a

* workging?

* work

* ?

* why it worksgit add -u

* ci

* ci

* TMATE

* ci

* ci

* ci

* remove tmate

* less

* fuck; let's try with introspection first

* fucking macro

* another windows shit

* stop it

* i'm harassed by how shit windows is

* fixing

* ci

* ziopera

* fix from main

* ci

* ci
2023-11-21 14:38:48 +01:00
Addison Crump
86cb187ef1
Add arg for profile in build.sh (#1680) 2023-11-21 04:15:53 +01:00
Addison Crump
281524dbf9
Unicode-preserving mutators (#1542)
* create the string classification stage

* modify API to pre-group

* preserving mutator

* more meaningful test

* subproperty mutators + some fixes

* document, finalise, integrate with libafl_libfuzzer

* add example, fix for weird range select

* fix for introspection

* fix fuzzer build

* speed optimisation: allow, but do not require, stacking

* property => category

* token replacement

* fixup: rare case where rust does not agree on valid character

* fix CI again

* again again

* take two: dynamic unicode discovery

* oops

* fix: last byte is never selected

* opt: bias to smaller unicode categories

* fix test

* opt: precompute regions and fix tests

* cache and allow stacking

* document and update libafl_libfuzzer

* oops, use reverse

* fix bolts clippy error

* fixup part 2

* clippy

* part 2

* clippy warning allow

* clippy complaint

* use alloc not std

---------

Co-authored-by: toka <tokazerkje@outlook.com>
2023-11-21 00:41:16 +01:00
Addison Crump
1e96652ed2
libafl_libfuzzer: rename all symbols and allow mimalloc use (#1565)
* rename allocator symbols to avoid conflict with mimalloc

* re-add llvm-tools to CI

* rename everything

* fixup clippy lint

* make fuzzer entries more noticeable :)

* rabbit mode

* clippy
2023-11-20 21:55:40 +01:00
Andrea Fioraldi
aa69436b64
Fix i386 QEMU read_function_argument() (#1677) 2023-11-20 13:53:29 +01:00
Addison Crump
a278357ed9
Add whole-archive feature to libafl_targets (#1544)
* maybe fix linkage?

* fix hack CI

* interceptors

* do not call strstr and friends

* format

* whoops

* enforce nightly; fixup linkage by featuring interceptors

* skip libafl_libfuzzer in stable cargo hack check

* oops

* packed_bundled_libs is stablised
2023-11-20 10:38:17 +01:00
David CARLIER
a013ad6085
bolts for haiku update (#1673)
core_affinity using available_parallelism which also support this
platform. further tests disabling.
2023-11-19 23:58:30 +01:00
s1341
57296a6750
Use Compound configurations in libpng launcher fuzzer (#1676) 2023-11-19 11:11:52 +01:00
Andrea Fioraldi
cc1ebb29f7
Add CmpLog routines to LibAFL QEMU and various fixes (#1664)
* Add CmpLog routines to LibAFL QEMU and various fixes

* format

* fix

* fix read_function_argument

* fix

* multithread

* fix qemu fork

* fix

* clippy

* fix systemmode

* unused imports
2023-11-17 16:59:50 +01:00
Andrea Fioraldi
d606d9f4f6
Avoid lagged receiver in TCP manager (#1672) 2023-11-17 14:23:51 +01:00
Andrea Fioraldi
d7825851e9
Fix SimpleRestartingMonitor after restart (#1669)
* Fix SimpleRestartingMonitor after restart

* a

* a

* a

* a

* a

* a

* a

* a

* a

* ci

---------

Co-authored-by: toka <tokazerkje@outlook.com>
2023-11-16 20:06:27 +01:00
Mark Giraud
0750a6c3ca
refactor: Remove unnecessary Debug trait bounds (#1667)
* refactor: Remove Debug supertraits

Instead of having the Debug trait as supertrait on several traits, the
Debug trait is now required in bounds in specific implementations that
need this specific trait. This keeps the API cleaner, since users now
don't have to propagate the Debug requirement if they don't need to use
the Debug trait.

* refactor: Reformat code
2023-11-15 20:26:12 +01:00
s1341
b1888e12c9
Support precompiled headers in clang/ar wrappers (#1668) 2023-11-15 15:10:03 +01:00
s1341
7acdeacae8
Allow compiling 32bit (#1666)
* Allow compiling for 32bit

* Fmt

* Clean up minibsod for 32bit

* fmt
2023-11-15 12:43:04 +01:00
Dominik Maier
8c62d339a2
Fix FreeBSD CI by updating freebsd-vm (#1665) 2023-11-13 22:51:57 +01:00
Dominik Maier
1138e6a341
Fix CI (#1662) 2023-11-10 12:08:29 +01:00
Benjamin Beyret
6300c5f493
Remove debug log (#1659) 2023-11-08 15:46:20 +01:00
Dongjia "toka" Zhang
d53503b73e
Fix stb image on windows (#1657)
* fix

* fix

* HOW DO I ADD FROM:FROM????

* ok
2023-11-08 15:20:35 +01:00
Benjamin Beyret
c97d0fa7fc
Allow MinimizerScheduler to not cleanup metadata after use (#1658)
* Allow MinimizerScheduler to not cleanup the metadata after use.

* Fix constructor

* cargo fmt and fix docstring.
2023-11-08 12:00:25 +01:00
Nereuxofficial
6089cc21ce
Fixed panic feature in baby_fuzzer example (#1656)
* Fixed panic feature in baby_fuzzer example

* Fixed typo
2023-11-08 00:14:42 +01:00
Dongjia "toka" Zhang
c9e147de8c
Fix LLVM Pass (#1654) 2023-11-06 13:35:10 +01:00
Dominik Maier
8545778780
Revert "Use clang-format-16 (#1649)" (#1650)
This reverts commit 1aede04af75564d4063f91d1c8c1a402760e86f5.
2023-11-04 21:38:36 +01:00
Abc Xyz
65ddfa6acf
drcov_rt: make coverage file names unique (#1581)
* fix(drcov_rt): coverage files are overwritten if have the same names

Make it unique.

* fix(drcov_rt): use coverage and input as a filename, skip empty covs
2023-11-04 17:54:35 +01:00
Dominik Maier
8a18ee4ece
Add Android Ashmem stub header to libafl_targets forkserver.c (#1648)
* Add Android Ashmem stub header to libafl_targets forkserver.c

* clang-format
2023-11-04 17:48:02 +01:00
Dongjia "toka" Zhang
1aede04af7
Use clang-format-16 (#1649) 2023-11-04 17:45:01 +01:00
David CARLIER
bae24d9072
bolts: haiku, addressing clippy warnings (#1647) 2023-11-04 17:03:09 +01:00
Addison Crump
56b37bb4bd
Improve the libafl_libfuzzer corpus (#1539)
* improved libfuzzer corpus

* use .into() for converting ids to usize

* oops

* fix warning about unused arg

* fix some lingering CI errors

* actually save the last lmao
2023-11-03 17:33:38 +01:00
Addison Crump
fd98eabfbf
clamp last to infinity to handle rare imprecision issues (#1532) 2023-11-03 17:32:48 +01:00
David CARLIER
2e980ca08d
bolts: initial haiku support (#1643) 2023-11-03 17:18:53 +01:00
Dongjia "toka" Zhang
745326ee26
Add post_run_target for ShadowExecutor (#1641) 2023-10-30 19:27:55 +01:00
Anne Borcherding
976d6b2e97
[WithObservers] Call the wrapped observer's post run function (#1640)
* [WithObservers] Call the wrapped observer's post run function

* fix typo and naming of variable
2023-10-30 17:58:54 +01:00
Azim Muradov
ad33ea086b
Fix typos and crates names formatting in crates.md (#1639)
* Fix typos and crates formatting in crates.md

* Fix header in crates.md
2023-10-27 11:31:02 +02:00
Dongjia "toka" Zhang
c6c93b5785
aa (#1638) 2023-10-25 16:36:20 +02:00
Dongjia "toka" Zhang
fdfa5b2d48
Fix ci (#1637)
* fix

* Stupid lint 🖕
2023-10-25 16:28:31 +02:00
Dongjia "toka" Zhang
f34bab2486
Fix CI (#1636) 2023-10-25 16:10:10 +02:00
Andrea Fioraldi
406e77faa9
QEMU Asan backtrace and report (#1628)
* wip

* ExtractFirstRefMutType

* Asan report with backtrace

* Print asan reports and fix backtraces in libafl qemu

* print context

* enlarge redzone

* nopstate

* fix

* reproducer

* clippy

* clippy

* Fix android

* Crash hook
2023-10-25 15:58:32 +02:00
Dongjia "toka" Zhang
02cd260af0
Update LibAFL concolic (#1634)
* concolic upd

* more

* working

* clippy

* rev

* fix

* remove cur_input

* rev

* gitignore
2023-10-22 13:44:01 +02:00
Anne Borcherding
c9403cbd00
fix: use correct trait bound in WithObservers Executor (#1633) 2023-10-20 16:32:40 +02:00
cube0x8
0db67dfc9a
updated rust container image + default nightly (#1631) 2023-10-19 11:05:39 +02:00
Dongjia "toka" Zhang
0b38fabeb0
CmpLog {Instruction, Switches} pass (#1612)
* switch and instruction pass copy paste

* FMT

* add cb

* put things in the functions

* fi

* working

* oops

* options

* no 128bit int on windows

* no 128bit on windows

* oops

* unix only

* windows

* PACKED

* let's stop using it, it's ugly

* fmt

* adjust

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-10-14 11:47:16 +02:00
Dongjia "toka" Zhang
77dfc7a26a
Update llvm ver in Dockerfile (#1629)
* llvm 15

* more
2023-10-13 17:00:12 +02:00
Benjamin Beyret
1b7e1da809
Fix typo in SimpleStdoutLogger comment. (#1627) 2023-10-12 17:03:38 +02:00
Dongjia "toka" Zhang
cb9ace52e1
Rename more options (#1626) 2023-10-12 12:01:39 +02:00
Andrea Fioraldi
f6ba9de044
Add SplitBorrow trait to split borrow tuple_list elements (#1624)
* Add SplitBorrow trait to split borrow tuple_list elements

* clippy
2023-10-12 10:16:41 +02:00
Andrea Fioraldi
4c17da00b0
Clipped Fixxy (#1622)
* clippy fix

* fix

* fix

* it works

* imports
2023-10-11 21:19:30 +02:00
Dongjia "toka" Zhang
67aa5b12c1
Rename option name (#1623)
* rename

* FMT
2023-10-11 17:38:56 +02:00
Andrea Fioraldi
35e387773c
Format C code (#1621)
* Add iter() to owned slice

* Format C
2023-10-11 14:19:14 +02:00
Andrea Fioraldi
6986317a03
Add iter() to owned slice (#1620) 2023-10-11 14:13:26 +02:00
Andrea Fioraldi
47cd4dfea6
Break on timeout in QEMU system mode (#1619)
* Break on timeout in QEMU system mode

* fix

* fix

* fix
2023-10-11 14:01:18 +02:00
Andrea Fioraldi
31f4669794
Autodetect llvm-config for QEMU bindings generation (#1610)
* Autodetect llvm-config for QEMU bindings generation

* fix ci

* Fix signal handlers without ucontext pointer

* ci
2023-10-10 15:26:32 +02:00
Andrea Fioraldi
bbb999f4d5
New logo in the book (#1618) 2023-10-09 15:54:04 +02:00
Dongjia "toka" Zhang
c94c26cb56
Document how to use cpp() and optimize() (#1615) 2023-10-07 16:36:33 +02:00
Dongjia "toka" Zhang
bc91436ef4
Refactor cmplog observers (#1603)
* refactor

* Rename Everything

* fmt

* chg

* test

* aa

* doc fix

* fix?

* doc
2023-10-06 15:22:11 +02:00
Dominik Maier
0bba8535b8
Tiny typo fix (#1611) 2023-10-06 01:11:23 +09:00
Dominik Maier
30686a2d28
Remove return type from fuzz_loop fn that never returns (#1606) 2023-10-06 01:02:16 +09:00
Dongjia "toka" Zhang
2ade1ee1f6
Bring back some checks (#1597) 2023-10-05 16:14:55 +02:00
Dongjia "toka" Zhang
f17e49e9aa
Remove warnings (#1609)
* two falgs

* UNIX ONLY FLAGS

* moa

* FMT
2023-10-05 15:25:55 +02:00
Dongjia "toka" Zhang
74783c2027
Add executions count at proper places (#1608)
* executions count

* tinyinst qemu frida

* aaaa

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-10-05 15:25:40 +02:00
Andrea Fioraldi
cffbf069d2
Call the original QEMU user crash handler in libafl_qemu (#1575)
* Call the original QEMU user crash handler in libafl_qemu

* Return if real crash or not

* merge

* Fix singal handlers in libafl and libafl_qemu

* doc and clippy

* clippy

* clippy

* clippy

* slirp

* fix

* fix system
2023-10-05 15:24:21 +02:00
cube0x8
d4e9107fc2
added ninja-build and python3-venv as dependencies (#1604) 2023-10-04 14:27:55 +02:00
Abc Xyz
7f68f66d70
drcov_rt: remove unused a field and methods (#1601) 2023-10-04 14:34:53 +09:00
Dominik Maier
cce25d0a94
Add OptionalStage (#1600) 2023-10-04 14:24:02 +09:00
Dongjia "toka" Zhang
fc16b70a65
Format C (#1602) 2023-10-03 13:40:19 +02:00
Dongjia "toka" Zhang
a9014a9419
fmt c too (#1593)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-10-03 11:43:28 +02:00
Dominik Maier
25409119ff
Make Signals compatible with nix, implement TryFrom<&str> (#1599)
* Make our signals compatible to nix Signals

* no-default nix
2023-10-03 17:33:45 +09:00
Addison Crump
20f1119bab
libafl_libfuzzer: documentation and build script (#1596)
* add docs; add build script for prepping libFuzzer

* clarifications
2023-10-03 16:56:27 +09:00
s1341
a27553daec
libafl_cc: fix configuration support (#1595)
* libafl_cc: fix configuration support

* fmt

* clippy
2023-10-02 17:48:33 +03:00
Dongjia "toka" Zhang
f35c59131d
Fix redundant area_is_valid() (#1594) 2023-10-02 13:44:42 +02:00
Dongjia "toka" Zhang
b20fda2a4a
Use /dev/urandom instead of /dev/null for probing valid memory (#1586) 2023-10-01 23:08:29 -05:00
Dongjia "toka" Zhang
583c84ab4e
cmplog routines update & fix (#1592)
* update

* runtime

* Update cmplog-routines-pass.cc (#1589)

* rtm

* fix

* no link rt

* fmt

* let's change script in another pr

* colon

* adjust the checks

* fix

* more fixes

* FMT
2023-10-01 23:06:34 -05:00
Abc Xyz
5854fd0c5b
fix(libafl_frida): correctly calculate the coverage using DrCov (#1579) 2023-10-01 08:11:46 -05:00
Dongjia "toka" Zhang
ee9eb3eef1
Revert "Update cmplog-routines-pass.cc (#1589)" (#1591)
This reverts commit d2ff88f6ff6ec38c16200e9ee59c180412430120.
2023-10-01 14:46:21 +02:00
Dongjia "toka" Zhang
60b3408737
Update dependencies (#1588)
* update

* downgrade some
2023-10-01 07:20:23 -05:00
Dongjia "toka" Zhang
d2ff88f6ff
Update cmplog-routines-pass.cc (#1589) 2023-10-01 07:20:00 -05:00
Dongjia "toka" Zhang
2474691623
Fix libjpeg fuzzer (#1582)
* Revert "Insert into corpus if feedback is_interesting on crash/timeout (#1327)"

This reverts commit 871dfa0a013f31f84e43e125105febca2f137049.

* unused
2023-09-30 18:34:08 +02:00
Dongjia "toka" Zhang
f31c2cc4ce
remove unused deps (#1587) 2023-09-30 18:32:59 +02:00
Dongjia "toka" Zhang
70b75e7fdb
Fix BytesDeleteMutator (#1585) 2023-09-30 00:25:12 +02:00
Abc Xyz
0932421020
fix(libafl_frida): enable asan for Android x86_64 (#1578) 2023-09-29 17:10:27 -04:00
Abc Xyz
6f67919622
fix(minibsod): allow dump_registers and write_crash for Android x86_64 (#1577) 2023-09-29 17:10:15 -04:00
Dongjia "toka" Zhang
5b0e3dd3bc
Make fuzzbench debugging easier (#1574)
* to make debugging easier

* debug
2023-09-29 18:32:09 +02:00
WorksButNotTested
d3a4b726d8
Added qemu_cmin (#1572)
Co-authored-by: Your Name <you@example.com>
2023-09-29 08:59:41 -04:00
WorksButNotTested
9755d189dd
Write coverage for QEMU into separate files (#1571)
Co-authored-by: Your Name <you@example.com>
2023-09-28 15:57:34 -04:00
s1341
78fd4e0d39
frida-asan: move to mmap-rs (#1570) 2023-09-28 16:35:54 +03:00
WorksButNotTested
9c3f8f4511
Qemu features3 (#1538)
* Fix issue with libafl_qemu being repeatedly rebuilt

* Changes to make qemu_launcher a production ready fuzzer

* Remove _get prefix

* Don't collect DrCov data during the campaign

* Fix poor performance

* Better validation for core selection

* Changes to print debug when running in verbose mode

* Autofix

* Remove afl++-clang

* Fix build error on 32-bit

* Fix some clippy

* Fix OSX

* Set default version of clang/clang++

* Review changes

* Fix issue with fd sharing between processes

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-09-28 14:31:15 +02:00
Andrea Fioraldi
19aac2fc04
Fix TCP manager and restarts (#1556)
* Fix TCP manager and restarts

* clippy

* clippy

* clippy
2023-09-28 13:46:07 +02:00
s1341
652c24cb2a
windows: Support LIBAFL_DEBUG_OUTPUT (#1569) 2023-09-28 11:16:41 +03:00
s1341
7cb1080e35
libafl_ar: add extensions (#1568) 2023-09-28 09:09:29 +03:00
Dongjia "toka" Zhang
4e6ad397ec
Fix CI (#1567) 2023-09-28 00:47:40 +02:00
s1341
fd229328eb
Fix frida libafl after #1523 (#1560)
* Fix frida libpng after PR1523

* fmt

* Fix

* Clippy
2023-09-27 08:02:11 -04:00
Dongjia "toka" Zhang
b3483ddd42
Give proper name to some crates and exclude them 2 (#1562)
* fix

* comma
2023-09-27 13:29:24 +02:00
Dongjia "toka" Zhang
324db072a2
Fix CI (#1558)
* endif

* just fix every profile

* WHY YOU DONT JUST USE THE SAME NAME FOR DIR

* fix

* Some fuzzer want release

* WHY I ALWAYS FORGET COMMA

* NO MORE SPACE

* rename

* stb doesn't like debug build

* just use release

* another just use release
2023-09-27 09:59:55 +02:00
Dongjia "toka" Zhang
74435e1461
Fix LLVMPass (#1557) 2023-09-26 18:54:54 +02:00
Dongjia "toka" Zhang
c1006c4d38
Fix CI (#1553)
* export PROFILE

* install aflplusplusw

* no dot

* a
2023-09-25 20:51:40 +02:00
Dongjia "toka" Zhang
c1eef33b5d
Remove --release from Makefile.toml (#1522)
* rem release

* Revert "rem release"

This reverts commit 13aaf13e412818629880348188c3e1b4137b9ed8.

* toggle it with envvar

* fm
2023-09-25 14:22:10 +02:00
Dongjia "toka" Zhang
dc7d561621
Don't send unstable entries if there's nothing (#1552)
* shutup calibration

* Update build_and_test.yml
2023-09-24 17:27:12 +02:00
Dominik Maier
aa7993de10
Some AFL UI example fuzzer cleanup (#1529)
* Some afl ui cleanup

* more info

* Fix CI (#1549)

* Change profiles for the fuzzbench fuzzers.

* just foreground

* Revert "just foreground"

This reverts commit abd4fbec40fd1a7f3bcca1190ce11816fc868c53.

* fix Makefile.toml

* Tmate debug

* fix?

* fix?

* Can't fix this

* remove reset

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-09-24 14:54:14 +02:00
Dongjia "toka" Zhang
c103444396
Change profiles for the fuzzbench fuzzers. 2023-09-22 23:51:06 +02:00
Dongjia "toka" Zhang
6251ad0051
Update llvm version in CI (#1533)
* UPD

* UPD

* UPD

* UPD

* MORE

* ??

* Update build_and_test.yml

* LLVM 15

* Update build_and_test.yml

* chg

* Update build_and_test.yml

* Update build_and_test.yml
2023-09-21 01:04:50 +02:00
Fabian Freyer
a092aed538
libafl_frida: Allow setting path for DrCovRuntime (#1536) 2023-09-21 01:03:56 +02:00
Dominik Maier
f70a16a09a
Fix unsoundness for misaligned map observers (#1530)
* Fix unsoundness for misaligned map observers

* nits

* clippy

* Make sure beginning of the page is aligned
2023-09-20 18:25:37 +02:00
Addison Crump
761a77fce0
libafl_libfuzzer fixes for port and fd allocation (#1525)
* better port and fd handling

* fix multitude of CI failures
2023-09-20 17:36:43 +02:00
Benjamin Beyret
0e149afd7a
Allow both fuzz_time and iters in TuneableMutationalStage (#1531) 2023-09-20 12:47:56 +02:00
Fabian Freyer
7f0a4f1d7e
libafl_frida: Add FridaInstrumentationHelperBuilder, don't rely on Clap options (#1523)
* impr(frida): Don't keep FuzzerOptions in Helper

Instead, keep the actual values that are needed. This allows us to make
a builder for FridaInstrumentationBuilder in a subsequent commit.

* refactor(frida): Move workaround to separate method

This is just code movement.

* refactor(frida): move transformer initialization

Mostly code movement here, sets up replacing `new` with a builder. The
one exception is the introduction of a lifetime bound on RT, which needs
to outlive the transformer. This could be generic, but there's probably
no reason to introduce an additional lifetime.

However, because of this lifetime introduction, this is _technically_ a
breaking change.

* impr(frida): Pass module map to runtimes

Instead of passing a slice of modules to instrument, and re-building the
modulemap, pass a Ref-counted module map directly to the initialization.

* feat(frida): Builder for InstrumentationHelper

Co-authored-by: Dominik Maier <domenukk@gmail.com>

* impr(frida/alloc): optional options in allocator

Move all the initialization into Default::default with sensible defaults
and override parameters set from options in new.

* impr(frida): remove options from AsanError

The only option AsanError uses is whether to continue on error. Instead
of keeping a whole clone of the options around, just store that single
boolean value.

* impr(frida/asan): Use less FuzzerOptions

* Implement Default::default to get a good default AsanRuntime

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-09-20 11:08:59 +02:00
Dongjia "toka" Zhang
fdd2f53871
Fix doc in testcase_score.rs 2023-09-20 10:36:56 +02:00
Dominik Maier
3625e881a3
Fix forkserver child kill, add kill_signal support (#1521)
* Fix forkserver child kill, add kill_signal support

* more fix
2023-09-19 17:27:50 +02:00
Addison Crump
8f6efe993d
Address recent clippy changes; build clippy in debug instead of release for perf (#1516) 2023-09-19 00:42:46 +02:00
Fabian Freyer
27333f9ce8
libafl_bolts fix potentially unaligned ucontexts in signal handler (#1520)
When entering a signal handler, the ucontext_t is not necessarily 0x10-aligned, so we need to use read_unaligned instead of dereferencing.
2023-09-18 23:17:54 +02:00
Addison Crump
6d0d4e287a
Metadata + infinite loop fix for TuneableMutationalStage (#1514)
* update tuneable: consistently access metadata + force 'choice'

* oops, loop in the wrong place

* clarify API some; allow for least of set configuration
2023-09-16 16:54:40 +02:00
Elnard Utiushev
d4f47340a3
libafl_libfuzzer: replace cargo:error with assert in build.rs (#1517)
It is very confusing if you are trying to build on MacOS
and it is telling you that it worked, but actually it didn't.
2023-09-16 01:53:33 +02:00
Andrea Fioraldi
acecf46fb9
Ignore TCP recv if failed (#1519) 2023-09-15 13:18:46 +02:00
Dongjia "toka" Zhang
b3e82ad36e
Add trophies (#1518) 2023-09-14 20:18:01 +02:00
Addison Crump
0b889312ae
mac forkserver linkage fix (#1503) 2023-09-14 12:52:29 +02:00
ToSeven
defe9084ae
Add an example fuzzer with AFL-Style UI (#1501)
* Add an example fuzzer with AFL-Style UI

* fix CI errors

* fix CI and improve the UI

---------

Co-authored-by: toseven <Byone.heng@gmail.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-09-12 10:17:31 +02:00
lenawanel
84beb61c3f
remove libafl/src/feedbacks/owned.rs (#1508)
fixes #1504
2023-09-08 11:14:37 +02:00
Andrea Fioraldi
5311ce705a
Fix missing usage of saved_tree in AsanGiovese (#1506) 2023-09-07 13:40:17 +02:00
David CARLIER
b090bc7b4b
bolts: openbsd (snapshot) clippy fix (#1502) 2023-09-06 03:39:43 +02:00
ToSeven
04aecd97f6
Add AFL-style metrics(pending,pend_fav, own_finds,imported) (#1351)
* add the metrics(pending,own_finds,imported)

* add the pend_fav metrics

* push

* Add the feature that AFLStats is computed and reported in AFLStatsStage

* fix some cicd errors

* AFLStats migrates to stage/stats.rs

* fix the cicd error

* fix some bugs and resolve the conflicts

* fix some typos

---------

Co-authored-by: toseven <Byone.heng@gmail.com>
Co-authored-by: toka <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-09-06 03:38:41 +02:00
lenawanel
c791a23456
reduce memory usage of the construct_automata script (#1481)
* remove unneeded loop in `SpliceMutator::mutate`

previously we searched for the first and the last difference
between exactly the same 2 inputs 3 times in a loop

* remove unused struct fields

* avoid allocating strings for `Transition`s

* avoid allocating `String`s for `Stack`s

* avoid allocating Strings for `Element`s

* apply some clippy lints

* some more clippy lints

* simplify regex

* remove superflous if condition

* remove the Rc<_> in `Element`

* small cleanups and regex fix

* avoid allocating a vector for the culled pda

* bug fix

* bug fix

* reintroduce the Rc, but make it use the *one* alloced VecDeque this time

* slim down dependencies

* use Box<[&str]> for storted state stacks

this saves us a whopping 8 bytes ;), since we don't have to store
the capacity

* revert the changes from 9ffa715c10089f157e4e20563143a2df890c8ffe

fixes a bug

* apply clippy lint

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-09-05 16:29:24 +02:00
Andrea Fioraldi
4c0e01c4aa
Fix memopidx bug in libafl_qemu r/w hooks and update QEMU (#1500) 2023-09-05 16:28:52 +02:00
Evan
9645dca274
Fixed libafl_atheris Makefile and flag read (#1499) 2023-09-05 01:31:31 +02:00
Dongjia "toka" Zhang
2076fc0722
Fix CI (#1498)
* Update build_and_test.yml

* Update build_and_test.yml

* fmt
2023-09-04 13:00:54 +02:00
ToSeven
a0bcdfa005
implement the AFL-Style Tui (#1432)
* implement an AFL-Style TUI

* improve the tui/mod.rs according to the reviews

* fixing fmt manually

---------

Co-authored-by: toseven <Byone.heng@gmail.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-09-03 23:52:48 +02:00
David CARLIER
1b6ef52a4e
bolts core affinity illumos clippy fixes (#1497) 2023-09-02 21:56:22 +02:00
Dominik Maier
f27107c5e4
Fix docs build for libafl_qemu (#1495)
* Fix docs build for libafl_qemu

* turn around

* does this work?

* build all-features in CI

* fixes

* fix ci
2023-09-02 21:56:01 +02:00
David CARLIER
7e5a1dba05
bolts linux arm64 clippy fix build (#1496) 2023-09-02 01:35:05 +02:00
Rowan Hart
256d010981
Add embed-runtime feature (#1489)
* Add library embedding feature to libafl_libfuzzer

* Add comment describing embed-runtime feature and CI test
2023-09-01 01:03:17 +02:00
Dominik Maier
134fe6a992
ForkserverExecutor: stop forked children on exit (#1493)
* wip

* Fix forkserver exit

* undo change in forkserver_simple

* less map_err

---------

Co-authored-by: Marco Vanotti <mvanotti@google.com>
2023-08-31 22:51:21 +02:00
David CARLIER
d0d378c174
bolts write_minibsod solaris version (#1494) 2023-08-31 22:48:43 +02:00
Andrea Fioraldi
00033426e7
Bump to 0.11.1 (#1491) 2023-08-31 15:07:31 +02:00
Andrea Fioraldi
d68c70b0f5
Fix clippy lint in libafl_libfuzzer (#1490)
* Fix clippy lint in libafl_libfuzzer

* fix libafl_libfuzzer_runtime version
2023-08-31 15:03:15 +02:00
Rowan Hart
bca14c041b
Update from unmaintained tui-rs to ratatui (#1488) 2023-08-31 02:02:36 +02:00
David CARLIER
09295ae819
fix frida build for linux arm64 (#1487) 2023-08-31 02:01:32 +02:00
Dominik Maier
81bdbc0dde
Fix TuneableMutationalStage _std function generics (#1486) 2023-08-30 00:57:10 +02:00
Addison Crump
9149d69699
Fixes for serdeany_autoreg (#1479)
* fixes for serdeany_autoreg

* fmt

* yet more docs

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2023-08-30 00:13:50 +02:00
Dominik Maier
5710c8b28a
Document LIBAFL_DEBUG_OUTPUT in Launcher (#1485)
* Document LIBAFL_DEBUG_OUTPUT in Launcher

* fmt

* more doc

* fork

* unix
2023-08-30 00:00:12 +02:00
Alexander Qi
51e4d814fb
bolts: Fix shmem leak when Drop-ing CommonUnixShMem (#1484) 2023-08-29 18:10:59 +02:00
kiwids
c91fc9a521
Update LibAFL_CC README.md (#1483)
Updated with steps to compile LLVM from source tree
2023-08-29 18:09:28 +02:00
Dominik Maier
61ad4a6ee8
bolts: Make xxh3 hashing optional with xxh3 feature flag (else use ahash for everything) (#1478)
* Make xxh3 hashing optional (and default to ahash)

* make xxh3 default anyway

* move import

* fix no_alloc

* No ahash without alloc

* fix import

* Keep xxh3 as default for libafl as well

* no randomness for xoshiro
2023-08-29 16:22:46 +02:00
Dominik Maier
ab837cbbf5
Fix document_features for libafl_libfuzzer (#1480) 2023-08-29 15:10:50 +02:00
Andrea Fioraldi
638d315b57
Add readmes (#1476)
* Add readmes

* fix docker
2023-08-29 14:51:55 +02:00
lenawanel
f3a4f4f664
Remove unneeded loop in SpliceMutator::mutate (#1471)
previously we searched for the first and the last difference
between exactly the same 2 inputs 3 times in a loop

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-08-29 13:30:29 +02:00
Dominik Maier
7d2c854b71
Introduce document-features feature (#1477) 2023-08-29 12:40:35 +02:00
Andrea Fioraldi
e66eb33e96
Fix libafl_libfuzzer publish (#1475)
* fixup build

* allow dirty

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
2023-08-29 11:32:52 +02:00
Andrea Fioraldi
062ae9d544
Fix doc for publish (#1472)
* Fix doc for publish

* add bolts to publish.sh
2023-08-28 17:22:44 +02:00
Andrea Fioraldi
7dd7c1a485
Bump to 0.11.0 (#1469)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-08-28 15:36:43 +02:00
Dominik Maier
b45985c76b
Less pub in LLMP (#1470)
* Less pub in LLMP

* add mut to docstring

* fix eample
2023-08-28 13:18:58 +02:00
Dominik Maier
1357b9f310
Add Broker.peek_next_client_id (#1468)
* Add Broker::next_client_id

* rename to peek_

* Undo change, probably not better
2023-08-28 09:00:05 +02:00
Dominik Maier
0a0c4639a6
Replace manual binary search with stdlib (#1466) 2023-08-27 23:12:36 +02:00
lenawanel
6a2d6fa66d
fix some docs and use slice::fill instead of manual implementation (#1467)
* update documentation of `MinimizerScheduler`

(convert a few references to types into doc links and update the docs of `on_remove`)

* replace manual implementation of `slice::fill`

the in the code comment linked stackoverflow comment https://stackoverflow.com/a/51732799/1345238/
now mentions `slice::fill`
it seems to compile to the same thing as the old version https://rust.godbolt.org/z/98Y4x97vY

* fix docs for the `*InterestingMutator`s and `*ByteAddMutator`s

the macros didn't previously docs gens didn't previously
 generate fitting docs
2023-08-27 23:11:44 +02:00
David CARLIER
713f0c5913
Update FreeBSD on CI (#1463) 2023-08-27 15:34:46 +02:00
David CARLIER
fc6df5ef47
llmp: switch to binary search (#1465) 2023-08-26 13:52:14 +02:00
Rowan Hart
8d8fcdd8db
Add generic cmp observer metadata, rename cmp observers, fix cmplogmap reset (#1461)
* Make cmp metadata generic, rename ForkserverCmpObservers with more accurate names

* Fix zeroed assignment in cmplogmap

* Dont use prelude in libafl_targets

* Make _mut functions actually return mut references

* Fix fuzzbench forkserver build

* Add type alias for easier construction of the standard cmp observer and add aux data accessors
2023-08-26 09:54:31 +02:00
Dominik Maier
6df415438d
Update frida_gdiplus readme (#1464)
Thanks to Nuja from Awesome Fuzzing Discord
2023-08-25 14:49:57 +02:00
Andrea Fioraldi
760edbf0d2
Fix forward_id stats for the centralized manager (#1454)
* Fix forward_id stats for the centralized manager

* Fix stats bug
2023-08-25 14:23:25 +02:00
Andrea Fioraldi
04c8d5208b
qemu: Fix cpu page size function for full-system (#1452)
* Revert "qemu: add cpu page_size call (#1433)"

This reverts commit d338b30c080ecfe1a6639185b6505b7a7b8edbeb.

* Reintroduce page_size
2023-08-25 11:42:23 +02:00
David CARLIER
4a96354276
bolts: fix netbsd/openbsd clippy (#1459) 2023-08-24 21:41:44 +02:00
David CARLIER
209d38a768
bolts: disable build for rust < 1.70 proposal. (#1460)
mostly due std::cell namespace introduction in the 1.70 version.
as rust versions evolve fast enough, it might be easier than
having conditional dependency on he old once_cell crate.
2023-08-24 21:41:26 +02:00
Addison Crump
9aa40c0734
Document libafl_libfuzzer (#1457)
* prep for publishing libafl_libfuzzer

* learn to use linkers

* document-features

* special handling for fuzzbench builds

* Update cmplog.c

* drop dep for llvm-tools; add testcase for memcmp sanity

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-08-24 20:24:38 +02:00
Dominik Maier
f7c94f9a85
Create _std public methods on TunableMutationalStage (#1458)
* Create _std public methods on TunableMutationalStage

* No tunafish
2023-08-24 16:05:30 +02:00
Dominik Maier
9208531951
Move from intervalltree to meminterval dep (#1456)
* Move from intervalltree to meminterval dep

* fixes
2023-08-24 14:15:24 +02:00
Addison Crump
862de53cf6
Full libfuzzer shimming (for cargo-fuzz libfuzzer alternative and other use cases) (#981)
* squash libfuzzer edits

* fixup: compat with custom mutators

* use tui flag

* add introspection support

* use libfuzzer dep now that we've merged

* force input loading

* some fixes

* begin docs, impl shrink

* make whole-archive conditional and not default

* make more copies of counters maps

* lol, remember to add the observer

* make size edge map observer an observer

* fixup: make def of run driver conditional

* add sanity checks for insertion

* revert silencing of forks

* add experimental tmin support; add default asan flags

* use default options instead of specifying our own

* implement lockless mode

* fix merge

* fixup lockless corpus

* fixup for generalisation

* remove erroneous drop_in_place

* improve error logging in the case of corpus loading failure

* ok, use lock files 😔

* fix tmin

* implement merge (again); fix rare cases with maps being too small

* implement a scheduler for removing excess

* implement a walking strategy for corpus loading for large corpora

* revert filename parameter; rename and remove duplicates

* various cleanup and clippy satisfaction

* fix no_std tests

* clang-format

* expand and satisfy the clippy gods

* fix sanitizer_ifaces bindgen for no_std

* fix wasm fuzzer

* fixup clippy script

* rename and provide a small amount of explanation for sanitizer_interfaces

* fixup: HasLastReportTime

* fix clippy oddities

* restrict clippy checks to linux-only for libafl_libfuzzer_runtime

* name the mutators

* format

* fix clippy warning

* hope docker is fixed

* fix cmin lint

* clippy pass

* more docs

* more clippy

* fix remaining clippy complaints

* fix import

* miri fixes (no constructors executed)

* exclude libafl_libfuzzer from cargo-hack

* fix clippy check for sanitizer_interfaces

* fmt

* fix CI (?)

* deduplicate sancov 8bit for improved perf on ASAN

* merge 8bit coverage regions + comment out insane deduplication

* no erroring out on free hooks

* fixup for non-forking merge

* skip the corpus dir if we use it

* fixup: recent libafl changes and feature flags

* libafl_libfuzzer: use rust-lld for whole-archive feature

* clarify cause of failure

* mark unsafe

* clippy :cursed_cowboy:

* attempt to fix wasm

* spooky unknowable bug 👻

* more clippy lints

* clippy fix for merge

* use the version pin

* add unsafe to ::register

* Serdeany autoreg fix

* make type assert actionable

* miri fixes

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dominik Maier <dmnk@google.com>
Co-authored-by: Mrmaxmeier <Mrmaxmeier@gmail.com>
2023-08-24 13:30:23 +02:00
Dominik Maier
f68fe95f09
Document features (#1453)
* Document features

* Fix doctest

* remove link

* <<<<head

* Fix doc links
2023-08-24 13:27:37 +02:00
Dominik Maier
e89e8dbaab
Remove dependencies, add doc.rs metadata (#1450)
* Remove dependency, add doc.rs metadata

* remove lazy_static

* even less lazy_static

* serial_test no default
2023-08-24 11:34:38 +02:00
lazymio
c84c105fb9
Allow setting max iterations for stages (#1436)
* Allow setting the max iterations

* Rename API

* Fix baby_fuzzer_grimoire

* Relax bound

* Also add a new API for transforming

* Revert back grimoire fix

* Revert bound relax
2023-08-24 09:59:11 +02:00
lazymio
20cee8cd33
Allow multiple tuneable mutational stages (#1437)
* Allow multiple tuneable mutational stages

* Fix for default name

* Fix import

* Format code

* Standalone trait bounds

* Minor fix

* Add _with_name API

* Format code

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-08-24 09:58:23 +02:00
Dominik Maier
2f840ef92d
Windows dependency upgrade (#1448)
* Windows dependency upgrade

* update windows

* fmt

* expect is not fun but what can you do

* fmt, clippy
2023-08-24 08:15:31 +02:00
Dominik Maier
454142c29e
Add bolts::math, make functions const, cleanup (#1444)
* Make some functions const

* fix isprint

* more const

* move integer_sqrt to bolts, use binary search, use u128 to handle extreme values

* Technically correct

* clippy

* u64 algo

* More test

* cumulative_distribution to in_place

* move calculate_cumulative_distribution_in_place to bolts

* clippy

* Move math stuff to bolts::math

* actually add math

* math?

* For some reason this fixes things, dunno

* fix builds?

* does that help?

* clippy ignores

* more clean clippy

* more cfg_attr
2023-08-23 21:12:39 +02:00
David CARLIER
d338b30c08
qemu: add cpu page_size call (#1433)
* qemu handy cpu page size call proposal.

* changes from feedback.
2023-08-23 20:27:58 +02:00
Manish Goregaokar
8f27b14eb8
Use postcard with default-features = false (#1446) 2023-08-23 19:53:25 +02:00
Dominik Maier
65ec23fd35
Update uds, remove unused features (#1447) 2023-08-23 19:52:59 +02:00
David CARLIER
1922cb0a65
qemu snapshot little update proposal. (#1431)
* qemu snapshot little update proposal.

* reeatablishing the TODO since the change does not do it at all
 but getting unrelated constant mask unrelated to mappings protection.

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-08-23 10:13:08 +02:00
Rowan Hart
942c6a42ac
Reset headers with a memcpy, not an assign from zeroed (#1443) 2023-08-23 08:23:52 +02:00
Marco Vanotti
174b852e0a
Fix probabilities in TuneableScheduledMutator (#1440)
This commit fixes some issues regarding the `TuneableScheduledMutator`,
which had an edge case for drawing probabilities.

The user is supposed to provide a vector with probabilities that have to
add up to 1.0, but due to floating-point errors, the number can be
sligthly off.

If the sum ends up being slow, there's a chance that we draw a number
that is bigger than it (for example, 1.0), and that would not be present
in the cumulative distribution vectors (either for iterations or
mutations).

The issue is fixed by setting the last value of the cumulative
distribution to 1.0.

This commits adds some validations in the function that calculates the
cumulative distribution function, making sure that the numbers add up to
1, and that they are all between 0 and 1.

The API is now changed so the functions can now return an error instead
of crashing.

The commit also adds some tests, and fixes the `reset()` function.
2023-08-23 01:37:22 +02:00
David CARLIER
389c7c6554
bolts: fix freebsd clippy warnings (#1442) 2023-08-23 01:32:34 +02:00
Andrea Fioraldi
0b43711dc9
Fix LLMP p2p + restart bug with CentralizedEventManager (#1389)
This commit rewrites the centralized manager to use a secondary broker, as p2p communication is unreliable during frequent restarts. A centralized launcher is introduced too.
2023-08-22 15:57:50 +02:00
Rowan Hart
a14363f1fc
Make CmpValues Clone (#1439) 2023-08-21 22:11:11 +02:00
Dominik Maier
6e5d102673
Clippy fixes for frida_executable_libpng fuzzer (#1438) 2023-08-21 19:41:03 +02:00
Dominik Maier
a426b6fc3d
Clippy for pthread_hook (#1435)
* Clippy

* doctest
2023-08-21 13:35:59 +02:00
Dominik Maier
c31ca2c9f7
Fix Frida CI for Windows, Clippy (#1430)
* Fix Frida for Windows

* more fix

* clippy in pthreads
2023-08-20 13:30:21 +02:00
David CARLIER
c6bfb07832
bolts write_minibsod netbsd implementation. (#1428)
pretty close to freebsd for the most part.
2023-08-20 12:01:04 +02:00
Dominik Maier
1d746b4074
Fixes for frida, qemu_sugar (#1427)
* Fixes for frida, qemu_sugar

* tiny clippy

* clippy

* fix thread_id

* Attempted fix for qemu
2023-08-20 12:00:41 +02:00
lenawanel
173b14258b
fix CI QemuCmpLogHelper error. (#1429)
this was caused by using `cpu_arch = {mips,hexagon}` and `feature = [mips,hexagon]`
for the same reasons
2023-08-20 11:58:50 +02:00
r4ve1
0eceafe0c5
Allow the FridaInProcessExecutor to attach Stalker on specific thread (#1256)
* feat: support specify thread id for frida stalker

* fix: thread_id type

* fix: use official repo for frida-gum

* Merged

* Added back missing bolts

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-08-17 19:47:07 +02:00
Dominik Maier
35fa881ff0
Update frida (#1408)
* Update frida

* fix build

* aarch64

* fix aarch64 buid

* Fix CI

* move to git version of frida

* fix

* Frida frida frida
2023-08-17 17:49:12 +02:00
Dominik Maier
b0179b4498
Update some deps, clippy (#1422)
* More less default

* More clippy

* updated rangemap

* Clean up depencdencies

* Undo accidental remove

* Fix

* trying to fix qemu build

* hexagon be gone
2023-08-17 17:15:03 +02:00
David CARLIER
b5774b2275
write_minibsod for apple (#1425) 2023-08-15 20:16:07 +02:00
lenawanel
5c05b3d32d
Update documentation of feedbacks::map::OneOrFilledIsNovel (#1423)
this previously seemed to describe `NextPow2IsNovel`
2023-08-15 20:14:30 +02:00
David CARLIER
bc42880274
minibsod, fix clippy warning (#1424) 2023-08-14 10:51:01 +02:00
Dominik Maier
0be4847cb7
Add more libafl_qemu archs to libafl_sugar (#1419)
* Add more archs to LibAFL_QEMU

* fixed critical whitespace
2023-08-13 20:38:24 +02:00
David CARLIER
8f16001c47
minibsod::generate_minibsod openbsd implementation (#1420) 2023-08-13 20:36:13 +02:00
David CARLIER
698ebb6b35
libafl_bolts: fix musl build (#1421)
despite being present in the headers, getcontext is not implemented in
musl libc, most likely due to the fact it s a deprecated interface.
The only way around is having the third party libucontext apk package
installed.
2023-08-13 12:14:30 +02:00
Dominik Maier
dcdfa978a4
Fix latest Clippy for good (#1418)
* More Clippy

* More clippy

* More ignore
2023-08-13 12:10:55 +02:00
Dominik Maier
b02592c5c7
Add serdeany_autoreg to libafl_frida (#1417) 2023-08-13 10:07:33 +02:00
Konstantin Bücheler
9650e06b45
Add serdeany_autoreg to libafl_qemu (#1416)
* Add `serdeany_autoreg` to `libafl_qemu`

* Update Cargo.toml

Add autoreg to default

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-08-13 01:25:59 +02:00
Dominik Maier
e0d90aa67f
More Clippy fixes (#1415)
* More Clippy fixes

* Clippy
2023-08-13 01:17:34 +02:00
Dominik Maier
b9879a8bfc
Fix CI (#1414) 2023-08-12 03:24:06 +02:00
mark0
a55d40cd00
Update accounting.rs (#1411)
Remove dead code for better semantic compliance
2023-08-10 17:46:56 +02:00
Dominik Maier
ff2f325d68
Fix building docs (#1413) 2023-08-10 14:51:19 +02:00
Dominik Maier
8ca2df8819
Updated Scheduler::on_add documentation (#1410) 2023-08-10 14:27:21 +02:00
lenawanel
4bee9a9039
Update documentation of PowerQueueScheduler::on_add (#1409)
this fixes https://github.com/AFLplusplus/LibAFL/issues/1373
2023-08-10 14:23:19 +02:00
Dominik Maier
418d0dba91
Remove unused owned (for now) (#1405) 2023-08-07 12:50:43 +02:00
Dominik Maier
b877ed7e0e
Removed unused intrinsics features (#1404) 2023-08-07 10:55:08 +02:00
WorksButNotTested
51e2f64e5b
gdb_qemu: Ignore UTF-8 errors (#1403)
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-08-07 10:54:49 +02:00
David CARLIER
3bf3172928
fix bolts build, intrinsics is an internal feature. (#1402) 2023-08-06 23:03:34 +02:00
Dominik Maier
dfaf06a22e
Make bolts work without alloc (#1401)
* Make bolts work without alloc

* Use core::Error where available

* unstable_feature -> nightly

* windows no_alloc
2023-08-05 01:03:40 +02:00
Dominik Maier
a0c03fccc5
Add serdeany_autoreg feature flag to allow disabling ctor use (#1398)
* Add  feature flag to allow disabling  use

* fix typo

* undo cargo.toml change

* Fix no_std

* Backticks

* rename register_at_startup to create_register

* fix

* Move Tui_monitor to default instead of std
2023-08-04 15:36:48 +02:00
David CARLIER
83f739f010
libafl_cc using hwasan on Linux/Android arm64 (#1399) 2023-08-04 01:50:41 +02:00
Dominik Maier
5dd5b1efa8
More fuzzer fixes for Bolts (#1397)
* more fixes

* more docker fix
2023-08-03 11:45:18 +02:00
Dominik Maier
dbba687b9b
Add proper REAME.md to libafl_bolts (#1396)
* Add proper readme to libafl_bolts

* more 0.11 doc
2023-08-03 02:59:30 +02:00
Dominik Maier
f752acc2a4
Info about how to migrate to 0.11 (#1395) 2023-08-03 02:35:37 +02:00
Dominik Maier
febb154e49
Fix merge fail for baby_fuzzer / bolts (#1394)
* Fix merge for bolts

* warning fix

* warning fix
2023-08-03 01:58:09 +02:00
Dominik Maier
e9e9c457d6
Move Bolts to libafl_bolts (#1335)
* sort memebers

* Building bolts

* fixing python, feature flags

* Cleanup bolts Cargo.toml

* Fix tests

* cleanup libafl

* removed duplicate examples

* Info text

* reenable agpl CI

* fix impl_serdeany

* new fmt

* Moved bolts

* fix some builds

* fix

* fix more fixes

* serdeany

* no_std

* Dependency cleanup

* Fix docs

* Docker

* add python bolts bindings

* no_std test fix

* merge fail

* typo fix

* add bolts dependency to fuzzers

* tiny fixes

* merge fun

* clippy

* link no longer exists

* make sure python gets rebuilt

* fix pybind

* doc fix

* remove bolts ref

* LibAFL bolts

* More info

* deprecation notice for launcher

* fix python

* cargo fmt

* fix concolic

* fix

* clippy

* fix libafl_cc

* fix tutorial, clippy

* fix concolic fuzzer

* fix push_stage_harness fuzzer

* prelude

* fix testcase post-merge

* mute clippy
2023-08-02 17:36:26 +02:00
Dominik Maier
d69cde896c
Less unsafe type_eq in stable (#1392)
* less unsafe type_eq

* add type_eq test

* More type eq test

* extend test by a lot

* go mad with tests

* fmt

* simpler tests

* clippy
2023-08-02 13:58:05 +02:00
David CARLIER
f4f55088e3
ControlFlowGraph::calculate_difference_all_edges build warning fix. (#1390)
get_edge returns a reference, anyhow CfgEdge does implement the Borrow's trait neither.
2023-08-02 09:58:49 +02:00
Dominik Maier
fc809ccb33
Remove FeedbackState reference from the book (#1391)
* Remove FeedbackState reference from the book

* Update feedback.md
2023-08-01 23:27:51 +02:00
Dominik Maier
006dcac00c
Named Mutators and MultiMutator API change (#1387)
* Mutators need names (alternative to #1379)

* Signature of MultiMutator shouldn't be the same as the normal mutator

* Named for python, remove mutator for multi_mutator

* fmt

* clippy edition warning

* clippy

* mac_count doc fix, return cleanup
2023-08-01 16:58:40 +02:00
Dominik Maier
90e9f3c786
Move apt-get before checkout (#1388) 2023-08-01 14:42:35 +02:00
Andrea Fioraldi
ac4a0e7330
libafl_qemu snapshot device filter (#1386)
* libafl_qemu snapshot device filter

* Working device list

* regenerate bindings stub
2023-08-01 12:01:10 +02:00
Mrmaxmeier
fc9caa8314
Fix UB in frida fuzzers (#1385)
* WIP: fix ub issue in frida fuzzers

* refactor frida helper: remove unused fields

* revert frida-gum bump. Current frida-gum doesn't build on iOS :/

* libafl_frida: silence must_use_candidate lint

this lint is very noisy, and adding #[must_use] to _all_
(even pure )functions seems very excessive to me

* fix clippy
2023-07-29 13:44:54 +02:00
Andrea Fioraldi
37bfead4e5
Fix generic hooks bug in libafl_qemu (#1382) 2023-07-27 17:28:33 +02:00
David CARLIER
eae6f0436f
fix riscv(32) tick reading for clang (#1381)
albeit it passes with gcc it does not with clang.
2023-07-26 13:58:35 +02:00
Andrea Fioraldi
cb24b5dc2d
Extract linker args when building QEMU (#1377)
* Update qemu commit

* Hook the linker and automatically extract linker args

* Comment code
2023-07-26 10:42:15 +02:00
Abc Xyz
993eb62bb8
fix(libafl): update Z3 dependency (#1372)
See https://github.com/Z3Prover/z3/issues/5586. libafl with `cmin` feature cannot be built for Android.
2023-07-24 15:12:16 +02:00
Addison Crump
81e9a9a60f
Fix build/clippy errors and update CASR (#1375)
* fix new exciting clippy errors

* fix CASR build errors

* bump casr version

* more clippy whack-a-mole

* allow needless pass by ref mut as it is improperly marked unnecessary
2023-07-24 15:11:24 +02:00
David CARLIER
b064eb3994
read_time_counter port for the RISCV family. (#1378) 2023-07-24 13:14:07 +02:00
David CARLIER
f0563475c3
noaslr: add netbsd support (#1371) 2023-07-16 17:09:44 +02:00
Dominik Maier
36b1d8aea2
Fix status updates for crashing fuzzers (fixes #1367) (#1368)
* Fix status updates for crashing fuzzers (fixes #1367)

* client perf fix

* Add HasLastReportTime trait :/

* ****** prelude

* reoder phantom

* fix tests

* clippy, fixes

* more fixes, traits are maaad

* fmt
2023-07-14 18:50:31 +02:00
Dominik Maier
003b219826
Make all no_mangle fns extern "C" (#1369) 2023-07-14 17:42:58 +02:00
David CARLIER
eb362c5c77
libnoaslr support for netbsd (#1366) 2023-07-14 14:59:24 +02:00
s1341
11fc57a5d7
Launcher: Allow setting a distinct stderr redirect (#1329)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-07-13 22:50:01 +02:00
Addison Crump
f76331eac7
Add RefCellValueObserver (#1363)
* add RefCellValueObserver

* appease the clippy gods

* Update libafl/src/observers/value.rs

Co-authored-by: Langston Barrett <langston.barrett@gmail.com>

---------

Co-authored-by: Langston Barrett <langston.barrett@gmail.com>
2023-07-13 18:02:02 +02:00
David CARLIER
a95b322b1c
noaslr disable aslr for dragonflybsd. (#1364) 2023-07-13 14:11:09 +02:00
David CARLIER
1609960244
libnoaslr: add FreeBSD support (#1361) 2023-07-12 13:55:18 +02:00
epi
72e54ac2f4
Update ForkserverBytesCoverageSugar to use parse_afl_cmdline, latest features (#1343)
* update forkserversugar to use parse_afl_cmdline

* added tokens/persistent/deferred to forkserver sugar

* removed deferred option

* added build_dynamic_map call; removed generic const

* clippy

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-07-12 12:16:46 +02:00
Andrea Fioraldi
3e0e753e9f
Update typed_builder to fix no_std (#1360) 2023-07-11 11:31:37 +02:00
WorksButNotTested
2002bbca35
Arch independent helpers in libafl_qemu (#1355)
* Add more features to libafl_qemu to remove some of the heavy lifting from the fuzzers

* Refactor qemu_coverage

* Minor tweaks to fix other fuzzers

* Autofix

* Add CallingConvention to write_function_argument

* Replay reverted clippy fixes

---------

Co-authored-by: Your Name <you@example.com>
2023-07-11 10:56:40 +02:00
Dongjia "toka" Zhang
109755208e
Revert "Make harness function take mut ref (#1338)" (#1358)
This reverts commit fe6daecf0bb178cd19970ae81c797443fd8cd88f.
2023-07-10 17:33:26 +02:00
Dongjia "toka" Zhang
1ad1b7cb17
revert typed builder version (#1357) 2023-07-10 14:16:24 +02:00
Andrea Fioraldi
65368408dd
Algorithm to choose to serialize the observers or not (#1227)
the algorithm is balancing between observers serialization and re-execution
2023-07-10 13:42:53 +02:00
Langston Barrett
cbf0952ec7
libafl{,_qemu}: Bump num_enum to 0.6 for syn 2 support (#1350)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-07-10 13:13:53 +02:00
Langston Barrett
2885b10f70
libafl_qemu_build: Bump bindgen to 0.66 for syn 2 support (#1349) 2023-07-10 13:12:26 +02:00
Langston Barrett
33aa012bdd
libafl_qemu: Bump strum to 0.25 for syn 2 support (#1348) 2023-07-10 13:12:16 +02:00
Langston Barrett
3f8c5f585b
libafl{,_concolic}: Bump ctor to 0.2 for syn 2 support (#1347) 2023-07-10 13:12:08 +02:00
Langston Barrett
2712430f93
libafl{,_sugar}: Use typed-builder 0.15 for syn 2 support (#1346) 2023-07-10 13:11:52 +02:00
Rowan Hart
fe6daecf0b
Make harness function take mut ref (#1338)
* Change executor trait to allow \&mut Input

* Add mut inprocess executor

* Add mut inprocess executor

* Format and fix clippy errors

* Fix more clippy errors

* Revert accidental refactoring of InMemoryCorpus

* Add mut versions of all executors that can support it

* Do not persist possible testcase mutation in stages, shadow/differential executors, or corpus minimization

* Fix missing imports

* Fix executor type for missed qemu items

* Add re-exports for mut executors

* Use InProcessForkExecutorMut in QemuForkExecutorMut

* Update BytesInput harnesses to take mutable references

* Update other-input-type-taking harnesses to take mut references

* Clippy fixes

* Feature gate TryFromIntError import

* Fix missed harness input type in baby_fuzzer

* Fix additional clippy issues

* Fix unnecessary hashes on string literal

* Even MORE clippy fixes

* Fix one more clippy issue

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-07-10 13:06:38 +02:00
Dongjia "toka" Zhang
52ab8c02d6
Fix CI (#1354)
* Update build_and_test.yml

* Update build_and_test.yml
2023-07-07 17:24:03 +02:00
Dongjia "toka" Zhang
44bbaf7d22
Update build_and_test.yml (#1353) 2023-07-07 16:22:27 +02:00
Dongjia "toka" Zhang
8cca87f2bd
Fix #1342 (#1345)
* push

* fmt
2023-07-05 13:03:09 +02:00
Dominik Maier
e5b3e5a677
Fixed Forkserver shmem input length, made it configurable (#1342)
* Fixed Forkserver shmem input length, made it configurable

* fix redqueen clippy

* Clippy

* Clippy

* WHY ARE THERE TWO TIMES THE SAME FN

* More clippy
2023-07-04 14:57:09 +01:00
Ivan Fratric
829b5049e6
Hexagon support (#1323)
* Hexagon support

* Fix format

* Fix needless bool

* Address comments

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-07-04 11:08:36 +02:00
Dongjia "toka" Zhang
07f4c42ecf
AFL++ redqueen update (#1291)
* up

* dbg

* fix

* fmt

* fix

* refactor

* more

* clp

* upd

* fmt

* fmt

* last

* debugging

* wip

* lastlast

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-07-03 19:27:34 +02:00
David CARLIER
4897c3f205
util/noaslr porting to FreeBSD (the non-lib part). (#1337)
to port to the library, might need a nice layer over the FreeBSD's C api (nix?)
before hand.
2023-07-03 00:51:32 +01:00
Dominik Maier
c0e1236a07
Formatting fuzzers with new fmt (#1340) 2023-07-02 18:19:48 +01:00
Dominik Maier
6f4955619a
Latest fmt (#1339) 2023-07-02 18:13:46 +01:00
WorksButNotTested
07047cb3bb
Added noaslr (#1333) 2023-06-30 20:37:48 +02:00
WorksButNotTested
97b3d3c7c7
Add gdb_qemu utility (#1331) 2023-06-30 20:36:46 +02:00
WorksButNotTested
c6062889d5
Extend qemu_launcher to support multiple architectures (#1328)
* Change qemu_launcher fuzzer to support multiple architectures and remove qemu_arm_launcher

* Review changes

* Changes to milliseconds

---------

Co-authored-by: Your Name <you@example.com>
2023-06-30 02:18:00 +02:00
s1341
871dfa0a01
Insert into corpus if feedback is_interesting on crash/timeout (#1327)
* Insert into corpus if feedback is_interesting on crash/timeout

* Use correct import for HasExecutions

* Windows add missing import

* QemuExecutor add HasFeedback

* Windows asan fix

* Add missing call to scheduler.on_add

* Add missing HasExecutions for windows frida

* QemuExecutor missing HasScheduler

* QemuExecutor missing HasCorput
2023-06-28 23:53:51 +02:00
s1341
71aa0221a0
Add feature to build variants/configurations automatically, with libtool/cc/cxx shims (#1322)
* Add feature to build variants/configurations automatically, with libtool/cc/cxx shims

* Fixes

* Clippy

* Add brief comment describing usage

* Fix

* Fix fuzzers: add ToolWrapper

* Clippy

* More clippy

* More clippy

* Add Compound configuration

* Clippy

* Fix

* Clippy

* Damn that Clippy

* Change names of Configurations

* Add ar wrapper

* Fix

* Clippy

* Windows build

* Clippy

* Clippy

* Clippy
2023-06-22 16:17:33 +02:00
Andrew-Fryer
07530fea57
Trigger feedback side effects during force-loading (#1317)
* this triggers feedback side effects during force-loading

* oops; correct typo in introspection branch

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-06-17 02:06:07 +02:00
Dongjia "toka" Zhang
dad8217c38
Update build_and_test.yml (#1318) 2023-06-16 01:26:40 +02:00
WilliamParks
dec202e6d6
Fixes math with register offsets (#1314) 2023-06-15 21:53:22 +02:00
s1341
c66c3ff2b8
Attempt to fix ci (#1315)
* Attempt to fix ci

* fix

* fix

* rm all the stuff
2023-06-15 21:53:06 +02:00
Dominik Maier
f858e1a247
Add TcpEventManager (#1302)
* Tcp manager, initial commit

* no tokio by default

* Allow Any broker type

* Add tcp_manager example

* fix CI
2023-06-10 06:25:25 +02:00
s1341
751d96f45a
libafl_cc: Add override env vars to configure LLVM (#1310)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-06-09 16:55:31 +02:00
Dominik Maier
62b1bde7a9
Fix AnyMap for TypeIds with 128 bit (#1311)
* Fix AnyMap for TypeIds with 128 bit

* make const

* added test, removed static_assertions
2023-06-09 14:06:42 +02:00
Daniel Blackwell
fa63493cee
Fix for issue with CommandExecutor when using InputLocation::StdIn (issue #1306) (#1308)
Co-authored-by: dan <dan@localhost.localdomain>
2023-06-08 16:25:20 +02:00
Dimitri Kokkonis
7d67fc77b5
Give baby fuzzer listings unique package names (#1307)
As discussed in [#1305], it is problematic for the listings to have the
same package name, as they cause warnings to be emitted.
2023-06-08 15:23:39 +02:00
Addison Crump
60c1990f4a
Make it possible to escape from simple event restarter (#1303) 2023-06-06 23:43:41 +02:00
WorksButNotTested
747a636f4f
Add sample fuzzer which collects DrCov coverage for various architect… (#1300)
* Add sample fuzzer which collects DrCov coverage for various architectures using QEMU instrumentation

* Fix clippy

* Rename NullCorpus to NopCorpus

* Added support for verbose output

* Attempt to fix clippy again

* Fix remaining defaults to use x86_64 when no arch specified and be more robust handling partial builds

* Make build even more robust against partial re-builds

* Added missing dependencies to workflow, updated README

* Add missing dependencies for i386

* Another dependency

* More dependencies

* Disable tests on OSX

* Add tmate

* Add missing dependencies and symlink header directory

* Tidy up after test so we don't hog all the disk space

---------

Co-authored-by: Your Name <you@example.com>
2023-06-06 11:50:38 +02:00
Dongjia "toka" Zhang
fa1e3fd504
CI (#1301)
* ci

* fi

* Revert "fi"

This reverts commit ed298d71057607f019e64d58687273a01d30e260.

* Revert "ci"

This reverts commit 6b65936990143a6069abd56dcbe633ac37be2ede.

* fi
2023-06-05 16:29:51 +02:00
Andrea Fioraldi
356698c24b
Update to QEMU 8 (#1299)
* Update to QEMU 8

* fix

* fix snapshots

* fix pcrel
2023-06-02 18:24:07 +02:00
Dongjia "toka" Zhang
8445ae54b3
Allow multiple source file in libafl_cc (#1296)
* add

* clp

* fi

* fmt
2023-05-26 11:35:04 +02:00
WorksButNotTested
0336eae908
Tidy libaf_qemu hooks (#1293)
* Simplify hooks

* More simplification

* Appease the clippy gods

---------

Co-authored-by: Your Name <you@example.com>
2023-05-25 00:24:28 +02:00
Dongjia "toka" Zhang
594ce420fc
Fix libafl_cc (#1295)
* push

* fix
2023-05-24 18:44:13 +02:00
WorksButNotTested
53dd6c6be6
Post gen (#1282)
* Add post_gen

* Adopt post_gen hooks in DrCovHelper

* Bump qemu-libafl-bridge revision

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-05-24 16:03:59 +02:00
Andrea Fioraldi
258780370f
Update publish.sh (#1294) 2023-05-24 14:16:09 +02:00
Dimitri Kokkonis
89876f2d89
Use listings for baby_fuzzer book chapter (#1289)
* Clarify setup steps for the baby fuzzer

Specifically:
- Explicitly mention that the dependency path must point to a specific
  directory in the cloned repo (and not the root directory)
- Explicitly mention how to manually trigger the panic in the harness
  for testing purposes

* Clean up documentation on the baby fuzzer

Since the baby fuzzer chapter of the documentation is done in a
"tutorial", step-by-step fashion, it would be nice to be able to see
where exactly new lines have to be placed in the existing code. To that
end, the code used in the tutorial is moved to snippets (as is done in
the Rust Book), as it allows for much more convenient maintenance of the
snippets, as well as easy hiding of the non-important code on any given
snippet.

Furthermore, a few minor fixes are applied; a typo on a comment and a
missing unsafe block.

* Fix code snippet attributes for baby fuzzer

Specifically:
- Remove unnecessary `compile_fail` attribute
- Add `ignore` attribute to the snippets of the complete baby fuzzer. As
  explained in [#1290], it is expected for the baby fuzzer to return a
  non-0 exit code, so this should not trigger a failure during `mdbook
  test`.

* Fix CLI snippet language

For CLI snippets, the "language" should be set to `console`.

* Remove nested safe block in baby_fuzzer listings
2023-05-24 12:18:26 +02:00
Rowan Hart
5a6d683fed
Add an observer for COUNTERS_MAPS for 8-bit SanCov (#1283)
* Add sancov multimap observer to sancov_8bit target

* Undo autofmt of Cargo.toml

* Fix formatting

* Fix import errors under no-default-features, add Safety to counters_maps_observer

* Make observer function no_mangle to allow it to easily be used in a staticlib crate

* Make clippy happy by using export_name instead of no_mangle

* Add observers feature flag and hide counters maps observer behind it

* Fix formatting
2023-05-23 23:31:07 +02:00
Dongjia "toka" Zhang
aa6d331110
Fix CI (#1292) 2023-05-23 18:07:54 +02:00
David CARLIER
dc82a53bec
minibsod dragonflybsd's portage (#1287) 2023-05-22 13:13:07 +02:00
Dongjia "toka" Zhang
2be9686a80
Fix clippy (#1288) 2023-05-22 13:12:43 +02:00
David CARLIER
b9b70b0d51
minibsod: generate_minibsod further memory maps data for freebsd. (#1285) 2023-05-22 12:43:31 +02:00
David CARLIER
0d7d52decf
afl_cc fix build for LLVM 17 (#1286) 2023-05-22 12:42:56 +02:00
Dongjia "toka" Zhang
6f21cb3848
Bump to 0.10.1 (#1280)
* bmp

* remove DEBUG env var
2023-05-22 12:42:36 +02:00
Dongjia "toka" Zhang
cba9df9a28
Delete gitmodules (#1278)
* fix

* rm
2023-05-18 13:07:10 +02:00
WorksButNotTested
4029069640
Disable capstone when building qemu-afl-bridge for user-mode fuzzing (#1281)
Co-authored-by: Your Name <you@example.com>
2023-05-18 00:47:59 +02:00
Dongjia "toka" Zhang
52557aefdd
Fix #1276 2023-05-17 15:39:21 +02:00
Dongjia "toka" Zhang
3fd5671909
add (#1276) 2023-05-17 15:22:49 +02:00
Dongjia "toka" Zhang
66127d8492
Revert "Don't pass LLVM pass & its args during linking (#1274)" (#1275)
This reverts commit efc5756e3fac9ed3b82e6d82b770b578b47b42d0.
2023-05-17 14:53:17 +02:00
Dongjia "toka" Zhang
efc5756e3f
Don't pass LLVM pass & its args during linking (#1274) 2023-05-17 14:32:56 +02:00
Dongjia "toka" Zhang
b7c1591b00
Linking arguments for LLVM passes (#1273) 2023-05-17 13:53:02 +02:00
Dominik Maier
20f8cb10eb
Revert "Automatically add the comment about executions when a new PR triggers (#1270)" (#1271)
This reverts commit d2e4b9f206307db0898caac707c0d2687079bfb1.
2023-05-17 02:48:15 +02:00
ToSeven
d2e4b9f206
Automatically add the comment about executions when a new PR triggers (#1270)
Co-authored-by: toseven <Byone.heng@gmail.com>
2023-05-17 00:30:15 +02:00
Arpan Kapoor
6d2284d8b9
Allow configuring timeout for CommandExecutor (#1269)
* Allow configuring timeout for CommandExecutor

* import Duration on windows as well

* fix example fuzzers
2023-05-15 12:59:06 +02:00
Addison Crump
1da621456f
Add check for if mutation succeeded, else skip processing (#1265) 2023-05-14 12:03:25 +02:00
ToSeven
659e91fb68
Fix performance regression detection in CI #1248 (#1259)
Co-authored-by: toseven <Byone.heng@gmail.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-05-14 12:02:32 +02:00
Dongjia "toka" Zhang
b9a540561b
Don't add llvm pass args when there're no passes & Don't pass -mllvm arguments when compiling asm files (#1266)
* f

* fix

* clp
2023-05-12 11:48:12 +02:00
intrigus-lgtm
91b10f8c40
LibAFL_qemu: Disable Capstone to fix build issues on some distributions (#1263) 2023-05-11 09:52:57 +02:00
Kevin Phoenix
6883c776ef
Update pyo3 crate to 0.18.3 (#1255)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-05-10 20:01:51 +02:00
Lei Zhu
a2719cf559
Add suggestion for arg & args (#1257)
* Add suggestion for arg & args

* Make fmt happy

* Explain @@

* Spotlight afl-fuzz

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-05-10 13:53:40 +02:00
Dominik Maier
0c7d42d28b
Clippy Debug fixes (#1261) 2023-05-09 17:05:51 +02:00
Dongjia "toka" Zhang
52d557aa8f
Ecofuzz Fix 2 (#1262)
* finally works

* f
2023-05-09 16:45:20 +02:00
Kevin Phoenix
be1d3da159
Add pyproject.toml to python bindings (#1239)
* Add pyproject.toml to python bindings

* Improve pyproject.toml

* Update CI pipeline to use pip to install python bindings
2023-05-09 13:23:28 +02:00
Dominik Maier
8bd18ef007
Fix latest clippy (#1258)
* Fix latest clippy

* oops needs alloc
2023-05-09 13:17:57 +02:00
Dongjia "toka" Zhang
fe8c06dd8f
Eco fuzz fix (#1253)
* f

* more fix

* aaaaa

* f

* fix

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-05-09 12:56:23 +02:00
Dongjia "toka" Zhang
721c02cd2c
Revert "Add a CI task that checks performance regression (#1248)" (#1254)
This reverts commit 6929c89b861faa4f382a51ab07e3ee1eb727df8c.
2023-05-04 20:03:06 +02:00
Addison Crump
a8e64be169
Alternative scheduled count strategy (#1252)
* early return generalization stage

* scheduled count

* aaa

* compile

* fix

* implement alternative scheduled count strategy

---------

Co-authored-by: toka <tokazerkje@outlook.com>
2023-05-04 13:15:28 +02:00
Tomas Duchac
53659f8a5c
Add file extension for clang in libafl_cc/build.rs (#1237)
* Add CLANG and CLANG_PP env vars

Add CLANG and CLANG_PP env variables for Windows. Resolves issue if clang and llvm-config are not in the same location.

* Just add clang".exe" for windows

User should have llvm-config and clang.exe clang++.exe in the same directory anyways.

* Ran cargo fmt
2023-05-04 11:52:51 +02:00
ToSeven
6929c89b86
Add a CI task that checks performance regression (#1248)
Co-authored-by: hengzh <byone.heng@gmail.com>
2023-05-04 11:51:42 +02:00
Arpan Kapoor
c8c5d89f33
Ignore 'Broken Pipe' if child process does not read all of stdin (#1244)
* Ignore 'Broken Pipe' if child process does not read all of stdin

* follow clippy suggestion
2023-05-03 15:45:27 +02:00
Dongjia "toka" Zhang
abd8efabd3
Add additional security sensitive functions for coverage accounting (#1246) 2023-05-03 15:45:07 +02:00
Dominik Maier
f9c74ed5d6
Update llvm for FreeBSD CI (#1243) 2023-05-03 11:45:49 +02:00
Dongjia "toka" Zhang
cf79d13d17
Change DumpToDiskStage's callback (#1242) 2023-05-03 11:16:53 +02:00
Dongjia "toka" Zhang
5b02fb420d
Fix CI (#1241) 2023-05-02 17:38:56 +02:00
Dongjia "toka" Zhang
c8fad7833d
Use InMemoryOnDiskCorpus in fuzzbench fuzzer (#1240)
* in memory

* f

* aaa

* nn
2023-05-02 15:18:17 +02:00
Michael Rodler
95d1069393
Use sancov_8bit.rs for OwnedMutSlice (#1235)
Co-authored-by: Michael Rodler <mrodler@amazon.de>
2023-05-02 14:41:33 +02:00
Dongjia "toka" Zhang
b2f9e23975
Fix double crash for solutions with the same filename (#1232) (#1236)
* fix

* mre

* why delete it???

* fmt

* clp

* comment
2023-04-29 23:42:51 +02:00
van Hauser
8ff8ae41f1
switch fuzzbench to FAST schedule (#1233) 2023-04-27 11:11:53 +02:00
Dongjia "toka" Zhang
dde7bc9b5c
Dump Call Graph (#1230)
* call graph

* nl

* typo
2023-04-26 20:22:57 +02:00
ToSeven
f248a061ef
add the version information of fuzzers in the UI (#1224)
Co-authored-by: toseven <Byone.heng@gmail.com>
2023-04-26 16:52:21 +02:00
Dongjia "toka" Zhang
037b9551ea
Fix #1228 (#1229) 2023-04-26 12:00:36 +02:00
Dongjia "toka" Zhang
eab7c32e9f
Dump whole program's CFG pass (#1226)
* skelton

* pass

* compiles

* python

* optional pass

* rev

* chg
2023-04-24 14:57:24 +02:00
Andrea Fioraldi
8ade809588
Centralized Testcase evaluation EventManager (#1216)
* template

* moar

* merge

* compiles

* fuzzer

* forward event newtestcase

* clippy
2023-04-24 11:38:55 +02:00
Dongjia "toka" Zhang
39c0a2040b
Fix CI (#1225) 2023-04-20 19:04:31 +02:00
Dongjia "toka" Zhang
e2f4e83890
Fix CommandExecutor type params (#1222) 2023-04-20 16:34:41 +02:00
Dongjia "toka" Zhang
fc23782dc3
Fix is_valid on Windows (#1217)
* git add -u

* fix cfg

* pub

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-04-18 12:15:47 +02:00
Dominik Maier
96e24d1c8b
Move Input loading and dumping APIs from Testcase to Corpus (#1201)
* Less allocatiosn for filenames

* clippy for wasm fuzzer

* Reworked filename and rename APIs

* python, clippy

* fmt

* More cleanup, fixed metadata location

* clippy

* fix fuzzbench_text / cached len, invert parameters (state first)

* clippy

* oops

* Caching for paths

* simplified, fixed

* no_std

* cached_len

* Nider API for input getting
2023-04-18 12:14:49 +02:00
Andrea Fioraldi
fd68c8a81f
Batch mode timeouts (Linux only ATM) (#1193)
* batch mode timeouts for linux

* batch_mode is linux only atm

* fix

* fix

* fix

* imports

* winfix

* more fix

* winfix

* fix

* fix

* fix

* fix

* clippy

* fix macos

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-17 18:16:44 +02:00
Andrea Fioraldi
fafa27a7e9
serial_test as normal optional dep enabled with std (#1215)
* sertial_test as a std and test only dependency

* serial_test as normal optional dep enabled with std
2023-04-17 18:16:29 +02:00
Dominik Maier
c881dc996d
Example fuzzers with less UB (#1212)
* Example fuzzers with even less UB

* more less ub, fixes

* unused dep
2023-04-16 14:29:41 +02:00
Dominik Maier
cdd3d8ace0
Tuneable stage with per-seed timeout (#1209)
* Tunable mutations with timeouts

* fix

* fmt

* Introspection fix
2023-04-13 15:30:47 +02:00
Langston Barrett
863a6b8b7c
Mark buffer_{self_,}copy as unsafe, don't export them (#1207) 2023-04-12 17:42:16 +02:00
Langston Barrett
1b9ffcec74
LibAFL: LLMP manager docstring cleanup (#1208) 2023-04-12 17:40:16 +02:00
Langston Barrett
aa3f126100
LibAFL_qemu: Return errors from Emulator::new instead of asserting (#1197)
* qemu: Return errors from Emulator::new instead of asserting

Libraries should not `assert!` except in cases of unrecoverable (library)
programmer error. These errors are all potentially recoverable, and aren't
internal errors in `libafl_qemu` itself.

* Respond to review comments
2023-04-09 21:27:27 +02:00
Elsa Granger
21ee8d2cae
Fix on_remove of MinimizerScheduler (#1161)
* Fix cursor not step

* Update ref_cnt after remove

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-04-08 16:58:25 +02:00
Vincent
b519d24981
Fix Testcase renaming on disk (#1191)
* fix set_filename

* use ? quantifier instead of expect

* fix clippy

* cargo fmt

* add rename old file to new file logic

* add cfg feature std

* add no_std set_filename

* fix create and remove lockfile logic

* fix cargo fmt

* remove unused import

* cargo fmt

* fix clippy

* fix lock filecondition

* remove useless import

* fix path

* revert fuzzer Makefile.toml

* fix fmt

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-07 02:36:08 +02:00
Dominik Maier
f73e2006fc
Removed more new_ (#1200) 2023-04-07 02:34:28 +02:00
Andrea Fioraldi
0f633962ff
Bump to 0.10.0 (#1156)
* Bump to 0.10.0

* fix

* Fix CI

* Fix copyright

* fmt

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-05 17:49:53 +02:00
Felipe Baltor
6523341c4d
fix: output directory name; monitor output with println! (#1192) 2023-04-05 11:00:21 +02:00
Dominik Maier
0d446bab20
Updated dependencies (#1174)
* Updated deps

* win

* Revert "win"

This reverts commit a6dfd95f1c63a9471659481d92c5cbc480af6360.

* revert win

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-04 22:58:00 +02:00
Andrey Fedotov
807a534121
Use observers to handle crashes in run_target for TimeoutForkserverExecutor (#1189)
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-04 19:17:48 +02:00
Andrey Fedotov
1bd21509af
CASR deduplication for StacktraceObservers (#1184)
* Implement CasrAsanBacktraceObserver for dedupe crashes using libCASR and ASAN reports.

* Use casr observer with forkserver executor

* Add casr deduplication for AsanBacktraceObserver

* Add casr deduplication for BacktraceObserver

* Add Stacktrace filtering

* Move init_ignored_frames to constructors

* Add go ignore regexps for BacktraceObservers

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-04-04 19:03:11 +02:00
Dongjia "toka" Zhang
ccd1211cd2
Remove qemu_arm_launcher test from CI (#1179)
* remove qemu arm

* trigger all

* debug

* revert

* api chg

* fix

* try

* debug

* remove qemu

* no_std

* Update build_and_test.yml

* llvm16

* revert z3

* macos

* fix

* remove test

* don't grep on mac

* fix

* ok

* f

* f

* f

* aaa
2023-04-04 14:49:58 +02:00
LiuZhihong
590d3655cd
add readme documentation description about the tui feature (#1198) 2023-04-04 10:34:22 +02:00
ToSeven
ea512f70f8
Fix a build error in baby_fuzzer_minimizing (#1195)
Co-authored-by: toseven <Byone.heng@gmail.com>
2023-04-03 13:38:11 +02:00
Andrea Fioraldi
a01863696e
Implement restarting without serializing the corpus (#1182)
* Restart without serializing state option

* libfuzzer libpng example

* clippy

* libfuzzer_libpng_norestart

* fix
2023-03-30 14:35:58 +02:00
Dongjia "toka" Zhang
702f163c13
Fix #1181 2023-03-26 17:37:44 +09:00
Dongjia "toka" Zhang
0c9933c3e4
Remove libfuzzer_stb_image_sugar for now (#1177)
* a

* better check

* slow
2023-03-24 02:41:15 +09:00
Dongjia "toka" Zhang
ae2caff990
Revert "Fix testcase set_filename (#1092)" (#1175)
This reverts commit a659dd821c484c4e0524d0a2bf88023dae5e259b.
2023-03-24 01:53:42 +09:00
Dominik Maier
620b2861e3
Fix libafl_qemu testcase (#1173)
* Fix libafl_qemu testcase

* stb?

* Undo change for stb
2023-03-23 15:15:54 +01:00
Dominik Maier
66b2867ba2
Fix example fuzzers (#1171)
* Fix example fuzzers

* fmt
2023-03-23 11:02:18 +01:00
Vincent
a659dd821c
Fix testcase set_filename (#1092)
* fix set_filename

* use ? quantifier instead of expect

* fix clippy

* cargo fmt

* add rename old file to new file logic

* add cfg feature std

* add no_std set_filename

* fix create and remove lockfile logic

* fix cargo fmt

* remove unused import

* cargo fmt

* fix clippy

* fix lock filecondition

* remove useless import

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-03-23 00:21:07 +01:00
David CARLIER
c9ea6ee6aa
core_affinity: freebsd constants are included in libc now. (#1170) 2023-03-23 00:11:02 +01:00
Dominik Maier
76e4f6031d
Fmt, no_std fixes (#1167)
* Fmt, no_std fixes

* push-stage fix
2023-03-23 00:10:01 +01:00
Aritra Mallick
02c6cab744
Link to mdbook book, not github (fixes #1137) (#1168) 2023-03-23 00:08:31 +01:00
Arpan Kapoor
d98384e582
Fix SimplePrintingMonitor (#1164) 2023-03-22 15:39:07 +01:00
Dominik Maier
3f7d35bfdc
Install libz3-dev in CI (#1163)
* install z3 in CI

* Update logics.rs

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-03-22 15:38:33 +01:00
v1ce0ye
7c514c3669
ix UB in baby_fuzzer_grimoire (#1166) 2023-03-22 15:37:57 +01:00
Vincent
38ea17b426
libafl_frida for Linux executables (#1117)
* add frida_executable_libpng

* fix makefile

* fix README.md

* remove author from Cargo.toml

* fix fuzzer

* fix fuzzer

* fix Makefile

* fix linter

* fix clang-format-13

* unsupport mac os

* fix build_and_test_fuzzers

* fix cargo fmt

* cargo fmt

* add safer libc_start_main

* fix call rax addr

* fix frida

* fix cargo fmt

* fix metadata() to metadata_map()

* fix toml

* fix maxmapfeedback
2023-03-22 15:18:21 +01:00
Alexander Zhang
c9a78f154b
Remove duplicate lines in attributes (#1165) 2023-03-22 19:08:32 +09:00
Dominik Maier
8f8e74d670
Don't build z3 from source by default (and add static_z3 feature) (#1160)
* Reduce build times by using preinstaled z3

* fix env order

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-03-20 10:04:27 +01:00
Dominik Maier
f4f23de32b
Fix fuzzers after HasTestcase (#1123) (#1162)
* Fix fuzzers after HasTestcase (#1123)

* Make the trait a trait

* Implement HasTestcase for Corpora

* fix

* fix

* a

* a

* fix

* wasm32

* a

* f

* f

* aa

---------

Co-authored-by: tokatoka <tokazerkje@outlook.com>
2023-03-19 11:58:32 +09:00
Dominik Maier
bbe4e85768
Removed new_ from constructors that don't need it (API consistency) (#1159)
* Removed new_ from constructors that don't need it (API consistency)

* un-change python bindings
2023-03-17 17:02:21 +01:00
Matheus Baptistella
104c170ade
Use the new metadata() function in more places (#1155) 2023-03-17 16:03:57 +01:00
David CARLIER
fd95560512
Check for the presence of clang frontends. (#1158)
* checks the presence of clang frontends.

close GH-1149.

* fix clippy complaints
2023-03-17 16:00:54 +01:00
Dongjia "toka" Zhang
d6ee2dbe12
IfStage (#1157)
* macro

* bracket

* IfStage

* remove macro

* revert
2023-03-17 23:25:01 +09:00
Dongjia "toka" Zhang
8245c7eda9
Logic stages (#1148)
* IfStage

* fmt clp

* constructor

* fmt

* else

* fmt

* while logic

* delete skippable

* fmt

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-03-17 10:21:51 +01:00
Dominik Maier
306cdcd800
Frida: Fix Android build (#1154)
* update android version

* fix android build some more
2023-03-16 16:26:22 +01:00
Dominik Maier
b9970cbdac
Implement From<CorpusId> for usize (#1152) 2023-03-16 16:12:00 +01:00
Dominik Maier
a351e7a509
Frida: fix aarch64 build (#1153) 2023-03-16 16:11:44 +01:00
Dongjia "toka" Zhang
08fe6ab791 Fix mutator slowdown (#1138)
* perf stat

* fix except swap

* swap

* fix

* reveral-based byte swap

* Revert "reveral-based byte swap"

This reverts commit 2bc9609ece47fd4e8f6d96862f8ad3fb77f11aec.

* no introspection

* clp fmt

* change rand_range to have at least 1 length

* don't use modulo

---------

Co-authored-by: Addison Crump <addison.crump@cispa.de>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-03-16 15:58:03 +01:00
Dominik Maier
3c331e5a9b
Create SchedulerTestcaseMetadata if it doesn't exist (#1151)
* Create SchedulerTestcaseMetadata if it doesn't exist

* reset symcc
2023-03-16 14:29:40 +01:00
Dongjia "toka" Zhang
51bc1d0328
Fix infinite calibration (#1147)
* Fix infinite calibration

* fmt

* fix

* fix
2023-03-15 22:19:23 +09:00
Dongjia "toka" Zhang
6c98945fc3
Fix fuzzbench_forkserver 2023-03-15 13:32:04 +09:00
Dongjia "toka" Zhang
0fa815f2b8
Rename MetaData to Metadata 2023-03-14 23:57:55 +09:00
Matheus Baptistella
c38405ef83
Shorthand functions to get typed metadata, renamed metatdata -> metadata_map (#1123)
* Created macro to get the metadata form State and Testcase

* Expanded the macros for mutable, or not, State and Testcase metadata

* Created functions on traits HasMetadata and HasNamedMetadatato get, mutable or not, metadata

* Created the functions to get metadata

* Added #[inline] attribute and renamed the functions

* Renamed the functions and added #[inline] attribute

* Temporarily added testcase() function

* Added testcase() function

* Changed Ref import to core::cell:Ref

* Added testcase_mut() and renamed occurences of metadata() and metadata_mut()

* Renamed more occurences

* Renamed the metadata() on impl HasMetadata for NopState

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-03-14 14:24:33 +01:00
Dominik Maier
8dfdee6fce
Fix UB for differential map observer example (#1140)
* Fix UB for differential map observer example

* clippy

* undo submodule foo
2023-03-14 13:50:50 +01:00
Dongjia "toka" Zhang
460787196a
Update README.md (#1142) 2023-03-14 02:09:39 +09:00
Dominik Maier
6894a37ceb
Added Truncate trait (#1141) 2023-03-13 17:34:58 +01:00
Dongjia "toka" Zhang
44b798c07e
AFL++ RedQueen (#1087)
* step 1

* step 2

* Vec

* comment

* Observer

* tmp

* TaintedTracingStage

* more

* more

* more

* Idea

* more

* more

* mmmmmore

* moremoremore

* more

* all

* clp

* comment

* core

* push temporary debug change

* note for myself

* working

* rename to AFLCmplogTracingStage

* rename

* revert fuzzers' change
2023-03-13 17:34:16 +01:00
Andrea Fioraldi
e8d99b9975
Fix capsone mode in LibAFL QEMU (#1136)
* Use regex feature in libafl_qemu

* wip

* set mode for arm reading pc

* fixes
2023-03-12 23:29:55 +01:00
Addison Crump
786af9f6a9
resolve zero-sized allocation in swap diff fuzzer (#1139) 2023-03-12 23:24:22 +01:00
lazymio
b72bf55555
Add From BytesInput trait for Vec<u8> (#1135)
* Allow take the ownership of the BytesInput

* Add must_use as told

* Implement From&Into for better interoperability

* Format code

* Remove into_bytes

* Remove From<&BytesInput> to avoid misuse
2023-03-09 02:12:09 +01:00
Dongjia "toka" Zhang
4d778dd64d
Fix fuzz_level related thing, separate on_replace/on_remove from Scheduler & various fixes (#1119)
* delete HasFuzzedCorpusId

* more

* fmt clp

* aa

* fixing

* delete

* a

* append parent id when Objective

* add HasCorpus inprocss executor

* ecofuzz, delete was_fuzzed, update fuzz_level

* fix

* RemovableScheduler for Tunable, Queue, Weighted

* clp

* no std

* import

* on_execution

* fix

* win

* fmt

* fix

* revert to on_evaluation and propogate in the accounting scheduler

* fix

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-03-08 19:43:32 +01:00
Dominik Maier
2ed6583041
CI: Run miri tests (#1130)
* Fixes/ignores for miri support

* linux

* fix doctest for miri

* fix docs

* fix UB in baby_fuzzer

* no custom allocator in miri
2023-03-08 19:21:17 +01:00
Dominik Maier
e8838ebebe
Safer EoP handling (#1128) 2023-03-08 00:33:55 +01:00
Andrea Fioraldi
3ac439b345
Use regex feature in libafl_qemu (#1127) 2023-03-07 15:18:50 +01:00
Andrea Fioraldi
20c32316eb
Define custom collectors for QemuCallTracerHelper (#1099)
* Define custom collectors for QemuCallTracerHelper and create OnCrashBacktraceCollector

* fmt

* clippy
2023-03-07 13:16:51 +01:00
Andrea Fioraldi
3ffec79a17
Increase LLMP clients timeout to 5 min (#1126)
* LLMP client access fast path

* Increase LLMP client timeoit to 5min

---------

Co-authored-by: Your Name <you@example.com>
2023-03-07 11:47:45 +01:00
Marco Cavenati
b96e194812
Improve find_llvm on MacOS (#1124)
By looking for explicitly versioned Homebrew formulae for LLVM
2023-03-07 03:23:46 +01:00
Vincent
c8254dbd0e
Check CI result on cargo make test for available fuzzers (#1107)
* fix libfuzzer_libpng_cmin

* fix libfuzzer_libpng_ctx

* revert libfuzzer_libpng_cmin and check ci by grepping broker stdout result instead

* revert libfuzzer_libpng_ctx and check ci by grepping broker stdout result instead

* add check ci for fuzzers

* add check ci for fuzzers

* add check ci

* add fuzzbench test

* add validation for qemu fuzzer

---------

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-03-06 23:21:24 +09:00
Dongjia "toka" Zhang
9df95bd936
Use InMemoryCorpus in libfuzzer_libpng (#1125) 2023-03-05 23:23:42 +09:00
Elia Geretto
4f7b59aca4
Forward on_evaluation callback in MinimizerScheduler (#1122) 2023-03-05 22:00:32 +09:00
Langston Barrett
35e5b87188
Cargo feature to avoid regex dependency (#1102)
regex is a large crate, and is only used in a few specific spots. Users should
have the ability to avoid this transitive dependency if not using the features
in question.
2023-03-03 16:00:49 +01:00
Dongjia "toka" Zhang
5b4ae61cdd
SimpleLogger API improvements, printing to stdout, timestamps (#1109)
* log

* fix

* a

* rev

* remove

* 2 logger

* cfg std

* more

* more

* cf

* no_std

* features

* optional

* rename

* current_time()
2023-03-02 14:07:46 +01:00
van Hauser
2a3f1d68f5
fix weighting from hits (#1120) 2023-03-02 14:05:34 +01:00
Arpan Kapoor
672f4d1668
Use a different crash history in forkserver examples (#1118) 2023-03-02 19:49:50 +09:00
Dongjia "toka" Zhang
2a926f6546
Fix forkserver regression in LTO mode (#1114)
* regression

* fix

* chg

* Comment

* fmt
2023-03-02 10:17:20 +09:00
Andrea Fioraldi
452ca7a672
Implement EcoFuzz (#1115)
* Implement EcoFuzz

* clippy

* fix
2023-03-01 13:21:43 +01:00
Dominik Maier
df6271a0f3
Windows fix (#1116)
* Windows fix

* fix fix
2023-03-01 00:49:11 +01:00
Dominik Maier
31357aa7e2
Track parent testcase id, tuneable stage probabilistic settings (#1081)
* Added local event handlers

* clippy

* move tuned mutator to pow2

* Tunable updates

* parent ids

* no_std, etc

* windows

* remove local event manager handler

* maybe fix win

* win:

* win docs

* docs

* ASAN -> ASan
2023-02-28 16:36:04 +01:00
Dongjia "toka" Zhang
3e7322e395
Remove unnecessary check in calibration stage (#1111)
* save

* fix
2023-02-28 15:41:17 +01:00
Dominik Maier
fbe8cce1b8
Real OnDiskCorpus (#1096)
* Real OnDiskCorpus

* clippy

* python

* docs

* clippy

* docs

* move to reuse cachedinmem corpus

* fmt
2023-02-28 15:41:05 +01:00
Andrea Fioraldi
d36296c654
Fix llmp CliendId search (#1112) 2023-02-28 15:20:24 +01:00
Andrea Fioraldi
dc800f0814
on_evaluation Scheduler method (#1106)
* add on evaluation hook in schedulers

* on_evaluation for WeightedScheduler

* fix PowerQueueScheduler

* fix fuzzers

* upd qemu

* tests

* upd
2023-02-28 11:33:26 +01:00
Dongjia "toka" Zhang
59bf118a5a
Clippy (#1105) 2023-02-28 01:08:19 +09:00
Addison Crump
0727c80347
Add example for WASM (#1093)
* add baby_fuzzer for wasm targets

* elaborate in README

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-02-26 17:02:22 +01:00
Dongjia "toka" Zhang
c0f229ec23
Add UsesObserver to allow more generic MapFeedback (#1104)
* UsesObserver

* a

* more

* don't need these
2023-02-26 08:35:45 +01:00
clesmian
cf02553ea7
Cleanup forkserver exec builder (#1094)
* Don't use magic string but string constant

* Don't allow to specify multiple input files with different names

* Ensure that the file name for the current test case is unique for every fuzzer currently running

* Add note advising users to choose distinct names for the input file

* Move builder functions to more generic implementation to allow parse_afl_cmdline rewrite

* Rewrite parse_afl_cmdline to reduce code duplication

* Add remark to documentation regarding the program path

* Change behavior to allow the usage of actual AFL command lines, hopefully without breaking existing code

* Rustfmt

* Move generation of unique filename to fs

* Ensure default input filename for command executor is unique per fuzzing process

* Pass the input to the target via stdin, when no input file is specified

Previous solution of passing it via a standard file is useless, as the target does not know to read said file

* Rustfmt

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
2023-02-26 02:00:28 +01:00
Langston Barrett
3dbea91a63
Use Iterators as Generator (#1101)
Also, remove seemingly-unused generate_dummy method to enable this instance.

Also, add an adapter that creates an Iterator from a Generator.
2023-02-26 01:59:56 +01:00
Dongjia "toka" Zhang
95004aab7e
Update build_and_test.yml (#1103) 2023-02-25 15:12:59 +09:00
Dominik Maier
b3020d7296
Fix CoreId for Frida, FreeBSD (#1100) 2023-02-25 00:16:37 +01:00
Dominik Maier
672d25e5ac
LLMP Client timeouts, Exit broker when last client exits (#1057)
* Moving type definitions to transparent structs

* function to notify other side of exit

* docs

* Exmaple support windows now

* timeout fix

* Exiting after the last client quit

* inform about quits

* clippy

* clippy

* clean exits

* fix

* more unsafe

* fixes

* Move ClientId

* fix no_std

* Fix prometheus

* introduce Cores.trim()

* add always_track metadata

* docu

* add AlwaysUniqueMapFeedback

* rename to always_interesting

* return CoreId for Launcher

* CoreId as transparent tuple struct

* fix graceful exits for launcher

* Broker exits after launcher

* clippy

* Fix llmp eop race, introduce llmp shmem cache

* initialize cached page, clippy

* fix llmp_debug strings

* add error handling

* nicer error output

* More error handling convenience

* clippy

* fix macos example

* nits

* trying to add a logger

* no_std

* inline logger enabled

* fix windows, non-fork

* macos

* no_std docs

* clippy

* use ? instead of unwraps in example

* more logging

* docs
2023-02-24 11:50:42 +01:00
Dominik Maier
92842c8b04
Fix LLMP eop race, introduce LLMP ShMem cache (#1091)
* Fix llmp eop race, introduce llmp shmem cache

* initialize cached page, clippy

* fix llmp_debug strings

* add error handling

* nicer error output

* More error handling convenience

* clippy

* fix macos example

* nits

* trying to add a logger

* no_std

* inline logger enabled

* clippy
2023-02-24 10:28:21 +01:00
Mrmaxmeier
ff4e2f4192
Fix max input size for {CrossOverInsert,BytesInsertCopy}Mutator (#1097) 2023-02-24 00:07:54 +01:00
R. Elliott Childre
64a57ad3e3
Move bytecount to dev-dependencies (#1090)
It is only used in test code
2023-02-23 13:52:43 +01:00
Dongjia "toka" Zhang
9e88e5734e
Timeout executor cfg fix (#1088)
* fix

* fix

* fix from mac

* fix

* fix

* fix

* ?

* fix
2023-02-22 10:20:11 +09:00
Andrea Fioraldi
1b0cdab3e4
Use GuestAddr in QemuInstrumentationFilter (#1085)
* Use GuestAddr in QemuInstrumentationFilter

* fix types
2023-02-21 16:19:43 +01:00
Addison Crump
b7296db406
Fix exits which may cause double-free corruption (#1086) 2023-02-21 07:34:16 +09:00
Dongjia "toka" Zhang
20958a979f
Weak link token section (#1080)
* fix

* a
2023-02-17 10:38:46 +01:00
Addison Crump
bdac876dd4
Mutator sampling probability fixes (#1030)
* fixes for standard mutations

* more mutation updates for sampling probability, tests

* slight doc fix

* clippy gripe

* clippy fixes

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-02-16 17:29:57 +01:00
Michael Rodler
46b75747ef
Make sure input was loaded to avoid panic on unwrap in MutatedTransform (#1077)
* make sure input was loaded to avoid panic on unwrap
fixes issue #1059

* avoid unnecessary clone, avoid unnecessary branching

---------

Co-authored-by: Michael Rodler <m@mrodler.eu>
Co-authored-by: Addison Crump <addison.crump@cispa.de>
2023-02-16 17:29:33 +01:00
Addison Crump
f454d17482
CMin: don't add to map if it's the initial value (uninteresting) (#1078) 2023-02-16 17:28:49 +01:00
Dongjia "toka" Zhang
8bffd28b4c
fix (#1076) 2023-02-16 10:29:24 +09:00
Dongjia "toka" Zhang
e7ef6ae8b7
Forkserver: 1. Add mem barrier 2. Don't send the initial 4 bytes message when it uses dynamic map option only (#1073)
* fix

* Real fix

* a
2023-02-16 09:42:28 +09:00
Addison Crump
26aace6073
Fix grimoire when used with on_replace/on_remove (#1075) 2023-02-16 00:14:26 +01:00
Addison Crump
e42cd9c12f
Fixes for on_replace/on_remove and related for StdFuzzer and MapFeedback (#1067)
* scheduler replace fixes

* oops, no-std

* add

* changes on the fuzzers

* move map feedback history updates to append_metadata

* fixes for python bindings

* learn to clippy

* fix for fuzzer add_input

* clippy fixes for frida

* additional powersched differences

* corrections for bitmap_size

* off-by-one

* I live in a prison of my own creation and clippy is the warden

* clear the novelties map for the situation where is_interesting is invoked, but not append_metadata

---------

Co-authored-by: tokatoka <tokazerkje@outlook.com>
2023-02-15 17:04:18 +01:00
radl97
e61ac10656
Fix StdErrObserver not implementing needed traits (#1072) 2023-02-15 12:39:23 +01:00
Vincent
71d367af30
TimeObserver: Use Instant::now instead of Duration (#1064)
* Use Instant::now instead of duration

* Use Some

* add custom serde for Instant

* fix linter

* only enable TimeFeedback when std flag is enabled

* fix typo

* fix linter std

* cargo fmt

* allow clippy::trivially_copy_pass_by_ref on custom serde serialize function

* allow TimeObserver and Timefeedback for no_std

* cargo fmt

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-02-15 12:38:25 +01:00
David CARLIER
fb0d3b07ea
MiniBSoD: solaris on amd64 implementations (#1068) 2023-02-15 12:27:45 +01:00
Andrea Fioraldi
cf0a0a0698
Add stub lib for fuzzbench (#1074) 2023-02-15 12:05:10 +01:00
Elsa Granger
44b69666da
Fix fuzzbench build (#1004)
* Fix -z,defs handle

* Add libfuzzer_no_link_main option in libfuzzer

* Use libfuzzer_no_link_main for fuzzbench

* no_link_main feature

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-02-15 11:58:32 +01:00
Andrea Fioraldi
f8a4a020e8
QEMU: do not crash in helpers pre and post execs (#1065)
* QEMU: do not crash in helpers pre and post execs

* comma
2023-02-14 13:35:20 +01:00
Fabian Freyer
53dba5f49d
Use the log facade instead of println (#1060)
* switched a couple of println / dbg statements to use log crate
* Use pyo3-log for logging in python bindings
2023-02-14 10:01:51 +01:00
Dongjia "toka" Zhang
30b51bb810
Remove unused dependencies (#1069) 2023-02-14 09:02:18 +01:00
Dongjia "toka" Zhang
bd2de16b4e
Colorization stage (#1039)
* type_replace

* separate

* more

* heap

* comment

* f

* fix

* clp

* need rev

* comment

* ColorizationTracingStage

* get_raw_map_hash_run

* process_execution

* metadat

* unused TE

* resolve type errors

* remove colorizationtracingstage

* Finally compiles

* clp

* fmt

* a few debug println

* revert

* fix
2023-02-13 15:02:19 +09:00
Dongjia "toka" Zhang
a74e5da268
Revert FridaInstrumentationHelper changes (#1062)
* Revert "Send stability in calibration stage & FridaInstrumentationHelper retunrs Result<Self, Error> (#1056)"

This reverts commit 4d78878c02846b2c0a49686cd05cccadd2b0ac72.

* fux

* poc

* revert
2023-02-13 10:02:26 +09:00
Dongjia "toka" Zhang
4d78878c02
Send stability in calibration stage & FridaInstrumentationHelper retunrs Result<Self, Error> (#1056)
* fix

* fix

* clippy
2023-02-13 05:35:09 +09:00
Dongjia "toka" Zhang
b7a0b823c6
Fix frida_gdiplus (#1045)
* fix

* I don't like prelude

* clp

* cargo make test

* poc

* one to_vec()

* fix?

* del

* fix
2023-02-08 00:20:38 +09:00
Andrea Fioraldi
0173d722c6
Fix typo in directory visiting (#1050) 2023-02-07 10:47:36 +01:00
Dongjia "toka" Zhang
30e296968b
Rename LLMP Timeout message, increase timeout (#1048)
* rename

* Update llmp.rs

* Print every 30 seconds only

---------

Co-authored-by: Dominik Maier <dmnk@google.com>
2023-02-06 16:42:14 +01:00
Langston Barrett
4e15be182e
Increase default initial capacity of NewHashFeedback (#1049) 2023-02-06 15:50:26 +01:00
R. Elliott Childre
4d5a759955
Update deps for libafl (#1042)
Reduces total number of packages from 577 to 571 on building with:
`cargo +nightly build --workspace --all-features`

* ahash 0.7 -> 0.8
  * Move `AHasher::new_with_keys` to `RandomState::with_seeds` given the
    recommendation from: aHash maintainer:
    https://github.com/tkaitchuck/aHash/issues/132#issuecomment-1288207069

* bindgen: 0.61 -> 0.63

* c2rust-bitfields: 0.3 -> 0.17

* criterion: 0.3 -> 0.4

* crossterm: 0.25 -> 0.26

* dynasmrt: 1.2 -> 2

* goblin: 0.5.3 -> 0.6

* hashbrown: 0.12 -> 0.13

* nix: 0.25 -> 0.26
  * The `addr` arg of `mmap` is now of type `Option<NonZeroUsize>`
  * The `length` arg of `mmap` is now of type `NonZeroUsize`
  * Requires updating implementers to update `nix` as well

* prometheus-client: 0.18.0 -> 0.19
  * Do not box metrics
  * Gauges (a majority of the LibAFL metrics) are now i64 types so there
    is a small chance of overflow, with the u64 values that LibAFL
    tracks, but unlikely to be problematic.
 * Keep `exec_rate` as a floating point value

* serial_test: 0.8 -> 1

* typed-builder: 0.10.0 -> 0.12

* windows: 0.42.0 -> 0.44

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-02-06 12:24:42 +01:00
Langston Barrett
e75f65080e
libafl: with_capacity method for NewHashFeedback (#1034)
Most of the time, fuzzing campaigns are reasonably long. Accordingly, when
using `NewHashFeedback`, you might have good reason to believe that you'll
find thousands (or more) different observations with different hashes. When
the `HashSet` outgrows its capacity, it can cause reallocation, which is slow.
See the following link for more details:

https://doc.rust-lang.org/std/vec/struct.Vec.html#capacity-and-reallocation
2023-02-06 01:44:57 +01:00
R. Elliott Childre
5d76707ede
Bump deps and fix Clippy warns in example fuzzers (#1043)
* Mostly addressing changing the `uninlined_format_args` lint which was
  changed to warn-by-default in rust clippy 1.67

* Bump dependencies:
  bindgen:  0.61 -> 0.63
  cc:       1.0 -> 1.0.42 (Exclue versions w/incompat rayon dependency)
  clap:     3.x -> 4.0
  rangemap: 0.1 -> 1
  xz -> xz2:  move to updated version

* Add fallthrough default return to `LLVMFuzzerTestOneInput` in
  **/fuzz.c to prevent Clang's -Wreturn-type

* libafl_atheris: Improve POSIX compatibility and reduce warnings
  * Check for .dylib and .so libraries
  * `source` -> `.` for POSIX shells
  * install wheel into the venv to support newer Python packaging
    standards
  * `LDPRELOAD` -> `LD_PRELOAD`
2023-02-05 21:53:45 +01:00
Dominik Maier
48caffb802
Allow to load a list of files (#1044) 2023-02-05 21:22:58 +01:00
Andrea Fioraldi
eaf5ff9de0
Restart loading initial inputs even after a crash/timeout (#1040)
* Track initial inputs loading

* libfuzzer libpng

* fuzzbench

* fix no_std

* fix no_std

* clippy

* fuzzers
2023-02-03 11:56:47 +01:00
Dominik Maier
86ab682e5a
Readme: Add information about system mode QEMU (#1038) 2023-02-02 15:20:45 +01:00
Dongjia "toka" Zhang
db62c26eda
Remove unused imports (#1035)
* remove unused imports

* fmt
2023-02-01 12:26:56 +01:00
WorksButNotTested
71f106be20
Fix accidental breakage of non-AARCH64 systems (#1036)
Co-authored-by: Your Name <you@example.com>
2023-02-01 17:46:12 +09:00
WorksButNotTested
d0b4c39acd
Change to combine restoration prologue with coverage register spill (#1029)
Co-authored-by: Your Name <you@example.com>
2023-02-01 04:41:56 +01:00
Andrea Fioraldi
2a88a776bf
Fix frida Cargo.toml (#1033) 2023-01-31 14:05:07 +01:00
Andrea Fioraldi
b77c0b78cc
Fix readme position in qemu sys (#1032) 2023-01-31 13:40:28 +01:00
Dongjia "toka" Zhang
f9dd67b59b
Comment Fix 2023-01-31 19:40:58 +09:00
Dominik Maier
cc53da85fb
Remove {update,clear}_hash from ObserverWithHashField, add hasher (extending #1019) (#1028)
* libafl: Remove `{update,clear}_hash` from `ObserverWithHashField`

These methods aren't used by `NewHashFeedback`, so there's no compelling reason
to keep them in the interface. They preclude implementations of
`ObserverWithHashField` that calculcate a hash on-the-fly from a value. For
example, my use-case is to store the stdout of a process, and use
`NewHashFeedback` to only collect inputs that result in new messages on stdout.

Both of these methods are pretty suspicious to begin with - why should other
code be able to update the internal state of the observer? What are the
semantics of `update_hash`? If there are compelling reasons to keep these
methods, let's clarify their intent in the documentation.

* libafl: Return hash by value from `ObserverWithHashField`

This allows implementors of this trait to not store the hash, but rather to
compute it on-the-fly. Since `Option<u64>` is `Copy` (and quite small), and
this method is called once per execution of the target program, this is likely
to have negligible performance impact.

* libafl: Implement `ObserverWithHashField` for `ValueObserver`

This demonstrates the utility of the previous two commits. Now, `ValueObserver`
can be used with `NewHashFeedback`.

* Clippy, move to ahasher

* Oops :)

---------

Co-authored-by: Langston Barrett <langston.barrett@gmail.com>
2023-01-31 10:45:42 +01:00
Andrea Fioraldi
fdf579bcd5
Bump to 0.9.0 (#946)
* bump to 0.9.0

* fix libafl_tinyinst

* fix

---------

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2023-01-31 10:42:01 +01:00
Dominik Maier
d73fb92ddf
Python CI (#1024)
* Python CI

* fix testcase

* fix yml

* Fixing test

* format python

* cleanup
2023-01-31 05:04:19 +01:00
Dominik Maier
fc8c92514f
Update README.md (#1027) 2023-01-31 04:43:27 +01:00
Dominik Maier
7c4acb3b22
Update README.md (#1026) 2023-01-31 04:34:01 +01:00
Dominik Maier
2cd3fb8fea
New Logo (#1025) 2023-01-31 04:32:47 +01:00
Dominik Maier
ff9208f107
Fixing python example (#1016)
* Fixing python example

* Fix python baby fuzzer

---------

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-01-30 20:03:07 +01:00
Fabian Freyer
afa506c0c8
libafl_frida: Allow compilation for iOS (#1023)
iOS does not have any TLS, so we don't need to keep track of it.
This allows compiling for the aarch64-apple-ios target.
2023-01-30 18:05:00 +01:00
Dominik Maier
33ddce2cea
Introduce MutatorId, Tuneable fixes (#1022)
* Add simpler APIs for TunableStage

* Make API usable

* Add TunableScheduledMutator APIs

* Introduce MutatorId

* More API

* Cleanup

* add sampling-based mutation scheduling

* reduce precision for sampling

* clippy
2023-01-30 18:04:42 +01:00
Dongjia "toka" Zhang
b927fc9b06
Add filename_path to MmapShMemProvider (#1014)
* change how it is named

* Add more comments

* more

* macOS 32bytes onlyu

* chg

* comment, fix
2023-01-26 00:53:37 +01:00
Dominik Maier
e5c220519e
LLMP Broker: timeouts for inactive clients (#1005)
* LLMP Timeouts

* Make broker timeouts optional

* fix warning

* fix warning
2023-01-25 12:03:23 +01:00
Andrea Fioraldi
92c0c5eeab
Fix second Forkserver Broken Pipe (#1013)
* Truncate at MAX_FILE

* AFL_MAP_SIZE

* todo
2023-01-24 20:50:56 +01:00
Addison Crump
00ec7e143c
fix for MapIndexesMetadata (#1008)
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-01-23 15:08:33 +01:00
Dongjia "toka" Zhang
fe51286586
TinyInst Update (#968)
* tmp

* more

* save

* TODO

* fix

* update to tinyinst on crates

* dep

* fmt

* shmem done

* cpp fmt

* clp

* fmt

* why??

* ver

* more makefile.toml

* windows test

* Update build_and_test.yml

* fix

* a

* install

* fmt

* fix

* only macos and win

* more

* The order matters

* remove

* fmt

* chg

* typo

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-01-23 11:11:53 +01:00
David CARLIER
3b68399cc9
libafl_cc fixes for clang 16 (#1010)
None constant being deprecated, it is recommended
to use the std::nullopt_t type instead.
2023-01-23 11:00:42 +01:00
Andrea Fioraldi
7fd9ac0952
SyncFromBrokerStage to sync from a broker with a different Input type (#997)
* ConverterLlmpEventManager

* docs

* SyncFromBrokerStage

* fix

* separate InputConverter

* nautilus

* nautilus_sync

* send testcases

* upd nautilus

* meta

* fix

* clippy

* fix

* Update build_and_test.yml

* fix

* fix

* Use find_libpython

* ci

* upd qemu
2023-01-20 17:16:29 +01:00
WorksButNotTested
5cdb7f7b05
Improve AARCH64 performance (#989) 2023-01-18 13:56:17 +01:00
Addison Crump
ebc886032f
Fixes for multiple subtle bugs with grimoire, mutators, and state (#1001)
* fix multiple subtle bugs with grimoire, mutators, and state

* obey the clippy overlord

* grimoire: skip over token after splice

* remove extraneous length check
2023-01-18 13:53:31 +01:00
Paul Walker
333a51aeaa
StacktraceObserver speedup using unresolved backtrace (#1002)
We don't use the symbols anyway, and it makes the call *way* faster.
2023-01-18 13:51:42 +01:00
Andrea Fioraldi
3c8a00bc42
Fix qemu user (#1003) 2023-01-18 13:38:49 +01:00
Dongjia "toka" Zhang
1446692f02
Fix stability UI (#1000)
* Update mod.rs

* fmt
2023-01-18 19:00:50 +09:00
van Hauser
15c1c0fb5e
Avoid no-op in ByteRandMutator (#999) 2023-01-17 11:07:50 +01:00
Andrea Fioraldi
7cf7d545a6
Update QEMU and fix snapshot restore mem leak (#998)
* Update qemu

* Fix leak

* upd

* fmt
2023-01-17 11:06:31 +01:00
Dominik Maier
97e88af0c5
OnDiskCorpus: Write metadata by default, metadata gzip compression (#995)
* Write metadata by default

* fix fuzzers

* Cleanup, gzip feature

* Fix casing for ondisk corpus

* fix fmt, clippy

* clippy

* clippy for gdiplus fuzzer

* fmt
2023-01-13 01:07:36 +01:00
Addison Crump
28786c943a
Grimoire fixes (#993)
* fixup grimoire/generalisation, remove GeneralizedInput in favour of metadata

* additional cleanup

* transformable inputs to solve the grimoire problem

* explicit use of 'transforming' to keep typing compatible with normal usage

* clippy fix

* fixes for nautilus, python

* explicit inlining for reflexive impl

* fix for tutorial

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-01-13 01:07:21 +01:00
Andrea Fioraldi
ec84c71eae
Corpus maps (#947)
* hashmap corpus for inmemory

* corpus_btreemap feature

* CorpusId

* queue

* MinimizerScheduler::remove

* fixes

* continue

* keys

* working corpus

* ok

* weighted left

* wip

* port weighted scheduler

* it compiles

* doc

* fix mutators

* fix queue

* fix iter

* tests

* fix

* fix

* fix

* py

* clippy

* clippy

* clippy

* cmin

* fix

* fix

* fix

* clippy

* remove Corpus::random_id
2023-01-09 14:15:07 +01:00
biazo
3345727c94
fixing linking issue on qemu build (#990)
* fixing linking issue

* insteading of linking lib we dont use. just disable them

* fixing the keyutils problem

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2023-01-09 10:10:14 +01:00
Dominik Maier
17cb317429
Fix early drop for frida transformer (#992)
* Fix early drop for frida transformer

* clippy
2023-01-08 18:19:30 +01:00
Dominik Maier
159e6ea480
Fix Launcher for M1, fix frida_libpng harness compilation, fix CI (#987)
* Fix harness compilation for frida_libpng

* M1: Always use fast cores

* always ignore result

* seeing if manualy installing libunistring fixes wget

* seeing if manualy installing wget fixes it, instead

* un-remove comment
2023-01-05 14:26:20 +01:00
WorksButNotTested
266677bb88
FRIDA: Fix previous_pc constant (#988)
Co-authored-by: Your Name <you@example.com>
2023-01-05 12:20:06 +01:00
WorksButNotTested
f27ca843e1
FRIDA x64 performance improvements (#985)
Co-authored-by: Your Name <you@example.com>
2023-01-05 11:51:58 +01:00
Dominik Maier
1bb37e4b98
Book: Explain SymCC constraint solving (follow up on #980) (#986)
* Make the kind of solving more clear (follow up on #980)

* Update docs/src/advanced_features/concolic.md

Co-authored-by: julihoh <julihoh@users.noreply.github.com>

Co-authored-by: julihoh <julihoh@users.noreply.github.com>
2023-01-05 11:51:31 +01:00
hexcoder
7d412693c8
Book review (#980)
* docs review

* docs review

* docs review wording

* docs review wording

* docs review wording

* wording

* nits

* wording

* wording

* nits

* docs_review wording

* wording

* wording

* wording

* Wording

* wording

* nits

* Wording

* fix main naming for afl++

* update symcc

Co-authored-by: Dominik Maier <dmnk@google.com>
2023-01-04 15:21:08 +01:00
Dongjia "toka" Zhang
d2985c5b2e
Clippy fix (#978)
* fix

* mac

* clp
2023-01-02 20:35:41 +09:00
Sparrrgh
43425cf103
Correct MIPS register naming in libafl_qemu (#977) 2022-12-31 09:23:50 +01:00
Dongjia "toka" Zhang
9458549fef
Remove declare -A (#976)
* fix

* fix

* debug

* debug

* older version

* newer version

* fix

* unix?

* fix
2022-12-30 02:02:38 +09:00
Erwan Grelet
3e38862837
Forkserver example with forkserver.c (#726) (#973)
* forkserver: Add an API to setup the shared memory region for edge coverage

This is inspired from and meant to be similar to afl-cc's instrumentation.
Remove ! return type from __afl_start_forkserver as it returns in several cases.

* Add example fuzzer using LibAFL's forkserver

The fuzzer is instrumented with libafl_cc as well.

Co-authored-by: ergrelet <ergrelet@users.noreply.github.com>
2022-12-28 22:16:27 +01:00
Dongjia "toka" Zhang
676a149497
Update CorpusWeightTestcaseScore (#975)
* fix

* clp

* fmt
2022-12-28 22:16:08 +01:00
Patrick Gersch
2b092f40fa
SimpleMonitor optionally displays user_monitor stats (#970)
* Adding with_user_monitor() to SimpleMonitor

* Satisfy clippy

* Satisfy fmt and pylibafl

* Fix leading whitespace
2022-12-26 11:20:30 +01:00
Dongjia "toka" Zhang
476cb7e7dc
Frida Makefile.toml fix (#969)
* frida build script fix

* fix

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml

* Update build_and_test.yml
2022-12-26 14:19:37 +09:00
Dominik Maier
75f12bd0eb
Remodelling Observers/Examples that rely on UB, API cleanups (#950)
* Tackling UB

* PtrMut -> MutPtr, moved mapobservers to non-UB

* QEMU fixes

* test fixes

* qemu

* Change all interfaces, fix all fuzzers

* fixes

* fix more fixes

* fmt

* fix qemu sugar

* fix some qemus

* atheris

* fmt

* more fmt

* most fmt

* more fix

* nyx fyx

* fix qemu

* clippy, fixes

* more fixes

* no unfix, only fix

* fix

* fix

* more clippy

* fixes

* ListObserver

* fmt, clippy

* fix qemu on arm

* update zlib target

* fix?

* fix

* added migration guide

* ignore doc

* fix symcc

* fix new win fuzzer

* Fixes, rename PTR_SIZE to PTR_NUM

* Try fix linking on win

* Trying to fix win linking

* more cov

* trying to fix win some more

* trying to fix mac

* trying to fix mac

* Fix tests

* Fix tests

* trying to fix win

* more mac

* giving up for windows

* fmt

* python3

* mac?

* undo windows tests
2022-12-24 14:20:44 +01:00
Dominik Maier
3a1e499d9d
Documentation fixes (#967)
* a few stylistic/grammar changes

* expression

* some wording and a different git clone command

The original `git clone` command did not work for me (permission denied).

* small wording changes

* review

* typo

* neutral

Co-authored-by: hexcoder <hexcoder-@users.noreply.github.com>
2022-12-21 12:44:42 +01:00
humpty99
de6ee8b161
Fix Nyx build script (#965)
due to the call to pushd on line 23 not being directed at packer, the wrong commit was being used and so that resulted in the wrong init.cpio.gz being generated which hangs when trying to run the libxml2 examples however using the right commit (86b159bafc0b2ba8feeaa8761a45b6201d34084f) fixes this problem.
2022-12-21 20:29:42 +09:00
Dongjia "toka" Zhang
d77d9d5f31
Frida: Make stalker.exclude() configurable from command line arguments (#956)
* remove exclude on windows

* linux x86_64

* option
2022-12-21 11:23:57 +01:00
Max Ammann
4d8b566a87
[Windows] Add libfuzzer example for windows with ASAN (#934)
* Add libfuzzer example for window with ASAN

* Fix formatting

* Add link

* Fix cpp format

* Skip windows fuzzers

* Fix format

* Fix testing fuzzer

* Fix taks name

Co-authored-by: Dongjia "toka" Zhang <tokazerkje@outlook.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2022-12-21 10:41:58 +01:00
Dongjia "toka" Zhang
3c7dcac41d
Deduplicate crash handlers (#951)
* unix

* win

* std

* fmt

* more

* more

* win

* rename

* win

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2022-12-21 10:41:18 +01:00
Dongjia "toka" Zhang
038732bd92
no mold (#964) 2022-12-21 13:27:14 +09:00
Dongjia "toka" Zhang
f1b25fed65
Fix CI (#955)
* fix

* fmt

* Update build_and_test.yml

* no nightly

* fix

* why

* Update build_and_test.yml

* a

* a

* ok

* linux only

* fmt

* Update build_and_test.yml

* fix
2022-12-21 11:12:54 +09:00
hexcoder
b0df0a26a1
Docs: grammar fix (#961) 2022-12-21 00:19:38 +01:00
Dominik Maier
7ed1ac9c9b
Additional SymCC Build Fixes (#954) 2022-12-20 00:37:19 +01:00
Dominik Maier
e56d5318e4
Fix SymCC build (#952) 2022-12-19 13:48:07 +01:00
Dominik Maier
ccf6cc708a
Windows clippy fixes (#948) 2022-12-18 12:35:30 +01:00
radl97
016a4c3778
Human readable execs & run/exec rounding fix (#936)
* Calculate run/exec statistics as float to solve rounding issues

* Fixup

* Clippy fixes

* Clippy fixes

* Change execs_per_sec() to return float per suggestions

* Monitors: Write 2 decimal floating-point for execs/sec

* Prettify exec/sec

* Formatting & fix copy pasta

* Pretty-print floats in monitor: use mega and kilo SI suffices

* prettify -> prettify_float, apply suggestion

* Clippy

* Fix prometheus client cannot handle float values yet

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2022-12-16 23:46:33 +01:00
Sparrrgh
d04346c870
Add mips support for QemuTracerHelper (#941)
* Add mips support for QemuTracerHelper

* Formatting

Ran cargo +nightly fmt

* Removed unnecessary `any`

* Removed cfg guarding calls module

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2022-12-14 17:45:54 +01:00
omergreen
664e87809e
libafl-frida: disable LibAFL's default features in Cargo.toml (#939)
* disable libafl's default features in libafl-frida

to allow users to disable default features while using stuff from libafl-frida

* Update Cargo.toml

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2022-12-14 01:59:17 +01:00
Andrea Fioraldi
55e220f0e8
CI: diff with main and HEAD^ (#945) 2022-12-14 01:10:36 +01:00
Andrea Fioraldi
162de0ceaf
Fix CI diffing (#944)
* fix build_and_test_fuzzers to diff from origin/main

* fix fuzzbench_forkserver
2022-12-13 21:19:44 +01:00
Ao Li
9e4a0513c6
Gramatron: Fix a typo in gnf_converter.py (#942)
This patch addresses the issue in #879, which fixes a typo in the `remove_left_recursion` method.
2022-12-13 17:27:16 +01:00
Andrea Fioraldi
08be5f732e
CI: Only test fuzzers with diffing deps (#940)
* build and test fuzzer crate

* diffing fuzzers ci only

* clippy

* clippy merda

* clippy merde

* improve it

* comment

* split ubuntu CI workflow

* fix
2022-12-13 14:10:34 +01:00
1741 changed files with 286539 additions and 65008 deletions

View File

@ -1,27 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/docker-existing-dockerfile
{
"name": "LibAFL Dockerfile",
"name": "Build LibAFL Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
"context": "../..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"matklad.rust-analyzer"
],
"dockerFile": "../../Dockerfile",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rust-lang.rust-analyzer",
"microsoft.Docker"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"rust-analyzer.cargo.noDefaultFeatures": true
}
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",
// Install development components that shouldn't be in the main Dockerfile
"postCreateCommand": "rustup component add rustfmt clippy llvm-tools-preview",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
]
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.

View File

@ -0,0 +1,34 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/docker-existing-dockerfile
{
"name": "Download LibAFL Dockerfile",
"image": "ghcr.io/aflplusplus/libafl:latest",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rust-lang.rust-analyzer",
"microsoft.Docker"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"rust-analyzer.cargo.noDefaultFeatures": true
}
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created - for example installing curl.
// Install development components that shouldn't be in the main Dockerfile
"postCreateCommand": "rustup component add rustfmt clippy llvm-tools-preview",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
]
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}

View File

@ -1,4 +1,5 @@
target
**/target
**/.git
Cargo.lock
*.o

14
.github/.linkspector.yml vendored Normal file
View File

@ -0,0 +1,14 @@
dirs:
- .
useGitIgnore: true
ignorePatterns:
- pattern: "^https://crates.io"
- pattern: "^https://github.com/AFLplusplus/linux-qemu-image-builder"
- pattern: "https://www.romu-random.org/"
aliveStatusCodes:
- 0
- 200
- 403

View File

@ -13,6 +13,8 @@ Thank you for making LibAFL better!
**Describe the bug**
A clear and concise description of what the bug is.
If you want to present the backtrace, don't forget to run with `errors_backtrace` feature and log from `RUST_LOG`
In addition, please tell us what is your fuzzer's Cargo.toml
**To Reproduce**
Steps to reproduce the behavior:

7
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,7 @@
## Description
*describe your PR here*
## Checklist
- [ ] I have run `./scripts/precommit.sh` and addressed all comments

8
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "pyo3"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
name: Setup Rust Environment
description: Sets up the Rust environment for the CI workflow
inputs:
fuzzer-name:
description: 'The fuzzer name to run'
required: true
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: ./.github/workflows/ubuntu-prepare
- name: enable mult-thread for `make`
shell: bash
run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)"
- name: Add nightly toolchain
if: ${{ inputs.fuzzer-name == 'inprocess/fuzzbench_ctx' || inputs.fuzzer-name == 'fuzz_anything/baby_no_std' || inputs.fuzzer-name == 'baby/tutorial'}}
shell: bash
run: rustup toolchain install nightly-x86_64-unknown-linux-gnu; rustup component add clippy rustfmt --toolchain nightly-x86_64-unknown-linux-gnu; rustup default nightly
- name: Add no_std toolchain
if: ${{ inputs.fuzzer-name == 'fuzz_anything/baby_no_std' }}
shell: bash
run: rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- name: Add nyx deps
if: ${{ inputs.fuzzer-name == 'full_system/nyx_launcher' || inputs.fuzzer-name == 'full_system/nyx_libxml2_standalone' || inputs.fuzzer-name == 'full_system/nyx_libxml2_parallel' }}
shell: bash
run: sudo apt update && sudo apt install -y libgtk-3-dev pax-utils python3-msgpack python3-jinja2 libcapstone-dev
- name: install just
uses: extractions/setup-just@v2
with:
just-version: '1.40.0'
- name: Add wasm target
if: ${{ inputs.fuzzer-name == 'fuzz_anything/baby_fuzzer_wasm' }}
shell: bash
run: rustup target add wasm32-unknown-unknown
- name: install wasm-pack
if: ${{ inputs.fuzzer-name == 'fuzz_anything/baby_fuzzer_wasm' }}
uses: baptiste0928/cargo-install@v3
with:
crate: wasm-pack
- name: install chrome
if: ${{ inputs.fuzzer-name == 'fuzz_anything/baby_fuzzer_wasm' }}
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable

View File

@ -0,0 +1,73 @@
name: Setup QEMU librasan environment
description: Sets up the QEMU librasan environment
runs:
using: composite
steps:
- name: Enable i386
shell: bash
run: sudo dpkg --add-architecture i386
- name: Install QEMU deps
shell: bash
run: |
sudo apt-get update && \
DEBIAN_FRONTEND=noninteractive \
sudo apt-get install -y \
build-essential \
clang-18 \
clang++-18 \
cmake \
curl \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabi \
g++-i686-linux-gnu \
g++-mipsel-linux-gnu \
g++-powerpc-linux-gnu \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
gcc-i686-linux-gnu \
gcc-mipsel-linux-gnu \
gcc-powerpc-linux-gnu \
gdb \
gdb-multiarch \
git \
gnupg \
libc6-dev:i386 \
libclang-dev \
libgcc-13-dev:i386 \
libglib2.0-dev \
lsb-release \
ninja-build \
python3 \
python3-pip \
python3-venv \
qemu-user \
software-properties-common \
wget
- uses: dtolnay/rust-toolchain@stable
- name: install just
uses: extractions/setup-just@v2
with:
just-version: '1.40.0'
- name: Install cargo-binstall
shell: bash
run: |
curl -L --proto '=https' --tlsv1.2 -sSf \
https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | \
bash
- name: Install nextest
shell: bash
run: |
cargo binstall --no-confirm cargo-nextest
- name: Install Rust Targets
shell: bash
run: |
rustup target add armv7-unknown-linux-gnueabi && \
rustup target add aarch64-unknown-linux-gnu && \
rustup target add i686-unknown-linux-gnu && \
rustup target add powerpc-unknown-linux-gnu
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: Swatinem/rust-cache@v2
with: { shared-key: "${{ runner.os }}-shared-fuzzer-cache" }

View File

@ -0,0 +1,32 @@
name: Setup QEMU Fuzzers environment
description: Sets up the QEMU fuzzers environment
runs:
using: composite
steps:
- name: Install QEMU deps
shell: bash
run: |
apt-get update
apt-get install -y qemu-utils sudo python3-msgpack python3-jinja2 curl python3-dev gcc-arm-none-eabi \
gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
- name: Remove old rust
shell: bash
run: sudo apt purge -y 'rust*' 'cargo*'
- uses: dtolnay/rust-toolchain@stable
env:
RUSTUP_HOME: /usr/local/rustup
CARGO_HOME: /usr/local/cargo
- name: enable mult-thread for `make`
shell: bash
run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)"
- name: install just
uses: extractions/setup-just@v2
with:
just-version: '1.40.0'
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: ./.github/workflows/ubuntu-prepare
- uses: Swatinem/rust-cache@v2
with: { shared-key: "${{ runner.os }}-shared-fuzzer-cache" }

View File

@ -0,0 +1,59 @@
name: Setup Rust Environment
description: Sets up the Rust environment for the CI workflow and optionally installs nightly
# ---------- new section ----------
inputs:
use_nightly:
description: "If true, install the Rust nightly toolchain instead of stable"
required: false
default: "false"
# ---------------------------------
runs:
using: composite
steps:
- name: Uninstall all currently installed Rust
shell: bash
run: |
sudo apt purge -y 'cargo*' 'rust*'
- name: Install and cache deps
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
curl lsb-release wget software-properties-common gnupg shellcheck pax-utils \
libsqlite3-dev libpixman-1-dev libc6-dev gcc g++ build-essential libglib2.0-dev
# ---------- toolchain selection ----------
- name: Install Rust (stable)
if: ${{ inputs.use_nightly == 'false' }}
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install Rust (nightly)
if: ${{ inputs.use_nightly == 'true' }}
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
# -----------------------------------------
- name: Install just
uses: extractions/setup-just@v2
with:
just-version: '1.40.0'
- uses: taiki-e/install-action@cargo-hack
- name: Install LLVM
shell: bash
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.MAIN_LLVM_VERSION }} all
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.MAIN_LLVM_VERSION }} 200
- name: Symlink headers
shell: bash
run: sudo ln -s /usr/include/asm-generic /usr/include/asm

View File

@ -0,0 +1,21 @@
name: Setup Rust Environment
description: Sets up the Rust environment for the CI workflow
runs:
using: composite
steps:
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools, clippy, rustfmt
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Build docs
shell: pwsh
run: cargo doc
- uses: ilammy/msvc-dev-cmd@v1
- name: Set LIBCLANG_PATH
shell: pwsh
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
- name: install just
uses: extractions/setup-just@v2
with:
just-version: '1.40.0'

53
.gitignore vendored
View File

@ -1,12 +1,19 @@
target
target-bin
out
Cargo.lock
vendor
# cargo lockfiles except from binaries
Cargo.lock
./**/Cargo.lock
# Un-ignore Cargo.lock files within the fuzzers directory
!./fuzzers/**/Cargo.lock
.DS_Store
.env
.vscode
*.test
*.tmp
*.swp
*.o
@ -17,27 +24,31 @@ vendor
*.bin
*.dll
*.exe
*.dylib
*.dSYM
*.obj
.cur_input
.cur_input_*
cur_input
.venv
crashes
corpus
callgrind.out.*
perf.data
perf.data.old
.vscode
.vscode/settings.json
test.dict
.idea/
# Ignore all built fuzzers
fuzzer_*
AFLplusplus
test_*
*_fuzzer
*_harness
# Ignore common dummy and logfiles
*.log
@ -46,6 +57,7 @@ a
forkserver_test
__pycache__
*.lafl_lock
*.metadata
*atomic_file_testfile*
**/libxml2
@ -53,4 +65,35 @@ __pycache__
**/libxml2-*.tar.gz
libafl_nyx/QEMU-Nyx
libafl_nyx/packer
libafl_nyx/packer
.z3-trace
# No gdb history
.gdb_history
# No llvm IR
*.ll
*.tar.gz
# common harness names
harness
program
fuzzer_libpng*
*.patch
# Sometimes this happens
rustc-ice-*
# perf files
*.mm_profdata
# backup files
*.bak
# log
log
# Coredumps
*.core

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "libafl_concolic/symcc_runtime/symcc"]
path = libafl_concolic/symcc_runtime/symcc
url = https://github.com/AFLplusplus/symcc.git

13
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,13 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: fmt
name: fmt
entry: scripts/fmt_all.sh check
language: script
- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format

19
.vscode/settings.json.default vendored Normal file
View File

@ -0,0 +1,19 @@
{
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
},
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
],
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"check",
"--message-format=json",
],
"rust-analyzer.check.overrideCommand": [
"cargo",
"check",
"--message-format=json",
]
}

163
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,163 @@
# How to Contribute to LibAFL
For bugs, feel free to open issues or contact us directly. Thank you for your support. <3
## Pull Request Guideline
Even though we will gladly assist you in finishing up your PR, try to:
- keep all the crates compiling with *stable* rust (hide the eventual non-stable code under [`cfg`s](https://github.com/AFLplusplus/LibAFL/blob/main/libafl/build.rs#L26))
- run `cargo +nightly fmt` on your code before pushing
- check the output of `cargo clippy --all` or `./scripts/clippy.sh` (On windows use `.\scripts\clippy.ps1`)
- run `cargo build --no-default-features` to check for `no_std` compatibility (and possibly add `#[cfg(feature = "std")]`) to hide parts of your code.
- Please add and describe your changes to MIGRATION.md if you change the APIs.
You can also run ./scripts/precommit.sh to execute checks that will be performed on a PR.
Some of the parts in this list may be hard, don't be afraid to open a PR if you cannot fix them by yourself, so we can help.
### Pre-commit Hooks
Some of these checks can be performed automatically during commit using [pre-commit](https://pre-commit.com/).
Once the package is installed, simply run `pre-commit install` to enable the hooks, the checks will run automatically before the commit becomes effective.
## LibAFL Code Rules
Before making your pull requests, try to see if your code follows these rules.
- Wherever possible, use `Cow<'static, str>` instead of String.
- `PhantomData` should have the smallest set of types needed. Try not adding `PhantomData` to your struct unless it is really necessary. Also even when you really need `PhantomData`, try to keep the types `T` used in `PhantomData` as smallest as possible
- Wherever possible, trait implementations with lifetime specifiers should use '_ lifetime elision.
- Complex constructors should be replaced with `typed_builder`, or write code in the builder pattern for yourself.
## Rules for Generics and Associated Types
1. Remove generic restrictions at the definitions (e.g., we do not need to specify that types impl `Serialize`, `Deserialize`, or `Debug` anymore at the struct definitions). Therefore, try avoiding code like this unless the constraint is really necessary.
```rust
pub struct X<A>
where
A: P // <- Do not add contraints here
{
fn ...
}
```
2. Reduce generics to the least restrictive necessary. __Never overspecify the constraints__. There's no automated tool to check the useless constraints, so you have to verify this manually.
```rust
pub struct X<A>
where
A: P + Q // <- Try to use the as smallest set of constraints as possible. If the code still compiles after deleting Q, then remove it.
{
fn ...
}
```
3. Prefer generic to associated types in traits definition as much as possible. They are much easier to use around, and avoid tricky caveats / type repetition in the code. It is also much easier to have unconstrained struct definitions.
Try not to write this:
```rust
pub trait X
{
type A;
fn a(&self) -> Self::A;
}
```
Try to write this instead:
```rust
pub trait X<A>
{
fn a(&self) -> A;
}
```
4. Traits which have an associated type (if you have made sure you cannot use a generic instead) should refer to the associated type, not the concrete/generic. In other words, you should only have the associated type when you can define a getter to it. For example, in the following code, you can define a associate type.
```rust
pub trait X
{
type A; // <- You should(can) define it as long as you have a getter to it.
fn a(&self) -> Self::A;
}
```
5. Generic naming should be consistent. Do NOT use multiple name for the same generic, it just makes things more confusing. Do:
```rust
pub struct X<A> {
phantom: PhanomData<A>,
}
impl<A> X<A> {}
```
But not:
```rust
pub struct X<A> {
phantom: PhanomData<A>,
}
impl<B> X<B> {} // <- Do NOT do that, use A instead of B
```
6. __Ideally__ the types used in the arguments of methods in traits should have the same as the types defined on the traits.
```rust
pub trait X<A, B, C> // <- this trait have 3 generics, A, B, and C
{
fn do_stuff(&self, a: A, b: B, c: C); // <- this is good because it uses all A, B, and C.
fn do_other_stuff(&self, a: A, b: B); // <- this is not ideal because it does not have C.
}
```
7. Try to avoid cyclical dependency if possible. Sometimes it is necessary but try to avoid it. For example, The following code is a bad example.
```rust
pub struct X {}
pub struct Y {}
pub trait Fuzzer: Sized {
fn fuzz<EM>(&self, em: &EM)
where
EM: EventManager
{
em.do_stuff(self);
}
}
pub trait EventManager: Sized {
fn do_stuff<Z>(&self, fuzzer: &Z); // <- This function signature should not take fuzzer
}
```
trait `EventManager` should not implement any method that takes fuzzer, any object that could implement `Fuzzer` trait.
## Formatting
1. Always alphabetically order the type generics. Therefore,
```rust
pub struct X<E, EM, OT, S, Z> {}; // <- Generics are alphabetically ordered
```
But not,
```rust
pub struct X<S, OT, Z, EM, E> {}; // <- Generics are not ordered
```
2. Similarly, generic bounds in `where` clauses should be alphabetically sorted.
Prefer:
```rust
pub trait FooA {}
pub trait FooB {}
pub struct X<A, B>;
impl<A, B> X<A, B>
where
A: FooA,
B: FooB,
{}
```
Over:
```rust
pub trait FooA {}
pub trait FooB {}
pub struct X<A, B>;
impl<A, B> X<A, B>
where
B: FooB, // <-|
// | Generic bounds are not alphabetically ordered.
A: FooA, // <-|
{}
```

View File

@ -1,42 +1,188 @@
[workspace]
resolver = "2"
members = [
"libafl",
"libafl_derive",
"libafl_cc",
"libafl_targets",
"libafl_frida",
"libafl_qemu",
"libafl_tinyinst",
"libafl_sugar",
"libafl_nyx",
"libafl_concolic/symcc_runtime",
"libafl_concolic/symcc_libafl",
"libafl_concolic/test/dump_constraints",
"libafl_concolic/test/runtime_test",
"utils/deexit",
"utils/gramatron/construct_automata",
"utils/libafl_benches",
"libafl",
"libafl_bolts",
"libafl_cc",
"libafl_concolic/symcc_runtime",
"libafl_concolic/symcc_libafl",
"libafl_derive",
"libafl_frida",
"libafl_intelpt",
"libafl_libfuzzer",
"libafl_nyx",
"libafl_unicorn",
"libafl_targets",
"libafl_tinyinst",
"libafl_qemu",
"libafl_qemu/libafl_qemu_build",
"libafl_qemu/libafl_qemu_sys",
"libafl_sugar",
"libafl_concolic/test/dump_constraints",
"libafl_concolic/test/runtime_test",
"utils/build_and_test_fuzzers",
"utils/deexit",
"utils/drcov_utils",
"utils/gramatron/construct_automata",
"utils/libafl_benches",
"utils/libafl_jumper",
"utils/ci_runner",
"utils/ci_splitter",
]
default-members = [
"libafl",
"libafl_derive",
"libafl_cc",
"libafl_targets",
"libafl",
"libafl_bolts",
"libafl_cc",
"libafl_derive",
"libafl_targets",
]
exclude = [
"fuzzers",
"bindings",
"scripts",
"libafl_qemu/libafl_qemu_build",
"libafl_qemu/libafl_qemu_sys"
"bindings/pylibafl",
"docs",
"fuzzers",
"libafl_libfuzzer_runtime",
"utils/noaslr",
"utils/gdb_qemu",
"utils/libafl_repo_tools",
"utils/desyscall",
"utils/multi_machine_generator",
"scripts",
# additional crates
"libafl_concolic/test/symcc/util/symcc_fuzzing_helper",
]
[workspace.package]
version = "0.8.2"
version = "0.15.3"
license = "MIT OR Apache-2.0"
[workspace.dependencies]
# Internal deps
libafl = { path = "./libafl", version = "0.15.3", default-features = false }
libafl_bolts = { path = "./libafl_bolts", version = "0.15.3", default-features = false }
libafl_cc = { path = "./libafl_cc", version = "0.15.3", default-features = false }
symcc_runtime = { path = "./libafl_concolic/symcc_runtime", version = "0.15.2", default-features = false }
symcc_libafl = { path = "./libafl_concolic/symcc_libafl", version = "0.15.3", default-features = false }
libafl_derive = { path = "./libafl_derive", version = "0.15.3", default-features = false }
libafl_frida = { path = "./libafl_frida", version = "0.15.3", default-features = false }
libafl_intelpt = { path = "./libafl_intelpt", version = "0.15.3", default-features = false }
libafl_libfuzzer = { path = "./libafl_libfuzzer", version = "0.15.3", default-features = false }
libafl_nyx = { path = "./libafl_nyx", version = "0.15.3", default-features = false }
libafl_targets = { path = "./libafl_targets", version = "0.15.3", default-features = false }
libafl_tinyinst = { path = "./libafl_tinyinst", version = "0.15.3", default-features = false }
libafl_qemu = { path = "./libafl_qemu", version = "0.15.3", default-features = false }
libafl_qemu_build = { path = "./libafl_qemu/libafl_qemu_build", version = "0.15.3", default-features = false }
libafl_qemu_sys = { path = "./libafl_qemu/libafl_qemu_sys", version = "0.15.3", default-features = false }
libafl_sugar = { path = "./libafl_sugar", version = "0.15.3", default-features = false }
dump_constraints = { path = "./libafl_concolic/test/dump_constraints", version = "0.15.2", default-features = false }
runtime_test = { path = "./libafl_concolic/test/runtime_test", version = "0.15.2", default-features = false }
build_and_test_fuzzers = { path = "./utils/build_and_test_fuzzers", version = "0.15.2", default-features = false }
deexit = { path = "./utils/deexit", version = "0.15.2", default-features = false }
drcov_utils = { path = "./utils/drcov_utils", version = "0.15.2", default-features = false }
construct_automata = { path = "./utils/gramatron/construct_automata", version = "0.15.2", default-features = false }
libafl_benches = { path = "./utils/libafl_benches", version = "0.15.3", default-features = false }
libafl_jumper = { path = "./utils/libafl_jumper", version = "0.15.3", default-features = false }
# External deps
ahash = { version = "0.8.12", default-features = false } # The hash function already used in hashbrown
arbitrary-int = "1.2.7" # arbitrary sized integers, useful in combination with bitfields (bitbybit crate)
backtrace = { version = "0.3.74", default-features = false } # Used to get the stacktrace in StacktraceObserver
bindgen = "0.71.1"
# 2024-12-16: bitbybit 1.3.3 is leading CI to fail due to missing docs.
# fixme: Change this to 1.3.3 when the issue https://github.com/danlehmann/bitfield/issues/66 is resolved.
bitbybit = "=1.3.2" # bitfields, use this for bit fields and bit enums
capstone = "0.13.0" # Disassembler used in libafl_unicorn to provide disassembly on crash
clap = "4.5.18"
cc = "1.1.21"
cmake = "0.1.51"
document-features = "0.2.10"
fastbloom = { version = "0.11.0", default-features = false }
hashbrown = { version = "0.14.5", default-features = false } # A faster hashmap, nostd compatible
just = "1.40.0"
libc = "0.2.159" # For (*nix) libc
libipt = "0.3.0"
log = "0.4.22"
meminterval = "0.4.1"
mimalloc = { version = "0.1.43", default-features = false }
nix = { version = "0.29.0", default-features = false }
num_enum = { version = "0.7.3", default-features = false }
num-traits = { version = "0.2.19", default-features = false }
paste = "1.0.15"
postcard = { version = "1.0.10", features = [
"alloc",
], default-features = false } # no_std compatible serde serialization format
pyo3 = "0.24.1"
pyo3-build-config = "0.25.0"
rangemap = "1.5.1"
regex = "1.10.6"
rustversion = "1.0.17"
serde = { version = "1.0.210", default-features = false } # serialization lib
serial_test = { version = "3.1.1", default-features = false }
serde_json = { version = "1.0.128", default-features = false }
serde_yaml = { version = "0.9.34" } # For parsing the injections yaml file
static_assertions = "1.1.0"
strum = "0.27.0"
strum_macros = "0.27.0"
toml = "0.8.19" # For parsing the injections toml file
typed-builder = "0.21.0" # Implement the builder pattern at compiletime
typeid = "1.0.0" # Safe type_eq that doesn't rely on std specialization
unicorn-engine = "2.0.1" # Used in libafl_unicorn
uuid = { version = "1.10.0", features = ["serde", "v4"] }
which = "7.0.2"
windows = "0.59.0"
z3 = "0.12.1"
fs2 = "0.4.3" # Used by OnDisk Corpus for file locking
[workspace.lints.rust]
# Deny
warnings = { level = "deny", priority = -1 }
# Forbid
unexpected_cfgs = "forbid"
# Allow
incomplete_features = "allow"
# ambiguous_glob_reexports = "allow"
[workspace.lints.clippy]
# Deny
all = { level = "deny", priority = -1 }
pedantic = { level = "deny", priority = -1 }
cargo_common_metadata = "deny"
alloc_instead_of_core = "deny"
std_instead_of_alloc = "deny"
std_instead_of_core = "deny"
# Warn
cargo = { level = "warn", priority = -1 }
# Allow
negative_feature_names = "allow" # TODO: turn into 'warn' when working
multiple_crate_versions = "allow" # TODO: turn into `warn` when working
unreadable_literal = "allow"
type_repetition_in_bounds = "allow"
missing_errors_doc = "allow"
cast_possible_truncation = "allow"
used_underscore_binding = "allow"
ptr_as_ptr = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
unsafe_derive_deserialize = "allow"
similar_names = "allow"
too_many_lines = "allow"
comparison_chain = "allow" # This lint makes **ZERO** sense
struct_field_names = "allow" # ????
[workspace.lints.rustdoc]
# Deny
broken_intra_doc_links = "deny"
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
debug = true

View File

@ -1,122 +1,103 @@
# syntax=docker/dockerfile:1.2
FROM rust:bullseye AS libafl
FROM rust:1.87.0 AS libafl
LABEL "maintainer"="afl++ team <afl@aflplus.plus>"
LABEL "about"="LibAFL Docker image"
# install sccache to cache subsequent builds of dependencies
RUN cargo install sccache
# Install cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
# We now use just to build things rather than cargo-make
RUN cargo binstall --no-confirm just
# Nexttest allows us to run tests which panic in an environment where we can't unwind
RUN cargo binstall --no-confirm cargo-nextest
# Cargo fuzz is useful for fuzz testing our implementations
RUN cargo binstall -y cargo-fuzz
# Taplo allows us to format toml files
RUN cargo binstall -y taplo-cli
ENV HOME=/root
ENV SCCACHE_CACHE_SIZE="1G"
ENV SCCACHE_DIR=$HOME/.cache/sccache
ENV RUSTC_WRAPPER="/usr/local/cargo/bin/sccache"
ENV IS_DOCKER="1"
RUN sh -c 'echo set encoding=utf-8 > /root/.vimrc' \
echo "export PS1='"'[LibAFL \h] \w$(__git_ps1) \$ '"'" >> ~/.bashrc && \
mkdir ~/.cargo && \
echo "[build]\nrustc-wrapper = \"${RUSTC_WRAPPER}\"" >> ~/.cargo/config
echo "export PS1='"'[LibAFL \h] \w$(__git_ps1) \$ '"'" >> ~/.bashrc && \
mkdir ~/.cargo && \
echo "[build]\nrustc-wrapper = \"${RUSTC_WRAPPER}\"" >> ~/.cargo/config
RUN rustup component add rustfmt clippy
# Install clang 11, common build tools
RUN apt update && apt install -y build-essential gdb git wget clang clang-tools libc++-11-dev libc++abi-11-dev llvm
RUN rustup target add armv7-unknown-linux-gnueabi
RUN rustup target add aarch64-unknown-linux-gnu
RUN rustup target add i686-unknown-linux-gnu
RUN rustup target add powerpc-unknown-linux-gnu
# Copy a dummy.rs and Cargo.toml first, so that dependencies are cached
WORKDIR /libafl
COPY Cargo.toml README.md ./
# Install clang 18, common build tools
ENV LLVM_VERSION=18
ENV LLVM_CONFIG=llvm-config-${LLVM_VERSION}
RUN dpkg --add-architecture i386
RUN apt-get update && \
apt-get install -y \
build-essential \
cmake \
curl \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabi \
g++-i686-linux-gnu \
g++-mipsel-linux-gnu \
g++-powerpc-linux-gnu \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
gcc-i686-linux-gnu \
gcc-mipsel-linux-gnu \
gcc-powerpc-linux-gnu \
gcc-riscv64-linux-gnu \
gdb \
gdb-multiarch \
git \
gnupg \
less \
libc6-dev:i386 \
libclang-dev \
libgcc-12-dev:i386 \
libglib2.0-dev \
lsb-release \
ninja-build \
python3 \
python3-pip \
python3-venv \
software-properties-common \
ca-certificates \
wget
RUN set -ex &&\
wget https://apt.llvm.org/llvm.sh &&\
chmod +x llvm.sh &&\
./llvm.sh ${LLVM_VERSION}
COPY libafl_derive/Cargo.toml libafl_derive/Cargo.toml
COPY scripts/dummy.rs libafl_derive/src/lib.rs
RUN apt-get update && \
apt-get install -y \
clang-format-${LLVM_VERSION}
COPY libafl/Cargo.toml libafl/build.rs libafl/
COPY libafl/examples libafl/examples
COPY scripts/dummy.rs libafl/src/lib.rs
# Install a modern version of QEMU
WORKDIR /root
ENV QEMU_VER=10.0.0
RUN wget https://download.qemu.org/qemu-${QEMU_VER}.tar.xz && \
tar xvJf qemu-${QEMU_VER}.tar.xz && \
cd /root/qemu-${QEMU_VER} && \
./configure --target-list="\
arm-linux-user,\
aarch64-linux-user,\
i386-linux-user,\
ppc-linux-user,\
mips-linux-user,\
x86_64-linux-user,\
arm-softmmu,\
aarch64-softmmu,\
i386-softmmu,\
ppc-softmmu,\
mips-softmmu,\
x86_64-softmmu" && \
make -j && \
make install && \
cd /root && \
rm -rf qemu-${QEMU_VER}
COPY libafl_frida/Cargo.toml libafl_frida/build.rs libafl_frida/
COPY scripts/dummy.rs libafl_frida/src/lib.rs
COPY libafl_frida/src/gettls.c libafl_frida/src/gettls.c
COPY libafl_qemu/Cargo.toml libafl_qemu/build.rs libafl_qemu/
COPY scripts/dummy.rs libafl_qemu/src/lib.rs
COPY libafl_qemu/libafl_qemu_build/Cargo.toml libafl_qemu/libafl_qemu_build/
COPY scripts/dummy.rs libafl_qemu/libafl_qemu_build/src/lib.rs
COPY libafl_qemu/libafl_qemu_sys/Cargo.toml libafl_qemu/libafl_qemu_sys/build.rs libafl_qemu/libafl_qemu_sys/
COPY scripts/dummy.rs libafl_qemu/libafl_qemu_sys/src/lib.rs
COPY libafl_sugar/Cargo.toml libafl_sugar/
COPY scripts/dummy.rs libafl_sugar/src/lib.rs
COPY libafl_cc/Cargo.toml libafl_cc/Cargo.toml
COPY libafl_cc/build.rs libafl_cc/build.rs
COPY libafl_cc/src libafl_cc/src
COPY scripts/dummy.rs libafl_cc/src/lib.rs
COPY libafl_targets/Cargo.toml libafl_targets/build.rs libafl_targets/
COPY libafl_targets/src libafl_targets/src
COPY scripts/dummy.rs libafl_targets/src/lib.rs
COPY libafl_concolic/test/dump_constraints/Cargo.toml libafl_concolic/test/dump_constraints/
COPY scripts/dummy.rs libafl_concolic/test/dump_constraints/src/lib.rs
COPY libafl_concolic/test/runtime_test/Cargo.toml libafl_concolic/test/runtime_test/
COPY scripts/dummy.rs libafl_concolic/test/runtime_test/src/lib.rs
COPY libafl_concolic/symcc_runtime/Cargo.toml libafl_concolic/symcc_runtime/build.rs libafl_concolic/symcc_runtime/
COPY scripts/dummy.rs libafl_concolic/symcc_runtime/src/lib.rs
COPY libafl_concolic/symcc_libafl/Cargo.toml libafl_concolic/symcc_libafl/
COPY scripts/dummy.rs libafl_concolic/symcc_libafl/src/lib.rs
COPY libafl_nyx/Cargo.toml libafl_nyx/build.rs libafl_nyx/
COPY scripts/dummy.rs libafl_nyx/src/lib.rs
COPY libafl_tinyinst/Cargo.toml libafl_tinyinst/
COPY scripts/dummy.rs libafl_tinyinst/src/lib.rs
COPY utils utils
RUN cargo build && cargo build --release
COPY scripts scripts
COPY docs docs
# Pre-build dependencies for a few common fuzzers
# Dep chain:
# libafl_cc (independent)
# libafl_derive -> libafl
# libafl -> libafl_targets
# libafl_targets -> libafl_frida
# Build once without source
COPY libafl_cc/src libafl_cc/src
RUN touch libafl_cc/src/lib.rs
COPY libafl_derive/src libafl_derive/src
RUN touch libafl_derive/src/lib.rs
COPY libafl/src libafl/src
RUN touch libafl/src/lib.rs
COPY libafl_targets/src libafl_targets/src
RUN touch libafl_targets/src/lib.rs
COPY libafl_frida/src libafl_frida/src
RUN touch libafl_qemu/libafl_qemu_build/src/lib.rs
COPY libafl_qemu/libafl_qemu_build/src libafl_qemu/libafl_qemu_build/src
RUN touch libafl_qemu/libafl_qemu_sys/src/lib.rs
COPY libafl_qemu/libafl_qemu_sys/src libafl_qemu/libafl_qemu_sys/src
RUN touch libafl_qemu/src/lib.rs
COPY libafl_qemu/src libafl_qemu/src
RUN touch libafl_frida/src/lib.rs
COPY libafl_concolic/symcc_libafl libafl_concolic/symcc_libafl
COPY libafl_concolic/symcc_runtime libafl_concolic/symcc_runtime
COPY libafl_concolic/test libafl_concolic/test
COPY libafl_nyx/src libafl_nyx/src
RUN touch libafl_nyx/src/lib.rs
RUN cargo build && cargo build --release
# Copy fuzzers over
COPY fuzzers fuzzers
# RUN ./scripts/test_all_fuzzers.sh --no-fmt
ENTRYPOINT [ "/bin/bash" ]
ENTRYPOINT [ "/bin/bash", "-c" ]
CMD ["/bin/bash"]

51
MIGRATION.md Normal file
View File

@ -0,0 +1,51 @@
# Migration Notes For LibAFL Versions
## 0.15.0 -> 0.16.0
- `EventManager` is refactored to avoid calling function from `Fuzzer`, thus we do not evaluate testcases in `EventManager` anymore.
- Now we have `EventReceiver` in `events` module, and `EventProcessor` in `fuzzer` module.
- `EventReceiver` is responsible for receiving testcases and delegates its evaluation to `EventProcessor`.
- `EventProcessor` is responsible for evaluating the testcases passed by the `EventReceiver`.
- Since we don't evaluate testcases in the `EventManager` anymore. `on_fire` and `post_exec` have been deleted from `EventManagerHook`.
- Similarly `pre_exec` has been renamed to `pre_receive`.
- `AsanModule` now uses a `builder()` method for constructing its instances.
- `Monitor` is refactored. Most statistics have been extracted into an individual `stats` module under `monitors`.
- There is a `ClientStatsManager` to manage client statistics, and is owned by `EventManager`. Most of previous `Monitor`'s trait methods have been moved to the `ClientStatsManager`.
- `user_monitor` has been renamed to `user_stats`, `introspection_monitor` has been renamed to `introspection_stats`, perf-related structure definitions have been renamed, and all were moved to the `stats` module.
- `OnDiskTomlMonitor`, `OnDiskJsonMonitor`, `OnDiskJsonAggregateMonitor` are now no longer takes a base monitor to wrap. If you want to use multiple monitors together, simply use a `tuple_list`.
- `MultipartInput` is now implemented as key-value tuples in a `ListInput`. The interface slightly changed, all functionality is maintained.
- Instead of names, `MultipartInput` uses generic `key`s (function names were changed accordingly).
- If you don't need the keys to identify individual parts, consider using `ListInput` directly.
- `StdScheduledMutator` has been renamed to `HavocScheduledMutator`.
## 0.14.1 -> 0.15.0
- `MmapShMem::new` and `MmapShMemProvider::new_shmem_with_id` now take `AsRef<Path>` instead of a byte array for the filename/id.
- The closure passed to a `DumpToDiskStage` now provides the `Testcase` instead of just the `Input`.
- `StatsStage` is deleted, and it is superceded by `AflStatsStage`
- Renamed and changed mapping mutators to take borrows directly instead of `MappedInput`s. See `baby_fuzzer_custom_input` for example usage
- Related: `MutVecInput` is deprecated in favor of directly using `&mut Vec<u8>`
- Related: `MappedInputFunctionMappingMutator` and `ToMappedInputFunctionMappingMutatorMapper` have been removed as now duplicates of `MappingMutator` (previously `FunctionMappingMutator`) and `ToMappingMutator` (previously `ToFunctionMappingMutatorMapper`)
- Related: `ToOptionMappingMutatorMapper` and `ToFunctionMappingMutatorMapper` have been renamed to `ToOptionalMutator` and `ToMappingMutator` respectively
- `Qemu` cannot be used to initialize `Emulator` directly anymore. Instead, `Qemu` should be initialized through `Emulator` systematically if `Emulator` should be used.
- Related: `EmulatorBuilder` uses a single function to provide a `Qemu` initializer: `EmulatorBuilder::qemu_parameters`. For now, it can be either a `Vec<String>` or a `QemuConfig` instance.
- Related: Qemu's `AsanModule` does not need any special call to `Qemu` init methods anymore. It is now possible to simply initialize `AsanModule` (or `AsanGuestModule`) with a reference to the environment as parameter.
- `CustomBufHandlers` has been deleted. Please use `EventManagerHooksTuple` from now on.
- Trait restrictions have been simplified
- The `UsesState` and `UsesInput` traits have been removed in favor of regular Generics.
- For the structs/traits that used to use `UsesState`, we bring back the generic for the state.
- `Input` is now only accessible through generic. `Input` associated types have been definitely removed.
- `HasCorpus` bound has been removed in many places it was unused before.
- `StdMutationalStage::transforming` must now explicitly state the Inputs types. As a result, `StdMutationalStage::transforming` must be written `StdMutationalStage::<_, _, FirstInputType, SecondInputType, _, _, _>::transforming`.
- The `State` trait is now private in favour of individual and more specific traits
- Restrictions from certain schedulers and stages that required their inner observer to implement `MapObserver` have been lifted in favor of requiring `Hash`
- Related: removed `hash_simple` from `MapObserver`
## 0.14.0 -> 0.15.0
- Removed `with_observers` from `Executor` trait.
- `MmapShMemProvider::new_shmem_persistent` has been removed in favour of `MmapShMem::persist`. You probably want to do something like this: `let shmem = MmapShMemProvider::new()?.new_shmem(size)?.persist()?;`
## Pre 0.9 -> 0.9
- [Migrating from LibAFL <0.9 to 0.9](https://aflplus.plus/libafl-book/design/migration-0.9.html)

143
README.md
View File

@ -1,19 +1,10 @@
# LibAFL, the fuzzer library.
<img align="right" src="https://github.com/AFLplusplus/Website/raw/master/static/logo_256x256.png" alt="AFL++ Logo">
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/main/static/libafl_logo.svg" alt="LibAFL logo" width="250" heigh="250">
Advanced Fuzzing Library - Slot your own fuzzers together and extend their features using Rust.
LibAFL is written and maintained by
* [Andrea Fioraldi](https://twitter.com/andreafioraldi) <andrea@aflplus.plus>
* [Dominik Maier](https://twitter.com/domenuk) <dominik@aflplus.plus>
* [s1341](https://twitter.com/srubenst1341) <github@shmarya.net>
* [Dongjia Zhang](https://github.com/tokatoka) <toka@aflplus.plus>
## Why LibAFL?
LibAFL gives you many of the benefits of an off-the-shelf fuzzer, while being completely customizable.
LibAFL is a collection of reusable pieces of fuzzers, written in Rust, it gives you many of the benefits of an off-the-shelf fuzzer, while being completely customizable.
Some highlight features currently include:
- `fast`: We do everything we can at compile time, keeping runtime overhead minimal. Users reach 120k execs/sec in frida-mode on a phone (using all cores).
- `scalable`: `Low Level Message Passing`, `LLMP` for short, allows LibAFL to scale almost linearly over cores, and via TCP to multiple machines.
@ -22,104 +13,80 @@ feel free to add an AST-based input for structured fuzzing, and more.
- `multi platform`: LibAFL was confirmed to work on *Windows*, *MacOS*, *Linux*, and *Android* on *x86_64* and *aarch64*. `LibAFL` can be built in `no_std` mode to inject LibAFL into obscure targets like embedded devices and hypervisors.
- `bring your own target`: We support binary-only modes, like Frida-Mode, as well as multiple compilation passes for sourced-based instrumentation. Of course it's easy to add custom instrumentation backends.
## Overview
## Core concepts
LibAFL is a collection of reusable pieces of fuzzers, written in Rust.
It is fast, multi-platform, no_std compatible, and scales over cores and machines.
LibAFL is fast, multi-platform, no_std compatible, and scales over cores and machines. It offers a main crate that provide building blocks for custom fuzzers, [libafl](./libafl), a library containing common code that can be used for targets instrumentation, [libafl_targets](./libafl_targets), and a library providing facilities to wrap compilers, [libafl_cc](./libafl_cc). It offers integrations with popular instrumentation frameworks. At the moment, the supported backends are:
+ `SanitizerCoverage`, in [libafl_targets](./libafl_targets)
+ `Frida`, in [libafl_frida](./libafl_frida)
+ `QEMU` user-mode and system mode, including hooks for emulation, in [libafl_qemu](./libafl_qemu)
+ `TinyInst`, in [libafl_tinyinst](./libafl_tinyinst) by [elbiazo](https://github.com/elbiazo)
It offers a main crate that provide building blocks for custom fuzzers, [libafl](./libafl), a library containing common code that can be used for targets instrumentation, [libafl_targets](./libafl_targets), and a library providing facilities to wrap compilers, [libafl_cc](./libafl_cc).
## Building and installing
LibAFL offers integrations with popular instrumentation frameworks. At the moment, the supported backends are:
+ SanitizerCoverage, in [libafl_targets](./libafl_targets)
+ Frida, in [libafl_frida](./libafl_frida)
+ QEMU user-mode, in [libafl_qemu](./libafl_qemu)
+ TinyInst, in [libafl_tinyinst](./libafl_tinyinst) by [elbiazo](https://github.com/elbiazo)
## Getting started
1. Install the Dependecies
- The Rust development language.
We highly recommend *not* to use e.g. your Linux distribition package as this is likely outdated. So rather install
Rust directly, instructions can be found [here](https://www.rust-lang.org/tools/install).
- LLVM tools
The LLVM tools are needed (newer than LLVM 11.0.0 but older than LLVM 15.0.0)
- Cargo-make
We use cargo-make to build the fuzzers in `fuzzers/` directory. You can install it with
```
cargo install cargo-make
```
2. Clone the LibAFL repository with
```
#### Install the Dependencies
- **The Rust development language**
- We highly recommend *not* to use e.g. your Linux distribution package as this is likely outdated. So rather install Rust directly, instructions can be found [here](https://www.rust-lang.org/tools/install).
- **LLVM tools**
- The LLVM tools (including clang, clang++) are needed (newer than LLVM 15.0.0 up to LLVM 18.1.3) If you are using Debian/Ubuntu, again, we highly recommmend that you install the package from [here](https://apt.llvm.org/)
- (In `libafl_concolic`, we only support LLVM version newer than 18)
- Just:
- We use [just](https://github.com/casey/just) to build the fuzzers in `fuzzers/` directory. You can find instructions to install it in your environment [in the Just Programmer's Manual](https://just.systems/man/en/packages.html).
#### Clone the LibAFL repository with
```sh
git clone https://github.com/AFLplusplus/LibAFL
```
3. Build the library using
```
#### Build the library using
```sh
cargo build --release
```
4. Build the API documentation with
```
#### Build the API documentation with
```sh
cargo doc
```
5. Browse the LibAFL book (WIP!) with (requires [mdbook](https://github.com/rust-lang/mdBook))
```
#### Browse the LibAFL book (WIP!) with (requires [mdbook](https://rust-lang.github.io/mdBook/index.html))
```sh
cd docs && mdbook serve
```
## Getting started
We collect all example fuzzers in [`./fuzzers`](./fuzzers/).
Be sure to read their documentation (and source), this is *the natural way to get started!*
You can run each example fuzzer with
```sh
just run
```
cargo make run
```
as long as the fuzzer directory has `Makefile.toml` file.
You can run each example fuzzer with this following command, as long as the fuzzer directory has a `Justfile` file. The best-tested fuzzer is [`./fuzzers/inprocess/libfuzzer_libpng`](./fuzzers/inprocess/libfuzzer_libpng), a multicore libfuzzer-like fuzzer using LibAFL for a libpng harness.
The best-tested fuzzer is [`./fuzzers/libfuzzer_libpng`](./fuzzers/libfuzzer_libpng), a multicore libfuzzer-like fuzzer using LibAFL for a libpng harness.
### Resources
- [Installation guide](./docs/src/getting_started/setup.md)
- [Online API documentation](https://docs.rs/libafl/)
- The LibAFL book (WIP) [online](https://aflplus.plus/libafl-book) or in the [repo](./docs/src/)
- Our research [paper](https://www.s3.eurecom.fr/docs/ccs22_fioraldi.pdf)
- Our RC3 [talk](http://www.youtube.com/watch?v=3RWkT1Q5IV0 "Fuzzers Like LEGO") explaining the core concepts
- Our Fuzzcon Europe [talk](https://www.youtube.com/watch?v=PWB8GIhFAaI "LibAFL: The Advanced Fuzzing Library") with a (a bit but not so much outdated) step-by-step discussion on how to build some example fuzzers
- The Fuzzing101 [solutions](https://github.com/epi052/fuzzing-101-solutions) & series of [blog posts](https://epi052.gitlab.io/notes-to-self/blog/2021-11-01-fuzzing-101-with-libafl/) by [epi](https://github.com/epi052)
- Blogpost on binary-only fuzzing lib libaf_qemu, [Hacking TMNF - Fuzzing the game server](https://blog.bricked.tech/posts/tmnf/part1/), by [RickdeJager](https://github.com/RickdeJager).
- [A LibAFL Introductory Workshop](https://www.atredis.com/blog/2023/12/4/a-libafl-introductory-workshop), by [Jordan Whitehead](https://github.com/jordan9001)
## Resources
## Contributors
+ [Installation guide](./docs/src/getting_started/setup.md)
LibAFL is written and maintained by
+ [Online API documentation](https://docs.rs/libafl/)
+ The LibAFL book (WIP) [online](https://aflplus.plus/libafl-book) or in the [repo](./docs/src/)
+ Our research [paper](https://www.s3.eurecom.fr/docs/ccs22_fioraldi.pdf)
+ Our RC3 [talk](http://www.youtube.com/watch?v=3RWkT1Q5IV0 "Fuzzers Like LEGO") explaining the core concepts
+ Our Fuzzcon Europe [talk](https://www.youtube.com/watch?v=PWB8GIhFAaI "LibAFL: The Advanced Fuzzing Library") with a (a bit but not so much outdated) step-by-step discussion on how to build some example fuzzers
+ The Fuzzing101 [solutions](https://github.com/epi052/fuzzing-101-solutions) & series of [blog posts](https://epi052.gitlab.io/notes-to-self/blog/2021-11-01-fuzzing-101-with-libafl/) by [epi](https://github.com/epi052)
+ Blogpost on binary-only fuzzing lib libaf_qemu, [Hacking TMNF - Fuzzing the game server](https://blog.bricked.tech/posts/tmnf/part1/), by [RickdeJager](https://github.com/RickdeJager).
* [Andrea Fioraldi](https://twitter.com/andreafioraldi) <andrea@aflplus.plus>
* [Dominik Maier](https://twitter.com/domenuk) <dominik@aflplus.plus>
* [s1341](https://twitter.com/srubenst1341) <github@shmarya.net>
* [Dongjia Zhang](https://github.com/tokatoka) <toka@aflplus.plus>
* [Addison Crump](https://github.com/addisoncrump) <me@addisoncrump.info>
* [Romain Malmain](https://github.com/rmalmain) <rmalmain@pm.me>
## Contributing
For bugs, feel free to open issues or contact us directly. Thank you for your support. <3
Please check out **[CONTRIBUTING.md](CONTRIBUTING.md)** for the contributing guideline.
Even though we will gladly assist you in finishing up your PR, try to
- keep all the crates compiling with *stable* rust (hide the eventual non-stable code under [`cfg`s](https://github.com/AFLplusplus/LibAFL/blob/main/libafl/build.rs#L26))
- run `cargo fmt` on your code before pushing
- check the output of `cargo clippy --all` or `./clippy.sh`
- run `cargo build --no-default-features` to check for `no_std` compatibility (and possibly add `#[cfg(feature = "std")]`) to hide parts of your code.
## Debugging
Some of the parts in this list may be hard, don't be afraid to open a PR if you cannot fix them by yourself, so we can help.
Your fuzzer doesn't work as expected? Try reading [DEBUGGING.md](./docs/src/DEBUGGING.md) to understand how to debug your problems.
## Cite
If you use LibAFL for your academic work, please cite the following paper:
```bibtex
@ -149,11 +116,3 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
</sub>
<br>
<sub>
Dependencies under more restrictive licenses, such as GPL or AGPL, can be enabled
using the respective feature in each crate when it is present, such as the
'agpl' feature of the libafl crate.
</sub>

17
TROPHIES.md Normal file
View File

@ -0,0 +1,17 @@
# Bugs found by `libafl` and `libafl_libfuzzer`
* pdf-rs
* <https://github.com/pdf-rs/pdf/issues/183>
* <https://github.com/pdf-rs/pdf/issues/184>
* <https://github.com/pdf-rs/pdf/issues/185>
* <https://github.com/pdf-rs/pdf/issues/186>
* <https://github.com/pdf-rs/pdf/issues/187>
* <https://github.com/pdf-rs/pdf/issues/189>
* nu-shell
* https://github.com/nushell/nushell/issues/10365
* https://github.com/nushell/nushell/issues/9417
* exrs
* https://github.com/johannesvollmer/exrs/pull/221
* pcre2
* https://github.com/PCRE2Project/pcre2/issues/275

1
bindings/pylibafl/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
dist/

View File

@ -1,20 +1,36 @@
[package]
name = "pylibafl"
version = "0.8.2"
edition = "2021"
description = "Python bindings for LibAFL"
version = "0.15.3"
license = "MIT OR Apache-2.0"
repository = "https://github.com/AFLplusplus/LibAFL/"
keywords = ["fuzzing", "testing", "security", "python"]
edition = "2024"
categories = ["development-tools::testing", "emulators", "embedded", "os"]
[dependencies]
pyo3 = { version = "0.17", features = ["extension-module"] }
libafl_qemu = { path = "../../libafl_qemu", version = "0.8.2", features = ["python"] }
libafl_sugar = { path = "../../libafl_sugar", version = "0.8.2", features = ["python"] }
libafl = { path = "../../libafl", version = "0.8.2", features = ["python"] }
pyo3 = { version = "0.24.0", features = ["extension-module"] }
pyo3-log = { version = "0.12.2" }
libafl_sugar = { path = "../../libafl_sugar", version = "0.15.3", features = [
"python",
] }
libafl_bolts = { path = "../../libafl_bolts", version = "0.15.3", features = [
"python",
] }
[target.'cfg(target_os = "linux")'.dependencies]
libafl_qemu = { path = "../../libafl_qemu", version = "0.15.3", features = [
"python",
] }
[build-dependencies]
pyo3-build-config = { version = "0.17" }
pyo3-build-config = "0.24.0"
[lib]
name = "pylibafl"
crate-type = ["cdylib"]
[profile.dev]
panic = "abort"
# TODO: find a way to fix this when a solution is found
# https://github.com/rust-lang/cargo/issues/9330
# [profile.dev]
# panic = "abort"

View File

@ -0,0 +1,26 @@
[build-system]
requires = ["maturin[patchelf]>=1.0,<2.0"]
build-backend = "maturin"
[project]
name = "PyLibAFL"
version = "0.15.3"
description = "Advanced Fuzzing Library for Python"
readme = "README.md"
requires-python = ">=3.8"
license = { text = "Apache-2.0" }
classifiers = [
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: MIT License",
"Programming Language :: Rust",
"Topic :: Security",
]
[project.urls]
repository = "https://github.com/AFLplusplus/LibAFL.git"
[tool.maturin]
bindings = "pyo3"
manifest-path = "Cargo.toml"
python-source = "src"
all-features = true

View File

@ -1,121 +1,33 @@
use libafl;
#[cfg(target_os = "linux")]
use libafl_qemu;
use libafl_sugar;
use pyo3::{prelude::*, types::PyDict};
const LIBAFL_CODE: &str = r#"
class BaseObserver:
def flush(self):
pass
def pre_exec(self, state, input):
pass
def post_exec(self, state, input, exit_kind):
pass
def pre_exec_child(self, state, input):
pass
def post_exec_child(self, state, input, exit_kind):
pass
def name(self):
return type(self).__name__
def as_observer(self):
return Observer.new_py(self)
class BaseFeedback:
def init_state(self, state):
pass
def is_interesting(self, state, mgr, input, observers, exit_kind) -> bool:
return False
def append_metadata(self, state, testcase):
pass
def discard_metadata(self, state, input):
pass
def name(self):
return type(self).__name__
def as_feedback(self):
return Feedback.new_py(self)
class BaseExecutor:
def observers(self) -> ObserversTuple:
raise NotImplementedError('Implement this yourself')
def run_target(self, fuzzer, state, mgr, input) -> ExitKind:
raise NotImplementedError('Implement this yourself')
def as_executor(self):
return Executor.new_py(self)
class BaseStage:
def perform(self, fuzzer, executor, state, manager, corpus_idx):
pass
def as_stage(self):
return Stage.new_py(self)
class BaseMutator:
def mutate(self, state, input, stage_idx):
pass
def post_exec(self, state, stage_idx, corpus_idx):
pass
def as_mutator(self):
return Mutator.new_py(self)
class FnStage(BaseStage):
def __init__(self, fn):
self.fn = fn
def __call__(self, fuzzer, executor, state, manager, corpus_idx):
self.fn(fuzzer, executor, state, manager, corpus_idx)
def perform(self, fuzzer, executor, state, manager, corpus_idx):
self.fn(fuzzer, executor, state, manager, corpus_idx)
def feedback_not(a):
return NotFeedback(a).as_feedback()
def feedback_and(a, b):
return EagerAndFeedback(a, b).as_feedback()
def feedback_and_fast(a, b):
return FastAndFeedback(a, b).as_feedback()
def feedback_or(a, b):
return EagerOrFeedback(a, b).as_feedback()
def feedback_or_fast(a, b):
return FastOrFeedback(a, b).as_feedback()
"#;
use pyo3::prelude::*;
/// Setup python modules for `libafl_qemu` and `libafl_sugar`.
///
/// # Errors
/// Returns error if python libafl setup failed.
#[pymodule]
#[pyo3(name = "pylibafl")]
pub fn python_module(py: Python, m: &PyModule) -> PyResult<()> {
let modules = py.import("sys")?.getattr("modules")?;
pub fn python_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
pyo3_log::init();
let sugar_module = PyModule::new(py, "sugar")?;
libafl_sugar::python_module(py, sugar_module)?;
m.add_submodule(sugar_module)?;
let modules = m.py().import("sys")?.getattr("modules")?;
let sugar_module = PyModule::new(m.py(), "sugar")?;
libafl_sugar::python_module(&sugar_module)?;
m.add_submodule(&sugar_module)?;
modules.set_item("pylibafl.sugar", sugar_module)?;
#[cfg(target_os = "linux")]
let qemu_module = PyModule::new(py, "qemu")?;
#[cfg(target_os = "linux")]
libafl_qemu::python_module(py, qemu_module)?;
#[cfg(target_os = "linux")]
m.add_submodule(qemu_module)?;
#[cfg(target_os = "linux")]
modules.set_item("pylibafl.qemu", qemu_module)?;
let libafl_module = PyModule::new(py, "libafl")?;
libafl::pybind::python_module(py, libafl_module)?;
libafl_module.add("__builtins__", py.import("builtins")?)?;
let locals = PyDict::new(py);
py.run(LIBAFL_CODE, Some(libafl_module.dict()), Some(locals))?;
for (key, val) in locals.iter() {
libafl_module.add(key.extract::<&str>()?, val)?;
{
let qemu_module = PyModule::new(m.py(), "qemu")?;
libafl_qemu::python_module(&qemu_module)?;
m.add_submodule(&qemu_module)?;
modules.set_item("pylibafl.qemu", qemu_module)?;
}
m.add_submodule(libafl_module)?;
modules.set_item("pylibafl.libafl", libafl_module)?;
let bolts_module = PyModule::new(m.py(), "libafl_bolts")?;
libafl_bolts::pybind::python_module(&bolts_module)?;
m.add_submodule(&bolts_module)?;
modules.set_item("pylibafl.libafl_bolts", bolts_module)?;
Ok(())
}

View File

@ -1,94 +1,9 @@
from pylibafl.libafl import *
import pylibafl.sugar as sugar
import ctypes
import platform
class FooObserver(BaseObserver):
def __init__(self):
self.n = 0
def name(self):
return "Foo"
def pre_exec(self, state, input):
if self.n % 10000 == 0:
print("FOO!", self.n, input)
self.n += 1
class FooFeedback(BaseFeedback):
def is_interesting(self, state, mgr, input, observers, exit_kind):
ob = observers.match_name("Foo").unwrap_py()
return ob.n % 10000 == 0
class FooExecutor(BaseExecutor):
def __init__(self, harness, observers: ObserversTuple):
self.h = harness
self.o = observers
def observers(self):
return self.o
def run_target(self, fuzzer, state, mgr, input) -> ExitKind:
return (self.h)(input)
libc = ctypes.cdll.LoadLibrary("libc.so.6")
area_ptr = libc.calloc(1, 4096)
observer = StdMapObserverI8("mymap", area_ptr, 4096)
m = observer.as_map_observer()
observers = ObserversTuple(
[observer.as_map_observer().as_observer(), FooObserver().as_observer()]
print("Starting to fuzz from python!")
fuzzer = sugar.InProcessBytesCoverageSugar(
input_dirs=["./in"], output_dir="out", broker_port=1337, cores=[0, 1]
)
feedback = feedback_or(MaxMapFeedbackI8(m).as_feedback(), FooFeedback().as_feedback())
objective = feedback_and_fast(
CrashFeedback().as_feedback(), MaxMapFeedbackI8(m).as_feedback()
)
fuzzer = StdFuzzer(feedback, objective)
rand = StdRand.with_current_nanos()
state = StdState(
rand.as_rand(),
InMemoryCorpus().as_corpus(),
InMemoryCorpus().as_corpus(),
feedback,
objective,
)
monitor = SimpleMonitor(lambda s: print(s))
mgr = SimpleEventManager(monitor.as_monitor())
def harness(buf) -> ExitKind:
# print(buf)
m[0] = 1
if len(buf) > 0 and buf[0] == ord("a"):
m[1] = 1
if len(buf) > 1 and buf[1] == ord("b"):
m[2] = 1
if len(buf) > 2 and buf[2] == ord("c"):
m[3] = 1
return ExitKind.crash()
return ExitKind.ok()
# executor = InProcessExecutor(harness, observers, fuzzer, state, mgr.as_manager())
executor = FooExecutor(harness, observers)
stage = StdMutationalStage(StdHavocMutator().as_mutator())
stage_tuple_list = StagesTuple([stage.as_stage()])
fuzzer.add_input(state, executor.as_executor(), mgr.as_manager(), b"\0\0")
fuzzer.fuzz_loop(executor.as_executor(), state, mgr.as_manager(), stage_tuple_list)
fuzzer.run(lambda b: print("foo"))

14
bindings/pylibafl/test.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
mkdir in || true
echo "a" > ./in/a
timeout 10 python3 ./test.py
export exit_code=$?
if [ $exit_code -eq 124 ]; then
# 124 = timeout happened. All good.
exit 0
else
exit $exit_code
fi

1
docs/.gitignore vendored
View File

@ -1 +1,2 @@
book
!listings/**/*

2
docs/listings/baby_fuzzer/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target
crashes

View File

@ -0,0 +1,17 @@
# Justfile to build all example projects
default: build-all
build PROJECT:
@echo "Building project in directory: {{PROJECT}}"
@cd {{PROJECT}} && cargo build
@echo "Finished building project in directory: {{PROJECT}}"
build-all: listing-01 listing-02 listing-03 listing-04 listing-05 listing-06
listing-01: (build "listing-01")
listing-02: (build "listing-02")
listing-03: (build "listing-03")
listing-04: (build "listing-04")
listing-05: (build "listing-05")
listing-06: (build "listing-06")

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "baby_fuzzer_listing_01"
version = "0.15.2"

View File

@ -0,0 +1,9 @@
[package]
name = "baby_fuzzer_listing_01"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
[package]
name = "baby_fuzzer_listing_02"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
#libafl = { version = ".." }
libafl = { path = "../../../../libafl" }
#libafl_bolts = { version = ".." }
libafl_bolts = { path = "../../../../libafl_bolts" }

View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
[package]
name = "baby_fuzzer_listing_03"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
test-panic = []
[dependencies]
#libafl = { version = ".." }
libafl = { path = "../../../../libafl" }
#libafl_bolts = { version = ".." }
libafl_bolts = { path = "../../../../libafl_bolts" }

View File

@ -0,0 +1,26 @@
extern crate libafl;
extern crate libafl_bolts;
use libafl::{
executors::ExitKind,
inputs::{BytesInput, HasTargetBytes},
};
use libafl_bolts::AsSlice;
fn main() {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if buf.len() > 0 && buf[0] == b'a' {
if buf.len() > 1 && buf[1] == b'b' {
if buf.len() > 2 && buf[2] == b'c' {
panic!("=)");
}
}
}
ExitKind::Ok
};
// To test the panic:
let input = BytesInput::new(Vec::from("abc"));
#[cfg(feature = "test-panic")]
harness(&input);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
[package]
name = "baby_fuzzer_listing_04"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
test-panic = []
[dependencies]
#libafl = { version = ".." }
libafl = { path = "../../../../libafl" }
#libafl_bolts = { version = ".." }
libafl_bolts = { path = "../../../../libafl_bolts" }

View File

@ -0,0 +1,87 @@
/* ANCHOR: use */
extern crate libafl;
extern crate libafl_bolts;
use std::path::PathBuf;
use libafl::{
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::{ExitKind, inprocess::InProcessExecutor},
fuzzer::StdFuzzer,
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
schedulers::QueueScheduler,
state::StdState,
};
use libafl_bolts::{AsSlice, nonzero, rands::StdRand};
/* ANCHOR_END: use */
fn main() {
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if buf.len() > 0 && buf[0] == b'a' {
if buf.len() > 1 && buf[1] == b'b' {
if buf.len() > 2 && buf[2] == b'c' {
panic!("=)");
}
}
}
ExitKind::Ok
};
// To test the panic:
let input = BytesInput::new(Vec::from("abc"));
#[cfg(feature = "test-panic")]
harness(&input);
/* ANCHOR: state */
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
// on disk so the user can get them after stopping the fuzzer
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
&mut (),
&mut (),
)
.unwrap();
/* ANCHOR_END: state */
/* ANCHOR: event_manager */
// The Monitor trait defines how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{s}"));
// The event manager handles the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(mon);
/* ANCHOR_END: event_manager */
/* ANCHOR: scheduler_fuzzer */
// A queue policy to get testcases from the corpus
let scheduler = QueueScheduler::new();
// A fuzzer with feedbacks and a corpus scheduler
let mut fuzzer = StdFuzzer::new(scheduler, (), ());
/* ANCHOR_END: scheduler_fuzzer */
/* ANCHOR: executor */
// Create the executor for an in-process function
let mut executor = InProcessExecutor::new(&mut harness, (), &mut fuzzer, &mut state, &mut mgr)
.expect("Failed to create the Executor");
/* ANCHOR_END: executor */
/* ANCHOR: generator */
// Generator of printable bytearrays of max size 32
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
// Generate 8 initial inputs
state
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
.expect("Failed to generate the initial corpus");
/* ANCHOR_END: generator */
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
[package]
name = "baby_fuzzer_listing_05"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
test-panic = []
[dependencies]
#libafl = { version = ".." }
libafl = { path = "../../../../libafl" }
#libafl_bolts = { version = ".." }
libafl_bolts = { path = "../../../../libafl_bolts" }

View File

@ -0,0 +1,117 @@
/* ANCHOR: use */
extern crate libafl;
extern crate libafl_bolts;
use std::path::PathBuf;
use libafl::{
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::{ExitKind, inprocess::InProcessExecutor},
feedbacks::{CrashFeedback, MaxMapFeedback},
fuzzer::StdFuzzer,
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
observers::ConstMapObserver,
schedulers::QueueScheduler,
state::StdState,
};
use libafl_bolts::{AsSlice, nonnull_raw_mut, nonzero, rands::StdRand, tuples::tuple_list};
/* ANCHOR_END: use */
/* ANCHOR: signals */
// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
fn signals_set(idx: usize) {
unsafe { SIGNALS[idx] = 1 };
}
fn main() {
// The closure that we want to fuzz
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0); // set SIGNALS[0]
if buf.len() > 0 && buf[0] == b'a' {
signals_set(1); // set SIGNALS[1]
if buf.len() > 1 && buf[1] == b'b' {
signals_set(2); // set SIGNALS[2]
if buf.len() > 2 && buf[2] == b'c' {
panic!("=)");
}
}
}
ExitKind::Ok
};
/* ANCHOR_END: signals */
// To test the panic:
let input = BytesInput::new(Vec::from("abc"));
#[cfg(feature = "test-panic")]
harness(&input);
/* ANCHOR: observer */
// Create an observation channel using the signals map
let observer = unsafe { ConstMapObserver::from_mut_ptr("signals", nonnull_raw_mut!(SIGNALS)) };
/* ANCHOR_END: observer */
/* ANCHOR: state_with_feedback_and_objective */
// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::new(&observer);
// A feedback to choose if an input is a solution or not
let mut objective = CrashFeedback::new();
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
// on disk so the user can get them after stopping the fuzzer
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
&mut feedback,
&mut objective,
)
.unwrap();
/* ANCHOR_END: state_with_feedback_and_objective */
// The Monitor trait defines how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{s}"));
// The event manager handles the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(mon);
// A queue policy to get testcasess from the corpus
let scheduler = QueueScheduler::new();
/* ANCHOR: state_with_feedback_and_objective */
// A fuzzer with feedbacks and a corpus scheduler
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
/* ANCHOR_END: state_with_feedback_and_objective */
/* ANCHOR: executor_with_observer */
// Create the executor for an in-process function with just one observer
let mut executor = InProcessExecutor::new(
&mut harness,
tuple_list!(observer),
&mut fuzzer,
&mut state,
&mut mgr,
)
.expect("Failed to create the Executor");
/* ANCHOR_END: executor_with_observer */
// Generator of printable bytearrays of max size 32
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
// Generate 8 initial inputs
state
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
.expect("Failed to generate the initial corpus");
/* ANCHOR: signals */
}
/* ANCHOR_END: signals */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
[package]
name = "baby_fuzzer_listing_06"
version = "0.15.3"
authors = ["Your Name <you@example.com>"]
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
test-panic = []
[dependencies]
#libafl = { version = ".." }
libafl = { path = "../../../../libafl" }
#libafl_bolts = { version = ".." }
libafl_bolts = { path = "../../../../libafl_bolts" }

View File

@ -0,0 +1,117 @@
/* ANCHOR: use */
extern crate libafl;
extern crate libafl_bolts;
use std::path::PathBuf;
use libafl::{
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::{ExitKind, inprocess::InProcessExecutor},
feedbacks::{CrashFeedback, MaxMapFeedback},
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::{havoc_mutations, scheduled::HavocScheduledMutator},
observers::ConstMapObserver,
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,
};
use libafl_bolts::{AsSlice, nonnull_raw_mut, nonzero, rands::StdRand, tuples::tuple_list};
/* ANCHOR_END: use */
// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
fn signals_set(idx: usize) {
unsafe { SIGNALS[idx] = 1 };
}
fn main() {
// The closure that we want to fuzz
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0); // set SIGNALS[0]
if buf.len() > 0 && buf[0] == b'a' {
signals_set(1); // set SIGNALS[1]
if buf.len() > 1 && buf[1] == b'b' {
signals_set(2); // set SIGNALS[2]
if buf.len() > 2 && buf[2] == b'c' {
panic!("=)");
}
}
}
ExitKind::Ok
};
// To test the panic:
let input = BytesInput::new(Vec::from("abc"));
#[cfg(feature = "test-panic")]
harness(&input);
// Create an observation channel using the signals map
let observer = unsafe { ConstMapObserver::from_mut_ptr("signals", nonnull_raw_mut!(SIGNALS)) };
// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::new(&observer);
// A feedback to choose if an input is a solution or not
let mut objective = CrashFeedback::new();
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::new(),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
// on disk so the user can get them after stopping the fuzzer
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
&mut feedback,
&mut objective,
)
.unwrap();
// The Monitor trait defines how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{s}"));
// The event manager handles the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(mon);
// A queue policy to get testcasess from the corpus
let scheduler = QueueScheduler::new();
// A fuzzer with feedbacks and a corpus scheduler
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
// Create the executor for an in-process function with just one observer
let mut executor = InProcessExecutor::new(
&mut harness,
tuple_list!(observer),
&mut fuzzer,
&mut state,
&mut mgr,
)
.expect("Failed to create the Executor");
// Generator of printable bytearrays of max size 32
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
// Generate 8 initial inputs
state
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
.expect("Failed to generate the initial corpus");
/* ANCHOR: mutational_stage */
// Setup a mutational stage with a basic bytes mutator
let mutator = HavocScheduledMutator::new(havoc_mutations());
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
fuzzer
.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)
.expect("Error in the fuzzing loop");
/* ANCHOR_END: mutational_stage */
}

53
docs/src/DEBUGGING.md Normal file
View File

@ -0,0 +1,53 @@
# General debugging tips
This file answers some common questions that arise when you are writing a fuzzer using LibAFL.
## Q. My fuzzer crashed but the stack trace is useless
You can enable the `errors_backtrace` feature of the `libafl` crate. With this the stacktrace is meaningful.
## Q. I started the fuzzer but the corpus count is 0
Unless the initial corpus is loaded with the "load_initial_inputs_forced" function, we only store the interesting inputs, which is the inputs that triggered the feedback. So this usually means that your input was not interesting, or your target was simply not properly implemented.
Either way, what you can do is attach to the executable with gdb and set a breakpoint at where the new edges should be reported. If no instrumentation code is executed, then the problem is in the instrumentation. If the instrumentation code is hit, but still your input is not deemed interesting/stored, then the problem could be that you are not passing the observer/feedback correctly to the fuzzer.
## Q. I started the fuzzer but the coverage is 0
This could mean two things. Perhaps your target was not properly instrumented, or you are not using the correct observer, feedback feature.
In this case, again, what usually should do is to run the fuzzer with gdb and set a breakpoint at where the coverage is recorded (e.g. __sanitizer_coverage_trace_pcguard), and validate that the target is giving the feedback to the fuzzer.
## Q. I started the fuzzer but there's no output
First, verify that your stdout and stderr are not redirected to `/dev/null`. If you get the log, then it should either fall into the previous 2 cases. Either the fuzzer crashed because you didn't have the initial seeds, or the coverage feedback is not working.
## Q. I don't see any output from my fuzzer (println!() or logging)
First, check that you are not redirecting things to `/dev/null` else you will see nothing.
To see the log that you added with `log::trace!();`, you need to initialize the logger (any logger, `env_logger` or `SimpleStdoutLogger` from `libafl_bolts`) before the fuzzer starts.
Also you have to make sure that you are runing with `RUST_LOG=<log_level>` and you are *NOT* using `release_max_level_info` feature of `log` crate in your `Cargo.toml` of your fuzzer
## Q. My fuzzer is slow
Try running the fuzzer with the `introspection` feature of the `libafl`. This will show how much time is spent on each module of your fuzzer. Also you might be using a wrong size of the coverage map. If you see `2621440` for the size of the coverage map, you are doing it wrong. One possible mistake is the misuse of `libafl_targets::coverage::EDGES_MAP`
```rust
let map = StdMapObserver::from_mut_ptr("edges", EDGES_MAP.as_mut_ptr(), EDGES_MAP.len());
```
You should *never* use the `EDGES_MAP`'s size as this is just the size of the allocated size of the coverage map. Consider using something smaller or our default value `libafl_targets::LIBAFL_EDGES_MAP_DEFAULT_SIZE`.
## Q. I still have problems with my fuzzer
Finally, if you really have no idea what is going on, run your fuzzer with logging enabled. (You can use `env_logger`, `SimpleStdoutLogger`, `SimpleStderrLogger` from `libafl_bolts`. `fuzzbench_text` has an example to show how to use it.) (Don't forget to enable stdout and stderr), and you can open an issue or ask us in Discord.
## Q. My fuzzer died of `Storing state in crashed fuzzer instance did not work`
If the exit code is zero, then this is because either your harness exited or you are using fuzzer_loop_for and forgot to add `mgr.on_restart` at the end of the fuzzer. In the first case, you should patch your harness not to exit. (or use `utils/deexit`).
## Q. I can't leave the TUI screen
Type `q` to leave TUI.
## Q. I see `QEMU internal SIGSEGV {code=MAPERR, addr=0x48}` and my QEMU fuzzer doesn't run
Are you running QEMU fuzzer on WSL? You have to enable vsyscall <https://github.com/microsoft/WSL/issues/4694#issuecomment-556095344>.

View File

@ -25,6 +25,7 @@
- [Architecture](./design/architecture.md)
- [Metadata](./design/metadata.md)
- [Migrating from LibAFL <0.9 to 0.9](./design/migration-0.9.md)
- [Migrating from LibAFL <0.11 to 0.11](./design/migration-0.11.md)
- [Message Passing](./message_passing/message_passing.md)
- [Spawning Instances](./message_passing/spawn_instances.md)
@ -38,3 +39,4 @@
- [Concolic Tracing & Hybrid Fuzzing](./advanced_features/concolic.md)
- [LibAFL in `no_std` environments (Kernels, Hypervisors, ...)](./advanced_features/no_std.md)
- [Snapshot Fuzzing in Nyx](./advanced_features/nyx.md)
- [StatsD Monitor](./advanced_features/statsd_monitor.md)

View File

@ -1,7 +1,8 @@
# Concolic Tracing and Hybrid Fuzzing
LibAFL has support for concolic tracing based on the [SymCC](https://github.com/eurecom-s3/symcc) instrumenting compiler.
For those uninitiated, the following attempts to describe concolic tracing from the ground up using an example.
For those uninitiated, the following text attempts to describe concolic tracing from the ground up using an example.
Then, we'll go through the relationship of SymCC and LibAFL concolic tracing.
Finally, we'll walk through building a basic hybrid fuzzer using LibAFL.
@ -92,18 +93,18 @@ In hybrid fuzzing, we combine this tracing + solving approach with more traditio
The concolic tracing support in LibAFL is implemented using SymCC.
SymCC is a compiler plugin for clang that can be used as a drop-in replacement for a normal C or C++ compiler.
SymCC will instrument the compiled code with callbacks into a runtime that can be supplied by the user.
These callbacks allow the runtime to construct a trace that similar to the previous example.
These callbacks allow the runtime to construct a trace that is similar to the previous example.
### SymCC and its Runtimes
SymCC ships with 2 runtimes:
SymCC ships with 2 runtimes:
* a 'simple' runtime that attempts to solve any branches it comes across using [Z3](https://github.com/Z3Prover/z3/wiki) and
* a [QSym](https://github.com/sslab-gatech/qsym)-based runtime, which does a bit more filtering on the expressions and also solves using Z3.
* A 'simple' runtime that attempts to negate and analytically solve any branch conditions it comes across using [Z3](https://github.com/Z3Prover/z3/wiki) and
* A [QSym](https://github.com/sslab-gatech/qsym)-based runtime, which does a bit more filtering on the expressions and also solves them using Z3.
The integration with LibAFL, however, requires you to **BYORT** (_bring your own runtime_) using the [`symcc_runtime`](https://docs.rs/symcc_runtime/0.1/symcc_runtime) crate.
This crate allows you to easily build a custom runtime out of the built-in building blocks or create entirely new runtimes with full flexibility.
Checkout out the `symcc_runtime` docs for more information on how to build your own runtime.
Check out the `symcc_runtime` docs for more information on how to build your own runtime.
### SymQEMU
@ -114,7 +115,7 @@ The `symcc_runtime` crate supports this use case and runtimes built with `symcc_
## Hybrid Fuzzing in LibAFL
The LibAFL repository contains an [example hybrid fuzzer](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/libfuzzer_stb_image_concolic).
The LibAFL repository contains an [example hybrid fuzzer](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/structure_aware/libfuzzer_stb_image_concolic).
There are three main steps involved with building a hybrid fuzzer using LibAFL:
@ -123,21 +124,23 @@ There are three main steps involved with building a hybrid fuzzer using LibAFL:
3. building the fuzzer.
Note that the order of these steps is important.
For example, we need to have runtime ready before we can do instrumentation with SymCC.
For example, we need to have a runtime ready before we can do instrumentation with SymCC.
### Building a Runtime
Building a custom runtime can be done easily using the `symcc_runtime` crate.
Note, that a custom runtime is a separate shared object file, which means that we need a separate crate for our runtime.
Check out the [example hybrid fuzzer's runtime](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/libfuzzer_stb_image_concolic/runtime) and the [`symcc_runtime` docs](https://docs.rs/symcc_runtime/0.1/symcc_runtime) for inspiration.
Check out the [example hybrid fuzzer's runtime](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/structure_aware/libfuzzer_stb_image_concolic/runtime) and the [`symcc_runtime` docs](https://docs.rs/symcc_runtime/0.1/symcc_runtime) for inspiration.
### Instrumentation
There are two main instrumentation methods to make use of concolic tracing in LibAFL:
* Using an **compile-time** instrumented target with **SymCC**.
* Using a **compile-time** instrumented target with **SymCC**.
This only works when the source is available for the target and the target is reasonably easy to build using the SymCC compiler wrapper.
* Using **SymQEMU** to dynamically instrument the target at **runtime**.
This avoids a separate instrumented target with concolic tracing instrumentation and does not require source code.
This avoids building a separate instrumented target with concolic tracing instrumentation and so does not require source code.
It should be noted, however, that the 'quality' of the generated expressions can be significantly worse and SymQEMU generally produces significantly more and significantly more convoluted expressions than SymCC.
Therefore, it is recommended to use SymCC over SymQEMU when possible.
@ -148,7 +151,7 @@ How exactly this is done does not matter.
However, the SymCC compiler needs to be made aware of the location of the runtime that it should instrument against.
This is done by setting the `SYMCC_RUNTIME_DIR` environment variable to the directory which contains the runtime (typically the `target/(debug|release)` folder of your runtime crate).
The example hybrid fuzzer instruments the target in its [`build.rs` build script](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/libfuzzer_stb_image_concolic/fuzzer/build.rs#L50).
The example hybrid fuzzer instruments the target in its [`build.rs` build script](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/structure_aware/libfuzzer_stb_image_concolic/fuzzer/build.rs#L50).
It does this by cloning and building a copy of SymCC and then using this version to instrument the target.
The [`symcc_libafl` crate](https://docs.rs/symcc_libafl) contains helper functions for cloning and building SymCC.
@ -158,27 +161,27 @@ Make sure you satisfy the [build requirements](https://github.com/eurecom-s3/sym
Build SymQEMU according to its [build instructions](https://github.com/eurecom-s3/symqemu#readme).
By default, SymQEMU looks for the runtime in a sibling directory.
Since we don't have a runtime there, we need to let it know the path to your runtime by setting `--symcc-build` argument of the `configure` script to the path of your runtime.
Since we don't have a runtime there, we need to explicitly set the `--symcc-build` argument of the `configure` script to the path of your runtime.
### Building the Fuzzer
No matter the instrumentation method, the interface between the fuzzer and the instrumented target should now be consistent.
The only difference between using SymCC and SymQEMU should be the binary that represents the target:
In the case of SymCC it will be the binary that was build with instrumentation and with SymQEMU it will be the emulator binary (eg. `x86_64-linux-user/symqemu-x86_64`), followed by your uninstrumented target binary and arguments.
In the case of SymCC it will be the binary that was build with instrumentation and with SymQEMU it will be the emulator binary (eg. `x86_64-linux-user/symqemu-x86_64`), followed by your uninstrumented target binary and its arguments.
You can use the [`CommandExecutor`](https://docs.rs/libafl/0.6.0/libafl/executors/command/struct.CommandExecutor.html) to execute your target ([example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs#L244)).
When configuring the command, make sure you pass the `SYMCC_INPUT_FILE` environment variable the input file path, if your target reads input from a file (instead of standard input).
You can use the [`CommandExecutor`](https://docs.rs/libafl/latest/libafl/executors/command/struct.CommandExecutor.html) to execute your target ([example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/structure_aware/libfuzzer_stb_image_concolic/fuzzer/src/main.rs#L244)).
When configuring the command, make sure you pass the `SYMCC_INPUT_FILE` environment variable (set to the input file path), if your target reads input from a file (instead of standard input).
#### Serialization and Solving
While it is perfectly possible to build a custom runtime that also performs the solving step of hybrid fuzzing in the context of the target process, the intended use of the LibAFL concolic tracing support is to serialize the (filtered and pre-processed) branch conditions using the [`TracingRuntime`](https://docs.rs/symcc_runtime/0.1/symcc_runtime/tracing/struct.TracingRuntime.html).
This serialized representation can be deserialized in the fuzzer process for solving using a [`ConcolicObserver`](https://docs.rs/libafl/0.6.0/libafl/observers/concolic/struct.ConcolicObserver.html) wrapped in a [`ConcolicTracingStage`](https://docs.rs/libafl/0.6.0/libafl/stages/concolic/struct.ConcolicTracingStage.html), which will attach a [`ConcolicMetadata`](https://docs.rs/libafl/0.6.0/libafl/observers/concolic/struct.ConcolicMetadata.html) to every [`TestCase`](https://docs.rs/libafl/0.6.0/libafl/corpus/testcase/struct.Testcase.html).
This serialized representation can be deserialized in the fuzzer process for solving using a [`ConcolicObserver`](https://docs.rs/libafl/latest/libafl/observers/concolic/struct.ConcolicObserver.html) wrapped in a [`ConcolicTracingStage`](https://docs.rs/libafl/latest/libafl/stages/concolic/struct.ConcolicTracingStage.html), which will attach a [`ConcolicMetadata`](https://docs.rs/libafl/latest/libafl/observers/concolic/struct.ConcolicMetadata.html) to every [`TestCase`](https://docs.rs/libafl/latest/libafl/corpus/testcase/struct.Testcase.html).
The `ConcolicMetadata` can be used to replay the concolic trace and solved using an SMT-Solver.
The `ConcolicMetadata` can be used to replay the concolic trace and to solve the conditions using an SMT-Solver.
Most use-cases involving concolic tracing, however, will need to define some policy around which branches they want to solve.
The [`SimpleConcolicMutationalStage`](https://docs.rs/libafl/0.6.0//libafl/stages/concolic/struct.SimpleConcolicMutationalStage.html) can be used for testing purposes.
The [`SimpleConcolicMutationalStage`](https://docs.rs/libafl/latest/libafl/stages/concolic/struct.SimpleConcolicMutationalStage.html) can be used for testing purposes.
It will attempt to solve all branches, like the original simple backend from SymCC, using Z3.
### Example
The example fuzzer shows how to use the [`ConcolicTracingStage` together with the `SimpleConcolicMutationalStage`](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs#L222) to build a basic hybrid fuzzer.
The example fuzzer shows how to use the [`ConcolicTracingStage` together with the `SimpleConcolicMutationalStage`](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/structure_aware/libfuzzer_stb_image_concolic/fuzzer/src/main.rs#L222) to build a basic hybrid fuzzer.

View File

@ -4,7 +4,7 @@ LibAFL supports different instrumentation engines for binary-only fuzzing.
A potent cross-platform (Windows, MacOS, Android, Linux, iOS) option for binary-only fuzzing is Frida; the dynamic instrumentation tool.
In this section, we will talk about the components in fuzzing with `libafl_frida`.
You can take a look at a working example in our [`fuzzers/frida_libpng`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/frida_libpng) folder for Linux, and [`fuzzers/frida_gdiplus`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/frida_gdiplus) for Windows.
You can take a look at a working example in our [`fuzzers/binary_only/frida_libpng`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/binary_only/frida_libpng) folder for Linux, and [`fuzzers/binary_only/frida_windows_gdiplus`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/binary_only/frida_windows_gdiplus) for Windows.
## Dependencies
@ -17,7 +17,7 @@ If you are on Windows, you'll need to install llvm tools.
LibAFL uses Frida's [__Stalker__](https://frida.re/docs/stalker/) to trace the execution of your program and instrument your harness.
Thus, you have to compile your harness to a dynamic library. Frida instruments your PUT after dynamically loading it.
For example in our `frida_libpng` example, we load the dynamic library and find the symbol to harness as follows:
In our `frida_libpng` example, we load the dynamic library and find the symbol to harness as follows:
```rust,ignore
let lib = libloading::Library::new(module_name).unwrap();
@ -28,9 +28,9 @@ For example in our `frida_libpng` example, we load the dynamic library and find
## `FridaInstrumentationHelper` and Runtimes
To use functionalities that Frida offers, we'll first need to obtain `Gum` object by `Gum::obtain()`.
To use functionalities that Frida offers, we'll first need to obtain a `Gum` object by `Gum::obtain()`.
In LibAFL, we use the `FridaInstrumentationHelper` struct to manage frida-related state. `FridaInstrumentationHelper` is a key component that sets up the [__Transformer__](https://frida.re/docs/stalker/#transformer) that is used to generate the instrumented code. It also initializes the `Runtimes` that offer various instrumentation.
In LibAFL, we use the `FridaInstrumentationHelper` struct to manage frida-related state. `FridaInstrumentationHelper` is a key component that sets up the [__Transformer__](https://frida.re/docs/stalker/#transformer) that is used to generate the instrumented code. It also initializes the `Runtimes` that offer various instrumentations.
We have `CoverageRuntime` that can track the edge coverage, `AsanRuntime` for address sanitizer, `DrCovRuntime` that uses [__DrCov__](https://dynamorio.org/page_drcov.html) for coverage collection (to be imported in coverage tools like Lighthouse, bncov, dragondance,...), and `CmpLogRuntime` for cmplog instrumentation.
All of these runtimes can be slotted into `FridaInstrumentationHelper` at build time.
@ -53,12 +53,12 @@ Combined with any `Runtime` you'd like to use, you can initialize the `FridaInst
## Running the Fuzzer
After setting up the `FridaInstrumentationHelper`. You can obtain the pointer to the coverage map by calling `map_ptr_mut()`.
After setting up the `FridaInstrumentationHelper` you can obtain the pointer to the coverage map by calling `map_mut_ptr()`.
```rust,ignore
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new_from_ptr(
let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr(
"edges",
frida_helper.map_ptr_mut().unwrap(),
frida_helper.map_mut_ptr().unwrap(),
MAP_SIZE,
));
```
@ -73,7 +73,7 @@ You can then link this observer to `FridaInProcessExecutor` as follows:
tuple_list!(
edges_observer,
time_observer,
AsanErrorsObserver::new(&ASAN_ERRORS)
AsanErrorsObserver::from_static_asan_errors()
),
&mut fuzzer,
&mut state,
@ -83,5 +83,5 @@ You can then link this observer to `FridaInProcessExecutor` as follows:
);
```
And, finally you can run the fuzzer.
See the `frida_` examples in [`./fuzzers`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/) for more information and, for linux or full-system, play around with `libafl_qemu`, another binary-only tracer.
And finally you can run the fuzzer.
See the `frida_` examples in [`./fuzzers/binary_only`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/binary_only/) for more information and, for linux or full-system, play around with `libafl_qemu`, another binary_only tracer.

View File

@ -1,6 +1,6 @@
# Using LibAFL in `no_std` environments
It is possible to use LibAFL in `no_std` environments e.g. custom platforms like microcontrollers, kernels, hypervisors, and more.
It is possible to use LibAFL in `no_std` environments e.g. on custom platforms like microcontrollers, kernels, hypervisors, and more.
You can simply add LibAFL to your `Cargo.toml` file:
@ -16,7 +16,7 @@ cargo build --no-default-features --target aarch64-unknown-none
## Use custom timing
The minimum amount of input LibAFL needs for `no_std` is a monotonically increasing timestamp.
The minimum amount of support LibAFL needs for a `no_std` environment is a monotonically increasing timestamp.
For this, anywhere in your project you need to implement the `external_current_millis` function, which returns the current time in milliseconds.
```c
@ -31,10 +31,10 @@ Here, we use it in Rust. `external_current_millis` is then called from LibAFL.
Note that it needs to be `no_mangle` in order to get picked up by LibAFL at linktime:
```rust,ignore
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn external_current_millis() -> u64 {
unsafe { my_real_seconds()*1000 }
}
```
See [./fuzzers/baby_no_std](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby_no_std) for an example.
See [./fuzzers/fuzz_anything/baby_no_std](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/fuzz_anything/baby_no_std) for an example.

View File

@ -2,12 +2,12 @@
NYX supports both source-based and binary-only fuzzing.
Currently, `libafl_nyx` only supports [afl++](https://github.com/AFLplusplus/AFLplusplus)'s instruction. To install it, you can use `sudo apt install aflplusplus`. Or compile from the source:
Currently, `libafl_nyx` only supports [afl++](https://github.com/AFLplusplus/AFLplusplus)'s instruction type. To install it, you can use `sudo apt install aflplusplus`. Or compile from the source:
```bash
git clone https://github.com/AFLplusplus/AFLplusplus
cd AFLplusplus
make all # this will not compile afl's additional extension
make all # this will not compile afl's additional extensions
```
Then you should compile the target with the afl++ compiler wrapper:
@ -20,11 +20,11 @@ export CXX=afl-clang-fast++
make
```
For binary-only fuzzing, Nyx uses intel-PT(Intel® Processor Trace). You can find the supported CPU at <https://www.intel.com/content/www/us/en/support/articles/000056730/processors.html>.
For binary-only fuzzing, Nyx uses intel-PT(Intel® Processor Trace). You can find the list of supported CPUs at <https://www.intel.com/content/www/us/en/support/articles/000056730/processors.html>.
## Preparing Nyx working directory
## Preparing the Nyx working directory
This step is used to pack the target into Nyx's kernel. Don't worry, we have a template shell script in our [example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_parallel/setup_libxml2.sh):
This step is used to pack the target into Nyx's kernel. Don't worry, we have a template shell script in our [example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/full_system/nyx_libxml2_parallel/setup_libxml2.sh):
the parameter's meaning is listed below:
@ -49,7 +49,7 @@ python3 ./packer/packer/nyx_config_gen.py /tmp/nyx_libxml2/ Kernel || exit
## Standalone fuzzing
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_standalone/src/main.rs). First you need to run `./setup_libxml2.sh`, It will prepare your target and create your nyx work directory in `/tmp/libxml2`. After that, you can start write your code.
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/full_system/nyx_libxml2_standalone/src/main.rs) you first need to run `./setup_libxml2.sh`. It will prepare your target and create your nyx work directory in `/tmp/libxml2`. After that, you can start to write your code.
First, to create `Nyxhelper`:
@ -57,22 +57,21 @@ First, to create `Nyxhelper`:
let share_dir = Path::new("/tmp/nyx_libxml2/");
let cpu_id = 0; // use first cpu
let parallel_mode = false; // close parallel_mode
let mut helper = NyxHelper::new(share_dir, cpu_id, true, parallel_mode, None).unwrap(); // we don't the set the last parameter in standalone mode, we just use None, here
let mut helper = NyxHelper::new(share_dir, cpu_id, true, parallel_mode, None).unwrap(); // we don't need to set the last parameter in standalone mode, we just use None, here
```
Then, fetch `trace_bits`, create an observer and the `NyxExecutor`:
```rust,ignore
let trace_bits = unsafe { std::slice::from_raw_parts_mut(helper.trace_bits, helper.map_size) };
let observer = StdMapObserver::new("trace", trace_bits);
let observer = unsafe { StdMapObserver::from_mut_ptr("trace", helper.trace_bits, helper.map_size) };
let mut executor = NyxExecutor::new(&mut helper, tuple_list!(observer)).unwrap();
```
Finally, use them as normal and pass them into `fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)` to start fuzzing.
Finally, use them normally and pass them into `fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)` to start fuzzing.
## Parallel fuzzing
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_parallel/src/main.rs). First you need to run `./setup_libxml2.sh` as described before.
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/full_system/nyx_libxml2_parallel/src/main.rs) you first need to run `./setup_libxml2.sh` as described before.
Parallel fuzzing relies on [`Launcher`](../message_passing/spawn_instances.md), so spawn logic should be written in the scoop of anonymous function `run_client`:
@ -91,7 +90,7 @@ let mut helper = NyxHelper::new(
cpu_id, // current cpu id
true, // open snap_mode
parallel_mode, // open parallel mode
Some(parent_cpu_id.id as u32), // the cpu-id of master instance, there is only one master instance, other instances will be treated as slaved
Some(parent_cpu_id.id as u32), // the cpu-id of main instance, there is only one main instance, other instances will be treated as secondaries
)
.unwrap();
```
@ -99,13 +98,11 @@ let mut helper = NyxHelper::new(
Then you can fetch the trace_bits and create an observer and `NyxExecutor`
```rust,ignore
let trace_bits =
unsafe { std::slice::from_raw_parts_mut(helper.trace_bits, helper.map_size) };
let observer = StdMapObserver::new("trace", trace_bits);
let observer = unsafe { StdMapObserver::from_mut_ptr("trace", helper.trace_bits, helper.map_size) }
let mut executor = NyxExecutor::new(&mut helper, tuple_list!(observer)).unwrap();
```
Finally, open a `Launcher` as normal to start fuzzing:
Finally, open a `Launcher` as usual to start fuzzing:
```rust,ignore
match Launcher::builder()
@ -121,6 +118,6 @@ match Launcher::builder()
{
Ok(()) => (),
Err(Error::ShuttingDown) => println!("Fuzzing stopped by user. Good bye."),
Err(err) => panic!("Failed to run launcher: {:?}", err),
Err(err) => panic!("Failed to run launcher: {err:?}"),
}
```

View File

@ -0,0 +1,185 @@
# StatsD Monitor
In modern fuzzing situations, it is very common to have multiple fuzzing instances running. LibAFL supports monitoring mutiple fuzzing instances with `StatsdMonitor`, which can be easily enabled by adding `statsd_monitor` feature in `Cargo.toml`:
```toml
[dependencies]
libafl = { version = "*", features = ["statsd_monitor"]}
```
After setting up a StatsD monitor infrastructure, you could view all of your fuzzing instances in a browser like this one (each line represents metrics of one fuzzing instance).
![example visualization with Grafana](../resources/statsd-grafana.png)
## Introduction to StatsD Architecture
A typical StatsD setup involves four participants: multiple StatsD clients, a StatsD aggregator, a Prometheus, and a visualizer.
Normally, each fuzzing instance is bound to a StatsD client (the `StatsdMonitor`). The StatsD client pushes fuzzing metrics (e.g. exec per second) towards the StatsD aggregator consistently. The Prometheus server is the center of StatsD metrics, which polls StatsD metrics from the StatsD aggregator at a specific polling frequency. The visualizer queries the Prometheus server, and display the metrics for further analysis and monitoring.
## Set up a StatsD Monitor Infrastructure
The easiest way to install and set up the infrastructure is with Docker and Docker Compose. To begin with, create a directory with the following files:
* `docker-compose.yml`
```yml
networks:
statsd-net:
driver: bridge
volumes:
grafana-data:
services:
prometheus:
image: prom/prometheus
container_name: prometheus
volumes:
- ./prometheus.yml:/prometheus.yml
command:
- '--config.file=/prometheus.yml'
restart: unless-stopped
ports:
- "9090:9090"
networks:
- statsd-net
statsd_exporter:
image: prom/statsd-exporter
container_name: statsd_exporter
volumes:
- ./statsd_mapping.yml:/statsd_mapping.yml
command:
- "--statsd.mapping-config=/statsd_mapping.yml"
ports:
- "9102:9102/tcp"
- "8125:9125/udp"
networks:
- statsd-net
grafana:
image: grafana/grafana
container_name: grafana
volumes:
- grafana-data:/var/lib/grafana
restart: unless-stopped
ports:
- "3000:3000"
networks:
- statsd-net
```
* `prometheus.yml`
```yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'fuzzing_metrics'
static_configs:
- targets: ['statsd_exporter:9102']
```
* `statsd_mapping.yml`
```yml
mappings:
- match: "fuzzing.*"
name: "fuzzing"
labels:
type: "$1"
```
And use
```shell
docker compose up -d
```
Then the basic infrastructure is set up.
It is worth noting that all participants are not necessarily be in the same machine, as long as they could communicate with each other with network. Specifically, the StatsD aggregator should be accessible from StatsD clients and Prometheus server, and the Prometheus server should be accessible from the visualizer.
In this infrastructure setup, we choose the [prometheus/statsd-exporter](https://github.com/prometheus/statsd_exporter) as a StatsD aggregator, which aggregates metrics from multiple StatsD clients, and converts the metrics into Prometheus format. And we choose the [Grafana](https://grafana.com) as the visualizer.
### Configure Grafana
After the infrastructure is set up, you should use a browser and go to `localhost:3000` to configure Grafana, the visualizer, and view StatsD metrics (the default username and password for Grafana docker login is admin/admin).
First, you should add the Prometheus server as data source for Grafana, as described in [Add a data source](https://grafana.com/docs/grafana/latest/datasources/#add-a-data-source). By picking "Prometheus" as datasource type, you could create a data source with name "prometheus", and use `http://prometheus:9090` as Prometheus server URL (Docker network could automatically resolve the host name to the IP of prometheus service, and the port is specified at `docker-compose.yml` above).
Then, you should create a dashboard to view the metrics. You could simply importing [this dashboard template](../resources/grafana-libafl.json), or create a dashboard manually by following [this official guide](https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/create-dashboard/#create-a-dashboard).
After the dashboard is created, all metrics can be viewed directly.
## Use `StatsdMonitor` in LibAFL
It is rather easy to use the `StatsdMonitor` in LibAFL. Let's say you were using a `MultiMonitor` previously:
```rust,ignore
let monitor = MultiMonitor::new(|s| println!("{s}"));
```
Then you could just create a `StatsdMonitor` and combine this two monitors with a `tuple_list!`:
```rust,ignore
let multi_monitor = MultiMonitor::new(|s| println!("{s}"));
let statsd_monitor = StatsdMonitor::new("localhost".to_string(), 8125, StatsdMonitorTagFlavor::default());
let monitor = tuple_list!(multi_monitor, statsd_monitor);
```
Then the monitor will automatically push StatsD metrics towards the StatsD aggregator at localhost:8125, which is specified in the `docker-compose.yml` above.
### Tag Flavor
The vanilla StatsD metrics do not have a mechanism to distinguish different StatsD clients, which is inconvenience to view multiple fuzzing instances. Several StatsD servers have introduced a new mechanism called tag to solve this problem, and in LibAFL, we currently support [Datadog](https://docs.datadoghq.com/developers/dogstatsd/) style tag, which is the default for `StatsdMonitorTagFlavor`.
To use tag correctly, we should create a `StatsdMonitorTagFlavor` with a tag identifier and optional custom tags.
```rust,ignore
let tag_flavor = StatsdMonitorTagFlavor::DogStatsd {
tag_identifier: "unique-name-for-this-fuzzing-instance".into(),
custom_tags: vec![
("custom-tag-key".into(), "custom-tag-value".into())
],
};
let statsd_monitor = StatsdMonitor::new("localhost".to_string(), 8125, tag_flavor);
```
The tag identifier is used to differentiate StatsD clients, which should be unique for each fuzzing instances. The optional custom tags could be used by Grafana users to filter clients based on custom informations.
## FAQ
### What can I do if I cannot see any metrics in Grafana?
To debug the `StatsdMonitor`, you could first comment out all other monitors for clarity. The you could setup a log implementation such as [`env_logger`](https://crates.io/crates/env_logger) at the top of your `main` function. For `env_logger`, run the target application with environment `RUST_LOG=info`, and you could see logs from LibAFL. The output logs should contain error logs of `StatsdMonitor` if connection is down or anything unexpected.
If you still have no idea why things went wrong, please [file an issue](https://github.com/AFLplusplus/LibAFL/issues/new/choose) to LibAFL.
### Does network interactions of StatsD decrease the fuzzing throughput?
Thanks to the [`cadence`](https://crates.io/crates/cadence) crate which we used as StatsD client implementation, the network interaction is conduct in an individual thread, so the affect from network interactions could be negligible.
### Can I optionally enable the `StatsdMonitor` via something like commandline options?
You can wrap the `StatsdMonitor` with an `OptionalMonitor`:
```rust,ignore
let statsd_monitor = if commandline_is_set {
Some(StatsdMonitor::new(/* ... */))
} else {
None
};
let optional_statsd_monitor = OptionalMonitor::new(statsd_monitor);
```
### What is the different between `StatsdMonitor` and `PrometheusMonitor`?
The `PrometheusMonitor` could be used to view detailed statistics about one fuzzing instance (with multiple clients maybe), since it can show the statistics about individual clients. And `PrometheusMonitor` is implemented as a Prometheus datasource, which will, based on the pull-architecture of Prometheus, occupy a port for each instance for Prometheus server to access.
The `StatsdMonitor` is used to view aggregated statistics about multiple fuzzing instances (showing individual client statistics will make the visualized graph very distracting). And due to the push-architecture of StatsD server, we only need one port for the StatsD aggregator to receive metrics from each client.
## References
* [AFL++'s docs about rpc_statsd](https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/rpc_statsd.md)
* [Prometheus wikipedia](https://en.wikipedia.org/wiki/Prometheus_(software))

View File

@ -6,7 +6,7 @@ While the following chapters discuss the components of LibAFL in detail, here we
We are going to fuzz a simple Rust function that panics under a condition. The fuzzer will be single-threaded and will stop after the crash, just like libFuzzer normally does.
You can find a complete version of this tutorial as an example fuzzer in [`fuzzers/baby_fuzzer`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby_fuzzer).
You can find a complete version of this tutorial as an example fuzzer in [`fuzzers/baby/baby_fuzzer`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby/baby_fuzzer).
> ### Warning
>
@ -17,7 +17,7 @@ You can find a complete version of this tutorial as an example fuzzer in [`fuzze
We use cargo to create a new Rust project with LibAFL as a dependency.
```sh
```console
$ cargo new baby_fuzzer
$ cd baby_fuzzer
```
@ -25,18 +25,11 @@ $ cd baby_fuzzer
The generated `Cargo.toml` looks like the following:
```toml
[package]
name = "baby_fuzzer"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
{{#include ../../listings/baby_fuzzer/listing-01/Cargo.toml}}
```
In order to use LibAFl we must add it as dependency adding `libafl = { path = "path/to/libafl/" }` under `[dependencies]`.
That path actually needs to point to the `libafl` directory within the cloned repo, not the root of the repo itself.
You can use the LibAFL version from [crates.io](https://crates.io/crates/libafl) if you want, in this case, you have to use `libafl = "*"` to get the latest version (or set it to the current version).
As we are going to fuzz Rust code, we want that a panic does not simply cause the program to exit, but raise an `abort` that can then be caught by the fuzzer.
@ -47,28 +40,10 @@ Alongside this setting, we add some optimization flags for the compilation, when
The final `Cargo.toml` should look similar to the following:
```toml
[package]
name = "baby_fuzzer"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libafl = { path = "path/to/libafl/" }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
lto = true
codegen-units = 1
opt-level = 3
debug = true
{{#include ../../listings/baby_fuzzer/listing-02/Cargo.toml}}
```
## The function under test
Opening `src/main.rs`, we have an empty `main` function.
@ -76,52 +51,32 @@ To start, we create the closure that we want to fuzz. It takes a buffer as input
`ExitKind` is used to inform the fuzzer about the harness' exit status.
```rust
extern crate libafl;
use libafl::{
bolts::AsSlice,
inputs::{BytesInput, HasTargetBytes},
executors::ExitKind,
};
fn main(){
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
if buf.len() > 0 && buf[0] == 'a' as u8 {
if buf.len() > 1 && buf[1] == 'b' as u8 {
if buf.len() > 2 && buf[2] == 'c' as u8 {
panic!("=)");
}
}
}
ExitKind::Ok
};
// To test the panic:
let input = BytesInput::new(Vec::from("abc"));
#[cfg(feature = "panic")]
harness(&input);
}
{{#rustdoc_include ../../listings/baby_fuzzer/listing-03/src/main.rs}}
```
To test the crash manually, you can add a feature in `Cargo.toml` that enables the call that triggers the panic:
```toml
{{#include ../../listings/baby_fuzzer/listing-03/Cargo.toml:23:25}}
```
And then run the program with that feature activated:
```console
$ cargo run -F panic
```
And you should see the program crash as expected.
## Generating and running some tests
One of the main components that a LibAFL-based fuzzer uses is the State, a container of the data that is evolved during the fuzzing process.
Includes all State, such as the Corpus of inputs, the current RNG state, and potential Metadata for the testcases and run.
One of the main components that a LibAFL-based fuzzer uses is the State, a container of the data that will evolve during the fuzzing process.
It includes all state, such as the Corpus of inputs, the current RNG state, and potential Metadata for the testcases and run.
In our `main` we create a basic State instance like the following:
```rust,ignore
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
// on disk so the user can get them after stopping the fuzzer
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
&mut (),
&mut ()
).unwrap();
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:state}}
```
- The first parameter is a random number generator, that is part of the fuzzer state, in this case, we use the default one `StdRand`, but you can choose a different one. We seed it with the current nanoseconds.
@ -129,43 +84,26 @@ let mut state = StdState::new(
To avoid type annotation error, you can use `InMemoryCorpus::<BytesInput>::new()` to replace `InMemoryCorpus::new()`. If not, type annotation will be automatically inferred when adding `executor`.
- third parameter is another corpus that stores the "solution" testcases for the fuzzer. For our purpose, the solution is the input that triggers the panic. In this case, we want to store it to disk under the `crashes` directory, so we can inspect it.
- last two parameters are feedback and objective, we will discuss them later.
- The third parameter is another Corpus that stores the "solution" testcases for the fuzzer. For our purpose, the solution is the input that triggers the panic. In this case, we want to store it to disk under the `crashes` directory, so we can inspect it.
- The last two parameters are feedback and objective, we will discuss them later.
Another required component is the **EventManager**. It handles some events such as the addition of a testcase to the corpus during the fuzzing process. For our purpose, we use the simplest one that just displays the information about these events to the user using a `Monitor` instance.
```rust,ignore
// The Monitor trait defines how the fuzzer stats are displayed to the user
let mon = SimpleMonitor::new(|s| println!("{}", s));
// The event manager handle the various events generated during the fuzzing loop
// such as the notification of the addition of a new item to the corpus
let mut mgr = SimpleEventManager::new(mon);
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:event_manager}}
```
In addition, we have the **Fuzzer**, an entity that contains some actions that alter the State. One of these actions is the scheduling of the testcases to the fuzzer using a **Scheduler**.
We create it as `QueueScheduler`, a scheduler that serves testcases to the fuzzer in a FIFO fashion.
```rust,ignore
// A queue policy to get testcasess from the corpus
let scheduler = QueueScheduler::new();
// A fuzzer with feedbacks and a corpus scheduler
let mut fuzzer = StdFuzzer::new(scheduler, (), ());
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:scheduler_fuzzer}}
```
Last but not least, we need an **Executor** that is the entity responsible to run our program under test. In this example, we want to run the harness function in-process (without forking off a child, for example), and so we use the `InProcessExecutor`.
```rust,ignore
// Create the executor for an in-process function
let mut executor = InProcessExecutor::new(
&mut harness,
(),
&mut fuzzer,
&mut state,
&mut mgr,
)
.expect("Failed to create the Executor");
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:executor}}
```
It takes a reference to the harness, the state, and the event manager. We will discuss the second parameter later.
@ -175,41 +113,19 @@ Now we have the 4 major entities ready for running our tests, but we still canno
For this purpose, we use a **Generator**, `RandPrintablesGenerator` that generates a string of printable bytes.
```rust,ignore
use libafl::generators::RandPrintablesGenerator;
// Generator of printable bytearrays of max size 32
let mut generator = RandPrintablesGenerator::new(32);
// Generate 8 initial inputs
state
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
.expect("Failed to generate the initial corpus".into());
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:generator}}
```
Now you can prepend the necessary `use` directives to your main.rs and compile the fuzzer.
```rust
extern crate libafl;
use std::path::PathBuf;
use libafl::{
bolts::{AsSlice, current_nanos, rands::StdRand},
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::{inprocess::InProcessExecutor, ExitKind},
fuzzer::StdFuzzer,
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
schedulers::QueueScheduler,
state::StdState,
};
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:use}}
```
When running, you should see something similar to:
```sh
```console
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/baby_fuzzer`
@ -225,60 +141,22 @@ Now we want to turn our simple fuzzer into a feedback-based one and increase the
**Observer** can record the information about properties of a fuzzing run and then feeds the fuzzer. We use the `StdMapObserver`, the default observer that uses a map to keep track of covered elements. In our fuzzer, each condition is mapped to an entry of such map.
We represent such map as a `static mut` variable.
As we don't rely on any instrumentation engine, we have to manually track the satisfied conditions by `singals_set` in our harness:
As we don't rely on any instrumentation engine, we have to manually track the satisfied conditions by `signals_set` in our harness:
```rust
extern crate libafl;
use libafl::{
bolts::AsSlice,
inputs::{BytesInput, HasTargetBytes},
executors::ExitKind,
};
// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
fn signals_set(idx: usize) {
unsafe { SIGNALS[idx] = 1 };
}
// The closure that we want to fuzz
let mut harness = |input: &BytesInput| {
let target = input.target_bytes();
let buf = target.as_slice();
signals_set(0); // set SIGNALS[0]
if buf.len() > 0 && buf[0] == 'a' as u8 {
signals_set(1); // set SIGNALS[1]
if buf.len() > 1 && buf[1] == 'b' as u8 {
signals_set(2); // set SIGNALS[2]
if buf.len() > 2 && buf[2] == 'c' as u8 {
panic!("=)");
}
}
}
ExitKind::Ok
};
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:signals}}
```
The observer can be created directly from the `SIGNALS` map, in the following way:
```rust,ignore
// Create an observation channel using the signals map
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:observer}}
```
The observers are usually kept in the corresponding executor as they keep track of information that is valid for just one run. We have then to modify our InProcessExecutor creation to include the observer as follows:
```rust,ignore
// Create the executor for an in-process function with just one observer
let mut executor = InProcessExecutor::new(
&mut harness,
tuple_list!(observer),
&mut fuzzer,
&mut state,
&mut mgr,
)
.expect("Failed to create the Executor".into());
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:executor_with_observer}}
```
Now that the fuzzer can observe which condition is satisfied, we need a way to rate an input as interesting (i.e. worth of addition to the corpus) based on this observation. Here comes the notion of Feedback.
@ -287,49 +165,23 @@ Now that the fuzzer can observe which condition is satisfied, we need a way to r
We use `MaxMapFeedback`, a feedback that implements a novelty search over the map of the MapObserver. Basically, if there is a value in the observer's map that is greater than the maximum value registered so far for the same entry, it rates the input as interesting and updates its state.
**Objective Feedback** is another kind of Feedback which decide if an input is a "solution". It will save input to solutions(`./crashes` in our case) other than corpus when the input is rated interesting. We use `CrashFeedback` to tell the fuzzer that if an input causes the program to crash it is a solution for us.
**Objective Feedback** is another kind of Feedback which decides if an input is a "solution". It will save input to solutions(`./crashes` in our case) rather than corpus when the input is rated interesting. We use `CrashFeedback` to tell the fuzzer that if an input causes the program to crash it is a solution for us.
We need to update our State creation including the feedback state and the Fuzzer including the feedback and the objective:
```rust,ignore
extern crate libafl;
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
corpus::{InMemoryCorpus, OnDiskCorpus},
feedbacks::{MaxMapFeedback, CrashFeedback},
fuzzer::StdFuzzer,
state::StdState,
observers::StdMapObserver,
};
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:state_with_feedback_and_objective}}
```
// Feedback to rate the interestingness of an input
let mut feedback = MaxMapFeedback::new(&observer);
Once again, you need to add the necessary `use` directives for this to work properly:
// A feedback to choose if an input is a solution or not
let mut objective = CrashFeedback::new();
// create a State from scratch
let mut state = StdState::new(
// RNG
StdRand::with_seed(current_nanos()),
// Corpus that will be evolved, we keep it in memory for performance
InMemoryCorpus::new(),
// Corpus in which we store solutions (crashes in this example),
// on disk so the user can get them after stopping the fuzzer
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
&mut feedback,
&mut objective
).unwrap();
// ...
// A fuzzer with feedbacks and a corpus scheduler
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
```rust
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:use}}
```
## The actual fuzzing
Now, after including the correct `use`, we can run the program, but the outcome is not so different from the previous one as the random generator does not take into account what we save as interesting in the corpus. To do that, we need to plug a Mutator.
Now, we can run the program, but the outcome is not so different from the previous one as the random generator does not take into account what we save as interesting in the corpus. To do that, we need to plug a Mutator.
**Stages** perform actions on individual inputs, taken from the corpus.
For instance, the `MutationalStage` executes the harness several times in a row, every time with mutated inputs.
@ -337,28 +189,20 @@ For instance, the `MutationalStage` executes the harness several times in a row,
As the last step, we create a MutationalStage that uses a mutator inspired by the havoc mutator of AFL.
```rust,ignore
use libafl::{
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
stages::mutational::StdMutationalStage,
fuzzer::Fuzzer,
};
// ...
// Setup a mutational stage with a basic bytes mutator
let mutator = StdScheduledMutator::new(havoc_mutations());
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
fuzzer
.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)
.expect("Error in the fuzzing loop");
{{#rustdoc_include ../../listings/baby_fuzzer/listing-06/src/main.rs:mutational_stage}}
```
`fuzz_loop` will request a testcase for each iteration to the fuzzer using the scheduler and then it will invoke the stage.
After adding this code, we have a proper fuzzer, that can run a find the input that panics the function in less than a second.
Again, we need to add the new `use` directives:
```text
```rust,ignore
{{#rustdoc_include ../../listings/baby_fuzzer/listing-06/src/main.rs:use}}
```
After adding this code, we have a proper fuzzer, that can run and find the input that panics the function in less than a second.
```console
$ cargo run
Compiling baby_fuzzer v0.1.0 (/home/andrea/Desktop/baby_fuzzer)
Finished dev [unoptimized + debuginfo] target(s) in 1.56s
@ -378,4 +222,4 @@ Bye!
As you can see, after the panic message, the `objectives` count of the log increased by one and you will find the crashing input in `crashes/`.
The complete code can be found in [`./fuzzers/baby_fuzzer`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby_fuzzer) alongside other `baby_` fuzzers.
The complete code can be found in [`./fuzzers/baby/baby_fuzzer`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby/baby_fuzzer) alongside other `baby_` fuzzers.

View File

@ -1,6 +1,6 @@
# More Examples
Examples can be found under `./fuzzer`.
Examples can be found under `./fuzzers/baby`.
|fuzzer name|usage|
| ---- | ---- |
@ -9,4 +9,4 @@ Examples can be found under `./fuzzer`.
| baby_fuzzer_nautilus | [nautilus](https://www.ndss-symposium.org/wp-content/uploads/2019/02/ndss2019_04A-3_Aschermann_paper.pdf) is a **coverage guided, grammar based** fuzzer|
|baby_fuzzer_tokens| basic **token level** fuzzer with token level mutations|
|baby_fuzzer_with_forkexecutor| example for **InProcessForkExecutor**|
|baby_no_std|a minimalistic example how to create a libafl based fuzzer that works on **`no_std`** environments like TEEs, Kernels or on barew metal|
|baby_no_std|a minimalistic example how to create a libafl based fuzzer that works on **`no_std`** environments like TEEs, Kernels or on bare metal|

View File

@ -4,8 +4,8 @@ The Corpus is where testcases are stored. We define a Testcase as an Input and a
A Corpus can store testcases in different ways, for example on disk, or in memory, or implement a cache to speedup on disk storage.
Usually, a testcase is added to the Corpus when it is considered as interesting, but a Corpus is used also to store testcases that fulfill an objective (like crashing the tested program for instance).
Usually, a testcase is added to the Corpus when it is considered as interesting, but a Corpus is used also to store testcases that fulfill an objective (like crashing the program under test for instance).
Related to the Corpus, there is the way in which the fuzzer should ask for the next testcase to fuzz picking it from the Corpus. The taxonomy for this in LibAFL is CorpusScheduler, the entity representing the policy to pop testcases from the Corpus, FIFO for instance.
Related to the Corpus is the way in which the next testcase (the fuzzer would ask for) is retrieved from the Corpus. The taxonomy for this handling in LibAFL is Scheduler, the entity representing the policy to pop testcases from the Corpus, in a FIFO fashion for instance.
Speaking about the code, [`Corpus`](https://docs.rs/libafl/0/libafl/corpus/trait.Corpus.html) and [`CorpusScheduler`](https://docs.rs/libafl/0/libafl/corpus/trait.CorpusScheduler.html) are traits.
Speaking about the code, [`Corpus`](https://docs.rs/libafl/latest/libafl/corpus/trait.Corpus.html) and [`Scheduler`](https://docs.rs/libafl/latest/libafl/schedulers/trait.Scheduler.html) are traits.

View File

@ -1,7 +1,7 @@
# Executor
In different fuzzers, this concept of executing the program under test means each run is now always the same.
For instance, for in-memory fuzzers like libFuzzer an execution is a call to an harness function, for hypervisor-based fuzzers like [kAFL](https://github.com/IntelLabs/kAFL) instead an entire operating system is started from a snapshot for each run.
For instance, for in-process fuzzers like libFuzzer an execution is a call to an harness function, for hypervisor-based fuzzers like [kAFL](https://github.com/IntelLabs/kAFL) instead an entire operating system is started from a snapshot for each run.
In our model, an Executor is the entity that defines not only how to execute the target, but all the volatile operations that are related to just a single run of the target.
@ -9,22 +9,22 @@ So the Executor is for instance responsible to inform the program about the inpu
In our model, it can also hold a set of Observers connected with each execution.
In Rust, we bind this concept to the [`Executor`](https://docs.rs/libafl/0/libafl/executors/trait.Executor.html) trait. A structure implementing this trait must implement [`HasObservers`](https://docs.rs/libafl/0/libafl/executors/trait.HasObservers.html) too if wants to hold a set of Observers.
In Rust, we bind this concept to the [`Executor`](https://docs.rs/libafl/latest/libafl/executors/trait.Executor.html) trait. A structure implementing this trait must implement [`HasObservers`](https://docs.rs/libafl/latest/libafl/executors/trait.HasObservers.html) too if wants to hold a set of Observers.
By default, we implement some commonly used Executors such as [`InProcessExecutor`](https://docs.rs/libafl/0/libafl/executors/inprocess/struct.InProcessExecutor.html) in which the target is a harness function providing in-process crash detection. Another Executor is the [`ForkserverExecutor`](https://docs.rs/libafl/0/libafl/executors/forkserver/struct.ForkserverExecutor.html) that implements an AFL-like mechanism to spawn child processes to fuzz.
A common pattern when creating an Executor is wrapping an existing one, for instance [`TimeoutExecutor`](https://docs.rs/libafl/0.6.1/libafl/executors/timeout/struct.TimeoutExecutor.html) wraps an executor and install a timeout callback before calling the original run function of the wrapped executor.
By default, we implement some commonly used Executors such as [`InProcessExecutor`](https://docs.rs/libafl/latest/libafl/executors/inprocess/type.InProcessExecutor.html) in which the target is a harness function providing in-process crash detection. Another Executor is the [`ForkserverExecutor`](https://docs.rs/libafl/latest/libafl/executors/forkserver/struct.ForkserverExecutor.html) that implements an AFL-like mechanism to spawn child processes to fuzz.
## InProcessExecutor
Let's begin with the base case; `InProcessExecutor`.
This executor executes the harness program (function) inside the fuzzer process.
When you want to execute the harness as fast as possible, you will most probably want to use this `InprocessExecutor`.
One thing to note here is, when your harness is likely to have heap corruption bugs, you want to use another allocator so that corrupted heap does not affect the fuzzer itself. (For example, we adopt MiMalloc in some of our fuzzers.). Alternatively you can compile your harness with address sanitizer to make sure you can catch these heap bugs.
One thing to note here is, when your harness is likely to have heap corruption bugs, you want to use another allocator so that corrupted heap does not affect the fuzzer itself. (For example, we adopt MiMalloc in some of our fuzzers.). Alternatively you can compile your harness with address sanitizer to make sure you can catch these heap bugs.
## ForkserverExecutor
Next, we'll take a look at the `ForkserverExecutor`. In this case, it is `afl-cc` (from AFLplusplus/AFLplusplus) that compiles the harness code, and therefore, we can't use `EDGES_MAP` anymore. Hopefully, we have [_a way_](https://github.com/AFLplusplus/AFLplusplus/blob/2e15661f184c77ac1fbb6f868c894e946cbb7f17/instrumentation/afl-compiler-rt.o.c#L270) to tell the forkserver which map to record the coverage.
Next, we'll take a look at the `ForkserverExecutor`. In this case, it is `afl-cc` (from AFL/AFLplusplus) that compiles the harness code, and therefore, we can't use `EDGES_MAP` anymore. Fortunately we have [_a way_](https://github.com/AFLplusplus/AFLplusplus/blob/2e15661f184c77ac1fbb6f868c894e946cbb7f17/instrumentation/afl-compiler-rt.o.c#L270) to tell the forkserver which map to record the coverage in.
As you can see from the forkserver example,
@ -32,13 +32,15 @@ As you can see from the forkserver example,
//Coverage map shared between observer and executor
let mut shmem = StdShMemProvider::new().unwrap().new_shmem(MAP_SIZE).unwrap();
//let the forkserver know the shmid
shmem.write_to_env("__AFL_SHM_ID").unwrap();
let mut shmem_buf = shmem.as_mut_slice();
unsafe {
shmem.write_to_env("__AFL_SHM_ID").unwrap();
}
let mut shmem_buf = shmem.as_slice_mut();
```
Here we make a shared memory region; `shmem`, and write this to environmental variable `__AFL_SHM_ID`. Then the instrumented binary, or the forkserver, finds this shared memory region (from the aforementioned env var) to record its coverage. On your fuzzer side, you can pass this shmem map to your `Observer` to obtain coverage feedbacks combined with any `Feedback`.
Another feature of the `ForkserverExecutor` to mention is the shared memory testcases. In normal cases, the mutated input is passed between the forkserver and the instrumented binary via `.cur_input` file. You can improve your forkserver fuzzer's performance by passing the input with shared memory.
Another feature of the `ForkserverExecutor` to mention is the shared memory testcases. In normal cases, the mutated input is passed between the forkserver and the instrumented binary via `.cur_input` file. You can improve your forkserver fuzzer's performance by passing the input with shared memory.
If the target is configured to use shared memory testcases, the `ForkserverExecutor` will notice this during the handshake and will automatically set up things accordingly.
See AFL++'s [_documentation_](https://github.com/AFLplusplus/AFLplusplus/blob/stable/instrumentation/README.persistent_mode.md#5-shared-memory-fuzzing) or the fuzzer example in `forkserver_simple/src/program.c` for reference.
@ -48,7 +50,7 @@ See AFL++'s [_documentation_](https://github.com/AFLplusplus/AFLplusplus/blob/st
Finally, we'll talk about the `InProcessForkExecutor`.
`InProcessForkExecutor` has only one difference from `InprocessExecutor`; It forks before running the harness and that's it.
But why do we want to do so? well, under some circumstances, you may find your harness pretty unstable or your harness wreaks havoc on the global states. In this case, you want to fork it before executing the harness runs in the child process so that it doesn't break things.
But why do we want to do so? Well, under some circumstances, you may find your harness pretty unstable or your harness wreaks havoc on the global states. In this case, you want to fork it before executing the harness runs in the child process so that it doesn't break things.
However, we have to take care of the shared memory, it's the child process that runs the harness code and writes the coverage to the map.
@ -59,12 +61,25 @@ On your fuzzer side, you can allocate a shared memory region and make the `EDGES
```rust,ignore
let mut shmem;
unsafe{
shmem = StdShMemProvider::new().unwrap().new_shmem(MAX_EDGES_NUM).unwrap();
shmem = StdShMemProvider::new().unwrap().new_shmem(EDGES_MAP_DEFAULT_SIZE).unwrap();
}
let shmem_buf = shmem.as_mut_slice();
let shmem_buf = shmem.as_slice_mut();
unsafe{
EDGES_PTR = shmem_buf.as_ptr();
}
```
Again, you can pass this shmem map to your `Observer` and `Feedback` to obtain coverage feedbacks.
Additionaly to allow the fuzzer to know when the child has crashed, the program should abort instead of unwinding upon a panic.
Without it, no crashes are saved by the fuzzer.
Cargo.toml:
```toml
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
```

View File

@ -10,17 +10,25 @@ The concept of "interestingness" is abstract, but typically it is related to a n
As an example, given an Observer that reports all the sizes of memory allocations, a maximization Feedback can be used to maximize these sizes to sport pathological inputs in terms of memory consumption.
In terms of code, the library offers the [`Feedback`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html) and the [`FeedbackState`](https://docs.rs/libafl/0/libafl/feedbacks/trait.FeedbackState.html) traits.
The first is used to implement functors that, given the state of the observers from the last execution, tells if the execution was interesting. The second is tied with `Feedback` and it is the state of the data that the feedback wants to persist in the fuzzers's state, for instance the cumulative map holding all the edges seen so far in the case of a feedback based on edge coverage.
In terms of code, the library offers the [`Feedback`](https://docs.rs/libafl/latest/libafl/feedbacks/trait.Feedback.html) trait.
It is used to implement functors that, given the state of the observers from the last execution, tells if the execution was interesting.
So to speak, it reduces the observations to a boolean result of [`is_interesting`](https://docs.rs/libafl/latest/libafl/feedbacks/trait.Feedback.html#tymethod.is_interesting) - or not.
For this, a `Feedback` can store anything it wants to persist in the fuzzers's state.
This might be, for instance, the cumulative map of all edges seen so far, in the case of a feedback based on edge coverage.
This can be achieved by adding `Metadata` in [`init_state`](https://docs.rs/libafl/latest/libafl/feedbacks/trait.Feedback.html#method.init_state) and accessing it later in `is_interesting`.
`Feedback` can also add custom metadata to a newly created [`Testcase`](https://docs.rs/libafl/latest/libafl/corpus/testcase/struct.Testcase.html) using [`append_metadata`](https://docs.rs/libafl/latest/libafl/feedbacks/trait.Feedback.html#method.append_metadata).
Multiple Feedbacks can be combined into boolean formula, considering for instance an execution as interesting if it triggers new code paths or execute in less time compared to the average execution time using [`feedback_or`](https://docs.rs/libafl/*/libafl/macro.feedback_or.html).
Multiple Feedbacks can be combined into a boolean expression, considering for instance an execution as interesting if it triggers new code paths or execute in less time compared to the average execution time using [`feedback_or`](https://docs.rs/libafl/latest/libafl/macro.feedback_or.html).
On top, logic operators like `feedback_or` and `feedback_and` have a `_fast` option (`feedback_or_fast` where the second feedback will not be evaluated, if the first part already answers the `interestingness` question, to save precious performance.
On top, logic operators like `feedback_or` and `feedback_and` have a `_fast` variant (e.g. `feedback_or_fast`) where the second feedback will not be evaluated, if the value of the first feedback operand already answers the `interestingness` question so as to save precious performance.
Using `feedback_and_fast` in combination with [`ConstFeedback`](https://docs.rs/libafl/*/libafl/feedbacks/enum.ConstFeedback.html#method.new), certain feedbacks can be disabled dynamically.
Using `feedback_and_fast` in combination with [`ConstFeedback`](https://docs.rs/libafl/latest/libafl/feedbacks/enum.ConstFeedback.html#method.new), certain feedbacks can be disabled dynamically.
## Objectives
While feedbacks are commonly used to decide if an [`Input`](https://docs.rs/libafl/*/libafl/inputs/trait.Input.html) should be kept for future mutations, they serve a double-purpose, as so-called `Objective Feedbacks`.
In this case, the `interestingness` of a feedback indicates, if an `Objective` has been hit.
Commonly, these would be a`crash or a timeout, but they can also be used to find specific parts of the program, for sanitization, or a differential fuzzing success.
While feedbacks are commonly used to decide if an [`Input`](https://docs.rs/libafl/latest/libafl/inputs/trait.Input.html) should be kept for future mutations, they serve a double-purpose, as so-called `Objective Feedbacks`.
In this case, the `interestingness` of a feedback indicates if an `Objective` has been hit.
Commonly, these objectives would be a crash or a timeout, but they can also be used to detect if specific parts of the program have been reached, for sanitization, or a differential fuzzing success.
Objectives use the same trait as a normal [`Feedback`](https://docs.rs/libafl/latest/libafl/feedbacks/trait.Feedback.html) and the implementations can be used interchangeably.
The only difference is that `interesting` Objectives won't be mutated further, and are counted as `Solutions`, a successful fuzzing campaign.

View File

@ -6,4 +6,4 @@ Typically, a random generator is used to generate random inputs.
Generators are traditionally less used in Feedback-driven Fuzzing, but there are exceptions, like Nautilus, that uses a Grammar generator to create the initial corpus and a sub-tree Generator as a mutation of its grammar Mutator.
In the code, [`Generator`](https://docs.rs/libafl/0/libafl/generators/trait.Generator.html) is a trait.
In the code, [`Generator`](https://docs.rs/libafl/latest/libafl/generators/trait.Generator.html) is a trait.

View File

@ -6,10 +6,10 @@ In our model of an abstract fuzzer, we define the Input as the internal represen
In the straightforward case, the input of the program is a byte array and in fuzzers such as AFL we store and manipulate exactly these byte arrays.
But it is not always the case. A program can expect inputs that are not byte arrays (e.g. a sequence of syscalls) and the fuzzer does not represent the Input in the same way that the program consumes it.
But it is not always the case. A program can expect inputs that are not linear byte arrays (e.g. a sequence of syscalls forming a use case or protocol) and the fuzzer does not represent the Input in the same way that the program consumes it.
In case of a grammar fuzzer for instance, the Input is generally an Abstract Syntax Tree because it is a data structure that can be easily manipulated while maintaining the validity, but the program expects a byte array as input, so just before the execution, the tree is serialized to a sequence of bytes.
In the Rust code, an [`Input`](https://docs.rs/libafl/*/libafl/inputs/trait.Input.html) is a trait that can be implemented only by structures that are serializable and have only owned data as fields.
In the Rust code, an [`Input`](https://docs.rs/libafl/latest/libafl/inputs/trait.Input.html) is a trait that can be implemented only by structures that are serializable and have only owned data as fields.
While most fuzzer use a normal `BytesInput`], more advanced inputs like inputs include special inputs for grammar fuzzing ([GramatronInput](https://docs.rs/libafl/*/libafl/inputs/gramatron/struct.GramatronInput.html) or `NautilusInput` on nightly), as well as the token-level [EncodedInput](https://docs.rs/libafl/*/libafl/inputs/encoded/struct.EncodedInput.html).
While most fuzzers use a normal `BytesInput`, more advanced ones use inputs that include special inputs for grammar fuzzing ([GramatronInput](https://docs.rs/libafl/latest/libafl/inputs/gramatron/struct.GramatronInput.html) or `NautilusInput` on Rust nightly), as well as the token-level [EncodedInput](https://docs.rs/libafl/latest/libafl/inputs/encoded/struct.EncodedInput.html).

View File

@ -1,9 +1,11 @@
# Mutator
The Mutator is an entity that takes one or more Inputs and generates a new derived one.
The Mutator is an entity that takes one or more Inputs and generates a new instance of Input derived by its inputs.
Mutators can be composed, and they are generally linked to a specific Input type.
There can be, for instance, a Mutator that applies more than a single type of mutation on the input. Consider a generic Mutator for a byte stream, bit flip is just one of the possible mutations but not the only one, there is also, for instance, the random replacement of a byte of the copy of a chunk.
There can be, for instance, a Mutator that applies more than a single type of mutation to the input. Consider a generic Mutator for a byte stream, bit flip is just one of the possible mutations but not the only one, there is also, for instance, the random replacement of a byte of the copy of a chunk.
In LibAFL, [`Mutator`](https://docs.rs/libafl/*/libafl/mutators/trait.Mutator.html) is a trait.
There are also mutators that always produce valid inputs, say a mutator that generates valid JSON or code, but these grammar based mutators need a grammar to work.
In LibAFL, [`Mutator`](https://docs.rs/libafl/latest/libafl/mutators/trait.Mutator.html) is a trait.

View File

@ -4,10 +4,10 @@ An Observer is an entity that provides an information observed during the execut
The information contained in the Observer is not preserved across executions, but it may be serialized and passed on to other nodes if an `Input` is considered `interesting`, and added to the `Corpus`.
As an example, the coverage map, filled during the execution to report the executed edges used by fuzzers such as AFL and `HonggFuzz` can be considered an observation. Another `Observer` can be the time spent executing a run, the program output, or more advanced observation, like maximum stack depth at runtime.
This information is not preserved across runs, and it is an observation of a dynamic property of the program.
As an example, the coverage map, filled during the execution to report the executed edges used by fuzzers such as AFL and `HonggFuzz` can be considered an observation. Another `Observer` can collect the time spent executing a run, the program output, or a more advanced observation, like maximum stack depth at runtime.
This information is an observation of a dynamic property of the program.
In terms of code, in the library this entity is described by the [`Observer`](https://docs.rs/libafl/0/libafl/observers/trait.Observer.html) trait.
In terms of code, in the library this entity is described by the [`Observer`](https://docs.rs/libafl/latest/libafl/observers/trait.Observer.html) trait.
In addition to holding the volatile data connected with the last execution of the target, the structures implementing this trait can define some execution hooks that are executed before and after each fuzz case. In these hooks, the observer can modify the fuzzer's state.

View File

@ -1,9 +1,9 @@
# Stage
A Stage is an entity that operates on a single Input got from the Corpus.
A Stage is an entity that operates on a single Input received from the Corpus.
For instance, a Mutational Stage, given an input of the corpus, applies a Mutator and executes the generated input one or more time. How many times this has to be done can be scheduled, AFL for instance uses a performance score of the input to choose how many times the havoc mutator should be invoked. This can depend also on other parameters, for instance, the length of the input if we want to just apply a sequential bitflip, or be a fixed value.
For instance, a Mutational Stage, given an input of the corpus, applies a Mutator and executes the generated input one or more times. How many times this has to be done can be scheduled, AFL for instance uses a performance score of the input to choose how many times the havoc mutator should be invoked. This can depend also on other parameters, for instance, the length of the input if we want to just apply a sequential bitflip, or a fixed value.
A stage can also be an analysis stage, for instance, the Colorization stage of Redqueen that aims to introduce more entropy in a testcase or the Trimming stage of AFL that aims to reduce the size of a testcase.
There are several stages in the LibAFL codebase implementing the [`Stage`](https://docs.rs/libafl/*/libafl/stages/trait.Stage.html) trait.
There are several stages in the LibAFL codebase implementing the [`Stage`](https://docs.rs/libafl/latest/libafl/stages/trait.Stage.html) trait.

View File

@ -8,8 +8,8 @@ The LibAFL code reuse mechanism is based on components, rather than sub-classes,
Thinking about similar fuzzers, you can observe that most of the time the data structures that are modified are the ones related to testcases and the fuzzer global state.
Beside the entities previously described, we introduce the [`Testcase`](https://docs.rs/libafl/0.6/libafl/corpus/testcase/struct.Testcase.html) and [`State`](https://docs.rs/libafl/0.6/libafl/state/struct.StdState.html) entities. The Testcase is a container for an Input stored in the Corpus and its metadata (so, in the implementation, the Corpus stores Testcases) and the State contains all the metadata that are evolved while running the fuzzer, Corpus included.
Beside the entities previously described, we introduce the [`Testcase`](https://docs.rs/libafl/latest/libafl/corpus/testcase/struct.Testcase.html) and [`State`](https://docs.rs/libafl/latest/libafl/state/struct.StdState.html) entities. The Testcase is a container for an Input stored in the Corpus and its metadata (so, in the implementation, the Corpus stores Testcases) and the State contains all the metadata that are evolved while running the fuzzer, Corpus included.
The State, in the implementation, contains only owned objects that are serializable, and it is serializable itself. Some fuzzers may want to serialize its state when pausing or just, when doing in-process fuzzing, serialize on crash and deserialize in the new process to continue to fuzz with all the metadata preserved.
The State, in the implementation, contains only owned objects that are serializable, and it is serializable itself. Some fuzzers may want to serialize their state when pausing or just, when doing in-process fuzzing, serialize on crash and deserialize in the new process to continue to fuzz with all the metadata preserved.
Additionally, we group the entities that are "actions", like the `CorpusScheduler` and the `Feedbacks`, in a common place, the [`Fuzzer'](https://docs.rs/libafl/*/libafl/fuzzer/struct.StdFuzzer.html).
Additionally, we group the entities that are "actions", like the `CorpusScheduler` and the `Feedbacks`, in a common place, the [`Fuzzer`](https://docs.rs/libafl/latest/libafl/fuzzer/struct.StdFuzzer.html).

View File

@ -5,10 +5,10 @@ A metadata in LibAFL is a self-contained structure that holds associated data to
In terms of code, a metadata can be defined as a Rust struct registered in the SerdeAny register.
```rust
extern crate libafl;
extern crate serde;
# extern crate libafl_bolts;
# extern crate serde;
use libafl::SerdeAny;
use libafl_bolts::SerdeAny;
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize, SerdeAny)]
@ -19,15 +19,15 @@ pub struct MyMetadata {
The struct must be static, so it cannot hold references to borrowed objects.
As an alternative to `derive(SerdeAny)` that is a proc-macro in `libafl_derive` the user can use `libafl::impl_serdeany!(MyMetadata);`.
As an alternative to `derive(SerdeAny)` which is a proc-macro in `libafl_derive` the user can use `libafl_bolts::impl_serdeany!(MyMetadata);`.
## Usage
Metadata objects are primarly intended to be used inside [`SerdeAnyMap`](https://docs.rs/libafl/0.5.0/libafl/bolts/serdeany/serdeany_registry/struct.SerdeAnyMap.html) and [`NamedSerdeAnyMap`](https://docs.rs/libafl/0.5.0/libafl/bolts/serdeany/serdeany_registry/struct.NamedSerdeAnyMap.html).
Metadata objects are primarly intended to be used inside [`SerdeAnyMap`](https://docs.rs/libafl_bolts/latest/libafl_bolts/serdeany/serdeany_registry/struct.SerdeAnyMap.html) and [`NamedSerdeAnyMap`](https://docs.rs/libafl_bolts/latest/libafl_bolts/serdeany/serdeany_registry/struct.NamedSerdeAnyMap.html).
With these maps, the user can retrieve instances by type (and name). Internally, the instances are stored as SerdeAny trait objects.
Structs that want to have a set of metadata must implement the [`HasMetadata`](https://docs.rs/libafl/0.5.0/libafl/state/trait.HasMetadata.html) trait.
Structs that want to have a set of metadata must implement the [`HasMetadata`](https://docs.rs/libafl/latest/libafl/common/trait.HasMetadata.html) trait.
By default, Testcase and State implement it and hold a SerdeAnyMap testcase.

View File

@ -0,0 +1,27 @@
# Migrating from LibAFL <0.11 to 0.11
We moved the old `libafl::bolts` module to its own crate called `libafl_bolts`.
For this, imports for types in LibAFL bolts have changed in version 0.11, everything else should remain the same.
## Reasons for This Change
With the change we can now use a lot of low-level features of LibAFL for projects that are unrelated to fuzzing, or just completely different to LibAFL.
Some cross-platform things in bolts include
* SerdeAnyMap: a map that stores and retrieves elements by type and is serializable and deserializable
* ShMem: A cross-platform (Windows, Linux, Android, MacOS) shared memory implementation
* LLMP: A fast, lock-free IPC mechanism via SharedMap
* Core_affinity: A maintained version of `core_affinity` that can be used to get core information and bind processes to cores
* Rands: Fast random number generators for fuzzing (like [RomuRand](https://www.romu-random.org/))
* MiniBSOD: get and print information about the current process state including important registers.
* Tuples: Haskel-like compile-time tuple lists
* Os: OS specific stuff like signal handling, windows exception handling, pipes, and helpers for `fork`
## What changed
You will need to move all `libafl::bolts::` imports to `libafl_bolts:::` and add the crate dependency in your Cargo.toml (and specify feature flags there).
As only exception, the `libafl::bolts::launcher::Launcher` has moved to `libafl::events::launcher::Launcher` since it has fuzzer and `EventManager` specific code.
If you are using `prelude`, you may need to also ad `libafl_bolts::prelude`.
That's it.
Enjoy using `libafl_bolts` in other projects.

View File

@ -0,0 +1,9 @@
# Migrating from <0.12 to 0.12
We deleted `TimeoutExecutor` and `TimeoutForkserverExecutor` and make it mandatory for `InProcessExecutor` and `ForkserverExecutor` to have the timeout. Now `InProcessExecutor` and `ForkserverExecutor` have the default timeout of 5 seconds.
## Reason for This Change.
In 99% of the case, it is advised to have the timeout for the fuzzer. This is because we do not want the fuzzer to stop forever just because the target has hit a path that resulted in a infinite-loop.
## What changed
You do not have to wrap the executor with `TimeoutExecutor` anymore. You can just use `InProcessExecutor::new()` to instantiate the executor with the default timeout or use `InProcessExecutor::timeout(duration)` to start the executor with the customized duration of timeout.

View File

@ -75,7 +75,7 @@ where
```
The executor is constrained to `EM` and `Z`, with each of their respective states being constrained to `E`'s state. It
is no longer necessary to explicitly defined a generic for the input type, the state type, or the generic type, as these
is no longer necessary to explicitly define a generic for the input type, the state type, or the generic type, as these
are all present as associated types for `E`. Additionally, we don't even need to specify any details about the observers
(`OT` in the previous version) as the type does not need to be constrained and is not shared by other types.
@ -101,7 +101,7 @@ See `fuzzers/` for examples of these changes.
If you implemented a Mutator, Executor, State, or another kind of component, you must update your implementation. The
main changes to the API are in the use of "Uses*" for associated types.
In many scenarios, Input, Observers, and State generics have been moved into traits with associated types (namely,
In many scenarios, Input, Observer, and State generics have been moved into traits with associated types (namely,
"UsesInput", "UsesObservers", and "UsesState". These traits are required for many existing traits now and are very
straightforward to implement. In a majority of cases, you will have generics on your custom implementation or a fixed
type to implement this with. Thankfully, Rust will let you know when you need to implement this type.
@ -127,7 +127,7 @@ where
}
```
After 0.9, all `Corpus` implementations are required to implement `UsesInput` and `Corpus` no longer has a generic for
After 0.9, all `Corpus` implementations are required to implement `UsesInput`. Also `Corpus` no longer has a generic for
the input type (as it is now provided by the UsesInput impl). The migrated implementation is shown below:
```rust,ignore
@ -160,3 +160,26 @@ Now, `Corpus` cannot be accidentally implemented for another type other than tha
is fixed to the associated type for `UsesInput`.
A more complex example of migration can be found in the "Reasons for this change" section of this document.
## Observer Changes
Additionally, we changed the Observer API, as the API in 0.8 led to undefined behavior.
At the same time, we used the change to simplify the common case: creating an `StdMapObserver`
from libafl_target's `EDGES_MAP`.
In the future, instead of using:
```rust,ignore
let edges = unsafe { &mut EDGES_MAP[0..EDGES_MAP_DEFAULT_SIZE] };
let edges_observer = StdMapObserver::new("edges", edges);
```
creating the edges observer is as simple as using the new `std_edges_map_observer` function.
```rust,ignore
let edges_observer = unsafe { std_edges_map_observer("edges") };
```
Alternatively, `StdMapObserver::new` will still work, but now the whole method is marked as `unsafe`.
The reason is that the caller has to make sure `EDGES_MAP` (or other maps) are not moved or freed in memory,
for the lifetime of the `MapObserver`.
This means that the buffer should either be `static` or `Pin`.

View File

@ -6,7 +6,7 @@ LibAFL, as most of the Rust projects, can be built using `cargo` from the root d
$ cargo build --release
```
Note that the `--release` flag is optional for development, but you needed to add it to fuzzing at a decent speed.
Note that the `--release` flag is optional for development, but you need to add it to do fuzzing at a decent speed.
Slowdowns of 10x or more are not uncommon for Debug builds.
The LibAFL repository is composed of multiple crates.

View File

@ -10,7 +10,7 @@ libafl = { version = "*" }
## Crate List
For LibAFL, each crate has its self-contained purpose, and the user may not need to use all of them in its project.
For LibAFL, each crate has its self-contained purpose, and the user may not need to use all of them in their project.
Following the naming convention of the folders in the project's root, they are:
### [`libafl`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl)
@ -31,20 +31,35 @@ You can choose the features by using `features = ["feature1", "feature2", ...]`
Out of this list, by default, `std`, `derive`, and `rand_trait` are already set.
You can choose to disable them by setting `default-features = false` in your `Cargo.toml`.
### libafl_sugar
### [`libafl_bolts`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_bolts)
The `libafl_bolts` crate is a minimal tool shed filled with useful low-level rust features, not necessarily related to fuzzers.
In it, you'll find highlights like:
- `core_affinity` to bind the current process to cores
- `SerdeAnyMap` a map that can store typed values in a serializable fashion
- `minibsod` to dump the current process state
- `LLMP`, "low level message passing", a lock-free IPC mechanism
- `Rand`, different fast (non-cryptographically secure) RNG implementations like RomuRand
- `ShMem`, a platform independent shard memory implementation
- `Tuples`, a compiletime tuple implementation
... and much more.
### [`libafl_sugar`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_sugar)
The sugar crate abstracts away most of the complexity of LibAFL's API.
Instead of high flexibility, it aims to be high-level and easy-to-use.
It is not as flexible as stitching your fuzzer together from each individual component, but allows you to build a fuzzer with minimal lines of code.
To see it in action, take a look at the [`libfuzzer_stb_image_sugar` example fuzzer](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/libfuzzer_stb_image_sugar).
To see it in action, take a look at the [`libfuzzer_stb_image_sugar` example fuzzer](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/inprocess/libfuzzer_stb_image_sugar).
### libafl_derive
### [`libafl_derive`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_derive)
This a proc-macro crate paired with the `libafl` crate.
At the moment, it just exposes the `derive(SerdeAny)` macro that can be used to define Metadata structs, see the section about [Metadata](../design/metadata.md) for details.
### libafl_targets
### [`libafl_targets`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_targets)
This crate exposes code to interact with, and to instrument, targets.
To enable and disable features at compile-time, the features are enabled and disabled using feature flags.
@ -52,36 +67,36 @@ To enable and disable features at compile-time, the features are enabled and dis
Currently, the supported flags are:
- `pcguard_edges` defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges in a map.
- `pcguard_hitcounts defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges with the hitcounts (like AFL) in a map.
- `pcguard_hitcounts` defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges with the hitcounts (like AFL) in a map.
- `libfuzzer` exposes a compatibility layer with libFuzzer style harnesses.
- `value_profile` defines the SanitizerCoverage trace-cmp hooks to track the matching bits of each comparison in a map.
### libafl_cc
### [`libafl_cc`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_cc)
This is a library that provides utils wrap compilers and create source-level fuzzers.
This is a library that provides utils to wrap compilers and create source-level fuzzers.
At the moment, only the Clang compiler is supported.
To understand it deeper, look through the tutorials and examples.
### libafl_frida
### [`libafl_frida`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_frida)
This library bridges LibAFL with Frida as instrumentation backend.
With this crate, you can instrument targets on Linux/macOS/Windows/Android for coverage collection.
Additionally, it supports CmpLog, and AddressSanitizer instrumentation and runtimes for aarch64.
See further information, as well as usage instructions, [later in the book](../advanced_features/frida.md).
### libafl_qemu
### [`libafl_qemu`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_qemu)
This library bridges LibAFL with QEMU user-mode to fuzz ELF cross-platform binaries.
It works on Linux and can collect edge coverage without collisions!
It also supports a wide range of hooks and instrumentation options.
### libafl_nyx
### [`libafl_nyx`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_nyx)
[Nyx](https://nyx-fuzz.com/) is a KVM-based snapshot fuzzer. `libafl_nyx` adds these capabilities to LibAFL. There is a specific section explaining usage of libafl_nyx [later in the book](../advanced_features/nyx.md).
### libafl_concolic
### [`libafl_concolic`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl_concolic)
Concolic fuzzing is the combination of fuzzing and a symbolic execution engine.
This can reach greater depth than normal fuzzing, and is exposed in this crate.

View File

@ -11,27 +11,27 @@ The first step is to download LibAFL and all dependencies that are not automatic
> previous command. Additionally, PowerShell-specific examples will use `>`
> rather than `$`.
While you technically do not need to install LibAFL, but can use the version from crates.io directly, we do recommend to download or clone the GitHub version.
While technically you do not need to install LibAFL, but can use the version from crates.io directly, we do recommend to download or clone the GitHub version.
This gets you the example fuzzers, additional utilities, and latest patches.
The easiest way to do this is to use `git`.
```sh
$ git clone git@github.com:AFLplusplus/LibAFL.git
$ git clone https://github.com/AFLplusplus/LibAFL.git
```
You can alternatively, on a UNIX-like machine, download a compressed archive and extract it with:
Alternatively, on a UNIX-like machine, you can download a compressed archive and extract it with:
```sh
wget https://github.com/AFLplusplus/LibAFL/archive/main.tar.gz
$ tar xvf LibAFL-main.tar.gz
$ rm LibAFL-main.tar.gz
$ wget https://github.com/AFLplusplus/LibAFL/archive/main.tar.gz
$ tar xvf main.tar.gz
$ rm main.tar.gz
$ ls LibAFL-main # this is the extracted folder
```
## Clang installation
One of the external dependencies of LibAFL is the Clang C/C++ compiler.
While most of the code is in pure Rust, we still need a C compiler because stable Rust still does not support features that some parts of LibAFL may need, such as weak linking, and LLVM builtins linking.
While most of the code is written in pure Rust, we still need a C compiler because stable Rust still does not support features that some parts of LibAFL may need, such as weak linking, and LLVM builtins linking.
For these parts, we use C to expose the missing functionalities to our Rust codebase.
In addition, if you want to perform source-level fuzz testing of C/C++ applications,
@ -54,6 +54,6 @@ explained [here](https://clang.llvm.org/get_started.html).
If you do not have Rust installed, you can easily follow the steps described [here](https://www.rust-lang.org/tools/install)
to install it on any supported system.
Be aware that Rust versions shipped with Linux distributions may be outdated, LibAFL always targets the latest `stable` version available via `rustup upgrade`.
Be aware that Rust versions shipped with Linux distributions may be outdated, LibAFL always targets the latest `stable` version available via `rustup update`.
We suggest installing Clang and LLVM first.

View File

@ -4,10 +4,10 @@ Fuzzers are important tools for security researchers and developers alike.
A wide range of state-of-the-art tools like [AFL++](https://github.com/AFLplusplus/AFLplusplus), [libFuzzer](https://llvm.org/docs/LibFuzzer.html) or [honggfuzz](https://github.com/google/honggfuzz) are available to users. They do their job in a very effective way, finding thousands of bugs.
From the perspective of a power user, however, these tools are limited.
Their design does not treat extensibility as a first-class citizen.
Their designs do not treat extensibility as a first-class citizen.
Usually, a fuzzer developer can choose to either fork one of these existing tools, or to create a new fuzzer from scratch.
In any case, researchers end up with tons of fuzzers, all of which are incompatible with each other.
Their outstanding features can not just be combined for new projects.
Their outstanding features cannot just be combined for new projects.
By reinventing the wheel over and over, we may completely miss out on features that are complex to reimplement.
To tackle this issue, we created LibAFL, a library that is _not just another fuzzer_, but a collection of reusable pieces for individual fuzzers.
@ -24,11 +24,11 @@ Some highlight features currently include:
This means it does not require a specific OS-dependent runtime to function.
Define an allocator and a way to map pages, and you are good to inject LibAFL in obscure targets like embedded devices, hypervisors, or maybe even WebAssembly?
- `adaptable`: Given years of experience fine-tuning *AFLplusplus* and our academic fuzzing background, we could incorporate recent fuzzing trends into LibAFL's design and make it future-proof.
To give an example, as opposed to old-skool fuzzers, a `BytesInput` is just one of the potential forms of inputs:
To give an example, as opposed to old-school fuzzers, a `BytesInput` is just one of the potential forms of inputs:
feel free to use and mutate an Abstract Syntax Tree instead, for structured fuzzing.
- `scalable`: As part of LibAFL, we developed `Low Level Message Passing`, `LLMP` for short, which allows LibAFL to scale almost linearly over cores. That is, if you chose to use this feature - it is your fuzzer, after all.
Scaling to multiple machines over TCP is also possible, using LLMP's `broker2broker` feature.
- `fast`: We do everything we can at compile time so that the runtime overhead is as minimal as it can get.
- `bring your own target`: We support binary-only modes, like QEMU-Mode and Frida-Mode with ASAN and CmpLog, as well as multiple compilation passes for sourced-based instrumentation.
- `bring your own target`: We support binary-only modes, like (full-system) QEMU-Mode and Frida-Mode with ASan and CmpLog, as well as multiple compilation passes for sourced-based instrumentation.
Of course, we also support custom instrumentation, as you can see in the Python example based on Google's Atheris.
- `usable`: This one is on you to decide. Dig right in!

View File

@ -1,11 +1,11 @@
# The LibAFL Fuzzing Library
<img align="right" src="https://github.com/AFLplusplus/Website/raw/master/static/logo_256x256.png" alt="AFL++ Logo">
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/main/static/libafl_logo.svg" alt="LibAFL Logo" style="width: 256px; height: auto">
*by Andrea Fioraldi and Dominik Maier*
Welcome to LibAFL, the Advanced Fuzzing Library.
This book shall be a gentle introduction into the library.
This book shall be a gentle introduction to the library.
This version of the LibAFL book is coupled with the release 1.0 beta of the library.

View File

@ -3,7 +3,7 @@
Configurations for individual fuzzer nodes are relevant for multi node fuzzing.
The chapter describes how to run nodes with different configurations
in one fuzzing cluster.
This allows, for example, a node compiled with ASAN, to know that it needs to rerun new testcases for a node without ASAN, while the same binary/configuration does not.
This allows, for example, a node compiled with ASan, to know that it needs to rerun new testcases for a node without ASan, while the same binary/configuration does not.
Fuzzers with the same configuration can exchange Observers for new testcases and reuse them without rerunning the input.
A different configuration indicates, that only the raw input can be exchanged, it must be rerun on the other node to capture relevant observations.

View File

@ -1,8 +1,8 @@
# Message Passing
LibAFL offers a standard mechanism for message passing over processes and machines with a low overhead.
LibAFL offers a standard mechanism for message passing between processes and machines with a low overhead.
We use message passing to inform the other connected clients/fuzzers/nodes about new testcases, metadata, and statistics about the current run.
Depending on individual needs, LibAFL can also write testcase contents to disk, while still using events to notify other fuzzers, using an `OnDiskCorpus`.
Depending on individual needs, LibAFL can also write testcase contents to disk, while still using events to notify other fuzzers, using the `CachedOnDiskCorpus` or similar.
In our tests, message passing scales very well to share new testcases and metadata between multiple running fuzzer instances for multi-core fuzzing.
Specifically, it scales _a lot_ better than using memory locks on a shared corpus, and _a lot_ better than sharing the testcases via the filesystem, as AFL traditionally does.
@ -12,7 +12,7 @@ The `EventManager` interface is used to send Events over the wire using `Low Lev
## Low Level Message Passing (LLMP)
LibAFL comes with a reasonably lock-free message passing mechanism that scales well across cores and, using its *broker2broker* mechanism, even to connected machines via TCP.
LibAFL comes with a reasonably lock-free message passing mechanism that scales well across cores and, using its _broker2broker_ mechanism, even to connected machines via TCP.
Most example fuzzers use this mechanism, and it is the best `EventManager` if you want to fuzz on more than a single core.
In the following, we will describe the inner workings of `LLMP`.
@ -28,12 +28,12 @@ Shared maps, called shared memory for the sake of not colliding with Rust's `map
Each client, usually a fuzzer trying to share stats and new testcases, maps an outgoing `ShMem` map.
With very few exceptions, only this client writes to this map, therefore, we do not run in race conditions and can live without locks.
The broker reads from all client's `ShMem` maps.
It checks all incoming client maps periodically and then forwards new messages to its outgoing broadcast-`ShMem`, mapped by all connected clients.
It periodically checks all incoming client maps and then forwards new messages to its outgoing broadcast-`ShMem`, mapped by all connected clients.
To send new messages, a client places a new message at the end of their shared memory and then updates a static field to notify the broker.
Once the outgoing map is full, the sender allocates a new `ShMem` using the respective `ShMemProvider`.
It then sends the information needed to map the newly-allocated page in connected processes to the old page, using an end of page (`EOP`) message.
Once the receiver maps the new page, flags it as safe for unmapping from the sending process (to avoid race conditions if we have more than a single EOP in a short time), and then continues to read from the new `ShMem`.
Once the receiver maps the new page, it flags it as safe for unmapping by the sending process (to avoid race conditions if we have more than a single EOP in a short time), and then continues to read from the new `ShMem`.
The schema for client's maps to the broker is as follows:
@ -54,10 +54,10 @@ After the broker received a new message from clientN, (`clientN_out->current_id
The clients periodically, for example after finishing `n` mutations, check for new incoming messages by checking if (`current_broadcast_map->current_id != last_message->message_id`).
While the broker uses the same EOP mechanism to map new `ShMem`s for its outgoing map, it never unmaps old pages.
This additional memory overhead serves a good purpose: by keeping all broadcast pages around, we make sure that new clients can join in on a fuzzing campaign at a later point in time
This additional memory resources serve a good purpose: by keeping all broadcast pages around, we make sure that new clients can join in on a fuzzing campaign at a later point in time.
They just need to re-read all broadcasted messages from start to finish.
So the outgoing messages flow like this over the outgoing broadcast `Shmem`:
So the outgoing messages flow is like this over the outgoing broadcast `Shmem`:
```text
[broker]
@ -72,13 +72,13 @@ So the outgoing messages flow like this over the outgoing broadcast `Shmem`:
[client0] [client1] ... [clientN]
```
To use `LLMP` in LibAFL, you usually want to use an `LlmpEventManager` or its restarting variant.
To use `LLMP` in LibAFL, you usually want to use an `LlmpRestartingEventManager` or its restarting variant.
They are the default if using LibAFL's `Launcher`.
If you should want to use `LLMP` in its raw form, without any `LibAFL` abstractions, take a look at the `llmp_test` example in [./libafl/examples](https://github.com/AFLplusplus/LibAFL/blob/main/libafl/examples/llmp_test/main.rs).
If you should want to use `LLMP` in its raw form, without any `LibAFL` abstractions, take a look at the `llmp_test` example in [./libafl/examples](https://github.com/AFLplusplus/LibAFL/blob/main/libafl_bolts/examples/llmp_test/main.rs).
You can run the example using `cargo run --example llmp_test` with the appropriate modes, as indicated by its help output.
First, you will have to create a broker using `LlmpBroker::new()`.
Then, create some `LlmpClient``s` in other threads and register them with the main thread using `LlmpBroker::register_client`.
Then, create some `LlmpClient`s in other threads and register them with the main thread using `LlmpBroker::register_client`.
Finally, call `LlmpBroker::loop_forever()`.
### B2B: Connecting Fuzzers via TCP

View File

@ -4,18 +4,18 @@ Multiple fuzzer instances can be spawned using different ways.
## Manually, via a TCP port
The straightforward way to do Multi-Threading is to use the `LlmpRestartingEventManager`, specifically to use `setup_restarting_mgr_std`.
It abstracts away all the pesky details about restarts on crash handling (for in-memory fuzzers) and multi-threading.
The straightforward way to do Multi-Threading is to use the [`LlmpRestartingEventManager`](https://docs.rs/libafl/latest/libafl/events/llmp/restarting/struct.LlmpRestartingEventManager.html), specifically to use [`setup_restarting_mgr_std`](https://docs.rs/libafl/latest/libafl/events/llmp/restarting/fn.setup_restarting_mgr_std.html).
It abstracts away all the pesky details about restarts on crash handling (for in-process fuzzers) and multi-threading.
With it, every instance you launch manually tries to connect to a TCP port on the local machine.
If the port is not yet bound, this instance becomes the broker, itself binding to the port to await new clients.
If the port is not yet bound, this instance becomes the broker, binding itself to the port to await new clients.
If the port is already bound, the EventManager will try to connect to it.
The instance becomes a client and can now communicate with all other nodes.
Launching nodes manually has the benefit that you can have multiple nodes with different configurations, such as clients fuzzing with and without ASAN.
Launching nodes manually has the benefit that you can have multiple nodes with different configurations, such as clients fuzzing with and without `ASan`.
While it's called "restarting" manager, it uses `fork` on Unix operating systems as optimization and only actually restarts from scratch on Windows.
While it's called "restarting" manager, it uses `fork` on Unix-like operating systems as optimization and only actually restarts from scratch on Windows.
## Automated, with Launcher
@ -23,7 +23,7 @@ While it's called "restarting" manager, it uses `fork` on Unix operating systems
The Launcher is the lazy way to do multiprocessing.
You can use the Launcher builder to create a fuzzer that spawns multiple nodes with one click, all using restarting event managers and the same configuration.
To use launcher, first you need to write an anonymous function `let mut run_client = |state: Option<_>, mut mgr, _core_id|{}`, which uses three parameters to create individual fuzzer. Then you can specify the `shmem_provider`,`broker_port`,`monitor`,`cores` and other stuff through `Launcher::builder()`:
To use launcher, first you need to write an anonymous function `let mut run_client = |state: Option<_>, mut mgr, _core_id|{}`, which uses three parameters to create an individual fuzzer. Then you can specify the `shmem_provider`,`broker_port`,`monitor`,`cores` and other stuff through `Launcher::builder()`:
```rust,ignore
Launcher::builder()
@ -42,18 +42,22 @@ To use launcher, first you need to write an anonymous function `let mut run_clie
This first starts a broker, then spawns `n` clients, according to the value passed to `cores`.
The value is a string indicating the cores to bind to, for example, `0,2,5` or `0-3`.
For each client, `run_client` will be called.
On Windows, the Launcher will restart each client, while on Unix, it will use `fork`.
If the launcher uses `fork`, it will hide child output, unless the settings indicate otherwise, or the `LIBAFL_DEBUG_OUTPUT` env variable is set.
On Windows, the Launcher will restart each client, while on Unix-alikes, it will use `fork`.
Advanced use-cases:
1. To connect multiple nodes together via TCP, you can use the `remote_broker_addr`. this requires the `llmp_bind_public` compile-time feature for `LibAFL`.
2. To use multiple launchers for individual configurations, you can set `spawn_broker` to `false` on all but one.
2. To use multiple launchers for individual configurations, you can set `spawn_broker` to `false` on all instances but one.
3. Launcher will not select the cores automatically, so you need to specify the `cores` that you want.
4. On `Unix`, you can chose between a forking and non-forking version of Launcher by setting the `fork` feature in LibAFL. Some targets may not like forking, but it is faster than restarting processes from scratch. Windows will never fork.
5. For simple debugging, first set the `LIBAFL_DEBUG_OUTPUT` env variable to see if a child process printed anything.
6. For further debugging of fuzzer failures, it may make sense to replace `Launcher` temporarily with a [`SimpleEventManager`](https://docs.rs/libafl/latest/libafl/events/simple/struct.SimpleEventManager.html#method.new) and call your harness fn (`run_client(None, mgr, 0);`) directly, so that fuzzing runs in the same thread and is easier to debug, before moving back to `Launcher` after the bugfix.
For more examples, you can check out `qemu_launcher` and `libfuzzer_libpng_launcher` in [`./fuzzers/`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers).
## Other ways
The `LlmpEventManager` family is the easiest way to spawn instances, but for obscure targets, you may need to come up with other solutions.
The `LlmpRestartEventManager` is the easiest way to spawn instances, but for obscure targets, you may need to come up with other solutions.
LLMP is even, in theory, `no_std` compatible, and even completely different EventManagers can be used for message passing.
If you are in this situation, please either read through the current implementations and/or reach out to us.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 KiB

View File

@ -5,4 +5,4 @@
> This section is under construction.
> Please check back later (or open a PR)
>
> In the meantime, find the final Lain-based fuzzer in [the fuzzers folder](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/tutorial)
> In the meantime, find the final Lain-based fuzzer in [the fuzzers folder](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/baby/tutorial)

View File

@ -2,4 +2,4 @@
In this chapter, we will build a custom fuzzer using the [Lain](https://github.com/microsoft/lain) mutator in Rust.
This tutorial will introduce you in writing extensions to LibAFL like Feedbacks and Testcase's metadata.
This tutorial will introduce you to writing extensions to LibAFL like Feedbacks and Testcase's metadata.

4
fuzzers/FRET/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.qcow2
corpus
*.axf
demo

83
fuzzers/FRET/Cargo.toml Normal file
View File

@ -0,0 +1,83 @@
[package]
name = "fret"
version = "0.8.2"
authors = ["Alwin Berger <alwin.berger@tu-dortmund.de>"]
edition = "2021"
[features]
default = ["std", "snapshot_fast", "restarting", "do_hash_notify_state", "do_hash_notify_value", "config_stg", "fuzz_int", "shortcut", "trace_job_response_times", "observe_systemstate_unordered" ]
std = []
# Exec environemnt basics
snapshot_restore = []
snapshot_fast = [ "snapshot_restore" ]
singlecore = []
restarting = ['singlecore']
run_until_saturation = []
fuzz_int = []
shortcut = []
# information capture
observe_edges = [] # observe cfg edges
observe_hitcounts = [ "observe_edges" ] # reduces edge granularity
observe_systemstate = []
observe_systemstate_unordered = []
do_hash_notify_state = []
do_hash_notify_value = []
trace_job_response_times = [ "trace_stg" ]
trace_stg = [ "observe_systemstate" ]
trace_reads = [ "trace_stg", "trace_job_response_times" ]
# feedbacks
feed_stg = [ "trace_stg", "observe_systemstate" ]
feed_stg_edge = [ "feed_stg"]
feed_stg_abb_woet = [ "feed_stg"]
feed_stg_pathhash = [ "feed_stg"]
feed_stg_abbhash = [ "feed_stg"]
feed_stg_aggregatehash = [ "feed_stg"]
feed_job_woet = [ "trace_job_response_times"]
feed_job_wort = [ "trace_job_response_times"]
mutate_stg = [ "observe_systemstate", "trace_reads" ]
feed_longest = [ ]
feed_afl = [ "observe_edges" ]
feed_genetic = []
gensize_1 = [ ]
gensize_10 = [ ]
gensize_100 = [ ]
gensize_1000 = [ ]
# schedulers
sched_genetic = []
sched_afl = []
sched_stg = []
sched_stg_edge = ['sched_stg'] # every edge in the stg
sched_stg_pathhash = ['sched_stg'] # every path in the stg
sched_stg_abbhash = ['sched_stg'] # every path of abbs
sched_stg_aggregatehash = ['sched_stg'] # every aggregated path (order independent)
# overall_configs
config_genetic = ["feed_genetic","sched_genetic","trace_stg"]
config_afl = ["feed_afl","sched_afl","trace_stg"]
config_frafl = ["feed_afl","sched_afl","feed_longest","trace_stg"]
config_stg = ["feed_stg_aggregatehash","sched_stg_aggregatehash","mutate_stg","feed_job_wort"]
config_stg_woet = ["feed_stg_aggregatehash","sched_stg_aggregatehash","mutate_stg","feed_job_wort","feed_job_woet","feed_stg_abb_woet"]
# config_stg_aggregate = ["feed_stg_aggregatehash","sched_stg_aggregatehash","mutate_stg"]
config_stg_abbpath = ["feed_stg_abbhash","sched_stg_abbhash","mutate_stg"]
config_stg_edge = ["feed_stg_edge","sched_stg_edge","mutate_stg"]
[profile.release]
lto = true
codegen-units = 1
debug = true
[dependencies]
libafl = { path = "../../libafl/", features = ["multipart_inputs", "prelude"] }
libafl_bolts = { path = "../../libafl_bolts/" }
libafl_targets = { path = "../../libafl_targets/" }
libafl_qemu = { path = "../../libafl_qemu/", features = ["arm", "systemmode"], default-features = false }
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
hashbrown = { version = "0.14.0", features = ["serde"] } # A faster hashmap, nostd compatible
petgraph = { version="0.6.5", features = ["serde-1"] }
ron = "0.7" # write serialized data - including hashmaps
rand = "0.5"
clap = { version = "4.4.11", features = ["derive"] }
csv = "1.3.0"
log = "0.4"
simple_moving_average = "1.0.2"
itertools = "0.13.0"

16
fuzzers/FRET/benchmark/.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
*dump
timedump*
corpora
build
mnt
.R*
*.png
*.pdf
bins
.snakemake
*.zip
*.tar.*
*.sqlite
eval*
test_*
bench_*

View File

@ -0,0 +1,57 @@
TIME=7200
corpora/%/seed:
mkdir -p $$(dirname $@)
LINE=$$(grep "^$$(basename $*)" target_symbols.csv); \
export \
KERNEL=benchmark/build/$*.elf \
FUZZ_MAIN=$$(echo $$LINE | cut -d, -f2) \
FUZZ_INPUT=$$(echo $$LINE | cut -d, -f3) \
FUZZ_INPUT_LEN=$$(echo $$LINE | cut -d, -f4) \
BREAKPOINT=$$(echo $$LINE | cut -d, -f5) \
SEED_DIR=benchmark/corpora/$* \
DUMP_SEED=seed; \
../fuzzer.sh
timedump/%$(FUZZ_RANDOM)$(SUFFIX): corpora/%/seed
mkdir -p $$(dirname $@)
LINE=$$(grep "^$$(basename $*)" target_symbols.csv); \
export \
KERNEL=benchmark/build/$*.elf \
FUZZ_MAIN=$$(echo $$LINE | cut -d, -f2) \
FUZZ_INPUT=$$(echo $$LINE | cut -d, -f3) \
FUZZ_INPUT_LEN=$$(echo $$LINE | cut -d, -f4) \
BREAKPOINT=$$(echo $$LINE | cut -d, -f5) \
SEED_RANDOM=1 \
TIME_DUMP=benchmark/$@ \
CASE_DUMP=benchmark/$@; \
../fuzzer.sh + + + + + $(TIME) + + + > $@_log
#SEED_DIR=benchmark/corpora/$*
all_sequential: timedump/sequential/mpeg2$(FUZZ_RANDOM) timedump/sequential/dijkstra$(FUZZ_RANDOM) timedump/sequential/epic$(FUZZ_RANDOM) \
timedump/sequential/g723_enc$(FUZZ_RANDOM) timedump/sequential/audiobeam$(FUZZ_RANDOM) \
timedump/sequential/gsm_enc$(FUZZ_RANDOM)
all_kernel: timedump/kernel/bsort$(FUZZ_RANDOM) timedump/kernel/insertsort$(FUZZ_RANDOM) #timedump/kernel/fft$(FUZZ_RANDOM)
all_app: timedump/app/lift$(FUZZ_RANDOM)
all_system: timedump/lift$(FUZZ_RANDOM)$(SUFFIX)
all_period: timedump/waters$(FUZZ_RANDOM)$(SUFFIX)
tacle_rtos: timedump/tacle_rtos$(FUZZ_RANDOM)
graphics:
Rscript --vanilla plot_comparison.r mnt/timedump/sequential audiobeam
Rscript --vanilla plot_comparison.r mnt/timedump/sequential dijkstra
Rscript --vanilla plot_comparison.r mnt/timedump/sequential epic
Rscript --vanilla plot_comparison.r mnt/timedump/sequential g723_enc
# Rscript --vanilla plot_comparison.r mnt/timedump/sequential gsm_enc
# Rscript --vanilla plot_comparison.r mnt/timedump/sequential huff_dec
Rscript --vanilla plot_comparison.r mnt/timedump/sequential mpeg2
# Rscript --vanilla plot_comparison.r mnt/timedump/sequential rijndael_dec
# Rscript --vanilla plot_comparison.r mnt/timedump/sequential rijndael_enc
clean:
rm -rf corpora timedump

View File

@ -0,0 +1,309 @@
import csv
import os
envvars:
"BENCHDIR"
def_flags="--release --no-default-features --features std,snapshot_fast,restarting,do_hash_notify_state,do_hash_notify_value,fuzz_int,trace_job_response_times,observe_systemstate_unordered"
benchdir=os.environ["BENCHDIR"]
RUNTIME=(3600*24)
rule copy_kernel:
input:
"build/{target}.elf"
output:
"{benchdir}/build/{target}.elf"
shell:
"mkdir -p {benchdir}/build && cp {input} {output}"
rule rebuild_qemu:
shell:
"unset CUSTOM_QEMU_NO_BUILD CUSTOM_QEMU_NO_CONFIGURE && cargo build"
rule build_default:
input:
"../Cargo.toml",
"../src"
output:
directory("{benchdir}/bins/target_default")
shell:
"cargo build --target-dir {output} {def_flags}"
rule build_showmap:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_showmap")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_stg"
rule build_random:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_random")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},feed_longest"
rule build_frafl:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_frafl")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_frafl,feed_longest"
rule build_afl:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_afl")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_afl"
rule build_stg:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_stg")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_stg"
rule build_stgwoet:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_stgwoet")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_stg_woet"
rule build_stg_abbpath:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_stg_abbpath")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_stg_abbpath"
rule build_stg_edge:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_stg_edge")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_stg_edge"
rule build_feedgeneration1:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_feedgeneration1")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},feed_genetic,gensize_1"
rule build_feedgeneration10:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_feedgeneration10")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},feed_genetic,gensize_10"
rule build_feedgeneration100:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_feedgeneration100")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_genetic,gensize_100"
rule build_genetic100:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_genetic100")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_genetic,mutate_stg,gensize_100"
rule build_feedgeneration1000:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_feedgeneration1000")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_genetic,gensize_1000"
rule build_genetic1000:
input:
"{benchdir}/bins/target_default"
output:
directory("{benchdir}/bins/target_genetic1000")
shell:
"cp -r -a --reflink=auto {input} {output} && cargo build --target-dir {output} {def_flags},config_genetic,mutate_stg,gensize_1000"
rule run_bench:
input:
"{benchdir}/build/{target}.elf",
"{benchdir}/bins/target_{fuzzer}"
output:
multiext("{benchdir}/timedump/{fuzzer}/{target}#{num}", ".time", ".log") # , ".case"
run:
with open('target_symbols.csv') as csvfile:
reader = csv.DictReader(csvfile)
line = next((x for x in reader if x['\ufeffkernel']==wildcards.target), None)
if line == None:
return False
kernel=line['\ufeffkernel']
fuzz_main=line['main_function']
fuzz_input=line['input_symbol']
fuzz_len=line['input_size']
bkp=line['return_function']
select_task=line['select_task']
if wildcards.fuzzer.find('random') >= 0:
script="""
export RUST_BACKTRACE=1
mkdir -p $(dirname {output[0]})
set +e
echo $(pwd)/{input[1]}/release/fret -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num} -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv fuzz --random -t {RUNTIME} -s {wildcards.num}
$(pwd)/{input[1]}/release/fret -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num} -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv fuzz --random -t {RUNTIME} -s {wildcards.num} > {output[1]} 2>&1
exit 0
"""
else:
script="""
export RUST_BACKTRACE=1
mkdir -p $(dirname {output[0]})
set +e
echo $(pwd)/{input[1]}/release/fret -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num} -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv fuzz -t {RUNTIME} -s {wildcards.num}
$(pwd)/{input[1]}/release/fret -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num} -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv fuzz -t {RUNTIME} -s {wildcards.num} > {output[1]} 2>&1
exit 0
"""
shell(script)
rule run_showmap:
input:
"{benchdir}/build/{target}.elf",
"{benchdir}/bins/target_showmap",
"{benchdir}/timedump/{fuzzer}/{target}#{num}.case"
output:
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.trace.ron",
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.time",
run:
with open('target_symbols.csv') as csvfile:
reader = csv.DictReader(csvfile)
line = next((x for x in reader if x['\ufeffkernel']==wildcards.target), None)
if line == None:
return False
kernel=line['\ufeffkernel']
fuzz_main=line['main_function']
fuzz_input=line['input_symbol']
fuzz_len=line['input_size']
bkp=line['return_function']
select_task=line['select_task']
script="""
export FUZZER=$(pwd)/{input[1]}/release/fret
mkdir -p $(dirname {output})
set +e
echo $FUZZER -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num}_case -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv showmap -i {input[2]}
$FUZZER -n $(pwd)/{benchdir}/timedump/{wildcards.fuzzer}/{wildcards.target}#{wildcards.num}_case -s {select_task} -t -a -r -g -k {input[0]} -c ./target_symbols.csv showmap -i {input[2]}
exit 0
"""
if wildcards.fuzzer.find('random') >= 0:
script="export FUZZ_RANDOM=1\n"+script
shell(script)
rule transform_trace:
input:
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.trace.ron",
output:
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.jobs.csv",
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.resp.csv",
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.abbs.csv"
run:
with open('target_symbols.csv') as csvfile:
reader = csv.DictReader(csvfile)
line = next((x for x in reader if x['\ufeffkernel']==wildcards.target), None)
if line == None:
return False
kernel=line['\ufeffkernel']
fuzz_main=line['main_function']
fuzz_input=line['input_symbol']
fuzz_len=line['input_size']
bkp=line['return_function']
select_task=line['select_task']
script="""
echo $(pwd)/../../../../state2gantt/target/debug/state2gantt -i {input} -a {output[0]} -r {output[1]} -p {output[2]} -t {select_task}
$(pwd)/../../../../state2gantt/target/debug/state2gantt -i {input} -a {output[0]} -r {output[1]} -p {output[2]} -t {select_task}
"""
shell(script)
rule trace2gantt:
input:
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.jobs.csv",
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.resp.csv"
output:
"{benchdir}/timedump/{fuzzer}/{target}#{num}_case.jobs.html",
shell:
"Rscript $(pwd)/../../../../state2gantt/plot_response.r {input[0]} {input[1]} html"
rule quicktest:
params:
benchdir=benchdir
input:
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stg', 'random'], target=['polycopter'], variant=['_seq_dataflow_full'], num=range(0,int( 1 ))),
# main scenarios
# main competitors: 10
# frafl: 10
# random: 5
# low prio scenarios
# main competitors: 8
# frafl: 8
# random: 5
rule set128:
params:
benchdir=benchdir
input:
# waters full
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stgwoet'], target=['waters'], variant=['_seq_full', '_seq_unsync_full'], num=range(0,int( 10 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['frafl'], target=['waters'], variant=['_seq_full', '_seq_unsync_full'], num=range(0,int( 10 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['random'], target=['waters'], variant=['_seq_full', '_seq_unsync_full'], num=range(0,int( 5 ))),
# release full
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stgwoet'], target=['release'], variant=['_seq_full'], num=range(0,int( 10 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['frafl'], target=['release'], variant=['_seq_full'], num=range(0,int( 10 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['random'], target=['release'], variant=['_seq_full'], num=range(0,int( 5 ))),
# release int (low prio)
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stgwoet'], target=['release'], variant=['_seq_int'], num=range(0,int( 5 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['random', 'frafl'], target=['release'], variant=['_seq_int'], num=range(0,int( 5 ))),
rule set48:
params:
benchdir=benchdir
input:
# polycopter full
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stgwoet'], target=['polycopter'], variant=['_seq_dataflow_full'], num=range(0,int( 12 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['frafl'], target=['polycopter'], variant=['_seq_dataflow_full'], num=range(0,int( 12 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['random'], target=['polycopter'], variant=['_seq_dataflow_full'], num=range(0,int( 10 ))),
rule set64:
params:
benchdir=benchdir
input:
# waters int+bytes (low prio)
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['feedgeneration100', 'stgwoet', 'frafl'], target=['waters'], variant=['_seq_int', '_seq_bytes'], num=range(0,int( 8 ))),
expand("{benchdir}/timedump/{fuzzer}/{target}{variant}#{num}.time", benchdir=benchdir, fuzzer=['random'], target=['waters'], variant=['_seq_int', '_seq_bytes'], num=range(0,int( 5 ))),
rule all_bins:
params:
benchdir=benchdir
input:
expand("{benchdir}/bins/target_{target}", benchdir=benchdir, target=['random','frafl','stg','stgwoet','feedgeneration100','genetic100'])
rule clean:
shell:
"rm -rf {benchdir}/timedump"
rule full_clean:
shell:
"rm -rf {benchdir}/bins & rm -rf {benchdir}/timedump"

View File

@ -0,0 +1,5 @@
#!/bin/sh
export TOPLEVEL="remote/timedump"
[ -d "$TOPLEVEL/feedgeneration100" ] && mv $TOPLEVEL/feedgeneration100 $TOPLEVEL/evolutionary
[ -d "$TOPLEVEL/stg" ] && mv $TOPLEVEL/stg $TOPLEVEL/fret
[ -d "$TOPLEVEL/frafl" ] && mv $TOPLEVEL/frafl $TOPLEVEL/coverage

View File

@ -0,0 +1,15 @@
def_flags="--no-default-features --features std,snapshot_fast,restarting,do_hash_notify_state,trace_job_response_times,fuzz_int"
set -e
cargo build --target-dir ./bins/target_showmap ${def_flags},config_stg
cargo build --target-dir ./bins/target_random ${def_flags},feed_longest
cargo build --target-dir ./bins/target_frafl ${def_flags},config_frafl,feed_longest
cargo build --target-dir ./bins/target_afl ${def_flags},config_afl,observe_hitcounts
cargo build --target-dir ./bins/target_stg ${def_flags},config_stg
cargo build --target-dir ./bins/target_stgpath ${def_flags},feed_stg_abbhash,sched_stg_abbhash,mutate_stg
cargo build --target-dir ./bins/target_feedgeneration1 ${def_flags},feed_genetic,gensize_1
cargo build --target-dir ./bins/target_feedgeneration10 ${def_flags},feed_genetic,gensize_10
cargo build --target-dir ./bins/target_feedgeneration100 ${def_flags},feed_genetic,gensize_100
cargo build --target-dir ./bins/target_feedgeneration1000 ${def_flags},feed_genetic,gensize_1000
cargo build --target-dir ./bins/target_genetic100 ${def_flags},feed_genetic,mutate_stg,gensize_100
cargo build --target-dir ./bins/target_genetic1000 ${def_flags},feed_genetic,mutate_stg,gensize_1000

View File

@ -0,0 +1,125 @@
#!/usr/bin/env bash
export INSERT_WC=${2:-0}
export BUILD_DIR=${1:-build}
mkdir -p $BUILD_DIR
build () {
make -C ../../../../FreeRTOS/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC clean && make -C ../../../../FreeRTOS/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC $1=1 IGNORE_INTERRUPTS=$IGNORE_INTERRUPTS IGNORE_BYTES=$IGNORE_BYTES IGNORE_INTERNAL_STATE=$IGNORE_INTERNAL_STATE INSERT_WC=$INSERT_WC $EXTRA_MAKE_ARGS
cp ../../../../FreeRTOS/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/build/RTOSDemo.axf $BUILD_DIR/$(echo $1 | cut -d_ -f1 | tr '[:upper:]' '[:lower:]')$EXTRA_NAME_SUFFIX$2.elf
}
mkdir -p build
# Sequential inputs!
export PARTITION_INPUT=0
unset SPECIAL_CFLAGS
# Baseline
## Don't keep rng states
export IGNORE_INTERNAL_STATE=1
### Only bytes
export IGNORE_INTERRUPTS=1 IGNORE_BYTES=0 SUFFIX="_seq_bytes"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
### Only interrupts
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=1 SUFFIX="_seq_int"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
### Full
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_seq_full"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
build POLYCOPTER_DEMO $SUFFIX
# Stateful -> presumably bad for us
## keep rng states
export IGNORE_INTERNAL_STATE=0
### Full
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_seq_stateful_full"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
# Paritioned inputs
export PARTITION_INPUT=1
# Alternative input scheme
## Don't keep rng states
export IGNORE_INTERNAL_STATE=1
### Only bytes
export IGNORE_INTERRUPTS=1 IGNORE_BYTES=0 SUFFIX="_par_bytes"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
### Only interrupts
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=1 SUFFIX="_par_int"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
### Full
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_par_full"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
build POLYCOPTER_DEMO $SUFFIX
# Stateful -> presumably bad for us
## keep rng states
export IGNORE_INTERNAL_STATE=0
### Full
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_par_stateful_full"
build WATERS_DEMO $SUFFIX
build RELEASE_DEMO $SUFFIX
build COPTER_DEMO $SUFFIX
# Stateful -> presumably bad for us
## keep rng states
export IGNORE_INTERNAL_STATE=0
export PARTITION_INPUT=0
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_seq_stateful_full"
build POLYCOPTER_DEMO $SUFFIX
# stateless + dataflow
export PARTITION_INPUT=0
export IGNORE_INTERNAL_STATE=1
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_seq_dataflow_full"
export SPECIAL_CFLAGS="-DCOPTER_DATAFLOW=1"
build POLYCOPTER_DEMO $SUFFIX
unset SPECIAL_CFLAGS
export PARTITION_INPUT=0
export IGNORE_INTERNAL_STATE=1
export IGNORE_INTERRUPTS=1 IGNORE_BYTES=0 SUFFIX="_seq_dataflow_bytes"
export SPECIAL_CFLAGS="-DCOPTER_DATAFLOW=1"
build POLYCOPTER_DEMO $SUFFIX
unset SPECIAL_CFLAGS
# stateless + dataflow
export PARTITION_INPUT=1
export IGNORE_INTERNAL_STATE=1
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_par_dataflow_full"
export SPECIAL_CFLAGS="-DCOPTER_DATAFLOW=1"
build POLYCOPTER_DEMO $SUFFIX
unset SPECIAL_CFLAGS
# special waters with no synchronization
export PARTITION_INPUT=0
export IGNORE_INTERNAL_STATE=1
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_seq_unsync_full"
export SPECIAL_CFLAGS="-DWATERS_UNSYNCHRONIZED=1"
build WATERS_DEMO $SUFFIX
unset SPECIAL_CFLAGS
# special generated waters 2015
export PARTITION_INPUT=0
export IGNORE_INTERNAL_STATE=1
export IGNORE_INTERRUPTS=0 IGNORE_BYTES=0 SUFFIX="_par_bytes"
export EXTRA_MAKE_ARGS="SEED=1"
export EXTRA_NAME_SUFFIX="1"
build WATERSGEN_DEMO $SUFFIX
unset EXTRA_MAKE_ARGS
unset EXTRA_NAME_SUFFIX

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
find $1 -type 'f' -iname "${2}#*.log" | while IFS="" read -r p || [ -n "$p" ]
do
LINE=$(tail -n 100 $p | grep -io "run time: .* corpus: [0-9]*" | tail -n 1)
echo $p: $LINE
LINE=$(grep -i "interesting corpus elements" $p | tail -n 1)
echo $p: $LINE
done

View File

@ -0,0 +1 @@
*.sqlite

View File

@ -0,0 +1,11 @@
[package]
name = "number_cruncher"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.5.28", features = ["derive"] }
itertools = "0.14.0"
rayon = "1.10.0"
regex = "1.11.1"
rusqlite = "0.33.0"

View File

@ -0,0 +1,295 @@
use clap::parser::ValueSource;
use clap::Parser;
use itertools::Group;
use itertools::Itertools;
use rayon::iter::ParallelBridge;
use rayon::prelude::*;
use rayon::result;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::path::PathBuf;
use rusqlite::{params, Connection, Result};
use std::collections::HashMap;
#[derive(clap::ValueEnum, Clone, PartialEq)]
enum Endpoint {
AllMin,
ToolMin,
ToolMax,
Max
}
#[derive(Parser)]
struct Config {
/// Input
#[arg(short, long, value_name = "DIR")]
input: PathBuf,
/// Output
#[arg(short, long, value_name = "FILE", default_value = "out.sqlite")]
output: PathBuf,
/// End each group after the first termination
#[arg(short, long, default_value = "max")]
end_early: Endpoint,
}
fn visit_dirs(
dir: &Path,
results: &mut Vec<(PathBuf, String, String, String)>,
) -> std::io::Result<()> {
if dir.is_dir() {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
visit_dirs(&path, results)?;
} else if path.extension().and_then(|s| s.to_str()) == Some("time") {
if let Some(file_name) = path.file_name().and_then(|s| s.to_str()) {
let re = regex::Regex::new(r".*#[0-9]+\.time$").unwrap();
if re.is_match(file_name) {
if let Some(dir_name) = path
.parent()
.and_then(|p| p.file_name())
.and_then(|s| s.to_str())
{
{
let mut file_stem =
path.file_stem().unwrap().to_str().unwrap().split("#");
let case_name = file_stem.next().unwrap();
let case_number = file_stem.next().unwrap();
results.push((
path.clone(),
dir_name.to_string(),
case_name.to_string(),
case_number.to_string(),
));
}
}
}
}
}
}
}
Ok(())
}
fn maxpoints_of_file(file_path: &Path) -> io::Result<Vec<(usize, usize)>> {
let file = File::open(file_path)?;
let reader = BufReader::new(file);
let mut results = Vec::new();
let mut watermark = 0;
let mut last_timestamp = 0;
for line in reader.lines() {
let line = line?;
let mut parts = line.split(',');
if let (Some(first_str), Some(second_str)) = (parts.next(), parts.next()) {
let first: usize = first_str.trim().parse().unwrap();
let second: usize = second_str.trim().parse().unwrap();
if first > watermark {
results.push((first, second));
watermark = first;
}
last_timestamp = second;
}
}
if results.len() > 1 {
results[0].1 = 0;
results.push((results[results.len() - 1].0, last_timestamp));
}
if results.len() == 0 {
results.push((0, 0));
results.push((0, last_timestamp));
}
Ok(results)
}
fn sample_maxpoints(points: &Vec<(usize, usize)>, samples: &Vec<usize>) -> Vec<(usize, usize)> {
let mut todo = samples.iter().peekable();
let mut ret = Vec::new();
for i in 0..points.len() {
if todo.peek().is_none() {
// Done
break;
}
while let Some(&&peek) = todo.peek() {
if peek >= points[i].1 && (i+1 >= points.len() || peek < points[i+1].1) {
// End or inside the interval
ret.push((points[i].0, peek));
todo.next();
} else if peek < points[i].1 {
if i == 0 {
// Before the first interval, just take the first
ret.push((points[i].0, peek));
todo.next();
} else {
// Already passed
eprintln!("WARNING Skipped: {}", todo.next().unwrap());
}
} else {
// Not yet
break;
}
}
}
ret
}
// https://rust-lang-nursery.github.io/rust-cookbook/science/mathematics/statistics.html
fn mean(data: &[usize]) -> Option<f64> {
let sum = data.iter().sum::<usize>() as f64;
let count = data.len();
match count {
positive if positive > 0 => Some(sum / count as f64),
_ => None,
}
}
fn median(data: &[usize]) -> Option<f64> {
let mut data = data.to_vec();
data.sort();
let size = data.len();
if size == 0 {
return None;
}
match size {
even if even % 2 == 0 => {
let fst_med = data[(even / 2) - 1];
let snd_med = data[even / 2];
fst_med.checked_add(snd_med).map(|x| x as f64 / 2.0)
},
odd => data.get(odd / 2).map(|x| *x as f64)
}
}
// https://rust-lang-nursery.github.io/rust-cookbook/science/mathematics/statistics.html
fn std_deviation(data: &[usize]) -> Option<f64> {
match (mean(data), data.len()) {
(Some(data_mean), count) if count > 0 => {
let variance = data
.iter()
.map(|value| {
let diff = data_mean - (*value as f64);
diff * diff
})
.sum::<f64>()
/ count as f64;
Some(variance.sqrt())
}
_ => None,
}
}
fn main() {
let conf = Config::parse();
let mut results = Vec::new();
if let Err(e) = visit_dirs(&conf.input, &mut results) {
eprintln!("Error reading directories: {}", e);
}
println!("Files: {:?}", results);
let mut connection = Connection::open(conf.output).unwrap();
connection.execute("DROP TABLE IF EXISTS combos", ()).unwrap();
connection.execute("CREATE TABLE IF NOT EXISTS combos (casename TEXT, toolname TEXT, fullname TEXT PRIMARY KEY)", ()).unwrap();
let mut points: Vec<_> = results
.par_iter()
.map(|(path, fuzzer, case, n)| {
(
case,
fuzzer,
n.parse::<usize>().unwrap(),
maxpoints_of_file(path).unwrap(),
)
})
.collect();
let mut last_common_point = points.iter().map(|x| x.3.last().expect(&format!("Missing maxpoint for {}", x.0)).1).min().unwrap();
points.sort_by_key(|x| x.0); // by case for grouping
for (case, casegroup) in &points.into_iter().chunk_by(|x| x.0) {
let casegroup = casegroup.collect::<Vec<_>>();
let last_case_point = casegroup.iter().map(|x| x.3.last().unwrap().1).min().unwrap();
println!("Processing case {}: {}", case, casegroup.len());
let mut timestamps = Vec::new();
for (_, _, _, points) in &casegroup {
timestamps.extend(points.iter().map(|(_, t)| *t));
}
timestamps.sort();
if matches!(conf.end_early, Endpoint::AllMin) {
// Dont' sample anything after the shortest run
timestamps = timestamps.into_iter().filter(|x| x<=&last_common_point).collect();
}
let least_runtime_per_tool = casegroup.iter().map(|g| (g.1, g.2, g.3.last().unwrap().1)).sorted_by_key(|x| x.0).chunk_by(|x| x.0).into_iter().map(|(tool, toolgroup)| (tool, toolgroup.min_by_key(|y| y.2))).collect::<HashMap<_,_>>();
let longest_runtime_per_tool = casegroup.iter().map(|g| (g.1, g.2, g.3.last().unwrap().1)).sorted_by_key(|x| x.0).chunk_by(|x| x.0).into_iter().map(|(tool, toolgroup)| (tool, toolgroup.max_by_key(|y| y.2))).collect::<HashMap<_,_>>();
timestamps.dedup();
let mut maxpoints_per_tool = casegroup
.par_iter()
.map(|g| (g.0, g.1, g.2, sample_maxpoints(&g.3, &timestamps)))
.collect::<Vec<_>>();
maxpoints_per_tool.sort_by_key(|x| x.1); // by tool
for (tool, toolgroup) in &maxpoints_per_tool.into_iter().chunk_by(|x| x.1) {
let toolgroup = toolgroup.collect::<Vec<_>>();
println!("Processing tool {}: {}", tool, toolgroup.len());
let mut lowest_common_length = toolgroup
.iter()
.map(|(_, _, _, points)| points.len())
.min()
.unwrap();
if conf.end_early == Endpoint::ToolMin {
lowest_common_length = timestamps.binary_search(&least_runtime_per_tool[tool].unwrap().2).unwrap();
}
if conf.end_early == Endpoint::ToolMax {
lowest_common_length = std::cmp::min(lowest_common_length, timestamps.binary_search(&longest_runtime_per_tool[tool].unwrap().2).unwrap());
}
let time_min_max_med_mean_sdiv : Vec<(usize,usize,usize,f64,f64,f64)> = (0..lowest_common_length)
.into_par_iter()
.map(|i| {
let slice = toolgroup.iter().map(|(_, _, _, p)| p[i].0).collect::<Vec<_>>();
assert_eq!(slice.len(), toolgroup.len());
(
toolgroup[0].3[i].1,
*slice.iter().min().unwrap_or(&0),
*slice.iter().max().unwrap_or(&0),
median(&slice).unwrap_or(0.0),
mean(&slice).unwrap_or(0.0),
std_deviation(&slice).unwrap_or(0.0),
)
})
.collect::<Vec<_>>();
// Save to db
connection.execute("INSERT INTO combos (casename, toolname, fullname) VALUES (?, ?, ?)", (case, tool, format!("{}${}",case, tool))).unwrap();
connection.execute(&format!("DROP TABLE IF EXISTS {}${}", case, tool), ()).unwrap();
connection.execute(&format!("CREATE TABLE IF NOT EXISTS {}${} (timestamp INTEGER PRIMARY KEY, min INTEGER, max INTEGER, median REAL, mean REAL, sdiv REAL)", case, tool), ()).unwrap();
// Start a transaction
let transaction = connection.transaction().unwrap();
let mut stmt = transaction.prepare(&format!(
"INSERT INTO {}${} (timestamp , min , max , median , mean , sdiv ) VALUES (?, ?, ?, ?, ?, ?)",
case, tool
)).unwrap();
for (timestamp, min, max, median, mean, sdiv) in time_min_max_med_mean_sdiv {
stmt.execute([(timestamp as i64).to_string(), (min as i64).to_string(), (max as i64).to_string(), median.to_string(), mean.to_string(), sdiv.to_string()]).unwrap();
}
drop(stmt);
// Commit the transaction
transaction.commit().unwrap();
}
}
}

View File

@ -0,0 +1,35 @@
BDIR=remote
plot () {
[ ! -f ../benchmark/$BDIR/${1}${2}_all.png ] && Rscript plot_multi.r $BDIR/timedump ${1}${2} ../benchmark/$BDIR
}
# Only bytes
export SUFFIX="_seq_bytes"
plot waters $SUFFIX
#plot release $SUFFIX
plot copter $SUFFIX
#plot interact $SUFFIX
# Only interrupts
export SUFFIX="_seq_int"
plot waters $SUFFIX
plot release $SUFFIX
plot copter $SUFFIX
#plot interact $SUFFIX
# Full
export SUFFIX="_seq_full"
plot waters $SUFFIX
#plot release $SUFFIX
plot copter $SUFFIX
#plot interact $SUFFIX
plot copter "_seq_stateless_full"
plot copter "_par_full"

View File

@ -0,0 +1,13 @@
#!/bin/sh
if [[ -n "$1" ]]; then
TARGET="$1"
else
TARGET=$BENCHDIR
fi
# Check if bench.sqlite needs to be updated
if [[ ! -f $TARGET/bench.sqlite || $(find $TARGET/timedump -name '.*[0-9]+\.time' -newer $TARGET/bench.sqlite | wc -l) -gt 0 ]]; then
number_cruncher/target/debug/number_cruncher -i $TARGET/timedump -o $TARGET/bench.sqlite
fi
Rscript plot_sqlite.r $TARGET/bench.sqlite $TARGET

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
./sem.sh /tmp/plot reset 20
declare -a PLOTS
COUNT=0
while IFS="" read -r p || [ -n "$p" ];
do
if [[ -z "$p" ]]; then
continue
fi
PLOTS[$COUNT]="$p"
COUNT=$((COUNT+1))
../../../../state2gantt/driver_sem.sh $p &
done < <(find $BENCHDIR/timedump -maxdepth 2 -type 'f' -iregex '.*icounttrace.ron$')

View File

@ -0,0 +1,33 @@
get_max_nodecount () {
rm -f sizecomp && for sizefile in $BENCHDIR/timedump/**/$1*.stgsize;do echo "$(tail -n 1 $sizefile),${sizefile}" >> sizecomp; done; sort -n sizecomp | tail -n 1
}
get_largest_files () {
T=$(get_max_nodecount $1)
echo $T | cut -d',' -f6
}
perform () {
T=$(get_max_nodecount $1)
echo $T | cut -d',' -f6
echo $T | cut -d',' -f6 | xargs -I {} ./plot_stgsize.r {}
mv "$(echo $T | cut -d',' -f6 | xargs -I {} basename -s .stgsize {})_nodes.png" $1_nodes.png
}
# perform copter
# perform release
# perform waters
A=$(get_largest_files polycopter_seq_dataflow_full)
B=$(get_largest_files release_seq_full)
C=$(get_largest_files waters_seq_full)
# A_="$(echo $A | sed 's/polycopter_seq_dataflow_full/UAV w. hid. com./')"
# B_="$(echo $B | sed 's/release_seq_full/Async. rel./')"
# C_="$(echo $C | sed 's/waters_seq_full/Waters ind. ch./')"
A_="UAV"
B_="Async. rel."
C_="Waters ind. ch."
echo $A_ $B_ $C_
cp $A "$A_"
cp $B "$B_"
cp $C "$C_"
./plot_stgsize_multi.r "$A_" "$B_" "$C_"

Some files were not shown because too many files have changed in this diff Show More