Project Sentry is a Windows-focused behavioral monitoring and anomaly detection system for local system telemetry, user activity tracking, and remote bot-based control. It combines:
- Keystroke and mouse behavior analysis
- Network usage anomaly detection
- Drive health monitoring
- Activity logging and event capture
- Telegram alerts and remote operational commands
- A local dashboard for overview and controls
This repository is intended for research, monitoring, and controlled security or operations use on Windows machines where you have permission to run and inspect such activity logging.
- Behavioral anomaly detection using CSV training data and model files
- Monitoring for keystroke, mouse, network, and drive health patterns
- Local web dashboard for status overview and controls
- Telegram notifications for alerts and system events
- Remote command execution through a Telegram bot
- Session log capture for system and remote actions
- Report generation for detected anomalies and diagnostics
Project-Sentry/
├── activity_logger.py
├── command_engine.py
├── dashboard.html
├── generate_report.py
├── main.pyw
├── telegram_alert.py
├── settings.json
├── requirements.txt
├── reports/
├── sentry logs/
├── user logs/
├── assets/
├── detection engine/
│ ├── drive health monitor/
│ ├── keystroke dynamics/
│ ├── mouse dynamics/
│ └── network usage/
├── tests/
├── README.md
├── LICENSE.txt
└── .env
- Windows 10 or Windows 11
- Python 3.10+
- A Telegram bot token and authorized chat ID
- Access to the machine where the monitoring app will run
This project is based on behavioral biometrics. The data it learns from is unique to each person and each machine. A user’s keystroke rhythm, mouse motion patterns, network behavior, and drive activity are not universal features—they vary by hardware, habits, posture, environment, and usage patterns.
Because of that, the anomaly detectors must be trained on the target person’s normal behavior before they can reliably detect deviations. The CSV files in the detection engine folders are baseline datasets used to build the model for that specific user profile. If the model is trained on someone else’s behavior, it may produce false positives or miss real anomalies.
The project uses the training files such as:
keystroke_dynamics_training.csvmouse_dynamics_training.csvnetwork_usage_training.csvdrive_health_training.csv
These files represent normal, accepted behavior for that user. The app then learns a baseline pattern from them and later compares new activity against that baseline. An anomaly is triggered when the new behavior drifts too far from the trained baseline.
- The model should be trained on the actual person and machine you plan to monitor.
- The training data must be collected during normal, non-abnormal activity.
- If the user’s behavior changes significantly over time, retraining may be needed.
- The detectors are best used as a personalized baseline system, not a universal one-size-fits-all detector.
git clone https://github.com/ashfaaqrifath/Project-Sentry.git
cd Project-Sentrypython -m venv .venv
.\.venv\Scripts\Activate.ps1python -m pip install --upgrade pip
python -m pip install -r requirements.txtpip install pyautogui pyperclip psutil python-dotenv plyer winshell pyttsx3 screen-brightness-control pygame pyTelegramBotAPI requests pygetwindow pynput numpy pandas scikit-learn joblib matplotlib pytestCreate a .env file in the project root:
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
SENTRY_DASHBOARD_TOKEN=your_dashboard_token_here-
Dashboard token
- When the dashboard starts, it generates a token automatically if
SENTRY_DASHBOARD_TOKENis missing. - You can also set a custom value manually in
.env. - Example:
SENTRY_DASHBOARD_TOKEN=my_secure_dashboard_token
- Use the same value in the dashboard requests if needed by your deployment.
- When the dashboard starts, it generates a token automatically if
-
Telegram bot token
- Open Telegram and search for
@BotFather. - Send
/newbot. - Follow the prompts to name your bot and choose a username.
- Copy the HTTP API token that BotFather gives you.
- Paste that value into
TELEGRAM_BOT_TOKEN.
- Open Telegram and search for
-
Telegram chat ID
- Start a chat with your bot in Telegram.
- Send a message like
/startto the bot. - Open this URL in your browser, replacing
YOUR_BOT_TOKENwith the token you just created:
https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates- Find the
"chat":{"id":1234567890...}entry in the JSON output. - Use that numeric value for
TELEGRAM_CHAT_ID. - If more than one user should be allowed, separate IDs with commas:
TELEGRAM_CHAT_ID=1234567890,987654321
TELEGRAM_BOT_TOKEN=123456:ABCDEF
TELEGRAM_CHAT_ID=1234567890
SENTRY_DASHBOARD_TOKEN=secure_dashboard_token_hereKeep
.envprivate and never commit it to GitHub.
The dashboard stores a password in settings.json on first launch. If needed, set DASHBOARD_PASSWORD before starting the app or enter the password when prompted.
settings.json contains options such as:
{
"components": {},
"telegram_alerts_enabled": true,
"telegram_commands_allow_all": true,
"behavior_alerts": {
"window_seconds": 45,
"combined_threshold": 0.12
}
}From the project root:
python .\main.pywThis starts the main local dashboard and monitoring components.
python .\command_engine.pyThis starts the bot handler that listens for approved Telegram commands and performs local actions.
The bot accepts commands from authorized chat IDs only. The user may be asked to verify the dashboard password before a command runs.
| Command | Description |
|---|---|
/stop |
Requests Sentry shutdown through the dashboard |
/log |
Sends the latest generated log file |
/report or /generate report |
Sends a generated PDF system report |
/enable all |
Starts all monitored components |
/disable all |
Stops all monitored components |
/enable <component> |
Starts a component: keystroke, mouse, network, drive, activity, remote, telegram |
/disable <component> |
Stops a component |
/delete detections |
Removes anomaly detections |
/delete logs or /delete log files |
Deletes generated log files |
/clearlogs |
Keeps only the newest log file |
/open <app> |
Opens an application such as notepad, calculator, chrome, or vscode |
/close <app> |
Closes a running app |
/alert |
Prompts for a Windows notification message |
/popup |
Displays a Windows pop-up message |
/speak |
Speaks a custom message via the system TTS engine |
/mute |
Stops system audio |
volup <number> |
Increases system volume |
voldown <number> |
Decreases system volume |
brightness <number> |
Sets screen brightness |
/getfocus |
Returns the currently focused window |
/getallwin |
Lists open windows |
/closefocus |
Closes the active window |
/closeall |
Closes all visible windows |
/signout |
Signs the current user out |
/lock |
Locks the workstation |
/hibernate |
Hibernates the machine |
/shutdown |
Schedules a Windows shutdown |
/bin |
Empties the Recycle Bin |
search <query> |
Opens a Google search for the query |
- Only authorized Telegram chat IDs can send commands.
- Dashboard password verification may be required before execution.
- The app may request local approval when
telegram_commands_allow_allis disabled. - Commands can trigger local actions like opening apps, closing windows, locking the machine, and generating reports.
Before pushing to GitHub, make sure the following are ignored:
.env
.venv/
__pycache__/
*.pyc
reports/
user logs/
sentry logs/
*.pklThis project monitors user activity and system behavior, stores logs locally, and can perform remote control actions on a Windows machine. Use it only in environments where such monitoring is permitted, authorized, and compliant with local privacy and security requirements.