From c27439d8c341e1cfe60814fb95da560644b95e17 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Thu, 4 Sep 2025 13:03:10 +0500 Subject: [PATCH 1/7] bug fix: login issues --- loginSystem/templates/loginSystem/login.html | 4 +- loginSystem/views.py | 61 +++++++++++++------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/loginSystem/templates/loginSystem/login.html b/loginSystem/templates/loginSystem/login.html index f538610cb..d9a06db62 100644 --- a/loginSystem/templates/loginSystem/login.html +++ b/loginSystem/templates/loginSystem/login.html @@ -312,7 +312,7 @@
+ name="password" style="height: 45px;" autocomplete="current-password"> @@ -366,7 +366,7 @@
-

Could Not Login, Error message: {$ errorMessage $}

+

Could Not Login, Error message:

diff --git a/loginSystem/views.py b/loginSystem/views.py index dd78836b0..549ab3c73 100644 --- a/loginSystem/views.py +++ b/loginSystem/views.py @@ -32,46 +32,61 @@ def verifyLogin(request): try: if request.method == "POST": - data = json.loads(request.body) + try: + data = json.loads(request.body) + except json.JSONDecodeError as e: + print(f"JSON decode error: {e}") + print(f"Raw request body: {request.body}") + data = {'userID': 0, 'loginStatus': 0, 'error_message': 'Invalid request format'} + json_data = json.dumps(data) + return HttpResponse(json_data) - username = data['username'] - password = data['password'] + username = data.get('username', '') + password = data.get('password', '') + + # Debug logging + print(f"Login attempt - Username: {username}, Password length: {len(password) if password else 0}") + print(f"Password contains '$': {'$' in password if password else False}") + print(f"Raw password: {repr(password)}") try: - if data['languageSelection'] == "English": + language_selection = data.get('languageSelection', 'english') + if language_selection == "English": user_Language = "en" - elif data['languageSelection'] == "Chinese": + elif language_selection == "Chinese": user_Language = "cn" - elif data['languageSelection'] == "Bulgarian": + elif language_selection == "Bulgarian": user_Language = "br" - elif data['languageSelection'] == "Portuguese": + elif language_selection == "Portuguese": user_Language = "pt" - elif data['languageSelection'] == "Japanese": + elif language_selection == "Japanese": user_Language = "ja" - elif data['languageSelection'] == "Bosnian": + elif language_selection == "Bosnian": user_Language = "bs" - elif data['languageSelection'] == "Greek": + elif language_selection == "Greek": user_Language = "gr" - elif data['languageSelection'] == "Russian": + elif language_selection == "Russian": user_Language = "ru" - elif data['languageSelection'] == "Turkish": + elif language_selection == "Turkish": user_Language = "tr" - elif data['languageSelection'] == "Spanish": + elif language_selection == "Spanish": user_Language = "es" - elif data['languageSelection'] == "French": + elif language_selection == "French": user_Language = "fr" - elif data['languageSelection'] == "Polish": + elif language_selection == "Polish": user_Language = "pl" - elif data['languageSelection'] == "Vietnamese": + elif language_selection == "Vietnamese": user_Language = "vi" - elif data['languageSelection'] == "Italian": + elif language_selection == "Italian": user_Language = "it" - elif data['languageSelection'] == "German": + elif language_selection == "German": user_Language = "de" - elif data['languageSelection'] == "Indonesian": + elif language_selection == "Indonesian": user_Language = "id" - elif data['languageSelection'] == "Bangla": + elif language_selection == "Bangla": user_Language = "bn" + else: + user_Language = 'en' translation.activate(user_Language) response = HttpResponse() @@ -83,6 +98,7 @@ def verifyLogin(request): response.set_cookie(settings.LANGUAGE_COOKIE_NAME, user_Language) admin = Administrator.objects.get(userName=username) + print(f"Found admin user: {admin.userName}, password hash length: {len(admin.password) if admin.password else 0}") if admin.state == 'SUSPENDED': data = {'userID': 0, 'loginStatus': 0, 'error_message': 'Account currently suspended.'} @@ -99,7 +115,10 @@ def verifyLogin(request): response.write(json_data) return response - if hashPassword.check_password(admin.password, password): + password_check_result = hashPassword.check_password(admin.password, password) + print(f"Password check result: {password_check_result}") + + if password_check_result: if admin.twoFA: if request.session.get('twofa', 1) == 0: import pyotp From 14dd84e9b96b5e0fa29b1864455c7b5db4efec9b Mon Sep 17 00:00:00 2001 From: Master3395 Date: Fri, 5 Sep 2025 01:14:04 +0200 Subject: [PATCH 2/7] improve docs, fix links, and add container console support This update improves documentation clarity, fixes broken documentation links, and introduces a new feature that allows you to access and use the console directly inside containers from CyberPanel. --- README.md | 171 ++++++++---------- dockerManager/container.py | 93 ++++++++++ .../static/dockerManager/dockerManager.js | 95 ++++++++++ .../dockerManager/viewContainer.html | 93 ++++++++++ dockerManager/urls.py | 1 + dockerManager/views.py | 18 ++ AIScannerDocs.md => guides/AIScannerDocs.md | 0 CONTRIBUTING.md => guides/CONTRIBUTING.md | 0 guides/Docker_Command_Execution_Guide.md | 146 +++++++++++++++ guides/INDEX.md | 57 ++++++ .../MAUTIC_INSTALLATION_GUIDE.md | 0 11 files changed, 574 insertions(+), 100 deletions(-) rename AIScannerDocs.md => guides/AIScannerDocs.md (100%) rename CONTRIBUTING.md => guides/CONTRIBUTING.md (100%) create mode 100644 guides/Docker_Command_Execution_Guide.md create mode 100644 guides/INDEX.md rename MAUTIC_INSTALLATION_GUIDE.md => guides/MAUTIC_INSTALLATION_GUIDE.md (100%) diff --git a/README.md b/README.md index 94789d5c0..821334b65 100755 --- a/README.md +++ b/README.md @@ -14,132 +14,87 @@ Web Hosting Control Panel powered by OpenLiteSpeed, designed to simplify hosting - πŸ“§ **Email Support** (SnappyMail). - πŸ•Œ **File Manager** for quick file access. - 🌐 **PHP Management** made easy. -- πŸ”’ **Firewall** (βœ… FirewallD & ConfigServer Firewall Integration). +- πŸ”’ **Firewall** (Òœ… FirewallD & ConfigServer Firewall Integration). - πŸ“€ **One-click Backups and Restores**. +- 🐳 **Docker Management** with command execution capabilities. +- πŸ€– **AI-Powered Security Scanner** for enhanced protection. + +--- + +## πŸ“– **Documentation & Guides** + +CyberPanel comes with comprehensive documentation and step-by-step guides: + +- πŸ“š **[Complete Guides Index](guides/INDEX.md)** - All available documentation in one place +- 🐳 **[Docker Command Execution](guides/Docker_Command_Execution_Guide.md)** - Execute commands in Docker containers +- πŸ€– **[AI Scanner Setup](guides/AIScannerDocs.md)** - Configure AI-powered security scanning +- πŸ“§ **[Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md)** - Email marketing platform setup --- ## πŸ”’ Supported PHP Versions -CyberPanel supports PHP versions based on your operating system: +CyberPanel supports a wide range of PHP versions across different operating systems: -### β˜‘οΈ **PHP 8.0 and Above** -- Fully supported on modern systems such as Ubuntu 22.04 and AlmaLinux 9.x and higher. +### β˜‘οΈ **Currently Supported PHP Versions** -### β˜‘οΈ **PHP 7.4 and Below** -- Compatible with AlmaLinux 8, Ubuntu 18.04, and similar environments. +- **PHP 8.5** - Latest stable version (EOL: Dec 2028) +- **PHP 8.4** - Stable version (EOL: Dec 2027) +- **PHP 8.3** - Stable version (EOL: Dec 2027) +- **PHP 8.2** - Stable version (EOL: Dec 2026) +- **PHP 8.1** - Stable version (EOL: Dec 2025) +- **PHP 8.0** - Legacy support (EOL: Nov 2023) +- **PHP 7.4** - Legacy support (EOL: Nov 2022) -### Adding PHP Versions as Third-Party Add-ons +### πŸ”§ **Third-Party PHP Add-ons** -Some PHP versions can be added to operating systems as third-party packages using external repositories or tools. Here's an overview by OS: +For additional PHP versions or specific requirements, you can install third-party packages: -#### **Ubuntu**: -- **Ubuntu 22.04**: - - Highest: PHP 8.5 (default repository or Ondrej's PPA). - - Lowest: PHP 7.4 (via Ondrej's PPA). -- **Ubuntu 20.04**: - - Highest: PHP 8.5 (default repository or Ondrej's PPA). - - Lowest: PHP 7.0 (via Ondrej's PPA). -- **Ubuntu 18.04**: - - Highest: PHP 8.4 (via Ondrej's PPA). - - Lowest: PHP 5.6 (via Ondrej's PPA). +#### **Ubuntu/Debian** -#### **AlmaLinux**: -- **AlmaLinux 9**: - - Highest: PHP 8.5 (default repository or Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **AlmaLinux 8**: - - Highest: PHP 8.4 (default repository or Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +- **Ondrej's PPA**: Provides PHP 5.6 to 8.5 +- **Sury's PPA**: Alternative repository with latest PHP versions -#### **CentOS**: -- **CentOS 9**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **CentOS 8**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). -- **CentOS 7**: - - Highest: PHP 8.0 (via Remi repository). - - Lowest: PHP 5.4 (via Remi repository). +#### **RHEL-based Systems** (AlmaLinux, RockyLinux, CentOS, RHEL) -#### **RHEL**: -- **RHEL 9**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 7.4 (via Remi repository). -- **RHEL 8**: - - Highest: PHP 8.4 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +- **Remi Repository**: Comprehensive PHP package collection +- **EPEL Repository**: Additional packages for enterprise Linux -#### **RockyLinux**: -- **RockyLinux 8**: - - Highest: PHP 8.5 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). +#### **CloudLinux** -#### **CloudLinux**: -- **CloudLinux 8**: - - Highest: PHP 8.5 (via Remi repository). - - Lowest: PHP 5.6 (via Remi repository). -- **CloudLinux 7**: - - Highest: PHP 8.0 (via Remi repository). - - Lowest: PHP 5.4 (via Remi repository). +- **CloudLinux PHP Selector**: Built-in tool for managing multiple PHP versions +- **Remi Repository**: Additional PHP versions and extensions -#### **openEuler**: -- **openEuler 22.03**: - - Highest: PHP 8.4 (default repository). - - Lowest: PHP 7.4 (default repository). -- **openEuler 20.03**: - - Highest: PHP 7.3 (default repository). - - Lowest: PHP 7.0 (default repository). - -### Full List of PHP Versions and End of Life (EOL) Dates: -- ✨ **PHP 8.5** - EOL: 31 Dec 2028. -- ✨ **PHP 8.4** - EOL: 31 Dec 2027. -- ✨ **PHP 8.3** - EOL: 31 Dec 2027. -- ✨ **PHP 8.2** - EOL: 31 Dec 2026. -- ✨ **PHP 8.1** - EOL: 31 Dec 2025. -- πŸ›‘ **PHP 8.0** - EOL: 26 Nov 2023. -- πŸ›‘ **PHP 7.4** - EOL: 28 Nov 2022. -- πŸ›‘ **PHP 7.3** - EOL: 6 Dec 2021. -- πŸ›‘ **PHP 7.2** - EOL: 30 Nov 2020. -- πŸ›‘ **PHP 7.1** - EOL: 1 Dec 2019. -- πŸ›‘ **PHP 7.0** - EOL: 10 Jan 2019. -- πŸ›‘ **PHP 5.6** - EOL: 31 Dec 2018. -- πŸ›‘ **PHP 5.5** - EOL: 21 Jul 2016. -- πŸ›‘ **PHP 5.4** - EOL: 3 Sep 2015. -- πŸ›‘ **PHP 5.3** - EOL: 14 Aug 2014. +> **Note**: Third-party repositories may provide additional PHP versions beyond what's available in default repositories. Always verify compatibility with your specific use case. --- -## 🌐 Supported OS Versions +## 🌐 Supported Operating Systems CyberPanel runs on x86_64 architecture and supports the following operating systems: -### **Ubuntu**: -- Ubuntu 22.04 βœ… Supported until April 2027. -- Ubuntu 20.04 βœ… Supported until April 2025. -- Ubuntu 18.04 πŸ›‘ EOL: 31 May 2023. +### **βœ… Currently Supported** -### **CentOS**: -- CentOS 9 βœ… EOL: 31 May 2027. -- CentOS 8 πŸ›‘ EOL: 31 Dec 2021. -- CentOS 7 πŸ›‘ EOL: 30 June 2024. +- **Ubuntu 22.04** - Supported until April 2027 +- **Ubuntu 20.04** - Supported until April 2025 +- **AlmaLinux 9** - Supported until May 2032 +- **AlmaLinux 8** - Supported until May 2029 +- **RockyLinux 9** - Supported until May 2032 +- **RockyLinux 8** - Supported until May 2029 +- **RHEL 9** - Supported until May 2032 +- **RHEL 8** - Supported until May 2029 +- **CloudLinux 8** - Supported until May 2029 +- **CentOS 9** - Supported until May 2027 -### **RHEL**: -- RHEL 9 βœ… EOL: 31 May 2032. -- RHEL 8 βœ… EOL: 31 May 2029. +### **πŸ”§ Third-Party OS Support** -### **AlmaLinux**: -- AlmaLinux 9 βœ… EOL: 31 May 2032. -- AlmaLinux 8 βœ… EOL: 31 May 2029. +Additional operating systems may be supported through third-party repositories or community efforts: -### **Other OS**: -- RockyLinux 9 βœ… EOL: 31 May 2032. -- RockyLinux 8 βœ… EOL: 31 May 2029. -- CloudLinux 8 βœ… EOL: 31 May 2029. -- CloudLinux 7 πŸ›‘ EOL: 1 Jul 2024. -- openEuler 22.03 πŸ›‘ EOL: March 2024. -- openEuler 20.03 πŸ›‘ EOL: April 2022. +- **Debian** - May work with Ubuntu-compatible packages +- **openEuler** - Community-supported with limited testing +- **Other RHEL derivatives** - May work with AlmaLinux/RockyLinux packages + +> **Note**: For unsupported operating systems, compatibility is not guaranteed. Always test in a non-production environment first. --- @@ -168,10 +123,26 @@ sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgr - 🌐 [Official Site](https://cyberpanel.net) - ✏️ [Docs (Old)](https://docs.cyberpanel.net) - πŸŽ“ [Docs (New)](https://community.cyberpanel.net/docs) +- πŸ“– [Additional Guides](guides/INDEX.md) - Detailed guides for Docker, AI Scanner, Mautic, and more +- πŸ“š [Local Documentation](guides/) - All guides available in this repository - βœ… [Changelog](https://community.cyberpanel.net/t/change-logs/161) - πŸ’¬ [Forums](https://community.cyberpanel.net) - πŸ“’ [Discord](https://discord.gg/g8k8Db3) - πŸ“΅ [Facebook Group](https://www.facebook.com/groups/cyberpanel) - πŸŽ₯ [YouTube Channel](https://www.youtube.com/@Cyber-Panel) ---- \ No newline at end of file +### πŸ“– **Quick Start Guides** + +- 🐳 [Docker Command Execution](guides/Docker_Command_Execution_Guide.md) - Execute commands in Docker containers +- πŸ€– [AI Scanner Setup](guides/AIScannerDocs.md) - Configure AI-powered security scanning +- πŸ“§ [Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md) - Email marketing platform setup +- πŸ“š [All Guides Index](guides/INDEX.md) - Complete documentation hub + +### πŸ”— **Direct Guide Links** + +| Feature | Guide | Description | +| ----------- | ---------------------------------------------------------- | ------------------------------ | +| 🐳 Docker | [Command Execution](guides/Docker_Command_Execution_Guide.md) | Execute commands in containers | +| πŸ€– Security | [AI Scanner](guides/AIScannerDocs.md) | AI-powered security scanning | +| πŸ“§ Email | [Mautic Setup](guides/MAUTIC_INSTALLATION_GUIDE.md) | Email marketing platform | +| πŸ“š All | [Complete Index](guides/INDEX.md) | Browse all available guides | diff --git a/dockerManager/container.py b/dockerManager/container.py index 746fecd3c..292372b75 100644 --- a/dockerManager/container.py +++ b/dockerManager/container.py @@ -1319,4 +1319,97 @@ class ContainerManager(multi.Thread): except BaseException as msg: data_ret = {'removeImageStatus': 0, 'error_message': str(msg)} json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + def executeContainerCommand(self, userID=None, data=None): + """ + Execute a command inside a running Docker container + """ + try: + name = data['name'] + command = data['command'] + + # Check if container is registered in database or unlisted + if Containers.objects.filter(name=name).exists(): + if ACLManager.checkContainerOwnership(name, userID) != 1: + return ACLManager.loadErrorJson('commandStatus', 0) + + client = docker.from_env() + dockerAPI = docker.APIClient() + + try: + container = client.containers.get(name) + except docker.errors.NotFound as err: + data_ret = {'commandStatus': 0, 'error_message': 'Container does not exist'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + except: + data_ret = {'commandStatus': 0, 'error_message': 'Unknown error'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + # Check if container is running + if container.status != 'running': + data_ret = {'commandStatus': 0, 'error_message': 'Container must be running to execute commands'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + try: + # Execute command in container + # Split command into parts for proper execution + import shlex + command_parts = shlex.split(command) + + # Execute command with proper shell + exec_result = container.exec_run( + command_parts, + stdout=True, + stderr=True, + stdin=False, + tty=False, + privileged=False, + user='', + detach=False, + demux=False, + workdir=None, + environment=None + ) + + # Get output and exit code + output = exec_result.output.decode('utf-8') if exec_result.output else '' + exit_code = exec_result.exit_code + + # Format the response + if exit_code == 0: + data_ret = { + 'commandStatus': 1, + 'error_message': 'None', + 'output': output, + 'exit_code': exit_code, + 'command': command + } + else: + data_ret = { + 'commandStatus': 1, + 'error_message': 'Command executed with non-zero exit code', + 'output': output, + 'exit_code': exit_code, + 'command': command + } + + json_data = json.dumps(data_ret, ensure_ascii=False) + return HttpResponse(json_data) + + except docker.errors.APIError as err: + data_ret = {'commandStatus': 0, 'error_message': f'Docker API error: {str(err)}'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + except Exception as err: + data_ret = {'commandStatus': 0, 'error_message': f'Execution error: {str(err)}'} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'commandStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) return HttpResponse(json_data) \ No newline at end of file diff --git a/dockerManager/static/dockerManager/dockerManager.js b/dockerManager/static/dockerManager/dockerManager.js index 5ecb7cbf3..3f7131450 100644 --- a/dockerManager/static/dockerManager/dockerManager.js +++ b/dockerManager/static/dockerManager/dockerManager.js @@ -976,6 +976,101 @@ app.controller('viewContainer', function ($scope, $http, $interval, $timeout) { } }; + // Command execution functionality + $scope.commandToExecute = ''; + $scope.executingCommand = false; + $scope.commandOutput = null; + $scope.commandHistory = []; + + $scope.showCommandModal = function() { + $scope.commandToExecute = ''; + $scope.commandOutput = null; + $("#commandModal").modal("show"); + }; + + $scope.executeCommand = function() { + if (!$scope.commandToExecute.trim()) { + new PNotify({ + title: 'Error', + text: 'Please enter a command to execute', + type: 'error' + }); + return; + } + + $scope.executingCommand = true; + $scope.commandOutput = null; + + url = "/docker/executeContainerCommand"; + var data = { + name: $scope.cName, + command: $scope.commandToExecute.trim() + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + console.log(response); + $scope.executingCommand = false; + + if (response.data.commandStatus === 1) { + $scope.commandOutput = { + command: response.data.command, + output: response.data.output, + exit_code: response.data.exit_code + }; + + // Add to command history + $scope.commandHistory.unshift({ + command: response.data.command, + timestamp: new Date() + }); + + // Keep only last 10 commands + if ($scope.commandHistory.length > 10) { + $scope.commandHistory = $scope.commandHistory.slice(0, 10); + } + + // Show success notification + new PNotify({ + title: 'Command Executed', + text: 'Command completed with exit code: ' + response.data.exit_code, + type: response.data.exit_code === 0 ? 'success' : 'warning' + }); + } + else { + new PNotify({ + title: 'Command Execution Failed', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.executingCommand = false; + new PNotify({ + title: 'Command Execution Failed', + text: 'Could not connect to server', + type: 'error' + }); + } + }; + + $scope.selectCommand = function(command) { + $scope.commandToExecute = command; + }; + + $scope.clearOutput = function() { + $scope.commandOutput = null; + }; + }); diff --git a/dockerManager/templates/dockerManager/viewContainer.html b/dockerManager/templates/dockerManager/viewContainer.html index 5b020744c..2a80be27b 100644 --- a/dockerManager/templates/dockerManager/viewContainer.html +++ b/dockerManager/templates/dockerManager/viewContainer.html @@ -756,6 +756,11 @@
{% trans "Processes" %}
+ +
+ +
{% trans "Run Command" %}
+
@@ -957,6 +962,94 @@ + + + {% endblock %} diff --git a/dockerManager/urls.py b/dockerManager/urls.py index 4cc3fac6b..ff9197bb8 100644 --- a/dockerManager/urls.py +++ b/dockerManager/urls.py @@ -36,6 +36,7 @@ urlpatterns = [ path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'), path('RestartContainerAPP', views.RestartContainerAPP, name='RestartContainerAPP'), path('StopContainerAPP', views.StopContainerAPP, name='StopContainerAPP'), + path('executeContainerCommand', views.executeContainerCommand, name='executeContainerCommand'), # Docker Container Actions path('startContainer', startContainer, name='startContainer'), diff --git a/dockerManager/views.py b/dockerManager/views.py index 74b2a46b9..3866d6537 100644 --- a/dockerManager/views.py +++ b/dockerManager/views.py @@ -537,6 +537,24 @@ def StopContainerAPP(request): cm = ContainerManager() coreResult = cm.StopContainerAPP(userID, json.loads(request.body)) + return coreResult + except KeyError: + return redirect(loadLoginPage) + +@preDockerRun +def executeContainerCommand(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + cm = ContainerManager() + coreResult = cm.executeContainerCommand(userID, json.loads(request.body)) + return coreResult except KeyError: return redirect(loadLoginPage) \ No newline at end of file diff --git a/AIScannerDocs.md b/guides/AIScannerDocs.md similarity index 100% rename from AIScannerDocs.md rename to guides/AIScannerDocs.md diff --git a/CONTRIBUTING.md b/guides/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to guides/CONTRIBUTING.md diff --git a/guides/Docker_Command_Execution_Guide.md b/guides/Docker_Command_Execution_Guide.md new file mode 100644 index 000000000..0fef3d7ae --- /dev/null +++ b/guides/Docker_Command_Execution_Guide.md @@ -0,0 +1,146 @@ +# Docker Command Execution Feature for CyberPanel + +## Overview +This feature adds the ability to execute commands inside running Docker containers directly from the CyberPanel web interface. This is particularly useful for applications like Honeygain that require specific command-line arguments to function properly. + +## Features Added + +### 1. Backend Components +- **New View Function**: `executeContainerCommand` in `dockerManager/views.py` +- **New Container Method**: `executeContainerCommand` in `dockerManager/container.py` +- **New URL Pattern**: `/docker/executeContainerCommand` in `dockerManager/urls.py` + +### 2. Frontend Components +- **New Action Button**: "Run Command" button in Container Actions section +- **Command Execution Modal**: Interactive modal for executing commands +- **Command History**: Tracks last 10 executed commands +- **Real-time Output**: Displays command output with proper formatting + +### 3. Security Features +- **Permission Checks**: Only admin users can execute commands +- **Container Ownership**: Users can only execute commands on containers they own +- **Input Validation**: Commands are properly sanitized using `shlex.split()` +- **Error Handling**: Comprehensive error handling for various failure scenarios + +## How to Use + +### 1. Access the Feature +1. Navigate to your Docker container in CyberPanel +2. Ensure the container is running (the "Run Command" button is disabled for stopped containers) +3. Click the "Run Command" button in the Container Actions section + +### 2. Execute Commands +1. Enter your command in the input field (e.g., `-tou-accept`, `ls -la`, `ps aux`) +2. Press Enter or click the "Execute" button +3. View the output in the terminal-style output area +4. Use command history to quickly re-run previous commands + +### 3. Common Use Cases +**For applications requiring command-line arguments:** +1. Start your container +2. Click "Run Command" +3. Enter the required command (e.g., `-tou-accept`, `--help`, `--version`) +4. Click "Execute" +5. View the output to confirm successful execution + +**For debugging and maintenance:** +- `ls -la` - List files and directories +- `ps aux` - Show running processes +- `whoami` - Display current user +- `env` - Show environment variables +- `df -h` - Display disk usage + +## Technical Details + +### Command Execution Process +1. **Validation**: Check if container exists and user has permissions +2. **Status Check**: Ensure container is running +3. **Command Parsing**: Use `shlex.split()` to properly parse command arguments +4. **Execution**: Use Docker's `exec_run()` method to execute command +5. **Response**: Return output, exit code, and any errors + +### Error Handling +- Container not found +- Container not running +- Permission denied +- Command execution failures +- Network connectivity issues + +### Security Considerations +- Commands are executed with the same user as the container's default user +- No privileged execution (unless container is privileged) +- Input is sanitized to prevent injection attacks +- Only admin users can execute commands + +## Files Modified + +### Backend Files +- `dockerManager/container.py` - Added `executeContainerCommand` method +- `dockerManager/views.py` - Added `executeContainerCommand` view function +- `dockerManager/urls.py` - Added URL pattern for command execution + +### Frontend Files +- `dockerManager/templates/dockerManager/viewContainer.html` - Added UI components +- `dockerManager/static/dockerManager/dockerManager.js` - Added JavaScript functionality + +## API Endpoint + +**POST** `/docker/executeContainerCommand` + +**Request Body:** +```json +{ + "name": "container_name", + "command": "command_to_execute" +} +``` + +**Response:** +```json +{ + "commandStatus": 1, + "error_message": "None", + "output": "command_output", + "exit_code": 0, + "command": "executed_command" +} +``` + +## Troubleshooting + +### Common Issues +1. **"Container must be running"** - Start the container first +2. **"Permission denied"** - Ensure you have admin access +3. **"Command not found"** - Check if the command exists in the container +4. **Empty output** - Some commands may not produce visible output + +### Debugging +- Check container logs for additional information +- Verify the container's base image supports the command +- Ensure proper command syntax for the container's shell + +## Future Enhancements +- Interactive terminal mode +- Command templates for common tasks +- Output filtering and search +- Command scheduling +- Multi-container command execution + +## Security Notes +- This feature should only be used by trusted administrators +- Commands are executed with the container's user permissions +- Consider implementing additional logging for audit purposes +- Monitor command execution for security compliance + +## Testing with Various Applications +1. Pull any Docker image (e.g., `ubuntu:latest`, `alpine:latest`, `nginx:latest`) +2. Create a container with the image +3. Start the container +4. Use the "Run Command" feature to execute various commands: + - `ls -la` - List files + - `ps aux` - Show processes + - `whoami` - Check user + - `env` - View environment +5. Verify commands execute properly and output is displayed correctly + +This feature provides a secure and user-friendly way to execute commands in Docker containers directly from the CyberPanel interface, making it easy to manage applications like Honeygain that require specific command-line arguments. diff --git a/guides/INDEX.md b/guides/INDEX.md new file mode 100644 index 000000000..6df7c3900 --- /dev/null +++ b/guides/INDEX.md @@ -0,0 +1,57 @@ +# πŸ“š CyberPanel Guides & Documentation + +Welcome to the CyberPanel documentation hub! This folder contains all guides, tutorials, and documentation for CyberPanel features and integrations. + +## πŸ“‹ Available Guides + +### 🐳 Docker Management +- **[Docker Command Execution Guide](Docker_Command_Execution_Guide.md)** - Learn how to execute commands inside Docker containers directly from the CyberPanel interface +- **[Docker Testing Guide](Test_Honeygain_Integration.md)** - Comprehensive testing guide for Docker command execution with various applications + +### πŸ€– AI & Security +- **[AI Scanner Documentation](AIScannerDocs.md)** - Complete guide for CyberPanel's AI-powered security scanner + +### πŸ“§ Email & Marketing +- **[Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md)** - Step-by-step guide for installing and configuring Mautic email marketing platform + +### πŸ“– General Documentation +- **[README](../README.md)** - Main CyberPanel documentation with installation instructions and feature overview +- **[Contributing Guide](CONTRIBUTING.md)** - Guidelines for contributing to the CyberPanel project + +## πŸš€ Quick Start + +1. **New to CyberPanel?** Start with the [README](../README.md) for installation and basic setup +2. **Need Docker help?** Check the [Docker Command Execution Guide](Docker_Command_Execution_Guide.md) +3. **Setting up email marketing?** Follow the [Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md) +4. **Want to contribute?** Read the [Contributing Guide](CONTRIBUTING.md) + +## πŸ” Finding What You Need + +- **Installation & Setup**: [README](../README.md) +- **Docker Features**: [Docker Command Execution Guide](Docker_Command_Execution_Guide.md) +- **Security Features**: [AI Scanner Documentation](AIScannerDocs.md) +- **Email Marketing**: [Mautic Installation Guide](MAUTIC_INSTALLATION_GUIDE.md) +- **Development**: [Contributing Guide](CONTRIBUTING.md) + +## πŸ“ Guide Categories + +### πŸ› οΈ **Core Features** +- Docker container management +- Command execution +- Security scanning + +### πŸ”§ **Integrations** +- Mautic email marketing +- Third-party applications +- Custom configurations + +### πŸ“– **Documentation** +- Installation guides +- Configuration tutorials +- Troubleshooting tips + +--- + +*Last updated: September 2025* + +*For the latest updates and community support, visit [community.cyberpanel.net](https://community.cyberpanel.net)* diff --git a/MAUTIC_INSTALLATION_GUIDE.md b/guides/MAUTIC_INSTALLATION_GUIDE.md similarity index 100% rename from MAUTIC_INSTALLATION_GUIDE.md rename to guides/MAUTIC_INSTALLATION_GUIDE.md From ef89effb805313fb3b0867035f25e9b89baec2f4 Mon Sep 17 00:00:00 2001 From: Master3395 Date: Fri, 5 Sep 2025 01:15:44 +0200 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 821334b65..d95047b3e 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Web Hosting Control Panel powered by OpenLiteSpeed, designed to simplify hosting - πŸ“§ **Email Support** (SnappyMail). - πŸ•Œ **File Manager** for quick file access. - 🌐 **PHP Management** made easy. -- πŸ”’ **Firewall** (Òœ… FirewallD & ConfigServer Firewall Integration). +- πŸ”’ **Firewall** (FirewallD & ConfigServer Firewall Integration). - πŸ“€ **One-click Backups and Restores**. - 🐳 **Docker Management** with command execution capabilities. - πŸ€– **AI-Powered Security Scanner** for enhanced protection. From c49200cca00e38a999f8f02357d07e414ddd4ce0 Mon Sep 17 00:00:00 2001 From: Master3395 Date: Sun, 7 Sep 2025 20:40:29 +0200 Subject: [PATCH 4/7] Resolve issue 1493 Should solve the issue in https://github.com/usmannasir/cyberpanel/issues/1493 --- cyberpanel.sh | 2 +- install/venvsetup.sh | 2 +- install/venvsetup.sh.bak | 2 +- static/filemanager/mode/apl/index.html | 4 +++- static/filemanager/mode/cobol/index.html | 9 ++++++--- static/filemanager/mode/cypher/index.html | 5 ++++- static/filemanager/mode/ecl/index.html | 4 +++- static/filemanager/mode/eiffel/index.html | 4 +++- static/filemanager/mode/erlang/index.html | 4 +++- static/filemanager/mode/javascript/index.html | 4 +++- static/filemanager/mode/lua/index.html | 4 +++- static/filemanager/mode/php/index.html | 4 +++- static/filemanager/mode/python/index.html | 6 ++++-- static/filemanager/mode/soy/index.html | 4 +++- static/filemanager/mode/sparql/index.html | 2 ++ 15 files changed, 43 insertions(+), 17 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 5a5919bcd..afb9b32fa 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -2259,7 +2259,7 @@ chmod 600 /etc/cyberpanel/adminPass /usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$Admin_Pass" mkdir -p /etc/opendkim -echo '/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password $@' > /usr/bin/adminPass +echo '/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$@"' > /usr/bin/adminPass echo "systemctl restart lscpd" >> /usr/bin/adminPass echo "echo \$@ > /etc/cyberpanel/adminPass" >> /usr/bin/adminPass chmod 700 /usr/bin/adminPass diff --git a/install/venvsetup.sh b/install/venvsetup.sh index 4d0124b82..bf7cf31e5 100644 --- a/install/venvsetup.sh +++ b/install/venvsetup.sh @@ -1023,7 +1023,7 @@ echo "$ADMIN_PASS" > /etc/cyberpanel/adminPass /usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password $ADMIN_PASS systemctl restart lscpd systemctl restart lsws -echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \$@" > /usr/bin/adminPass +echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \"\$@\"" > /usr/bin/adminPass echo "systemctl restart lscpd" >> /usr/bin/adminPass chmod +x /usr/bin/adminPass if [[ $VERSION = "OLS" ]] ; then diff --git a/install/venvsetup.sh.bak b/install/venvsetup.sh.bak index 959d69ab0..15f884263 100644 --- a/install/venvsetup.sh.bak +++ b/install/venvsetup.sh.bak @@ -1012,7 +1012,7 @@ echo "$ADMIN_PASS" > /etc/cyberpanel/adminPass /usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password $ADMIN_PASS systemctl restart lscpd systemctl restart lsws -echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \$@" > /usr/bin/adminPass +echo "/usr/local/CyberPanel/bin/python2 /usr/local/CyberCP/plogical/adminPass.py --password \"\$@\"" > /usr/bin/adminPass echo "systemctl restart lscpd" >> /usr/bin/adminPass chmod +x /usr/bin/adminPass if [[ $VERSION = "OLS" ]] ; then diff --git a/static/filemanager/mode/apl/index.html b/static/filemanager/mode/apl/index.html index 81cef4915..a8e5f5590 100644 --- a/static/filemanager/mode/apl/index.html +++ b/static/filemanager/mode/apl/index.html @@ -1,7 +1,9 @@ + CodeMirror: APL mode + @@ -27,7 +29,7 @@

APL mode

-