All Projects → trailofbits → Deepstate

trailofbits / Deepstate

Licence: apache-2.0
A unit test-like interface for fuzzing and symbolic execution

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Deepstate

eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (-93.2%)
Mutual labels:  unit-testing, testing-tools, testing-framework
Awesome Unit Testing Swift
A curated collection of awesome blog articles, books, talks, podcasts, tools/frameworks and examples.
Stars: ✭ 272 (-54.89%)
Mutual labels:  testing-tools, unit-testing, testing-framework
Crosshair
An analysis tool for Python that blurs the line between testing and type systems.
Stars: ✭ 586 (-2.82%)
Mutual labels:  symbolic-execution, fuzzing, testing-framework
Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+331.84%)
Mutual labels:  unit-testing, fuzzing, property-based-testing
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (-96.68%)
Mutual labels:  unit-testing, testing-tools, testing-framework
crusher
No description or website provided.
Stars: ✭ 21 (-96.52%)
Mutual labels:  symbolic-execution, fuzzing
swagger-conformance
Python based tool for testing whether your API conforms to its Swagger schema
Stars: ✭ 51 (-91.54%)
Mutual labels:  property-based-testing, fuzzing
libfuzzer
Thin interface for libFuzzer, an in-process, coverage-guided, evolutionary fuzzing engine.
Stars: ✭ 39 (-93.53%)
Mutual labels:  unit-testing, fuzzing
Selenium Wire
Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
Stars: ✭ 531 (-11.94%)
Mutual labels:  testing-tools, testing-framework
cpptest
🛠️ Powerful, yet simple, C++ unit testing framework; new home after https://sourceforge.net/projects/cpptest/
Stars: ✭ 51 (-91.54%)
Mutual labels:  unit-testing, testing-framework
Doctest
The fastest feature-rich C++11/14/17/20 single-header testing framework
Stars: ✭ 3,568 (+491.71%)
Mutual labels:  unit-testing, testing-framework
Haskell Hedgehog
Release with confidence, state-of-the-art property testing for Haskell.
Stars: ✭ 584 (-3.15%)
Mutual labels:  testing-tools, property-based-testing
sbml-test-suite
The SBML Test Suite is a conformance testing system. It allows developers and users to test the degree and correctness of the SBML support provided in a software package.
Stars: ✭ 21 (-96.52%)
Mutual labels:  testing-tools, testing-framework
SpecTools
Write less test code with this set of spec tools. Swift, iOS, testing framework independent (but works well with Quick/Nimble or directly).
Stars: ✭ 38 (-93.7%)
Mutual labels:  testing-tools, testing-framework
leancheck
enumerative property-based testing for Haskell
Stars: ✭ 38 (-93.7%)
Mutual labels:  property-based-testing, testing-tools
Jqf
JQF + Zest: Coverage-guided semantic fuzzing for Java.
Stars: ✭ 340 (-43.62%)
Mutual labels:  fuzzing, property-based-testing
Expecto
A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Stars: ✭ 495 (-17.91%)
Mutual labels:  unit-testing, property-based-testing
Bach
Bach Testing Framework
Stars: ✭ 392 (-34.99%)
Mutual labels:  unit-testing, testing-framework
Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+811.61%)
Mutual labels:  testing-tools, testing-framework
op-test
Testing Firmware for OpenPOWER systems
Stars: ✭ 30 (-95.02%)
Mutual labels:  testing-tools, testing-framework

DeepState

Slack Chat

Build Status

DeepState is a framework that provides C and C++ developers with a common interface to various symbolic execution and fuzzing engines. Users can write one test harness using a Google Test-like API, then execute it using multiple backends without having to learn the complexities of the underlying engines. It supports writing unit tests and API sequence tests, as well as automatic test generation. Read more about the goals and design of DeepState in our paper.

The 2018 IEEE Cybersecurity Development Conference included a full tutorial on effective use of DeepState.

Table of Contents

Articles describing DeepState

Overview of Features

  • Tests look like Google Test, but can use symbolic execution/fuzzing to generate data (parameterized unit testing)
    • Easier to learn than binary analysis tools/fuzzers, but provides similar functionality
  • Already supports Manticore, Angr, libFuzzer, file-based fuzzing with e.g., AFL or Eclipser; more back-ends likely in future
    • Switch test generation tool without re-writing test harness
      • Work around show-stopper bugs
      • Find out which tool works best for your code under test
      • Different tools find different bugs/vulnerabilities
      • Fair way to benchmark/bakeoff tools
  • Provides test replay for regression plus effective automatic test case reduction to aid debugging
  • Supports API-sequence generation with extensions to Google Test interface
    • Concise readable way (OneOf) to say "run one of these blocks of code"
    • Same construct supports fixed value set non-determinism
    • E.g., writing a POSIX file system tester is pleasant, not painful as in pure Google Test idioms
  • Provides high-level strategies for improving symbolic execution/fuzzing effectiveness
    • Pumping (novel to DeepState) to pick concrete values when symbolic execution is too expensive
    • Automatic decomposition of integer compares to guide coverage-driven fuzzers
    • Stong support for automated swarm testing

To put it another way, DeepState sits at the intersection of property-based testing, traditional unit testing, fuzzing, and symbolic execution. It lets you perform property-based unit testing using fuzzing or symbolic execution as a back end to generate data, and saves the results so that what DeepState finds can easily be used in deterministic settings such as regression testing or CI.

Build'n'run

Supported Platforms

DeepState currently targets Linux, with macOS support in progress (the fuzzers work fine, but symbolic execution is not well-supported yet, without a painful cross-compilation process).

Dependencies

Build:

  • CMake
  • GCC and G++ with multilib support
  • Python 3.6 (or newer)
  • Setuptools

Runtime:

  • Python 3.6 (or newer)
  • Z3 (for the Manticore backend)

Building on Ubuntu 18.04 (Bionic)

First make sure you install Python 3.6 or greater. Then use this command line to install additional requirements and compile DeepState:

sudo apt update && sudo apt-get install build-essential gcc-multilib g++-multilib cmake python3-setuptools python3-dev libffi-dev z3
sudo apt-add-repository ppa:sri-csl/formal-methods
sudo apt-get update
sudo apt-get install yices2
git clone https://github.com/trailofbits/deepstate deepstate
mkdir deepstate/build && cd deepstate/build
cmake ../
make
sudo make install

Installing

Assuming the DeepState build resides in $DEEPSTATE, run the following commands to install the DeepState python package:

virtualenv venv
. venv/bin/activate
python $DEEPSTATE/build/setup.py install

The virtualenv-enabled $PATH should now include two executables: deepstate and deepstate-angr. These are executors, which are used to run DeepState test binaries with specific backends (automatically installed as Python dependencies). The deepstate or deepstate-manticore executor uses the Manticore backend while deepstate-angr uses angr. They share a common interface where you may specify a number of workers and an output directory for saving backend-generated test cases.

If you try using Manticore, and it doesn't work, but you definitely have the latest Manticore installed, check the .travis.yml file. If that grabs a Manticore other than the master version, you can try using the version of Manticore we use in our CI tests. Sometimes Manticore makes a breaking change, and we are behind for a short time.

Installation testing

You can check your build using the test binaries that were (by default) built and emitted to deepstate/build/examples. For example, to use angr to symbolically execute the IntegerOverflow test harness with 4 workers, saving generated test cases in a directory called out, you would invoke:

deepstate-angr --num_workers 4 --output_test_dir out $DEEPSTATE/build/examples/IntegerOverflow

The resulting out directory should look something like:

out
└── IntegerOverflow.cpp
   ├── SignedInteger_AdditionOverflow
   │   ├── a512f8ffb2c1bb775a9779ec60b699cb.fail
   │   └── f1d3ff8443297732862df21dc4e57262.pass
   └── SignedInteger_MultiplicationOverflow
       ├── 6a1a90442b4d898cb3fac2800fef5baf.fail
       └── f1d3ff8443297732862df21dc4e57262.pass

To run these tests, you can just use the native executable, e.g.:

$DEEPSTATE/build/examples/IntegerOverflow --input_test_dir out

to run all the generated tests, or

$DEEPSTATE/build/examples/IntegerOverflow --input_test_files_dir out/IntegerOverflow.cpp/SignedInteger_AdditionOverflow --input_which_test SignedInteger_AdditionOverflow

to run the tests in one directory (in this case, you want to specify which test to run, also). You can also run a single test, e.g.:

$DEEPSTATE/build/examples/IntegerOverflow --input_test_file out/IntegerOverflow.cpp/SignedInteger_AdditionOverflow/a512f8ffb2c1bb775a9779ec60b699cb.fail--input_which_test SignedInteger_AdditionOverflow

In the absence of an --input_which_test argument, DeepState defaults to the first-defined test. Run the native executable with the --help argument to see all DeepState options.

Docker

You can also try out Deepstate with Docker, which is the easiest way to get all the fuzzers and tools up and running on any system.

The build may take about 40 minutes, because some fuzzers require us building huge projects like QEMU or LLVM.

$ docker build -t deepstate-base -f docker/base/Dockerfile docker/base
$ docker build -t deepstate --build-arg make_j=6 -f ./docker/Dockerfile .
$ docker run -it deepstate bash
[email protected]:~/deepstate$ cd build/examples
[email protected]:~/deepstate/build/examples$ deepstate-angr ./Runlen
[email protected]:~/deepstate/build/examples$ mkdir tmp && deepstate-eclipser ./Runlen -o tmp --timeout 30
[email protected]:~/deepstate/build/examples$ cd ../../build_libfuzzer/examples
[email protected]:~/deepstate/build_libfuzzer/examples$ ./Runlen_LF -max_total_time=30
[email protected]:~/deepstate/build_libfuzzer/examples$ cd ../../build_afl/examples
[email protected]:~/deepstate/build_afl/examples$ mkdir foo && echo x > foo/x && mkdir afl_Runlen2
[email protected]:~/deepstate/build_afl/examples$ $AFL_HOME/afl-fuzz -i foo -o afl_Runlen -- ./Runlen_AFL --input_test_file @@ --no_fork --abort_on_fail
[email protected]:~/deepstate/build_afl/examples$ deepstate-afl -o afl_Runlen2 ./Runlen_AFL --fuzzer_out

Documentation

Check out docs folder:

Contributing

All accepted PRs are awarded bounties by Trail of Bits. Join the #deepstate channel on the Empire Hacking Slack to discuss ongoing development and claim bounties. Check the good first issue label for suggested contributions.

Trophy case

We have not yet applied DeepState to many targets, but it was responsible for finding the following confirmed bugs (serious faults are in bold):

License

DeepState is released under The Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].