Added clear log button and ModSec improvements.

This commit is contained in:
usmannasir
2018-03-23 23:05:55 +05:00
parent 1e16db3a05
commit d9d3dd1149
19 changed files with 1721 additions and 18 deletions

View File

@@ -529,6 +529,7 @@
<li><a href="{% url 'errorLogs' %}" title="{% trans 'Error Logs' %}"><span>{% trans "Error Logs" %}</span></a></li> <li><a href="{% url 'errorLogs' %}" title="{% trans 'Error Logs' %}"><span>{% trans "Error Logs" %}</span></a></li>
<li><a href="{% url 'emaillogs' %}" title="{% trans 'Email Logs' %}"><span>{% trans "Email Log" %}</span></a></li> <li><a href="{% url 'emaillogs' %}" title="{% trans 'Email Logs' %}"><span>{% trans "Email Log" %}</span></a></li>
<li><a href="{% url 'ftplogs' %}" title="{% trans 'FTP Logs' %}"><span>{% trans "FTP Logs" %}</span></a></li> <li><a href="{% url 'ftplogs' %}" title="{% trans 'FTP Logs' %}"><span>{% trans "FTP Logs" %}</span></a></li>
<li><a href="{% url 'modSecAuditLogs' %}" title="{% trans 'ModSecurity Audit Logs' %}"><span>{% trans "ModSec Audit Logs" %}</span></a></li>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->
@@ -545,6 +546,8 @@
<ul> <ul>
<li><a href="{% url 'firewallHome' %}" title="{% trans 'Firewall Home' %}"><span>{% trans "Firewall" %}</span></a></li> <li><a href="{% url 'firewallHome' %}" title="{% trans 'Firewall Home' %}"><span>{% trans "Firewall" %}</span></a></li>
<li><a href="{% url 'secureSSH' %}" title="{% trans 'Secure SSH' %}"><span>{% trans "Secure SSH" %}</span></a></li> <li><a href="{% url 'secureSSH' %}" title="{% trans 'Secure SSH' %}"><span>{% trans "Secure SSH" %}</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>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->

View File

@@ -1072,6 +1072,168 @@ app.controller('modSec', function($scope, $http, $timeout, $window) {
$scope.failedToSave = true; $scope.failedToSave = true;
$scope.successfullySaved = true; $scope.successfullySaved = true;
$scope.saveModSecConfigurations = function () {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.modsecLoading = false;
$scope.couldNotConnect = true;
url = "/firewall/saveModSecConfigurations";
var data = {
modsecurity_status:modsecurity_status,
SecAuditEngine:SecAuditEngine,
SecRuleEngine:SecRuleEngine,
SecDebugLogLevel:$scope.SecDebugLogLevel,
SecAuditLogParts:$scope.SecAuditLogParts,
SecAuditLogRelevantStatus:$scope.SecAuditLogRelevantStatus,
SecAuditLogType:$scope.SecAuditLogType,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.saveStatus === 1){
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToSave = false;
$scope.successfullySaved = true;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
};
});
app.controller('modSecRules', function($scope, $http) {
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
fetchModSecRules();
function fetchModSecRules(){
$scope.modsecLoading = false;
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
url = "/firewall/fetchModSecRules";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.modSecInstalled === 1){
$scope.currentModSecRules = response.data.currentModSecRules;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
}
}
$scope.saveModSecRules = function(){
$scope.modsecLoading = false;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
url = "/firewall/saveModSecRules";
var data = {
modSecRules:$scope.currentModSecRules
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.saveStatus === 1){
$scope.rulesSaved = false;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
}else{
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = false;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = false;
$scope.couldNotSave = true;
}
}
}); });
/* Java script code for ModSec */ /* Java script code for ModSec */

View File

@@ -153,7 +153,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="saveModSecChanges()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button> <button type="button" ng-click="saveModSecConfigurations()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,90 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "ModSecurity Rules - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "ModSecurity Rules!" %} </h2>
<p>{% trans "On this page you can add/delete ModSecurity rules." %}</p>
</div>
<div ng-controller="modSecRules" class="example-box-wrapper">
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
<h3 class="content-box-header bg-blue">
{% trans "ModSecurity Rules" %} <img ng-hide="modsecLoading" src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
{% if modSecInstalled == 1 %}
<div class="col-md-12">
<form class="form-horizontal bordered-row">
<div style="border-top: none" class="form-group">
<div class="col-sm-12">
<textarea ng-model="currentModSecRules" rows="15" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="saveModSecRules()" class="btn btn-primary btn-lg btn-block">{% trans "Save Rules!" %}</button>
</div>
</div>
<div ng-hide="rulesSaved" class="alert alert-success">
<p>{% trans "ModSecurity Rules Saved" %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
<div ng-hide="couldNotSave" class="alert alert-danger">
<p>{% trans "Could not save rules, Error message: " %} {$ errorMessage $}</p>
</div>
</form>
</div>
<!----- ModeSec Install Log box ----------------->
{% else %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "ModSecurity is not installed " %}
<a href="{% url 'modSecurity' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Install Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button></a></h3>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -29,6 +29,10 @@ urlpatterns = [
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'^modSecRules', views.modSecRules, name='modSecRules'),
url(r'^fetchModSecRules', views.fetchModSecRules, name='fetchModSecRules'),
url(r'^saveModSecRules', views.saveModSecRules, name='saveModSecRules'),
] ]

View File

@@ -13,6 +13,7 @@ from plogical.virtualHostUtilities import virtualHostUtilities
import thread import thread
from plogical.modSec import modSec from plogical.modSec import modSec
from plogical.installUtilities import installUtilities from plogical.installUtilities import installUtilities
from random import randint
# Create your views here. # Create your views here.
@@ -753,7 +754,9 @@ def fetchModSecSettings(request):
if os.path.exists(modSecPath): if os.path.exists(modSecPath):
data = open(confPath, 'r').readlines() command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines()
for items in data: for items in data:
@@ -824,3 +827,191 @@ def fetchModSecSettings(request):
return render(request,'managePHP/editPHPConfig.html') return render(request,'managePHP/editPHPConfig.html')
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
def saveModSecConfigurations(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
modsecurity = data['modsecurity_status']
SecAuditEngine = data['SecAuditEngine']
SecRuleEngine = data['SecRuleEngine']
SecDebugLogLevel = data['SecDebugLogLevel']
SecAuditLogParts = data['SecAuditLogParts']
SecAuditLogRelevantStatus = data['SecAuditLogRelevantStatus']
SecAuditLogType = data['SecAuditLogType']
if modsecurity == True:
modsecurity = "modsecurity on"
else:
modsecurity = "modsecurity off"
if SecAuditEngine == True:
SecAuditEngine = "SecAuditEngine on"
else:
SecAuditEngine = "SecAuditEngine off"
if SecRuleEngine == True:
SecRuleEngine = "SecRuleEngine On"
else:
SecRuleEngine = "SecRuleEngine off"
SecDebugLogLevel = "SecDebugLogLevel " + str(SecDebugLogLevel)
SecAuditLogParts = "SecAuditLogParts " + str(SecAuditLogParts)
SecAuditLogRelevantStatus = "SecAuditLogRelevantStatus " + SecAuditLogRelevantStatus
SecAuditLogType = "SecAuditLogType " + SecAuditLogType
## writing data temporary to file
tempConfigPath = "/home/cyberpanel/" + str(randint(1000, 9999))
confPath = open(tempConfigPath, "w")
confPath.writelines(modsecurity + "\n")
confPath.writelines(SecAuditEngine + "\n")
confPath.writelines(SecRuleEngine + "\n")
confPath.writelines(SecDebugLogLevel + "\n")
confPath.writelines(SecAuditLogParts + "\n")
confPath.writelines(SecAuditLogRelevantStatus + "\n")
confPath.writelines(SecAuditLogType + "\n")
confPath.close()
## save configuration data
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
data_ret = {'saveStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'saveStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def modSecRules(request):
try:
userID = request.session['userID']
admin = Administrator.objects.get(pk=userID)
if admin.type == 3:
return HttpResponse("You don't have enough privileges to access this page.")
modSecPath = os.path.join(virtualHostUtilities.Server_root,'modules','mod_security.so')
modSecInstalled = 0
if os.path.exists(modSecPath):
modSecInstalled = 1
return render(request, 'firewall/modSecurityRules.html',{'modSecInstalled': modSecInstalled})
except KeyError:
return redirect(loadLoginPage)
def fetchModSecRules(request):
try:
userID = request.session['userID']
admin = Administrator.objects.get(pk=userID)
if admin.type == 3:
return HttpResponse("You don't have enough privileges to access this page.")
modSecPath = os.path.join(virtualHostUtilities.Server_root,'modules','mod_security.so')
rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/modsec/rules.conf")
if os.path.exists(modSecPath):
command = "sudo cat " + rulesPath
currentModSecRules = subprocess.check_output(shlex.split(command))
final_dic = {'modSecInstalled': 1,
'currentModSecRules': currentModSecRules}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:
final_dic = {'modSecInstalled': 0}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
return redirect(loadLoginPage)
def saveModSecRules(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
newModSecRules = data['modSecRules']
## writing data temporary to file
rulesPath = open(modSec.tempRulesFile, "w")
rulesPath.write(newModSecRules)
rulesPath.close()
## save configuration data
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " saveModSecRules"
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
data_ret = {'saveStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'saveStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

View File

@@ -7,6 +7,7 @@ import os
class modSec: class modSec:
installLogPath = "/home/cyberpanel/modSecInstallLog" installLogPath = "/home/cyberpanel/modSecInstallLog"
tempRulesFile = "/home/cyberpanel/tempModSecRules"
@staticmethod @staticmethod
def installModSec(install, modSecInstall): def installModSec(install, modSecInstall):
@@ -87,6 +88,79 @@ SecRule ARGS "\.\./" "t:normalisePathWin,id:99999,severity:4,msg:'Drive Access'
str(msg) + " [installModSecConfigs]") str(msg) + " [installModSecConfigs]")
print "0," + str(msg) print "0," + str(msg)
@staticmethod
def saveModSecConfigs(tempConfigPath):
try:
data = open(tempConfigPath).readlines()
os.remove(tempConfigPath)
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
confData = open(confFile).readlines()
conf = open(confFile, 'w')
for items in confData:
if items.find('modsecurity ') > -1:
conf.writelines(data[0])
continue
elif items.find('SecAuditEngine ') > -1:
conf.writelines(data[1])
continue
elif items.find('SecRuleEngine ') > -1:
conf.writelines(data[2])
continue
elif items.find('SecDebugLogLevel') > -1:
conf.writelines(data[3])
continue
elif items.find('SecAuditLogRelevantStatus ') > -1:
conf.writelines(data[5])
continue
elif items.find('SecAuditLogParts ') > -1:
conf.writelines(data[4])
continue
elif items.find('SecAuditLogType ') > -1:
conf.writelines(data[6])
continue
else:
conf.writelines(items)
conf.close()
print "1,None"
return
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveModSecConfigs]")
print "0," + str(msg)
@staticmethod
def saveModSecRules():
try:
rulesFile = open(modSec.tempRulesFile,'r')
data = rulesFile.read()
rulesFile.close()
rulesFilePath = os.path.join(virtualHostUtilities.Server_root, "conf/modsec/rules.conf")
rulesFile = open(rulesFilePath,'w')
rulesFile.write(data)
rulesFile.close()
print data
print "1,None"
return
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [saveModSecRules]")
print "0," + str(msg)
def main(): def main():
@@ -94,10 +168,16 @@ def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer') parser = argparse.ArgumentParser(description='CyberPanel Installer')
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!')
args = parser.parse_args() args = parser.parse_args()
if args.function == "installModSecConfigs": if args.function == "installModSecConfigs":
modSec.installModSecConfigs() modSec.installModSecConfigs()
elif args.function == "saveModSecConfigs":
modSec.saveModSecConfigs(args.tempConfigPath)
elif args.function == "saveModSecRules":
modSec.saveModSecRules()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

28
plogical/serverLogs.py Normal file
View File

@@ -0,0 +1,28 @@
import CyberCPLogFileWriter as logging
import argparse
class serverLogs:
@staticmethod
def cleanLogFile(fileName):
try:
logFile = open(fileName,'w')
logFile.close()
print "1,None"
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cleanLogFile]")
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--fileName', help='File to clean.')
args = parser.parse_args()
if args.function == "cleanLogFile":
serverLogs.cleanLogFile(args.fileName)
if __name__ == "__main__":
main()

View File

@@ -125,6 +125,65 @@ app.controller('readAccessLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/access.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -163,7 +222,7 @@ app.controller('readErrorLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -255,6 +314,65 @@ app.controller('readErrorLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/error.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -291,7 +409,7 @@ app.controller('readFTPLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -383,6 +501,65 @@ app.controller('readFTPLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/var/log/messages"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -419,7 +596,7 @@ app.controller('readEmailLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -511,8 +688,253 @@ app.controller('readEmailLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/var/log/maillog"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Java script code to read modsec audit log file */
app.controller('modSecAuditLogs', function($scope,$http) {
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/getLogsFromFile";
var data = {
type:"modSec"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.logstatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = false;
$scope.couldNotFetchLogs = true;
$scope.logsData = response.data.logsdata;
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
$scope.fetchLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/getLogsFromFile";
var data = {
type:"modSec"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true;
$scope.logsFeteched = false;
$scope.couldNotFetchLogs = true;
$scope.logsData = response.data.logsdata;
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/auditmodsec.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
});
/* Java script code to read modsec audit log ends here */

View File

@@ -37,9 +37,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-2 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button> <button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
</div>
<div class="col-sm-4">
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
</div> </div>
</div> </div>

View File

@@ -34,9 +34,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-2 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button> <button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
</div>
<div class="col-sm-4">
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
</div> </div>
</div> </div>

View File

@@ -34,9 +34,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-2 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button> <button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
</div>
<div class="col-sm-4">
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
</div> </div>
</div> </div>

View File

@@ -34,9 +34,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-2 control-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button> <button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
</div>
<div class="col-sm-4">
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,72 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "ModSecurity Audit Logs - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div class="container">
<div id="page-title">
<h2>{% trans "ModSecurity Audit Logs" %}</h2>
<p>{% trans "ModSecurity Audit logs" %}</p>
</div>
<div ng-controller="modSecAuditLogs" class="row">
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Last 50 Lines" %} <img ng-hide="logFileLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="col-md-12">
<form class="form-horizontal bordered-row">
<div class="form-group">
<div class="col-sm-12">
<textarea ng-model="logsData" rows="30" class="form-control">{{ logs }}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="fetchLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Refresh" %}</button>
</div>
<div class="col-sm-4">
<button type="button" ng-click="clearLogs()" class="btn btn-primary btn-lg btn-block">{% trans "Clear Logs" %}</button>
</div>
</div>
<div ng-hide="logsFeteched" class="alert alert-success">
<p>{% trans "Last 50 Lines Fetched" %}</p>
</div>
<div ng-hide="couldNotFetchLogs" class="alert alert-danger">
<p>{% trans "Could not fetch logs. Use the command line to view the log file." %}</p>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -7,6 +7,8 @@ urlpatterns = [
url(r'^errorLogs', views.errorLogs, name='errorLogs'), url(r'^errorLogs', views.errorLogs, name='errorLogs'),
url(r'^emaillogs', views.emailLogs, name='emaillogs'), url(r'^emaillogs', views.emailLogs, name='emaillogs'),
url(r'^ftplogs', views.ftplogs, name='ftplogs'), url(r'^ftplogs', views.ftplogs, name='ftplogs'),
url(r'^modSecAuditLogs', views.modSecAuditLogs, name='modSecAuditLogs'),
url(r'^getLogsFromFile',views.getLogsFromFile, name="getLogsFromFile"), url(r'^getLogsFromFile',views.getLogsFromFile, name="getLogsFromFile"),
url(r'^clearLogFile',views.clearLogFile, name="clearLogFile"),
] ]

View File

@@ -10,6 +10,7 @@ from plogical.installUtilities import installUtilities
from loginSystem.models import Administrator from loginSystem.models import Administrator
import subprocess import subprocess
import shlex import shlex
from plogical.virtualHostUtilities import virtualHostUtilities
# Create your views here. # Create your views here.
@@ -88,6 +89,21 @@ def emailLogs(request):
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
return redirect(loadLoginPage) return redirect(loadLoginPage)
def modSecAuditLogs(request):
try:
val = request.session['userID']
admin = Administrator.objects.get(pk=val)
if admin.type == 3:
return HttpResponse("You don't have enough priviliges to access this page.")
return render(request,'serverLogs/modSecAuditLog.html')
except KeyError,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
return redirect(loadLoginPage)
def getLogsFromFile(request): def getLogsFromFile(request):
@@ -105,6 +121,9 @@ def getLogsFromFile(request):
fileName="/var/log/maillog" fileName="/var/log/maillog"
elif type=="ftp": elif type=="ftp":
fileName="/var/log/messages" fileName="/var/log/messages"
elif type == "modSec":
fileName = "/usr/local/lsws/logs/auditmodsec.log"
command = "sudo tail -50 " + fileName command = "sudo tail -50 " + fileName
@@ -120,4 +139,40 @@ def getLogsFromFile(request):
except KeyError, msg: except KeyError, msg:
status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."} status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]") logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getLogsFromFile]")
return HttpResponse("Not Logged in as admin") return HttpResponse("Not Logged in as admin")
def clearLogFile(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
fileName = data['fileName']
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py"
execPath = execPath + " cleanLogFile --fileName " + fileName
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'cleanStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'cleanStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'cleanStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError,msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
data_ret = {'cleanStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

View File

@@ -1072,6 +1072,168 @@ app.controller('modSec', function($scope, $http, $timeout, $window) {
$scope.failedToSave = true; $scope.failedToSave = true;
$scope.successfullySaved = true; $scope.successfullySaved = true;
$scope.saveModSecConfigurations = function () {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.modsecLoading = false;
$scope.couldNotConnect = true;
url = "/firewall/saveModSecConfigurations";
var data = {
modsecurity_status:modsecurity_status,
SecAuditEngine:SecAuditEngine,
SecRuleEngine:SecRuleEngine,
SecDebugLogLevel:$scope.SecDebugLogLevel,
SecAuditLogParts:$scope.SecAuditLogParts,
SecAuditLogRelevantStatus:$scope.SecAuditLogRelevantStatus,
SecAuditLogType:$scope.SecAuditLogType,
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.saveStatus === 1){
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
else{
$scope.errorMessage = response.data.error_message;
$scope.failedToSave = false;
$scope.successfullySaved = true;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.modsecLoading = true;
$scope.couldNotConnect = true;
}
};
});
app.controller('modSecRules', function($scope, $http) {
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
fetchModSecRules();
function fetchModSecRules(){
$scope.modsecLoading = false;
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
url = "/firewall/fetchModSecRules";
var data = {};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.modSecInstalled === 1){
$scope.currentModSecRules = response.data.currentModSecRules;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
}
}
$scope.saveModSecRules = function(){
$scope.modsecLoading = false;
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
url = "/firewall/saveModSecRules";
var data = {
modSecRules:$scope.currentModSecRules
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.saveStatus === 1){
$scope.rulesSaved = false;
$scope.couldNotConnect = true;
$scope.couldNotSave = true;
}else{
$scope.rulesSaved = true;
$scope.couldNotConnect = true;
$scope.couldNotSave = false;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
$scope.rulesSaved = true;
$scope.couldNotConnect = false;
$scope.couldNotSave = true;
}
}
}); });
/* Java script code for ModSec */ /* Java script code for ModSec */

View File

@@ -125,6 +125,65 @@ app.controller('readAccessLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/access.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -163,7 +222,7 @@ app.controller('readErrorLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -255,6 +314,65 @@ app.controller('readErrorLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/error.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -291,7 +409,7 @@ app.controller('readFTPLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -383,6 +501,65 @@ app.controller('readFTPLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/var/log/messages"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
@@ -419,7 +596,7 @@ app.controller('readEmailLogs', function($scope,$http) {
if(response.data.logstatus == 1){ if(response.data.logstatus === 1){
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = false; $scope.logsFeteched = false;
@@ -511,8 +688,253 @@ app.controller('readEmailLogs', function($scope,$http) {
}; };
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/var/log/maillog"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
}); });
/* Java script code to read log file ends here */ /* Java script code to read log file ends here */
/* Java script code to read modsec audit log file */
app.controller('modSecAuditLogs', function($scope,$http) {
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/getLogsFromFile";
var data = {
type:"modSec"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.logstatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = false;
$scope.couldNotFetchLogs = true;
$scope.logsData = response.data.logsdata;
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
$scope.fetchLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/getLogsFromFile";
var data = {
type:"modSec"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.logstatus == 1){
$scope.logFileLoading = true;
$scope.logsFeteched = false;
$scope.couldNotFetchLogs = true;
$scope.logsData = response.data.logsdata;
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
$scope.clearLogs = function(){
$scope.logFileLoading = false;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
var url = "/serverlogs/clearLogFile";
var data = {
fileName:"/usr/local/lsws/logs/auditmodsec.log"
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.cleanStatus === 1){
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
$scope.logsData = "";
}
else{
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = true;
}
}
function cantLoadInitialDatas(response) {
$scope.logFileLoading = true;
$scope.logsFeteched = true;
$scope.couldNotFetchLogs = false;
}
};
});
/* Java script code to read modsec audit log ends here */

View File

@@ -1573,7 +1573,7 @@ def saveSSL(request):
vhost = open(tempCertPath, "w") vhost = open(tempCertPath, "w")
vhost.write(data['key']) vhost.write(data['cert'])
vhost.close() vhost.close()
@@ -1591,8 +1591,6 @@ def saveSSL(request):
execPath = execPath + " saveSSL --virtualHostName " + domain + " --path " + pathToStoreSSL + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath + " --sslCheck 0" execPath = execPath + " saveSSL --virtualHostName " + domain + " --path " + pathToStoreSSL + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath + " --sslCheck 0"
output = subprocess.check_output(shlex.split(execPath)) output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1: if output.find("1,None") > -1: