efforts to embed csf ui
This commit is contained in:
parent
0f9e713716
commit
c80ef3288f
|
|
@ -65,6 +65,7 @@ INSTALLED_APPS = [
|
|||
'containerization',
|
||||
'CLManager',
|
||||
'IncBackups',
|
||||
'configservercsf'
|
||||
# 'WebTerminal'
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
#default_app_config = 'configservercsf.apps.configservercsfConfig'
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class configservercsfConfig(AppConfig):
|
||||
name = 'configservercsf'
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cyberpanelPluginConfig>
|
||||
<name>ConfigServer Security and Firewall</name>
|
||||
<type>plugin</type>
|
||||
<description>ConfigServer Security and Firewall</description>
|
||||
<version>1.0</version>
|
||||
</cyberpanelPluginConfig>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from django.dispatch import receiver
|
||||
from django.shortcuts import redirect
|
||||
from firewall.signals import preFirewallHome, preCSF
|
||||
|
||||
@receiver(preFirewallHome)
|
||||
def csfFirewallHome(sender, **kwargs):
|
||||
request = kwargs['request']
|
||||
return redirect('/configservercsf/')
|
||||
|
||||
@receiver(preCSF)
|
||||
def csfCSF(sender, **kwargs):
|
||||
request = kwargs['request']
|
||||
return redirect('/configservercsf/')
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}ConfigServer Security and Firewall{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
|
||||
<iframe border="0" name='myiframe' id='myiframe' src="/configservercsf/iframe/" style="width: 100%;" frameborder="0" onload="resizeIframe(this);"></iframe>
|
||||
<script>
|
||||
function resizeIframe(obj) {
|
||||
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
window.parent.parent.scrollTo(0,0);
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<a href="#" title="ConfigServer Services">
|
||||
<i class="glyph-icon icon-bug"></i>
|
||||
<span>ConfigServer Services</span>
|
||||
</a>
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
<ul>
|
||||
{% url 'configservercsf' as the_url %}
|
||||
{% if the_url %}
|
||||
<li><a href="{% url 'configservercsf' %}"
|
||||
title="ConfigServer Security & Firewall"><span>ConfigServer Security & Firewall</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% url 'configservercxs' as the_url %}
|
||||
{% if the_url %}
|
||||
<li><a href="{% url 'configservercxs' %}"
|
||||
title="ConfigServer Exploit Scanner"><span>ConfigServer Exploit Scanner</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<li class="serverACL">
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path, re_path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.configservercsf, name='configservercsf'),
|
||||
path('iframe/', views.configservercsfiframe, name='configservercsfiframe'),
|
||||
]
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from plogical.acl import ACLManager
|
||||
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
import tempfile
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
def configservercsf(request):
|
||||
proc = httpProc(request, 'configservercsf/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
@csrf_exempt
|
||||
@xframe_options_exempt
|
||||
def configservercsfiframe(request):
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if request.method == 'GET':
|
||||
qs = request.GET.urlencode()
|
||||
elif request.method == 'POST':
|
||||
qs = request.POST.urlencode()
|
||||
|
||||
try:
|
||||
tmp = tempfile.NamedTemporaryFile(mode = "w", delete=False)
|
||||
tmp.write(qs)
|
||||
tmp.close()
|
||||
command = "/usr/local/csf/bin/cyberpanel.pl '" + tmp.name + "'"
|
||||
|
||||
try:
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
except:
|
||||
output = "Output Error from csf UI script"
|
||||
|
||||
os.unlink(tmp.name)
|
||||
except:
|
||||
output = "Unable to create csf UI temp file"
|
||||
|
||||
return HttpResponse(output)
|
||||
165
plogical/csf.py
165
plogical/csf.py
|
|
@ -54,71 +54,106 @@ class CSF(multi.Thread):
|
|||
|
||||
### manually update csf views.py because it does not load CyberPanel properly in default configurations
|
||||
|
||||
# content = '''
|
||||
# # -*- coding: utf-8 -*-
|
||||
# from __future__ import unicode_literals
|
||||
#
|
||||
# import os
|
||||
# import os.path
|
||||
# import sys
|
||||
# import django
|
||||
# sys.path.append('/usr/local/CyberCP')
|
||||
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
# django.setup()
|
||||
# import json
|
||||
# from plogical.acl import ACLManager
|
||||
# from plogical.httpProc import httpProc
|
||||
# import plogical.CyberCPLogFileWriter as logging
|
||||
# import subprocess
|
||||
# from django.shortcuts import HttpResponse, render
|
||||
# from plogical.processUtilities import ProcessUtilities
|
||||
# from django.views.decorators.csrf import csrf_exempt
|
||||
# import tempfile
|
||||
# from django.http import HttpResponse
|
||||
# from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
#
|
||||
# def configservercsf(request):
|
||||
# proc = httpProc(request, 'configservercsf/index.html',
|
||||
# None, 'admin')
|
||||
# return proc.render()
|
||||
#
|
||||
# @csrf_exempt
|
||||
# @xframe_options_exempt
|
||||
# def configservercsfiframe(request):
|
||||
# userID = request.session['userID']
|
||||
# currentACL = ACLManager.loadedACL(userID)
|
||||
#
|
||||
# if currentACL['admin'] == 1:
|
||||
# pass
|
||||
# else:
|
||||
# return ACLManager.loadError()
|
||||
#
|
||||
# if request.method == 'GET':
|
||||
# qs = request.GET.urlencode()
|
||||
# elif request.method == 'POST':
|
||||
# qs = request.POST.urlencode()
|
||||
#
|
||||
# try:
|
||||
# tmp = tempfile.NamedTemporaryFile(mode = "w", delete=False)
|
||||
# tmp.write(qs)
|
||||
# tmp.close()
|
||||
# command = "/usr/local/csf/bin/cyberpanel.pl '" + tmp.name + "'"
|
||||
#
|
||||
# try:
|
||||
# output = ProcessUtilities.outputExecutioner(command)
|
||||
# except:
|
||||
# output = "Output Error from csf UI script"
|
||||
#
|
||||
# os.unlink(tmp.name)
|
||||
# except:
|
||||
# output = "Unable to create csf UI temp file"
|
||||
#
|
||||
# return HttpResponse(output)
|
||||
# '''
|
||||
#
|
||||
# WriteToFile = open('cyberpanel/configservercsf/views.py', 'w')
|
||||
# WriteToFile.write(content)
|
||||
# WriteToFile.close()
|
||||
content = '''
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from plogical.acl import ACLManager
|
||||
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
import tempfile
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
def configservercsf(request):
|
||||
proc = httpProc(request, 'configservercsf/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
@csrf_exempt
|
||||
@xframe_options_exempt
|
||||
def configservercsfiframe(request):
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if request.method == 'GET':
|
||||
qs = request.GET.urlencode()
|
||||
elif request.method == 'POST':
|
||||
qs = request.POST.urlencode()
|
||||
|
||||
try:
|
||||
tmp = tempfile.NamedTemporaryFile(mode = "w", delete=False)
|
||||
tmp.write(qs)
|
||||
tmp.close()
|
||||
command = "/usr/local/csf/bin/cyberpanel.pl '" + tmp.name + "'"
|
||||
|
||||
try:
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
except:
|
||||
output = "Output Error from csf UI script"
|
||||
|
||||
os.unlink(tmp.name)
|
||||
except:
|
||||
output = "Unable to create csf UI temp file"
|
||||
|
||||
return HttpResponse(output)
|
||||
'''
|
||||
|
||||
WriteToFile = open('cyberpanel/configservercsf/views.py', 'w')
|
||||
WriteToFile.write(content)
|
||||
WriteToFile.close()
|
||||
|
||||
### now update content of signals.py
|
||||
WriteToFile = open('cyberpanel/configservercsf/signals.py', 'w')
|
||||
WriteToFile.close()
|
||||
|
||||
### now update content of apps.py
|
||||
|
||||
content = '''
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class configservercsfConfig(AppConfig):
|
||||
name = 'configservercsf'
|
||||
'''
|
||||
|
||||
WriteToFile = open('cyberpanel/configservercsf/apps.py', 'w')
|
||||
WriteToFile.write(content)
|
||||
WriteToFile.close()
|
||||
|
||||
|
||||
### now update content of urls.py
|
||||
|
||||
content = '''
|
||||
from django.urls import path, re_path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.configservercsf, name='configservercsf'),
|
||||
path('iframe/', views.configservercsfiframe, name='configservercsfiframe'),
|
||||
]
|
||||
'''
|
||||
|
||||
WriteToFile = open('cyberpanel/configservercsf/urls.py', 'w')
|
||||
WriteToFile.write(content)
|
||||
WriteToFile.close()
|
||||
|
||||
command = "chmod +x install.sh"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
|
|
|||
Loading…
Reference in New Issue