diff --git a/README.md b/README.md index cbe86b132..ab5ee0242 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 Integration with One-Click IP Blocking). - 📀 **One-click Backups and Restores**. - 🐳 **Docker Management** with command execution capabilities. - 🤖 **AI-Powered Security Scanner** for enhanced protection. @@ -31,6 +31,7 @@ CyberPanel comes with comprehensive documentation and step-by-step guides: - 🤖 **[AI Scanner Setup](guides/AIScannerDocs.md)** - Configure AI-powered security scanning - 📧 **[Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md)** - Email marketing platform setup - 🎨 **[Custom CSS Guide](guides/CUSTOM_CSS_GUIDE.md)** - Create custom themes for CyberPanel 2.5.5-dev +- 🛡️ **[Firewall Blocking Feature](guides/FIREWALL_BLOCKING_FEATURE.md)** - One-click IP blocking from dashboard --- @@ -163,6 +164,7 @@ sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgr - 🤖 [AI Scanner Setup](guides/AIScannerDocs.md) - Configure AI-powered security scanning - 📧 [Mautic Installation](guides/MAUTIC_INSTALLATION_GUIDE.md) - Email marketing platform setup - 🎨 [Custom CSS Guide](guides/CUSTOM_CSS_GUIDE.md) - Create custom themes for CyberPanel 2.5.5+ +- 🛡️ [Firewall Blocking Feature](guides/FIREWALL_BLOCKING_FEATURE.md) - One-click IP blocking from dashboard - 📚 [All Guides Index](guides/INDEX.md) - Complete documentation hub ### 🔗 **Direct Guide Links** @@ -171,6 +173,7 @@ sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgr | ------------ | ---------------------------------------------------------- | ---------------------------------- | | 🐳 Docker | [Command Execution](guides/Docker_Command_Execution_Guide.md) | Execute commands in containers | | 🤖 Security | [AI Scanner](guides/AIScannerDocs.md) | AI-powered security scanning | +| 🛡️ Firewall | [Firewall Blocking Feature](guides/FIREWALL_BLOCKING_FEATURE.md) | One-click IP blocking from dashboard | | 📧 Email | [Mautic Setup](guides/MAUTIC_INSTALLATION_GUIDE.md) | Email marketing platform | | 🎨 Design | [Custom CSS Guide](guides/CUSTOM_CSS_GUIDE.md) | Create custom themes for 2.5.5-dev | | 📊 Bandwidth | [Reset Fix Guide](to-do/cyberpanel-bandwidth-reset-fix.md) | Fix bandwidth reset issues | diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js index 63c4e4e42..3d5c7bcd6 100644 --- a/baseTemplate/static/baseTemplate/custom-js/system-status.js +++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js @@ -980,6 +980,10 @@ app.controller('dashboardStatsController', function ($scope, $http, $timeout) { $scope.showAddonRequired = false; $scope.addonInfo = {}; + // IP Blocking functionality + $scope.blockingIP = null; + $scope.blockedIPs = {}; + $scope.analyzeSSHSecurity = function() { $scope.loadingSecurityAnalysis = true; $scope.showAddonRequired = false; @@ -999,6 +1003,64 @@ app.controller('dashboardStatsController', function ($scope, $http, $timeout) { $scope.loadingSecurityAnalysis = false; }); }; + + $scope.blockIPAddress = function(ipAddress) { + if (!$scope.blockingIP) { + $scope.blockingIP = ipAddress; + + var data = { + ip_address: ipAddress + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post('/base/blockIPAddress', data, config).then(function (response) { + $scope.blockingIP = null; + if (response.data && response.data.status === 1) { + // Mark IP as blocked + $scope.blockedIPs[ipAddress] = true; + + // Show success notification + new PNotify({ + title: 'Success', + text: `IP address ${ipAddress} has been blocked successfully using ${response.data.firewall.toUpperCase()}`, + type: 'success', + delay: 5000 + }); + + // Refresh security analysis to update alerts + $scope.analyzeSSHSecurity(); + } else { + // Show error notification + new PNotify({ + title: 'Error', + text: response.data && response.data.error ? response.data.error : 'Failed to block IP address', + type: 'error', + delay: 5000 + }); + } + }, function (err) { + $scope.blockingIP = null; + var errorMessage = 'Failed to block IP address'; + if (err.data && err.data.error) { + errorMessage = err.data.error; + } else if (err.data && err.data.message) { + errorMessage = err.data.message; + } + + new PNotify({ + title: 'Error', + text: errorMessage, + type: 'error', + delay: 5000 + }); + }); + } + }; // Initial fetch $scope.refreshTopProcesses(); diff --git a/baseTemplate/templates/baseTemplate/homePage.html b/baseTemplate/templates/baseTemplate/homePage.html index d6b4409c2..5523d03d3 100644 --- a/baseTemplate/templates/baseTemplate/homePage.html +++ b/baseTemplate/templates/baseTemplate/homePage.html @@ -663,6 +663,23 @@ Recommendation:

{$ alert.recommendation $}

+ +
+ + + Blocked + +
SSH Security Analysis") + print("3. Look for 'Brute Force Attack Detected' alerts") + print("4. Click the 'Block IP' button next to malicious IPs") + print() + + print("Expected behavior:") + print("- Button shows loading state during blocking") + print("- Success notification appears on successful blocking") + print("- IP is marked as 'Blocked' in the interface") + print("- Security analysis refreshes to update alerts") + print() + + print("Firewall Commands:") + print("- firewalld: firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address= drop'") + print("- firewalld reload: firewall-cmd --reload") + print() + +if __name__ == "__main__": + test_firewall_blocking()