net-sentry 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. net_sentry-0.1.0/LICENSE +21 -0
  2. net_sentry-0.1.0/PKG-INFO +215 -0
  3. net_sentry-0.1.0/README.md +179 -0
  4. net_sentry-0.1.0/pyproject.toml +61 -0
  5. net_sentry-0.1.0/setup.cfg +4 -0
  6. net_sentry-0.1.0/src/net_sentry.egg-info/PKG-INFO +215 -0
  7. net_sentry-0.1.0/src/net_sentry.egg-info/SOURCES.txt +32 -0
  8. net_sentry-0.1.0/src/net_sentry.egg-info/dependency_links.txt +1 -0
  9. net_sentry-0.1.0/src/net_sentry.egg-info/entry_points.txt +2 -0
  10. net_sentry-0.1.0/src/net_sentry.egg-info/requires.txt +8 -0
  11. net_sentry-0.1.0/src/net_sentry.egg-info/top_level.txt +1 -0
  12. net_sentry-0.1.0/src/netsentry/__init__.py +4 -0
  13. net_sentry-0.1.0/src/netsentry/cli.py +529 -0
  14. net_sentry-0.1.0/src/netsentry/config.py +105 -0
  15. net_sentry-0.1.0/src/netsentry/core/__init__.py +1 -0
  16. net_sentry-0.1.0/src/netsentry/core/database.py +179 -0
  17. net_sentry-0.1.0/src/netsentry/core/detector.py +131 -0
  18. net_sentry-0.1.0/src/netsentry/core/firewall.py +88 -0
  19. net_sentry-0.1.0/src/netsentry/core/monitor.py +117 -0
  20. net_sentry-0.1.0/src/netsentry/core/notifier.py +72 -0
  21. net_sentry-0.1.0/src/netsentry/core/threat_intel.py +125 -0
  22. net_sentry-0.1.0/src/netsentry/daemon.py +152 -0
  23. net_sentry-0.1.0/src/netsentry/data/extension/extension.js +236 -0
  24. net_sentry-0.1.0/src/netsentry/data/extension/metadata.json +15 -0
  25. net_sentry-0.1.0/src/netsentry/data/extension/stylesheet.css +34 -0
  26. net_sentry-0.1.0/src/netsentry/data/systemd/netsentry.service +20 -0
  27. net_sentry-0.1.0/src/netsentry/tui/__init__.py +1 -0
  28. net_sentry-0.1.0/src/netsentry/tui/dashboard.py +164 -0
  29. net_sentry-0.1.0/tests/test_cli.py +21 -0
  30. net_sentry-0.1.0/tests/test_config.py +16 -0
  31. net_sentry-0.1.0/tests/test_database.py +48 -0
  32. net_sentry-0.1.0/tests/test_detector.py +79 -0
  33. net_sentry-0.1.0/tests/test_firewall.py +13 -0
  34. net_sentry-0.1.0/tests/test_threat_intel.py +25 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lukasz Szymanski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: net-sentry
3
+ Version: 0.1.0
4
+ Summary: A lightweight Linux network sentinel and threat monitoring daemon
5
+ Author: Lukasz Szymanski
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Lukasz-Szymanski/net-sentry
8
+ Project-URL: Documentation, https://github.com/Lukasz-Szymanski/net-sentry#readme
9
+ Project-URL: Repository, https://github.com/Lukasz-Szymanski/net-sentry.git
10
+ Project-URL: Issues, https://github.com/Lukasz-Szymanski/net-sentry/issues
11
+ Keywords: linux,security,network-monitor,threat-detection,firewall,ids
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Security
24
+ Classifier: Topic :: System :: Networking :: Monitoring
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: psutil>=5.9.0
29
+ Requires-Dist: rich>=13.0.0
30
+ Requires-Dist: requests>=2.28.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
33
+ Requires-Dist: build>=1.0.0; extra == "dev"
34
+ Requires-Dist: twine>=5.0.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # ๐Ÿ›ก๏ธ NetSentry
38
+
39
+ [![CI](https://github.com/Lukasz-Szymanski/net-sentry/actions/workflows/ci.yml/badge.svg)](https://github.com/Lukasz-Szymanski/net-sentry/actions/workflows/ci.yml)
40
+ [![PyPI](https://img.shields.io/pypi/v/net-sentry.svg)](https://pypi.org/project/net-sentry/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
42
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
43
+ [![Linux Daemon](https://img.shields.io/badge/platform-Linux-orange.svg)](https://kernel.org)
44
+
45
+ **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.
46
+
47
+ ---
48
+
49
+ ## โœจ Features
50
+
51
+ - ๐Ÿ•ต๏ธ **Process-Network Correlation**: Maps every active socket to its PID, executable path, process name, and user.
52
+ - ๐Ÿšจ **Real-Time Threat Detection**:
53
+ - **Reverse Shell Detection**: Detects shells (`bash`, `zsh`, `sh`) or net tools (`nc`, `socat`) opening remote sockets.
54
+ - **Untrusted Path Execution**: Flags binaries running from temporary directories like `/tmp/`, `/dev/shm/`, or `/var/tmp/`.
55
+ - **Suspicious Port Alerts**: Identifies connections on backdoor ports (4444, 1337, 31337, 6667, etc.).
56
+ - **Threat Intelligence**: Built-in and downloadable IP reputation feeds (Tor exits, botnet C2s, scanner IPs).
57
+ - ๐Ÿ–ฅ๏ธ **Live Terminal Dashboard (TUI)**: Beautiful `htop`-style live monitoring dashboard built with Rich.
58
+ - ๐Ÿ”” **Linux Desktop Notifications**: Native `notify-send` desktop popups with rate-limiting and urgency levels.
59
+ - ๐Ÿงฑ **Firewall Integration**: One-click or automated IP dropping via `iptables` / `nftables` with loopback protection.
60
+ - โš™๏ธ **Systemd Integration**: Single-command user service setup (`netsentry install-service`).
61
+
62
+ ---
63
+
64
+ ## ๐Ÿ—๏ธ Architecture
65
+
66
+ ```
67
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
68
+ โ”‚ Linux Kernel / Sockets โ”‚
69
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
70
+ โ”‚
71
+ โ–ผ
72
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
73
+ โ”‚ Network Monitor (psutil/proc) โ”‚
74
+ โ”‚ Maps sockets to PID & Binary Path โ”‚
75
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
76
+ โ”‚
77
+ โ–ผ
78
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
79
+ โ”‚ Threat Detector โ”‚
80
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
81
+ โ”‚ โ€ข Threat Intel โ”‚ โ€ข Port Blacklist โ”‚
82
+ โ”‚ โ€ข Shell Sockets โ”‚ โ€ข Untrusted Path โ”‚
83
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
84
+ โ”‚
85
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
86
+ โ–ผ โ–ผ โ–ผ
87
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
88
+ โ”‚ Desktop UI โ”‚ โ”‚ SQLite DB โ”‚ โ”‚ Firewall โ”‚
89
+ โ”‚ (notify) โ”‚ โ”‚ (sentry.db)โ”‚ โ”‚ (iptables) โ”‚
90
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
91
+ ```
92
+
93
+ ---
94
+
95
+ ## ๐Ÿš€ Quick Start
96
+
97
+ ### 1. Installation
98
+
99
+ #### Via `pipx` (Recommended on Linux)
100
+ ```bash
101
+ pipx install net-sentry
102
+ ```
103
+
104
+ #### Via `pip`
105
+ ```bash
106
+ pip install net-sentry
107
+ ```
108
+
109
+ #### From source (for development)
110
+ ```bash
111
+ git clone https://github.com/Lukasz-Szymanski/net-sentry.git
112
+ cd net-sentry
113
+
114
+ python3 -m venv .venv
115
+ source .venv/bin/activate
116
+ pip install -e ".[dev]"
117
+ ```
118
+
119
+ ### 2. Launch Interactive TUI Dashboard
120
+
121
+ ```bash
122
+ netsentry tui
123
+ ```
124
+
125
+ ### 3. Start Background Monitoring Daemon
126
+
127
+ ```bash
128
+ # Start background daemon
129
+ netsentry start
130
+
131
+ # Check running status
132
+ netsentry status
133
+ ```
134
+
135
+ ### 4. Install GNOME Top Panel Indicator (Optional)
136
+
137
+ To show the live shield status on the Linux top panel:
138
+
139
+ ```bash
140
+ netsentry install-extension
141
+ ```
142
+
143
+ Log out and log back in (Wayland) or press `Alt + F2` -> `r` (X11) to activate the shield in your top bar.
144
+
145
+ ---
146
+
147
+ ## ๐Ÿ“– CLI Commands
148
+
149
+ | Command | Description |
150
+ | :--- | :--- |
151
+ | `netsentry tui` | Open the interactive real-time terminal dashboard |
152
+ | `netsentry start` | Start the background monitoring daemon |
153
+ | `netsentry start -f` | Run the monitoring daemon in foreground |
154
+ | `netsentry stop` | Stop the running daemon |
155
+ | `netsentry status` | Display daemon status, total alerts, and active connections |
156
+ | `netsentry status --json` | Output system metrics and alerts in JSON format |
157
+ | `netsentry scan` | Run an instant socket scan and print security analysis table |
158
+ | `netsentry alerts` | Display recent security events recorded in SQLite |
159
+ | `netsentry block <IP>` | Add IP to blacklist and apply firewall DROP rule |
160
+ | `netsentry unblock <IP>` | Remove firewall DROP rule for IP |
161
+ | `netsentry update-intel` | Download updated threat intelligence feeds |
162
+ | `netsentry install-service` | Install and enable the background systemd user service |
163
+ | `netsentry uninstall-service` | Stop and remove the systemd user service |
164
+ | `netsentry install-extension` | Install and enable the GNOME Shell top panel extension |
165
+ | `netsentry uninstall-extension` | Remove the GNOME Shell extension |
166
+
167
+ ---
168
+
169
+ ## โš™๏ธ Configuration
170
+
171
+ Configuration is automatically generated on first run at:
172
+ `~/.config/netsentry/config.json`
173
+
174
+ ```json
175
+ {
176
+ "scan_interval_seconds": 2.0,
177
+ "desktop_notifications": true,
178
+ "notification_cooldown_seconds": 30,
179
+ "auto_block_threats": false,
180
+ "threat_score_threshold": 60,
181
+ "suspicious_ports": [23, 2323, 4444, 5555, 6667, 9001, 9050, 9051, 1337, 31337],
182
+ "whitelist_ips": ["127.0.0.1", "::1", "0.0.0.0"],
183
+ "whitelist_processes": ["systemd-resolved", "chronyd", "ntpd", "NetworkManager"]
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## ๐Ÿง Systemd Service (Autostart)
190
+
191
+ To enable NetSentry as a systemd user service with a single command:
192
+
193
+ ```bash
194
+ netsentry install-service
195
+ ```
196
+
197
+ To stop and remove the service:
198
+
199
+ ```bash
200
+ netsentry uninstall-service
201
+ ```
202
+
203
+ ---
204
+
205
+ ## ๐Ÿงช Testing
206
+
207
+ ```bash
208
+ pytest -v
209
+ ```
210
+
211
+ ---
212
+
213
+ ## ๐Ÿ“œ License
214
+
215
+ Released under the [MIT License](LICENSE).
@@ -0,0 +1,179 @@
1
+ # ๐Ÿ›ก๏ธ NetSentry
2
+
3
+ [![CI](https://github.com/Lukasz-Szymanski/net-sentry/actions/workflows/ci.yml/badge.svg)](https://github.com/Lukasz-Szymanski/net-sentry/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/net-sentry.svg)](https://pypi.org/project/net-sentry/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
7
+ [![Linux Daemon](https://img.shields.io/badge/platform-Linux-orange.svg)](https://kernel.org)
8
+
9
+ **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.
10
+
11
+ ---
12
+
13
+ ## โœจ Features
14
+
15
+ - ๐Ÿ•ต๏ธ **Process-Network Correlation**: Maps every active socket to its PID, executable path, process name, and user.
16
+ - ๐Ÿšจ **Real-Time Threat Detection**:
17
+ - **Reverse Shell Detection**: Detects shells (`bash`, `zsh`, `sh`) or net tools (`nc`, `socat`) opening remote sockets.
18
+ - **Untrusted Path Execution**: Flags binaries running from temporary directories like `/tmp/`, `/dev/shm/`, or `/var/tmp/`.
19
+ - **Suspicious Port Alerts**: Identifies connections on backdoor ports (4444, 1337, 31337, 6667, etc.).
20
+ - **Threat Intelligence**: Built-in and downloadable IP reputation feeds (Tor exits, botnet C2s, scanner IPs).
21
+ - ๐Ÿ–ฅ๏ธ **Live Terminal Dashboard (TUI)**: Beautiful `htop`-style live monitoring dashboard built with Rich.
22
+ - ๐Ÿ”” **Linux Desktop Notifications**: Native `notify-send` desktop popups with rate-limiting and urgency levels.
23
+ - ๐Ÿงฑ **Firewall Integration**: One-click or automated IP dropping via `iptables` / `nftables` with loopback protection.
24
+ - โš™๏ธ **Systemd Integration**: Single-command user service setup (`netsentry install-service`).
25
+
26
+ ---
27
+
28
+ ## ๐Ÿ—๏ธ Architecture
29
+
30
+ ```
31
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
32
+ โ”‚ Linux Kernel / Sockets โ”‚
33
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
34
+ โ”‚
35
+ โ–ผ
36
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
37
+ โ”‚ Network Monitor (psutil/proc) โ”‚
38
+ โ”‚ Maps sockets to PID & Binary Path โ”‚
39
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
40
+ โ”‚
41
+ โ–ผ
42
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
43
+ โ”‚ Threat Detector โ”‚
44
+ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
45
+ โ”‚ โ€ข Threat Intel โ”‚ โ€ข Port Blacklist โ”‚
46
+ โ”‚ โ€ข Shell Sockets โ”‚ โ€ข Untrusted Path โ”‚
47
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
48
+ โ”‚
49
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
50
+ โ–ผ โ–ผ โ–ผ
51
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
52
+ โ”‚ Desktop UI โ”‚ โ”‚ SQLite DB โ”‚ โ”‚ Firewall โ”‚
53
+ โ”‚ (notify) โ”‚ โ”‚ (sentry.db)โ”‚ โ”‚ (iptables) โ”‚
54
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
55
+ ```
56
+
57
+ ---
58
+
59
+ ## ๐Ÿš€ Quick Start
60
+
61
+ ### 1. Installation
62
+
63
+ #### Via `pipx` (Recommended on Linux)
64
+ ```bash
65
+ pipx install net-sentry
66
+ ```
67
+
68
+ #### Via `pip`
69
+ ```bash
70
+ pip install net-sentry
71
+ ```
72
+
73
+ #### From source (for development)
74
+ ```bash
75
+ git clone https://github.com/Lukasz-Szymanski/net-sentry.git
76
+ cd net-sentry
77
+
78
+ python3 -m venv .venv
79
+ source .venv/bin/activate
80
+ pip install -e ".[dev]"
81
+ ```
82
+
83
+ ### 2. Launch Interactive TUI Dashboard
84
+
85
+ ```bash
86
+ netsentry tui
87
+ ```
88
+
89
+ ### 3. Start Background Monitoring Daemon
90
+
91
+ ```bash
92
+ # Start background daemon
93
+ netsentry start
94
+
95
+ # Check running status
96
+ netsentry status
97
+ ```
98
+
99
+ ### 4. Install GNOME Top Panel Indicator (Optional)
100
+
101
+ To show the live shield status on the Linux top panel:
102
+
103
+ ```bash
104
+ netsentry install-extension
105
+ ```
106
+
107
+ Log out and log back in (Wayland) or press `Alt + F2` -> `r` (X11) to activate the shield in your top bar.
108
+
109
+ ---
110
+
111
+ ## ๐Ÿ“– CLI Commands
112
+
113
+ | Command | Description |
114
+ | :--- | :--- |
115
+ | `netsentry tui` | Open the interactive real-time terminal dashboard |
116
+ | `netsentry start` | Start the background monitoring daemon |
117
+ | `netsentry start -f` | Run the monitoring daemon in foreground |
118
+ | `netsentry stop` | Stop the running daemon |
119
+ | `netsentry status` | Display daemon status, total alerts, and active connections |
120
+ | `netsentry status --json` | Output system metrics and alerts in JSON format |
121
+ | `netsentry scan` | Run an instant socket scan and print security analysis table |
122
+ | `netsentry alerts` | Display recent security events recorded in SQLite |
123
+ | `netsentry block <IP>` | Add IP to blacklist and apply firewall DROP rule |
124
+ | `netsentry unblock <IP>` | Remove firewall DROP rule for IP |
125
+ | `netsentry update-intel` | Download updated threat intelligence feeds |
126
+ | `netsentry install-service` | Install and enable the background systemd user service |
127
+ | `netsentry uninstall-service` | Stop and remove the systemd user service |
128
+ | `netsentry install-extension` | Install and enable the GNOME Shell top panel extension |
129
+ | `netsentry uninstall-extension` | Remove the GNOME Shell extension |
130
+
131
+ ---
132
+
133
+ ## โš™๏ธ Configuration
134
+
135
+ Configuration is automatically generated on first run at:
136
+ `~/.config/netsentry/config.json`
137
+
138
+ ```json
139
+ {
140
+ "scan_interval_seconds": 2.0,
141
+ "desktop_notifications": true,
142
+ "notification_cooldown_seconds": 30,
143
+ "auto_block_threats": false,
144
+ "threat_score_threshold": 60,
145
+ "suspicious_ports": [23, 2323, 4444, 5555, 6667, 9001, 9050, 9051, 1337, 31337],
146
+ "whitelist_ips": ["127.0.0.1", "::1", "0.0.0.0"],
147
+ "whitelist_processes": ["systemd-resolved", "chronyd", "ntpd", "NetworkManager"]
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## ๐Ÿง Systemd Service (Autostart)
154
+
155
+ To enable NetSentry as a systemd user service with a single command:
156
+
157
+ ```bash
158
+ netsentry install-service
159
+ ```
160
+
161
+ To stop and remove the service:
162
+
163
+ ```bash
164
+ netsentry uninstall-service
165
+ ```
166
+
167
+ ---
168
+
169
+ ## ๐Ÿงช Testing
170
+
171
+ ```bash
172
+ pytest -v
173
+ ```
174
+
175
+ ---
176
+
177
+ ## ๐Ÿ“œ License
178
+
179
+ Released under the [MIT License](LICENSE).
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "net-sentry"
7
+ version = "0.1.0"
8
+ description = "A lightweight Linux network sentinel and threat monitoring daemon"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Lukasz Szymanski" }
14
+ ]
15
+ keywords = ["linux", "security", "network-monitor", "threat-detection", "firewall", "ids"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: System Administrators",
20
+ "Intended Audience :: Developers",
21
+ "Operating System :: POSIX :: Linux",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Topic :: Security",
29
+ "Topic :: System :: Networking :: Monitoring",
30
+ ]
31
+ dependencies = [
32
+ "psutil>=5.9.0",
33
+ "rich>=13.0.0",
34
+ "requests>=2.28.0",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=8.0.0",
40
+ "build>=1.0.0",
41
+ "twine>=5.0.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/Lukasz-Szymanski/net-sentry"
46
+ Documentation = "https://github.com/Lukasz-Szymanski/net-sentry#readme"
47
+ Repository = "https://github.com/Lukasz-Szymanski/net-sentry.git"
48
+ Issues = "https://github.com/Lukasz-Szymanski/net-sentry/issues"
49
+
50
+ [project.scripts]
51
+ netsentry = "netsentry.cli:main"
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["src"]
55
+
56
+ [tool.setuptools.package-data]
57
+ netsentry = ["data/**/*"]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ python_files = ["test_*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+