403Webshell
Server IP : 89.39.208.18  /  Your IP : 216.73.217.74
Web Server : LiteSpeed
System :
User :  ( )
PHP Version : 7.4.33
Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home3/mahyarcake/www/wp-content/plugins/duplicator-pro/src/Utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home3/mahyarcake/www/wp-content/plugins/duplicator-pro/src/Utils//PHPExecCheck.php
<?php

/**
 * @package   Duplicator
 * @copyright (c) 2022, Snap Creek LLC
 */

namespace Duplicator\Utils;

use Duplicator\Libs\Snap\SnapUtil;
use Error;
use Exception;
use VendorDuplicator\WpOrg\Requests\Requests;
use VendorDuplicator\WpOrg\Requests\Auth\Basic;
use VendorDuplicator\WpOrg\Requests\Response;

/**
 * PHP check utility
 */
class PHPExecCheck
{
    /** @var string */
    protected $dir = '';
    /** @var string */
    protected $url = '';
    /** @var string */
    protected $phpTestFile = '';
    /** @var null|Response */
    protected $lastResponse = null;
    /** @var string */
    protected $lastError = '';

    const PHP_OK               = 1;
    const PHP_FAIL_FILE_CREATE = -1;
    const PHP_REQUEST_FAIL     = -2;
    const PHP_RESULT_FAIL      = -3;

    const TEST_FILE_PREFIX  = 'dup_php_test_';
    const TEST_FILE_CONTENT = <<<TEST
<?php echo "abcde";
TEST;


    /**
     * Class contructor
     *
     * @param string $dir dir to check
     * @param string $url related URL dir
     */
    public function __construct($dir, $url)
    {
        if (!is_dir($dir)) {
            throw new Exception('Dir ' . $dir . ' must be a directory');
        }
        $this->dir = trailingslashit($dir);
        $this->url = trailingslashit($url);
    }

    /**
     * Class destructor
     */
    public function __destruct()
    {
        $this->removeTestFile();
    }

    /**
     * Check if PHP is executable in $dir
     *
     * @return int return PHP check result status (see constants)
     */
    public function check()
    {
        try {
            $this->lastResponse = null;
            $this->lastError    = '';

            if ($this->createTestFile() == false) {
                throw new Exception('Couldn\'t create test php file', self::PHP_FAIL_FILE_CREATE);
            }

            $options = array(
                //'max_bytes' => 250,
                'verify'     => false,
                'verifyname' => false,
            );

            $phpAuthUser = SnapUtil::sanitizeTextInput(INPUT_SERVER, 'PHP_AUTH_USER', '');
            $phpAuthPw   = SnapUtil::sanitizeTextInput(INPUT_SERVER, 'PHP_AUTH_PW', '');
            if (strlen($phpAuthUser) > 0) {
                $options['auth'] = new Basic(array(
                    $phpAuthUser,
                    strlen($phpAuthPw) > 0 ? $phpAuthPw : '',
                ));
            }

            $testUrl            = $this->url . basename($this->phpTestFile);
            $this->lastResponse = $response = Requests::get(
                $testUrl,
                array(),
                $options
            );

            $this->removeTestFile();

            if ($response->success !== true || $response->status_code !== 200) {
                throw new Exception("Server responded with status code $response->status_code. File: $testUrl", self::PHP_REQUEST_FAIL);
            }

            if (strcmp($response->body, 'abcde') !== 0) {
                throw new Exception('The HTTP response body is different from expected result. Please check if PHP is running.', self::PHP_RESULT_FAIL);
            }
        } catch (Exception $e) {
            $this->lastError = $e->getMessage();
            $this->removeTestFile();
            return $e->getCode();
        } catch (Error $e) {
            $this->lastError = $e->getMessage();
            $this->removeTestFile();
            return $e->getCode();
        }

        return self::PHP_OK;
    }

    /**
     * Create test file, removes the old one if it already exists.
     *
     * @return bool Returns true on success or false on failure.
     */
    protected function createTestFile()
    {
        $this->removeTestFile();

        // prevent tempnam to create the file in system's temporary directory
        if (!is_writable($this->dir)) {
            return false;
        }

        if (($tempfile = tempnam($this->dir, self::TEST_FILE_PREFIX)) === false) {
            return false;
        }
        unlink($tempfile); // remove temp file to recreate it with php extension
        $this->phpTestFile = $tempfile . '.php';
        return (file_put_contents($this->phpTestFile, self::TEST_FILE_CONTENT) !== false);
    }

    /**
     * Remove test file if exists
     *
     * @return bool Returns true on success or false on failure.
     */
    protected function removeTestFile()
    {
        $result = true;
        if (strlen($this->phpTestFile) == 0) {
            return $result;
        }

        if (file_exists($this->phpTestFile)) {
            $result = unlink($this->phpTestFile);
        }

        $this->phpTestFile = '';
        return $result;
    }

    /**
     * Get responde of last check
     *
     * @return null|Response
     */
    public function getLastResponse()
    {
        return $this->lastResponse;
    }

    /**
     * Get last error message
     *
     * @return string Returns error message of last check
     */
    public function getLastError()
    {
        return $this->lastError;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit