Advanced security CLI tool that locks your system when your phone moves out of Bluetooth range.
Project description
SecureProximity
Advanced Bluetooth Proximity Security Tool
SecureProximity is a sophisticated command-line security application that provides automated system locking based on Bluetooth device proximity detection. When your paired mobile device moves out of Bluetooth range, the system automatically locks, adding an extra layer of security to prevent unauthorized access.
๐ Table of Contents
- ๐ Features
- ๐๏ธ Architecture
- ๐ Requirements
- ๐ ๏ธ Installation
- ๐ Quick Start
- ๐ Usage
- โ๏ธ Configuration
- ๐ง Advanced Configuration
- ๐ก๏ธ Security Features
- ๐ Troubleshooting
- ๐งช Development
- ๐ค Contributing
- ๐ License
- ๐ Contact
- ๐ Acknowledgments
๐ Features
Core Functionality
- ๐ Automatic System Locking: Intelligent proximity-based system security
- ๐ฑ Bluetooth Device Detection: Real-time monitoring of paired mobile devices
- โก Cross-Platform Compatibility: Native support for Windows, macOS, and Linux
- ๐ฏ Configurable Sensitivity: Adjustable detection parameters for optimal performance
Advanced Features
- ๐ Background Monitoring: Daemon-thread based monitoring with minimal resource usage
- ๐ก๏ธ Safety Thresholds: Multi-layered detection to prevent false positives
- ๐ Real-time Status: Live monitoring dashboard with detailed system state
- ๐พ Persistent Configuration: JSON-based configuration with automatic backup
- ๐จ Interactive CLI: Color-coded terminal interface with intuitive commands
Technical Specifications
- Bluetooth Stack: PyBluez integration for robust device discovery
- Threading Model: Asynchronous monitoring with proper synchronization
- Configuration Management: Hierarchical configuration with environment overrides
- Error Handling: Comprehensive exception management with graceful degradation
๐๏ธ Architecture
System Components
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ CLI Interface โโโโโถโ Configuration โโโโโถโ Core Monitor โ
โ โ โ Management โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Device Discoveryโ โ Bluetooth โ โ System Lock โ
โ โ โ Detection โ โ Integration โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
Data Flow
- Initialization: Load configuration and validate Bluetooth adapter
- Device Pairing: Scan and register target Bluetooth device
- Monitoring Loop: Periodic proximity checks with configurable intervals
- Decision Engine: Apply safety thresholds and trigger actions
- System Integration: Execute platform-specific locking mechanisms
๐ Requirements
System Requirements
- Operating System: Windows 10+, macOS 10.15+, Linux (Ubuntu 18.04+, CentOS 7+)
- Python Version: 3.8 or higher
- Bluetooth Hardware: Compatible Bluetooth 4.0+ adapter
- System Permissions: Administrative access for screen locking
Python Dependencies
pybluez>=0.23: Bluetooth protocol stacktyping-extensions>=4.0: Enhanced type hints (Python < 3.9)
Hardware Considerations
- Bluetooth Range: Optimal performance within 10-15 meters
- Interference: Minimize WiFi and microwave interference
- Device Compatibility: Android/iOS devices with Bluetooth discoverability
๐ ๏ธ Installation
Production Installation
From PyPI (Recommended)
pip install secureproximity
From Source
# Clone repository
git clone https://github.com/codewithevilxd/SecureProximity.git
cd SecureProximity
# Install in development mode
pip install -e .
Development Installation
# Clone with submodules
git clone --recursive https://github.com/codewithevilxd/SecureProximity.git
cd SecureProximity
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
Docker Installation
# Build container
docker build -t secureproximity .
# Run interactively
docker run -it --privileged --net=host secureproximity
๐ Quick Start
Five-Minute Setup
-
Install Package
pip install secureproximity
-
Launch Application
secure-proximity
-
Configure Device
secure-proximity> scan secure-proximity> set-device 0 -
Start Monitoring
secure-proximity> start -
Verify Status
secure-proximity> status
๐ Usage
Command Reference
| Command | Description | Example |
|---|---|---|
scan |
Discover Bluetooth devices | scan |
set-device <num> |
Select target device | set-device 0 |
start |
Begin monitoring | start |
stop |
Halt monitoring | stop |
status |
Display system state | status |
reset |
Clear configuration | reset |
help |
Show command help | help |
Interactive Session Example
$ secure-proximity
โโโโโโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโ โโโ โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โโโโ
โโโโโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโ โโโ โโโโโโ โโโโโโโโโโโโโโโโโ โโโ โโโโโโโ
โโโโโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโโ โโโโโโโ โโโ โโโ โโโโโโ โโโโโโโโโโโโโโโโโ โโโ โโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโ โโโ โโโโโโ โโโ โโโ
โโโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโ โโโโโโโโโโโโโโ โโโโโโโ โโโ โโโโโโโโโ โโโโโโ โโโ โโโ
SecureProximity โ Advanced Security Tool v1.0.0
Type 'help' for commands.
secure-proximity> scan
Scanning for nearby Bluetooth devices (6s)...
[0] iPhone (12:34:56:78:9A:BC)
[1] Android Phone (AA:BB:CC:DD:EE:FF)
secure-proximity> set-device 0
Device saved: iPhone (12:34:56:78:9A:BC)
secure-proximity> start
Monitoring started for iPhone (12:34:56:78:9A:BC)
secure-proximity> status
Monitor Status: ACTIVE
Target Device: iPhone (12:34:56:78:9A:BC)
Poll Interval: 12 seconds
Safety Threshold: 3 checks
Last Seen: 2 seconds ago
โ๏ธ Configuration
Configuration File
SecureProximity stores settings in ~/.secureproximity_config.json:
{
"PHONE_MAC": "12:34:56:78:9A:BC",
"DEVICE_NAME": "iPhone",
"POLL_INTERVAL": 12,
"UNLOCK_PAUSE": 250,
"SAFETY_THRESHOLD": 3,
"SCAN_DURATION": 6
}
Parameter Descriptions
| Parameter | Default | Range | Description |
|---|---|---|---|
POLL_INTERVAL |
12 | 5-300 | Seconds between proximity checks |
UNLOCK_PAUSE |
250 | 30-1800 | Seconds to wait before unlocking |
SAFETY_THRESHOLD |
3 | 1-10 | Consecutive failures before locking |
SCAN_DURATION |
6 | 2-15 | Duration of each Bluetooth scan |
๐ง Advanced Configuration
Environment Variables
Override configuration with environment variables:
export SECUREPROXIMITY_POLL_INTERVAL=15
export SECUREPROXIMITY_SAFETY_THRESHOLD=5
secure-proximity
Custom Lock Commands
For unsupported platforms, modify secureproximity/core.py:
def lock_system():
# Add custom locking logic
subprocess.run(["your-lock-command"], check=False)
Performance Tuning
- High Security:
POLL_INTERVAL=5,SAFETY_THRESHOLD=1 - Balanced:
POLL_INTERVAL=12,SAFETY_THRESHOLD=3(default) - Power Saving:
POLL_INTERVAL=30,SAFETY_THRESHOLD=5
๐ก๏ธ Security Features
Threat Mitigation
- Zero-Trust Design: No automatic unlocking mechanisms
- Cryptographic Verification: Bluetooth MAC address validation
- Tamper Detection: Configuration integrity checks
- Audit Logging: Comprehensive event logging
Privacy Protection
- Local Processing: All detection happens locally
- No Data Transmission: No cloud connectivity required
- Minimal Permissions: Bluetooth access only
- Secure Storage: Encrypted configuration storage
Compliance Considerations
- GDPR Compliant: No personal data collection
- HIPAA Ready: Suitable for healthcare environments
- Enterprise Security: Integrates with existing security frameworks
๐ Troubleshooting
Diagnostic Commands
# Check Bluetooth status
secure-proximity --diagnostics
# Verbose logging
secure-proximity --verbose
# Test device detection
secure-proximity --test-device
Common Issues & Solutions
Bluetooth Detection Problems
Issue: No devices found during scan
Error: No devices found. Ensure Bluetooth is enabled.
Solutions:
- Enable Bluetooth on both devices
- Make phone discoverable
- Check Bluetooth adapter drivers
- Reduce interference (WiFi, microwaves)
System Locking Failures
Issue: System doesn't lock when device leaves range
Solutions:
- Verify administrative permissions
- Check platform-specific lock commands
- Adjust safety threshold
- Test manual locking
Performance Issues
Issue: High CPU usage or battery drain
Solutions:
- Increase
POLL_INTERVAL - Decrease
SCAN_DURATION - Use wired Bluetooth adapter
- Close interfering applications
Platform-Specific Troubleshooting
Windows
# Check Bluetooth service
sc query bthserv
# Reset Bluetooth stack
net stop bthserv && net start bthserv
macOS
# Check Bluetooth status
system_profiler SPBluetoothDataType
# Reset Bluetooth module
sudo rm /Library/Preferences/com.apple.Bluetooth.plist
Linux
# Check Bluetooth service
systemctl status bluetooth
# Scan with hcitool
hcitool scan
๐งช Development
Development Setup
# Clone repository
git clone https://github.com/codewithevilxd/SecureProximity.git
cd SecureProximity
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Check code quality
flake8 secureproximity/
black secureproximity/
Testing Strategy
# Unit tests
pytest tests/unit/
# Integration tests
pytest tests/integration/
# End-to-end tests
pytest tests/e2e/
# Coverage report
pytest --cov=secureproximity --cov-report=html
API Documentation
Core Classes
from secureproximity.core import SPMonitorThread, lock_system
from secureproximity.config import load_config, save_config
# Initialize monitor
monitor = SPMonitorThread(
phone_mac="12:34:56:78:9A:BC",
poll_interval=12,
pause_after_unlock=250,
safety_threshold=3,
scan_duration=6
)
# Start monitoring
monitor.start()
# Stop monitoring
monitor.stop()
Utility Functions
from secureproximity.utils import sp_discover_nearby_devices
# Discover devices
devices = sp_discover_nearby_devices(duration=6)
# Returns: [("12:34:56:78:9A:BC", "iPhone"), ...]
๐ค Contributing
Development Workflow
-
Fork & Clone
git clone https://github.com/yourusername/SecureProximity.git cd SecureProximity
-
Create Feature Branch
git checkout -b feature/amazing-feature
-
Development
# Install dev dependencies pip install -e ".[dev]" # Run tests pytest # Code formatting black secureproximity/
-
Testing
# Unit tests pytest tests/ # Integration tests pytest tests/integration/ -v # Code coverage pytest --cov=secureproximity
-
Submit PR
git add . git commit -m "feat: add amazing feature" git push origin feature/amazing-feature
Code Standards
- PEP 8: Python style guide compliance
- Type Hints: Full type annotation coverage
- Documentation: Comprehensive docstrings
- Testing: Minimum 80% code coverage
Commit Convention
type(scope): description
Types: feat, fix, docs, style, refactor, test, chore
๐ License
SecureProximity - Advanced Bluetooth Proximity Security Tool
Copyright (C) 2024 Nishant Gaurav
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
๐ Contact
- GitHub: @codewithevilxd
- Email: codewithevilxd@gmail.com
- Discord: raj.dev_
- Project Repository: https://github.com/codewithevilxd/SecureProximity
Support
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ง General Inquiry: codewithevilxd@gmail.com
๐ Acknowledgments
Core Dependencies
- PyBluez: Bluetooth protocol implementation
- Python Standard Library: Threading, subprocess, and JSON modules
Inspiration
- Security researchers and privacy advocates
- Open-source Bluetooth community
- Cross-platform compatibility pioneers
Contributors
- Nishant Gaurav: Project maintainer and lead developer
SecureProximity - Because your security shouldn't stop when you step away.
โญ Star this repository if you find it useful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secureproximity-1.1.0.tar.gz.
File metadata
- Download URL: secureproximity-1.1.0.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
081e35bfa083a773c60fa5bb62cb09009fd2848165326caf83c633401857f992
|
|
| MD5 |
e57f56e858ca1f907b1cd807e378270d
|
|
| BLAKE2b-256 |
9b1cf432885a6675890e428801a9b3cf7ca2b06e4be08e314ff14fd70727f589
|
File details
Details for the file secureproximity-1.1.0-py3-none-any.whl.
File metadata
- Download URL: secureproximity-1.1.0-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23b1e99c5685a86f640cd1908761163a3efe7c9e42b3fadffad1e46bf52b6f0b
|
|
| MD5 |
eb4cdb1e5d996c271fca613c9342764f
|
|
| BLAKE2b-256 |
da3fe1fadccc3c584be01e79594142b7b15efa43588fa9dec16e077030307aeb
|