Version: 1.0.0
Purpose: A comprehensive exam monitoring and security system designed to prevent cheating and unauthorized activities during online assessments.
- Project Overview
- Architecture
- File Structure
- Core Components
- Building
- Installation
- Usage
- Security Features
- Development
A3Guard is a C++17 Qt5-based desktop application for comprehensive exam monitoring with the following key features:
- Real-time Monitoring: Application tracking, clipboard monitoring, keystroke detection, USB device monitoring
- Network Control: WiFi/Bluetooth/Ethernet disabling, airplane mode toggle
- Security: AES-256 encryption, SHA-256 integrity checking, encrypted logs and screenshots
- System Monitoring: CPU/memory usage tracking, file integrity verification, privilege enforcement
- Intuitive UI: Tabbed interface with dashboard, logs, clipboard data, keylogger, USB, and statistics
Target Users: Educational institutions running online exams, proctoring systems
Security Level: Enterprise-grade with root privilege enforcement and encrypted data storage
┌─────────────────────────────────────────────────────────────┐
│ A3Guard Application │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ MainWindow │ │ AlertManager │ │ Logger │ │
│ │ (UI) │ │ (Alerts) │ │ (Logging) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ ▲ ▲ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ MonitoringEngine (Central Hub) │ │
│ │ • checkApplications() │ │
│ │ • checkWindows() │ │
│ │ • checkClipboard() │ │
│ │ • checkUSBDevices() │ │
│ │ • checkKeystrokes() │ │
│ └──────────────────────────────────────────────────────┘ │
│ ▲ ▲ ▲ ▲ │
│ │ │ │ │ │
│ ┌──────┴──┐ ┌─────┴────┐ ┌──┴──────┐ ┌─┴─────────┐ │
│ │ Network │ │ Resource │ │ Security│ │ Privilege │ │
│ │Manager │ │ Monitor │ │Manager │ │ Dialog │ │
│ └─────────┘ └──────────┘ └─────────┘ └───────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ConfigManager │ │ SystemCtrlr │ │SessionMgr │ │
│ │ (Config) │ │ (System) │ │ (Sessions) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌──────────┐ ┌──────────┐
│ Qt5 Core │ │ OpenSSL │ │ X11/ │
│ Widgets │ │ Crypto │ │ udev │
└─────────────┘ └──────────┘ └──────────┘
- Encryption Pipeline: All logs, screenshots, and backups encrypted with AES-256-CBC
- Privilege Separation: App runs with minimal privileges initially, elevates via pkexec
- Integrity Verification: SHA-256 hashing with real-time tamper detection
- Resource Limits: Self-monitoring to prevent system abuse (<10% CPU, <100MB RAM)
A3Guard/
├── CMakeLists.txt # CMake build configuration
├── LICENSE # Software license
├── WARP.md # WARP IDE guidance
├── README.md # Original README (quick start)
├── README_DETAILED.md # This file
│
├── include/ # C++ Header files
│ ├── Common.h # Common enums, structures, constants
│ ├── MainWindow.h # Main UI window interface
│ ├── SecurityManager.h # Encryption/decryption interface
│ ├── ConfigManager.h # Configuration management interface
│ ├── Logger.h # Event logging interface
│ ├── MonitoringEngine.h # Core monitoring interface
│ ├── NetworkManager.h # Network control interface
│ ├── SystemController.h # System integration interface
│ ├── AlertManager.h # Alert/notification interface
│ ├── ResourceMonitor.h # Resource usage interface
│ ├── SessionManager.h # Session management interface
│ ├── PrivilegeDialog.h # Privilege elevation dialog
│ └── KeyLogger.h # Keystroke logging interface
│
├── src/ # C++ Implementation files
│ ├── main.cpp # Entry point, QApplication setup
│ ├── MainWindow.cpp # UI implementation, event handlers
│ ├── SecurityManager.cpp # Encryption/decryption implementation
│ ├── ConfigManager.cpp # Config file parsing and management
│ ├── Logger.cpp # Log file creation and writing
│ ├── MonitoringEngine.cpp # Core monitoring logic
│ ├── NetworkManager.cpp # Network interface control via D-Bus
│ ├── SystemController.cpp # System commands execution
│ ├── AlertManager.cpp # Alert notifications (tray)
│ ├── ResourceMonitor.cpp # CPU/memory monitoring from /proc
│ ├── SessionManager.cpp # Session state and history
│ ├── PrivilegeDialog.cpp # Privilege elevation UI and logic
│ └── KeyLogger.cpp # Keystroke detection from /proc/interrupts
│
├── config/ # Configuration files
│ └── a3guard.conf # Default configuration (INI format)
│
├── resources/ # Qt resource files
│ └── a3guard.qrc # Resource file definitions (icons, etc)
│
├── scripts/ # Utility scripts
│ └── install.sh # Installation script
│
└── build/ # Build output directory (created by cmake)
└── A3Guard # Compiled executable
Purpose: Main GUI window with tabbed interface
Key Features:
- Tabbed interface: Dashboard, Clipboard, Keylogger, USB, Logs, Statistics
- Real-time monitoring status display
- System tray integration for minimize/restore
- Session history tracking
- Report generation and export
Key Methods:
setupUI()- Initialize all UI componentstoggleMonitoring()- Start/stop monitoringupdateUI()- Periodic UI updatescheckPrivileges()- Privilege elevation dialogupdateClipboardTabDisplay()- Display clipboard dataupdateKeyloggerDisplay()- Display keystroke dataupdateUsbDisplay()- Display USB device infoupdateLogs()- Refresh log display
Signals Emitted: None directly (receives signals from monitoring engine)
Purpose: Handles all encryption, decryption, and file integrity operations
Key Features:
- AES-256-CBC encryption/decryption
- SHA-256 hashing for integrity checking
- Secure file deletion (overwrite before delete)
- Key generation and management
- Encrypted file format:
.a3log,.a3img,.a3bak,.a3int
Key Methods:
initialize()- Load/generate encryption keysencrypt()- Encrypt data with AES-256-CBCdecrypt()- Decrypt encrypted datacalculateHash()- Generate SHA-256 hashverifyFileIntegrity()- Check if file has been tamperedverifyDirectoryIntegrity()- Batch integrity checksecureDelete()- Securely delete file
File Format: Custom .a3* extensions with header + IV + encrypted data
Purpose: Core event-driven monitoring system for applications, windows, clipboard, USB, keystrokes
Key Features:
- Polls system state at configurable intervals (5s apps, 2s clipboard, 5s USB, 2s keystrokes)
- X11-based window tracking
- USB device detection via
lsblkandudevadm - Keystroke detection from
/proc/interrupts - Clipboard monitoring via Qt signals
- Auto-unmount USB devices on detection
Key Methods:
startMonitoring()- Start all monitoring timersstopMonitoring()- Stop all monitoringcheckApplications()- Scan running processescheckWindows()- Get current active windowcheckClipboard()- Monitor clipboard changescheckUSBDevices()- Detect USB insertions/removalscheckKeystrokes()- Monitor keyboard activityunmountUSBDevice()- Auto-unmount USB partitions
Signals Emitted:
suspiciousActivityDetected(QString)- General activity alertwindowChanged(QString)- Window focus changedclipboardChanged()- Clipboard data changedkeystrokeDetected(QString)- Keyboard activity detectedusbDeviceDetected(QString)- USB device connected
Purpose: Controls network interfaces (WiFi, Bluetooth, Ethernet)
Key Features:
- D-Bus integration with NetworkManager
- Enables/disables WiFi, Bluetooth, Ethernet
- "Airplane mode" functionality
- Real-time network state monitoring
- Command execution via
nmclioriptables
Key Methods:
enableAirplaneMode()- Disable all network interfacesdisableAirplaneMode()- Enable network interfacesdisableWiFi()/enableWiFi()- Toggle WiFidisableBluetooth()/enableBluetooth()- Toggle BluetoothdisableEthernet()/enableEthernet()- Toggle EthernetblockAllNetworkTraffic()- Block traffic via iptablesallowNetworkTraffic()- Allow traffic
Dependencies: NetworkManager (D-Bus), nmcli, iptables
Purpose: Manages configuration file parsing and application settings
Configuration Sections:
[monitoring]
screenshot_interval=120000
network_check_interval=30000
app_monitor_interval=5000
clipboard_interval=2000
[network]
disable_wifi=true
disable_bluetooth=true
disable_ethernet=false
airplane_mode=false
[security]
enable_encryption=true
encrypt_screenshots=true
encrypt_logs=true
enable_integrity_check=true
[alerts]
show_alerts=true
log_violations=true
[ui]
show_dashboard=true
show_clipboard=true
show_keylogger=true
show_usb=true
[resources]
max_cpu_usage=10.0
max_memory_mb=100
log_max_size_mb=10Key Methods:
initialize()- Load config from filegetScreenshotInterval()- Get screenshot intervalgetAllowLocalhost()- Check if localhost allowedgetWhitelistedApplications()- Get app whitelist
Purpose: Event logging with encryption support
Key Features:
- Encrypted log file writing (
.a3logformat) - Automatic log rotation based on size
- Timestamp and severity level tracking
- Batch file logging from memory
- Log retrieval by time range
Key Methods:
initialize()- Create log files and directorieslog()- Write log entrylogEvent()- Log monitoring eventrotateLogFiles()- Manage log sizegetLogsFromLastHours()- Retrieve recent logs
Log Format: [TIMESTAMP] [LEVEL] [COMPONENT] Message
Purpose: System tray notifications and alerts
Key Features:
- Qt system tray integration
- Alert levels: INFO, WARNING, CRITICAL, VIOLATION
- Non-intrusive notifications
- Context menu in tray
- Alert history tracking
Key Methods:
showAlert()- Display alert messageshowTrayNotification()- Show system notificationsetAlertLevel()- Set severity level
Purpose: Monitors application resource usage to prevent abuse
Key Features:
- CPU usage tracking from
/proc/[pid]/stat - Memory usage from
/proc/[pid]/status - Threshold-based alerts
- Self-resource awareness
Key Methods:
startMonitoring()- Start resource trackingstopMonitoring()- Stop resource trackinggetCpuUsage()- Get current CPU %getMemoryPercentage()- Get current memory %
Purpose: Manages exam session state, timing, and history
Key Features:
- Session start/stop tracking
- Event aggregation per session
- Session history persistence
- Report generation
Key Methods:
startSession()- Initialize new exam sessionendSession()- Finalize sessionaddEvent()- Record event in sessiongetSummary()- Get session statistics
Purpose: Handles privilege elevation via pkexec
Key Features:
- Modal privilege request dialog
- pkexec-based elevation (no sudo password required)
- X11 display preservation for GUI
- Timeout handling
- User-friendly error messages
Key Methods:
hasRootPrivileges()- Check if running as rootrequestElevation()- Show dialog and request elevationauthenticateWithPkexec()- Execute elevation via pkexeconElevateClicked()- Handle button clicks
Elevation Flow:
- Non-elevated app starts
- Privilege dialog appears
- User clicks "Request Privileges"
- pkexec password dialog appears
- After authentication, elevated app launches
- Non-elevated instance exits
Purpose: Execute system commands and manage system integration
Key Features:
- Process execution wrapper
- Command timeout handling
- Output capture
- Error handling
Key Methods:
executeCommand()- Run system commandexecuteCommandWithOutput()- Run and capture outputkillProcess()- Terminate process
Purpose: Shared definitions, enums, and constants
Defines:
- Version:
A3GUARD_VERSION = "1.0.0" - File extensions:
.a3log,.a3img,.a3bak,.a3int - Default paths:
/etc/a3guard/,/var/lib/a3guard/,/var/log/a3guard/ - Monitoring intervals in milliseconds
- Resource limits (CPU, memory, log size)
- Event types, alert levels
- Structures:
MonitoringEvent,SessionSummary,ResourceUsage - Logging macros:
LOG_DEBUG,LOG_INFO,LOG_WARNING,LOG_ERROR
# Debian/Ubuntu
sudo apt-get install -y \
build-essential \
cmake \
qtbase5-dev qtbase5-dev-tools \
libssl-dev \
libudev-dev \
libx11-dev libxfixes-dev \
pkg-config# Navigate to project directory
cd /home/test/A3Guard
# Create build directory
mkdir -p build && cd build
# Configure (Debug or Release)
cmake -DCMAKE_BUILD_TYPE=Release ..
# Build
make -j$(nproc)
# Binary location
./A3Guard- Release (default): Optimized with
-O3 -march=native, minimal debug info - Debug: Full symbols, no optimization, verbose logging
- Profile: Profile-guided optimization for benchmarking
cd /home/test/A3Guard/build
# Install (requires root)
sudo make install
# This installs:
# - Binary: /opt/a3guard/bin/A3Guard
# - Config: /etc/a3guard/a3guard.conf
# - Systemd service: /etc/systemd/system/a3guard.service
# - Desktop entry: /usr/share/applications/A3Guard.desktop
# - PolicyKit policy: /usr/share/polkit-1/actions/com.a3guard.policycd build
cpack -G DEB
sudo dpkg -i a3guard-*.debAfter installation, set proper permissions:
sudo mkdir -p /var/lib/a3guard/{screenshots,backup,integrity}
sudo mkdir -p /var/log/a3guard
sudo chown -R a3guard:a3guard /var/lib/a3guard /var/log/a3guard
sudo chmod 700 /var/lib/a3guard /var/log/a3guard# Without elevation (limited features)
./build/A3Guard
# Or with elevation prompt
./build/A3Guard
# → Privilege dialog appears
# → Click "Request Privileges"
# → Enter password when prompted
# → Elevated app launches# Generate new encryption key
sudo ./build/A3Guard --generate-key
# Verify file integrity
sudo ./build/A3Guard --verify-integrity
# Enable verbose logging
sudo ./build/A3Guard --verbose
# Use custom config
./build/A3Guard --config /path/to/custom.conf
# View help
./build/A3Guard --help- Dashboard Tab: Monitoring status, airplane mode, violations, resource usage
- Clipboard Tab: Recent clipboard entries with detection types
- Keylogger Tab: Keystroke activity summary
- USB Tab: Connected USB devices with model/serial info
- Logs Tab: Event log with severity levels
- Statistics Tab: Session summary, report generation
- Click "Start Monitoring" button in Dashboard
- System begins collecting data
- Click "Stop Monitoring" to pause
- Generate reports from Statistics tab
- Algorithm: AES-256-CBC with PKCS#7 padding
- Key Management: 256-bit keys in
/etc/a3guard/a3guard.key - IV Generation: Random 128-bit per operation
- Applies to: Logs, screenshots, backups
- Algorithm: SHA-256 hashing
- Detection: Real-time file monitoring with
QFileSystemWatcher - Storage:
.a3intencrypted hash files - Response: Immediate alert and logging
- Model: Minimal privilege by default, elevation on demand
- Method: pkexec (PolicyKit) for user-friendly auth
- Requirements: PolicyKit daemon, polkit rules
- Timeout: 120 seconds for password entry
- CPU: Self-limits to 10% (monitored and logged)
- Memory: Self-limits to 100MB (monitored and logged)
- Logs: Auto-rotate at 10MB
- Screenshots: Automatic cleanup based on retention policy
- Airplane Mode: Disables WiFi, Bluetooth, Ethernet simultaneously
- Traffic Control: iptables rules for granular blocking
- State Enforcement: Periodic verification that restrictions hold
- Headers in
include/: Interface definitions - Implementation in
src/: Core logic - Config in
config/: Default settings - Resources in
resources/: Qt resources (icons, etc)
-
Create header in
include/class MyNewFeature : public QObject { Q_OBJECT public slots: void onSomething(); signals: void featureEvent(QString); };
-
Implement in
src/MyNewFeature.cpp -
Connect to MainWindow:
connect(m_myFeature.get(), &MyNewFeature::featureEvent, this, &MainWindow::onViolationDetected); -
Update
CMakeLists.txtto include new files -
Build and test:
cd build && make -j$(nproc)
No automated tests currently. Manual testing:
# Test privilege elevation
./build/A3Guard
# Test USB detection
# → Plug in USB device → Check USB tab
# Test clipboard monitoring
# → Copy text → Check Clipboard tab
# Test keystroke detection
# → Type on keyboard → Check Keylogger tab
# Test network control
# → Check airplane mode toggle
# Test encryption
# → Check log files in /var/log/a3guard/
# → Verify .a3log files are binary (encrypted)Enable debug logging:
./build/A3Guard --verbose 2>&1 | tee a3guard.log
# Also check system logs:
journalctl -u a3guard -f- C++17 standard
- Qt naming conventions (m_ for members, camelCase for methods)
- Const correctness
- Smart pointers (shared_ptr, unique_ptr)
Location: /etc/a3guard/a3guard.conf or ~/.config/a3guard/a3guard.conf
Edit to customize:
- Monitoring intervals
- Resource limits
- Network restrictions
- Whitelisted applications/windows
- Alert settings
# Increase screenshot interval (milliseconds)
screenshot_interval=300000
# Enable localhost for local testing
allow_localhost=true
# Disable USB monitoring
check_usb_devices=false
# Set custom logging level
log_level=DEBUG| Issue | Solution |
|---|---|
| "Could not connect to X11 display" | Run with DISPLAY=:0, ensure X11 running |
| "Permission denied for USB unmount" | App must run as root (use pkexec) |
| "pkexec: command not found" | Install policykit package |
| "Blank UI after elevation" | Check X11 authority, run xhost +local: |
| "High CPU/memory usage" | Check resource limits in config |
See LICENSE file for full license terms.
Contributions welcome! Please ensure:
- Code compiles without warnings
- Follows existing code style
- Includes appropriate logging
- Tests manual functionality
- Documents new features
For issues, questions, or contributions, please use the project's issue tracker or contact the development team.