README.md
Markdown
# Cybertection Port Master AI v3.6 **AI-Enhanced Port Management & Security Tool for Windows Firewall**
**(Generated: Friday, May 2, 2025 at 8:19:42 PM EDT)**
## Overview Cybertection Port Master AI is a graphical tool designed to help users manage Windows Firewall rules for specific ports with greater ease and insight. It leverages the `netsh advfirewall` command-line interface but provides a user-friendly GUI. The core feature is the "AI Port Advisor," which utilizes a comprehensive JSON database (`port_database.json`) to provide detailed information about ports, including common uses, security risks, and recommendations, helping users make more informed decisions about opening or closing ports.
**Primary Functions:** * Allow/Block specific TCP/UDP ports or ranges via Windows Firewall. * Provide detailed information and security guidance for selected ports ("AI Advisor"). * Apply predefined security profiles (Hardened, Balanced, Permissive). * Perform basic TCP port scans on target hosts. * Log all actions and results.
**Disclaimer:** This tool directly modifies system firewall settings. Use it responsibly, with proper authorization, and at your own risk. Incorrect configuration can impact network connectivity and security. It is primarily designed for Windows. ## Features *
**Port Control Tab:** * Browse and search an extensive port database. * View detailed port information: Description, Use Cases, Risks, Recommendation, Risk Level. * Check current firewall state for managed rules (Allow/Block/Partial). * Allow or Block selected/custom ports/ranges for TCP, UDP, or Both. * AI-driven warnings when attempting to allow high-risk ports. *
**Network Scanner Tab:** * Perform TCP connect scans on specified IP/hostname and port range. * View open ports with service and risk level information. *
**Security Profiles Tab:** * Select predefined security levels (Hardened, Balanced, Permissive) based on database risk levels. * Apply profile rules to automatically manage (`CS_Port_*` prefixed) firewall rules. * Toggle "Secure Mode" to enforce blocking of all 'Critical' risk ports. *
**Activity Log Tab:** * View detailed, timestamped logs of all operations. * Copy, Save, and Clear log capabilities. *
**Advanced Management:** * List or Delete all rules managed by this tool. * Option to reset the entire Windows Firewall (Use with extreme caution!). * Open and Reload the Port Database file. *
**Admin Elevation:** Attempts to automatically request Administrator privileges on startup (required for firewall changes). * **Themed UI:** Uses a dark, "cyberpunk" styled theme with clear visual indicators. ## Requirements *
**Operating System:** Windows 10 / Windows 11 (Recommended). Uses `netsh advfirewall`. Limited functionality on other OSes. *
*Python:** Python 3.6 or higher. *
**Port Database:** A `port_database.json` file (containing port information) must be present in the same directory as the script. A generation script (`generate_db.py` or similar) might be needed to create the full database. *
**Administrator Privileges:** Essential for modifying firewall rules. ## Setup & Installation 1. **Obtain Files:** Download or place the main Python script (e.g., `cybertection_ai.py`) and the `port_database.json` file into the same directory. 2.
**Port Database:** If you don't have `port_database.json`, you may need to run a separate script (like `generate_db.py` provided previously) to create it first: `python generate_db.py`. Ensure the final database file is named exactly `port_database.json`. 3. **Icon (Optional):** Place an icon file named `shield.ico` in the same directory for the window icon. 4. **Ensure Python:** Verify Python 3.x is installed and added to your system's PATH. 5. **Run as Admin:** * Right-click the script and choose "Run as administrator" OR * Open Command Prompt or PowerShell **as Administrator**, navigate (`cd`) to the script's directory, and run: `python your_script_name.py` * The script will also try to self-elevate if run without admin rights initially. Grant permission if prompted by UAC.
## Usage *(See the "How to Use Cybertection Port Master AI" section above for a detailed guide on each tab and feature.)* ## Important Notes & Warnings * ⚠️ **ADMINISTRATOR RIGHTS REQUIRED:** Modifying the firewall requires running this application with administrator privileges. Most core features (Allow, Block, Apply Profile, Reset) will be disabled otherwise. * ⚠️ **MODIFIES FIREWALL:** This tool adds and deletes rules in the Windows Firewall. Understand the implications before allowing or blocking ports, especially based on profiles. Rules created by this tool are prefixed with `CS_Port_`. * ⚠️ **USE RESPONSIBLY:** Do not block ports essential for your operating system or critical applications unless you understand the consequences. Blocking ports like RDP or SMB incorrectly can lock you out or break network functionality. * ⚠️ **ADVANCED OPTIONS:** The "Reset Windows Firewall" option is extremely destructive and will remove *all* firewall rules. Use only if you fully understand the impact and have a recovery plan. "Delete ALL Managed Rules" is safer but still removes all rules created by *this* tool. *
**AI is Database-Driven:** The "AI Advisor" recommendations and risk levels are based entirely on the content of the `port_database.json` file. The quality of advice depends on the accuracy and completeness of this file. It is *not* a learning AI. * **Windows Focus:** While the GUI might run on other systems, the core firewall interaction relies on Windows `netsh` commands. Functionality on macOS or Linux is not guaranteed or implemented for firewall control.
## Troubleshooting * **Permission Errors / Buttons Disabled:** Ensure you are running the script with Administrator privileges. * **"Database File Not Found":** Make sure `port_database.json` exists in the same directory as the Python script and is correctly named. * **`netsh` Command Errors:** Check the Activity Log for specific error messages from `netsh`. These might indicate syntax issues, permissions problems, or conflicts with other firewall management software. * **UI Freezes:** Long operations (applying profiles, deleting many rules, slow scans) run in background threads, but brief freezes might occur. If persistent freezes happen, check the console for errors. ---