~ K A L I ~
UNAME : Linux web65.extendcp.co.uk 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64SERVER IP : 10.0.187.65 -________-
CLIENT IP : 216.73.216.230 MINI SHELL D ZAB '
Current File : //usr/lib/perl5/vendor_perl/5.8.8/ftpcp/permissions.pm |
package ftpcp::permissions;
use ftpcp;
use warnings;
use strict;
=head1 NAME
ftpcp::permissions
=head1 DESCRIPTION
A permissions scanner for ftpcp. Finds files which deviate from expected
permissions, in effect.
=head1 SYNOPSIS
use ftpcp;
use ftpcp::permissions;
my $ftpcp = new ftpcp();
my $ftpcp_s = new ftpcp::single($server, $username, $password);
ftpcp::permissions::scan($ftpcp_s, \%ext_to_perms);
=head1 METHODS
=head2 scan($ftps, \%ext_to_perms, \@res, \&on_find_callback)
Performs the scan.
%ext_to_perms is a hash mapping file extensions (not including the dot)
to a list of allowed numeric permissions.
Special keys are:
=over
=item ""
The default permissions. Includes by default 755, 711, 700, 644 and 600.
=item "."
Directory permissions. By default, this is 755, 711 and 700; it's very
unlikely that you would need to change it.
=back
@res is a set of regular expressions allowing you to perform more
fine-grained mapping of extensions, for example:
(qr/Makefile/)
If this matches, the extension would be considered to be the regular
expression object (or at least its string value).
When a file of incorrect mode is discovered, on_find_callback($path,
$mode, \@allowed_modes) will be called. This is intended to allow
reflexive corrections or continuous output.
Returns a hash mapping the paths of incorrect-mode filess to [$mode,
\@allowed_modes].
=cut
sub scan {
my ($ftps, $ext_to_perms_h, $res_a, $on_find_callback) = @_;
$ext_to_perms_h->{""} ||= [0755,0711,0700,0644,0600];
$ext_to_perms_h->{"."} ||= [0755,0711,0700];
for(keys %$ext_to_perms_h) {
unless(ref $ext_to_perms_h->{$_}) {
$ext_to_perms_h->{$_} = [ $ext_to_perms_h->{$_} ];
}
}
my @res = @$res_a;
my %exceptions_by_path;
if(1) {
$ftps->ls_lR(".", sub {
my ($d) = @_;
return if $d->{filename}=~/^\.\.?$/;
my $path = $d->{filename};
my $ext="";
if($d->{type} eq "d") {
$ext = ".";
} elsif($d->{type} eq "-") {
if($d->{filename}=~/\.([^.]*)$/) {
$ext = lc($1);
}
} else {
return;
}
$ext = "" unless $ext_to_perms_h->{$ext};
for(@res) {
if(ref($_) and $d->{filename}=~$_) {
$ext = $_;
last;
}
}
my @allowed_permissions = @{ $ext_to_perms_h->{$ext} };
unless(grep {$d->{mode} == $_} @allowed_permissions) {
$exceptions_by_path{$path} = [$d->{mode}, \@allowed_permissions];
&{$on_find_callback}($path, $d->{mode}, \@allowed_permissions)
if $on_find_callback;
}
});
}
return %exceptions_by_path;
}
1;
Coded by KALI :v Greetz to DR HARD ../ kali.zbi@hotmail.com