403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.133.109.58
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/apachelimits
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/apachelimits                    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::apachelimits;

use strict;
use warnings;

use Cpanel::Usage                        ();
use Cpanel::HttpUtils::Rlimits           ();
use Cpanel::HttpUtils::ApRestart::BgSafe ();
use Cpanel::Server::Type::License        ();

exit unless Cpanel::Server::Type::License::is_ea4_allowed();
exit __PACKAGE__->runner(@ARGV) if not caller();

sub runner {
    my ( $class, @argv ) = @_;

    #this is under the artistic lics
    print "Apache Limiter by cPanel, Inc. <copyright\@cpanel.net>\n\n";

    my $opts;
    my %OPTS = (
        'current'   => \$opts->{'current'},
        'rlimitmem' => \$opts->{'rlimitmem'},
        'disable'   => \$opts->{'disable'},
        'restart'   => \$opts->{'restart'},
    );
    Cpanel::Usage::wrap_options( \@argv, \&show_help, \%OPTS );

    if ( $> != 0 ) {
        print "[!] Sorry, only root can use this utility to modify Apache RLimits on the server.\n";
        return 1;
    }
    if ( $opts->{'current'} ) {
        return _current_rlimits();
    }
    elsif ( $opts->{'disable'} ) {
        return _disable_rlimits( $opts->{'restart'} );
    }
    else {
        return _set_rlimits( $opts->{'rlimitmem'}, $opts->{'restart'} );
    }
}

sub _current_rlimits {
    my $current    = Cpanel::HttpUtils::Rlimits::get_current_rlimitmem() || 0;
    my $current_MB = int( $current / ( 1024 * 1024 ) );
    print "[*] Current RLimitMEM: $current ( $current_MB MB )\n";
    return;
}

sub _disable_rlimits {
    my $restart_apache = shift;

    my $status;
    print "[*] Removing rlimits ... \n";
    eval { $status = Cpanel::HttpUtils::Rlimits::unset_rlimits_in_apache(); };

    if ( !$status ) {
        if ($@) {
            print "[!] Failed to remove rlimits: $@\n";
        }
        else {
            print "[!] Failed to remove rlimits: Unknown error.\n";
        }
    }
    else {
        print "[+] Removed rlimits successfully.\n";
    }

    return _restart_apache() if $restart_apache;
    return;
}

sub _set_rlimits {
    my ( $size, $restart_apache ) = @_;
    $size = _parse_rlimit($size);
    if ( !$size ) {
        print "[*] No valid rlimit specified. Calculating Limit to use...\n";
        ($size) = Cpanel::HttpUtils::Rlimits::determine_rlimitmem_for_apache();
        if ( !$size ) {
            print "[!] Unable to determine appropriate memory limit.\n";
            return 1;
        }
    }
    my $size_MB = int( $size / ( 1024 * 1024 ) );
    _current_rlimits();
    print "[*] Setting rlimit to: $size bytes( $size_MB MB ).\n";

    my $status;
    eval { $status = Cpanel::HttpUtils::Rlimits::set_rlimits_in_apache($size); };

    if ( !$status ) {
        if ($@) {
            print "[!] Failed to set new Rlimit: $@\n";
        }
        else {
            print "[!] Failed to set new Rlimit: Unknown error.\n";
        }
    }
    else {
        print "[+] Largest webserver child cgi/ssi/php is now limited to $size_MB MB.\n";
    }

    return _restart_apache() if $restart_apache;
    return;
}

sub _restart_apache {
    Cpanel::HttpUtils::ApRestart::BgSafe::restart();
    print "[+] Apache restarting the background.\n";
    return;
}

sub _parse_rlimit {
    my $input = shift or return;
    if ( $input =~ m/([0-9]+)([M])?$/i ) {
        my $number = $1;
        my $type   = $2;

        if ( $type eq "M" or $type eq "m" ) {
            $number *= 1024 * 1024;
        }
        return $number;
    }
    return;
}

sub show_help {
    print <<"EOM";
$0: Command line tool to manage Apache RLimits.

Usage:
    $0

    --current   : Display the current RlimitMEM value.
    --rlimitmem : The new RlimitMEM value to use. You can specify this in MB (eg: 64M), or bytes (eg: 67108864).
    --disable   : Remove the RlimitMEM and RlimitCPU limits.
    --restart   : Restart Apache after the changes have been made (Default: off)

    Note: If none of these options are specified, then the script will determine a value for RlimitMEM based on the amount of ram and swap available on the server, and update the limit to this value.

EOM
    exit 1;
}

Youez - 2016 - github.com/yon3zu
LinuXploit