GithubHelp home page GithubHelp logo

redcrabs / fsa Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 3.0 5.31 MB

Fuzzing with optimized grammar-aware mutation strategies.

License: Apache License 2.0

Makefile 34.40% C 11.03% Shell 0.90% HTML 0.09% C++ 49.37% JavaScript 0.02% Rich Text Format 0.01% CMake 2.20% ANTLR 2.00%

fsa's Introduction

FSA

Fuzzing with optimized grammar-aware mutation strategies. FSA is short for fuzzing with subtree-pool-based random mutation and AST-node-level power schedule. It is built mostly based on the famous AFL (http://lcamtuf.coredump.cx/afl/) and Superion (https://github.com/zhunki/Superion).

The parsing ability of FSA is provided by ANTLR (https://www.antlr.org/), which can automatically generate a parser given the grammar file.

Building

0. Pre Install

  • Debian 8.3.0 (Ubuntu also works)
  • cmake 3.16.0
  • clang 7.0.1

1. Build ANTLR runtime

To build FSA, we first need to build the ANTLR runtime. The ANTLR runtime is located in tree_mutation folder.

cd /path_to_FSA/tree_mutation/
cmake ./
make

If a missing uuid error is raised, you need to install uuid first.

sudo apt-get install uuid-dev

2. Generate Lexer, Parser, Visitor automatically (Optional)

The project already included xml and javascript parsers generated as follows. If you need to support other input grammar, you caan refer to the following instructions.

add antlr-4.7-complete.jar to classpath

xml:

java -jar antlr-4.7-complete.jar -o path -visitor -no-listener -Dlanguage=Cpp XMLLexer.g4 
java -jar antlr-4.7-complete.jar -o path -visitor -no-listener -Dlanguage=Cpp XMLParser.g4

javascript:

java -jar antlr-4.7-complete.jar -o path -visitor -no-listener -Dlanguage=Cpp ECMAScript.g4 

3. Build tree mutator

The XML parser is located in tree_mutation/xml_parser folder.

cd /path_to_FSA/tree_mutation/xml_parser

for f in *.cpp; do g++ -I ../runtime/src/ -c $f -fPIC -std=c++11; done

g++ -shared -std=c++11 *.o ../dist/libantlr4-runtime.a  -o libTreeMutation.so

4. Build AFL

Compile afl-clang-fast and afl-clang-fast++, which are used to instrument fuzzing targets.

# install llvm+clang
PREFIX=/path/to/install/llvm ./install_llvm.sh

# install FSA
cd /path_to_FSA/
make

Fuzzing

0. Environment

CC=/path/to/FSA/afl-clang-fast
CXX=/path/to/FSA/afl-clang-fast++

1. libxml 2

# build libxml 2
git clone https://github.com/GNOME/libxml2.git

2. Sablotron


3. JerryScript

# build JerryScript
python ./tools/build.py --clean --debug --compile-flag=-fsanitize=address --compile-flag=-m32 --compile-flag=-fno-omit-frame-pointer --compile-flag=-fno-common --jerry-libc=off --static-link=off --lto=off --error-message=on --system-allocator=on

# start fuzzing
./afl-fuzz -i ~/jerry_seeds/ -o ~/jerry_out/ ~/jerryscript/build/bin/jerry @@

fsa's People

Contributors

jialedeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.