r/linuxadmin • u/anxiousvater • Jan 12 '26
ebpf fim for linux
I wrote this utility to perform File Integrity Monitoring of critical files & directories on a linux system.
In current state, it captures create, update & delete actions. What stands out is unlike capturing every event, the binary does in-kernel filtering to ignore certain actions such as read, stat by users root or app users who regularly access those files.
In addition to this, when users switch to root/app users to access the files, those actions are captured too. The performance penalty compared to other userspace monitoring tools is minimal as ebpf runs in kernel.
This is all configurable via a config file like below::
monitored_files:
- /tmp/testfile
- /etc/passwd
- /etc/shadow
ignore_actions:
- read
- stat
ignore_users:
- root
A sample log trial:
2025/08/18 07:22:09 Monitoring started. Ctrl+C to exit.
2025/08/18 07:22:37 Event: PID=1745080 UID=6087179 (6087179 (harsha)) CMD=touch FILE=/tmp/testfile FLAGS=00000941 ## actual user
2025/08/18 07:22:54 Event: PID=1745108 UID=0 (0 (root) [Login: 6087179 (harsha)]) CMD=touch FILE=/tmp/testfile FLAGS=00000941 ## even after sudo
GH repo :: https://github.com/harshavmb/fim-ebpf
I hope you find this tiny utility helpful.
View all comments
Show parent comment
5
u/anxiousvater Jan 12 '26
Tripwire like AIDE requires a database to store hashes & a scan needs to be initiated that compares the hashes with the database & tells you what has changed. Depending on the volume of files you monitor, it may take sometime to finish that scan consuming many CPU cycles.
eBPF on other hand is event driven, runs in the kernel & logs as and when events get triggered by tracing syscalls. CPU consumption is negligible (mostly due to logging rather tracing) & you get which user changed what kind of information.
BTW, the tripwire opensource version seems to be neglected (last commit was like 7 years ago).
Having said that eBPF is a live tracer, it cannot capture the changes made to the filesystem when it's powered off.