8000 GitHub - upwindsecurity/ebpf-demo: Demo eBPF Program.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

upwindsecurity/ebpf-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ebpf-demo

Demo eBPF Program.

This program uses an eBPF Tracepoint, sched/sched_process_exec, to monitor new processes being executed.

Tracepoints are eBPF programs that attach to pre-defined trace points in the linux kernel. These tracepoints are often placed in locations which are interesting or common locations to measure performance.

Requirements

macOS

When running on macOS you need to build and run this in a Linux virtual machine (VM). On macOS 13.0+ VMs can also be run using macOS's Virtualization Framework (vz) instead of QEMU but it has some limitations so QEMU is preferred.

Note: Some of the limitations of vz are that it fails to cross-compile for multiple architectures and also can not emulate a different architecture and can only run VMs using its own native architecture; example M3 Macs (arm64 arch) can only run arm64 VMs.

Install Dependencies (macOS)

brew bundle

Start a virtual machine using Lima and QEMU, and getting a terminal:

limactl start ./lima/ebpf-demo.yaml
limactl shell ebpf-demo
  • To start the VM using a different architecture add --arch=<ARCH> where <ARCH> can be one of: x86_64 or aarch64.

Linux

  • Go
  • linux-tools
  • build-essential
  • llvm
  • clang
  • libbpf-dev
  • libelf-dev
  • libpcap-dev
  • bpftool
  • curl

Install Dependencies (Linux)

  • Install Go

  • Install dependencies:

    export KERNEL_VERSION=`uname -r`
    apt-get update -q
    apt-get install -q -y \
    apt-transport-https ca-certificates curl \
    linux-tools-common linux-tools-generic linux-tools-${KERNEL_VERSION} \
    build-essential llvm clang \
    libbpf-dev libelf-dev libpcap-dev
  • Install BPFTool

    git clone --recurse-submodules https://github.com/libbpf/bpftool.git /tmp/bpftool
    pushd /tmp/bpftool/src
    make install
    popd

Building

On a linux environment run make build.

Running

Running applications that load BPF programs needs privilege so running the application as root or using sudo is required.

sudo ./demo

Links

Some useful links for additional information and learning about eBPF:

About

Demo eBPF Program.

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages

0