Esonhugh / my_durdur

Cilium/ebpf Learning idea from boratanrikulu/durdur

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Durdur

Durdur is a CLI tool for Linux implementing L4 package dropping with eBPF/Go (proof of concept).

How to install

From source;

Build and use build/durdur binary.

make build

How to Use

# ./build/durdur help   
Durdur is a L4 package Dropper/Firewall.

Usage:
  durdur [command]

Available Commands:
  attach      Attaches the program to the network.
  completion  Generate the autocompletion script for the specified shell
  detach      Detaches the program from the network.
  drop        Add new IP/port to the maps.
  help        Help about any command
  list        List all the rules
  log         print logs of dropping data
  undrop      Add new IP/port to the maps.

Flags:
  -b, --bpffs string   mounted bpffs location (default "/sys/fs/bpf")
  -d, --debug          Enable debug mode
  -h, --help           help for durdur

Use "durdur [command] --help" for more information about a command.

Attach to interface

./build/durdur attach -i eth0 -d
INFO[0000] Trying to attach XDP and TC eBPF program to the eth0. 
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully     

Detach from interface

./build/durdur detach
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] Detached from the network.     

Add a drop rule

# ./build/durdur drop --dst -i 198.19.249.98 -p 8000
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] MapOperation: add dst 198.19.249.98 8000   
# ./build/durdur drop --dst -i 198.19.249.97        
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] MapOperation: add dst 198.19.249.97 0 
# ./build/durdur drop --src -i 198.19.249.97
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] MapOperation: add src 198.19.249.97 0  

List all rules

# ./build/durdur list                       
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] --ingress-> world 198.19.249.97:any hint-rule:0 
INFO[0000] world <-egress-- 198.19.249.97:any hint-rule:0 
INFO[0000] world <-egress-- 198.19.249.98:8000 hint-rule:0 

Del a drop rule

#  ./build/durdur undrop --src -i 198.19.249.97
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
INFO[0000] MapOperation: del src 198.19.249.97 0 

Print logs

# ./build/durdur log
INFO[0000] Load XDP eBPF program successfully           
INFO[0000] Load TC eBPF program successfully            
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:46279 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 
Dropped Packect from 198.19.249.193:5790 to 198.19.249.98:16415 

Copyright

GPL-3.0 license,
Copyright 2022 Bora Tanrikulu <me@bora.sh> Copyright 2024 Esonhugh <durdur-project@eson.ninja>

About

Cilium/ebpf Learning idea from boratanrikulu/durdur

License:GNU General Public License v3.0


Languages

Language:Go 71.3%Language:C 22.9%Language:Makefile 5.0%Language:Dockerfile 0.8%