FRET-LibAFL/fuzzers/libfuzzer_windows_asan
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
..

LibFuzzer Example for Windows with ASAN

This folder contains an example fuzzer for Windows which also uses ASAN.

We are initializing LibAFL to be compatible with ASAN.

Setup

We are currently using Clang on Windows. Make sure to install Clang through the Visual Studio installer.

We recommend using Powershell and enabling the Visual Studio environment using this script:

Push-Location "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\"
& "C:\\Windows\System32\cmd.exe" /c "vcvars64.bat & set" |
ForEach-Object {
  if ($_ -match "=") {
    $v = $_.split("=", 2); set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])" 
  }
}
Pop-Location
Write-Host "`nVisual Studio 2022 Command Prompt variables set." -ForegroundColor Yellow

After that clang should be available in the PATH.

Build

To build the fuzzer and link against the harness.cpp in this example run:

cargo make fuzzer

Running

.\libfuzzer_windows_asan.exe

Note on MSVC

The MSVC compiler (cl.exe) will work in the future. Currently, it is blocked because of a bug with coverage.

Note on ASAN

Using ASAN on Windows with MSVC is not trivial as of 2022. Depending on the harness and fuzzing target, the required compilation flags differ. Most notably, the usage of /MT and /MD for the CRT is important. All compilation artifacts should use the same config for the CRT (either all /MT or all /MD). Rust uses as of 2022 /MD as default. So compile everything with /MD.

Depending on the linking mode different ASAN libraries get linked. Definitely read this blog post by Microsoft.