Commit graph

988 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
d11a98e418 fixed interception and system fw rules, default action
- The firewall rules defined in /etc/opensnitchd/system-fw.json take
precedence over the interception rules, but we were inserting the
interception rules before the system's ones. With this change #455
should be fixed.

- On the other hand, the DefaultAction was not being applied correctly
  in all cases. As of today the DefaultAction is applied in 2 scenarios:
  * When the daemon is connected to the GUI and the user doesn't answer
    a pop-up.
  * When the daemon is not connected to the GUI.

  However as we don't parse all network protocols, even if the GUI is
  connected we may end up parsing a connection and don't know what to do
  with it. In this case the DefaultAction was always Deny.

  Now in the above scenario, i.e.: when the GUI is connected but we
  can't parse a connection, we'll apply the DefaultAction configured by
  the user.
2021-08-25 13:06:32 +02:00
Gustavo Iñiguez Goia
7c991dd85f
Merge pull request #479 from gnuhead-chieb/master
Update Japanese translation
2021-08-23 10:40:13 +02:00
Gustavo Iñiguez Goia
96722ed740 blocklists: sanitize hosts entries
Remove \r\n\t\s from the end of each line of a blocklist.

If the entries of a list had these characters caused to not match
connections and not apply the rule.

closes #429
2021-08-22 23:07:25 +02:00
gnuhead-chieb
48538323ca
Add files via upload 2021-08-22 08:03:11 +09:00
Flávio Costa
e85ba18a17
Update Brazilian Portuguese translation (#478)
* Update Brazilian Portuguese translation
2021-08-20 20:51:39 +02:00
Gustavo Iñiguez Goia
49c171df4c Use eBPF as procs monitor method by default
If eBPF is not available we'll fallback to proc parsing.
2021-08-17 13:54:46 +02:00
Gustavo Iñiguez Goia
94fa3c8093 ui, stats: better window restoration on KDE
Latest approach seems to not always work (latest KDE on kubuntu 20 and
manjaro as of today).

This seems to work better:
https://doc.qt.io/qt-5/qwidget.html#setWindowState
2021-08-13 18:03:10 +02:00
Gustavo Iñiguez Goia
a354ae22e1 statistics: fixed missed connections
Previous behaviour:

 1) Before version 1.0.0b the daemon kept a list of processes that had
 established connections. The list was displayed on the GUI as is, so
 the maximum number of connections displayed were 100 (hardcoded).

 2) When the intercepted connections reached 100, the last entry of the
    list was removed, and a new one was inserted on the top.

After v1.0.0 we started saving connections to a DB on the GUI side, to
get rid of the hardcoded connections limit. However, the point 2) was
still present that caused some problems:
 - When the backlog was full we kept inserting and deleting connections
   from it continuously, one by one.
 - If there was a connections burst we could end up missing some
   connections.

New behaviour:
 - The statisics are deleted from the daemon everytime we send them to
   the GUI, because we don't need them on the daemon anymore.
 - If the GUI is not connected, the connections will be added to the
   backlog as in the point 2).
 - When the backlog reaches the limit, it'll keep deleting the last
   one in order to insert a new one.
 - The number of connections to keep on the backlog is configurable.
 - If the statistics configuration is missing, default values will be
   150 (maxEvents) and 25 (maxStats).

Notes:
 If the GUI is saving the data to memory (default), there won't be
 any noticeable side effect.
 If the GUI is configured to save the connections to a DB on disk, and
 the daemon sends all the backlog at once, the GUI may experience a
 delay and a high CPU spike. This can occur on connecting to the daemon
 (because the backlog will be full), or when an app sends too many
 connections per second (like nmap).
2021-08-13 12:18:10 +02:00
Gustavo Iñiguez Goia
2b8c931762 ui, events: translate columns headers
Related: #465
2021-08-12 15:12:11 +02:00
Gustavo Iñiguez Goia
38d4fb9ae5 Bump versions to v1.4.0rc4 2021-08-11 17:16:56 +02:00
Gustavo Iñiguez Goia
5a6dd28072 cache of PIDs: added new tests, fixed rare crash
- New tests to validate deleion of PIDs.
- Fixed potential out-of-bounds when deleting PIDs from cache.
2021-08-11 14:19:43 +02:00
Gustavo Iñiguez Goia
6ce099ffd5 ui, events: fixed restoring state when minimized
On KDE the events window was not restored to previous state when the
window was minimized to the taskbar.

This was fixed by @themighty1 in this PR #315, but there was an
unexpected behaviour on others DE.

As I haven't seen this error in others DE, we apply the original
fix, but only when the DE in use is KDE.
2021-08-09 15:28:15 +02:00
Gustavo Iñiguez Goia
0910249fb2 ui: fixed typos, improvements.
- Fixed typos in the preferences dialog (#465).
- Fixed hiding/showing rules combobox.
- Keep opensnitchd/default-config.json format when saving node's
  configuration from the GUI.
2021-08-09 13:30:56 +02:00
Gustavo Iñiguez Goia
ba7c4e1878 allow to configure what firewall to use
Before this change, we tried to determine what firewall to use based on
the version of iptables (if -V legacy -> nftables, otherwise iptables).

This caused problems (#455), and as there's no support yet for nftables
system firewall rules, it can't be configured to workaround these
errors.

Now the default firewall to use will be iptables.
If it's not available (installed), can't be used or the configuration
option is empty/missing, we'll use nftables.
2021-08-09 00:32:27 +02:00
Gustavo Iñiguez Goia
db18b0cc63
Merge pull request #470 from ovari/master
Update opensnitch-hu_HU.ts
2021-08-08 12:51:34 +02:00
Gustavo Iñiguez Goia
bca5ffa9b5 ui,rules: update rules last_seen field on new stats
Update the last_seen field every time a new connection is established.
2021-08-08 12:29:37 +02:00
ovari
dd94c3fe1a
Update opensnitch-hu_HU.ts 2021-08-06 18:28:24 +10:00
Gustavo Iñiguez Goia
388c98e559 ui,preferences dialog: fixed crash
qcombobox placeHolderText preference was set as translatable, and it
caused a crash.
2021-08-03 01:11:12 +02:00
Gustavo Iñiguez Goia
f96e44dc93 ui: improved UI internationalization, columns fix
- Now the columns names of the details views can be translated (#465).
- Fixed columns size restoring when clicking on the Events tab to view
  the details of an item (process, rule or node).
2021-08-02 17:16:10 +02:00
Gustavo Iñiguez Goia
de3c4be5d5 ui: allow personalize columns size
Now if you resize any columns, it'll be remembered the next time you
open that view.
2021-07-31 18:57:17 +02:00
Gustavo Iñiguez Goia
2b3fdfc948 ui,db: display an error if the db file is corrupted
Display an alert if the db loaded from disk is corrupted.

closes #460
2021-07-31 01:35:28 +02:00
Gustavo Iñiguez Goia
83ab1f9f5e ui, prompt: fixed increasing height when prompting
There was an annoying bug that increased the pop-up height a little bit
everytime a new pop-up was displayed.

Hopefully this time it's fixed, while maintaining compatiblitiy on the
mobile (i.e.: displaying the buttons at the bottom and the connection
information at the top of the pop-up).
2021-07-29 19:22:15 +02:00
Gustavo Iñiguez Goia
9a34665d0e improved PID discovering
One of the steps of PIDs discovering is knowing what's the socket inode
of a connection. The first try is to dump the active connections in the
kernel, using NETLINK_SOCK_DIAG via netlink.

Sometimes when a source port was reused, the kernel could return multiple
entries with the same source port, leading us to associate connections with
the wrong application.

This change fixes this problem, while allowing us to discover other
apps.
More information:
https://github.com/evilsocket/opensnitch/issues/387#issuecomment-888663121

Note: this problem shouldn't occur using the procs monitor method eBPF.
2021-07-29 15:40:25 +02:00
Gustavo Iñiguez Goia
b644853d63 ui: allow to configure events columns, misc
* Preferences:
  - Allow to configure the columns of the Events tab.
  - Fixed displaying labels on small screens.

* Rules:
  - Added combo to select the type of rules to list (all, permanent,
    temporary) when the left panel is hidden.

* Main window:
  - Improved tabs widgets positioning.

* Misc:
  - Improved code to avoid typos.
2021-07-26 19:00:22 +02:00
Gustavo Iñiguez Goia
a3a171d2a2 ui: allow to ignore temporary rules, fixes, impovements
- Added option to ignore temporary rules. All or only of duration
  "once".
  You can still use them when answering a pop-up, but if you check the
  option, the rules won't be added to the rules list.

- Fixed wrong behaviour when adding rules to the db/gui.
  When changing a rule duration (always->30s, 30s->always), if there
  were connections matching that rule, the rule was re-added to the
  db/rules list with the old duration, ending up with 2 rules in the
  list.
  This was caused by how stats are sent to the GUI. When populating the
  db with the stats, we were also adding the rules.

  Now we don't add the rules when adding the stats. Rules are added to
  the db everytime a node connects to the GUI, when answering a pop-up
  or whenever the user performs an operation on them.

  Performance has increased a little bit due to this.

- Fixed applying configuration to all nodes at once.
- Added help menu to the preferences dialog.
- Removed lists grid.
- A little bit of code reorganization.
2021-07-24 23:53:42 +02:00
Gustavo Iñiguez Goia
fbcab5a0c4 cache, pids/inodes: fixed race conditions, improvements
- Fixed multiple race conditions when using the cache of PIDs.
- Improved the chances to hit the cache of inodes, which helps to keep
  down the times to get the PID of a connection to <= 30us.

These caches are mainly used when not using "ebpf" proc monitor method.
2021-07-21 15:04:23 +02:00
Gustavo Iñiguez Goia
544887adeb ui, pkgs: added packaging step to fix pb2 files. 2021-07-17 11:13:34 +02:00
Gustavo Iñiguez Goia
be32ddc574 added script to update ads lists, old script relocated.
There's a new way of blocking lists of domains:
https://github.com/evilsocket/opensnitch/wiki/block-lists

However the update of the lists is not implemented yet. You can use
this or other simple script to download and update the lists (in hosts
format).
2021-07-17 00:41:13 +02:00
Gustavo Iñiguez Goia
708a7e6333 Bump versions to v1.4.0rc3 2021-07-16 23:41:02 +02:00
Gustavo Iñiguez Goia
cec619aa3b removed debugging log message 2021-07-16 23:24:52 +02:00
Gustavo Iñiguez Goia
85802811d1 fixed race condition counting lists of domains
Removed the number of loaded lists of domains, that caused a race
condition and added no value. It was only used for debugging
purposes.
2021-07-07 18:50:30 +02:00
Gustavo Iñiguez Goia
5e56e9033f ui, process monitor dialog: fixed exception
Fixed exception when stopping the monitor fails and an error is
returned.
2021-06-19 01:00:33 +02:00
Gustavo Iñiguez Goia
38e3bd45ed
Merge pull request #442 from shollingsworth/issue-439-python-module-conflict-fix
fixes #439 - module namespace conflict
2021-06-19 00:08:21 +02:00
Steven Hollingsworth
de559dccf8
Changed import ui_pb2 from global to relative 2021-06-18 12:54:17 -07:00
Steven Hollingsworth
3d9b44cb50
fixes #439 - module namespace conflict 2021-06-17 16:39:35 -07:00
Gustavo Iñiguez Goia
1c73a48b9c
Merge pull request #438 from gnuhead-chieb/master
Update Japanese translation
2021-06-16 14:34:38 +02:00
gnuhead-chieb
a006f25fb3
Add files via upload 2021-06-16 11:39:42 +00:00
Gustavo Iñiguez Goia
21c6a914d6 drop connections while a pop-up is running
Prior to v1.4.x versions, when a pop-up asked the user to allow or deny
a connection, the rest of the network traffic was dropped until an
action was taken.

We fixed it, but when a pop-up was asking to allow or deny a new connection,
we let it passing by if the daemon's DefaultAction option was set to
allow, even if the user hadn't taken an action on it yet.

It also caused some confusion if the users had configured the pop-up's
DefaultAction to deny, they were expecting to not allow the connection
until they had decided what to do.

Now the previous behaviour has been restored, having these usage
scenarios:
- If the GUI is connected + daemon DefaultAction set to allow or deny.
  Result:
    1. Prompt the user to allow or deny the new connection.
    2. Deny the new connection until the user takes an action on it.
    3. Allow the rest of traffic, allowing known connections, and
       denying new ones until the active pop-up is closed and we can
       prompt the user again.

- GUI disconnected.
  Result:
    1. Apply daemon's DefaultAction from the configuration file
       default-config.json.

closes: #392
2021-06-16 09:50:36 +02:00
Gustavo Iñiguez Goia
eaa015870b ui,rules: fixed refreshing list after delete,
- Fixed refreshing rules list after delete a rule(s).
  (There was an annoying delay).
- Added button to delete connections associated with a rule, from the
  details view of a rule. (related: #334).
2021-06-09 00:25:24 +02:00
Gustavo Iñiguez Goia
465d531496 find PID: use legacy methods if the PID is not found.
Some times, processes that establish connections to localhost are only
found in /proc/net/* files. So if we fail to get the PID of a
connection, fallback to legacy method to find it.
2021-06-08 14:11:19 +02:00
Gustavo Iñiguez Goia
f143107639 ebpf: fixed race condition when listing connections
Better fix for locking already established connections.
2021-06-07 22:55:08 +02:00
Gustavo Iñiguez Goia
da23c827f7 added nftables support
Added basic nftables support, which adds the needed rules to intercept
outgoing network traffic and DNS responses. System rules will be added
soon.

What netfilter subsystem to use is determined based on the following:
- nftables: if the _iptables_ binary is not present in the system, or
  if the iptables version (iptables -V) is
  "iptables vX.Y.Z (nf_tables)".
- iptables: in the rest of the cases.
2021-06-07 01:32:05 +02:00
Gustavo Iñiguez Goia
3d11134363 fixed race condition when deleting a rule from disk 2021-06-05 16:33:50 +02:00
Gustavo Iñiguez Goia
ff40e99f77 tests, rules: added Duration change test
Verify that if the user changes the Duration of a temporary rule, the
old timer does not delete the rule.
2021-06-03 17:35:48 +02:00
Gustavo Iñiguez Goia
bae8b711bd
Merge pull request #430 from ovari/master
Update opensnitch_ui.desktop
2021-06-03 00:14:24 +02:00
ovari
5f73dc1069
Update opensnitch_ui.desktop 2021-06-03 06:44:21 +10:00
Gustavo Iñiguez Goia
403c218209 prevent deleting temporary rules when the Duration changes
When the Duration of a rule changed (from 1h to 5m, from 5m to until
restart, etc), the timer of the old rule was fired, causing deleting the
rule from the list.

This erroneous behaviour could be one of the reasons of #429
2021-06-01 23:52:02 +02:00
Gustavo Iñiguez Goia
95a30c4959 ui, rules editor: fixed editing/adding rules
There was a race condition that caused several problems when editing or
adding rules.

for rules of type "list", the operand must be "list" as well.

related: #429 #425
2021-05-31 20:22:44 +02:00
Gustavo Iñiguez Goia
e5b54f0a6b eBPF: ignore netlink errors if there're no connections
When enabling the eBPF monitor method we dump the active connections,
but in some cases there're no active connections, and because of this
we're failing enabling this monitor method.

If there're no connections established, netlink returns 0 entries. It's
not clear if it's an indication of error in some cases or the expected
result.

Either way:
- fail only if we're unable to load the eBPF module.
- dump TCP IPv6 connections only if IPv6 is enabled in the syste,-
2021-05-29 00:16:18 +02:00
Gustavo Iñiguez Goia
1db03b5570 eBPF procs monitor method: fixed race conditions
It'd probably be a good idea to write a module and encapsulate all the
functionality of the fields in funcs(), to lock them properly
(get/set maps, etc).

TODO: replace monitorLocalAddress() by
netlink.AddrSubscribeWithoptions(), to receive addresses' events
asynchronously.
2021-05-26 22:52:33 +02:00