Commit graph

912 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
d6af47813e netlink: exclude connections with invalid inode 2020-04-12 12:33:59 +02:00
Gustavo Iñiguez Goia
c51d9542ae audit: avoid to overwrite cmdline of new events
when an audit msg of type !SYSCALL is added, the cmdline field may be
empty, and thus cause to loose the original proc cmdline.
2020-04-12 12:31:59 +02:00
Gustavo Iñiguez Goia
99ad5e531f fixed getting process uid under certain situations 2020-04-12 01:38:39 +02:00
Gustavo Iñiguez Goia
b9af7c2837 fixed compiling for arm and i386 2020-04-11 00:23:27 +02:00
Gustavo Iñiguez Goia
60005d7497 UI: added help menu
Added help menu to load the wiki.
2020-04-10 13:15:11 +02:00
Gustavo Iñiguez Goia
1e11e52457 deb UI packages improved
- kill UI on uninstall.
- update system icon cache after installing.
2020-04-09 18:51:17 +02:00
Gustavo Iñiguez Goia
ab1513334b Merge branch 'ui2.0' into main: fixed UI icons 2020-04-09 18:48:40 +02:00
Gustavo Iñiguez Goia
7c647f5782 fixed UI icons
- display correctly the connection status with the daemon whe it's
  disconnected.
- display correctly the icon (at least on gnome).
- changed "active" icon to svg, to fix a size problem displaying
  notifications on gnome.
2020-04-09 18:45:05 +02:00
Gustavo Iñiguez Goia
9d139a3f51 fixed not answered dialog alert icon
On gnome-shell,ubuntu 18.04 by using the Warning icon, it substituted
our icon by another one. So use NoIcon, since we're already setting our
own alert icon.
2020-04-09 17:07:58 +02:00
Gustavo Iñiguez Goia
24ede1c92b netlink: get active connections by source port + protocol
- Dump connections from kernel querying by source port + protocol.
- Prioritize responses which match the outgoing connection.
- If we don't get any response, apply the default action configured in
/etc/opensnitchd/default-config.json

--

A connection can be considered unique if:
protocol + source port + source ip + destination ip + destination port

We can be quite sure that only one process has created the connection.

However, many times, querying the kernel for the connection details by
all these parameters results in no response.

A regular query and normal response would be:
query: TCP:47344:192.168.1.106 -> 151.101.65.140:443
response: 47344:192.168.1.106 -> 151.101.65.140:443, inode: 1234567, ...

But in another cases, the details of the outgoing connection differs
from the kernel response, or it even doesn't exist.

However, if we query by protocol+source port, we can get more entries, and
somewhat guess what program opened the outgoing connection.

Some examples of querying by outgoing connection and response from
kernel:

query: 8612:192.168.1.5 -> 192.168.1.255:8612
response: 8612:192.168.1.105 -> 0.0.0.0:0

query: 123:192.168.1.5  -> 217.144.138.234:123
response: 123:0.0.0.0 -> 0.0.0.0:0

query: 45015:127.0.0.1 -> 239.255.255.250:1900
response: 45015:127.0.0.1 -> 0.0.0.0:0

query: 50416:fe80::9fc2:ddcf:df22:aa50 -> fe80::1:53
response: 50416:254.128.0.0 -> 254.128.0.0:53

query: 51413:192.168.1.106 -> 103.224.182.250:1337
response: 51413:0.0.0.0 -> 0.0.0.0:0
2020-04-05 19:14:51 +02:00
Gustavo Iñiguez Goia
315cf9e628 Merge branch 'main' of github.com:gustavo-iniguez-goya/opensnitch into main 2020-04-05 19:07:45 +02:00
Gustavo Iñiguez Goia
bf90229a1f procmon cache: removed redundant inodes cache deletion 2020-04-05 18:49:26 +02:00
Gustavo Iñiguez Goia
14d487ebee
Merge pull request #12 from deathtrip/patch-2
opensnitchd.service: update upstream url in
2020-04-05 13:06:02 +02:00
deathtrip
b359bfd754
update upstream url 2020-04-05 11:35:30 +02:00
Gustavo Iñiguez Goia
528ce81c04 exclude localhost resolved dns from being cached
it led to resolve some domains to 127.0.0.1 and show the user a
dialog with that misleading domain.
2020-04-04 10:53:30 +02:00
Gustavo Iñiguez Goia
bfee1f014b Revert "search for the PID in the inodes cache before discard it"
This reverts commit 4466d1dfbc.

This change was not intended for this branch.
2020-04-03 11:56:45 +02:00
Gustavo Iñiguez Goia
4466d1dfbc search for the PID in the inodes cache before discard it
Even if we don't have the inode, the connection might be cached.
2020-04-03 00:43:49 +02:00
Gustavo Iñiguez Goia
f7114d95c4 delete inodes cache when a process exits 2020-04-03 00:42:46 +02:00
Gustavo Iñiguez Goia
4a7607a323 removed useless debug log 2020-04-01 01:51:53 +02:00
Gustavo Iñiguez Goia
e85a41ca0f allow to configure process monitor method in daemon config
Added ProcMonitorMethod, which can be "proc", "ftrace" or "audit".

Parameters passed by command line take prevalence over default
configuration.

breaking changes: config options changed from xx_yy to XxYy.

Config example:
{
    "DefaultAction": "allow",
    "DefaultDuration": "once",
    "InterceptUnknown": true,
    "ProcMonitorMethod": "audit"
}
2020-03-16 01:37:33 +01:00
Gustavo Iñiguez Goia
bc4c7387a9 Added .spec file for build rpm packages
Only for the daemon for now.
2020-03-15 01:57:44 +01:00
Gustavo Iñiguez Goia
dbb86d7df8 avoid to crash if opensnitchd is already running 2020-03-13 12:47:04 +01:00
Gustavo Iñiguez Goia
2d5b89a0d4 UI: removed configparser dependency
It looks like it's part of python since 3.2, and as far as I can tell
without the pip dependency work just fine (tested on ubuntu >=14.x, mint
>= 18, debian >= 8.x).

It should also help packaging for ArchLinux #8.
2020-03-12 01:22:45 +01:00
Gustavo Iñiguez Goia
6c64438256 UI: removed configparser dependency
It looks like it's part of python since 3.2, and as far as I can tell
without the pip dependency work just fine (tested on ubuntu >=14.x, mint
>= 18, debian >= 8.x).
2020-03-12 01:18:26 +01:00
Gustavo Iñiguez Goia
0139e28c38 UI deb package: removed duplicated dependency.
protobuf is already installed by the grpcio-tools package.
2020-03-12 00:50:21 +01:00
Gustavo Iñiguez Goia
0c6836539e audit: code reformatted, ALL_CAPS to mixedCaps
Also do not filter sockets by code, nor by pid/ppid (for now at least).
2020-03-10 10:16:32 +01:00
Gustavo Iñiguez Goia
06d146b619 netstat/ sources commented and reformatted. 2020-03-09 20:08:14 +01:00
Gustavo Iñiguez Goia
eb52af72e5 audit: exclude events from our pid at rule level
Do not exclude them by code, just don't receive them.
2020-03-09 19:51:06 +01:00
Gustavo Iñiguez Goia
3c500a9314 Update issue templates 2020-03-09 19:32:21 +01:00
Gustavo Iñiguez Goia
27778c1fd6 Bump version to v1.0.0rc6 2020-03-08 20:59:57 +01:00
Gustavo Iñiguez Goia
c21e552e28 deb packages: distribute default daemon configuration 2020-03-08 20:28:24 +01:00
Gustavo Iñiguez Goia
6ebd6cca99 added a default configuration file
Some people has asked where they can change the daemon configuration.

As we can't change it from the GUI yet, and we're providing deb
packages, we need to distribute a default config.

That way the users will see it and will be able to customize it.
2020-03-08 20:25:05 +01:00
Gustavo Iñiguez Goia
8194199955 Merge branch 'ui2.0': workaround for cinnamon systray icon 2020-03-08 01:10:53 +01:00
Gustavo Iñiguez Goia
0fb23bb588 audit: avoid to alloc unused map, reformatted code 2020-03-08 01:09:47 +01:00
Gustavo Iñiguez Goia
99b024e0de dns sources formatted and documented 2020-03-07 10:23:53 +01:00
Gustavo Iñiguez Goia
a3422e493b audit: sort events after update the cache 2020-03-07 00:57:43 +01:00
Gustavo Iñiguez Goia
ba770fdf0d audit: insert new processes at the top of the list.
And avoid to sort the list of known processes every time we add a new
one.

Code formatted and documented.
2020-03-07 00:23:33 +01:00
Gustavo Iñiguez Goia
ef04667cdb cache of pids: insert new processes at the top of the list
code formatted and documented a little bit.
2020-03-06 23:23:16 +01:00
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
9e6860fe63 formatted connman/ 2020-03-06 21:44:47 +01:00
Gustavo Iñiguez Goia
6e3336258c firewall/rules.go formatted and documented. 2020-03-06 21:28:22 +01:00
Gustavo Iñiguez Goia
7cbcc4d736 reformatted netlink/ sources, fixed typo 2020-03-06 21:02:34 +01:00
Gustavo Iñiguez Goia
63b6ba6f94 added description for netlink/GetSocketInfo 2020-03-06 20:32:19 +01:00
Gustavo Iñiguez Goia
2137a395d1 audit: Fixed 32bits socket monitoring. 2020-03-05 20:57:37 +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
010a657f64 audit: get rid of mozilla/libaudit-go
mozilla/libaudit-go does not support i386/arm/etc, and we were using it
only for parsing audit messages.

So do not use it and parse raw messages directly. WIP.
2020-03-05 01:54:27 +01:00
Gustavo Iñiguez Goia
db22e83de1 pids cache: delete from cache non existent PIDs 2020-03-04 01:56:48 +01:00
Gustavo Iñiguez Goia
7ef15faf62 cache of known pids: update lastSeen field when we have a match 2020-03-04 01:31:36 +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
4407b82346 deb package: added logrotate file, lower daemon log level
Added a logrotate file to limit the size of the log and rotate as
needeed.
Changed daemon log level to important.
2020-03-01 00:40:58 +01:00