GithubHelp home page GithubHelp logo

trailofbits / ebpfault Goto Github PK

View Code? Open in Web Editor NEW
92.0 36.0 8.0 50 KB

A BPF-based syscall fault injector

Home Page: https://www.trailofbits.com/services/security-engineering

License: Apache License 2.0

CMake 17.58% C++ 82.42%
ebpf fault-injection debugging llvm bpf

ebpfault's Introduction

ebpfault

This tool is a syscall fault injector built on top of eBPF that has no requirements on the target machine other than a kernel version good enough to support the required features.

Usage

Sample configuration

The configuration supports both integers and errno value names.

{
  "fault_injectors": [
    {
      "syscall_name": "fchmodat",

      "error_list": [
        {
          "exit_code": "-ENOENT",
          "probability": 50
        },

        {
          "exit_code": -100,
          "probability": 30
        }
      ]
    },

    {
      "syscall_name": "openat",

      "error_list": [
        {
          "exit_code": "-ENOENT",
          "probability": 50
        }
      ]
    }
  ]
}

Against a new process

ebpfault --config /path/to/config.json --exec /path/to/program arg1 arg2

Against one or more running processes

ebpfault --config /path/to/config.json --pid_list pid1,pid2,pid3,...

System wide, excluding one or more running processes

ebpfault --config /path/to/config.json --except-pid-list --pid_list pid1,pid2,pid3,...

Building

Prerequisites

  • A recent Clang/LLVM installation (9.0 or better), compiled with BPF support
  • A recent libc++ or stdc++ library, supporting C++17
  • CMake >= 3.21.4. A pre-built binary can be downloaded from the CMake's download page.
  • โš ๏ธ Linux kernel >= 5.x (tested on Ubuntu 19.10) with the CONFIG_BPF_KPROBE_OVERRIDE option enabled

Building

  1. Download the osquery-toolchain from the following page: https://github.com/osquery/osquery-toolchain
  2. Extract the osquery-toolchain and set the TOOLCHAIN_PATH environment variable to its location
  3. Obtain the source code: git clone --recursive https://github.com/trailofbits/ebpfault
  4. In case the --recursive flag was not provided, run git submodule update --init --recursive
  5. Configure the project: cmake -S ebpfault -B build-ebpfault -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DEBPFAULT_ENABLE_INSTALL=true
  6. Build the project: cmake --build build-ebpfault

ebpfault's People

Contributors

alessandrogario avatar artemdinaburg avatar aymericdd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebpfault's Issues

Add support for dynamically adding forked processes to the active pid list

Ebpfault does not inject child process of a program. If an application creates a fork and this fork open a file, ebpfault will not catch the event. Example:

bash -c "echo 'create file to read from: /mnt/data/disk-read-file' && dd if=/dev/zero of=/mnt/data/disk-read-file bs=10k count=1; while true; do time dd if=/mnt/data/disk-read-file of=/dev/null iflag=direct; sleep 1; done"

The previous command will not be impacted by ebpfault because the dd command will be executed in a child process:

strace  -e trace=openat -p xxx
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16039, si_uid=0, si_status=0, si_utime=0, si_stime=1} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16042, si_uid=0, si_status=0, si_utime=1, si_stime=0} ---

Do you think we can implement this feature (We could add a flag like -f --follow)?

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.