All Projects → elesiuta → picosnitch

elesiuta / picosnitch

Licence: GPL-3.0 license
Monitor network traffic per executable using BPF

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to picosnitch

Siac
SIAC is an enterprise SIEM built on open-source technology.
Stars: ✭ 100 (-76.3%)
Mutual labels:  intrusion-detection
Py Idstools
idstools: Snort and Suricata Rule and Event Utilities in Python (Including a Rule Update Tool)
Stars: ✭ 205 (-51.42%)
Mutual labels:  intrusion-detection
yulong-hids-archived
[archived] 一款实验性质的主机入侵检测系统
Stars: ✭ 2,079 (+392.65%)
Mutual labels:  intrusion-detection
Awesome Threat Detection
A curated list of awesome threat detection and hunting resources
Stars: ✭ 1,804 (+327.49%)
Mutual labels:  intrusion-detection
Wazuh
Wazuh - The Open Source Security Platform
Stars: ✭ 3,154 (+647.39%)
Mutual labels:  intrusion-detection
Wazuh Docker
Wazuh - Docker containers
Stars: ✭ 213 (-49.53%)
Mutual labels:  intrusion-detection
Pysad
Streaming Anomaly Detection Framework in Python (Outlier Detection for Streaming Data)
Stars: ✭ 87 (-79.38%)
Mutual labels:  intrusion-detection
fever
fast, extensible, versatile event router for Suricata's EVE-JSON format
Stars: ✭ 47 (-88.86%)
Mutual labels:  intrusion-detection
Briarids
An All-In-One home intrusion detection system (IDS) solution for the Raspberry PI.
Stars: ✭ 187 (-55.69%)
Mutual labels:  intrusion-detection
hyperdome
the safest place to reach out
Stars: ✭ 26 (-93.84%)
Mutual labels:  privacy-protection
Snort Rules
An UNOFFICIAL Git Repository of Snort Rules(IDS rules) Releases.
Stars: ✭ 135 (-68.01%)
Mutual labels:  intrusion-detection
Osquery Extensions
osquery extensions by Trail of Bits
Stars: ✭ 180 (-57.35%)
Mutual labels:  intrusion-detection
Wazuh Kibana App
Wazuh - Kibana plugin
Stars: ✭ 212 (-49.76%)
Mutual labels:  intrusion-detection
Nfr
A lightweight tool to score network traffic and flag anomalies
Stars: ✭ 104 (-75.36%)
Mutual labels:  intrusion-detection
LID-DS
LID-DS is an intrusion detection data simulation framework.
Stars: ✭ 32 (-92.42%)
Mutual labels:  intrusion-detection
Blackbook
Blackbook of malware domains
Stars: ✭ 89 (-78.91%)
Mutual labels:  intrusion-detection
Pi.alert
WIFI / LAN intruder detector. Check the devices connected and alert you with unknown devices. It also warns of the disconnection of "always connected" devices
Stars: ✭ 209 (-50.47%)
Mutual labels:  intrusion-detection
waycup
A minimal tool that hides your online assets from online security scanners, researchers and hackers.
Stars: ✭ 100 (-76.3%)
Mutual labels:  privacy-protection
Intrusion Detection
Whenever founds internet connectivity confirms is it you, if not log you off and send you image of intruder.
Stars: ✭ 24 (-94.31%)
Mutual labels:  intrusion-detection
Secuml
Machine Learning for Computer Security
Stars: ✭ 221 (-47.63%)
Mutual labels:  intrusion-detection

GitHub release PyPI release AUR release Copr release OBS package build status GitHub commits since latest release GitHub contributors Source size

screenshot.png

picosnitch

  • 🔔 Receive notifications whenever a new program connects to the network, or when it's modified
  • 📈 Monitors your bandwidth, breaking down traffic by executable, hash, parent, domain, port, or user over time
  • 🛡️ Can optionally check hashes or executables using VirusTotal
  • 🚀 Executable hashes are cached based on device + inode for improved performance, and works with applications running inside containers
  • 🕵️ Uses BPF for accurate, low overhead bandwidth monitoring and fanotify to watch executables for modification
  • 👨‍👦 Since applications can call others to send/receive data for them, the parent executable and hash is also logged for each connection
  • 🧰 Pragmatic and minimalist design focussing on accurate detection with clear error reporting when it isn't possible

installation

AUR for Arch and derivatives

Details

PPA for Ubuntu and derivatives

Details
  • sudo add-apt-repository ppa:elesiuta/picosnitch
  • sudo apt update
  • sudo apt install picosnitch
  • install extra dependencies for dash using pip (optional): dash, pandas, and plotly
    • sudo apt install python3-pip
    • pip3 install dash pandas plotly --user
  • you will likely require a newer version of BCC (unofficial PPA) since the version in the Ubuntu repos lags behind its supported kernel

OBS for Debian and derivatives

Details
  • visit the OBS picosnitch page and follow the instructions for your distribution
  • install extra dependencies for dash using pip (optional): dash, pandas, and plotly
    • sudo apt install python3-pip
    • pip3 install dash pandas plotly --user
  • if you're having issues on bullseye, you may need a newer version of BCC

OBS for openSUSE Tumbleweed and derivatives

Details
  • sudo zypper addrepo https://download.opensuse.org/repositories/home:elesiuta/openSUSE_Tumbleweed/home:elesiuta.repo
  • sudo zypper refresh
  • sudo zypper install picosnitch
  • install extra dependencies for dash using pip (optional): dash, pandas, and plotly
    • sudo zypper install python3-pip
    • pip3 install dash pandas plotly --user

Copr for Fedora, Mageia, Mandriva, and derivatives

Details
  • sudo dnf copr enable elesiuta/picosnitch
  • sudo dnf install picosnitch
  • install extra dependencies for dash using pip (optional): dash, pandas, and plotly
    • sudo dnf install python3-pip
    • pip3 install dash pandas plotly --user

PyPI for any Linux distribution with Python >= 3.8

Details
  • install the BPF Compiler Collection python package for your distribution
    • it should be called python-bcc or python-bpfcc
  • install picosnitch using pip
    • pip3 install "picosnitch[full]" --upgrade --user
    • warning: installing as user makes it easier for another program to modify picosnitch; however, installing with sudo results in xkcd.com/1987
  • create a service file for systemd to run picosnitch (recommended)
    • picosnitch systemd
  • optional dependencies (will install from PyPI with [full] if not already installed)
    • for dash: dash, pandas, and plotly
    • for notifications: dbus-python, python-dbus, or python3-dbus (name depends on your distro and should be installed from their repo)
    • for sql server: one of psycopg, pymysql, mariadb, or psycopg2 (latter two not included with [full])
    • for VirusTotal: requests

GitHub for installing from source

Details
  • clone the repo or download picosnitch.py and setup.py
  • install the BPF Compiler Collection python package for your distribution
    • it should be called python-bcc or python-bpfcc
  • install psutil
  • install python-setuptools
  • install picosnitch with python setup.py install --user
  • see other options with python setup.py [build|install] --help
  • you can also run the script picosnitch.py directly

usage

  • running picosnitch
    • enable/disable autostart on reboot with systemctl enable|disable picosnitch
    • start/stop/restart with systemctl start|stop|restart picosnitch
    • or if you don't use systemd picosnitch start|stop|restart
  • web user interface for browsing past connections
    • start with picosnitch dash
    • visit http://localhost:5100 (you change this by setting the environment variables HOST and PORT)
  • terminal user interface for browsing past connections
    • start with picosnitch view
    • space/enter: filter on entry backspace: remove filter h/H: cycle through history t/T: cycle time range u/U: cycle byte units r: refresh view q: quit
  • show usage with picosnitch help

configuration

  • config is stored in ~/.config/picosnitch/config.json
    • restart picosnitch if it is currently running for any changes to take effect
{
  "Bandwidth monitor": true, # Log traffic per connection since last db write
  "DB retention (days)": 90, # How many days to keep connection logs in snitch.db
  "DB sql log": true, # Write connection logs to snitch.db (SQLite)
  "DB sql server": {}, # Write connection logs to a MariaDB, MySQL, or PostgreSQL server
  "DB text log": false, # Write connection logs to conn.log
  "DB write limit (seconds)": 10, # Minimum time between writing connection logs
  # increasing it decreases disk writes by grouping connections into larger time windows
  # reducing time precision, decreasing database size, and increasing hash latency
  "Desktop notifications": true, # Try connecting to dbus to show notifications
  "Every exe (not just conns)": false, # Check every running executable with picosnitch
  # these are treated as "connections" with a port of -1
  # this feature is experimental but should work fairly well, errors should be expected as
  # picosnitch is unable to open file descriptors for some extremely short-lived processes
  # if you just want logs (no hashes) to trace process hierarchy, see execsnoop or forkstat
  "Log addresses": true, # Log remote addresses for each connection
  "Log commands": true, # Log command line args for each executable
  "Log ignore": [], # List of hashes (str), domains (str), IP subnets (str), or ports (int)
  # will omit connections that match any of these from the connection log
  # domains are in reverse domain name notation and will match all subdomains
  # the process name, executable, and hash will still be recorded in record.json
  "Perf ring buffer (pages)": 64, # Power of two number of pages for BPF program
  # only change this if it is giving you errors
  "Set RLIMIT_NOFILE": null, # Set the maximum number of open file descriptors (int)
  # it is used for caching process executables and hashes (typical system default is 1024)
  # this is good enough for most people since caching is based on executable device + inode
  # fanotify is used to detect if a cached executable is modified to trigger a hash update
  "VT API key": "", # API key for VirusTotal, leave blank to disable (str)
  "VT file upload": false, # Upload file if hash not found, only hashes are used by default
  "VT request limit (seconds)": 15 # Number of seconds between requests (free tier quota)
}

logging

  • a log of seen executables is stored in ~/.config/picosnitch/exe.log
    • this is a history of your notifications
  • a record of seen executables is stored in ~/.config/picosnitch/record.json
    • this is used for determining whether to create a notification
    • it contains known process name(s) by executable, executable(s) by process name, and sha256 hash(es) with VirusTotal results by executable
  • enable DB sql log (default) to write the full connection log to ~/.config/picosnitch/snitch.db
    • this is used for picosnitch dash, picosnitch view, or something like DB Browser
    • note, connection times are based on when the group is processed, so they are accurate to within DB write limit (seconds) at best, and could be delayed if the previous group is slow to hash
    • notifications are handled by a separate subprocess, so they are not subject to the same delays as the connection log
  • use DB sql server to write the full connection log to a MariaDB, MySQL, or PostgreSQL server
    • this is independent of DB sql log and is used for providing an off-system copy to prevent tampering (use GRANT to assign privileges and see limitations for other caveats)
    • to configure, add the key client to DB sql server with value mariadb, psycopg, psycopg2, or pymysql, you can also optionally set table_name
    • assign remaining connection parameters for mariadb, psycopg, or pymysql to DB sql server as key/value pairs
  • enable DB text log to write the full connection log to ~/.config/picosnitch/conn.log
    • this may be useful for watching with another program
    • it contains the following fields, separated by commas (commas, newlines, and null characters are removed from values)
    • executable,name,cmdline,sha256,time,domain,ip,port,uid,parent_exe,parent_name,parent_cmdline,parent_sha256,conns,sent,received
  • the error log is stored in ~/.config/picosnitch/error.log
    • errors will also trigger a notification and are usually caused by far too many or extremely short-lived processes/connections, or suspending your system while a new executable is being hashed
    • while it is very unlikely for processes/connections to be missed (unless Every exe (not just conns) is enabled), picosnitch was designed such that it should still detect this and log an error giving you some indication of what happened
    • for most people in most cases, this should raise suspicion that a program may be misbehaving
    • a program should not be able to hide from picosnitch (either by omission or spoofing another program) without picosnitch reporting an error
    • see limitations below for other sources of errors

limitations

  • while picosnitch aims to be as reliable as possible, no tool is perfect and you should know the limitations when deciding whether it is useful and how to use it effectively, whether it's for your threat model or simply measuring bandwidth
    • for example, picosnitch was designed to be more accurate than existing tools by hashing executables and tracking parents, but there are still ways malicious software could hide its traffic through trusted executables as described below, such as compromising shared libraries
    • for stricter security requirements you can keep an off-system copy of your logs to protect them
      • this is not necessary for most people, and of little benefit without considering what else an adversary with these capabilities could do to your system in order to establish appropriate safeguards for your threat model, such as cross-checking with a standalone router/firewall to ensure all communication is accounted for, monitoring error logs, etc
  • detecting open sockets, monitoring traffic, and identifying the process should be fairly reliable with BPF; however, accurately identifying the application behind it can be difficult, especially if has malicious intent
    • the process name is trivial to change, the path can be set to anything with mount namespaces, including impersonating an already existing executable (or replacing it)
    • hashing the executable helps with this; however, it is an imperfect solution since only the process executable itself is hashed and there are still ways a program can hide
    • if a process is too short lived, picosnitch may not be able to open a file descriptor in time in order to hash it (should be very rare)
    • the device and inode of the opened file descriptor is checked against what was reported by the BPF program to detect if the executable was replaced; however, BTRFS uses non-unique inodes, negating this protection (this is negligible and only mentioned in an attempt for thoroughness)
    • if for any reason the executable fails to hash, the traffic will still be logged with whatever information was available and you will be notified of an error
  • too many processes or connections could cause the connection data to be lost if callbacks are not processed fast enough, this will be detected, logging the error and triggering a notification
  • instead of playing cat and mouse by trying to cover any edge cases malware may use to hide, the focus is on accurately handling the common case, with clear and reliable error reporting for anything else
  • in addition to bugs, please report any other caveats I may have missed!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].