403Webshell
Server IP : 127.0.1.1  /  Your IP : 127.0.0.1
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux sealall 5.15.0-179-generic #189-Ubuntu SMP Tue May 5 18:20:56 UTC 2026 x86_64
User : devops ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/domains/sealall.ca/wp-content/mu-plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/domains/sealall.ca/wp-content/mu-plugins/xcloud-auto-login.php
<?php /*
Plugin Name: xCloud Magic Login
Plugin URI: https://xcloud.host
Description: Secure login with xCloud two-way token verification, using unique magic URLs for enhanced user safety and convenience.
Version: 1.1.3
Author: xCloud
Author URI: https://xcloud.host
License: GPL2
*/

define('XCLOUD_MAGIC_HELPER_VERSION', '1.1.3');
define('XCLOUD_MAGIC_HELPER_AUTH_TOKEN', 'AgyWloOrmdnQxGY4V8XMbPjNMDbq5V1EB8Zz');
define('XCLOUD_MAGIC_HELPER_VERIFY_TOKEN', 'eyJpdiI6IlYwdktBMjRaQi95cFdib250amk0T2c9PSIsInZhbHVlIjoiN2NDa1N2T29OZ25ram9zdmN2MDd1Q3dObmV5cUFWUURuZ0VCTmNHWDEyTU01cm1wOXcrUzZwc3JFQ3QwMjVRUSIsIm1hYyI6IjcyOWVlNjVhOWViNDljZDczZWQ4Y2UwYzU2MmU1NmFjZmE2OWEwMmIxYmM3MThjNzk0YmFmOGMwMDVkODA4ZjciLCJ0YWciOiIifQ==');

class xCloudMagicLogin
{
    /**
     * Initialize the plugin by setting up hooks and actions
     */
    public function __construct()
    {
        add_action('init', array($this, 'handle_magic_url_login'));
        add_action('rest_api_init', array($this, 'register_rest_endpoint'));
    }

    /**
     * Handle the magic URL login process.
     */
    public function handle_magic_url_login()
    {
        if (empty($_GET['xcloud_magic_login_token']) || empty($_GET['auth_token'])) {
            return;
        }

        $xcloud_url = "https://app.xcloud.host/api/site/remote-login";
        $token = $_GET['xcloud_magic_login_token'];
        $auth_token = $_GET['auth_token'];
        $url = "{$xcloud_url}/verify";

        if ($auth_token != XCLOUD_MAGIC_HELPER_AUTH_TOKEN) {
            $this->log_error_and_redirect('Invalid auth token.', "https://app.xcloud.host/api/site/remote-login");
        }

        $response = wp_remote_get($url, array(
            'body' => array(
                'token' => $token,
                'auth_token' => XCLOUD_MAGIC_HELPER_AUTH_TOKEN,
                'verify_token' => XCLOUD_MAGIC_HELPER_VERIFY_TOKEN,
            )
        ));

        if (is_wp_error($response)) {
            $this->log_error_and_redirect($response->get_error_message(), $xcloud_url);
        }

        $body = wp_remote_retrieve_body($response);

        if (is_wp_error($body)) {
            $this->log_error_and_redirect($body->get_error_message(), $xcloud_url);
        }

        $xcloud_response = json_decode($body);

        if (empty($xcloud_response->success)) {
            $this->log_error_and_redirect('Invalid response. `'.$body.'`', $xcloud_url);
        }

        $user = $this->get_user_from_data($xcloud_response);

        if (empty($user)) {
            $this->log_error_and_redirect('Admin user not found.', $xcloud_url);
        }

        wp_set_auth_cookie($user->ID);
        wp_redirect(admin_url());
        exit;
    }

    /**
     * Register REST API endpoint for checking plugin status.
     */
    public function register_rest_endpoint()
    {
        register_rest_route('xcloud-magic-login/v1', '/plugin-status', array(
            'methods' => 'GET',
            'callback' => array($this, 'plugin_status'),
            'permission_callback' => '__return_true',
        ));
    }

    /**
     * Return the plugin status.
     */
    public function plugin_status()
    {
        $auth_token = isset($_GET['auth_token']) ? $_GET['auth_token'] : null;
        $code = 'xcloud_magic_login_is_active';
        $message = 'Plugin is active';

        if ($auth_token != XCLOUD_MAGIC_HELPER_AUTH_TOKEN) {
            $code = 'auth_token_invalid';
            $message = 'Invalid auth token';
        }

        return array(
            'code' => $code,
            'version' => XCLOUD_MAGIC_HELPER_VERSION,
            'message' => $message,
            'callback_url' => "https://app.xcloud.host/api/site/remote-login",
        );
    }

    /**
     * Log error
     *
     * @param  string  $error_message  The error message to log.
     */
    private function log_error($error_message)
    {
        error_log('xcloud_magic_url_login_custom_login : '.$error_message);
    }

    /**
     * Log error and redirect to a specified URL.
     *
     * @param  string  $error_message  The error message to log.
     * @param  string  $redirect_url  The URL to redirect to.
     */
    private function log_error_and_redirect($error_message, $redirect_url)
    {
        error_log('xcloud_magic_url_login_custom_login : '.$error_message);
        wp_redirect($redirect_url.'/failed');
        exit;
    }

    /**
     * Retrieve user based on the response data.
     *
     * @param  object  $xcloud_response  The response data.
     * @return WP_User|null The user object or null if not found.
     */
    private function get_user_from_data($xcloud_response)
    {
        $user = null;

        if (isset($xcloud_response->login_user)){
            $user = $this->get_wp_user($xcloud_response->login_user);
            if(!$user){
                $this->log_error('Custom user `'.$xcloud_response->login_user.'` not found.');
            }
            return $user;
        }

        if (empty($user) && isset($xcloud_response->email)) {
            $user = get_user_by('email', $xcloud_response->email);
        }

        if (empty($user) && isset($xcloud_response->user)) {
            $user = get_user_by('login', $xcloud_response->user);
        }

        if (empty($user)) {
            $admins = get_users(array(
                'role' => 'administrator',
                'orderby' => 'user_registered',
                'order' => 'ASC',
                'number' => 1,
            ));

            $user = isset($admins[0]) ? $admins[0] : null;
        }

        return $user;
    }

    /**
     * Retrieve user based on the response data.
     *
     * @param  object  $xcloud_response  The response data.
     * @return WP_User|null The user object or null if not found.
     */
    private function get_wp_user($login_user)
    {
        $user = null;

        if (isset($login_user)) {
            $user = get_user_by('email', $login_user);
        }

        if (empty($user)) {
            $user = get_user_by('login', $login_user);
        }

        return $user;
    }
}

// Instantiate the plugin class
new xCloudMagicLogin();


Youez - 2016 - github.com/yon3zu
LinuXploit