mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 15:26:13 +01:00
bug fix to csf
This commit is contained in:
@@ -60,7 +60,7 @@ class secMiddleware:
|
||||
|
||||
if request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('filemanager') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
|
||||
continue
|
||||
if key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' or key == 'fileContent':
|
||||
if key == 'ports' or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' or key == 'fileContent':
|
||||
continue
|
||||
if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \
|
||||
or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \
|
||||
|
||||
@@ -11,14 +11,11 @@ from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.installUtilities import installUtilities
|
||||
from django.shortcuts import HttpResponse, render
|
||||
from random import randint
|
||||
import time
|
||||
from plogical.firewallUtilities import FirewallUtilities
|
||||
from firewall.models import FirewallRules
|
||||
import thread
|
||||
from plogical.modSec import modSec
|
||||
from plogical.csf import CSF
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
@@ -1482,8 +1479,17 @@ class FirewallManager:
|
||||
protocol = data['protocol']
|
||||
ports = data['ports']
|
||||
|
||||
portsPath = '/tmp/ports'
|
||||
|
||||
if os.path.exists(portsPath):
|
||||
os.remove(portsPath)
|
||||
|
||||
writeToFile = open(portsPath, 'w')
|
||||
writeToFile.write(ports)
|
||||
writeToFile.close()
|
||||
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
|
||||
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports
|
||||
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + portsPath
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
|
||||
@@ -212,11 +212,14 @@ class CSF(multi.Thread):
|
||||
print '0',str(msg)
|
||||
|
||||
@staticmethod
|
||||
def modifyPorts(protocol, ports):
|
||||
def modifyPorts(protocol, portsPath):
|
||||
try:
|
||||
|
||||
data = open('/etc/csf/csf.conf', 'r').readlines()
|
||||
writeToFile = open('/etc/csf/csf.conf', 'w')
|
||||
|
||||
ports = open(portsPath, 'r').read()
|
||||
|
||||
if protocol == 'TCP_IN':
|
||||
for items in data:
|
||||
if items.find('TCP_IN') > -1 and items.find('=') > -1 and (items[0] != '#'):
|
||||
@@ -249,6 +252,11 @@ class CSF(multi.Thread):
|
||||
command = 'csf -r'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
try:
|
||||
os.remove(portsPath)
|
||||
except:
|
||||
pass
|
||||
|
||||
print '1,None'
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
Reference in New Issue
Block a user