Commit graph

23 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
1c04e95fdc audit: search for a process using the ppid
auditd events provides the parent pid of a process which has created
a connection. If we don't find the socket inode under the pid of the
process, use the ppid.

This is normally the case when systemd-* spawns a new process which
creates a new connection.
2020-03-06 23:21:24 +01:00
Gustavo Iñiguez Goia
461118e321 replace ReplaceAll() by Replace() to compile with go <= 11 2020-03-05 19:39:35 +01: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
8b579ece28 procmon: split cache functionality to a new file 2020-02-20 09:58:19 +01:00
Gustavo Iñiguez Goia
25c27511e1 Improved PIDs searching and sorting
Accuracy and reliability improved.
2020-02-17 23:39:26 +01:00
Gustavo Iñiguez Goia
be7ffbc54b Improved PIDs searching in /proc
Improved and reorganized code.
2020-02-17 01:17:28 +01:00
Gustavo Iñiguez Goia
a4a5637a22 Fixed errors
Typos were made.
2020-02-13 23:19:15 +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
Gustavo Iñiguez Goia
a6ff8d2c4f Prioritize cache pids with active connections
Processes with active connections are the most likely to be the latest
modified ones in /proc, thus sort cache pids by time speeds up pids cache
searching. From several ms to us.
2020-02-12 22:20:26 +01:00
Gustavo Iñiguez Goia
489b64730a Sort process descriptors by modified time
When parsing /proc/<pid>/fd/ looking for sockets, latest
modified/created descriptors are the most likely to have
generated connections.

This way we decrease the parsing time, system load and speed up process name
retrieval.
2020-02-11 21:32:48 +01:00
Gustavo Iñiguez Goia
4a30cc5b84 Reduced the pid cache sizes
It's somewhat arbitrary. It'll depend on each use case.
2019-12-01 20:05:20 +01:00
Gustavo Iñiguez Goia
7eec749498 allow to configure unknown conns interception
/etc/opensnitchd/default-config.json can now contain
"intercept_unknown": true|false
2019-11-01 01:00:10 +01:00
Gustavo Iñiguez Goia
65c3790106 Prompt the user to allow/deny all outgoing connections
With the current implementation, it's not possible to know what
process/pid has created an outgoing connection, but there's still
valuable information that the user may want to know, so:

- display outgoing connections even if the process name/path is unknown.
 (src ip, dst ip, dst port, uid)
- get outgoing connection uid if kernel > 3.6.
2019-10-25 00:55:32 +02:00
Gustavo Iñiguez Goia
9cc3da6446 experimental cache of inodes and pids
Just an experimental cache of inodes and pids, which lowers the CPU
usage and improves user's experience.
2019-10-24 01:01:20 +02:00
Gustavo Iñiguez Goia
dea50635d5 Merge branch 'fix_process_finding' into main 2019-10-21 19:48:17 +02:00
Gustavo Iñiguez Goia
59a11a530c Workaroung process name lookup 2019-10-21 19:45:35 +02:00
Gustavo Iñiguez Goia
a7e9b5072f project import paths changed 2019-10-20 21:51:35 +02:00
evilsocket
461e6b678e
using ftrace in order to track pids in realtime 2018-04-17 18:08:03 +02:00
evilsocket
96cc94180e
misc: small fix or general refactoring i did not bother commenting 2018-04-16 19:28:28 +02:00
evilsocket
d4cca89329
optimization 2018-04-16 19:12:46 +02:00
evilsocket
55e7ad9702
misc: small fix or general refactoring i did not bother commenting 2018-04-15 15:40:40 +02:00
evilsocket
b014a4069e
misc: small fix or general refactoring i did not bother commenting 2018-04-15 15:39:43 +02:00
evilsocket
534ec8cd73
misc: small fix or general refactoring i did not bother commenting 2018-04-02 05:25:32 +02:00