Skip to content

Commit

Permalink
mopt2
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed Jan 15, 2025
1 parent 9af6194 commit ff0d69c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
31 changes: 31 additions & 0 deletions fuzzers/mopt2/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG parent_image
FROM $parent_image

# Set AFL_NO_X86 to skip flaky tests.
RUN git clone https://github.com/vanhauser-THC/MOpt /afl && \
cd /afl && \
git checkout 63ce2d71134d80327b28ee2a80cae4ecbe374f54 && \
cd MOpt && AFL_NO_X86=1 make && \
cp afl-fuzz ..

# Use afl_driver.cpp from LLVM as our fuzzing library.
RUN apt-get update && \
apt-get install wget -y && cd /afl/MOpt && \
wget https://raw.githubusercontent.com/llvm/llvm-project/5feb80e748924606531ba28c97fe65145c65372e/compiler-rt/lib/fuzzer/afl/afl_driver.cpp -O /afl/MOpt/afl_driver.cpp && \
clang -Wno-pointer-sign -c -o /afl/MOpt/afl-llvm-rt.o /afl/MOpt/llvm_mode/afl-llvm-rt.o.c -I/afl/MOpt && \
clang++ -stdlib=libc++ -std=c++11 -O2 -c -o /afl/MOpt/afl_driver.o /afl/MOpt/afl_driver.cpp && \
ar r /libAFL.a *.o
37 changes: 37 additions & 0 deletions fuzzers/mopt2/fuzzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Integration code for MOpt fuzzer."""

from fuzzers.afl import fuzzer as afl_fuzzer


def build():
"""Build benchmark."""
afl_fuzzer.build()


def fuzz(input_corpus, output_corpus, target_binary):
"""Run fuzzer."""
afl_fuzzer.prepare_fuzz_environment(input_corpus)

afl_fuzzer.run_afl_fuzz(
input_corpus,
output_corpus,
target_binary,
additional_flags=[
# Enable Mopt mutator with pacemaker fuzzing mode at first. This
# is also recommended in a short-time scale evaluation.
'-L',
'0',
])
15 changes: 15 additions & 0 deletions fuzzers/mopt2/runner.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM gcr.io/fuzzbench/base-image

0 comments on commit ff0d69c

Please sign in to comment.