Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions .github/workflows/blank.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/build-linux-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Linux Docker Images for Mayhem

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Check out the repo
uses: actions/checkout@v5

- name: Docker login
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- name: Build images
env:
MAYHEM_DOCKER_REGISTRY: docker.io
run: make build

- name: Push images
env:
MAYHEM_DOCKER_REGISTRY: docker.io
run: make push
67 changes: 67 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build Windows Targets for Mayhem

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- name: Check out the repo
uses: actions/checkout@v5

- name: Setup Developer Command Prompt
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64

- name: Build Windows C++ targets
run: |
cl.exe cpp\windows\base-executable\msvc-cpp-base-executable\src\fuzz_target.cpp /nologo /Zi /FS /MDd /EHsc /Fo: "fuzz_target_msvc.obj" /Fe: "fuzz_target_msvc.exe"
clang++.exe cpp\windows\base-executable\clang-cpp-base-executable\src\fuzz_target.cpp -g -O1 -o fuzz_target_clang.exe
clang++.exe cpp\windows\libfuzzer\src\libfuzzer_target.cpp -g -O1 -fsanitize=fuzzer -o fuzz_target_libfuzzer.exe
g++.exe cpp\windows\base-executable\gcc-cpp-base-executable\src\fuzz_target.cpp -g -O1 -o fuzz_target_mingw.exe

- name: Build Windows C# targets
run: |
csc.exe /unsafe /nologo /out:/dotnet_fuzz.exe csharp\windows\base-executable\csharp-base-executable\src\dotnet_fuzz.cs

# - name: Install Mayhem
# shell: pwsh
# run: |
# Invoke-WebRequest -Uri "https://app.mayhem.security/cli/Windows/mayhem.msi" -OutFile "mayhem.msi"
# Start-Process msiexec.exe -ArgumentList "/i mayhem.msi /quiet /norestart" -Wait
# echo "MAYHEM_PATH=C:\Program Files (x86)\Mayhem\mayhem.exe" | Out-File -FilePath $env:GITHUB_ENV -Append

# - name: Set values
# shell: pwsh
# run: |
# $mayhemUrl = if ([string]::IsNullOrEmpty("${{ inputs.mayhem_url }}")) { 'https://app.mayhem.security' } else { "${{ inputs.mayhem_url }}" }
# $workspace = if ([string]::IsNullOrEmpty("${{ inputs.workspace }}")) { 'mayhem-examples' } else { "${{ inputs.workspace }}" }
# echo "MAYHEM_URL=$mayhemUrl" | Out-File -FilePath $env:GITHUB_ENV -Append
# echo "WORKSPACE=$workspace" | Out-File -FilePath $env:GITHUB_ENV -Append

# - name: Mayhem login
# shell: pwsh
# run: |
# &$env:MAYHEM_PATH login "$env:MAYHEM_URL" "${{ secrets.MAYHEM_TOKEN }}"

# - name: Mayhem run
# shell: pwsh
# run: |
# &$env:MAYHEM_PATH package -o mayhem_package_msvc fuzz_target_msvc.exe
# Copy-Item -Path cpp\windows\base-executable\msvc\testsuite -Destination mayhem_package_msvc\testsuite
# &$env:MAYHEM_PATH run --owner $env:WORKSPACE --project mayhem-examples --target cpp-windows-msvc --duration 5m mayhem_package_msvc
# &$env:MAYHEM_PATH package -o mayhem_package_clang fuzz_target_clang.exe
# Copy-Item -Path cpp\windows\base-executable\clang\testsuite -Destination mayhem_package_clang\testsuite
# &$env:MAYHEM_PATH run --owner $env:WORKSPACE --project mayhem-examples --target cpp-windows-clang --duration 5m mayhem_package_clang
# &$env:MAYHEM_PATH package -o mayhem_package_libfuzzer fuzz_target_libfuzzer.exe
# Copy-Item -Path cpp\windows\libfuzzer\testsuite -Destination mayhem_package_libfuzzer\testsuite
# &$env:MAYHEM_PATH run --owner $env:WORKSPACE --project mayhem-examples --target cpp-windows-libfuzzer --duration 5m mayhem_package_libfuzzer
# &$env:MAYHEM_PATH package -o mayhem_package_mingw fuzz_target_mingw.exe
# Copy-Item -Path cpp\windows\base-executable\gcc\testsuite -Destination mayhem_package_mingw\testsuite
# &$env:MAYHEM_PATH run --owner $env:WORKSPACE --project mayhem-examples --target cpp-windows-mingw --duration 5m mayhem_package_mingw
27 changes: 18 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# How do I contribute?

All targets are broken down by language, fuzzer, and target. The general structure is:
All targets are broken down by language, OS, fuzzer, and target. The general structure is:

```sh
- <language>
- <fuzzer>
- <target>
- testsuite
- src
- Dockerfile
- Mayhemfile
- README.md
- <os>
- <fuzzer>
- <target>
- testsuite
- src
- Dockerfile
- Mayhemfile
- README.md
```

All targets should be able to be built and pushed using the following commands:
## Linux Targets

All Linux targets should be able to be built and pushed using the following commands:

> **Note:** You should first navigate to the corresponding target directory before executing the below commands.

Expand Down Expand Up @@ -43,3 +46,9 @@ if input[0] == "b"
```

You can also use the included `Makefile` at the root of the `mayhem-examples` repository to automatically build and push all images using the `make build` and `make push` commands, respectively.

## Windows Targets

For Windows targets, the structure is similar, but the build and packaging process is different. Namely, you will not use a Dockerfile or Mayhemfile, and will compile the target directly using the appropriate compiler for the language (e.g., `csc.exe` for C# or `clang++.exe` for C++). You can find more examples under the (`base-executable/windows/README.md`)[base-executable/windows/README.md] and [cpp/windows/libfuzzer/README.md](cpp/windows/libfuzzer/README.md) directories.

Be sure to include a `README.md` as well.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 ForAllSecure
Copyright (c) 2025 ForAllSecure

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ FUZZERS := \
c/honggfuzz/c-honggfuzz-clang \
c/honggfuzz/c-honggfuzz-gcc \
c/libfuzzer/c-libfuzzer \
cpp/afl/cpp-afl-clang \
cpp/afl/cpp-afl-gcc \
cpp/aflpp/cpp-aflpp-clang \
cpp/aflpp/cpp-aflpp-gcc \
cpp/base-executable/cpp-base-executable \
cpp/honggfuzz/cpp-honggfuzz-clang \
cpp/honggfuzz/cpp-honggfuzz-gcc \
cpp/libfuzzer/cpp-libfuzzer \
csharp/libfuzzer/csharp-sharpfuzz \
cpp/linux/afl/cpp-afl-clang \
cpp/linux/afl/cpp-afl-gcc \
cpp/linux/aflpp/cpp-aflpp-clang \
cpp/linux/aflpp/cpp-aflpp-gcc \
cpp/linux/base-executable/cpp-base-executable \
cpp/linux/honggfuzz/cpp-honggfuzz-clang \
cpp/linux/honggfuzz/cpp-honggfuzz-gcc \
cpp/linux/libfuzzer/cpp-libfuzzer \
csharp/linux/libfuzzer/csharp-sharpfuzz \
fortran/base-executable/fortran-base-executable \
go/base-executable/go-base-executable \
go/libfuzzer/go-go-fuzz \
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
Mayhem example templates for programming languages and fuzzers that you love! Like a "Hello World!" but for fuzzing!

![visitors](https://visitor-badge.glitch.me/badge?page_id=ForAllSecure.mayhem-examples)
[![CI](https://github.com/ForAllSecure/mayhem-examples/actions/workflows/blank.yml/badge.svg)](https://github.com/ForAllSecure/mayhem-examples/actions/workflows/blank.yml)
[![CI](https://github.com/ForAllSecure/mayhem-examples/actions/workflows/build-linux-docker.yml/badge.svg)](https://github.com/ForAllSecure/mayhem-examples/actions/workflows/build-linux-docker.yml)

---

## Quickstart

Use the Mayhem CLI to execute a new Mayhem run (via the `mayhem run` command) for any mayhem-examples target directory with a valid `Mayhemfile`. Alternatively, Mayhem users can use the Mayhem UI to execute a new Mayhem run by selecting and fuzzing a mayhem-examples target Docker image uploaded to either the private Mayhem Docker Registry or the public [Docker Hub](https://hub.docker.com/).

> **Note:** Before executing a Mayhem run on the mayhem-examples, you'll need to first upload the below mayhem-example targets to either a private Mayhem Docker Registry or to the public Docker Hub. Read the [How to Get Started](#how-to-get-started) section for more details.
> **Note:** Before executing a Mayhem run on most of the mayhem-examples, you'll need to first upload the below mayhem-example targets to either a private Mayhem Docker Registry, or to the public Github Container Registry or Docker Hub. Read the [How to Get Started](#how-to-get-started) section for more details. Windows targets can be built directly and packaged with the `mayhem package` command.

## Target List by Language/Fuzzer

Expand Down Expand Up @@ -57,6 +57,12 @@ Order is alphabetical.
| [forallsecure/rust-cargo-fuzz](rust/libfuzzer/rust-cargo-fuzz) | Rust | Rust 1.44 | [cargo-fuzz](https://rust-fuzz.github.io/book/cargo-fuzz.html) | ![](https://img.shields.io/docker/image-size/forallsecure/rust-cargo-fuzz) | [![docker-logo](.images/docker-logo.png)](https://hub.docker.com/r/forallsecure/rust-cargo-fuzz)
| [forallsecure/swift-libfuzzer](swift/libfuzzer/swift-libfuzzer) | Swift | Swift 5.4.2 | [libFuzzer](https://github.com/apple/swift/blob/main/docs/libFuzzerIntegration.md) | ![](https://img.shields.io/docker/image-size/forallsecure/swift-libfuzzer) | [![docker-logo](.images/docker-logo.png)](https://hub.docker.com/r/forallsecure/swift-libfuzzer)


#### Looking for Windows targets?

You can find information about building Windows base executable targets [here](base-executable/windows/README.md) and Windows libFuzzer targets [here](cpp/windows/libfuzzer/README.md).


## Supported Fuzzers

| Fuzzer | dictionary | max_length | sanitizers |
Expand Down Expand Up @@ -161,8 +167,6 @@ Mayhem can run Docker images stored on either the included private Docker regist

## About Us

ForAllSecure was founded with the mission to make the world’s critical software safe. The company has been applying its patented technology from over a decade of CMU research to solving the difficult challenge of making software safer. ForAllSecure has partnered with Fortune 1000 companies in aerospace, automotive and high-tech industries, as well as the US Department of Defense to integrate Mayhem into software development cycles for continuous security. Profitable and revenue-funded, the company is scaling rapidly.
Mayhem was founded with the mission to make the world’s critical software safe. The company has been applying its patented technology from over a decade of CMU research to solving the difficult challenge of making software safer. Mayhem has partnered with Fortune 1000 companies in aerospace, automotive and high-tech industries, as well as the US Department of Defense to integrate Mayhem into software development cycles for continuous security. Profitable and revenue-funded, the company is scaling rapidly.

* [https://forallsecure.com/](https://forallsecure.com/)
* [https://forallsecure.com/mayhem-for-code](https://forallsecure.com/mayhem-for-code)
* [https://community.forallsecure.com/](https://community.forallsecure.com/)
* [https://mayhem.security/](https://mayhem.security/)
6 changes: 3 additions & 3 deletions android/base-executable/android-base-executable/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM debian:bookworm-slim AS builder
RUN apt-get update && \
apt-get install -fy wget zip make && \
wget https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip && \
Expand All @@ -12,8 +12,8 @@ WORKDIR /android-ndk-r21e/mayhemit/jni/
RUN ../../ndk-build
WORKDIR /android-ndk-r21e/mayhemit/libs/x86_64

FROM debian:buster-slim
COPY --from=0 /android-ndk-r21e/mayhemit/libs/x86_64/mayhemit /mayhemit
FROM debian:bookworm-slim
COPY --from=builder /android-ndk-r21e/mayhemit/libs/x86_64/mayhemit /mayhemit

# Set to fuzz!
ENTRYPOINT []
Expand Down
1 change: 0 additions & 1 deletion base-executable/ada-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/android-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/c-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/cpp-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/fortran-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/go-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/java-base-executable

This file was deleted.

1 change: 1 addition & 0 deletions base-executable/linux/ada-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/android-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/c-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/fortran-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/go-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/java-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/obj-c-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/ocaml-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/powerpc-c-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/powerpc64-c-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/powerpc64le-c-base-executable
1 change: 1 addition & 0 deletions base-executable/linux/rust-base-executable
1 change: 0 additions & 1 deletion base-executable/obj-c-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/ocaml-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/powerpc-c-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/powerpc64-c-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/powerpc64le-c-base-executable

This file was deleted.

1 change: 0 additions & 1 deletion base-executable/rust-base-executable

This file was deleted.

Loading
Loading