Commit graph

11 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
71d0f6d27d improved process monitor method (re)configuring
- Fixed reloading process monitor method if the configuration changes on
  disk. This can occur in two situations: 1) if it's changed from the
  UI, 2) if the user changes it manually.
- Ensure that we don't crash if there's an error changing the
  method and ebpf is active.
- When changing monitor method to ebpf and it fails to start, stop it
  anyway. It helps cleaning up kprobes and avoiding the error
  "cannot write...: file exists".
2021-09-04 21:18:22 +02:00
themighty1
9497cf8394
Use ebpf program to find PID of new connections. (#397)
* Use ebpf program to find PID of new connections.

    before running the branch you have to compile ebpf_prog/opensnitch.c
    opensnitch.c is an eBPF program. Compilation requires getting kernel source.

    cd opensnitch
    wget https://github.com/torvalds/linux/archive/v5.8.tar.gz
    tar -xf v5.8.tar.gz
    patch linux-5.8/tools/lib/bpf/bpf_helpers.h < ebpf_prog/file.patch
    cp ebpf_prog/opensnitch.c ebpf_prog/Makefile linux-5.8/samples/bpf
    cd linux-5.8 && yes "" | make oldconfig && make prepare && make headers_install # (1 min)
    cd samples/bpf && make
    objdump -h opensnitch.o #you should see many section, number 1 should be called kprobe/tcp_v4_connect
    llvm-strip -g opensnitch.o #remove debug info
    sudo cp opensnitch.o /etc/opensnitchd
    cd ../../../daemon

    --opensnitchd expects to find opensnitch.o in /etc/opensnitchd/
    --start opensnitchd with:

    opensnitchd -rules-path /etc/opensnitchd/rules -process-monitor-method ebpf

Co-authored-by: themighty1 <you@example.com>
Co-authored-by: Gustavo Iñiguez Goia <gooffy1@gmail.com>
2021-04-05 11:28:16 +02:00
Gustavo Iñiguez Goia
e13015ce67 updated import paths 2020-12-09 18:18:42 +01:00
Gustavo Iñiguez Goia
01e795c9ea ftrace: report if Reset() has failed
+ added funcs comments
2020-10-24 19:15:42 +02:00
Gustavo Iñiguez Goia
b03bbf0506 fixed race conditions setting log level and monitor methods 2020-06-14 20:14:24 +02:00
Gustavo Iñiguez Goia
3d6beb5ec3 Added new processes monitor method: audit
Use auditd events to keep a list of PIDs which open sockets, reading
them from the audisp af_unix plugin.

- Install auditd and audisp-plugins
- Enable the af_unix plugin (/etc/audisp-plugin/af_unix, active = yes)
- Start opensnitch with -process-monitor-method audit.

If the choosen method is audit but it's not active or not installed,
it'll fallback to /proc anyway.

If it's properly configured, a debug trace will be written to the logs:
"PID found via audit events ..."
2020-03-03 23:51:25 +01:00
Gustavo Iñiguez Goia
c5a3fb5132 Allow to select what process search method to use
Until now OpenSnitch used ftrace(debugfs) to search for running
processes (PIDs) and obtain the process path.

On some systems, this filesystem is not mounted or available, so we have
to rely on /proc.

After several weeks of use, I think that it's faster and more accurate
the 2nd method, search pids/cmdlines in /proc. So we offer the user to
choose which one to use.
2020-02-26 19:13:42 +01:00
Gustavo Iñiguez Goia
1e2f9aa124 Find pid of a process in /proc if debugfs is unavailable
debugfs is not always available due to different reasons:
https://github.com/evilsocket/opensnitch/issues/214
https://github.com/evilsocket/opensnitch/issues/276

Fallback to /proc parsing, although procfs could also be not available.

Easily testable by unmounting debugfs (umount debugfs) and launch
opensnitchd. It should work as expected.
2020-02-13 23:08:58 +01:00
Northern-Lights
f4162b9384
Update probed function sys_execve to do_execve 2018-08-12 13:02:33 -07:00
evilsocket
6962c19de2
fix: calling ftrace probe Reset in order to start from a clean state (fixes #159) 2018-04-18 02:00:12 +02:00
evilsocket
461e6b678e
using ftrace in order to track pids in realtime 2018-04-17 18:08:03 +02:00