Commit graph

912 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
23b61f5341 ui, pop-ups: allow to choose the position of popups
This feature was disabled on the preferences dialog, it just needed to
be removed or implmented.
2021-04-17 13:07:38 +02:00
Gustavo Iñiguez Goia
49d12612db ui: updated help url, fixed a typo
point help links to evilsocket's repo.
fixed error launching the GUI when there's no systray available.
2021-04-13 00:10:56 +02:00
Gustavo Iñiguez Goia
f288078c0b ui, db: fixed loading db type from saved configuration
If a db from disk was being used, and the user changed it to in-memory,
we were still loading the file from disk.
2021-04-12 17:59:14 +02:00
Gustavo Iñiguez Goia
03e97903d6 ui, prefs/pop-ups: improved layout
specially for non-desktop displays (mobiles), like librem5.
2021-04-12 17:52:27 +02:00
Gustavo Iñiguez Goia
4332469fc2 improved nodes connectivity handling
problem:
 - after losing network connectivity node<->server, the node didn't restore
   the connection. In reality, the connection with the server was not
   closed, but the notifications channel was closed due to inactivity
   after 20s.

set inactivity timeouts to 20s on both node and server. Previous
timeouts were 2h for the main connection and 20s for the streaming
channels (notifications).

- get rid of the logic to determine if the server is alive or not based
  on sending pings.
  Instead, use the connection events when a node connects/disconnects
  (Subscribe).
  The Ping call is still used to send the statistics.

other:
- fixed exception when updating the status of a node.
2021-04-11 20:55:14 +02:00
Gustavo Iñiguez Goia
356e3dc54e ui: fixed notifications and rules editing
- fixed remote nodes rules editing.
- improved notifications when a node is not connected and an action is
  performed on it (edit a rule, disable/enable a rule, etc).
2021-04-08 00:49:49 +02:00
Gustavo Iñiguez Goia
2c1c3b0251 ui,stats: added more options to handle rules in batch
- allow to change duration and action to multiple rules at once.
closes #393
- fixed updating a rule on the db (per node).
- fixed typo.

 #334
2021-04-07 23:14:26 +02:00
Gustavo Iñiguez Goia
c7411a4770 ui, pop-up: improved layout
better layout when there's or there isn't app description.
2021-04-07 19:03:50 +02:00
Gustavo Iñiguez Goia
dbe7861bcb ui: allow to select eBPF method from the GUI
+ fixed getting PID column in order to monitor processes' details.
2021-04-05 13:28:16 +02:00
Gustavo Iñiguez Goia
0a12fc5c73 don't save daemon config if monitor method fails
If we change the monitor method from the GUI, and it fails to start
(eBPF, audit or ftrace), use the old configured method and don't save
the configuration to disk, to avoid configuring a monitor method that
doesn't work.
2021-04-05 13:18:19 +02:00
Gustavo Iñiguez Goia
8ea58ade19 fixed ebpf error logging
+ split functionality into different files.
2021-04-05 12:19:00 +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
148526e527
Merge pull request #381 from raboof/support-more-recent-protoc-gen-go
Support more recent protoc-gen-go
2021-04-03 18:10:18 +02:00
Gustavo Iñiguez Goia
e2be2b769a improved monitor method switching (audit)
when switching from audit to another one.
2021-03-30 01:13:02 +02:00
Gustavo Iñiguez Goia
4b0b8ccef0 display an error if a monitor method has not been applied
Sometimes ftrace monitor method fails to apply, but we displayed on the
GUI that it had been applied.
2021-03-29 17:59:09 +02:00
Gustavo Iñiguez Goia
7934dfac7f debs, ui: fixed package creation 2021-03-29 01:54:24 +02:00
Gustavo Iñiguez Goia
879d18f15a ui: fixed monitoring processes details
- ui: fixed error getting the icon of an app.
- ui: fixed getting the list of pids of an app.
- ui: improved proc details start/stop icon behaviour.
- daemon: improved error message when we fail getting the details of a
  process.

others:
 - changed icon search by system-search.
2021-03-29 01:36:41 +02:00
Arnout Engelen
1f26f66e8a
Support more recent protoc-gen-go
When building the project with protoc-gen-go version 1.5.1,
it fails with the following:

```
protoc -I. ui.proto --go_out=plugins=grpc:../daemon/ui/protocol/
protoc-gen-go: unable to determine Go import path for "ui.proto"

Please specify either:
	• a "go_package" option in the .proto source file, or
	• a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

--go_out: protoc-gen-go: Plugin failed with status code 1.
```

This can be fixed by adding the full go package as an option in the
proto file. To make sure the code is generated to the correct path,
we also have to add add the `paths=source_relative` option to the
protoc plugin.

After this, the code is generated correctly, but the generated code
references classes like grpc.ClientConnInterface which were introduced
in 1.27.0.
2021-03-28 16:38:21 +02:00
Gustavo Iñiguez Goia
8af290e970 Bump versions to 1.4.0rc1 2021-03-26 00:59:16 +01:00
Gustavo Iñiguez Goia
6048b0ef64 more cache improvements
- don't clean cache by number of items.
- clean inodes from cache every 2' if the descriptor symlink doesn't exist
  anymore, or if the lastSeen time is more than 5 minutes.
- launch cache cleaners before start a new process monitoring method,
  and start it only once for the life time of the daemon.
- do not store in cache the Time objects, only the nanoseconds of
  the last updated time.
- if the inode of a connection is found in cache, reorder the
  descriptors to push the descritptor to the top of the list.
  Also add cached the inode.

It turns out that when a new connection is about to be established,
when the process resolves the domain, the same inode is used to open the
tcp connection to the target. So if it's cached we save CPU cycles.

This also occurs when we block a connection and the process retries it,
or when a connection timeouts and the process retries it
(telnet 1.1.1.1).
2021-03-24 01:16:47 +01:00
Gustavo Iñiguez Goia
7b9a57b788 added -version cli option
closes #374
2021-03-22 17:51:31 +01:00
gnuhead-chieb
f8607d8619
[Locale]Add Japanese Translation (#375)
Added Japanese Translation
2021-03-21 22:23:47 +01:00
Gustavo Iñiguez Goia
630e3717dd auditd: cache new Proc objects 2021-03-21 21:55:59 +01:00
Gustavo Iñiguez Goia
36cdb76113 prevent leaks when reloading domains lists in debug
If the log level was debug, when reloading the lists of domains could
lead to memory leaks.
2021-03-21 21:16:57 +01:00
Flávio Costa
7cd16c6f3d
Update Brazilian Portuguese translation (#372) 2021-03-20 10:42:37 +01:00
Gustavo Iñiguez Goia
1a61a2dca9 cache improvements
- update the descriptors/inodes of a PID when it's found in cache.
- when a descriptor/inode is found in cache, push it to the top
  of the descriptors list. The next time it's found in cache it'll be in
  the 1st position of the list, saving CPU time.
- added test cases and benchmark helpers to help analyzing performance.
2021-03-19 19:05:45 +01:00
Gustavo Iñiguez Goia
b29283805e updated spanish translation 2021-03-19 13:28:34 +01:00
Gustavo Iñiguez Goia
7b7e110537
Merge pull request #352 from tioguda/translation
Update Brazilian Portuguese translation
2021-03-18 00:31:14 +01:00
Gustavo Iñiguez Goia
53904cb70f ignore hidden files when loading lists of domains 2021-03-14 20:23:48 +01:00
Gustavo Iñiguez Goia
0d2e8b56ea added operator tests
fixed lists operator tests.
added domain lists tests.
2021-03-05 01:10:01 +01:00
Gustavo Iñiguez Goia
408150073a fix deadlock
closes #365
2021-03-04 12:10:53 +01:00
Gustavo Iñiguez Goia
0362a0b780 ui, pop-ups: added app description, better icon discovery
Added the description of an app to the pop-ups, to help users know
what an application is or does.

The discovery of app icons has been improved for those edge cases where
the system is not properly configured and we were not able to get the
icon of the app.
2021-03-03 23:57:25 +01:00
Gustavo Iñiguez Goia
c7d93d83a5 improved rules (re)loading
- Delete lists of domains if the rule about to change is of type Lists.
- Monitor the lists of domains, and reload them if they're modified.
- Delete rules from disk when the Duration changes from
  Always (saved on disk) to !Always (temporary).
- After the above operation a fsnotify Remove event is fired. Don't
  delete the rule from memory if it's temporary.
- Rules are only compiled if they're enabled, avoiding unnecessary
  allocations.
2021-03-01 12:41:35 +01:00
Gustavo Iñiguez Goia
1528fabfca
Merge pull request #362 from themighty1/master
flush conntrack at start
2021-02-28 15:23:15 +01:00
themighty1
616681e44d flush conntrack at start 2021-02-28 15:21:07 +03:00
Gustavo Iñiguez Goia
0b978c0c1f
Merge pull request #361 from themighty1/master
clean up the obsolete "drop marked"
2021-02-28 10:01:18 +01:00
themighty1
b5bf4edec7 clean up the obsolete "drop marked" 2021-02-28 11:30:26 +03:00
Gustavo Iñiguez Goia
1d277efd01 updated operator and loader tests 2021-02-27 01:56:49 +01:00
Gustavo Iñiguez Goia
44e8561e0c load/reload rules from disk one by one
Any rule changed on disk caused reloading of all rules, usually
up to three times. This caused some problems.

- Don't compile Operators if the rule is disabled.
- Empty lists of domains if the user disables the rule.
- Delete rule from disk if the duration is not Always anymore.
2021-02-27 01:39:04 +01:00
Gustavo Iñiguez Goia
4532c2513e delete loaded lists when needed
There're some situations where we need to delete loaded lists:
 - When an enabled rule of type Lists is disabled (after changed on
   disk, or when configured from the GUI).
 - When an enabled rule of type List with an Operator of type Lists is
   disabled.
2021-02-25 20:09:23 +01:00
Gustavo Iñiguez Goia
c9ba858fc5 add missing operator lists file
needed to load lists.
2021-02-25 13:51:36 +01:00
Gustavo Iñiguez Goia
26671ded24 added support for list of domains
Initial support to filter connections using lists of domains.

The lists must be in hosts format:
- 0.0.0.0 www.domain.com
- 127.0.0.1 www.domain.com

From the rules editor, create a new rule, and select
[x] To this lists of domains

Select a directory with files in hosts format, select [x] Priority rule,
select [x] Deny and click on Apply.

An example of a list in hosts format:
https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt

Note: you can also add a list of domains to allow, not only domains to
block.

TODOs:
- support for URLs besides directories (local lists).
- support for scheduled updates of the above URLs.

related #298
2021-02-25 13:38:48 +01:00
Gustavo Iñiguez Goia
fab5d97cd8
Merge pull request #356 from themighty1/upstreammaster
github action fix
2021-02-23 16:26:32 +01:00
themighty1
9b0f400c5e github action fix 2021-02-23 18:11:27 +03:00
Gustavo Iñiguez Goia
484be33b08
Merge pull request #346 from themighty1/master
makefile:
2021-02-22 16:36:55 +01:00
Gustavo Iñiguez Goia
a325876641 improved connection parsing
Sometimes when querying the kernel for a given connection, the inode of
the connection is 0, i.e.: invalid (or not yet valid).

In these cases we search for the connection in /proc/net/. It turns out
that some connections are found in netstat but the inode is still 0, and
we were accepting them erronously.

As a result, when looking for the inode under /proc we didn't find it,
so an "Unknown process" dialog was shown to the user.

Discarding this type of connections avoids unknown process dialogs when
using Epiphany in particular. It retries to establish the connection
several times, and finally we're able to find the PID of the process.
2021-02-20 23:53:22 +01:00
Gustavo Iñiguez Goia
0dbd8e00ee
Merge pull request #355 from themighty1/upstreammaster
wait for success when sending packet to chan, don't error out after f…
2021-02-19 12:47:14 +01:00
themighty1
6f6e91ac41 wait for success when sending packet to chan, don't error out after first failed attempt.
When testing this patch under a heavy load of 300 new connections per second running for 12 hours, I saw a few timeouts.
This means that there are legitimate cases when sending the packet to the channel will not go through
no matter how long we wait.
However, compared to the old behavior, the amount of dropped packets decreased by a factor of 100x.

The value of timeout is chosen to be 1 millisecond, because it feels reasonable that if after so long the packet did
not go through, it is not due to a congested channel but due to some other error which will not go away even if we wait longer.
2021-02-19 09:01:01 +03:00
Gustavo Iñiguez Goia
b066b11c47 improved complex rules
Every rule has an entry point besides a constructor, which configures
all it needs to match connections, based on user defined criteria (ip,
regexp, etc).

This only needs to be done the first time we load a rule, because the
fields of a rule are static. However for rules of type "lists" we were
iniatializing each rule of this type once per connection that it
matched.
2021-02-19 01:03:45 +01:00
Gustavo Iñiguez Goia
72a2162577
Merge pull request #354 from themighty1/upstreammaster
do not block connection processing when GUI popup is active.
2021-02-18 20:50:16 +01:00