Git Product home page Git Product logo

attack_surface_approximation's Introduction

attack_surface_approximation ๐Ÿคบ



Description

attack_surface_approximation is the CRS module that deals with the approximation of the attack surface in a vulnerable program.

Some input mechanisms are omitted: elements of the user interface, signals, devices and interrupts. At the moment, the supported mechanisms are the following:

  • Files;
  • Arguments;
  • Standard input;
  • Networking; and
  • Environment variables.

In addition, a custom fuzzer is implemented to discover arguments that trigger different code coverage. It takes arguments from a dictionary which can be handcrafted or generated with an exposed command, with an implemented heuristic.

Examples of arguments dictionaries can be found in examples/dictionaries:

  • man.txt, generated with the man_parsing heurstic and having 6605 entries; and
  • generation.txt, generated with the generation heuristic and having 62 entries.

Limitations

  • ELF format
  • x86 architecture
  • Non-static binaries
  • Symbols present (namely, no stripping is involved)
  • No obfuscation technique involved

How It Works

The module works by automating Ghidra for static binary analysis. It extracts information and apply heuristics to determine if a given input stream is present.

Examples of such heuristics are:

  • For standard input, calls to getc() and gets()
  • For networking, calls to recv() and recvfrom()
  • For arguments, occurrences of argc and argv in the main()'s decompilation.

The argument fuzzer uses Docker and QBDI to detect basic block coverage.

Setup

  1. Ensure you have Docker installed.
  2. Install the required Python 3 packages via poetry install --no-dev.
  3. Ensure the Docker API is accessible by:
    • Running the module as root; or
    • Changing the Docker socket permissions (unsecure approach) via chmod 777 /var/run/docker.sock.

Usage

As a CLI Tool

Arguments Dictionary Generation

โžœ poetry run attack_surface_approximation generate --heuristic man --output args.txt --top 10
Successfully generated dictionary with 10 arguments
โžœ cat args.txt
--and
--get
--get-feedbacks
--no-progress-meter
--print-name
-input
-lmydep2
-miniswhite
-nM
-prune

Input Streams Detection

โžœ ./crackme
Enter the password: pass
Wrong password!
โžœ poetry run attack_surface_approximation detect --elf crackme
Several input mechanisms were detected for the given program:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Stream                โ”ƒ Present โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ files                 โ”‚   No    โ”‚
โ”‚ arguments             โ”‚   No    โ”‚
โ”‚ stdin                 โ”‚   Yes   โ”‚
โ”‚ networking            โ”‚   No    โ”‚
โ”‚ environment_variables โ”‚   No    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Arguments Fuzzing

โžœ poetry run attack_surface_approximation fuzz --elf /bin/uname --dictionary args.txt
Several arguments were detected for the given program:

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Argument  โ”ƒ      Role      โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ -         โ”‚      FLAG      โ”‚
โ”‚ -a        โ”‚      FLAG      โ”‚
โ”‚ -a string โ”‚ STRING_ENABLER โ”‚
โ”‚ -i        โ”‚      FLAG      โ”‚
โ”‚ -i string โ”‚ STRING_ENABLER โ”‚
โ”‚ -m        โ”‚      FLAG      โ”‚
โ”‚ -m string โ”‚ STRING_ENABLER โ”‚
โ”‚ -n        โ”‚      FLAG      โ”‚
โ”‚ -n string โ”‚ STRING_ENABLER โ”‚
โ”‚ -o        โ”‚      FLAG      โ”‚
โ”‚ -o string โ”‚ STRING_ENABLER โ”‚
โ”‚ -p        โ”‚      FLAG      โ”‚
โ”‚ -p string โ”‚ STRING_ENABLER โ”‚
โ”‚ -r        โ”‚      FLAG      โ”‚
โ”‚ -r string โ”‚ STRING_ENABLER โ”‚
โ”‚ -s        โ”‚      FLAG      โ”‚
โ”‚ -s string โ”‚ STRING_ENABLER โ”‚
โ”‚ -v        โ”‚      FLAG      โ”‚
โ”‚ -v string โ”‚ STRING_ENABLER โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Help

โžœ poetry run attack_surface_approximation
Usage: attack_surface_approximation [OPTIONS] COMMAND [ARGS]...

  Discovers the attack surface of vulnerable programs.

Options:
  --help  Show this message and exit.

Commands:
  analyze   Analyze with all methods.
  detect    Statically detect what input streams are used by an executable.
  fuzz      Fuzz the arguments of an executable.
  generate  Generate dictionaries with arguments, based on heuristics.

As a Python Module

Input Streams Detection

from attack_surface_approximation.static_input_streams_detection import \
    InputStreamsDetector

detector = InputStreamsDetector(elf_filename)
streams_list = detector.detect_all()

Arguments Fuzzing

from attack_surface_approximation.arguments_fuzzing import ArgumentsFuzzer

fuzzer = ArgumentsFuzzer(elf_filename, fuzzed_arguments)
detected_arguments = fuzzer.get_all_valid_arguments()

attack_surface_approximation's People

Contributors

iosifache avatar tvveeck avatar

Stargazers

 avatar

Watchers

 avatar

attack_surface_approximation's Issues

32-bit Ghidra Function Resolution

Description

On 32-bit (unlike the 64-bit executables, that gives correct results), Ghidra does not correctly resolve the imported function, replacing them with another ones, prefixed with FUNC_.

Assignees

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.