403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.227.209.214
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /scripts/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /scripts/backups_list_user_files
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/backups_list_user_files         Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

################################################################################

package scripts::backups_list_user_files;

use strict;
use warnings;

use Cpanel::Backup::Metadata ();
use Cpanel::DBI::SQLite      ();
use Getopt::Long             ();

################################################################################

Cpanel::Backup::Metadata::metadata_disabled_check(1);

################################################################################

sub _help {
    my ($msg) = @_;
    $msg //= '';

    print qq{$msg

Usage:

$0 --user=user [--regexp=regexp]

user - is the name of the user files to list
regexp - is an optional regex to refine your file list
};

    exit 0;
}

sub _invalid_parms {
    _help();
    die "Invalid Command Line Parameters\n";
}

our $user;
our $regexp;

sub generate_output {
    my ( $user, $regexp ) = @_;
    $regexp //= '';

    my $meta_path = Cpanel::Backup::Metadata::get_metadata_filename($user);
    my $dbh       = Cpanel::DBI::SQLite->connect( { 'database' => $meta_path } );

    # Get all the backup IDs and their paths
    my $sth     = $dbh->prepare(qq{SELECT backup_id,backup_path FROM backup_paths});
    my $results = $sth->execute();

    my @backups;
    while ( my $row = $sth->fetchrow_arrayref() ) {
        push @backups, { 'id' => $row->[0], 'path' => $row->[1] };
    }

    # type == 0 uncompressed
    # type == 1 compressed
    # type == 2 incremental
    # type == 3 other

    foreach my $backup (@backups) {

        # Get basedir with date by stripping /accounts/
        $backup->{'path'} =~ s/\/accounts$//;

        my $ref = Cpanel::Backup::Metadata::load_master_meta( $backup->{'path'} );

        if ( defined( $ref->{'backup_type'} ) and $ref->{'backup_type'} eq 'ERROR' ) {

            # print "Could not load .master.meta from " . $backup->{'path'} . "/accounts/\n"; # This would be a good case for adding a debugging/verbose flag to this script
            next;
        }
        my $backup_type_text = Cpanel::Backup::Metadata::get_backup_type_text( $ref->{'users'}{$user}{'backup_type'} );
        my $full_path_to_backup;
        if ( $ref->{'users'}{$user}{'backup_type'} == 0 ) {
            $full_path_to_backup = $backup->{'path'} . '/accounts/' . $user . '.tar';
        }
        elsif ( $ref->{'users'}{$user}{'backup_type'} == 1 ) {
            $full_path_to_backup = $backup->{'path'} . '/accounts/' . $user . '.tar.gz';
        }
        elsif ( $ref->{'users'}{$user}{'backup_type'} == 2 ) {
            $full_path_to_backup = $backup->{'path'} . '/accounts/' . $user;
        }
        else {
            $full_path_to_backup = '';
        }

        my $resolution_query = <<END;
SELECT
    b.backup_path,
    f.size,
    s.path,
    f.mtime,
    f.operation,
    f.type
FROM file_changes AS f
JOIN seen_files AS s ON f.seen_files_id = s.file_id
JOIN backup_paths AS b ON f.backup_id = b.backup_id
WHERE f.backup_id <= ?
GROUP BY path
HAVING operation != ?
ORDER BY s.path ASC
END

        my $sth = $dbh->prepare($resolution_query);
        $sth->execute( $backup->{'id'}, $Cpanel::Backup::Metadata::REMOVE_OPERATION );
        while ( my $row = $sth->fetchrow_arrayref() ) {
            my ( $bu_path, $size, $path, $mtime, $operation, $file_type ) = @{$row};
            my $full_path_to_backup_file;
            if ($regexp) {
                next if $path !~ m/$regexp/;
            }

            if ( $ref->{'users'}{$user}{'backup_type'} == 2 ) {
                $full_path_to_backup_file = $full_path_to_backup . '/homedir' . $path;
            }
            else {
                $full_path_to_backup_file = $full_path_to_backup;
            }

            my $file_type_text = Cpanel::Backup::Metadata::get_file_type_text($file_type);
            print '"' . gmtime($mtime) . '",' . $size . ',' . $backup_type_text . ',' . '"' . $path . '"' . ',"' . $full_path_to_backup_file . '",' . $file_type_text . "\n";

        }

    }

    return;
}

sub script {
    my (@args) = @_;

    my $opts = Getopt::Long::GetOptionsFromArray(
        \@args,
        'user=s'   => \$user,
        'regexp=s' => \$regexp,
    ) or _invalid_parms();

    _help("no user provided") if !$user;

    generate_output( $user, $regexp );

    return 1;
}

exit( script(@ARGV) ? 0 : 1 ) unless caller();

Youez - 2016 - github.com/yon3zu
LinuXploit