Commit graph

51 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
831ab347e3 Merge branch 'priority-rules' into main
Added option to let the users define iptables rules.

The system rules are added in the file /etc/opensnitchd/system-fw.json
with this format:
```
{
    "SystemRules": [
        {
            "Rule": {
                "Description": "Allow pptp VPN",
                "Table": "mangle",
                "Chain": "OUTPUT",
                "Parameters": "-p gre",
                "Target": "ACCEPT",
                "TargetParameters": ""
            }
        }
    ]
}
```
On the mangle table, OUTPUT chain, these rules are added before
the NFQUEUE interception rule, so any rule you add there bypasses the
interception. Useful to allow traffic you don't want to intercept.

This feature solves in some way the issue some users have connecting to
VPNs when the Default Action configured in the daemon is Deny.

For example:
- OpenVPN when keepalive is configured and ICMP is used.
- PPTP because the GRE routing protocol is blocked.
- probably others like IPSEC.

(regarding WireGuard, as far as I can tell it works just fine, see #61).

closes #47
2020-11-13 00:14:39 +01:00
Gustavo Iñiguez Goia
ff5c1ff4c2 cli logging parameters overwrite config options
Parameters passed by command line must overwrite the options configured
in the config file.

closes #82
2020-11-02 01:37:35 +01:00
Gustavo Iñiguez Goia
0d1e9f5b47 set server address and log file from the default config
The server address and log file were hardcoded into the
opensnitchd.service file, making it almost impossible to change.

Soon we'll be able to change it from the UI.
2020-10-26 23:16:27 +01:00
Gustavo Iñiguez Goia
df9e781051 Do not panic if we can't insert fw rules
Some systems has the IPV6 protocol disabled, so we failed starting up
with the error "Address family not supported by protocol" (#52).

Now we don't exist even if we can't insert the needed rules, we'll just
log the error.
2020-07-30 01:10:53 +02:00
Gustavo Iñiguez Goia
b547067f61 close nfqueue descriptors gracefully
When the daemon is stopped, we need to close opened netfilter recurses.
Otherwise we can fall into a situation where we leave NFQUEUE queues
opened, which causes opensnitch to not run anymore until system restart
or a manual intervention, because there's a NFQUEUE queue already created
with the same ID.

This is what was happening as a collateral effect of #41.
2020-07-17 01:29:58 +02:00
Gustavo Iñiguez Goia
b03bbf0506 fixed race conditions setting log level and monitor methods 2020-06-14 20:14:24 +02:00
Gustavo Iñiguez Goia
78c0da83c0 increase default timeout to ask for a rule
Explained here: https://github.com/gustavo-iniguez-goya/opensnitch/issues/28#issuecomment-637484501
2020-06-04 00:38:11 +02:00
Gustavo Iñiguez Goia
d8b2f41e08 Apply default action if a rule is disabled. 2020-05-10 17:08:08 +02:00
Gustavo Iñiguez Goia
83ffaaad44 decrease log level of denied connections
Denied connections were logged with Warning level.
However if you had a rule that denied a particular noisy connection, it
generated too much logs that didn't add value.

In the future it would be nice to log as warning, denied connections
that do not have a rule created by a user.

Discussion: https://github.com/gustavo-iniguez-goya/opensnitch/issues/10#issuecomment-615854975
2020-04-20 01:00:16 +02:00
Gustavo Iñiguez Goia
6ee80b1640 Allow to change settings from the UI
(1/2)
We start receiving notifications from the UI, which allow us to change
configurations and perform actions on the daemon.

The concept of Node has also been introduced, which identifies every
daemon (client) connected to the UI (server).

These options has been added:
- Enable/Disable firewall interception (for all nodes)
- Change daemons (clients) configuration. globally or per node.
- Change prompt dialog options.

We have fixed some bugs along the way:
- Close audit client connection gracefully.
- Exclude our own connections from being intercepted.
- Better handling of client connection status with the UI.

We probably has also introduced some other bugs (not listed here).
2020-04-19 20:13:31 +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
dbb86d7df8 avoid to crash if opensnitchd is already running 2020-03-13 12:47:04 +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
6a82cdbac1 Allow to select which log level to use
Let the user choose which level log to use. For now it must be set
manually and when starting the daemon.
2020-02-28 10:24:08 +01:00
Gustavo Iñiguez Goia
c5a3fb5132 Allow to select what process search method to use
Until now OpenSnitch used ftrace(debugfs) to search for running
processes (PIDs) and obtain the process path.

On some systems, this filesystem is not mounted or available, so we have
to rely on /proc.

After several weeks of use, I think that it's faster and more accurate
the 2nd method, search pids/cmdlines in /proc. So we offer the user to
choose which one to use.
2020-02-26 19:13:42 +01:00
Gustavo Iñiguez Goia
2c7472f06d firewall: check rules every 5s
Every 5s check if our rules are loaded, and if they aren't, add them
again.
2020-02-22 00:27:35 +01:00
Gustavo Iñiguez Goia
9207465d58 Do not panic if we can't parse a Regex type rule
If for some reason a Regex type rule can not be parsed, opensnitchd
panics and exit. We drop regex.MustCompile() in favor of
regex.Compile(), and in case of failure we just drop the packet.

In either case, the daemon should not panic but it should not received
an invalid rule either, specially from the UI.

Closes #4
2020-02-14 23:15:14 +01:00
Gustavo Iñiguez Goia
1e2f9aa124 Find pid of a process in /proc if debugfs is unavailable
debugfs is not always available due to different reasons:
https://github.com/evilsocket/opensnitch/issues/214
https://github.com/evilsocket/opensnitch/issues/276

Fallback to /proc parsing, although procfs could also be not available.

Easily testable by unmounting debugfs (umount debugfs) and launch
opensnitchd. It should work as expected.
2020-02-13 23:08:58 +01:00
Gustavo Iñiguez Goia
912f85f5d1 Added more timeout options (30s, 5m, 15m, 30m, 1h)
Added 30s, 5m, 15m, 30m and 1h timeout options to deny or allow
connections.

It helps to avoid repetitive new connection dialogs, while at the same
time it allows you to deny/allow a connection for a short period of time,
and apply the default for the rest.
2019-11-09 01:35:13 +01:00
Gustavo Iñiguez Goia
7eec749498 allow to configure unknown conns interception
/etc/opensnitchd/default-config.json can now contain
"intercept_unknown": true|false
2019-11-01 01:00:10 +01:00
Gustavo Iñiguez Goia
5690d37d52 Merge branch 'clean_fw_rules_before_start' into main 2019-10-21 19:25:42 +02:00
Gustavo Iñiguez Goia
8922d445af Clean firewall rules before start
If opensnitchd dies unexpectedly, firewall rules are not cleaned up.
2019-10-21 19:23:29 +02:00
Gustavo Iñiguez Goia
ad70655698 removed useless trace log 2019-10-21 00:40:26 +02:00
Gustavo Iñiguez Goia
dedd009204 Merge branch 'daemon_default_config' into main 2019-10-21 00:02:25 +02:00
Gustavo Iñiguez Goia
a7e9b5072f project import paths changed 2019-10-20 21:51:35 +02:00
Gustavo Iñiguez Goia
3bc83efd10 apply default action to connections that can not be parsed
If a connection can not be parsed for some reason, apply the default
action configured.
2019-07-31 01:44:41 +02:00
evilsocket
461e6b678e
using ftrace in order to track pids in realtime 2018-04-17 18:08:03 +02:00
evilsocket
a80f41a147
misc: small fix or general refactoring i did not bother commenting 2018-04-16 17:51:54 +02:00
evilsocket
4560219b92
parsing process env (ref #152) 2018-04-15 15:47:08 +02:00
evilsocket
b014a4069e
misc: small fix or general refactoring i did not bother commenting 2018-04-15 15:39:43 +02:00
evilsocket
e3db27dfc3
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:15:30 +02:00
evilsocket
01e5134139
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:11:39 +02:00
evilsocket
fc97f5b431
misc: small fix or general refactoring i did not bother commenting 2018-04-10 13:06:02 +02:00
evilsocket
de1d7cd414
misc: small fix or general refactoring i did not bother commenting 2018-04-10 12:52:01 +02:00
evilsocket
7e474a0514
refactored netfilter code, implemented SetVerdictAndMark method 2018-04-08 20:13:35 +02:00
evilsocket
fb5ccb03a3
added the number of loaded rules in the statistics 2018-04-08 17:20:37 +02:00
evilsocket
ead3725bbe
added rules live reloading (closes #128) 2018-04-08 16:36:12 +02:00
evilsocket
8009743d60
when the thc kicks in and you find a better logic, better naming, better design and new ideas 2018-04-08 15:32:20 +02:00
evilsocket
589c9f57f5
misc: small fix or general refactoring i did not bother commenting 2018-04-07 13:58:34 +02:00
evilsocket
a33c463ffb
support rules with type=regexp (closes #127) 2018-04-07 13:52:25 +02:00
evilsocket
e920e85f97
added support for a tcp listener (closes #119) 2018-04-07 01:52:43 +02:00
evilsocket
0a26d4ea5d
misc: small fix or general refactoring i did not bother commenting 2018-04-06 01:44:15 +02:00
evilsocket
c8fc9726f3
misc: small fix or general refactoring i did not bother commenting 2018-04-05 23:56:26 +02:00
evilsocket
b6bdeb7173
misc: small fix or general refactoring i did not bother commenting 2018-04-05 23:56:07 +02:00
evilsocket
05c1676271
misc: small fix or general refactoring i did not bother commenting 2018-04-05 18:15:36 +02:00
evilsocket
9fe5915e5b
misc: small fix or general refactoring i did not bother commenting 2018-04-05 17:41:12 +02:00
evilsocket
540335056b
misc: small fix or general refactoring i did not bother commenting 2018-04-03 14:51:58 +02:00
evilsocket
b5b4a56a45
added ui ping/pong 2018-04-02 18:26:04 +02:00
evilsocket
36c9b515f1
misc: small fix or general refactoring i did not bother commenting 2018-04-02 18:11:36 +02:00
evilsocket
9887fc936d
added version and expanded paths 2018-04-02 05:34:21 +02:00