Linux vmi284606.contaboserver.net 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
Apache/2.4.57 (Ubuntu)
: 167.86.127.34 | : 216.73.217.31
Cant Read [ /etc/named.conf ]
7.2.24-0ubuntu0.18.04.17
root
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
share /
webmin /
fail2ban /
[ HOME SHELL ]
Name
Size
Permission
Action
help
[ DIR ]
drwxr-xr-x
images
[ DIR ]
drwxr-xr-x
lang
[ DIR ]
drwxr-xr-x
CHANGELOG
110
B
-rw-r--r--
atboot.cgi
919
B
-rwxr-xr-x
backup_config.pl
771
B
-rwxr-xr-x
config
100
B
-rw-r--r--
config-debian-linux
118
B
-rw-r--r--
config-redhat-linux
118
B
-rw-r--r--
config-syno-linux
100
B
-rw-r--r--
config.info
196
B
-rw-r--r--
config.info.ca
249
B
-rw-r--r--
config.info.de
202
B
-rw-r--r--
config.info.fr
231
B
-rw-r--r--
config.info.ms
201
B
-rw-r--r--
config.info.no
203
B
-rw-r--r--
config.info.pl
232
B
-rw-r--r--
delete_actions.cgi
877
B
-rwxr-xr-x
delete_filters.cgi
877
B
-rwxr-xr-x
delete_jails.cgi
624
B
-rwxr-xr-x
edit_action.cgi
2.12
KB
-rwxr-xr-x
edit_config.cgi
1.67
KB
-rwxr-xr-x
edit_filter.cgi
1.67
KB
-rwxr-xr-x
edit_jail.cgi
3.91
KB
-rwxr-xr-x
edit_jaildef.cgi
2.57
KB
-rwxr-xr-x
edit_manual.cgi
1.05
KB
-rwxr-xr-x
fail2ban-lib.pl
13.86
KB
-rw-r--r--
index.cgi
2.15
KB
-rwxr-xr-x
install_check.pl
465
B
-rwxr-xr-x
list_actions.cgi
1.15
KB
-rwxr-xr-x
list_filters.cgi
1.2
KB
-rwxr-xr-x
list_jails.cgi
1.55
KB
-rwxr-xr-x
list_status.cgi
3.04
KB
-rwxr-xr-x
log_parser.pl
804
B
-rwxr-xr-x
module.info
201
B
-rw-r--r--
module.info.af
0
B
-rw-r--r--
module.info.af.auto
150
B
-rw-r--r--
module.info.ar
0
B
-rw-r--r--
module.info.ar.auto
233
B
-rw-r--r--
module.info.be
0
B
-rw-r--r--
module.info.be.auto
225
B
-rw-r--r--
module.info.bg
0
B
-rw-r--r--
module.info.bg.auto
239
B
-rw-r--r--
module.info.ca
149
B
-rw-r--r--
module.info.cs
0
B
-rw-r--r--
module.info.cs.auto
161
B
-rw-r--r--
module.info.da
0
B
-rw-r--r--
module.info.da.auto
157
B
-rw-r--r--
module.info.de
138
B
-rw-r--r--
module.info.el
0
B
-rw-r--r--
module.info.el.auto
291
B
-rw-r--r--
module.info.es
0
B
-rw-r--r--
module.info.es.auto
152
B
-rw-r--r--
module.info.eu
0
B
-rw-r--r--
module.info.eu.auto
157
B
-rw-r--r--
module.info.fa
0
B
-rw-r--r--
module.info.fa.auto
220
B
-rw-r--r--
module.info.fi
0
B
-rw-r--r--
module.info.fi.auto
175
B
-rw-r--r--
module.info.fr
0
B
-rw-r--r--
module.info.fr.auto
180
B
-rw-r--r--
module.info.he
0
B
-rw-r--r--
module.info.he.auto
201
B
-rw-r--r--
module.info.hr
0
B
-rw-r--r--
module.info.hr.auto
141
B
-rw-r--r--
module.info.hu
0
B
-rw-r--r--
module.info.hu.auto
159
B
-rw-r--r--
module.info.it
0
B
-rw-r--r--
module.info.it.auto
163
B
-rw-r--r--
module.info.ja
0
B
-rw-r--r--
module.info.ja.auto
187
B
-rw-r--r--
module.info.ko
0
B
-rw-r--r--
module.info.ko.auto
167
B
-rw-r--r--
module.info.lt
0
B
-rw-r--r--
module.info.lt.auto
171
B
-rw-r--r--
module.info.lv
0
B
-rw-r--r--
module.info.lv.auto
162
B
-rw-r--r--
module.info.ms
161
B
-rw-r--r--
module.info.mt
0
B
-rw-r--r--
module.info.mt.auto
176
B
-rw-r--r--
module.info.nl
0
B
-rw-r--r--
module.info.nl.auto
156
B
-rw-r--r--
module.info.no
36
B
-rw-r--r--
module.info.no.auto
114
B
-rw-r--r--
module.info.pl
158
B
-rw-r--r--
module.info.pt
0
B
-rw-r--r--
module.info.pt.auto
161
B
-rw-r--r--
module.info.pt_BR
0
B
-rw-r--r--
module.info.pt_BR.auto
167
B
-rw-r--r--
module.info.ro
0
B
-rw-r--r--
module.info.ro.auto
186
B
-rw-r--r--
module.info.ru
0
B
-rw-r--r--
module.info.ru.auto
249
B
-rw-r--r--
module.info.sk
0
B
-rw-r--r--
module.info.sk.auto
174
B
-rw-r--r--
module.info.sl
0
B
-rw-r--r--
module.info.sl.auto
147
B
-rw-r--r--
module.info.sv
0
B
-rw-r--r--
module.info.sv.auto
164
B
-rw-r--r--
module.info.th
0
B
-rw-r--r--
module.info.th.auto
326
B
-rw-r--r--
module.info.tr
0
B
-rw-r--r--
module.info.tr.auto
173
B
-rw-r--r--
module.info.uk
0
B
-rw-r--r--
module.info.uk.auto
236
B
-rw-r--r--
module.info.ur
0
B
-rw-r--r--
module.info.ur.auto
272
B
-rw-r--r--
module.info.vi
0
B
-rw-r--r--
module.info.vi.auto
203
B
-rw-r--r--
module.info.zh
0
B
-rw-r--r--
module.info.zh.auto
118
B
-rw-r--r--
module.info.zh_TW
0
B
-rw-r--r--
module.info.zh_TW.auto
124
B
-rw-r--r--
restart.cgi
334
B
-rwxr-xr-x
save_action.cgi
1.86
KB
-rwxr-xr-x
save_config.cgi
975
B
-rwxr-xr-x
save_filter.cgi
1.69
KB
-rwxr-xr-x
save_jail.cgi
3.71
KB
-rwxr-xr-x
save_jaildef.cgi
1.49
KB
-rwxr-xr-x
save_manual.cgi
620
B
-rwxr-xr-x
start.cgi
326
B
-rwxr-xr-x
stop.cgi
322
B
-rwxr-xr-x
syslog_logs.pl
599
B
-rwxr-xr-x
unblock_jail.cgi
708
B
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : fail2ban-lib.pl
# Functions for configuring the fail2ban log analyser BEGIN { push(@INC, ".."); }; use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; use WebminCore; &init_config(); our ($module_root_directory, %text, %config, %gconfig, $base_remote_user); our %access = &get_module_acl(); our @all_files_for_lock; # check_fail2ban() # Returns undef if installed, or an appropriate error message if missing sub check_fail2ban { -d $config{'config_dir'} || return &text('check_edir', "<tt>$config{'config_dir'}</tt>"); -r "$config{'config_dir'}/fail2ban.conf" || return &text('check_econf', "<tt>$config{'config_dir'}</tt>", "<tt>fail2ban.conf</tt>"); &has_command($config{'client_cmd'}) || return &text('check_eclient', "<tt>$config{'client_cmd'}</tt>"); &has_command($config{'server_cmd'}) || return &text('check_eserver', "<tt>$config{'server_cmd'}</tt>"); return undef; } sub is_fail2ban_running { my ($pid) = &find_byname($config{'server_cmd'}); if (!$pid) { ($pid) = &find_byname("fail2ban-server"); } return $pid; } # list_filters() # Returns a list of all defined filter files, each of which contains multiple # sections like [Definition] sub list_filters { my $dir = "$config{'config_dir'}/filter.d"; my @rv; foreach my $f (glob("$dir/*.conf")) { my @conf = &parse_config_file($f); my @lconf = &parse_config_file(&make_local_file($f)); &merge_local_files(\@conf, \@lconf); if (@conf) { push(@rv, \@conf); } } return @rv; } # list_actions() # Returns a list of all defined action files, each of which contains multiple # sections like [Definition] and [Init] sub list_actions { my $dir = "$config{'config_dir'}/action.d"; my @rv; foreach my $f (glob("$dir/*.conf")) { my @conf = &parse_config_file($f); my @lconf = &parse_config_file(&make_local_file($f)); &merge_local_files(\@conf, \@lconf); if (@conf) { push(@rv, \@conf); } } return @rv; } # list_jails() # Returns a list of all sections from the jails file sub list_jails { # Read the main config file my @rv; my $jfile = "$config{'config_dir'}/jail.conf"; if (-r $jfile) { push(@rv, &parse_config_file($jfile)); } # Read separate config files under jail.d my $jdir = "$config{'config_dir'}/jail.d"; if (-d $jdir) { foreach my $f (glob("$jdir/*.conf")) { push(@rv, &parse_config_file($f)); } } # Read the main local file, and separate files under jail.d my @lrv; my $jlfile = &make_local_file($jfile); if (-r $jlfile) { push(@lrv, &parse_config_file($jlfile)); } if (-d $jdir) { foreach my $f (glob("$jdir/*.local")) { push(@lrv, &parse_config_file($f)); } } # Use local file entries to override the global config &merge_local_files(\@rv, \@lrv); return @rv; } # merge_local_files(&rv, &locals) # Merges .local file entries in with .conf files sub merge_local_files { my ($rv, $lrv) = @_; foreach my $l (@$lrv) { my ($r) = grep { $_->{'name'} eq $l->{'name'} } @$rv; if ($r) { # Section exists in the global config, so put the local # directives first my $m = { %$l }; $m->{'local'} = 1; $m->{'origfile'} = $r->{'file'}; push(@{$m->{'members'}}, @{$r->{'members'}}); $rv->[&indexof($r, @$rv)] = $m; } else { # Section does not exist, so just add it push(@$rv, $l); } } } # make_local_file(path) sub make_local_file { my ($f) = @_; $f =~ s/\.conf$/\.local/g; return $f; } # get_config() # Returns the global config as an array ref of directives sub get_config { my $file = "$config{'config_dir'}/fail2ban.conf"; my @conf = &parse_config_file($file); my @lconf = &parse_config_file(&make_local_file($file)); &merge_local_files(\@conf, \@lconf); return \@conf; } # parse_config_file(file) # Parses one file into a list of [] sections, each with multiple directives sub parse_config_file { my ($file) = @_; my $lref = &read_file_lines($file, 1); my $lnum = 0; my $fh = "CONF"; my $sect; my @rv; &open_readfile($fh, $file) || return ( ); while(<$fh>) { s/\r|\n//g; s/^\s*#.*$//; s/^\s;.*$//; if (/^\[([^\]]+)\]/) { # Start of a section $sect = { 'name' => $1, 'line' => $lnum, 'eline' => $lnum, 'file' => $file, 'members' => [] }; push(@rv, $sect); } elsif (/^(\S+)\s*=\s*(.*)/ && $sect) { # A directive in a section my $dir = { 'name' => $1, 'value' => $2, 'line' => $lnum, 'eline' => $lnum, 'file' => $file, }; push(@{$sect->{'members'}}, $dir); $sect->{'eline'} = $lnum; &split_directive_values($dir); } elsif (/^\s+(\S.*)/ && $sect && @{$sect->{'members'}}) { # Continuation of a directive my $dir = $sect->{'members'}->[@{$sect->{'members'}} - 1]; $dir->{'value'} .= "\n".$1; $dir->{'eline'} = $lnum; $sect->{'eline'} = $lnum; &split_directive_values($dir); } $lnum++; } close($fh); return @rv; } # split_directive_values(&dir) # Populate the 'values' field by splitting up the 'value' field sub split_directive_values { my ($dir) = @_; my @w; my $v = $dir->{'value'}; $v =~ s/\n/ /g; while($v =~ /\S/) { if ($v =~ /^([^\[]+\[[^\]]+\])\s*(.*)/) { push(@w, $1); $v = $2; } elsif ($v =~ /^\s*(\S+)\s*(.*)/) { push(@w, $1); $v = $2; } } $dir->{'words'} = \@w; } # create_section(file, §ion) # Add a new section to a file sub create_section { my ($file, $sect) = @_; my $lref = &read_file_lines($file); $sect->{'file'} = $file; $sect->{'line'} = scalar(@$lref); push(@$lref, §ion_lines($sect)); $sect->{'eline'} = scalar(@$lref); &flush_file_lines($file); } # modify_section(file, §ion) # Update the first line (only) for some section sub modify_section { my ($file, $sect) = @_; my $lref = &read_file_lines($file); my @lines = §ion_lines($sect); $lref->[$sect->{'line'}] = $lines[0]; &flush_file_lines($file); } # delete_section(file, §ion, [keep-file]) # Remove a section and all directives from a file sub delete_section { my ($file, $sect, $keepfile) = @_; my $lref = &read_file_lines($file); splice(@$lref, $sect->{'line'}, $sect->{'eline'} - $sect->{'line'} + 1); my $empty = 1; foreach my $l (@$lref) { my $ll = $l; $ll =~ s/^\s*#.*//; $empty = 0 if ($ll =~ /\S/); } if ($empty && !$keepfile) { # File is now empty, so delete it &unflush_file_lines($file); &unlink_file($file); } else { # Save the file &flush_file_lines($file); } } # section_lines(§ion) # Returns all the lines of text for some section plus directives sub section_lines { my ($sect) = @_; my @rv; push(@rv, "[".$sect->{'name'}."]"); foreach my $m (@{$sect->{'members'}}) { push(@rv, &directive_lines($m)); } return @rv; } # directive_lines(&directive) # Returns all lines of text for some directive sub directive_lines { my ($dir) = @_; my @rv; my @v = ref($dir->{'value'}) eq 'ARRAY' ? @{$dir->{'value'}} : split(/\n/, $dir->{'value'}); push(@rv, $dir->{'name'}." = ".shift(@v)); push(@rv, map { " ".$_ } @v); # Continuation return @rv; } # save_directive(name, value|&values|&directive, §ion) # Updates one directive in a section sub save_directive { my ($name, $v, $sect) = @_; my $dir; if (ref($v) eq 'HASH') { $dir = $v; } elsif (ref($v) eq 'ARRAY') { $dir = { 'name' => $name, 'value' => $v }; } elsif (defined($v)) { $dir = { 'name' => $name, 'value' => $v }; } else { $dir = undef; } my $old = &find($name, $sect); my $oldlen = $old ? $old->{'eline'} - $old->{'line'} + 1 : undef; my $oldidx = $old ? &indexof($old, @{$sect->{'members'}}) : -1; my $file = $old ? $old->{'file'} : $sect->{'file'}; my $lref = &read_file_lines($file); my @dirlines = defined($dir) ? &directive_lines($dir) : (); if ($old && defined($dir) && $old->{'value'} ne $dir->{'value'}) { # Update existing if ($sect->{'local'} && $old->{'file'} ne $sect->{'file'}) { # Section is in a local file, so to override we need to # add a new line in the local file &unflush_file_lines($file); $file = $sect->{'file'}; $lref = &read_file_lines($file); splice(@$lref, $sect->{'eline'}+1, 0, @dirlines); $dir->{'line'} = $sect->{'eline'}+1; $dir->{'file'} = $sect->{'file'}; $sect->{'eline'} += scalar(@dirlines); $dir->{'eline'} = $sect->{'eline'}; } else { # Just update the existing line splice(@$lref, $old->{'line'}, $oldlen, @dirlines); $dir->{'line'} = $old->{'line'}; $dir->{'eline'} = $dir->{'line'} + scalar(@dirlines) - 1; $dir->{'file'} = $sect->{'file'}; if ($oldidx >= 0) { $sect->{'members'}->[$oldidx] = $dir; } my $offset = scalar(@dirlines) - $oldlen; foreach my $m (@{$sect->{'members'}}) { next if ($m eq $dir || $m eq $old); if ($m->{'line'} > $old->{'line'}) { $m->{'line'} += $offset; $m->{'eline'} += $offset; } } } } elsif (!$old && defined($dir)) { # Add new if (!$sect->{'local'} && $file =~ /^(.*)\.conf$/) { # New directives should go in a .local file. We can assume at # this point that it doesn't exist yet, or that there is no # section in it. So convert this section object to local. my $lfile = $1.".local"; &unflush_file_lines($file); $file = $lfile; $lref = &read_file_lines($file); $sect->{'line'} = $sect->{'eline'} = scalar(@$lref); $sect->{'file'} = $file; splice(@$lref, $sect->{'eline'}, 0, "[$sect->{'name'}]"); splice(@$lref, $sect->{'eline'}+1, 0, @dirlines); $dir->{'line'} = $sect->{'eline'}+1; $dir->{'file'} = $sect->{'file'}; $sect->{'eline'} += scalar(@dirlines); $dir->{'eline'} = $sect->{'eline'}; } else { # Just add to the file the section is in (which will be local) splice(@$lref, $sect->{'eline'}+1, 0, @dirlines); $dir->{'line'} = $sect->{'eline'}+1; $dir->{'file'} = $sect->{'file'}; $sect->{'eline'} += scalar(@dirlines); $dir->{'eline'} = $sect->{'eline'}; } } elsif ($old && !defined($dir)) { # Remove existing splice(@$lref, $old->{'line'}, $oldlen); $sect->{'eline'} -= $oldlen; if ($oldidx >= 0) { splice(@{$sect->{'members'}}, $oldidx, 1); } foreach my $m (@{$sect->{'members'}}) { next if ($m eq $old); if ($m->{'line'} > $old->{'line'}) { $m->{'eline'} -= $oldlen; $m->{'line'} -= $oldlen; } } } &flush_file_lines($file); } sub find_value { my ($name, $object) = @_; my @rv = map { $_->{'value'} } &find($name, $object); return wantarray ? @rv : $rv[0]; } sub find { my ($name, $object) = @_; my $members = ref($object) eq 'HASH' ? $object->{'members'} : $object; my @rv = grep { lc($_->{'name'}) eq $name } @$members; return wantarray ? @rv : $rv[0]; } # filename_to_name(file) # Given a filename like /etc/fail2ban/foo.d/bar.conf , return bar sub filename_to_name { my ($file) = @_; $file =~ s/^.*\///; $file =~ s/\.[^\.]+$//; return $file; } # find_jail_by_filter(&filter) # returns the jail objects using a filter sub find_jail_by_filter { my ($filter) = @_; my $fname = &filename_to_name($filter->[0]->{'file'}); my @rv; foreach my $jail (&list_jails()) { my $jfilter = &find_value("filter", $jail); if ($jfilter eq $fname) { push(@rv, $jail); } } return @rv; } # find_jail_by_action(&action) # returns the jail objects using an action sub find_jail_by_action { my ($action) = @_; my $aname = &filename_to_name($action->[0]->{'file'}); my @rv; foreach my $jail (&list_jails()) { my $jaction = &find("action", $jail); next if (!$jaction); my @jactions = map { /^([^\[]+)/; $1 } @{$jaction->{'words'}}; if (&indexof($aname, @jactions) >= 0) { push(@rv, $jail); } } return @rv; } # start_fail2ban_server() # Attempts to start the server process, returning undef on success or an error message # on failure. sub start_fail2ban_server { if ($config{'init_script'}) { &foreign_require("init"); foreach my $init (split(/\s+/, $config{'init_script'})) { my ($ok, $out) = &init::start_action($init); return $out if (!$ok); } return undef; } else { my $out = &backquote_logged("$config{'client_cmd'} -x start 2>&1 </dev/null"); return $? ? $out : undef; } } # stop_fail2ban_server() # Attempts to stop the server process, returning undef on success or an error message # on failure. sub stop_fail2ban_server { if ($config{'init_script'}) { &foreign_require("init"); foreach my $init (split(/\s+/, $config{'init_script'})) { my ($ok, $out) = &init::stop_action($init); return $out if (!$ok); } return undef; } else { my $out = &backquote_logged("$config{'client_cmd'} stop 2>&1 </dev/null"); return $? ? $out : undef; } } # restart_fail2ban_server() # Force the fail2ban server to re-read its config sub restart_fail2ban_server { my ($force_restart) = @_; my $out; $out = &backquote_logged("$config{'client_cmd'} reload 2>&1 </dev/null") if (!$force_restart); if ($? || $force_restart) { &stop_fail2ban_server(); $out = &start_fail2ban_server(); } return $? ? $out : undef; } # list_all_config_files() # Returns a list of all Fail2Ban config files sub list_all_config_files { my @rv; push(@rv, "$config{'config_dir'}/fail2ban.local"); push(@rv, "$config{'config_dir'}/fail2ban.conf"); push(@rv, glob("$config{'config_dir'}/filter.d/*.conf")); push(@rv, glob("$config{'config_dir'}/filter.d/*.local")); push(@rv, glob("$config{'config_dir'}/action.d/*.conf")); push(@rv, glob("$config{'config_dir'}/action.d/*.local")); push(@rv, "$config{'config_dir'}/jail.conf"); push(@rv, "$config{'config_dir'}/jail.local"); push(@rv, glob("$config{'config_dir'}/jail.d/*.conf")); push(@rv, glob("$config{'config_dir'}/jail.d/*.local")); return grep { -r $_ || $_ =~ /fail2ban\.local$/ } @rv; } sub lock_all_config_files { @all_files_for_lock = &list_all_config_files(); foreach my $f (@all_files_for_lock) { &lock_file($f); } } sub unlock_all_config_files { foreach my $f (reverse(@all_files_for_lock)) { &unlock_file($f); } @all_files_for_lock = (); } # get_fail2ban_version() # Returns the version number, or undef if it cannot be found sub get_fail2ban_version { my $out = &backquote_command("$config{'client_cmd'} -V 2>/dev/null </dev/null"); return !$? && $out =~ /v([0-9\.]+)/ ? $1 : undef; } # Unblock given IP in given jail sub unblock_jailed_ip { my ($jail, $ip) = @_; my $cmd = "$config{'client_cmd'} set ".quotemeta($jail)." unbanip ".quotemeta($ip)." 2>&1 </dev/null"; my $out = &backquote_logged($cmd); if ($?) { &error(&text('status_err_unban', &html_escape($ip)) . " : $out"); } } 1;
Close