강력한 .env 파일 스캐너 업데이트

This commit is contained in:
2026-01-04 16:15:35 +09:00
parent 16451963ff
commit a5bc2198eb

View File

@@ -1,23 +1,32 @@
<?php
header('Content-Type: text/plain; charset=utf-8');
echo "=== File Search Result ===\n";
echo "=== Aggressive Env Search ===\n";
function deepSearch($dir) {
echo "Checking: $dir ... ";
if (!is_readable($dir)) {
echo "PERMISSION DENIED\n";
return;
}
echo "OK\n";
function searchEnv($dir, $depth = 0) {
if ($depth > 2) return;
echo "Scanning: $dir\n";
if (!is_dir($dir)) return;
$files = scandir($dir);
foreach ($files as $file) {
if ($file === '.' || $file === '..') continue;
if (strpos($file, '.env') !== false) {
echo "[FOUND] $dir/$file\n";
$content = file_get_contents("$dir/$file");
echo "--- Content of $file ---\n";
$path = $dir . DIRECTORY_SEPARATOR . $file;
// .env 라는 글자가 포함된 모든 파일 검색
if (strpos($file, '.env') !== false && is_file($path)) {
echo "\n[!!! FOUND !!!] Path: $path\n";
echo "--- Content (Masked) ---\n";
$content = file_get_contents($path);
foreach (explode("\n", $content) as $line) {
if (trim($line) === '') continue;
if (strpos($line, 'DB_PASS') !== false || strpos($line, 'PASSWORD') !== false) {
echo explode('=', $line)[0] . "=********\n";
$parts = explode('=', $line, 2);
$key = trim($parts[0]);
if (stripos($key, 'PASS') !== false || stripos($key, 'PW') !== false) {
echo "$key=********\n";
} else {
echo $line . "\n";
}
@@ -25,11 +34,14 @@ function searchEnv($dir, $depth = 0) {
echo "------------------------\n";
}
}
searchEnv(dirname($dir), $depth + 1);
}
searchEnv(__DIR__);
// 현재 경로, 상위 경로, 상위의 상위 경로까지 검색
$current = __DIR__;
deepSearch($current);
deepSearch(dirname($current));
deepSearch(dirname(dirname($current)));
echo "\n=== Permissions Check ===\n";
echo "Web User: " . posix_getpwuid(posix_geteuid())['name'] . "\n";
echo "Directory writable: " . (is_writable(__DIR__) ? "YES" : "NO") . "\n";
echo "\n=== System Info ===\n";
echo "Current User: " . `whoami`;
echo "Document Root: " . $_SERVER['DOCUMENT_ROOT'] . "\n";