Skip to content

Commit 33df973

Browse files
committed
perf_stats->instrospection; merged dev; moved back to x86 stable
2 parents 8219da3 + 730df64 commit 33df973

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4298
-874
lines changed

.github/workflows/build_and_test.yml

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,83 @@
1-
name: Build and Test
2-
3-
on:
4-
push:
5-
branches: [ main, dev ]
6-
pull_request:
7-
branches: [ main, dev ]
8-
9-
env:
10-
CARGO_TERM_COLOR: always
11-
12-
jobs:
13-
lint:
14-
strategy:
15-
matrix:
16-
os: [ubuntu-latest, windows-latest]
17-
runs-on: ${{ matrix.os }}
18-
steps:
19-
- uses: actions/checkout@v2
20-
- name: Cache cargo registry
21-
uses: actions/cache@v2
22-
with:
23-
path: |
24-
~/.cargo/registry
25-
~/.cargo/git
26-
key: clippy-cargo-${{ hashFiles('**/Cargo.toml') }}
27-
- name: Add clippy
28-
run: rustup component add clippy
29-
- name: Run clippy
30-
uses: actions-rs/cargo@v1
31-
with:
32-
command: clippy
33-
args: --all
34-
ubuntu:
35-
runs-on: ubuntu-latest
36-
steps:
37-
- uses: actions/checkout@v2
38-
- name: Default Build
39-
run: cargo build --verbose
40-
- name: Default Test
41-
run: cargo test --verbose
42-
- name: Build all features
43-
run: cd libafl && cargo build --all-features --verbose
44-
- name: Test all features
45-
run: cd libafl && cargo test --all-features --verbose
46-
- name: Build no_std
47-
run: cd libafl && cargo build --no-default-features --verbose
48-
- name: Test no_std
49-
run: cd libafl && cargo test --no-default-features --verbose
50-
- name: Build examples
51-
run: cargo build --examples --verbose
52-
- uses: actions/checkout@v2
53-
- name: Format
54-
run: cargo fmt -- --check
55-
- uses: actions/checkout@v2
56-
- name: Build Docs
57-
run: cargo doc
58-
- name: Test Docs
59-
run: cargo test --doc
60-
windows:
61-
runs-on: windows-latest
62-
steps:
63-
- uses: actions/checkout@v2
64-
- name: Windows Build
65-
run: cargo build --verbose
66-
# TODO: Figure out how to properly build stuff with clang
67-
#- name: Add clang path to $PATH env
68-
# if: runner.os == 'Windows'
69-
# run: echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
70-
#- name: Try if clang works
71-
# run: clang -v
72-
#- name: Windows Test
73-
# run: C:\Rust\.cargo\bin\cargo.exe test --verbose
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
lint:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
runs-on: ${{ matrix.os }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Cache cargo registry
21+
uses: actions/cache@v2
22+
with:
23+
path: |
24+
~/.cargo/registry
25+
~/.cargo/git
26+
key: clippy-cargo-${{ hashFiles('**/Cargo.toml') }}
27+
- name: Add clippy
28+
run: rustup component add clippy
29+
#- name: Run clippy
30+
# uses: actions-rs/cargo@v1
31+
# with:
32+
# command: clippy
33+
# args: --all
34+
35+
ubuntu:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Default Build
40+
run: cargo build --verbose
41+
- name: Default Test
42+
run: cargo test --verbose
43+
- name: Build all features
44+
run: cd libafl && cargo build --all-features --verbose
45+
- name: Test all features
46+
run: cd libafl && cargo test --all-features --verbose
47+
- name: Build no_std
48+
run: cd libafl && cargo build --no-default-features --verbose
49+
- name: Test no_std
50+
run: cd libafl && cargo test --no-default-features --verbose
51+
- name: Build examples
52+
run: cargo build --examples --verbose
53+
- uses: actions/checkout@v2
54+
- name: Format
55+
run: cargo fmt -- --check
56+
- uses: actions/checkout@v2
57+
- name: Build Docs
58+
run: cargo doc
59+
- name: Test Docs
60+
run: cargo test --doc
61+
- name: Run clippy
62+
uses: actions-rs/cargo@v1
63+
with:
64+
command: clippy
65+
args: --all
66+
windows:
67+
runs-on: windows-latest
68+
steps:
69+
- uses: actions/checkout@v2
70+
- name: Windows Build
71+
run: cargo build --verbose
72+
- name: Run clippy
73+
uses: actions-rs/cargo@v1
74+
with:
75+
command: clippy
76+
# TODO: Figure out how to properly build stuff with clang
77+
#- name: Add clang path to $PATH env
78+
# if: runner.os == 'Windows'
79+
# run: echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
80+
#- name: Try if clang works
81+
# run: clang -v
82+
#- name: Windows Test
83+
# run: C:\Rust\.cargo\bin\cargo.exe test --verbose

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ members = [
1010
"libafl_derive",
1111
"libafl_cc",
1212
"libafl_targets",
13+
"libafl_frida",
14+
]
15+
default-members = [
16+
"libafl",
17+
"libafl_derive",
18+
"libafl_cc",
19+
"libafl_targets",
1320
]
1421
exclude = [
15-
"fuzzers/libfuzzer_libpng",
16-
"fuzzers/libfuzzer_stb_image",
17-
"fuzzers/libfuzzer_libmozjpeg",
18-
"fuzzers/frida_libpng",
19-
"fuzzers/baby_fuzzer",
22+
"fuzzers",
2023
]

README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,73 @@
11
# LibAFL, the fuzzer library.
22

3+
<img align="right" src="https://github.com/AFLplusplus/Website/raw/master/static/logo_256x256.png" alt="AFL++ Logo">
4+
35
Advanced Fuzzing Library - Slot your own fuzzers together and extend their features using Rust.
46

57
LibAFL is written and maintained by Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <mail@dmnk.co>.
68

7-
## What
9+
## Why LibAFL?
10+
11+
LibAFL gives you many of the benefits of an off-the-shelf fuzzer, while being completely customizable.
12+
Some highlight features currently include:
13+
- `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).
14+
- `scalable`: `Low Level Message Passing`, `LLMP` for short, allows LibAFL to scale almost linearly over cores, and via TCP to multiple machines soon!
15+
- `adaptable`: You can replace each part of LibAFL. For example, `BytesInput` is just one potential form input:
16+
feel free to add an AST-based input for structured fuzzing, and more.
17+
- `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.
18+
- `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.
19+
20+
## Overview
821

922
LibAFL is a collection of reusable pieces of fuzzers, written in Rust.
23+
It is fast, multi-platform, no_std compatible, and scales over cores and machines.
1024

1125
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).
1226

13-
LibAFL is fast, multi-platform, no_std compatible, and scales over cores (and machines in the near future!).
27+
LibAFL offers integrations with popular instrumentation frameworks. At the moment, the supported backends are:
28+
29+
+ SanitizerCoverage, in [libafl_targets](./libafl_targets)
30+
+ Frida, in [libafl_frida](./libafl_frida), by s1341 <github@shmarya.net> (Windows support is broken atm, it relies on [this upstream issue](https://github.com/meme/frida-rust/issues/9) to be fixed.)
31+
+ More to come (QEMU-mode, ...)
1432

1533
## Getting started
1634

17-
Clone the LibAFL repository with
35+
1. Install the Rust development language. We highly recommend *not* to use e.g.
36+
your Linux distribution package as this is likely outdated. So rather install
37+
Rust directly, instructions can be found [here](https://www.rust-lang.org/tools/install).
38+
39+
2. Clone the LibAFL repository with
1840

1941
```
2042
git clone https://github.com/AFLplusplus/LibAFL
2143
```
2244

45+
If you want to get the latest and greatest features,
46+
```
47+
git checkout dev
48+
```
49+
2350
Build the library using
2451

2552
```
2653
cargo build --release
2754
```
2855

29-
Build the API documentation with
56+
4. Build the API documentation with
3057

3158
```
3259
cargo doc
3360
```
3461

35-
Browse the LibAFL book with (requires [mdbook](https://github.com/rust-lang/mdBook))
62+
5. Browse the LibAFL book (WIP!) with (requires [mdbook](https://github.com/rust-lang/mdBook))
3663

3764
```
3865
cd docs && mdbook serve
3966
```
4067

41-
We collect example fuzzers in [`./fuzzers`](./fuzzers/).
68+
69+
We collect all example fuzzers in [`./fuzzers`](./fuzzers/).
70+
Be sure to read their documentation (and source), this is *the natural way to get started!*
4271

4372
The best-tested fuzzer is [`./fuzzers/libfuzzer_libpng`](./fuzzers/libfuzzer_libpng), a multicore libfuzzer-like fuzzer using LibAFL for a libpng harness.
4473

TODO.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# TODOs
22

3+
- [ ] Conditional composition of feedbacks (issue #24)
34
- [ ] Other objectives examples (e.g. execution of a given program point)
45
- [ ] Objective-Specific Corpuses (named per objective)
56
- [ ] Good documentation
@@ -12,11 +13,14 @@
1213
- [ ] LLMP Cross Machine Link (2 brokers connected via TCP)
1314
- [ ] "Launcher" example that spawns broker + n clients
1415
- [ ] Heap for signal handling (bumpallo or llmp directly?)
15-
- [x] ~~Minset corpus scheduler~~ still doc missing
16+
- [ ] Frida support for Windows
17+
- [ ] QEMU based instrumentation
18+
- [ ] AFL++ LLVM passes in libafl_cc
19+
- [x] Minset corpus scheduler
1620
- [x] Win32 shared mem and crash handler to have Windows in-process executor
1721
- [x] Other feedbacks examples (e.g. maximize allocations to spot OOMs)
1822
- [x] A macro crate with derive directives (e.g. for SerdeAny impl).
19-
- [x] Restarting EventMgr could use forks on unix
23+
- [x] Restarting EventMgr could use forks on Unix
2024
- [x] Android Ashmem support
2125
- [x] Errors in the Fuzzer should exit the fuzz run
22-
- [x] Timeouts for executors
26+
- [x] Timeouts for executors (WIP on Windows)

docs/src/design/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The LibAFL architecture is built around some entities to allow code reuse and low-cost abstractions.
44

5-
Initially, we started thinking to implement LibAFL in an Object Oriented language, such C++. When we landed to Rust, we immediately changed our idea as we realized that, while Rust allow a sort of OOP pattern, we can build the library using a more sane approach like the one described in [this blogpost](https://kyren.github.io/2018/09/14/rustconf-talk.html) about game design in Rust.
5+
Initially, we started thinking to implement LibAFL in an Object Oriented language, such C++. When we landed to Rust, we immediately changed our idea as we realized that, while Rust allows a sort of OOP pattern, we can build the library using a more sane approach like the one described in [this blogpost](https://kyren.github.io/2018/09/14/rustconf-talk.html) about game design in Rust.
66

77
The LibAFL code reuse meachanism is so based on components rather than sub-classes, but there are still some OOP patterns in the library.
88

docs/src/getting_started/setup.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ In addition, if you want to perform source-level fuzz testing of C/C++ applicati
3737
you will likely need Clang with its instrumentation options to compile the programs
3838
under test.
3939

40-
You can download and build the LLVM source tree, Clang included, following the steps
41-
explained [here](https://clang.llvm.org/get_started.html).
42-
43-
Alternatively, on Linux, you can use your distro's package manager to get Clang,
40+
On Linux you can use your distro's package manager to get Clang,
4441
but these packages are not always updated, so we suggest you to use the
4542
Debian/Ubuntu prebuilt packages from LLVM that are available using their [official repository](https://apt.llvm.org/).
4643

47-
For Miscrosoft Windows, you can download the [installer package](https://llvm.org/builds/) that LLVM generates periodically.
44+
For Microsoft Windows, you can download the [installer package](https://llvm.org/builds/) that LLVM generates periodically.
4845

4946
Despite that Clang is the default C compiler on macOS, we discourage the use of the build shipped by Apple and encourage
50-
the installation from `brew` or direclty a fresh build from the source code.
47+
the installation from `brew` or directly a fresh build from the source code.
48+
49+
Alternatively you can download and build the LLVM source tree - Clang included - following the steps
50+
explained [here](https://clang.llvm.org/get_started.html).
5151

5252
## Rust installation
5353

docs/src/libafl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ This version of the LibAFL book is coupled with the release 1.0 beta of the libr
66

77
This document is still work-in-progress and incomplete. The structure and the concepts explained here are subject to change in future revisions, as the structure of LibAFL itself will evolve.
88

9-
The HTML version of this book is available online at PLACEHOLDER and offline from the LibAFL repository in the docs/ folder.
9+
The HTML version of this book is available online at https://aflplus.plus/libafl-book/ and offline from the LibAFL repository in the docs/ folder.

docs/src/medatata/definition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ pub struct MyMetadata {
1414
}
1515
```
1616

17-
The struct must be static, so it cannot holds references to borrowed objects.
17+
The struct must be static, so it cannot hold references to borrowed objects.
1818

1919

fuzzers/frida_libpng/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ num_cpus = "1.0"
2222
which = "4.1"
2323

2424
[target.'cfg(unix)'.dependencies]
25-
libafl = { path = "../../libafl/" }
26-
frida-gum = { version = "0.3.2", optional = true, features = ["auto-download", "event-sink", "invocation-listener"] }
27-
frida-gum-sys = { version = "0.2.2", optional = true, features = ["auto-download", "event-sink", "invocation-listener"] }
25+
libafl = { path = "../../libafl/", features = [ "std" ] } #, "llmp_small_maps", "llmp_debug"]}
26+
capstone = "0.8.0"
27+
frida-gum = { version = "0.4", optional = true, features = [ "auto-download", "event-sink", "invocation-listener"] }
28+
frida-gum-sys = { version = "0.2.4", optional = true, features = [ "auto-download", "event-sink", "invocation-listener"] }
29+
libafl_frida = { path = "../../libafl_frida", version = "0.1.0" }
2830
lazy_static = "1.4.0"
2931
libc = "0.2"
3032
libloading = "0.7.0"
33+
num-traits = "0.2.14"
34+
rangemap = "0.1.10"
35+
seahash = "4.1.0"

fuzzers/frida_libpng/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ fn main() {
119119
//.arg("HAS_DUMMY_CRASH=1")
120120
.arg("-fPIC")
121121
.arg("-shared")
122+
.arg("-O3")
123+
//.arg("-fomit-frame-pointer")
122124
.arg(if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
123125
"-static-libstdc++"
124126
} else {

0 commit comments

Comments
 (0)