GithubHelp home page GithubHelp logo

beating-the-machine / ubsym Goto Github PK

View Code? Open in Web Editor NEW

This project forked from softwaresecuritylab/ubsym

0.0 0.0 0.0 3.55 MB

A Unit-Based Symbolic Execution Method for Detecting Memory Corruption Vulnerabilities in Executable Codes

License: Apache License 2.0

Shell 0.07% C++ 0.05% Python 0.89% C 98.99% Batchfile 0.01%

ubsym's Introduction

UbSym

UbSym attempts to improve the efficiency of symbolic execution technique and use it to detect a group of memory corruption vulnerabilities in binary programs. Instead of applying symbolic execution to the whole program, this tool initially determines a program test unit, probably containing vulnerability, using static analysis and based on the defined specifications for memory corruption vulnerabilities. Then the constraint tree of the program unit is extracted using symbolic execution so that every node in this constraint tree contains the desired path and vulnerability constraints. Finally, using the curve fitting technique and treatment learning the system inputs are estimated consistent with these constraints. Thus, new inputs are generated that reach the vulnerable instructions in the desired unit from the beginning of the program and cause vulnerability aactivation in those instructions.

Analysis Steps of UbSym

  • Static Analysis on x64 Binary Codes for Finding Possibly Vulnerable Units
  • Symbolic Execution on Test Units
  • Monte Carlo Simulation and Curve Fitting
  • Detecting Vulnerability and Generating Appropriate Inputs for Activating of the Vulnerability

Supported Vulnerabilities

  • Heap-Based Buffer Overflow
  • Stack-Based Buffer Overflow
  • Double-Free
  • Use-After-Free

Requirements

Getting Started

Step 1: Creating Virtual Environment

Create and activate a virtual environment:

sudo apt-get install virtualenv
virtualenv -p /usr/bin/python3 env
source env/bin/activate

Step 2: Cloning Files to Use UbSym

git clone https://github.com/SoftwareSecurityLab/UbSym

Step 3: Installing Requirements

Now install project requirements using requirements.txt file:

pip install -r requirements.txt

Running Test Cases

Everything is completed. Now you can test your desired code using our tool. We put some test cases from the NIST SARD benchmark vulnerable programs in this repository by which you can test our vulnerability detection tool.

Options

-h or --help        HELP
-b or --binary      BINARY     [The Name of Binary File You Want to Analyze]
-p or --prototype   PROTOTYPE  [The Prototype of Test Unit You Want to Analyze]
-t or --type        TYPE       [The Type of Vulnerabilities You want to Detect]
-s or --sizes       SIZES      [The Size of Test Unit Arguments]
-a or --args        ARGS       [The Indexes of Argv Passed to The Test Unit As Function Arguments]
-S or --solo        SOLO       [The Solo Mode Avoids Executing Nested Functions in Unit Symbolically]

Testing UbSym

You can see possibly vulnerable units contaning double-free vulnerability in a binary program:

chmod +x run.py; ./run.py -b program -t DF

For example, you want to analyze the function "CWE415_Double_Free__malloc_free_int_01_bad" as a vulnerable unit:
We need one argument with the maximum length of 100 bytes as the input "argv", making the possible vulnerability active in the "CWE415_Double_Free__malloc_free_int_01_bad" unit, so we use -s 100 for the sizes option and -a 1 for the args option.

./run.py -b program -t DF -p 'void CWE415_Double_Free__malloc_free_int_01_bad(char*)' -s 100 -a 1

Results

Compile programs using executable.sh script and run benchmarks_running.py file to analyze all programs of tests directory.

chmod +x ./tests/executable.sh
cd tests
./executable.sh
cd ..
chmod +x benchmarks_running.py; 
./benchmarks_running.py

We wish you happy testing!๐Ÿ˜„

Known Issues

You may get the message "node i is not satisfiable" since the detection tool can not generate appropriate input data if the symbolic buffer does not have enough space to hold the generated input. In this situation, you have to increase the value of parameters BUF_SYMBOLIC_BYTES and MAX_STR_LEN in the VTree.py file.

Authors

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

Notes

We have tested our project on Ubuntu 18.04.1 LTS.

ubsym's People

Contributors

sarabaradaran 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.