Commit graph

769 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
f3a621e192
changed system requirements reading 2023-05-18 14:32:03 +02:00
Gustavo Iñiguez Goia
8513c0dd7f
Added system requirements check
Added flag to check system requirements.
Related: #774
2023-05-18 14:23:40 +02:00
Gustavo Iñiguez Goia
474ad7636d
close ebpf perf module on stopping the monitor 2023-05-10 00:02:53 +02:00
Gustavo Iñiguez Goia
4570491523
allow to filter connections by source port
- Allow to filter connections by source port.
2023-05-01 14:48:34 +02:00
Gustavo Iñiguez Goia
57739cc974
rules: allow to filter connections by source ip/net
- Allow to filter connections by source IP/Network.
  (it also may be useful filter by source port)
- Removed AlwaysOnTop Hint from rules editor dialog.

Closes #922
2023-04-29 18:47:44 +02:00
Gustavo Iñiguez Goia
a1948e259a
Bump versions to 1.6.0 2023-04-22 12:32:53 +02:00
Gustavo Iñiguez Goia
19890062ff
added more logs for better issues debugging
- Log packet mark, which may help debugging VPN connections for example.
- Log the nfqueue number when we fail to setup the queue.
  * Suggest to restart the computer on one particular case (#912).
2023-04-21 23:28:13 +02:00
Gustavo Iñiguez Goia
fe88841640
sys fw: support ports range operators
Allow to use operators (==, !=) when adding firewall rules with port
ranges (444-555).
2023-04-15 00:33:47 +02:00
Gustavo Iñiguez Goia
e32881c03f
sys fw: allow to apply operators on Meta and Ct expressions
Allow to apply operators (==, !=) on Meta (mark, skuid, skgid, etc) and
Conntrack Mark expressions.
2023-04-13 01:36:59 +02:00
Marcelina Hołub
327df0c0ee feat(daemon): add OpenRC script 2023-04-02 02:33:40 +02:00
Gustavo Iñiguez Goia
816496ae72
dns monitor: ignore some dns answers
Ignore those DNS answers that we don't need or use.
2023-03-12 21:37:11 +01:00
Gustavo Iñiguez Goia
5f532e5011
logging: better connections logging
- in DEBUG level log dst_host(dst_ip), instead of only dst_host.
2023-03-10 22:02:02 +01:00
Gustavo Iñiguez Goia
e58ade4365
dns/logs minor improvements
- Fixed adding CNAME domains to cache.
- Better connection logging in DEBUG.
- Exclude from dns cache local IPs, equal IPs/domains.
2023-03-10 21:30:28 +01:00
Gustavo Iñiguez Goia
b560ad6967
Added systemd-resolved DNS monitor
Up until now we intercepted query and DNS answers using these methods:
 - Intercepting DNS queries to port 53.
 - Intercepting DNS answers from port 53
 - Intercepting glibc DNS functions.

Unfortunately there are scenarios where these methods are not enough:
 - When using DNSSEC, DoT, DoH, etc.
 - When resolvers return DNS answers from cache
 - When resolvers don't use glibc functions to resolve domains.
 - When applications use D-BUS to query for domain names instead of
   using UDP/TCP (VPNs, flatpaks, electron based apps, etc.).

With this new DNS monitor now we're able to intercept DNS answers when
systemd-resolved is used to resolve domains.
This includes queries from flatpaks and others containerized
applications, as well as cyphered DNS queries.

Closes #874
2023-03-10 15:04:42 +01:00
NRGLine4Sec
7273f73e59
make version consistent with github tags (#870)
* make version consistent with github tags
2023-02-28 22:21:55 +01:00
Gustavo Iñiguez Goia
5237a2df60
lower error message to debug 2023-02-22 23:07:11 +01:00
Gustavo Iñiguez Goia
da4d834c15
tests: disable netlink sockets tests by default
It causes random failures on restricted environments.
Use NETLINK_TESTS=1 to launch them.
2023-02-21 00:23:16 +01:00
Gustavo Iñiguez Goia
b53e2af52a
Bump versions to 1.6.0rc5 2023-02-18 20:37:08 +01:00
Timur13240
4a21518db2
Replace docs link in opensnitchd.service
replace that "https://github.com/gustavo-iniguez-goya/opensnitch/wiki" link
to "https://github.com/evilsocket/opensnitch/wiki" link
2023-02-09 20:56:29 +00:00
Gustavo Iñiguez Goia
e44e1468b8
improved connections parsing, minor refactoring
When using proc monitor method + interceptUnknown, allow to ask the user
about connections not associated with a process. Usually they're safe to
discard, but on some special cases it helps not disrupt some services.

Block of code to find connections via netstat moved to procmon/
2023-02-04 16:43:24 +01:00
Gustavo Iñiguez Goia
b7c6c8b8db
fw: minor changes for better code reading 2023-01-30 13:43:44 +01:00
Petter Reinholdtsen
3d38ffbd07 Added copyright and license header to daemon/main.go and ui/bin/opensnitch-ui.
Based on git history with no lower threshold on contributions, so any
contributors get a copyright claim in the code.
2023-01-23 06:13:40 +00:00
Gustavo Iñiguez Goia
b546fb9e7a
Bump nftables-go lib version to 0.1.0 2023-01-22 14:40:08 +01:00
Gustavo Iñiguez Goia
18dc32c51f
removed ftrace monitor method
deprecated, was not in use.
2023-01-21 21:03:53 +01:00
Gustavo Iñiguez Goia
9dfcca295a
fixed adding interception chains on old kernels (4.x) 2023-01-07 22:28:52 +01:00
Gustavo Iñiguez Goia
d31c4e86bf
fixed adding interception rule on some kernels
On some kernels (4.19), adding the interception rule to the
inet-mangle-output chain failed.

According to the nftables wiki, the mangle-output chain have (must?) to
be of type Route:
"route type: ... mangle table ... for the output hook (for other
hooks use type filter instead)."

https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains#Base_chain_types

So if we fail adding the interception rule, we retry it with type Filter
instead of Route.

Related: #781 , ced9a24
2023-01-04 21:44:46 +01:00
Gustavo Iñiguez Goia
274a3483d7
improvements to ui, ebpf, netfilter
- Fixed firewall dialog label alignment.
 - Fixed potential race condition when stopping the daemon, and there're
   connections being enqueued.
 - Added "clear" button to GUI's filter line (#786)
 - Create ebpf cache object only if the modules have been loaded.
 - Set default stats workers to the sme amount defined in configuration.

Closes #785
2022-12-23 14:39:49 +01:00
Gustavo Iñiguez Goia
05e63e97a7
sys fw: improved chains creation
This is part of latest commit ced9a24933

 - When reusing a chain, configure the new policy.
 - Don't backup existing rules when reloading the configuration.
2022-12-23 00:50:22 +01:00
Gustavo Iñiguez Goia
39473439b2
ebpf monitor: fixed crash if modules are malformed
If a eBPF module is malformed, we crashed trying reading the eBPF maps.
2022-12-22 11:40:34 +01:00
Gustavo Iñiguez Goia
85776f4d17
Bump ui and daemon versions to 1.6.0rc4 2022-12-22 10:20:36 +01:00
Gustavo Iñiguez Goia
ced9a24933
nftables: fixed adding interception rules
On some systems after disabling and enabling the interception, the
DNS rule was not being re-added, with error: chain already exists.

When the interception is disabled, we firstly remove the rules,
and secondly if the chain and table is empty we try to remove them
as well.

However, on some systems even if "nft list ruleset" didn't list the
chains to hold our rules, it failed with error "already exists".

Before adding a chain now we check if it exists, and if it does we
reuse it.

Closes #781
2022-12-22 00:19:16 +01:00
clayton craft
8f49816dee
daemon/Makefile: improvements to make distro packaging easier (#780)
* daemon/Makefile: add support for PREFIX, DESTDIR, SYSCONFDIR in install

This is helpful for package maintainers who need to install components
into specific locations for building packages of this project.

example:
$ make \
    PREFIX=/usr \
    DESTDIR=/some/package/dir \
    SYSCONFDIR=/foo/etc \
    install

* daemon/Makefile: use 'install' to copy files / make dirs
2022-12-21 10:35:52 +01:00
Gustavo Iñiguez Goia
7b99383546
find connections with connection fields swapped
Under certain situations, like when using systemd-resolved as DNS
resolver, we receive outbound connections with the fields swapped:

Instead of: local-port:local-ip -> public-ip:public-port
we receive: public-port:public-ip -> local-ip:local-port

Sometimes this behaviour causes network slowdowns, or no network at all.

If we swap the fields of these connections, then we're able to get the
process and keep functioning as usual. But what causes this behaviour is
yet unknown, and needs further analysis.

See these issues for more information: #779 , #711
2022-12-20 17:16:20 +01:00
Gustavo Iñiguez Goia
a45ba914e3
better ebpf tasks cancellation
It should improve daemon stopping times.
2022-12-19 18:38:13 +01:00
Gustavo Iñiguez Goia
afa23f5ac2
sys fw: improved rules, profiles policies
- Allow to use commas to define conntrack states:
  ("related,established")
- Remove profile's rules when switching from Deny to Allow.
- Fixed checking duplicated rules.

Closes #778
2022-12-19 10:59:43 +01:00
Gustavo Iñiguez Goia
50217afc9f
added initial support for ICMP and SCTP
Closes: 714
2022-12-18 00:41:06 +01:00
Gustavo Iñiguez Goia
342c75a6e1
better errors, fixed default sys fw conf 2022-12-16 17:09:37 +01:00
Gustavo Iñiguez Goia
c81dc22c02
sys fw: allow to change fw type from the GUI
- Configuration of system firewall rules from the GUI is not supported for
 iptables. Up until now only a warning was displayed, encouring to change
 fw type manually.

 Now if configured fw type is iptables (default-config.json, Firewall:),
 and the user opens the fw dialog, we'll ask the user to change it from
 the GUI.

- Add fw rules before connecting to the GUI. Otherwise we send to the
  GUI an invalid fw state.
2022-12-16 17:03:36 +01:00
Gustavo Iñiguez Goia
1775da2b48
sys fw: silence error parsing configuration
Some checks failed
CI - build eBPF modules / build (5.19, 1.5.0) (push) Has been cancelled
CI - build eBPF modules / build (5.19, master) (push) Has been cancelled
CI - build eBPF modules / build (5.8, 1.5.0) (push) Has been cancelled
CI - build eBPF modules / build (5.8, master) (push) Has been cancelled
Build status / Build (push) Has been cancelled
2022-12-11 22:11:37 +01:00
Gustavo Iñiguez Goia
93e1135b4a
better ebpf errors printing
Provide more information when loading ebpf modules fails.
2022-12-11 17:25:05 +01:00
Gustavo Iñiguez Goia
23b1a6b75e
fw: restore chains policy where applicable
If the user configures chains' policy to Drop, we need to restore it to
Accept when exiting, otherwise we could block connections
unintentionally.
2022-12-11 14:15:17 +01:00
Gustavo Iñiguez Goia
2e2f1768f2
improved errors printing 2022-12-11 11:41:47 +01:00
Gustavo Iñiguez Goia
e2a822b731
better errors printing
Explain a littler bit better some errors.
2022-12-10 21:49:48 +01:00
Gustavo Iñiguez Goia
daae591d05
impoved alerts
- Increased number of alerts to queue.
- Fixed sending alerts to server.
2022-12-09 17:03:02 +01:00
Gustavo Iñiguez Goia
1a493b9da1
ebpf: improved process details gathering
In order to detect short-lived processes we intercept new processes
executions as they happen, and cache them for later use.

When a new connection is established, then we check if the PID of the
connection is cached, and use the details of the process to ask the user
to allow or deny it.

However, there're some situations where the path or cmdline of a PID,
doesn't correspond with the one that's establishing the connection.

Given the same PID:
 - Sometimes we receive from the tracepoint a wrong/non-existent path.
 - Other times we receive a "helper" which is the one executing the
   real binary that opens the connection.

For these reasons now when a new connection is established, we read the
path to the binary from proc. If the PID is cached and the cached path
differs, then we'll use the path from proc.

We lose a bit of performance, but hopefully we'll be more consistent
with what the user expect, while at the same time keeping intercepting
short-lived processes.

Downsides: for execveat() executions we won't display the original binary.

Closes #771
2022-11-27 14:03:13 +01:00
Gustavo Iñiguez Goia
314ee820ce
centralized ebpf modules loading 2022-11-18 20:38:52 +01:00
Gustavo Iñiguez Goia
c64b2df03c
ebpf: delete expired exec events from cache
Whenever a process exits, we delete the corresponding entry from
cache.

But when a process executes a new process (sh -c ls), we receive an
exit event for the parent, while the child continues working with *the
same PID*. Sometimes we don't receive exit events for the child, so the
entry was never removed from cache.

We should properly detect the exits, but forthe time being, delete
expired processes from cache every minute.
2022-11-15 23:30:26 +01:00
Gustavo Iñiguez Goia
6bfe6cef8d
Bump versions to 1.6.0-rc.3 2022-11-15 00:52:23 +01:00
Gustavo Iñiguez Goia
a3538a728f
systemd service: wait 10s to stop, otherwise kill daemon 2022-10-27 17:53:42 +02:00
Gustavo Iñiguez Goia
ec31ee0814
sys fw: added option to filter by MAC 2022-10-23 11:36:51 +02:00