Netstat sort of fills this niche, but not without a lot of manual toil on behalf of the operator. In general, Linux and the apps in the ecosystem are much more well-behaved with regard to "wtf is this traffic" compared to macOS or Windows.
Trust is great and all but visibility is better. Linux is still dicey to correlate traffic with a particular app, especially if the connection is/was shortlived.
This is has become a lot easier and more reliable to do now with BPF [0].
I also used the same approach to create a somewhat user-friendly TUI and web dashboard for it [1]. It is also able to hash the executable (even if it was shortlived).
[0] https://www.gcardone.net/2020-07-31-per-process-bandwidth-mo...
can ebpf operate in a blocking manner while making drop/allow decisions on packets WITH reliable access to the callers pid and argv?
I wasn't talking about using it as a firewall, just a connection/bandwidth monitor that correlates traffic with a particular app.
picosnitch looks really cool! i’ve rss subscribed to its github commits.
If so (without a kernel vulnerability which should be a given) I'd like to have it mentioned under the limitations section for picosnitch so others can be aware as well.
[0] https://github.com/iovisor/bcc/blob/master/docs/reference_gu...
in the end there are only two ways to handle this: drop data or block. for a bandwidth monitor, i’d choose drop. for a firewall, i’d choose block.
i use bpftrace to monitor docker filesystem access in a similar way[1]. i also increase the ringbuffer size until i stop seeing lost data.
https://github.com/evilsocket/opensnitch/blob/4ce8b0e57cfb25... https://github.com/evilsocket/opensnitch/blob/d9e0c59158ddf6...
my understanding of what is happening is as follows:
- 1: libnetfilterqueue gets a packet.
- 2: lookup packet via ebpf to get pid and argv.
- 3: lookup rule, on miss prompt user to allow/deny.
- 4: libnetfilterqueue allows/denies the packet.
the tricky part is step 2. afaik there are 3 possibilities:
- ebpf already knows about about this packet, return pid and argv.
- ebpf will know about this packet shortly, wait, then return pid and argv.
- ebpf dropped the data because of ringbuffer overflow, wait, then give up.
Little snitch does not have this issues and you can have multiple users logged in with fast user switching and all can operate their notifications no problem.
lsof -i -n -P | grep "\\-\>" | awk '{a[\$1"_p"\$2]++;}END{ for (it in a){print it,a[it]}}' | sort -nr -k2,2
This project uses conky to display the current connexions:
awk '{a[$1"_p"$2]++;}END{ for(it in a){print it,a[it]}}'