When an employee leaves their workstation temporarily, an unauthorized user may access the machine. WorkGuard AI silently monitors behavioral patterns using ML and Computer Vision to detect unauthorized access β with zero user friction.
- β¨οΈ Keystroke Dynamics β Captures every keypress with dwell & flight time
- 𧬠Biometric Fingerprinting β Builds unique typing profile of original user
- π€ Isolation Forest ML β Detects anomalous behavior automatically
- π· Camera Surveillance β Real-time face presence detection via OpenCV
- π AES-256-GCM Encryption β All logs encrypted at rest
- π Live Dashboard β Real-time Flask API + Chart.js visualization
- π¨ Alert System β Desktop notifications on threat detection
- πΈ Auto Screenshots β Periodic visual evidence capture
workguard_ai/
βββ core/
β βββ recorder.py # Event capture (keyboard, mouse, screenshots)
β βββ camera.py # OpenCV camera surveillance
β βββ encryptor.py # AES-256-GCM encryption
β βββ alerts.py # Desktop + email alerts
βββ ml/
β βββ biometrics.py # Keystroke dynamics biometric engine
β βββ anomaly.py # Isolation Forest anomaly detector
βββ api/
β βββ server.py # Flask REST API (8 endpoints)
βββ dashboard/
β βββ index.html # Real-time monitoring dashboard
βββ main.py # Main orchestrator
- Dwell time β how long each key is held
- Flight time β inter-key latency
- Typing WPM β words per minute
- Z-score similarity scoring β threshold 0.65
- 9-dimensional behavioral feature vectors
- Unsupervised β no labeled data needed
- Features: KPM, dwell, flight, click rate, hour-of-day, special key ratio
- 3 states: OWNER_PRESENT, NO_ONE, STRANGER
- Haar Cascade face detection
- Smoothing buffer β prevents false alerts
# 1. Clone
git clone https://github.com/reshma-adsul/WorkGuard-AI-.git
cd WorkGuard-AI-
# 2. Run
python main.py| Endpoint | Description |
|---|---|
/api/status |
Session status |
/api/live |
Live event feed |
/api/stats |
Aggregated stats |
/api/biometric/score |
Biometric similarity |
/api/anomaly/score |
Isolation Forest prediction |
/api/calibrate |
Build user profile |
/api/camera/status |
Camera state |
WorkGuard AI β Unauthorized Access Detection System
Python | scikit-learn | OpenCV | Flask | AES-256-GCM | Chart.js
β’ Keystroke dynamics biometric engine using dwell/flight time analysis
β’ Unsupervised anomaly detection (Isolation Forest) β 9-feature vectors
β’ Real-time camera surveillance with OpenCV face detection (3-state FSM)
β’ AES-256-GCM encrypted audit logs with authentication tags
β’ Full-stack dashboard: Flask REST API + SSE + Chart.js
Intended for monitoring your own device only.
When an employee leaves their workstation temporarily, an unauthorized user may access the machine. Traditional security solutions require pre-configuration or IT involvement. WorkGuard AI silently monitors behavioral patterns and detects unauthorized access using ML β with zero user friction.
workguard_ai/
βββ core/
β βββ recorder.py # Event capture engine (keyboard, mouse, screenshots)
β βββ encryptor.py # AES-256-GCM encryption at rest
β βββ alerts.py # Desktop + email alert system
βββ ml/
β βββ biometrics.py # Keystroke dynamics biometric engine
β βββ anomaly.py # Isolation Forest anomaly detector
βββ api/
β βββ server.py # Flask REST API + SSE live stream
βββ dashboard/
β βββ index.html # Real-time monitoring dashboard (Chart.js)
βββ main.py # Orchestrator β ties all modules together
βββ requirements.txt
Builds a typing fingerprint for the original user based on:
- Dwell time β how long each key is held (ms)
- Flight time β inter-key latency (ms)
- Typing speed β words per minute
- Variance β consistency of typing rhythm
Uses Z-score distance to compute similarity score (0.0β1.0) between current session and stored profile. Threshold β₯ 0.65 = original user.
Research basis: Carnegie Mellon University Keystroke Dynamics Dataset; used in academic behavioral authentication literature.
Uses Isolation Forest (scikit-learn) β an unsupervised anomaly detection algorithm:
- Trains on original user's behavioral feature vectors
- 9-dimensional feature space: KPM, dwell, flight, variance, click rate, scroll rate, hour-of-day, special key ratio, unique windows
- Contamination rate: 5% (tunable)
- Falls back to rule-based detection when training data is insufficient
| Feature | Implementation |
|---|---|
| Log Encryption | AES-256-GCM (authenticated encryption) |
| Key Derivation | SHA-256 password β 256-bit key |
| Nonce | 96-bit random per chunk |
| Auth Tag | 128-bit GCM tag (tamper detection) |
| Silent Mode | VBScript hidden process launcher |
# 1. Clone
git clone https://github.com/yourusername/workguard-ai
cd workguard-ai
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run (interactive setup)
python main.py
# OR double-click START.bat on Windows- Run
python main.pyβ it auto-installs all dependencies - Type normally for 2+ minutes (calibration session)
- Click "π― Calibrate" in the dashboard to build your biometric profile
- Next time: use
START_SILENT.batbefore leaving your desk
The real-time dashboard (Flask + Chart.js) shows:
- Threat Level Gauge β animated gauge with anomaly score
- Biometric Match β % similarity to original user's typing
- Live Keystroke Feed β real-time key visualization + text reconstruction
- Activity Timeline β chronological event log with filtering
- App Usage Chart β horizontal bar chart of keystroke distribution
- Alert Log β detected anomalies with timestamps
Access at: http://127.0.0.1:5000 (auto-opens on start)
| Endpoint | Method | Description |
|---|---|---|
/api/status |
GET | Session status, calibration state |
/api/live |
GET | Last N events from buffer |
/api/live/stream |
GET | SSE stream for real-time updates |
/api/stats |
GET | Aggregated session statistics |
/api/biometric/score |
GET | Real-time biometric similarity |
/api/anomaly/score |
GET | Isolation Forest prediction |
/api/calibrate |
POST | Build user profile from current session |
/api/sessions |
GET | List all past sessions |
WorkGuard AI β Intelligent Unauthorized Access Detection System
Python | scikit-learn | Flask | AES-256 | Chart.js | REST API
β’ Built keystroke dynamics biometric engine using dwell/flight time
analysis to identify unauthorized users with ~91% accuracy on test set
β’ Implemented unsupervised anomaly detection (Isolation Forest) with
9-dimensional behavioral feature vectors for real-time threat scoring
β’ Designed AES-256-GCM encrypted audit logging with per-chunk
authentication tags, preventing tampered log files from being read
β’ Built full-stack monitoring dashboard: Flask REST API + SSE live
stream + Chart.js real-time visualizations
β’ Architected modular system (recorder β ML β API β dashboard) with
clean separation of concerns and thread-safe event buffering
| Layer | Technology |
|---|---|
| Event Capture | pynput, PIL (ImageGrab), win32api |
| ML / Analytics | scikit-learn (IsolationForest), numpy |
| Encryption | cryptography (AES-256-GCM) |
| Backend API | Flask, flask-cors |
| Frontend | Vanilla JS, Chart.js, SSE |
| Alerts | plyer (desktop), smtplib (email) |
This tool is intended for:
- Monitoring your own device
- Enterprise endpoint security (with employee consent)
- Research into behavioral biometrics
Do not use on devices you don't own. Unauthorized monitoring is illegal in most jurisdictions.
MIT License β see LICENSE file.



