Coder Social home page Coder Social logo

zigelboim-misha / kernel-system-enter-write-test Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.21 MB

Using eBPF to print each a line every time a system enter write event is executed on the kernel

Dockerfile 15.33% Go 43.01% C 41.66%
clang dockerfile ebpf golang

kernel-system-enter-write-test's Introduction

In this repository we will compile, build and run our eBPF kernel side script.

Golang Project

First we must initiate a go project:

go mod init ebpf-test
go mod tidy

Generating our Go files from Clang

Using go generate to compile the .c file into .o and .go files.

Running the eBPF script on the Kernel

By executing go generate && go build && sudo ./ebpf-test for a couple of seconds and then using ctrl+c we wrote some traces into /sys/kernel/debug/tracing/trace_pipe.

They can be viewed by sudo cat /sys/kernel/debug/tracing/trace_pipe | grep "BPF triggered sys_enter_write".

Enabling Tracing

If your Linux distribution (e.g. Ubuntu) does not have the tracing subsystem enabled by default, you may not see any output. Use the following command to enable this feature:

  • sudo mount -t debugfs none /sys/kernel/debug
  • sudo echo 1 > /sys/kernel/debug/tracing/tracing_on

Dockerfile

The Dockerfile contains everything that is needed to compile the .c code, build the .go files and run it on the kernel:

Build the image using docker build -t ebpf2go . Run the Dockerfile using docker run --privileged -v C:\Path\To\Files:/ebpf ebpf2go:latest

MacOS

In the dockerfile there is a need to change the existing ln to ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm.

kernel-system-enter-write-test's People

Contributors

zigelboim-misha avatar

Watchers

 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.