Skip to main content

🛡️ NetSentry

CI PyPI License: MIT Python 3.10+ Linux Daemon

NetSentry is a lightweight, real-time Linux network bodyguard and threat sentinel. Running silently in the background or interactively via an htop-style terminal dashboard (TUI), NetSentry correlates network sockets with Linux processes, flags suspicious outbound connections (reverse shells, untrusted /tmp binaries, known malicious botnets/C2 nodes), and dispatches desktop notifications or executes firewall countermeasures.


✨ Features

  • 🕵️ Process-Network Correlation: Maps every active socket to its PID, executable path, process name, and user.
  • 🚨 Real-Time Threat Detection:
    • Reverse Shell Detection: Detects shells (bash, zsh, sh) or net tools (nc, socat) opening remote sockets.
    • Untrusted Path Execution: Flags binaries running from temporary directories like /tmp/, /dev/shm/, or /var/tmp/.
    • Suspicious Port Alerts: Identifies connections on backdoor ports (4444, 1337, 31337, 6667, etc.).
    • Threat Intelligence: Built-in and downloadable IP reputation feeds (Tor exits, botnet C2s, scanner IPs).
  • 🖥️ Live Terminal Dashboard (TUI): Beautiful htop-style live monitoring dashboard built with Rich.
  • 🔔 Linux Desktop Notifications: Native notify-send desktop popups with rate-limiting and urgency levels.
  • 🧱 Firewall Integration: One-click or automated IP dropping via iptables / nftables with loopback protection.
  • ⚙️ Systemd Integration: Single-command user service setup (netsentry install-service).

🏗️ Architecture

                      ┌────────────────────────┐
                      │ Linux Kernel / Sockets │
                      └───────────┬────────────┘
                                  │
                                  ▼
               ┌─────────────────────────────────────┐
               │    Network Monitor (psutil/proc)    │
               │  Maps sockets to PID & Binary Path  │
               └──────────────────┬──────────────────┘
                                  │
                                  ▼
               ┌─────────────────────────────────────┐
               │         Threat Detector             │
               ├──────────────────┬──────────────────┤
               │ • Threat Intel   │ • Port Blacklist │
               │ • Shell Sockets  │ • Untrusted Path │
               └──────────────────┬──────────────────┘
                                  │
                  ┌───────────────┼───────────────┐
                  ▼               ▼               ▼
           ┌────────────┐  ┌─────────────┐  ┌────────────┐
           │ Desktop UI │  │  SQLite DB  │  │  Firewall  │
           │ (notify)   │  │  (sentry.db)│  │ (iptables) │
           └────────────┘  └─────────────┘  └────────────┘

🚀 Quick Start

1. Installation

pipx install net-sentry

Via pip

pip install net-sentry

From source (for development)

git clone https://github.com/Lukasz-Szymanski/net-sentry.git
cd net-sentry

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

2. Launch Interactive TUI Dashboard

netsentry tui

3. Start Background Monitoring Daemon

# Start background daemon
netsentry start

# Check running status
netsentry status

4. Install GNOME Top Panel Indicator (Optional)

To show the live shield status on the Linux top panel:

netsentry install-extension

Log out and log back in (Wayland) or press Alt + F2 -> r (X11) to activate the shield in your top bar.


📖 CLI Commands

Command Description
netsentry tui Open the interactive real-time terminal dashboard
netsentry start Start the background monitoring daemon
netsentry start -f Run the monitoring daemon in foreground
netsentry stop Stop the running daemon
netsentry status Display daemon status, total alerts, and active connections
netsentry status --json Output system metrics and alerts in JSON format
netsentry scan Run an instant socket scan and print security analysis table
netsentry alerts Display recent security events recorded in SQLite
netsentry block <IP> Add IP to blacklist and apply firewall DROP rule
netsentry unblock <IP> Remove firewall DROP rule for IP
netsentry update-intel Download updated threat intelligence feeds
netsentry install-service Install and enable the background systemd user service
netsentry uninstall-service Stop and remove the systemd user service
netsentry install-extension Install and enable the GNOME Shell top panel extension
netsentry uninstall-extension Remove the GNOME Shell extension

⚙️ Configuration

Configuration is automatically generated on first run at: ~/.config/netsentry/config.json

{
  "scan_interval_seconds": 2.0,
  "desktop_notifications": true,
  "notification_cooldown_seconds": 30,
  "auto_block_threats": false,
  "threat_score_threshold": 60,
  "suspicious_ports": [23, 2323, 4444, 5555, 6667, 9001, 9050, 9051, 1337, 31337],
  "whitelist_ips": ["127.0.0.1", "::1", "0.0.0.0"],
  "whitelist_processes": ["systemd-resolved", "chronyd", "ntpd", "NetworkManager"]
}

🐧 Systemd Service (Autostart)

To enable NetSentry as a systemd user service with a single command:

netsentry install-service

To stop and remove the service:

netsentry uninstall-service

🧪 Testing

pytest -v

📜 License

Released under the MIT License.

Metadata

Release files for net-sentry 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for net-sentry 0.1.0
File Size Uploaded
net_sentry-0.1.0.tar.gz 25.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for net-sentry 0.1.0
File Interpreter ABI Platform
net_sentry-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 53.7 kB

Release files / net_sentry-0.1.0.tar.gz

Download URL net_sentry-0.1.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cef056213b3ca29ded0634a7912996749a8a3d0fae79a921cf41fbe6b3895cff
BLAKE2b-256 checksum
How to use checksums
2640e063d5022b10e030f7418b9f9dacb0064093e9474709e48c72fc572bb5f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / net_sentry-0.1.0-py3-none-any.whl

Download URL net_sentry-0.1.0-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ea3e900beda5935830811e88560a8f7a25d0412cde51d30fa2963398e06d503
BLAKE2b-256 checksum
How to use checksums
3583322fd44b37fcb608dd87a65580484161649b49891ebe55453b035691179e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page