Skip to content

reshma-adsul/WorkGuard-AI-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

πŸ›‘οΈ WorkGuard AI

AI-Powered Unauthorized Access Detection & Workspace Security Monitor

Python ML Security Platform Camera Flask License


🎯 The Problem

Every day, employees leave their workstations unlocked β€” for a meeting, a coffee break, or an emergency. In those few unattended minutes, sensitive data can be accessed, files can be copied, and credentials can be stolen.

Traditional solutions? Either too complex (IT-configured software) or too passive (just a screensaver lock). Neither detects who used the machine while you were away, what they did, or when it happened.

WorkGuard AI solves this.

It runs silently in the background, learns your unique behavioral fingerprint, and the moment someone else touches your keyboard β€” it knows.


πŸ“Έ Screenshots

πŸ–₯️ Terminal β€” System Startup

Terminal

πŸ“Š Live Monitoring Dashboard

Dashboard

πŸ“· Camera Surveillance Bar

Camera

πŸ“ˆ App Usage Analytics

Chart


✨ Key Features

Feature Description
⌨️ Keystroke Capture Every keypress logged with millisecond-precision timing
🧬 Biometric Fingerprinting Builds unique typing profile using dwell & flight time
πŸ€– ML Anomaly Detection Isolation Forest detects behavioral deviations in real-time
πŸ“· Camera Surveillance OpenCV monitors desk presence β€” detects owner vs stranger
πŸ” AES-256-GCM Encryption All logs encrypted at rest with tamper detection
πŸ“Š Live Dashboard Real-time Flask API + Chart.js β€” no refresh needed
πŸ–±οΈ Mouse Tracking Clicks, scrolls, movement patterns recorded
πŸ“Έ Auto Screenshots Periodic visual evidence every 30 seconds
🚨 Instant Alerts Desktop notification fires on unauthorized access
πŸ“ Session Reports Full HTML report generated at end of each session

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     WorkGuard AI                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                         β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚   CAPTURE   β”‚    β”‚  ML ENGINE  β”‚    β”‚    API    β”‚  β”‚
β”‚   β”‚             β”‚    β”‚             β”‚    β”‚           β”‚  β”‚
β”‚   β”‚ β€’ Keyboard  │───▢│ β€’ Biometrics│───▢│ β€’ Flask   β”‚  β”‚
β”‚   β”‚ β€’ Mouse     β”‚    β”‚ β€’ Isolation β”‚    β”‚ β€’ 8 REST  β”‚  β”‚
β”‚   β”‚ β€’ Camera    β”‚    β”‚   Forest    β”‚    β”‚   endpointsβ”‚  β”‚
β”‚   β”‚ β€’ Screenshotβ”‚    β”‚ β€’ Z-score   β”‚    β”‚ β€’ SSE     β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                               β”‚        β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚        β”‚
β”‚   β”‚  SECURITY   β”‚    β”‚  DASHBOARD  β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β”‚             β”‚    β”‚             β”‚                   β”‚
β”‚   β”‚ β€’ AES-256   β”‚    β”‚ β€’ Chart.js  β”‚                   β”‚
β”‚   β”‚ β€’ GCM Auth  β”‚    β”‚ β€’ Live Feed β”‚                   β”‚
β”‚   β”‚ β€’ Encrypted β”‚    β”‚ β€’ Threat    β”‚                   β”‚
β”‚   β”‚   Logs      β”‚    β”‚   Gauge     β”‚                   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
workguard_ai/
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ recorder.py       # Event capture engine
β”‚   β”œβ”€β”€ camera.py         # OpenCV camera surveillance
β”‚   β”œβ”€β”€ encryptor.py      # AES-256-GCM encryption
β”‚   └── alerts.py         # Alert system
β”œβ”€β”€ ml/
β”‚   β”œβ”€β”€ biometrics.py     # Keystroke dynamics engine
β”‚   └── anomaly.py        # Isolation Forest detector
β”œβ”€β”€ api/
β”‚   └── server.py         # Flask REST API
β”œβ”€β”€ dashboard/
β”‚   └── index.html        # Live monitoring dashboard
β”œβ”€β”€ main.py               # Main orchestrator
└── requirements.txt

🧠 How the ML Works

Layer 1 β€” Keystroke Dynamics Biometrics

Every person types differently. WorkGuard AI captures your unique typing fingerprint:

Key Press ──────────────────────────────── Key Release
    │◄──────── Dwell Time (ms) ──────────►│

Key Release ──────────────── Next Key Press
    │◄──── Flight Time (ms) ────►│

Profile building:

  • Captures 50+ keystrokes during calibration
  • Computes mean & standard deviation of dwell/flight times
  • Stores typing WPM and rhythm variance

Similarity scoring (Z-score method):

Z = |current_value - profile_mean| / profile_std
Similarity = e^(-0.5 Γ— ZΒ²)

Score β‰₯ 0.65 β†’ Original User βœ…
Score < 0.65 β†’ Unknown User ⚠️

Research basis: Carnegie Mellon University Keystroke Dynamics Dataset


Layer 2 β€” Isolation Forest Anomaly Detection

Uses scikit-learn's Isolation Forest β€” an unsupervised ML algorithm that learns what "normal" looks like and flags deviations.

9-dimensional feature vector per session window:

Feature What it measures
kpm Keystrokes per minute
mean_dwell Average key hold duration
mean_flight Average inter-key latency
dwell_variance Typing consistency
click_rate Mouse clicks per minute
scroll_rate Scroll events per minute
hour_of_day Unusual login times (2AM?)
special_key_ratio Ctrl/Alt/Win usage (hackers use more)
unique_windows Number of different apps opened

Why Isolation Forest?

  • Unsupervised β€” no labeled "attack" data needed
  • Works with small datasets (your own sessions)
  • O(n log n) β€” fast enough for real-time use
  • Industry standard for behavioral anomaly detection

Layer 3 β€” Camera Surveillance (OpenCV)

3-State Finite State Machine:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     user leaves      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  OWNER_PRESENT  │─────────────────────▢│   NO_ONE     β”‚
β”‚   (Safe mode)   β”‚                      β”‚ (Standby)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
         β–²                                      β”‚ stranger arrives
         β”‚ owner returns                        β–Ό
         β”‚                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         └──────────────────────────────│   STRANGER   β”‚
                                        β”‚  πŸ”΄ ALERT!   β”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Haar Cascade face detection (built into OpenCV)
  • Smoothing buffer β€” requires 3 consecutive detections before state change (prevents false alerts)
  • Intruder photo captured automatically on STRANGER detection

πŸ” Security Architecture

Password
   β”‚
   β–Ό
SHA-256 Hash ──▢ 256-bit Key
                     β”‚
                     β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  For each log chunk:    β”‚
              β”‚  β€’ Generate 96-bit nonceβ”‚
              β”‚  β€’ AES-256-GCM encrypt  β”‚
              β”‚  β€’ Append auth tag      β”‚
              β”‚  β€’ Write to .enc file   β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Property Value
Algorithm AES-256-GCM
Key size 256 bits
Nonce 96-bit (random per chunk)
Auth tag 128-bit (tamper detection)
Key derivation SHA-256

πŸš€ Quick Start

# 1. Clone the repository
git clone https://github.com/reshma-adsul/WorkGuard-AI-.git
cd WorkGuard-AI-

# 2. Run (auto-installs all dependencies)
python main.py

First-time setup:

Enable AES-256 encryption? β†’ y (recommended) or n
Screenshot interval?       β†’ 30 (default)
Launch live dashboard?     β†’ y
Enable camera?             β†’ y
Register your face?        β†’ y (look at camera)

Then:

  1. Type normally for 2+ minutes
  2. Click "🎯 Calibrate" in dashboard
  3. Your behavioral profile is saved!
  4. Use START_SILENT.bat before leaving your desk next time

Dashboard: http://127.0.0.1:5000


🌐 REST API Reference

Endpoint Method Description
/api/status GET Session info, calibration state
/api/live GET Last N events from buffer
/api/live/stream GET SSE stream (real-time push)
/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 behavioral profile
/api/camera/status GET Camera surveillance state
/api/sessions GET List all past sessions

πŸ§ͺ Tech Stack

Layer Technology Why
Event Capture pynput OS-level hooks β€” works across all apps
Screenshots PIL ImageGrab Lightweight, no dependencies
Window Tracking win32gui, psutil Native Windows API
Computer Vision OpenCV Industry standard, no internet needed
ML β€” Biometrics NumPy, statistics Lightweight statistical modeling
ML β€” Anomaly scikit-learn IsolationForest, production-ready
Encryption cryptography AES-256-GCM, NIST approved
Backend Flask, flask-cors Lightweight REST API
Frontend Vanilla JS, Chart.js Zero build process, fast
Alerts plyer, smtplib Cross-platform desktop + email

πŸ“‹ Requirements

pynput>=1.7.6
Pillow>=10.0.0
pywin32>=306
psutil>=5.9.0
flask>=3.0.0
flask-cors>=4.0.0
cryptography>=41.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
opencv-python>=4.8.0
plyer>=2.1.0

⚠️ Ethical Use

This tool is intended only for:

  • Monitoring your own device
  • Enterprise endpoint security with employee consent
  • Academic research in behavioral biometrics

Unauthorized monitoring is illegal. Do not use on devices you do not own.


πŸ‘©β€πŸ’» Author

Reshma Adsul

LinkedIn GitHub


πŸ“„ License

MIT License β€” free to use, modify, and distribute with attribution.

About

AI-Powered Unauthorized Access Detection System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors