Skip to content

Commit

Permalink
Merge pull request #53 from KTH/wasm-fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus authored Aug 18, 2020
2 parents 6dffa41 + baec6b0 commit 4ba9ce1
Show file tree
Hide file tree
Showing 29 changed files with 1,227 additions and 104 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_souper.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build souper

# this is the workflow for CROW/Souper, we don't care about other changes
on:
push:
paths-ignore:
Expand Down Expand Up @@ -32,4 +33,4 @@ jobs:
run: cd souper && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ../ && make

- name: Zip folder
run: cd souper && tar -zcvf souper-mac.tar.gz build && ls -la | grep -i souper-mac.tar.gz
run: cd souper && tar -zcvf souper-mac.tar.gz build && ls -la | grep -i souper-mac.tar.gz
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
path = wabt
url = git://github.com/WebAssembly/wabt.git
branch = master
[submodule "wasm-fuzzer/fuzzing-server"]
path = wasm-fuzzer/fuzzing-server
url = https://github.com/olapiv/swam.git
103 changes: 0 additions & 103 deletions benchmark_programs/valid_crow/Vigenère_cipher-Cryptanalysis.c

This file was deleted.

2 changes: 2 additions & 0 deletions wasm-fuzzer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.out
*.dat
35 changes: 35 additions & 0 deletions wasm-fuzzer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Whether we are using AFL with Swam or just using dummy data
DUMMY_TESTING_AFL=False

# (Not being used yet..) Error, Warn, Info, Debug
LOG_LEVEL=Error

# Path to the parent directory of our local .wasm/.wat executable
LOCAL_WASM=/tmp/fuzzer-wat_files

# Name of our local .wasm/.wat executable
WASM_EXECUTABLE=fibo.wat

# Path on our local machine for us to read AFL's output
LOCAL_AFL_OUTPUT=/tmp/afl_out

# Path on our local machine for us to read our own logs
LOCAL_LOGS=/tmp/fuzzer/fuzzerlogs

# Path on our local machine for us to read SWAM's output (if any)
# SWAM_OUTPUT_LOCAL=/tmp/swam-out

# Function to be executed in .wasm/.wat ("_start" is default)
TARGET_FUNCTION=clever

# Parameter types for target function. Comma-separated list of types Int32, Int64, Float32, Float64.
WASM_ARG_TYPES_LIST=Int64

# Sample input for target function. Comma-separated list of numbers.
WASM_ARG_LIST=14

# Executable has wasi format
WASI=False

##### No need to change: #####
SWAM_SOCKET_PORT=9999
106 changes: 106 additions & 0 deletions wasm-fuzzer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This Dockerfile aims to substitute the docker-compose configuration

FROM aflplusplus/aflplusplus

################
##### JVM ######
################

RUN yes | apt-get install curl
RUN apt-get update
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
RUN yes | apt-get install software-properties-common
RUN apt-get update
RUN yes | add-apt-repository ppa:openjdk-r/ppa
RUN apt-get update
RUN yes | apt-get install openjdk-12-jdk-headless

#######################
##### Supervisor ######
#######################

RUN apt-get install -y supervisor

#########################
##### Scala & Mill ######
#########################

# Env variables
ENV SCALA_VERSION 2.13.2
ENV MILL_VERSION 0.7.0

# Define working directory
WORKDIR /root

# Install Scala
## Piping curl directly in tar
RUN \
curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
echo >> /root/.bashrc && \
echo "export PATH=~/scala-$SCALA_VERSION/bin:$PATH" >> /root/.bashrc

# Install mill
RUN \
curl -L -o /usr/local/bin/mill https://github.com/lihaoyi/mill/releases/download/$MILL_VERSION/$MILL_VERSION && \
chmod +x /usr/local/bin/mill && \
touch build.sc && \
mill -i resolve _ && \
rm build.sc

################################
#### fuzzing-server (SWAM) #####
################################

ENV DOCKER_SWAM_SRC=/home/server/src
ENV DOCKER_SWAM_OUTPUT=/home/server/out
ENV DOCKER_WASM=/home/server/wasm

# Create the appropriate directories
RUN mkdir -p $DOCKER_SWAM_SRC
RUN mkdir -p $DOCKER_SWAM_OUTPUT
RUN mkdir -p $DOCKER_WASM

WORKDIR $DOCKER_SWAM_SRC

# TODO: Find way of installing dependencies with Mill without copying over entire repo
# See: https://stackoverflow.com/questions/62834693/mill-build-tool-install-dependencies-without-compiling-source-code

ADD ./fuzzing-server $DOCKER_SWAM_SRC

RUN chmod +x $DOCKER_SWAM_SRC/entrypoint_mill_server.sh

#############################
#### fuzzing-client-afl #####
#############################

ENV DOCKER_INTERFACE_SRC=/home/client/interface
ENV DOCKER_AFL_INPUT=/home/client/in
ENV DOCKER_AFL_OUTPUT=/home/client/out

# Create the appropriate directories
RUN mkdir -p $DOCKER_INTERFACE_SRC
RUN mkdir -p $DOCKER_AFL_INPUT
RUN mkdir -p $DOCKER_AFL_OUTPUT
WORKDIR $DOCKER_INTERFACE_SRC

ADD ./fuzzing-client-afl $DOCKER_INTERFACE_SRC

RUN g++ -o ./prepare_wasm_input.out ./prepare_wasm_input.cpp ./utils.cpp
RUN g++ -o ./getFileSize.out ./getFileSize.cpp ./utils.cpp
RUN g++ -o ./wait_for_server.out ./wait_for_server.cpp ./utils.cpp ./socket_client.cpp
RUN g++ -o ./interface.out ./interface.cpp ./socket_client.cpp ./utils.cpp

RUN chmod +x $DOCKER_INTERFACE_SRC/entrypoint_afl.sh

#########################
######## Shared #########
#########################

ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf

ENV DOCKER_SHARED=/home/shared
ENV DOCKER_LOGS=$DOCKER_SHARED/logs

RUN mkdir -p $DOCKER_LOGS

ENTRYPOINT ["/usr/bin/supervisord"]
Loading

0 comments on commit 4ba9ce1

Please sign in to comment.