Commit graph

646 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
f1ef00a5fd
tests: added nftables/system tests
- test add/delete system fw rules
- test fw config disabled.
2023-07-01 22:41:04 +02:00
Gustavo Iñiguez Goia
0a2dcf6406
tests: added basic nftables/rules tests 2023-06-30 16:19:50 +02:00
Gustavo Iñiguez Goia
e345d61076
tests: added nftables/monitor tests 2023-06-30 10:51:18 +02:00
Gustavo Iñiguez Goia
78ac6c0f6b
tests: disable some tests by default, added utils.go tests
- These tests require permissions for creating new namespaces.
  By default disable them for now.
- Added utils.go tests.
2023-06-29 16:19:47 +02:00
Gustavo Iñiguez Goia
d3b40108c7
tests: added sys fw basic tables/chains tests 2023-06-29 11:27:18 +02:00
Gustavo Iñiguez Goia
5a0bd3bc27
added more requirements checks, minor code refactor
- Check kernel configs NET_DIAG_*.
- config.SaveConfiguration() -> config.Save()
2023-06-28 11:24:24 +02:00
Gustavo Iñiguez Goia
8240b7bfda
ui/client: minor code reorganization 2023-06-27 16:47:47 +02:00
Gustavo Iñiguez Goia
de45e1698b
ui: minor code reorganization 2023-06-27 16:19:51 +02:00
Gustavo Iñiguez Goia
a233006d78
added more checks to -checks-requirements
Closes #976
2023-06-25 02:36:12 +02:00
Gustavo Iñiguez Goia
12b4cf3104
added option to secure channel communications
Allow to cypher channel communications with certificates.

There are 3 authentication types: simple, tls-simple and tls-mutual.

 - 'simple' wont't cypher communications.
 - 'tls-simple' uses a server key and certificate for the server, and a
   common CA certificate or the server certificate to authenticate all
   nodes.
 - 'tls-mutual' uses a server key and certificate for the server, and a
   client key and certificate per node.

There are 2 options to verify how gRPC validates credentials:
 - SkipVerify: https://pkg.go.dev/crypto/tls#Config
 - ClientAuthType: https://pkg.go.dev/crypto/tls#ClientAuthType

Example configuration:
    "Server": {
        "Address": "127.0.0.1:12345",
        "Authentication": {
            "Type": "tls-simple",
            "TLSOptions": {
                "CACert": "/etc/opensnitchd/auth/ca-cert.pem",
                "ServerCert": "/etc/opensnitchd/auth/server-cert.pem",
                "ClientCert": "/etc/opensnitchd/auth/client-cert.pem",
                "ClientKey": "/etc/opensnitchd/auth/client-key.pem",
                "SkipVerify": false,
                "ClientAuthType": "req-and-verify-cert"
            }
        }
    }

More info: https://github.com/evilsocket/opensnitch/wiki/Nodes
2023-06-23 16:51:36 +02:00
Gustavo Iñiguez Goia
c2da6d11c8
Merge pull request #969 from jackffmm/master
Dinit service file
2023-06-21 23:29:13 +02:00
Gustavo Iñiguez Goia
f7eec83367
sys fw: allow to add icmp types by commas
- Previously we only supported multiple ICMP types on the same rule
by adding multiple keys:
 Key: type
 Value: echo-request
 Key: type
 Value: echo-reply

Now it's possible to specify them using ',':
 Key: type
 Value: echo-request,echo-reply

- Validate ICMP types before adding them.
2023-06-20 01:14:57 +02:00
jackffmm
0753ee3230
Add files via upload 2023-06-17 23:56:58 +02:00
Gustavo Iñiguez Goia
000a2f1848
avoid notifications errors when saving config
- fsnotify notifies 2 WRITE events sometimes (known bug), which leads to
read 0 bytes one of the times.

As now we send these errors to the GUI, on some systems we were
displaying an error reading the config, which was not really the case.

- Only parse the config before writing it to disk, instead of call the
  load() method.
2023-06-15 00:50:07 +02:00
Gustavo Iñiguez Goia
9bad34bb16
changed default config permissions on saving
- Changed default permissions of default-config.json, system-fw.json
 - Changed bool values by constants.
2023-06-14 12:10:19 +02:00
Gustavo Iñiguez Goia
e1afd24dbf
log: fixed logging service
A default value was preventing from writing logs to the configured file.

+ Changed a couple of locks by rlocks.
2023-06-09 17:43:32 +02:00
selfdenial
52c23ffd5d Introduce 2 new daemon logging options: LogUTC & LogMicro. 2023-06-05 20:46:42 -06:00
Gustavo Iñiguez Goia
102b65e6c3
added new generic remote logger and new formats
- Added new generic remote logger to send events to remote servers.
- Added new formats RFC3164 and JSON.

Configuration example to send events to logstash using the tcp input
plugin, in json format:
 "Loggers": [
    {
        "Name": "remote",
        "Server": "127.0.0.1:3333",
        "Protocol": "tcp",
        "Workers": 5,
        "Format": "json",
        "Tag": "opensnitch"
    },
 ]

logstash configuration, saving events under document.*:
 input {
    tcp {
        port => 3333
        codec => json_lines {
            target => "[document]"
        }
    }
 }

You can also use the syslog input plugin:
 "Loggers": [
    {
        "Name": "remote",
        "Server": "127.0.0.1:5140",
        "Protocol": "tcp",
        "Workers": 5,
        "Format": "rfc3164",
        "Tag": "opensnitch"
    },
 ]

logstash's syslog input plugin configuration:
 input {
    syslog {
        port => 5140
    }
}

Note: you'll need a grok filter to parse and extract the fields.

See: #947
2023-05-29 13:49:38 +02:00
Gustavo Iñiguez Goia
89dc6abbcd
loggers: remote syslog, rfc5424 format improvements
- Allow to configure remote logger's write timeout and workers.
- Improved syslog RFC5424 formatting.
2023-05-28 23:19:56 +02:00
Gustavo Iñiguez Goia
463378c214
misc: changed the level of some messages
Also added [DNS] to some messages.

Related: #954
2023-05-28 16:23:39 +02:00
Gustavo Iñiguez Goia
9c483b1a59
sys,fw: allow to create multiprotocol rules
Now you can add rules to allow multiple protocols.
For example you can add a rule to allow dport/sport for both TCP
and UDP.

There're two options to allow a port:

Statement {
 Name: tcp
 Values:
   Key: dport
   Value: 1234
}

Statement {
 Name: meta
 Values:
   Key: l4proto
   Value: tcp,udp

   Key: dport
   Value: 1234
}

Closes #951.
2023-05-27 22:02:14 +02:00
Gustavo Iñiguez Goia
810b785b3a
sys,fw: put dns rule always at the top of the chain
The DNS rule to intercept DNS responses must always be at the top of
the (input-filter) rules, otherwise we won't receive DNS resolutions.

Adding, removing or changing system fw rules was removing the rule from 1st
position.

Another approach to this problem could be to remove&&add only the dns rule,
instead of disable-enable interception+rules monitor.
2023-05-25 01:20:53 +02:00
Gustavo Iñiguez Goia
9f71c15e57
sys,fw: fixed race condition creating system rules
Hard to reproduce, but not impossible
2023-05-24 14:26:58 +02:00
Gustavo Iñiguez Goia
631f27ee24
loggers: fixed race condition on remote loggers
- Fixed race condition when a remote logger can't open a connection with
  the server.
2023-05-24 01:19:07 +02:00
Gustavo Iñiguez Goia
9079323bed
sys,fw: better fw rules monitor
- Fixed race conditio monitoring interception rules.
2023-05-22 18:10:12 +02:00
Gustavo Iñiguez Goia
6c456aefba
sys fw: fixed race condition reloading rules 2023-05-19 01:35:20 +02:00
Gustavo Iñiguez Goia
de198fd826
fw: fixed leak stopping rules checker 2023-05-18 23:28:42 +02:00
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