654 Commits

Author SHA1 Message Date
s1341
dea96ab59c frida: modules may be relative paths; move to ahash for filenames; fix tls bug 2021-04-30 15:35:40 +03:00
s1341
e62f4de6b5
Various fixes for frida-asan on aarch64-linux-android (#64) 2021-04-29 19:31:36 +02:00
Dominik Maier
dadc486452 added restarts to libfuzzer example, docu cleanup 2021-04-29 10:55:31 +02:00
andreafioraldi
4747a35936 MSVC fixes 2021-04-28 08:47:07 +02:00
s1341
5c856cccc8
WIP: Implement ASAN instrumentation using frida (#45)
* frida_asan: Implemented initial asan runtime library

* frida_asan: Switch to hashbrown

* Implemented GOT-based hooking to isolate the hooking of the memory functions. Implemented initial ASAN instrumentation

* WIP: Shadowing all used memory. Currently tracking pages using a BTreeSet. Slow AF!

* Add SigTrap to unix_signals and inprocess

* Working frida-asan, almost no speed degradation.

Currently the shadow check is reversed, so it checks only that the shadow is not 0.
We need to implement sub-8-byte checking.

* Format

* Cleanup and formatting

* Sub-qword and 16-byte checks implemented; Fixed unaligned access to QWORD

* Pass the ucontext_t to signal handlers. Initial regdump on crash

* Fix typo

* Make the context argument a mut ref

* Add missing files; Implement initial reporting

* Refactor out gothook; Move safety checkers to dynasm

* Get rid of const assembly blobs no longer needed

* Move to a handler function instead of using SIGTRAP.

This bloats the transformed code, but doesn't seem to have a major impact on performance.

Also, implemented pretty backtraces and assembly output.

* Formatting

* Get rid of all the pinning crap I wasted my day on, We don't need it

* windows fixes

* ashmem

* ashmem_service: server side ready

* ashmem_service: client side ready. Ready for integration

* ashmem_service: changes to UnixShMem to make it 'threadable'

* ashmem_service: format

* ashmem_service: Undo changes to UnixShMem, make the thread own the AshmemService instead; Fix protocol bug

* ashmem_service: working ashmem service. Fix merge issues

* use the newly released capston e 0.8.0; Fix a nasty bug where the afl_area an pc_pointer were reversed. Changed Vectors to Boxed [u8]

* Implement type detection for reporting; Implement double-free/unallocated free checking

* fmt

* Cleanup code a little

* frida-asan: This is an omnibus commit. Should probably have been a bunch of small commits, but I don't have the time/patience.

 - Implemented DrCov support in order to debug a failing harness. This is actually
   generic and should be moved out of libafl_frida.
 - Implemented LIBAFL_FRIDA_OPTIONS env var to pass options to the frida helper,
   to dynamically enable/disable asan and drcov.
 - Implemented memory reuse - after each test case the used pages are recycled and
   can be reused in the next test case.
 - Implemented and tested vectorized instruction instrumentation.
 - Implemented not instrumenting atomic load/store instructions. The cost of
   trying to emulate their behaviour is too high at the moment.
 - Implemented probing of shadow bit to determine the best match for the current
   system.
 - Implemented shadow memory pre-mapping where it is available. We probe for this
   too.
 - Implemented ability to specify a list of modules to instrument on the command
   line. This allows fine-grained control of which modules are instrumented for
   coverage/asan/drcov.
 - Implemented unpoisoning of the Input target_bytes in a pre_exec hook.
 - Added support for zero-sized allocations. We return 0x10 bytes at the moment.
 - Added all known operator new/delete functions to hooks.
 - Added workaround for frida_gum_allocate_near bug.
 - Cleaned up reporting, added reporting for different error types.

* frida-asan: Implement leak detection

* Fix merge issues

* Rebased on dev to get llmp/shmem changes; Clippy fixes

* Add FridaOptions struct

* Add the Custom ExitKind; Get rid of Clone/PartialEq on ExitKind

* Make it possible to recover from an ASAN error

* Add SIGTRAP to crashing signals

* Add back (conditional) crashing on Asan errors.

* Fix too-large immediates in add instruction

* Implement RcShMemProvider, finally fix the EOP bug

* Clear ASAN_ERRORS before each test

* Fix warnings; Fix review issues

* Cleanup prints

* Add timeout to Frida mode

* Make allocation-/free-site backtraces optional

* CPU Context and backtrace (on android/aarch64 atm) on crash

* Make stalker conditional

* Add metadata to solution, and write metadata files

* Add addresses to backtrace; Add reporting of ASAN stack errors; Fix ASAN reporting bugs

* Remove meaningless backtrace on crash

* Fix the x0, x1 load in report

* use upstream color-backtrace

* use __builtin_thread_pointer instead of custom asm

* Don't unwrap ASAN_ERRORS if it isn't some

* Fix bug where we weren't clearing the drcov basicblocks after each run

* Fix bug where we were dropping an ashmem too soon

* Fix OwnedPtr instead of CPtr

* Fix gettls for all archs

* cfg guards for target arch, disabling Frida-ASAN/-DrCov if not on aarch64

* Cargo fmt

* Only panic in options when asan/drcov are turned on; Merge fixes

* gothook only supported on unix

* Fix gettls on msvc

* Another attempt to fix MSVC gettls

* Fix backtrace use

* nostd fixes; warning fixes

* formatting

* Migrate FridaEdgeCoverageHelper into libafl_frida, and rename to FridaInstrumentationHelper

* Clean up uses

* Move DrCovWriter to libafl_targets

* Refactor DrCovWriter to get a vec of DrCovBasicBlocks; formatting

* Update to newer backtrace which supports android with gimli

* windows fixes

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: andreafioraldi <andreafioraldi@gmail.com>
2021-04-28 10:12:49 +02:00
Andrea Fioraldi
f25862cb90 fix baby fuzzer 2021-04-26 09:41:35 +02:00
Andrea Fioraldi
b7de33e922 feedbacks in libfuzzer_libmozjpeg 2021-04-25 16:13:15 +02:00
Andrea Fioraldi
2f7bb8d532 baby fuzzer 2021-04-21 14:51:51 +02:00
Andrea Fioraldi
0732028190 remove qemufuzzer 2021-04-21 09:58:11 +02:00
s1341
655d30519b
Convert ShMem into a state-full ShMemProvider and otherwise refactor shmem/llmp (#54)
* shmeme/llmp refactor to convert ShMem into a stateful ShMemProvider
factory.

At the moment we use parking_lot::ReentrantMutex. That may not be
necessary.

* fix merge issue

* formatting

* Fix fuzzer examples for new ShMemProvider

* Fix clippy warnings

* Fix build and clippy for x86_64

* Resolve review comments

* Remove ReentrantMutex and RefCell - they are not needed

* Hopefully fix win32 build

* Fix tests, windows build

* Rename ShMemProvider to ShMem

* Revert "Rename ShMemProvider to ShMem"

This reverts commit eca07c8d7bb3d5e829fecf3f7213c763470a41e9.

* Rename ShMemMapping to ShMem; Test fixes

* Add missing trait to scope

* Fix from_int

* Fix try_into

* Move to alloc::sync::Arc and spin::Mutex to support nostd

* Fix tests

* nostd fixes; Make new() a part of the ShMemProvider trait

* Fix errant ?

* Fix windows

* Fix missing trait

* nostd remove dbg!

* Add Default and Clone to ShMemProvider

* Formatting

* Fix windows

* Get rid of ArcMutex in favor of RefCell

* Rc RefCell

* moved to refs

* SHP->SP

* Use alloc::rc::Rc instead of std::rc::Rc

* Format

* Add setup_restarting_mgr_std which selects the right ShMemProvider; changed fuzzers to use it

* Get rid of unnecessary clone

* Fix clippy error on windows

* Fix nostd

* Fix formatting

* Make StdShmemProvider include ServedShMemProvider

* Get rid of lifetime specifiers now that we are using Rc

* Get rid of unneccesary spin

* Rename ShMemProvider::Mapping to ShMemProvider::Mem

* Formatting

* fix Windows

* Rename DefaultUnixShmem* to CommonUnixShmem*

Co-authored-by: Dominik Maier <domenukk@gmail.com>
2021-04-16 11:26:06 +02:00
Dominik Maier
022c12568b QoL improvements 2021-04-12 12:16:45 +02:00
Dominik Maier
e505e7689c fixed merge fails 2021-04-12 11:30:44 +02:00
Grant Hernandez
24a033de31
Add tool detection to build.rs, improve README (#43)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2021-04-10 11:16:35 +02:00
s1341
c8bfe76c43
Fix android and optimize frida (#44)
* fix_android_and_optimize_frida: Fix build and run for android; optimize frida maybe_log functions

* fix_android_and_optimize_frida: Get rid of the HasFd trait; cleanup warnings

* fix_android_and_optimize_frida: fmt
2021-04-01 14:39:11 +02:00
Andrea Fioraldi
d889c8c826 libfuzzer_stb_image readme 2021-03-29 16:13:46 +02:00
Andrea Fioraldi
bd9aa89753 libfuzzer_libmozjpeg readme 2021-03-29 16:07:56 +02:00
Andrea Fioraldi
0c2a267075 remove libfuzzer_runtime and use cc wrapper for mozjpeg 2021-03-29 15:56:54 +02:00
Andrea Fioraldi
1f7be63031 value profile in libafl_targets 2021-03-26 17:53:47 +01:00
andreafioraldi
2cd046e1e8 catch assertion errors on win32 2021-03-26 11:42:26 +01:00
andreafioraldi
9c1f836ff2 fix libfuzzer_stb_image 2021-03-26 10:55:23 +01:00
andreafioraldi
7564ce1e87 libfuzzer_stb_image with build.rs and win32 fixes 2021-03-26 10:39:02 +01:00
andreafioraldi
40fe286cf9 run on win32 using the clang wrapper 2021-03-25 20:04:52 +01:00
root
a0550b3154 compile libfuzzer_libpng on windows 2021-03-25 18:50:40 +01:00
Toka
82f5dad784
Add mutator stats method (#40)
* add LogMutation trait

* change &self to &mut self

* move self.scheduler out of StdFuzzer

* reorder generics?, implement post_exec

* append metadata to the corresponding testcase in the corpus

* turn mutations into Mutators

* impl Named for mutations

* add LoggerScheduledMutator, add fn get_name() to MutatorTuple

* Fix BytesDeleteMutator, and format

* remove TupleList bound on Tail

* turn TokenInsert, TokenReplace into Mutator, fill havoc_mutations

* libfuzzer_libpng

* libfuzzer_libpng_cmpalloc

* libfuzzer_libmozjpeg

* fix tests

* fix libfuzzer_libmozjpeg

* fix tests

* fix LoggerScheduledMutator::mutate

* use vec<u8> instead of String

* fix post_exec and get_name

* fmt

* NamedTuple and HasNameIdTuple

* always clear mutations log

* fix tests

* format

* remove libafl_targets default features

* use vec<string> instead of vec<vec<u8>>

* add alloc::string::String

* format

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2021-03-25 13:04:18 +01:00
Andrea Fioraldi
21b790060d readme 2021-03-24 16:24:37 +01:00
Andrea Fioraldi
79dbdf8251 readme 2021-03-24 16:23:08 +01:00
Andrea Fioraldi
9c0fdee007 complete libfuzzer_libpng example with compiler wrapper 2021-03-24 16:15:07 +01:00
Andrea Fioraldi
8d2713c4d9 libfuzzer_libpng wrappers 2021-03-24 15:28:58 +01:00
Andrea Fioraldi
1c8cdc76a8 create libafl_targets and start new structure for libfuzzer_libpng 2021-03-23 20:39:23 +01:00
Dominik Maier
7f72d70977
Windows Fuzzing Example (#41)
* windows fuzzer target and minor changes - breaks android support and maybe linux build

* adapted windows example

* removed warnings from build.rs

* fixed build on unix

* fixed no_std

* build fix, silenced warnings

* no_std warning silenced

* clippy fixes

* fmt

* windows fuzzer target and minor changes - breaks android support and maybe linux build

* adapted windows example

* removed warnings from build.rs

* fixed build on unix

* fixed no_std

* build fix, silenced warnings

* no_std warning silenced

* clippy fixes

* fmt

* clippy

* trying to add clang support

* debugging win build

* debugging win build more

* debuggin..

* debuggin....

* more debugging

* giving up

Co-authored-by: richinseattle <richinseattle@gmail.com>
2021-03-23 13:50:22 +01:00
Dominik Maier
5f74a08316 fix frida wrapper 2021-03-22 17:02:14 +01:00
Dominik Maier
92dd0bfcb2 added main.rs wrapper for frida 2021-03-22 16:58:53 +01:00
Dominik Maier
556141e9a3 ignored frida on windows 2021-03-22 16:54:31 +01:00
Dominik Maier
11686b1667 fixed libfuzzer_libmozjpeg build 2021-03-22 15:04:56 +01:00
Dominik Maier
013dc85328 download to out_dir 2021-03-22 14:04:34 +01:00
s1341
a02cc39bba
Frida Executor Example (#27)
* inprocess: Allow InProcessExecutor to take a function pointer or a closure

* frida: initial working (but slow + buggy) frida helper

Issues:
- it's slow as ****
- there is an Llmp exception after the 227th corpus entry is found
- Cargo.toml lines currently import from a local ../frida-rust dir, as frida-rust is still under development

* inprocess: let the InProcessExecutor take a closure or a function pointer

* frida: working FridaHelper with InProcessExecutor

* frida: Apply suggestions; Move to RefCell; Cleanup warnings

* frida: link libstdc++_static.a on android

* take an FnMut in InProcessExecutor

* adapt libfuzzer_libpng to FnMut in InProcessExecutor

* create FridaInProcessExecutor and FridaEdgeCoverageHelper

* fix frida build.rs

* frida: move gum to main, get rid of lazy_static; use PageProtection enum

* stalker exclude

* frida: implement inline map-update for x86_64

* inprocess: add harness/harness_mut accessors

* format

* remove get_module_size from FridaEdgeCoverageHelper

* frida: implement aarch64 inline map update

* frida: add missing IndexMode

* add timeouts for executors

* move timeouts to observer

* add with_timeout constructor for Observer

* cast to i64 later in pre_exec

* add cfg(unix) guards

* add TimeoutExecutor

* add TimeoutFeedback and send ExitKind::Timeout from the handler

* pass Duration and move timeout stuff to post_exec

* format

* add timeouts to libpng_libfuzzer

* 10 sec timeout

* timeout executor file

* fix timeout executor no_std

* format

* todos

* Win32ShMem

* win32 exceptions

* fixes

* fix win32 build.rs

* fix win32 build.rs

* fixes fro win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* fixes for win32

* inprocess::windows_exception_handler

* inprocess::windows_exception_handler fixes

* windows_exception_handler in InProcessExecutor

* inprocess::windows_exception_handler fix

* fix windows exceptions mapping

* format

* format

* inprocess: Allow InProcessExecutor to take a function pointer or a closure

* frida: initial working (but slow + buggy) frida helper

Issues:
- it's slow as ****
- there is an Llmp exception after the 227th corpus entry is found
- Cargo.toml lines currently import from a local ../frida-rust dir, as frida-rust is still under development

* inprocess: let the InProcessExecutor take a closure or a function pointer

* frida: Apply suggestions; Move to RefCell; Cleanup warnings

* take an FnMut in InProcessExecutor

* adapt libfuzzer_libpng to FnMut in InProcessExecutor

* reenabled ci for prs

* frida: update to frida-rust 0.3.2

* frida: fix buid errors

* frida: fix build_and_test.yml

* frida: uses crates.io for frida-gum and frida-gum-sys

* fix merge errors

* fix typo

* frida: x86_64 now working

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: toka <tokazerkje@outlook.com>
Co-authored-by: Dominik Maier <domenukk@gmail.com>
2021-03-22 12:45:38 +01:00
Andrea Fioraldi
8a3e4301fb format 2021-03-17 17:19:33 +01:00
Andrea Fioraldi
cd7030443e timeout executor file 2021-03-17 17:08:17 +01:00
Andrea Fioraldi
5d92871b27
Merge pull request #31 from AFLplusplus/timeout_executors
add timeouts for executors
2021-03-17 16:49:07 +01:00
Andrea Fioraldi
774dbc82d1 10 sec timeout 2021-03-17 16:46:29 +01:00
Andrea Fioraldi
46c69aeee8 add timeouts to libpng_libfuzzer 2021-03-17 15:36:56 +01:00
toka
b321675aa9 add TimeoutFeedback and send ExitKind::Timeout from the handler 2021-03-16 18:48:40 +09:00
toka
ab3d070f1a add TimeoutExecutor 2021-03-16 18:13:18 +09:00
Andrea Fioraldi
eaa5b15304 readmes 2021-03-11 10:15:53 +01:00
Andrea Fioraldi
93d484bb58 posix_memalign in calloc 2021-03-11 10:11:22 +01:00
Andrea Fioraldi
3752821ab4 create libfuzzer_libpng_cmpalloc 2021-03-11 10:09:42 +01:00
Dominik Maier
f7db29d213 workaround for recursive malloc in release mode 2021-03-10 19:40:39 +01:00
Andrea Fioraldi
add3cf9665 rewrite alloc size tracking in rt.c 2021-03-09 15:23:40 +01:00
Andrea Fioraldi
dbe935b078 time feedback in libfuzzer example 2021-03-09 15:18:50 +01:00
s1341
b048ddf470
Better Unix Signal Handling Abstractions (#22)
* WIP: unix_signal_handling

* WIP: unix_signal_handling, another try

* only emit a single illegal instruction

* unix_signal_handling: Now working

* unix_signal_handling: squash warnings

* unix_signal_handling: formatting

* fix spelling

* unix_signal_handling: add missing file

* unix_signal_handling: port LlmpBroker

* unix_signal_handling: fix missing import

* moving towards no_std compatibility

* unix_signal_handling: get rid of HashMap, Mutex and lazy-static

* unix_signal_handling: formatting

* readme

* no_std fixes

* fixed windows build

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
2021-03-05 15:36:44 +01:00