%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /root/
Upload File :
Create Path :
Current File : //root/.bash_history.cpanel_ticket.94491923

#1665003482
export PS1="Still logged into remote - \TcPs# "
#1665003482
export LANG=en_US.UTF-8
#1665003482
export PS1="[\t \h \u@94491923 \w]cPs# "
#1665003482
export HISTFILE=~/.bash_history.cpanel_ticket.94491923
#1665003483
export HISTFILESIZE=100000
#1665003484
set +o emacs +o vi
#1665003484
IFS='' read -r -d '' PACHA_AUTOFIXER <<-'EOF_PACHA'
use strict;

BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

our $VERSION = '1.2';

my $shell_pid = get_shell_pid();
my $shell_exe = get_pid_exe($shell_pid);

$| = 1;

print "ENTER_TEMP_RESELLER_AND_PASSWORD: ";

open( STDIN, '<&STDOUT' ) || die "Could not open STDOUT";
my $userpass = <STDIN>;
chomp($userpass);

eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };

if ( !$userpass ) {
    die "Failed to read userpass";
}

my ( $user, $pass ) = split( m{\s+}, $userpass, 2 );

if ( $user !~ /^cp/ ) {
    die "User must start with cp";
}

my ($ticket_number) = ( $user =~ m/([0-9]+)/ );

$SIG{'INT'}   = \&exit_cleanly;
$SIG{'TERM'}  = \&exit_cleanly;
$SIG{__DIE__} = \&exit_cleanly;

if ( my $pid = fork() ) {

}
else {
    $0 = "cpanelsupportmgr - waiting for $shell_pid to exit for cleanup";
    daemonize();
    wait_for_death($shell_pid);
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

add_user( $user, "auto onetime user for cpanel ticket $ticket_number autoremoved at logout" ) if !getpwnam($user);
set_user_pass( $user, $pass );
make_root_reseller($user);

print "CREATE_TEMP_RESELLER_DONE\n";

sub exit_cleanly {
    remove_user($user);
    unmake_root_reseller($user);
    exit;
}

sub unmake_root_reseller {
    my ($user) = @_;

    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt !~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already removed from resellers\n";
        return;
    }
    my @all_res_line = grep { !m/^\Q$user\E:/ } split( /\n/, $txt );
    seek( $fh, 0, 0 );
    print {$fh} join( "\n", @all_res_line ) . "\n";
    truncate( $fh, tell($fh) );
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub make_root_reseller {
    my ($user) = @_;
    eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Cpanel::SafeFile; };
    my $resellers_file = '/var/cpanel/resellers';
    my $lock;
    my $fh;

    system 'touch', $resellers_file;    #incase we don't have touchfile
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        if ( !( $lock = Cpanel::SafeFile::safeopen( $fh, '+<', $resellers_file ) ) ) {
            print "Failed to open + lock $resellers_file: $1\n";
            exit 1;
        }
    }
    else {
        if ( !open( $fh, '+<', $resellers_file ) ) {
            print "Failed to open $resellers_file: $1\n";
            exit 1;
        }
    }
    my $txt;
    {
        local $/ = undef;
        $txt = readline($fh);
    }
    if ( $txt =~ m/^\Q$user\E:/m ) {
        if ( $INC{'Cpanel/SafeFile.pm'} ) {
            Cpanel::SafeFile::safeclose( $fh, $lock );
        }
        print "already in resellers\n";
        return;
    }
    print {$fh} "$user:all\n";
    if ( $INC{'Cpanel/SafeFile.pm'} ) {
        Cpanel::SafeFile::safeclose( $fh, $lock );
    }
    return;
}

sub set_user_pass {
    my ( $user, $pass ) = @_;
    local $ENV{'ALLOW_PASSWORD_CHANGE'} = 1;
    my $script_path 
    if ( -d "/usr/local/cpanel/scripts" ) {
        $script_path = "/usr/local/cpanel/scripts";
    }
    my $chpass_write_fh;
    my $chpass_read_fh;
    my $pid = inout( $chpass_write_fh, $chpass_read_fh, "$script_path/chpass" );
    if ( !$pid ) {
        return (
            0,
            "Failed to execute: $script_path/chpass: $!",
            "Failed to execute: $script_path/chpass: $!"
        );
    }
    print {$chpass_write_fh} "$user $pass\n";
    close($chpass_write_fh);
    my $result;
    {
        local $/ = undef;
        $result = readline($chpass_read_fh);
    }
    close($chpass_read_fh);
    waitpid( $pid, 0 );
    return $result;

}

sub get_shell_pid {
    my $parent_pid = get_parent_pid($$);
    while ( get_pid_exe($parent_pid) =~ /perl/ ) {
        $parent_pid = get_parent_pid($parent_pid);
    }
    return $parent_pid;
}

sub _zero_quota {
    my $login = shift;

    system( '/usr/local/cpanel/scripts/editquota', $login, '0M' );
    return $?;
}

sub add_user {
    my ( $login, $comment ) = @_;
    system '/usr/sbin/useradd', '-c', $comment, $login;
    my $ua_status = $?;
    if ( open( my $cph_fh, '>', "/var/cpanel/users/$login" ) ) {
        my $time = time();

        print {$cph_fh} "#Automatic temp user created by cPanel support\nCONTACTEMAIL=cs\@cpanel.net\nPLAN=cPanel Ticket System temporary user\nOWNER=root\nSTARTDATE=$time\nDNS=$login.tickets.cpanel.net\nUSER=$login\n";
        close($cph_fh);
    }
    return $ua_status;
}

sub remove_user {
    my ($login) = @_;
    system '/usr/sbin/userdel', '-r', $login;
    system '/usr/sbin/userdel', $login;
    unlink( "/var/cpanel/users/$login", "/var/cpanel/users.cache/$login" );
    system '/scripts/updateuserdomains';    # remove it for sure
    return $?;
}

sub get_parent_pid {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return getppid() if $pid == $$;
    if ( open( my $proc_status_fh, '<', "/proc/$pid/status" ) ) {
        local $/;
        my %status = map { lc $_->[0] => $_->[1] }
          map { [ ( split( /\s*:\s*/, $_ ) )[ 0, 1 ] ] }
          split( /\n/, readline($proc_status_fh) );
        return $status{'ppid'};
    }

}

sub get_pid_exe {
    my ($unsafe_pid) = @_;
    my ($pid)        = $unsafe_pid =~ /([0-9]+)/;
    return readlink( '/proc/' . $pid . '/exe' );
}

sub inout {    ## no critic qw(RequireArgUnpacking)
    my $wtr = $_[0] ||= SymbolLite::gensym();
    my $rdr = $_[1] ||= SymbolLite::gensym();

    my $child_read;

    pipe( $child_read, $wtr );

    select( ( select($wtr),        $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $wtr->autoflush(1);
    select( ( select($child_read), $| = 1 )[0] );    ## no critic qw(ProhibitOneArgSelect)   #aka $child_read->autoflush(1);

    if ( my $pid = open( $rdr, '-|' ) ) {
        return $pid;
    }
    elsif ( defined $pid ) {
        open( STDIN, '<&=', fileno($child_read) ) || die "Could not open STDIN";
        if ( ref $_[2] eq 'CODE' ) {
            $_[2]->();
            exec( @_[ 3 .. $#_ ] );
        }
        else {
            exec( @_[ 2 .. $#_ ] );
        }
        exit 1;
    }
    else {
        return;
    }
}

sub wait_for_death {
    my (@pids) = @_;

    my $num_killed = kill( 0, @pids );

    my $loop_count = 0;
    while ( $num_killed && ++$loop_count <= 345600 ) {    # Will timeout after about 24 hours if cp staff has not disconnected.
        $num_killed = kill( 0, @pids );
        select( undef, undef, undef, 0.25 )               ## no critic qw(ProhibitSleepViaSelect);
    }

    return;
}

sub daemonize {
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require Cpanel::CloseFDs; };
    setpgrp( 0, 0 );                                      #cheap setsid();
    eval { local $SIG{__WARN__}; local $SIG{__DIE__}; Cpanel::CloseFDs::fast_daemonclosefds(); } if $INC{'Cpanel/CloseFDs.pm'};
    if ( !$INC{'Cpanel/CloseFDs.pm'} || $@ ) {
        eval { local $SIG{__WARN__}; local $SIG{__DIE__}; require POSIX; };
        open( STDOUT, '>', '/dev/null' ) || warn "Failed to connect STDOUT to /dev/null";
        open( STDERR, '>', '/dev/null' ) || warn "Failed to connect STDERR to /dev/null";
        open( STDIN,  '<', '/dev/null' ) || warn "Failed to connect STDIN to /dev/null";
        eval {
            local $SIG{__WARN__};
            local $SIG{__DIE__};
            for ( 3 .. 1024 ) {
                POSIX::close($_);
            }
        };
    }

    return 1;

}

package SymbolLite;

my $genpkg = "SymbolLite::";
my $genseq = 0;

sub gensym {
    no strict 'refs';    ## no critic qw(ProhibitNoStrict);
    my $name = "GEN" . $genseq++;
    my $ref  = \*{ $genpkg . $name };
    delete $$genpkg{$name};
    return $ref;
}

EOF_PACHA

#1665003484
echo "$PACHA_AUTOFIXER" | /usr/local/cpanel/3rdparty/bin/perl -c
#1665003488
set -o emacs
#1665003488
/bin/mkdir /tmp/4cp900AjbzsF3juM/
#1665003488
/bin/chown vipin:vipin /tmp/4cp900AjbzsF3juM/
#1665003488
/bin/chmod 744 /tmp/4cp900AjbzsF3juM/
#1665003488
[ -d "/tmp/4cp900AjbzsF3juM/" ]&&echo "TMP_DIR_EXISTS"||echo "TMP_DIR_MISSING"
#1665003489
/usr/local/cpanel/3rdparty/bin/perl /tmp/4cp900AjbzsF3juM/create_temp_reseller_for_ticket_access_XTAFqDA1knZ4L1mH; /bin/rm -rf /tmp/4cp900AjbzsF3juM/
#1665003490
echo "a.gros@cpanel.net (WHMuser: cptkt2wvfedysff5 ) logged in for 94491923  - ready for cPanel support"
#1665003490
uname -a
#1665003491
echo -ne '\033]0;cPTKT 94491923 - Domain resolution regarding two domains, Server: 1\007'
#1665003494
alias reboot='echo "Are you sure you want to REBOOT a customer server? If so use /usr/sbin/reboot"'
#1665003494
alias rm='echo "Are you sure you want to remove files? If so use /bin/rm"'
#1665003494
alias acctinfo='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelInc/tech-acctinfo/master/acctinfo)'
#1665003494
alias init='echo "Are you sure you want to change run runlevel on a customer server? If so use /usr/sbin/init"'
#1665003494
alias cplicensets='/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)'
#1665003494
alias shutdown='echo "Are you sure you want to SHUTDOWN a customer server? If so use /usr/sbin/shutdown"'
#1665003494
alias sqlite3='/usr/local/cpanel/3rdparty/bin/sqlite3'
#1665003494
alias crontab='crontab -i'
#1665003494
curl https://ssp.cpanel.net/run|sh
#1665003765
acctinfo gifterman.in
#1665003953
acctinfo vfmassets.com
#1665004559
egrep -l "vfmassets.com|gifterman.in" /var/named/*.db
#1665004582
grep -l ns1.nexidigital.com /var/named/*.db
#1665004608
stat /var/named/vfmassets*
#1665004619
stat /var/named/gifterman*

Zerion Mini Shell 1.0