Skip to content

containerscrew/kernelsnoop

Repository files navigation

kernelsnoop

What's going on down there? Kernel sniffing using eBPF.

I want to learn how to create my own applications to simply monitor my computer. I don't know how far this will go.

I am practicing everything I learned in this book.

Table of Contents generated with mtoc

About

...pending to add

By the moment, clone the repo and run:

make compose-up-build

Once the containers are running, visit http://127.0.0.1:3000 or docker logs -f kernelsnoop.

usernames/password for every tool in docker/compose.yml

Available tools

  • Shell readline: read every user command for bash, zsh and sh.
  • In progress: file access. Read file, access to a file, write a file.

Local development

Requirements

System package dependencies are MANDATORY.

Since I'm using the framework ebpf-go from Cilium, see the required dependencies in their official documentation.

pre-commit

Please, install pre-commit before push your changes

pre-commit install
# or run once
pre-commit run -a

Stuff

  • Generate vmlinux.h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > internal/headers/vmlinux.h
  • Look for available tracepoints:
sudo bpftrace -l 'tracepoint:*'
  • Other:
sudo cat /sys/kernel/debug/tracing/events/ext4/ext4_free_inode/format
  • Stuff
curl -sL ip.guide/bulk/asns.csv
sudo bpftrace -l | grep cap_capable
{container="kernelsnoop"} |= "new connection"
| json
| latitude != 0.0
| longitude != 0.0
| line_format "{{.dst_addr}},{{.latitude}},{{.longitude}}"

Ideas

  1. User Activity Monitor
  2. Network connection tracker
  3. Real-Time File Access Watchdog

Useful links

Packages

No packages published

Languages