Skip to content

Commit 4f49e38

Browse files
committed
add naive explore fast
1 parent e7419a3 commit 4f49e38

File tree

17 files changed

+330
-10
lines changed

17 files changed

+330
-10
lines changed

fuzzers/libafl_covaccount/builder.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN wget https://gist.githubusercontent.com/tokatoka/26f4ba95991c6e3313999997633
3838
RUN git clone https://github.com/zukatsinadze/LibAFL /libafl
3939

4040
# Checkout a current commit
41-
RUN cd /libafl && git pull && git checkout 94eb2b6fe2cdcf65ace7aa9c2c9c94ee4e8e00d9 || true
41+
RUN cd /libafl && git pull && git checkout 462f87c2ce6d10dbcc4520431a0af781b306f80b || true
4242
# Note that due a nightly bug it is currently fixed to a known version on top!
4343

4444
# Compile libafl.

fuzzers/libafl_covaccount/fuzzer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ def fuzz(input_corpus, output_corpus, target_binary):
7474
command += ["-o", output_corpus, "-i", input_corpus]
7575
fuzzer_env = os.environ.copy()
7676
fuzzer_env["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
77+
fuzzer_env["FUZZSHARK_TARGET"] = "tcp"
7778
print(command)
7879
subprocess.check_call(command, cwd=os.environ["OUT"], env=fuzzer_env)

fuzzers/libafl_default/builder.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN wget https://gist.githubusercontent.com/tokatoka/26f4ba95991c6e3313999997633
3838
RUN git clone https://github.com/zukatsinadze/LibAFL /libafl
3939

4040
# Checkout a current commit
41-
RUN cd /libafl && git pull && git checkout 94eb2b6fe2cdcf65ace7aa9c2c9c94ee4e8e00d9 || true
41+
RUN cd /libafl && git pull && git checkout 462f87c2ce6d10dbcc4520431a0af781b306f80b || true
4242
# Note that due a nightly bug it is currently fixed to a known version on top!
4343

4444
# Compile libafl.

fuzzers/libafl_default/fuzzer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ def fuzz(input_corpus, output_corpus, target_binary):
7474
command += ["-o", output_corpus, "-i", input_corpus]
7575
fuzzer_env = os.environ.copy()
7676
fuzzer_env["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
77+
fuzzer_env["FUZZSHARK_TARGET"] = "tcp"
7778
print(command)
7879
subprocess.check_call(command, cwd=os.environ["OUT"], env=fuzzer_env)

fuzzers/libafl_valprof/builder.Dockerfile renamed to fuzzers/libafl_explore/builder.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ RUN wget https://gist.githubusercontent.com/tokatoka/26f4ba95991c6e3313999997633
3838
RUN git clone https://github.com/zukatsinadze/LibAFL /libafl
3939

4040
# Checkout a current commit
41-
RUN cd /libafl && git pull && git checkout 94eb2b6fe2cdcf65ace7aa9c2c9c94ee4e8e00d9 || true
41+
RUN cd /libafl && git pull && git checkout 462f87c2ce6d10dbcc4520431a0af781b306f80b || true
4242
# Note that due a nightly bug it is currently fixed to a known version on top!
4343

4444
# Compile libafl.
4545
RUN cd /libafl && \
4646
unset CFLAGS CXXFLAGS && \
4747
export LIBAFL_EDGES_MAP_SIZE=2621440 && \
48-
cd ./fuzzers/fuzzbench/fuzzbench_valprof && \
48+
cd ./fuzzers/fuzzbench/fuzzbench_explore && \
4949
PATH="/root/.cargo/bin/:$PATH" cargo build --profile release-fuzzbench --features no_link_main
5050

5151
# Auxiliary weak references.
52-
RUN cd /libafl/fuzzers/fuzzbench/fuzzbench_valprof && \
52+
RUN cd /libafl/fuzzers/fuzzbench/fuzzbench_explore && \
5353
clang -c stub_rt.c && \
5454
ar r /stub_rt.a stub_rt.o

fuzzers/libafl_valprof/fuzzer.py renamed to fuzzers/libafl_explore/fuzzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ def prepare_fuzz_environment(input_corpus):
4545
def build(): # pylint: disable=too-many-branches,too-many-statements
4646
"""Build benchmark."""
4747
os.environ["CC"] = (
48-
"/libafl/fuzzers/fuzzbench/fuzzbench_valprof/target/release-fuzzbench/libafl_cc"
48+
"/libafl/fuzzers/fuzzbench/fuzzbench_explore/target/release-fuzzbench/libafl_cc"
4949
)
5050
os.environ["CXX"] = (
51-
"/libafl/fuzzers/fuzzbench/fuzzbench_valprof"
52-
"/target/release-fuzzbench/libafl_cxx"
51+
"/libafl/fuzzers/fuzzbench/fuzzbench_explore/target/release-fuzzbench/libafl_cxx"
5352
)
5453

5554
os.environ["ASAN_OPTIONS"] = "abort_on_error=0:allocator_may_return_null=1"
@@ -75,5 +74,6 @@ def fuzz(input_corpus, output_corpus, target_binary):
7574
command += ["-o", output_corpus, "-i", input_corpus]
7675
fuzzer_env = os.environ.copy()
7776
fuzzer_env["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
77+
fuzzer_env["FUZZSHARK_TARGET"] = "tcp"
7878
print(command)
7979
subprocess.check_call(command, cwd=os.environ["OUT"], env=fuzzer_env)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG parent_image
16+
FROM $parent_image
17+
18+
# Uninstall old Rust & Install the latest one.
19+
RUN if which rustup; then rustup self uninstall -y; fi && \
20+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /rustup.sh && \
21+
sh /rustup.sh --default-toolchain nightly-2024-08-12 -y && \
22+
rm /rustup.sh
23+
24+
# Install dependencies.
25+
RUN apt-get update && \
26+
apt-get remove -y llvm-10 && \
27+
apt-get install -y \
28+
build-essential \
29+
lsb-release wget software-properties-common gnupg && \
30+
apt-get install -y wget libstdc++5 libtool-bin automake flex bison \
31+
libglib2.0-dev libpixman-1-dev python3-setuptools unzip \
32+
apt-utils apt-transport-https ca-certificates joe curl && \
33+
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 17
34+
35+
RUN wget https://gist.githubusercontent.com/tokatoka/26f4ba95991c6e33139999976332aa8e/raw/698ac2087d58ce5c7a6ad59adce58dbfdc32bd46/createAliases.sh && chmod u+x ./createAliases.sh && ./createAliases.sh
36+
37+
# Download libafl.
38+
RUN git clone https://github.com/zukatsinadze/LibAFL /libafl
39+
40+
# Checkout a current commit
41+
RUN cd /libafl && git pull && git checkout 462f87c2ce6d10dbcc4520431a0af781b306f80b || true
42+
# Note that due a nightly bug it is currently fixed to a known version on top!
43+
44+
# Compile libafl.
45+
RUN cd /libafl && \
46+
unset CFLAGS CXXFLAGS && \
47+
export LIBAFL_EDGES_MAP_SIZE=2621440 && \
48+
cd ./fuzzers/fuzzbench/fuzzbench_fast && \
49+
PATH="/root/.cargo/bin/:$PATH" cargo build --profile release-fuzzbench --features no_link_main
50+
51+
# Auxiliary weak references.
52+
RUN cd /libafl/fuzzers/fuzzbench/fuzzbench_fast && \
53+
clang -c stub_rt.c && \
54+
ar r /stub_rt.a stub_rt.o

fuzzers/libafl_fast/fuzzer.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
"""Integration code for a LibAFL-based fuzzer."""
16+
17+
import os
18+
import subprocess
19+
20+
from fuzzers import utils
21+
22+
23+
def prepare_fuzz_environment(input_corpus):
24+
"""Prepare to fuzz with a LibAFL-based fuzzer."""
25+
os.environ["ASAN_OPTIONS"] = (
26+
"abort_on_error=1:detect_leaks=0:"
27+
"malloc_context_size=0:symbolize=0:"
28+
"allocator_may_return_null=1:"
29+
"detect_odr_violation=0:handle_segv=0:"
30+
"handle_sigbus=0:handle_abort=0:"
31+
"handle_sigfpe=0:handle_sigill=0"
32+
)
33+
os.environ["UBSAN_OPTIONS"] = (
34+
"abort_on_error=1:"
35+
"allocator_release_to_os_interval_ms=500:"
36+
"handle_abort=0:handle_segv=0:"
37+
"handle_sigbus=0:handle_sigfpe=0:"
38+
"handle_sigill=0:print_stacktrace=0:"
39+
"symbolize=0:symbolize_inline_frames=0"
40+
)
41+
# Create at least one non-empty seed to start.
42+
utils.create_seed_file_for_empty_corpus(input_corpus)
43+
44+
45+
def build(): # pylint: disable=too-many-branches,too-many-statements
46+
"""Build benchmark."""
47+
os.environ["CC"] = (
48+
"/libafl/fuzzers/fuzzbench/fuzzbench_fast/target/release-fuzzbench/libafl_cc"
49+
)
50+
os.environ["CXX"] = (
51+
"/libafl/fuzzers/fuzzbench/fuzzbench_fast/target/release-fuzzbench/libafl_cxx"
52+
)
53+
54+
os.environ["ASAN_OPTIONS"] = "abort_on_error=0:allocator_may_return_null=1"
55+
os.environ["UBSAN_OPTIONS"] = "abort_on_error=0"
56+
57+
cflags = ["--libafl"]
58+
cxxflags = ["--libafl", "--std=c++14"]
59+
utils.append_flags("CFLAGS", cflags)
60+
utils.append_flags("CXXFLAGS", cxxflags)
61+
utils.append_flags("LDFLAGS", cflags)
62+
63+
os.environ["FUZZER_LIB"] = "/stub_rt.a"
64+
utils.build_benchmark()
65+
66+
67+
def fuzz(input_corpus, output_corpus, target_binary):
68+
"""Run fuzzer."""
69+
prepare_fuzz_environment(input_corpus)
70+
dictionary_path = utils.get_dictionary_path(target_binary)
71+
command = [target_binary]
72+
if dictionary_path:
73+
command += ["-x", dictionary_path]
74+
command += ["-o", output_corpus, "-i", input_corpus]
75+
fuzzer_env = os.environ.copy()
76+
fuzzer_env["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
77+
fuzzer_env["FUZZSHARK_TARGET"] = "tcp"
78+
print(command)
79+
subprocess.check_call(command, cwd=os.environ["OUT"], env=fuzzer_env)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM gcr.io/fuzzbench/base-image
16+
17+
RUN apt install libjemalloc2
18+
19+
# This makes interactive docker runs painless:
20+
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/out"
21+
#ENV AFL_MAP_SIZE=2621440
22+
ENV PATH="$PATH:/out"
23+
ENV AFL_SKIP_CPUFREQ=1
24+
ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
25+
ENV AFL_TESTCACHE_SIZE=2

0 commit comments

Comments
 (0)