Automated VPN & Security Analysis Tool
This Python script automates the management of Docker containers for VPN testing and network analysis using Nmap. It integrates advanced logging and messaging with Telegram for real-time updates, enabling efficient monitoring and scanning.
-
Docker Container Management
- Start, stop, and manage containers programmatically.
- Dynamically configure containers with specific network settings.
-
Network Interface Detection
- Automatically identifies network interfaces (
ppp0
). - Retrieves CIDRs and configures routing tables within containers.
- Automatically identifies network interfaces (
-
Nmap Scanning Integration
- Installs
nmap
and additional tools inside containers. - Performs network vulnerability scans for specific ports and services (e.g., SMB, RDP).
- Outputs results in structured formats like JSON and XML.
- Installs
-
Telegram Notifications
- Sends real-time updates and scan summaries to specified Telegram chats.
- Shares files (e.g., Nmap results) via Telegram for easy accessibility.
-
Error Handling & Logging
- Implements retry mechanisms for container operations and CIDR retrieval.
- Logs actions and errors with timestamped entries for debugging.
-
Container Initialization
- Defines container properties such as IP, VPN credentials, and privileged permissions.
- Starts and configures Docker containers with these properties.
-
Interface & CIDR Management
- Checks for the existence of network interfaces within the container.
- Retrieves and validates CIDRs for further scanning.
-
Nmap Installation & Scanning
- Installs tools (
nmap
,jq
) to facilitate network scanning and result processing. - Executes scans using advanced Nmap arguments for service detection and vulnerability analysis.
- Installs tools (
-
Results Processing
- Parses Nmap XML output into JSON for easier interpretation.
- Filters and sends relevant results to Telegram.
- Saves detailed results as JSON files for future reference.
-
Real-time Updates:
- Notifies on key milestones (e.g., container start, scan completion).
- Alerts on errors or invalid configurations.
-
Detailed Reporting:
- Sends formatted scan summaries and full scan results.
- Shares JSON files containing detailed scan data.
-
Dependencies
- Python Modules:
requests
,time
,subprocess
,logging
,xmltodict
,json
- Linux tools within Docker containers:
nmap
,jq
- Python Modules:
-
Docker Networking
- Privileged access for configuring custom routes and VPN addresses.
-
Telegram API Integration
- A valid Telegram bot API key and chat IDs for notifications.
- Automated VPN testing and validation.
- Network vulnerability assessments.
- Real-time security monitoring for dynamic IP ranges.
- Scalable testing for large-scale networks.
-
Expand Features:
- Add support for custom Nmap scripts.
- Enhance error reporting with container-specific logs.
-
Performance Optimization:
- Parallelize scanning across containers for faster execution.
-
Security Enhancements:
- Secure sensitive data (e.g., passwords, API keys) using environment variables or encrypted files.
-
Testing Automation:
- Develop unit tests to validate individual components.