Update Language Files

This commit is contained in:
usmannasir
2018-08-10 23:29:10 +05:00
parent bd4dbe894c
commit 254e4976d4
22 changed files with 26771 additions and 19303 deletions

View File

@@ -0,0 +1,10 @@
/*!
Author : Hunter Perrin
Version : 3.2.0
Link : http://sciactive.com/pnotify/
*/.ui-pnotify{top:36px;right:36px;position:absolute;height:auto;z-index:2}body>.ui-pnotify{position:fixed;z-index:100040}.ui-pnotify-modal-overlay{background-color:rgba(0,0,0,.4);top:0;left:0;position:absolute;height:100%;width:100%;z-index:1}body>.ui-pnotify-modal-overlay{position:fixed;z-index:100039}.ui-pnotify.ui-pnotify-in{display:block!important}.ui-pnotify.ui-pnotify-move{transition:left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-slow{transition:opacity .4s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-slow.ui-pnotify.ui-pnotify-move{transition:opacity .4s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-normal{transition:opacity .25s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-normal.ui-pnotify.ui-pnotify-move{transition:opacity .25s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-fast{transition:opacity .1s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-fast.ui-pnotify.ui-pnotify-move{transition:opacity .1s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-in{opacity:1}.ui-pnotify .ui-pnotify-shadow{-webkit-box-shadow:0 6px 28px 0 rgba(0,0,0,.1);-moz-box-shadow:0 6px 28px 0 rgba(0,0,0,.1);box-shadow:0 6px 28px 0 rgba(0,0,0,.1)}.ui-pnotify-container{background-position:0 0;padding:.8em;height:100%;margin:0}.ui-pnotify-container:after{content:" ";visibility:hidden;display:block;height:0;clear:both}.ui-pnotify-container.ui-pnotify-sharp{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-pnotify-title{display:block;margin-bottom:.4em;margin-top:0}.ui-pnotify-text{display:block}.ui-pnotify-icon,.ui-pnotify-icon span{display:block;float:left;margin-right:.2em}.ui-pnotify.stack-bottomleft,.ui-pnotify.stack-topleft{left:25px;right:auto}.ui-pnotify.stack-bottomleft,.ui-pnotify.stack-bottomright{bottom:25px;top:auto}.ui-pnotify.stack-modal{left:50%;right:auto;margin-left:-150px}
.brighttheme{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.brighttheme.ui-pnotify-container{padding:18px}.brighttheme .ui-pnotify-title{margin-bottom:12px}.brighttheme-notice{background-color:#ffffa2;border:0 solid #ff0;color:#4f4f00}.brighttheme-info{background-color:#8fcedd;border:0 solid #0286a5;color:#012831}.brighttheme-success{background-color:#aff29a;border:0 solid #35db00;color:#104300}.brighttheme-error{background-color:#ffaba2;background-image:repeating-linear-gradient(135deg,transparent,transparent 35px,rgba(255,255,255,.3) 35px,rgba(255,255,255,.3) 70px);border:0 solid #ff1800;color:#4f0800}.brighttheme-icon-closer,.brighttheme-icon-info,.brighttheme-icon-notice,.brighttheme-icon-sticker,.brighttheme-icon-success{position:relative;width:16px;height:16px;font-size:12px;font-weight:700;line-height:16px;font-family:"Courier New",Courier,monospace;border-radius:50%}.brighttheme-icon-closer:after,.brighttheme-icon-info:after,.brighttheme-icon-notice:after,.brighttheme-icon-sticker:after,.brighttheme-icon-success:after{position:absolute;top:0;left:4px}.brighttheme-icon-notice{background-color:#2e2e00;color:#ffffa2;margin-top:2px}.brighttheme-icon-notice:after{content:"!"}.brighttheme-icon-info{background-color:#012831;color:#8fcedd;margin-top:2px}.brighttheme-icon-info:after{content:"i"}.brighttheme-icon-success{background-color:#104300;color:#aff29a;margin-top:2px}.brighttheme-icon-success:after{content:"\002713"}.brighttheme-icon-error{position:relative;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:16px solid #2e0400;font-size:0;line-height:0;color:#ffaba2;margin-top:1px}.brighttheme-icon-error:after{position:absolute;top:1px;left:-4px;font-size:12px;font-weight:700;line-height:16px;font-family:"Courier New",Courier,monospace;content:"!"}.brighttheme-icon-closer,.brighttheme-icon-sticker{display:inline-block}.brighttheme-icon-closer:after{top:-4px;content:"\002715"}.brighttheme-icon-sticker:after{top:-5px;content:"\01D1BC";-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);-o-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.brighttheme-icon-sticker.brighttheme-icon-stuck:after{-moz-transform:rotate(180deg);-webkit-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.brighttheme .ui-pnotify-action-bar{padding-top:12px}.brighttheme .ui-pnotify-action-bar input,.brighttheme .ui-pnotify-action-bar textarea{display:block;width:100%;margin-bottom:12px!important}.brighttheme .ui-pnotify-action-button{text-transform:uppercase;font-weight:700;padding:4px 8px;border:none;background:0 0}.brighttheme .ui-pnotify-action-button.btn-primary{border:none;border-radius:0}.brighttheme-notice .ui-pnotify-action-button.btn-primary{background-color:#ff0;color:#4f4f00}.brighttheme-info .ui-pnotify-action-button.btn-primary{background-color:#0286a5;color:#012831}.brighttheme-success .ui-pnotify-action-button.btn-primary{background-color:#35db00;color:#104300}.brighttheme-error .ui-pnotify-action-button.btn-primary{background-color:#ff1800;color:#4f0800}
.ui-pnotify-closer,.ui-pnotify-sticker{float:right;margin-left:.2em}
.ui-pnotify-history-container{position:absolute;top:0;right:18px;width:70px;border-top:none;padding:0;-webkit-border-top-left-radius:0;-moz-border-top-left-radius:0;border-top-left-radius:0;-webkit-border-top-right-radius:0;-moz-border-top-right-radius:0;border-top-right-radius:0;z-index:10000}.ui-pnotify-history-container.ui-pnotify-history-fixed{position:fixed}.ui-pnotify-history-container .ui-pnotify-history-header{padding:2px;text-align:center}.ui-pnotify-history-container button{cursor:pointer;display:block;width:100%}.ui-pnotify-history-container .ui-pnotify-history-pulldown{display:block;margin:0 auto}.ui-pnotify-history-brighttheme{background-color:#8fcedd;border:0 solid #0286a5;color:#012831}.ui-pnotify-history-brighttheme button{text-transform:uppercase;font-weight:700;padding:4px 8px;border:none;background:0 0}.ui-pnotify-history-brighttheme .ui-pnotify-history-pulldown::after{display:block;font-size:16px;line-height:14px;padding-bottom:4px;content:"⌄";text-align:center;font-weight:700;font-family:Arial,sans-serif}
.ui-pnotify-container{position:relative;left:0}@media (max-width:480px){.ui-pnotify-mobile-able.ui-pnotify{position:fixed;top:0;right:0;left:0;width:auto!important;font-size:1.2em;-webkit-font-smoothing:antialiased;-moz-font-smoothing:antialiased;-ms-font-smoothing:antialiased;font-smoothing:antialiased}.ui-pnotify-mobile-able.ui-pnotify .ui-pnotify-shadow{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;border-bottom-width:5px}.ui-pnotify-mobile-able .ui-pnotify-container{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft,.ui-pnotify-mobile-able.ui-pnotify.stack-topleft{left:0;right:0}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft,.ui-pnotify-mobile-able.ui-pnotify.stack-bottomright{left:0;right:0;bottom:0;top:auto}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft .ui-pnotify-shadow,.ui-pnotify-mobile-able.ui-pnotify.stack-bottomright .ui-pnotify-shadow{border-top-width:5px;border-bottom-width:1px}}
.ui-pnotify.ui-pnotify-nonblock-fade{opacity:.2}.ui-pnotify.ui-pnotify-nonblock-hide{display:none!important}

File diff suppressed because one or more lines are too long

View File

@@ -42,7 +42,7 @@
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/layout.css"> <link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/layout.css">
<link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/color-schemes/default.css"> <link rel="stylesheet" type="text/css" href="/static/baseTemplate/assets/themes/admin/color-schemes/default.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/custom-js/pnotify.custom.min.css' %}">
<!-- Components theme, component below was above three CSS files. --> <!-- Components theme, component below was above three CSS files. -->
@@ -544,6 +544,7 @@
<li><a href="{% url 'modSecurity' %}" title="{% trans 'ModSecurity Configurations' %}"><span>{% trans "ModSecurity Conf" %}</span></a></li> <li><a href="{% url 'modSecurity' %}" title="{% trans 'ModSecurity Configurations' %}"><span>{% trans "ModSecurity Conf" %}</span></a></li>
<li><a href="{% url 'modSecRules' %}" title="{% trans 'ModSecurity Rules' %}"><span>{% trans "ModSecurity Rules" %}</span></a></li> <li><a href="{% url 'modSecRules' %}" title="{% trans 'ModSecurity Rules' %}"><span>{% trans "ModSecurity Rules" %}</span></a></li>
<li><a href="{% url 'modSecRulesPacks' %}" title="{% trans 'ModSecurity Rules Packs' %}"><span>{% trans "ModSecurity Rules Packs" %}</span></a></li> <li><a href="{% url 'modSecRulesPacks' %}" title="{% trans 'ModSecurity Rules Packs' %}"><span>{% trans "ModSecurity Rules Packs" %}</span></a></li>
<li><a href="{% url 'csf' %}" title="{% trans 'ConfigServer Security & Firewall (CSF)' %}"><span>{% trans "CSF" %}</span></a></li>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -608,7 +609,7 @@
<!-- Sparklines charts --> <!-- Sparklines charts -->
<script src="{% static 'baseTemplate/custom-js/pnotify.custom.min.js' %}"></script>
<script src="{% static 'baseTemplate/custom-js/system-status.js' %}"></script> <script src="{% static 'baseTemplate/custom-js/system-status.js' %}"></script>
<script src="{% static 'packages/packages.js' %}"></script> <script src="{% static 'packages/packages.js' %}"></script>
<script src="{% static 'websiteFunctions/websiteFunctions.js' %}"></script> <script src="{% static 'websiteFunctions/websiteFunctions.js' %}"></script>

View File

@@ -1583,7 +1583,7 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
$scope.installCSF = function(){ $scope.installCSF = function(){
$scope.modSecNotifyBox = true; $scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = true; $scope.modeSecInstallBox = false;
$scope.modsecLoading = false; $scope.modsecLoading = false;
$scope.failedToStartInallation = true; $scope.failedToStartInallation = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
@@ -1645,7 +1645,6 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
} }
}; };
function getRequestStatus(){ function getRequestStatus(){
$scope.modSecNotifyBox = true; $scope.modSecNotifyBox = true;
@@ -1703,7 +1702,7 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
}else{ }else{
$scope.modSecSuccessfullyInstalled = false; $scope.modSecSuccessfullyInstalled = false;
//$timeout(function() { $window.location.reload(); }, 3000); $timeout(function() { $window.location.reload(); }, 3000);
} }
} }
@@ -1724,4 +1723,396 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
} }
// After installation
var currentMain = "generalLI";
var currentChild = "general";
$scope.activateTab = function (newMain, newChild) {
$("#"+currentMain).removeClass("ui-tabs-active");
$("#"+currentMain).removeClass("ui-state-active");
$("#"+newMain).addClass("ui-tabs-active");
$("#"+newMain).addClass("ui-state-active");
$('#'+currentChild).hide();
$('#'+newChild).show();
currentMain = newMain;
currentChild = newChild;
};
$scope.removeCSF = function(){
$scope.csfLoading = false;
url = "/firewall/removeCSF";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.installStatus === 1){
new PNotify({
title: 'Successfully removed!',
text: 'CSF successfully removed from server, refreshing page in 3 seconds..',
type:'success'
});
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
new PNotify({
title: 'Operation failed!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
new PNotify({
title: 'Operation failed!',
text: 'Could not connect to server, please refresh this page.',
type:'error'
});
}
};
//////// Fetch settings
//
var testingMode = false;
var testingCounter = 0;
$('#testingMode').change(function() {
testingMode = $(this).prop('checked');
if(testingCounter !== 0) {
if (testingMode === true) {
$scope.changeStatus('testingMode', 'enable');
} else {
$scope.changeStatus('testingMode', 'disable');
}
}
testingCounter = testingCounter + 1;
});
//
//
var firewallStatus = false;
var firewallCounter = 0;
$('#firewallStatus').change(function() {
firewallStatus = $(this).prop('checked');
if(firewallCounter !== 0) {
if (firewallStatus === true) {
$scope.changeStatus('csf', 'enable');
} else {
$scope.changeStatus('csf', 'disable');
}
}
firewallCounter = firewallCounter + 1;
});
//
$scope.fetchSettings = function(){
$scope.csfLoading = false;
$('#testingMode').bootstrapToggle('off');
$('#firewallStatus').bootstrapToggle('off');
url = "/firewall/fetchCSFSettings";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.fetchStatus === 1){
new PNotify({
title: 'Successfully fetched!',
text: 'CSF settings successfully fetched.',
type:'success'
});
if (response.data.testingMode === 1) {
$('#testingMode').bootstrapToggle('on');
}
if (response.data.firewallStatus === 1) {
$('#firewallStatus').bootstrapToggle('on');
}
$scope.tcpIN = response.data.tcpIN;
$scope.tcpOUT = response.data.tcpOUT;
$scope.udpIN = response.data.udpIN;
$scope.udpOUT = response.data.udpOUT;
}else{
new PNotify({
title: 'Failed to load!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.fetchSettings();
$scope.changeStatus = function(controller, status){
$scope.csfLoading = false;
url = "/firewall/changeStatus";
var data = {
controller: controller,
status : status
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.modifyPorts = function(protocol){
$scope.csfLoading = false;
var ports;
if(protocol === 'TCP_IN'){
ports = $scope.tcpIN;
}else if(protocol === 'TCP_OUT'){
ports = $scope.tcpOUT;
}else if(protocol === 'UDP_IN'){
ports = $scope.udpIN;
}else if(protocol === 'UDP_OUT'){
ports = $scope.udpOUT;
}
url = "/firewall/modifyPorts";
var data = {
protocol: protocol,
ports : ports
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.modifyIPs = function(mode){
$scope.csfLoading = false;
var ipAddress;
if(mode === 'allowIP'){
ipAddress = $scope.allowIP;
}else if(mode === 'blockIP'){
ipAddress = $scope.blockIP;
}
url = "/firewall/modifyIPs";
var data = {
mode: mode,
ipAddress : ipAddress
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
}); });

View File

@@ -8,13 +8,14 @@
<!-- Current language: {{ LANGUAGE_CODE }} --> <!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container"> <div ng-controller="csf" class="container">
<div id="page-title"> <div id="page-title">
<h2>{% trans "CSF (ConfigServer Security and Firewall)!" %}</h2> <h2>{% trans "CSF (ConfigServer Security and Firewall)!" %}</h2>
<p>{% trans "On this page you can configure CSF (ConfigServer Security and Firewall) settings." %}</p> <p>{% trans "On this page you can configure CSF (ConfigServer Security and Firewall) settings." %}</p>
</div> </div>
<div ng-controller="csf" class="example-box-wrapper"> {% if csfInstalled == 0 %}
<div class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box"> <div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue"> <h3 class="content-box-header bg-blue">
{% trans "CSF" %} <img ng-hide="csfLoading" src="/static/images/loading.gif"> {% trans "CSF" %} <img ng-hide="csfLoading" src="/static/images/loading.gif">
@@ -23,8 +24,6 @@
<div class="content-box-wrapper"> <div class="content-box-wrapper">
<div class="row"> <div class="row">
{% if csfInstalled == 0 %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;"> <div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "CSF is not installed " %} <h3>{% trans "CSF is not installed " %}
<button ng-click="installCSF()" class="btn btn-alt btn-hover btn-blue-alt"> <button ng-click="installCSF()" class="btn btn-alt btn-hover btn-blue-alt">
@@ -74,124 +73,138 @@
<!----- ModeSec Install Log box -----------------> <!----- ModeSec Install Log box ----------------->
{% else %}
<div style="padding: 2%" class="col-md-12">
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">ModSecurity Status</label>
<div class="col-sm-6">
<input type="checkbox" id="modsecurity_status" data-toggle="toggle">
</div>
</div>
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">SecAuditEngine</label>
<div class="col-sm-6">
<input type="checkbox" id="SecAuditEngine" data-toggle="toggle">
</div>
</div>
<div ng-hide="phpDetailsBox" class="form-group">
<label class="col-sm-4 control-label">SecRuleEngine</label>
<div class="col-sm-6">
<input type="checkbox" id="SecRuleEngine" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecDebugLogLevel</label>
<div class="col-sm-6">
<div class="selector" style="width: 79px;"><span style="width: 57px; -moz-user-select: none;">{$ SecDebugLogLevel $}</span><select ng-model="SecDebugLogLevel" class="custom-select">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select><i class="glyph-icon icon-caret-down"></i></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogParts</label>
<div class="col-sm-6">
<div class="selector" style="width: 79px;"><span style="width: 57px; -moz-user-select: none;">{$ SecAuditLogParts $}</span><select ng-model="SecAuditLogParts" class="custom-select">
<option>A</option>
<option>AB</option>
<option>ABI</option>
<option>ABIJ</option>
<option>ABIJD</option>
<option>ABIJDE</option>
<option>ABIJDEF</option>
<option>ABIJDEFH</option>
<option>ABIJDEFHZ</option>
</select><i class="glyph-icon icon-caret-down"></i></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogRelevantStatus</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="SecAuditLogRelevantStatus" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">SecAuditLogType</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="SecAuditLogType" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveModSecConfigurations()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="failedToSave" class="alert alert-danger">
<p>{% trans "Failed to save ModSecurity configurations. Error message: " %} {$ errorMessage $}</p>
</div>
<div ng-hide="successfullySaved" class="alert alert-success">
<p>{% trans "ModSecurity configurations successfully saved." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
</div>
</div>
</form>
</div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% else %}
<div class="example-box-wrapper">
<div class="content-box tabs ui-tabs ui-widget ui-widget-content ui-corner-all">
<h3 class="content-box-header bg-blue">
<span>{% trans 'CSF' %} <img ng-hide="csfLoading" src="/static/images/loading.gif"></span>
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
<li ng-click="activateTab('generalLI', 'general')" id="generalLI" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="tabs-example-1" aria-labelledby="ui-id-22" aria-selected="true" aria-expanded="true">
<a ng-click="activateTab('generalLI', 'general')" href="" title="Tab 1" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-22">
{% trans 'General' %}
</a>
</li>
<li ng-click="activateTab('csfLI', 'csf')" id="csfLI" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tabs-example-2" aria-labelledby="ui-id-23" aria-selected="false" aria-expanded="false">
<a href="" ng-click="activateTab('csfLI', 'csf')" title="Tab 2" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-23">
{% trans 'CSF' %}
</a>
</li>
<li id="lfdLI" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tabs-example-3" aria-labelledby="ui-id-24" aria-selected="false" aria-expanded="false">
<a href="" ng-click="activateTab('lfdLI', 'lfd')" title="Tab 3" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-24">
{% trans 'LFD' %}
</a>
</li>
</ul>
</h3>
<div id="general" aria-labelledby="ui-id-22" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="false">
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-4 control-label">{% trans 'Remove CSF' %}</label>
<div class="col-sm-6">
<button type="button" ng-click="removeCSF()" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans 'Completely Remove CSF' %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans 'Firewall' %}</label>
<div class="col-sm-6">
<input type="checkbox" id="firewallStatus" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans 'Testing Mode' %}</label>
<div class="col-sm-6">
<input type="checkbox" id="testingMode" data-toggle="toggle">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "TCP IN Ports" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="tcpIN">
</div>
<button type="button" ng-click="modifyPorts('TCP_IN')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "TCP Out Ports" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="tcpOUT">
</div>
<button type="button" ng-click="modifyPorts('TCP_OUT')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "UDP In Ports" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="udpIN">
</div>
<button type="button" ng-click="modifyPorts('UDP_IN')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "UDP Out Ports" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="udpOUT">
</div>
<button ng-click="modifyPorts('UDP_OUT')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
</form>
</div>
<div id="csf" aria-labelledby="ui-id-23" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="true" style="display: none;">
<form action="/" id="createPackages" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "Allow IP" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="allowIP">
</div>
<button type="button" ng-click="modifyIPs('allowIP')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">{% trans "Block IP Address" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="blockIP">
</div>
<button type="button" ng-click="modifyIPs('blockIP')" class="btn btn-round btn-blue-alt">
<i class="glyph-icon icon-save"></i>
</button>
</div>
</form>
</div>
<div id="lfd" aria-labelledby="ui-id-24" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="true" style="display: none;">
{% trans 'Comming Soon.' %}
</div>
</div>
</div>
{% endif %}
</div> </div>

View File

@@ -25,25 +25,31 @@ urlpatterns = [
## ModSecurity ## ModSecurity
url(r'^modSecurity', views.loadModSecurityHome, name='modSecurity'), url(r'^modSecurity$', views.loadModSecurityHome, name='modSecurity'),
url(r'^installModSec$', views.installModSec, name='installModSec'), url(r'^installModSec$', views.installModSec, name='installModSec'),
url(r'^installStatusModSec$', views.installStatusModSec, name='installStatusModSec'), url(r'^installStatusModSec$', views.installStatusModSec, name='installStatusModSec'),
url(r'^fetchModSecSettings', views.fetchModSecSettings, name='fetchModSecSettings'), url(r'^fetchModSecSettings$', views.fetchModSecSettings, name='fetchModSecSettings'),
url(r'^saveModSecConfigurations', views.saveModSecConfigurations, name='saveModSecConfigurations'), url(r'^saveModSecConfigurations$', views.saveModSecConfigurations, name='saveModSecConfigurations'),
url(r'^modSecRules$', views.modSecRules, name='modSecRules'), url(r'^modSecRules$', views.modSecRules, name='modSecRules'),
url(r'^fetchModSecRules', views.fetchModSecRules, name='fetchModSecRules'), url(r'^fetchModSecRules$', views.fetchModSecRules, name='fetchModSecRules'),
url(r'^saveModSecRules', views.saveModSecRules, name='saveModSecRules'), url(r'^saveModSecRules$', views.saveModSecRules, name='saveModSecRules'),
url(r'^modSecRulesPacks', views.modSecRulesPacks, name='modSecRulesPacks'), url(r'^modSecRulesPacks$', views.modSecRulesPacks, name='modSecRulesPacks'),
url(r'^getOWASPAndComodoStatus', views.getOWASPAndComodoStatus, name='getOWASPAndComodoStatus'), url(r'^getOWASPAndComodoStatus$', views.getOWASPAndComodoStatus, name='getOWASPAndComodoStatus'),
url(r'^installModSecRulesPack', views.installModSecRulesPack, name='installModSecRulesPack'), url(r'^installModSecRulesPack$', views.installModSecRulesPack, name='installModSecRulesPack'),
url(r'^getRulesFiles', views.getRulesFiles, name='getRulesFiles'), url(r'^getRulesFiles$', views.getRulesFiles, name='getRulesFiles'),
url(r'^enableDisableRuleFile', views.enableDisableRuleFile, name='enableDisableRuleFile'), url(r'^enableDisableRuleFile$', views.enableDisableRuleFile, name='enableDisableRuleFile'),
## CSF ## CSF
url(r'^csf$', views.csf, name='csf'), url(r'^csf$', views.csf, name='csf'),
url(r'^installCSF$', views.installCSF, name='installModSec'), url(r'^installCSF$', views.installCSF, name='installModSec'),
url(r'^installStatusCSF$', views.installStatusCSF, name='installStatusCSF'), url(r'^installStatusCSF$', views.installStatusCSF, name='installStatusCSF'),
url(r'^removeCSF$', views.removeCSF, name='removeCSF'),
url(r'^fetchCSFSettings$', views.fetchCSFSettings, name='fetchCSFSettings'),
url(r'^changeStatus$', views.changeStatus, name='changeStatus'),
url(r'^modifyPorts$', views.modifyPorts, name='modifyPorts'),
url(r'^modifyIPs$', views.modifyIPs, name='modifyIPs'),

View File

@@ -15,6 +15,7 @@ from plogical.modSec import modSec
from plogical.installUtilities import installUtilities from plogical.installUtilities import installUtilities
from random import randint from random import randint
from plogical.csf import CSF from plogical.csf import CSF
import time
# Create your views here. # Create your views here.
@@ -1150,8 +1151,6 @@ def getOWASPAndComodoStatus(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf')
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath command = "sudo cat " + confPath
@@ -1379,7 +1378,6 @@ def csf(request):
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
def installCSF(request): def installCSF(request):
try: try:
val = request.session['userID'] val = request.session['userID']
@@ -1391,9 +1389,16 @@ def installCSF(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
thread.start_new_thread(CSF.installCSF, ('Install','csf'))
final_json = json.dumps({'installStatus': 1, 'error_message': "None"}) execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
return HttpResponse(final_json) execPath = execPath + " installCSF"
subprocess.Popen(shlex.split(execPath))
time.sleep(2)
data_ret = {"installStatus": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg: except BaseException,msg:
final_dic = {'installStatus': 0, 'error_message': str(msg)} final_dic = {'installStatus': 0, 'error_message': str(msg)}
@@ -1420,6 +1425,9 @@ def installStatusCSF(request):
if installStatus.find("[200]")>-1: if installStatus.find("[200]")>-1:
command = 'sudo rm -f ' + CSF.installLogPath
subprocess.call(shlex.split(command))
final_json = json.dumps({ final_json = json.dumps({
'error_message': "None", 'error_message': "None",
'requestStatus': installStatus, 'requestStatus': installStatus,
@@ -1428,7 +1436,8 @@ def installStatusCSF(request):
}) })
return HttpResponse(final_json) return HttpResponse(final_json)
elif installStatus.find("[404]") > -1: elif installStatus.find("[404]") > -1:
command = 'sudo rm -f ' + CSF.installLogPath
subprocess.call(shlex.split(command))
final_json = json.dumps({ final_json = json.dumps({
'abort':1, 'abort':1,
'installed':0, 'installed':0,
@@ -1455,3 +1464,183 @@ def installStatusCSF(request):
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def removeCSF(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_dic = {'installStatus': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " removeCSF"
subprocess.Popen(shlex.split(execPath))
time.sleep(2)
data_ret = {"installStatus": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
final_dic = {'installStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'installStatus': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def fetchCSFSettings(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_dic = {'fetchStatus': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
currentSettings = CSF.fetchCSFSettings()
data_ret = {"fetchStatus": 1, 'testingMode' : currentSettings['TESTING'],
'tcpIN' : currentSettings['tcpIN'],
'tcpOUT': currentSettings['tcpOUT'],
'udpIN': currentSettings['udpIN'],
'udpOUT': currentSettings['udpOUT'],
'firewallStatus': currentSettings['firewallStatus']
}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'fetchStatus': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def changeStatus(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_dic = {'status': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
data = json.loads(request.body)
controller = data['controller']
status = data['status']
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " changeStatus --controller " + controller + " --status " + status
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'status': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status'
'': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def modifyPorts(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_dic = {'status': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
data = json.loads(request.body)
protocol = data['protocol']
ports = data['ports']
execPath = "sudo " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'status': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status'
'': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def modifyIPs(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
try:
if admin.type != 1:
final_dic = {'status': 0, 'error_message': 'Not enough privileges.'}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
data = json.loads(request.body)
mode = data['mode']
ipAddress = data['ipAddress']
if mode == 'allowIP':
CSF.allowIP(ipAddress)
elif mode == 'blockIP':
CSF.blockIP(ipAddress)
data_ret = {"status": 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status'
'': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

299
plogical/csf.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/local/CyberCP/bin/python2
import CyberCPLogFileWriter as logging import CyberCPLogFileWriter as logging
import subprocess import subprocess
import shlex import shlex
@@ -7,103 +8,287 @@ import os
import tarfile import tarfile
import shutil import shutil
from mailUtilities import mailUtilities from mailUtilities import mailUtilities
import threading as multi
class CSF: class CSF(multi.Thread):
installLogPath = "/home/cyberpanel/csfInstallLog" installLogPath = "/home/cyberpanel/csfInstallLog"
csfURL = 'https://download.configserver.com/csf.tgz' csfURL = 'https://download.configserver.com/csf.tgz'
@staticmethod def __init__(self, installApp, extraArgs):
def installCSF(install, csfInstall): multi.Thread.__init__(self)
self.installApp = installApp
self.extraArgs = extraArgs
def run(self):
try:
if self.installApp == 'installCSF':
self.installCSF()
elif self.installApp == 'removeCSF':
self.removeCSF()
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [CSF.run]')
def installCSF(self):
try: try:
mailUtilities.checkHome() ##
command = 'wget ' + CSF.csfURL
cmd = shlex.split(command)
with open(CSF.installLogPath, 'a') as f:
subprocess.call(cmd, stdout=f)
## ##
command = 'sudo wget ' + CSF.csfURL command = 'tar -xzf csf.tgz'
cmd = shlex.split(command) cmd = shlex.split(command)
with open(CSF.installLogPath, 'w') as f: with open(CSF.installLogPath, 'a') as f:
res = subprocess.call(cmd, stdout=f)
##
command = 'sudo tar -xzf csf.tgz'
cmd = shlex.split(command)
with open(CSF.installLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f) res = subprocess.call(cmd, stdout=f)
## ##
os.chdir('csf') os.chdir('csf')
command = 'sudo ./install.sh' command = './install.sh'
cmd = shlex.split(command) cmd = shlex.split(command)
with open(CSF.installLogPath, 'w') as f: with open(CSF.installLogPath, 'a') as f:
res = subprocess.call(cmd, stdout=f) res = subprocess.call(cmd, stdout=f)
os.chdir('/usr/local/CyberCP') os.chdir('/usr/local/CyberCP')
## Some initial configurations
data = open('/etc/csf/csf.conf', 'r').readlines()
writeToConf = open('/etc/csf/csf.conf', 'w')
for items in data:
if items.find('TCP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToConf.writelines('TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,8090,40110:40210"\n')
elif items.find('TCP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToConf.writelines('TCP_OUT = "20,21,22,25,53,80,110,113,443,587,993,995,8090,40110:40210"\n')
elif items.find('UDP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToConf.writelines('UDP_IN = "20,21,53"\n')
elif items.find('UDP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToConf.writelines('UDP_OUT = "20,21,53,113,123"\n')
else:
writeToConf.writelines(items)
writeToConf.close()
##
command = 'csf -s'
cmd = shlex.split(command)
with open(CSF.installLogPath, 'a') as f:
subprocess.call(cmd, stdout=f)
writeToFile = open(CSF.installLogPath, 'a') writeToFile = open(CSF.installLogPath, 'a')
writeToFile.writelines("CSF successfully Installed.[200]\n") writeToFile.writelines("CSF successfully Installed.[200]\n")
writeToFile.close() writeToFile.close()
command = 'sudo rm -rf csf' os.remove('csf.tgz')
cmd = shlex.split(command) os.removedirs('csf')
res = subprocess.call(cmd)
command = 'sudo rm -f csf.tgz'
cmd = shlex.split(command)
res = subprocess.call(cmd)
return 1 return 1
except BaseException, msg: except BaseException, msg:
command = 'sudo rm -rf csf' os.remove('csf.tgz')
cmd = shlex.split(command) os.removedirs('csf')
res = subprocess.call(cmd) writeToFile = open(CSF.installLogPath, 'a')
writeToFile.writelines(str(msg) + " [404]")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installCSF]")
command = 'sudo rm -f csf.tgz' def removeCSF(self):
cmd = shlex.split(command) try:
res = subprocess.call(cmd)
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installModSec]")
##
os.chdir('/etc/csf')
command = './uninstall.sh'
cmd = shlex.split(command)
subprocess.call(cmd)
os.chdir('/usr/local/CyberCP')
#
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[removeCSF]")
@staticmethod
def fetchCSFSettings():
try:
currentSettings = {}
command = 'sudo cat /etc/csf/csf.conf'
output = subprocess.check_output(shlex.split(command)).splitlines()
for items in output:
if items.find('TESTING') > -1 and items.find('=') > -1 and (items[0]!= '#') and items.find('TESTING_INTERVAL') == -1:
if items.find('0') > -1:
currentSettings['TESTING'] = 0
else:
currentSettings['TESTING'] = 1
elif items.find('TCP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
tcpIN = items[items.find('"'):]
currentSettings['tcpIN'] = tcpIN.strip('"')
elif items.find('TCP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
tcpOUT = items[items.find('"'):]
currentSettings['tcpOUT'] = tcpOUT.strip('"')
elif items.find('UDP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
udpIN = items[items.find('"'):]
currentSettings['udpIN'] = udpIN.strip('"')
elif items.find('UDP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
udpOUT = items[items.find('"'):]
currentSettings['udpOUT'] = udpOUT.strip('"')
### Check if rules are applied
currentSettings['firewallStatus'] = 0
command = 'sudo iptables -nv -L'
output = subprocess.check_output(shlex.split(command))
if output.find('0.0.0.0/0') > -1:
currentSettings['firewallStatus'] = 1
return currentSettings
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[fetchCSFSettings]")
@staticmethod
def changeStatus(controller, status):
try:
if controller == 'csf':
if status == 'enable':
command = 'csf -s'
subprocess.call(shlex.split(command))
print '1,None'
else:
command = 'csf -f'
subprocess.call(shlex.split(command))
print '1,None'
elif controller == 'testingMode':
data = open('/etc/csf/csf.conf', 'r').readlines()
writeToFile = open('/etc/csf/csf.conf', 'w')
for items in data:
if items.find('TESTING') > -1 and items.find('=') > -1 and (items[0] != '#') and items.find(
'TESTING_INTERVAL') == -1:
if status == 'enable':
writeToFile.writelines('TESTING = "1"\n')
else:
writeToFile.writelines('TESTING = "0"\n')
else:
writeToFile.writelines(items)
writeToFile.close()
print '1,None'
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[changeStatus]")
print '0',str(msg)
@staticmethod
def modifyPorts(protocol, ports):
try:
data = open('/etc/csf/csf.conf', 'r').readlines()
writeToFile = open('/etc/csf/csf.conf', 'w')
if protocol == 'TCP_IN':
for items in data:
if items.find('TCP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToFile.writelines('TCP_IN = "' + ports + '"\n')
else:
writeToFile.writelines(items)
writeToFile.close()
elif protocol == 'TCP_OUT':
for items in data:
if items.find('TCP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToFile.writelines('TCP_OUT = "' + ports + '"\n')
else:
writeToFile.writelines(items)
writeToFile.close()
elif protocol == 'UDP_IN':
for items in data:
if items.find('UDP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToFile.writelines('UDP_IN = "' + ports + '"\n')
else:
writeToFile.writelines(items)
writeToFile.close()
elif protocol == 'UDP_OUT':
for items in data:
if items.find('UDP_OUT') > -1 and items.find('=') > -1 and (items[0] != '#'):
writeToFile.writelines('UDP_OUT = "' + ports + '"\n')
else:
writeToFile.writelines(items)
writeToFile.close()
command = 'csf -r'
subprocess.call(shlex.split(command))
print '1,None'
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[modifyPorts]")
print '0', str(msg)
@staticmethod
def allowIP(ipAddress):
try:
command = 'sudo csf -dr ' + ipAddress
subprocess.call(shlex.split(command))
command = 'sudo csf -a ' + ipAddress
subprocess.call(shlex.split(command))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[allowIP]")
@staticmethod
def blockIP(ipAddress):
try:
command = 'sudo csf -tr ' + ipAddress
subprocess.call(shlex.split(command))
command = 'sudo csf -d ' + ipAddress
subprocess.call(shlex.split(command))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")
def main(): def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer') parser = argparse.ArgumentParser(description='CSF Manager')
parser.add_argument('function', help='Specific a function to call!') parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--tempConfigPath', help='Temporary path to configurations data!') parser.add_argument('--controller', help='Controller selection!')
parser.add_argument('--packName', help='ModSecurity supplier name!') parser.add_argument('--status', help='Controller status!')
parser.add_argument('--fileName', help='Filename to enable or disable!') parser.add_argument('--protocol', help='Protocol Modifications!')
parser.add_argument('--ports', help='Ports!')
args = parser.parse_args() args = parser.parse_args()
if args.function == "installModSecConfigs": if args.function == "installCSF":
modSec.installModSecConfigs() controller = CSF(args.function, {})
elif args.function == "saveModSecConfigs": controller.run()
modSec.saveModSecConfigs(args.tempConfigPath) elif args.function == 'removeCSF':
elif args.function == "saveModSecRules": controller = CSF(args.function, {})
modSec.saveModSecRules() controller.run()
elif args.function == "setupOWASPRules": elif args.function == 'changeStatus':
modSec.setupOWASPRules() CSF.changeStatus(args.controller, args.status)
elif args.function == "installOWASP": elif args.function == 'modifyPorts':
modSec.installOWASP() CSF.modifyPorts(args.protocol, args.ports)
elif args.function == "disableOWASP":
modSec.disableOWASP()
elif args.function == "setupComodoRules":
modSec.setupComodoRules()
elif args.function == "installComodo":
modSec.installComodo()
elif args.function == "disableComodo":
modSec.disableComodo()
elif args.function == "disableRuleFile":
modSec.disableRuleFile(args.fileName, args.packName)
elif args.function == "enableRuleFile":
modSec.enableRuleFile(args.fileName, args.packName)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -0,0 +1,10 @@
/*!
Author : Hunter Perrin
Version : 3.2.0
Link : http://sciactive.com/pnotify/
*/.ui-pnotify{top:36px;right:36px;position:absolute;height:auto;z-index:2}body>.ui-pnotify{position:fixed;z-index:100040}.ui-pnotify-modal-overlay{background-color:rgba(0,0,0,.4);top:0;left:0;position:absolute;height:100%;width:100%;z-index:1}body>.ui-pnotify-modal-overlay{position:fixed;z-index:100039}.ui-pnotify.ui-pnotify-in{display:block!important}.ui-pnotify.ui-pnotify-move{transition:left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-slow{transition:opacity .4s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-slow.ui-pnotify.ui-pnotify-move{transition:opacity .4s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-normal{transition:opacity .25s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-normal.ui-pnotify.ui-pnotify-move{transition:opacity .25s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-fast{transition:opacity .1s linear;opacity:0}.ui-pnotify.ui-pnotify-fade-fast.ui-pnotify.ui-pnotify-move{transition:opacity .1s linear,left .5s ease,top .5s ease,right .5s ease,bottom .5s ease}.ui-pnotify.ui-pnotify-fade-in{opacity:1}.ui-pnotify .ui-pnotify-shadow{-webkit-box-shadow:0 6px 28px 0 rgba(0,0,0,.1);-moz-box-shadow:0 6px 28px 0 rgba(0,0,0,.1);box-shadow:0 6px 28px 0 rgba(0,0,0,.1)}.ui-pnotify-container{background-position:0 0;padding:.8em;height:100%;margin:0}.ui-pnotify-container:after{content:" ";visibility:hidden;display:block;height:0;clear:both}.ui-pnotify-container.ui-pnotify-sharp{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-pnotify-title{display:block;margin-bottom:.4em;margin-top:0}.ui-pnotify-text{display:block}.ui-pnotify-icon,.ui-pnotify-icon span{display:block;float:left;margin-right:.2em}.ui-pnotify.stack-bottomleft,.ui-pnotify.stack-topleft{left:25px;right:auto}.ui-pnotify.stack-bottomleft,.ui-pnotify.stack-bottomright{bottom:25px;top:auto}.ui-pnotify.stack-modal{left:50%;right:auto;margin-left:-150px}
.brighttheme{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.brighttheme.ui-pnotify-container{padding:18px}.brighttheme .ui-pnotify-title{margin-bottom:12px}.brighttheme-notice{background-color:#ffffa2;border:0 solid #ff0;color:#4f4f00}.brighttheme-info{background-color:#8fcedd;border:0 solid #0286a5;color:#012831}.brighttheme-success{background-color:#aff29a;border:0 solid #35db00;color:#104300}.brighttheme-error{background-color:#ffaba2;background-image:repeating-linear-gradient(135deg,transparent,transparent 35px,rgba(255,255,255,.3) 35px,rgba(255,255,255,.3) 70px);border:0 solid #ff1800;color:#4f0800}.brighttheme-icon-closer,.brighttheme-icon-info,.brighttheme-icon-notice,.brighttheme-icon-sticker,.brighttheme-icon-success{position:relative;width:16px;height:16px;font-size:12px;font-weight:700;line-height:16px;font-family:"Courier New",Courier,monospace;border-radius:50%}.brighttheme-icon-closer:after,.brighttheme-icon-info:after,.brighttheme-icon-notice:after,.brighttheme-icon-sticker:after,.brighttheme-icon-success:after{position:absolute;top:0;left:4px}.brighttheme-icon-notice{background-color:#2e2e00;color:#ffffa2;margin-top:2px}.brighttheme-icon-notice:after{content:"!"}.brighttheme-icon-info{background-color:#012831;color:#8fcedd;margin-top:2px}.brighttheme-icon-info:after{content:"i"}.brighttheme-icon-success{background-color:#104300;color:#aff29a;margin-top:2px}.brighttheme-icon-success:after{content:"\002713"}.brighttheme-icon-error{position:relative;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:16px solid #2e0400;font-size:0;line-height:0;color:#ffaba2;margin-top:1px}.brighttheme-icon-error:after{position:absolute;top:1px;left:-4px;font-size:12px;font-weight:700;line-height:16px;font-family:"Courier New",Courier,monospace;content:"!"}.brighttheme-icon-closer,.brighttheme-icon-sticker{display:inline-block}.brighttheme-icon-closer:after{top:-4px;content:"\002715"}.brighttheme-icon-sticker:after{top:-5px;content:"\01D1BC";-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);-o-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.brighttheme-icon-sticker.brighttheme-icon-stuck:after{-moz-transform:rotate(180deg);-webkit-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.brighttheme .ui-pnotify-action-bar{padding-top:12px}.brighttheme .ui-pnotify-action-bar input,.brighttheme .ui-pnotify-action-bar textarea{display:block;width:100%;margin-bottom:12px!important}.brighttheme .ui-pnotify-action-button{text-transform:uppercase;font-weight:700;padding:4px 8px;border:none;background:0 0}.brighttheme .ui-pnotify-action-button.btn-primary{border:none;border-radius:0}.brighttheme-notice .ui-pnotify-action-button.btn-primary{background-color:#ff0;color:#4f4f00}.brighttheme-info .ui-pnotify-action-button.btn-primary{background-color:#0286a5;color:#012831}.brighttheme-success .ui-pnotify-action-button.btn-primary{background-color:#35db00;color:#104300}.brighttheme-error .ui-pnotify-action-button.btn-primary{background-color:#ff1800;color:#4f0800}
.ui-pnotify-closer,.ui-pnotify-sticker{float:right;margin-left:.2em}
.ui-pnotify-history-container{position:absolute;top:0;right:18px;width:70px;border-top:none;padding:0;-webkit-border-top-left-radius:0;-moz-border-top-left-radius:0;border-top-left-radius:0;-webkit-border-top-right-radius:0;-moz-border-top-right-radius:0;border-top-right-radius:0;z-index:10000}.ui-pnotify-history-container.ui-pnotify-history-fixed{position:fixed}.ui-pnotify-history-container .ui-pnotify-history-header{padding:2px;text-align:center}.ui-pnotify-history-container button{cursor:pointer;display:block;width:100%}.ui-pnotify-history-container .ui-pnotify-history-pulldown{display:block;margin:0 auto}.ui-pnotify-history-brighttheme{background-color:#8fcedd;border:0 solid #0286a5;color:#012831}.ui-pnotify-history-brighttheme button{text-transform:uppercase;font-weight:700;padding:4px 8px;border:none;background:0 0}.ui-pnotify-history-brighttheme .ui-pnotify-history-pulldown::after{display:block;font-size:16px;line-height:14px;padding-bottom:4px;content:"⌄";text-align:center;font-weight:700;font-family:Arial,sans-serif}
.ui-pnotify-container{position:relative;left:0}@media (max-width:480px){.ui-pnotify-mobile-able.ui-pnotify{position:fixed;top:0;right:0;left:0;width:auto!important;font-size:1.2em;-webkit-font-smoothing:antialiased;-moz-font-smoothing:antialiased;-ms-font-smoothing:antialiased;font-smoothing:antialiased}.ui-pnotify-mobile-able.ui-pnotify .ui-pnotify-shadow{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;border-bottom-width:5px}.ui-pnotify-mobile-able .ui-pnotify-container{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft,.ui-pnotify-mobile-able.ui-pnotify.stack-topleft{left:0;right:0}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft,.ui-pnotify-mobile-able.ui-pnotify.stack-bottomright{left:0;right:0;bottom:0;top:auto}.ui-pnotify-mobile-able.ui-pnotify.stack-bottomleft .ui-pnotify-shadow,.ui-pnotify-mobile-able.ui-pnotify.stack-bottomright .ui-pnotify-shadow{border-top-width:5px;border-bottom-width:1px}}
.ui-pnotify.ui-pnotify-nonblock-fade{opacity:.2}.ui-pnotify.ui-pnotify-nonblock-hide{display:none!important}

File diff suppressed because one or more lines are too long

View File

@@ -1583,7 +1583,7 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
$scope.installCSF = function(){ $scope.installCSF = function(){
$scope.modSecNotifyBox = true; $scope.modSecNotifyBox = true;
$scope.modeSecInstallBox = true; $scope.modeSecInstallBox = false;
$scope.modsecLoading = false; $scope.modsecLoading = false;
$scope.failedToStartInallation = true; $scope.failedToStartInallation = true;
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
@@ -1645,7 +1645,6 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
} }
}; };
function getRequestStatus(){ function getRequestStatus(){
$scope.modSecNotifyBox = true; $scope.modSecNotifyBox = true;
@@ -1703,7 +1702,7 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
$scope.errorMessage = response.data.error_message; $scope.errorMessage = response.data.error_message;
}else{ }else{
$scope.modSecSuccessfullyInstalled = false; $scope.modSecSuccessfullyInstalled = false;
//$timeout(function() { $window.location.reload(); }, 3000); $timeout(function() { $window.location.reload(); }, 3000);
} }
} }
@@ -1724,4 +1723,396 @@ app.controller('csf', function($scope, $http, $timeout, $window) {
} }
// After installation
var currentMain = "generalLI";
var currentChild = "general";
$scope.activateTab = function (newMain, newChild) {
$("#"+currentMain).removeClass("ui-tabs-active");
$("#"+currentMain).removeClass("ui-state-active");
$("#"+newMain).addClass("ui-tabs-active");
$("#"+newMain).addClass("ui-state-active");
$('#'+currentChild).hide();
$('#'+newChild).show();
currentMain = newMain;
currentChild = newChild;
};
$scope.removeCSF = function(){
$scope.csfLoading = false;
url = "/firewall/removeCSF";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.installStatus === 1){
new PNotify({
title: 'Successfully removed!',
text: 'CSF successfully removed from server, refreshing page in 3 seconds..',
type:'success'
});
$timeout(function() { $window.location.reload(); }, 3000);
}
else{
new PNotify({
title: 'Operation failed!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
new PNotify({
title: 'Operation failed!',
text: 'Could not connect to server, please refresh this page.',
type:'error'
});
}
};
//////// Fetch settings
//
var testingMode = false;
var testingCounter = 0;
$('#testingMode').change(function() {
testingMode = $(this).prop('checked');
if(testingCounter !== 0) {
if (testingMode === true) {
$scope.changeStatus('testingMode', 'enable');
} else {
$scope.changeStatus('testingMode', 'disable');
}
}
testingCounter = testingCounter + 1;
});
//
//
var firewallStatus = false;
var firewallCounter = 0;
$('#firewallStatus').change(function() {
firewallStatus = $(this).prop('checked');
if(firewallCounter !== 0) {
if (firewallStatus === true) {
$scope.changeStatus('csf', 'enable');
} else {
$scope.changeStatus('csf', 'disable');
}
}
firewallCounter = firewallCounter + 1;
});
//
$scope.fetchSettings = function(){
$scope.csfLoading = false;
$('#testingMode').bootstrapToggle('off');
$('#firewallStatus').bootstrapToggle('off');
url = "/firewall/fetchCSFSettings";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.fetchStatus === 1){
new PNotify({
title: 'Successfully fetched!',
text: 'CSF settings successfully fetched.',
type:'success'
});
if (response.data.testingMode === 1) {
$('#testingMode').bootstrapToggle('on');
}
if (response.data.firewallStatus === 1) {
$('#firewallStatus').bootstrapToggle('on');
}
$scope.tcpIN = response.data.tcpIN;
$scope.tcpOUT = response.data.tcpOUT;
$scope.udpIN = response.data.udpIN;
$scope.udpOUT = response.data.udpOUT;
}else{
new PNotify({
title: 'Failed to load!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.fetchSettings();
$scope.changeStatus = function(controller, status){
$scope.csfLoading = false;
url = "/firewall/changeStatus";
var data = {
controller: controller,
status : status
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.modifyPorts = function(protocol){
$scope.csfLoading = false;
var ports;
if(protocol === 'TCP_IN'){
ports = $scope.tcpIN;
}else if(protocol === 'TCP_OUT'){
ports = $scope.tcpOUT;
}else if(protocol === 'UDP_IN'){
ports = $scope.udpIN;
}else if(protocol === 'UDP_OUT'){
ports = $scope.udpOUT;
}
url = "/firewall/modifyPorts";
var data = {
protocol: protocol,
ports : ports
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
$scope.modifyIPs = function(mode){
$scope.csfLoading = false;
var ipAddress;
if(mode === 'allowIP'){
ipAddress = $scope.allowIP;
}else if(mode === 'blockIP'){
ipAddress = $scope.blockIP;
}
url = "/firewall/modifyIPs";
var data = {
mode: mode,
ipAddress : ipAddress
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.csfLoading = true;
if(response.data.status === 1){
new PNotify({
title: 'Success!',
text: 'Changes successfully applied.',
type:'success'
});
}else{
new PNotify({
title: 'Error!',
text: response.data.error_message,
type:'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.csfLoading = true;
new PNotify({
title: 'Failed to load!',
text: 'Failed to fetch CSF settings.',
type:'error'
});
}
};
}); });