GPL v3 Release

This commit is contained in:
chirpy
2025-08-28 15:15:56 +01:00
parent c15ade09f6
commit 2923c43f8f
494 changed files with 106870 additions and 58 deletions

View File

@@ -0,0 +1 @@
#default_app_config = 'configservercsf.apps.configservercsfConfig'

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class configservercsfConfig(AppConfig):
name = 'configservercsf'
def ready(self):
import signals

View File

View File

@@ -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>

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.

View File

@@ -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/')

View File

@@ -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 %}

View File

@@ -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 &amp; Firewall"><span>ConfigServer Security &amp; 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">

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,8 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.configservercsf, name='configservercsf'),
url(r'^iframe/$', views.configservercsfiframe, name='configservercsfiframe'),
]

View File

@@ -0,0 +1,64 @@
# -*- 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
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):
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
return render(request,'configservercsf/index.html')
@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)

View File

@@ -0,0 +1,218 @@
#!/usr/bin/perl
###############################################################################
# Copyright (C) 2006-2025 Jonathan Michaelson
#
# https://github.com/waytotheweb/scripts
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses>.
###############################################################################
# start main
use strict;
use File::Find;
use Fcntl qw(:DEFAULT :flock);
use Sys::Hostname qw(hostname);
use IPC::Open3;
use lib '/usr/local/csf/lib';
use ConfigServer::DisplayUI;
use ConfigServer::Config;
our ($script, $images, $myv, %FORM, %in);
my $config = ConfigServer::Config->loadconfig();
my %config = $config->config;
open (my $IN, "<", "/etc/csf/version.txt");
$myv = <$IN>;
close ($IN);
chomp $myv;
$script = "/configservercsf/iframe/";
$images = "/static/configservercsf";
my $file = $ARGV[0];
unless (-e $file) {die "Cannot find tempfile [$file]"}
my (undef,undef,$uuid,$ugid) = getpwnam("cyberpanel");
my $uid = (stat($file))[4];
my $gid = (stat($file))[5];
if ($uid != $uuid or $gid != $ugid) {die "Invalid tempfile ownership [$file]"}
open (my $DATA, "<", $file);
my $buffer = <$DATA>;
close ($DATA);
my @pairs = split(/&/, $buffer);
foreach my $pair (@pairs) {
my ($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
#print "<pre>$ARGV[0]:$ARGV[1]:[[$buffer]]</pre>\n";
#foreach my $key (keys %ENV) {
# print "$key = [$ENV{$key}]<br>\n";
#}
my $bootstrapcss = "<link rel='stylesheet' href='$images/bootstrap/css/bootstrap.min.css'>";
my $jqueryjs = "<script src='$images/jquery.min.js'></script>";
my $bootstrapjs = "<script src='$images/bootstrap/js/bootstrap.min.js'></script>";
unless ($FORM{action} eq "tailcmd" or $FORM{action} =~ /^cf/ or $FORM{action} eq "logtailcmd" or $FORM{action} eq "loggrepcmd") {
print <<EOF;
<!doctype html>
<html lang='en'>
<head>
<title>ConfigServer Security &amp; Firewall</title>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
$bootstrapcss
<link href='$images/configserver.css' rel='stylesheet' type='text/css'>
$jqueryjs
$bootstrapjs
<style>
.mobilecontainer {
display:none;
}
.normalcontainer {
display:block;
}
EOF
if ($config{STYLE_MOBILE}) {
print <<EOF;
\@media (max-width: 600px) {
.mobilecontainer {
display:block;
}
.normalcontainer {
display:none;
}
}
EOF
}
print "</style>\n";
print <<EOF;
</head>
<body>
<div id="loader"></div>
<a id='toplink' class='toplink' title='Go to bottom'><span class='glyphicon glyphicon-hand-down'></span></a>
<div class='container-fluid'>
<br>
<div class='panel panel-default'>
<h4><img src='$images/csf_small.png' style='padding-left: 10px'> ConfigServer Security &amp; Firewall - csf v$myv</h4>
</div>
EOF
}
#my $templatehtml;
#open (my $SCRIPTOUT, '>', \$templatehtml);
#select $SCRIPTOUT;
ConfigServer::DisplayUI::main(\%FORM, $script, $script, $images, $myv);
#close ($SCRIPTOUT);
#select STDOUT;
#open (OUT, ">/tmp/out.html");
#print OUT $templatehtml;
#close (OUT);
#print $templatehtml;
unless ($FORM{action} eq "tailcmd" or $FORM{action} =~ /^cf/ or $FORM{action} eq "logtailcmd" or $FORM{action} eq "loggrepcmd") {
print <<EOF;
<a class='botlink' id='botlink' title='Go to top'><span class='glyphicon glyphicon-hand-up'></span></a>
<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length,c.length);
}
}
return "";
}
\$("#loader").hide();
\$.fn.scrollBottom = function() {
return \$(document).height() - this.scrollTop() - this.height();
};
\$('#botlink').on("click",function(){
\$('html,body').animate({ scrollTop: 0 }, 'slow', function () {});
});
\$('#toplink').on("click",function() {
var window_height = \$(window).height();
var document_height = \$(document).height();
\$('html,body').animate({ scrollTop: window_height + document_height }, 'slow', function () {});
});
\$('#tabAll').click(function(){
\$('#tabAll').addClass('active');
\$('.tab-pane').each(function(i,t){
\$('#myTabs li').removeClass('active');
\$(this).addClass('active');
});
});
\$(document).ready(function(){
\$('[data-tooltip="tooltip"]').tooltip();
\$(window).scroll(function () {
if (\$(this).scrollTop() > 500) {
\$('#botlink').fadeIn();
} else {
\$('#botlink').fadeOut();
}
if (\$(this).scrollBottom() > 500) {
\$('#toplink').fadeIn();
} else {
\$('#toplink').fadeOut();
}
});
EOF
if ($config{STYLE_MOBILE}) {
print <<EOF;
var csfview = getCookie('csfview');
if (csfview == 'mobile') {
\$(".mobilecontainer").css('display','block');
\$(".normalcontainer").css('display','none');
\$("#csfreturn").addClass('btn-primary btn-lg btn-block').removeClass('btn-default');
} else if (csfview == 'desktop') {
\$(".mobilecontainer").css('display','none');
\$(".normalcontainer").css('display','block');
\$("#csfreturn").removeClass('btn-primary btn-lg btn-block').addClass('btn-default');
}
EOF
}
print "});\n";
if ($config{STYLE_MOBILE}) {
print <<EOF;
\$("#NormalView").click(function(){
document.cookie = "csfview=desktop; path=/";
\$(".mobilecontainer").css('display','none');
\$(".normalcontainer").css('display','block');
});
\$("#MobileView").click(function(){
document.cookie = "csfview=mobile; path=/";
\$(".mobilecontainer").css('display','block');
\$(".normalcontainer").css('display','none');
});
EOF
}
print " parent.resizeIframe(parent.document.getElementById('myiframe'));\n";
print "</script>\n";
print "</body>\n";
print "</html>\n";
}
1;