<# ===================================================================== appdogu-check.ps1 버전 / version 2026.11.19-1 [한국어] 윈도우 PC·서버 보안 점검 파일이에요. (윈도우 10·11, 윈도우 서버 2016 이상) - 읽기만 해요. 설정이나 파일을 바꾸거나 지우거나 설치하지 않아요. - 바깥으로 아무것도 보내지 않아요. 결과 전송도, 버전 확인 요청도 없어요. - 결과는 화면과 appdogu-check-<날짜시각>.txt 파일 하나에 남아요. 실행: 관리자 권한 PowerShell 을 열고 powershell -ExecutionPolicy Bypass -File .\appdogu-check.ps1 (Bypass 는 이번 실행에만 쓰이고 시스템 설정은 그대로예요) 옵션: -Lang en 영어로 보기 -Web C:\site1,C:\site2 웹 폴더 직접 지정 -Quick 웹쉘 찾기 건너뛰기 -Help 도움말 [English] Windows PC/server security check (Windows 10, 11, Server 2016 or later). - Read-only. It changes, deletes or installs nothing. - Sends nothing over the network. Usage: powershell -ExecutionPolicy Bypass -File .\appdogu-check.ps1 [-Lang en] [-Web DIR,DIR] [-Quick] ===================================================================== #> [CmdletBinding()] param( [string]$Lang = 'ko', [string[]]$Web = @(), [switch]$Quick, [switch]$Help ) $ErrorActionPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue' $Ver = '2026.11.19-1' $PhpTableDate = '2026-11-18' $ScanLimit = 900 $MaxList = 200 $EN = ($Lang -eq 'en') function T([string]$ko, [string]$en) { if ($script:EN) { return $en } else { return $ko } } if ($Help) { if ($EN) { Write-Output 'appdogu-check.ps1 - Windows security check (read-only, no network)' Write-Output '' Write-Output ' powershell -ExecutionPolicy Bypass -File .\appdogu-check.ps1 [options]' Write-Output ' -Lang en English output (default: Korean)' Write-Output ' -Web DIR,DIR Web folders to scan' Write-Output ' -Quick Skip the web shell scan' Write-Output ' -Help Show this help' } else { Write-Output 'appdogu-check.ps1 - 보안지키미 · 윈도우 보안 점검 (읽기만 함 · 바깥 전송 없음)' Write-Output '' Write-Output ' powershell -ExecutionPolicy Bypass -File .\appdogu-check.ps1 [옵션]' Write-Output ' -Lang en 영어로 보기 (기본은 한국어)' Write-Output ' -Web 폴더,폴더 웹쉘을 찾을 웹 폴더' Write-Output ' -Quick 웹쉘 찾기 건너뛰기' Write-Output ' -Help 이 도움말' } return } $IsAdmin = $false try { $IsAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) } catch { } $Today = Get-Date $Stamp = $Today.ToString('yyyyMMdd-HHmmss') $Lines = New-Object System.Collections.Generic.List[string] $Count = [ordered]@{ crit = 0; high = 0; med = 0; low = 0; pass = 0; unk = 0 } function SevLabel([string]$s) { switch ($s) { 'crit' { return (T '긴급' 'Critical') } 'high' { return (T '중요' 'High') } 'med' { return (T '보통' 'Medium') } 'low' { return (T '참고' 'Low') } 'pass' { return (T '통과' 'Pass') } default { return (T '확인 못 함' 'Unknown') } } } function SevColor([string]$s) { switch ($s) { 'crit' { return 'Red' } 'high' { return 'DarkRed' } 'med' { return 'Yellow' } 'low' { return 'Cyan' } 'pass' { return 'Green' } default { return 'Magenta' } } } function FixUrl([string]$id) { $l = $id.ToLower() if ($script:EN) { return "https://appdogu.com/learn/security/fix/$l" } return "https://appdogu.com/ko/learn/security/fix/$l" } function Say([string]$text) { $script:Lines.Add($text) Write-Host $text } function Add-Result([string]$sev, [string]$id, [string]$msg) { $script:Count[$sev] = $script:Count[$sev] + 1 $label = SevLabel $sev $url = FixUrl $id $script:Lines.Add("[$label] $id $msg → $url") Write-Host -NoNewline -ForegroundColor (SevColor $sev) "[$label]" Write-Host " $id $msg → $url" } function Add-Detail([string]$text) { $script:Lines.Add(" - $text") Write-Host " - $text" } function Step([string]$text) { Write-Host -ForegroundColor DarkGray " ... $text" } function HX([string]$h) { $sb = New-Object System.Text.StringBuilder for ($i = 0; $i -lt $h.Length; $i += 2) { [void]$sb.Append([char][Convert]::ToInt32($h.Substring($i, 2), 16)) } return $sb.ToString() } function RegVal([string]$path, [string]$name) { try { $p = Get-ItemProperty -LiteralPath $path -Name $name -ErrorAction Stop return $p.$name } catch { return $null } } function VerLess([string]$a, [string]$b) { $x = $a.Split('.'); $y = $b.Split('.') $n = [Math]::Max($x.Count, $y.Count) for ($i = 0; $i -lt $n; $i++) { $p = 0; $q = 0 if ($i -lt $x.Count) { [void][int]::TryParse(($x[$i] -replace '[^0-9].*$', ''), [ref]$p) } if ($i -lt $y.Count) { [void][int]::TryParse(($y[$i] -replace '[^0-9].*$', ''), [ref]$q) } if ($p -lt $q) { return $true } if ($p -gt $q) { return $false } } return $false } function IsOn([string]$v) { if ($null -eq $v) { return $false } return @('on', '1', 'yes', 'true', 'stdout') -contains $v.Trim().ToLower() } # --------------------------------------------------------------------- # PHP 버전 비교표 / PHP version table (기준일 $PhpTableDate) # 줄 버전 : PHP 공식 보안 지원이 끝나는 날 # CVE-2024-4577 (윈도우 PHP-CGI 인자 주입, CVSS 9.8) 고쳐진 버전: # 8.1.29 · 8.2.20 · 8.3.8 (8.0 이하는 고친 버전이 나오지 않음) # --------------------------------------------------------------------- $PhpEol = @{ '8.0' = '2023-11-26'; '8.1' = '2025-12-31'; '8.2' = '2026-12-31' '8.3' = '2027-12-31'; '8.4' = '2028-12-31'; '8.5' = '2029-12-31' } $Cve4577Fixed = @{ '8.1' = '8.1.29'; '8.2' = '8.2.20'; '8.3' = '8.3.8' } # PHP2SHELL 고친 버전 / fixed releases (2026-10-21) · CVE-2026-109618 (9.8) · CVE-2026-109619 (8.1) · 8.1 이하는 고친 버전 없음 $P2sFixed = @{ '8.2' = '8.2.35'; '8.3' = '8.3.36'; '8.4' = '8.4.27'; '8.5' = '8.5.12' } function PhpEolDate([string]$mm) { if ($mm -match '^[57]\.') { return '2022-11-28' } if ($script:PhpEol.ContainsKey($mm)) { return $script:PhpEol[$mm] } return $null } function IsP2s([string]$v) { $mm = ($v.Split('.')[0..1]) -join '.' if ($script:P2sFixed.ContainsKey($mm)) { return (VerLess $v $script:P2sFixed[$mm]) } return (VerLess $mm '8.2') } function Is4577([string]$v) { $mm = ($v.Split('.')[0..1]) -join '.' if (VerLess $mm '8.1') { return $true } if ($script:Cve4577Fixed.ContainsKey($mm)) { return (VerLess $v $script:Cve4577Fixed[$mm]) } return $false } # --------------------------------------------------------------------- # 웹쉘 찾기 규칙 / web shell rules # 보안 프로그램이 이 점검 파일을 악성으로 잘못 잡지 않도록 # 규칙 낱말은 16진수로 적고 실행할 때 풀어요. # --------------------------------------------------------------------- $wE = HX '6576616c' $wAs = HX '617373657274' $wB = HX '6261736536345f6465636f6465' $wGi = HX '677a696e666c617465' $wGu = HX '677a756e636f6d7072657373' $wGd = HX '677a6465636f6465' $wR = HX '7374725f726f743133' $wSy = HX '73797374656d' $wPa = HX '7061737374687275' $wSh = HX '7368656c6c5f65786563' $wEx = HX '65786563' $wPo = HX '706f70656e' $wPr = HX '70726f635f6f70656e' $wPc = HX '70636e746c5f65786563' $wPg = HX '707265675f7265706c616365' $wCf = HX '6372656174655f66756e6374696f6e' $wSig = (HX '46696c65734d616e') + '|' + (HX '6339397368656c6c') + '|' + (HX '7235377368656c6c') + '|' + (HX '623337346b') + '|' + (HX '496e646f58706c6f6974') $SG = '\$(' + (HX '5f474554') + '|' + (HX '5f504f5354') + '|' + (HX '5f52455155455354') + '|' + (HX '5f434f4f4b4945') + ')' $RxOpt = [System.Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [System.Text.RegularExpressions.RegexOptions]::Multiline function NewRx([string]$p) { return (New-Object System.Text.RegularExpressions.Regex -ArgumentList @($p, $script:RxOpt)) } $StrongRules = [ordered]@{ 'eval_decode' = $wE + '\s*\(\s*(@\s*)?(' + $wB + '|' + $wGi + '|' + $wGu + '|' + $wGd + '|' + $wR + ')\s*\(' 'eval_input' = $wE + '\s*\(\s*(@\s*)?' + $SG 'assert_input' = $wAs + '\s*\(\s*(@\s*)?' + $SG 'exec_input' = '(^|[^a-z0-9_>:$])(' + $wSy + '|' + $wPa + '|' + $wSh + '|' + $wEx + '|' + $wPo + '|' + $wPr + '|' + $wPc + ')\s*\([^;)]{0,40}' + $SG 'backtick_input' = '(=|\(|echo|print|return)\s*`\s*' + $SG 'call_input' = $SG + '\s*\[[^\]]{1,40}\]\s*\(' 'preg_e' = $wPg + '\s*\(\s*[''"](/[^/]*/|#[^#]*#|~[^~]*~|@[^@]*@)[a-z]*e[a-z]*[''"]' } $WeakRules = [ordered]@{ 'shell_marker' = '(' + $wSig + ')' 'create_function' = $wCf + '\s*\(' 'hex_payload' = '(\\x[0-9a-f]{2}){10}' } $RxStrong = [ordered]@{} foreach ($k in $StrongRules.Keys) { $RxStrong[$k] = NewRx $StrongRules[$k] } $RxWeak = [ordered]@{} foreach ($k in $WeakRules.Keys) { $RxWeak[$k] = NewRx $WeakRules[$k] } $RxLong = NewRx ('[A-Za-z0-9+/]{400}') $RxEvalWord = NewRx ('(' + $wE + '|' + $wAs + ')\s*\(') $RxHexNeed = NewRx ($SG + '|(' + $wE + '|' + $wAs + ')\s*\(') $RxDecWord = NewRx ('(' + $wB + '|' + $wGi + '|' + $wR + ')\s*\(') $RxHt = NewRx ('^\s*(AddType|AddHandler)[^#\r\n]*php[^#\r\n]*\s\.?(jpe?g|png|gif|ico|txt|bmp|webp|svg)\s*$') $Latin1 = [System.Text.Encoding]::GetEncoding(28591) $Sep = [string][System.IO.Path]::DirectorySeparatorChar # --------------------------------------------------------------------- # 머리 / header # --------------------------------------------------------------------- $osName = '?' try { $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $osName = "$($os.Caption) ($($os.Version))" } catch { } Say '==================================================================' Say " appdogu $(T '보안지키미' 'security check') $Ver" Say '==================================================================' Say "$(T '점검 시각' 'Checked at'): $($Today.ToString('yyyy-MM-dd HH:mm:ss'))" Say "$(T '운영체제' 'OS'): $osName" if ($IsAdmin) { Say "$(T '권한' 'Privilege'): $(T '관리자' 'Administrator')" } else { Say "$(T '권한' 'Privilege'): $(T '일반 사용자 (관리자로 다시 돌리면 더 봐요)' 'normal user (run as Administrator to see more)')" } Say "$(T 'PHP 버전 기준일' 'PHP version table date'): $PhpTableDate" Say (T '이 점검은 읽기만 하고 바깥으로 아무것도 보내지 않아요.' 'This check is read-only and sends nothing over the network.') Say '------------------------------------------------------------------' # --------------------------------------------------------------------- # 웹 폴더 / web folders # --------------------------------------------------------------------- $IisConfig = Join-Path $env:windir 'System32\inetsrv\config\applicationHost.config' $IisText = $null if (Test-Path -LiteralPath $IisConfig) { try { $IisText = [System.IO.File]::ReadAllText($IisConfig) } catch { $IisText = $null } } $WebRoots = New-Object System.Collections.Generic.List[string] $cand = @() if ($Web.Count -gt 0) { $cand = $Web } else { $cand = @('C:\inetpub\wwwroot', 'C:\xampp\htdocs', 'C:\wamp64\www') if ($IisText) { foreach ($m in [regex]::Matches($IisText, 'physicalPath="([^"]+)"')) { $cand += [Environment]::ExpandEnvironmentVariables($m.Groups[1].Value) } } } foreach ($c in $cand) { if (-not $c) { continue } if (-not (Test-Path -LiteralPath $c -PathType Container)) { continue } $full = (Resolve-Path -LiteralPath $c).ProviderPath.TrimEnd('\') $skip = $false foreach ($e in @($WebRoots)) { if ($full.ToLower() -eq $e.ToLower() -or $full.ToLower().StartsWith($e.ToLower() + $Sep)) { $skip = $true } } if ($skip) { continue } foreach ($e in @($WebRoots)) { if ($e.ToLower().StartsWith($full.ToLower() + $Sep)) { [void]$WebRoots.Remove($e) } } $WebRoots.Add($full) } if ($WebRoots.Count -gt 0) { Say "$(T '웹 폴더' 'Web folders'): $($WebRoots -join ', ')" } else { Say "$(T '웹 폴더' 'Web folders'): $(T '못 찾음 (-Web 으로 알려 주세요)' 'none found (use -Web)')" } Say '------------------------------------------------------------------' # --------------------------------------------------------------------- # 웹 폴더 훑기 (한 번만) / walk web folders once # --------------------------------------------------------------------- $PhpExt = @('.php', '.phtml', '.pht', '.phar', '.inc', '.php3', '.php4', '.php5', '.php7', '.php8') $ImgExt = @('.jpg', '.jpeg', '.png', '.gif', '.ico', '.bmp', '.webp') $UploadNames = @('uploads', 'upload', 'files', 'data', 'attach', 'attachments', 'userfiles') $PruneNames = @('.git', 'node_modules') $UploadPrune = @('vendor', 'wp-includes', 'wp-admin', 'plugins', 'themes', 'src', 'lib', 'libs', 'includes') $PhpFiles = New-Object System.Collections.Generic.List[string] $HtFiles = New-Object System.Collections.Generic.List[string] $UploadDirs = New-Object System.Collections.Generic.List[string] $WalkTimedOut = $false $Sw = [System.Diagnostics.Stopwatch]::StartNew() function Walk-Web { $stack = New-Object System.Collections.Generic.Stack[object] foreach ($r in $script:WebRoots) { $stack.Push(@($r, $false)) } while ($stack.Count -gt 0) { if ($script:Sw.Elapsed.TotalSeconds -gt $script:ScanLimit) { $script:WalkTimedOut = $true; return } $item = $stack.Pop() $dir = $item[0]; $codeArea = $item[1] $name = [System.IO.Path]::GetFileName($dir) $lower = $name.ToLower() if ($dir -match '[\\/]vendor[\\/][^\\/]+[\\/]tests?$') { continue } if (-not $codeArea -and $script:UploadNames -contains $name) { $script:UploadDirs.Add($dir) } $childCode = $codeArea -or ($script:UploadPrune -contains $lower) try { foreach ($f in [System.IO.Directory]::EnumerateFiles($dir)) { $ext = [System.IO.Path]::GetExtension($f).ToLower() if ($script:PhpExt -contains $ext) { try { if ((New-Object System.IO.FileInfo($f)).Length -lt 5MB) { $script:PhpFiles.Add($f) } } catch { } } elseif ([System.IO.Path]::GetFileName($f).ToLower() -eq '.htaccess') { $script:HtFiles.Add($f) } } } catch { } try { foreach ($d in [System.IO.Directory]::EnumerateDirectories($dir)) { $di = New-Object System.IO.DirectoryInfo($d) if (($di.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -ne 0) { continue } if ($script:PruneNames -contains $di.Name.ToLower()) { continue } $stack.Push(@($d, $childCode)) } } catch { } } } if ($WebRoots.Count -gt 0) { Step (T '웹 폴더 훑기' 'walking web folders') Walk-Web } function ReadLatin1([string]$path) { try { return [System.IO.File]::ReadAllText($path, $script:Latin1) } catch { return $null } } # ===================================================================== # P02 ~ P06, P08 : PHP # ===================================================================== Step 'PHP' $PhpDirs = New-Object System.Collections.Generic.List[string] function Add-PhpDir([string]$d) { if (-not $d) { return } if (-not (Test-Path -LiteralPath $d -PathType Container)) { return } $full = (Resolve-Path -LiteralPath $d).ProviderPath.TrimEnd('\') if (-not ((Test-Path -LiteralPath (Join-Path $full 'php.exe')) -or (Test-Path -LiteralPath (Join-Path $full 'php-cgi.exe')))) { return } foreach ($e in $script:PhpDirs) { if ($e.ToLower() -eq $full.ToLower()) { return } } $script:PhpDirs.Add($full) } foreach ($pat in @('C:\php*', 'C:\xampp\php', 'C:\tools\php*', "$env:ProgramFiles\PHP\*", "$env:ProgramFiles\PHP", "${env:ProgramFiles(x86)}\PHP\*", 'C:\wamp64\bin\php\*', 'C:\wamp\bin\php\*', 'C:\laragon\bin\php\*', "$env:ProgramFiles\IIS Express\PHP\*")) { foreach ($i in @(Get-Item -Path $pat -ErrorAction SilentlyContinue)) { if ($i.PSIsContainer) { Add-PhpDir $i.FullName } } } foreach ($cmd in @(Get-Command -Name php.exe, php-cgi.exe -All -CommandType Application -ErrorAction SilentlyContinue)) { Add-PhpDir (Split-Path -Parent $cmd.Source) } if ($IisText) { foreach ($m in [regex]::Matches($IisText, 'fullPath="([^"]*php-cgi\.exe)"', 'IgnoreCase')) { Add-PhpDir (Split-Path -Parent ([Environment]::ExpandEnvironmentVariables($m.Groups[1].Value))) } } foreach ($p in @(Get-Process -Name php-cgi, php -ErrorAction SilentlyContinue)) { if ($p.Path) { Add-PhpDir (Split-Path -Parent $p.Path) } } $PhpVers = @() foreach ($d in $PhpDirs) { $exe = Join-Path $d 'php.exe' if (-not (Test-Path -LiteralPath $exe)) { $exe = Join-Path $d 'php-cgi.exe' } $v = $null try { $vi = (Get-Item -LiteralPath $exe).VersionInfo foreach ($s in @($vi.ProductVersion, $vi.FileVersion)) { if ($s -and $s -match '(\d+\.\d+\.\d+)') { $v = $Matches[1]; break } } } catch { } $PhpVers += New-Object PSObject -Property @{ Dir = $d; Version = $v } } $CgiHits = New-Object System.Collections.Generic.List[string] if ($IisText -and $IisText -match 'php-cgi\.exe') { $CgiHits.Add('IIS FastCGI (applicationHost.config)') } $apacheConfDirs = @('C:\xampp\apache\conf', 'C:\Apache24\conf', 'C:\wamp64\bin\apache\*\conf', 'C:\wamp\bin\apache\*\conf', 'C:\laragon\bin\apache\*\conf', "$env:ProgramFiles\Apache*\conf", "$env:ProgramFiles\Apache Software Foundation\*\conf") foreach ($pat in $apacheConfDirs) { foreach ($cd in @(Get-Item -Path $pat -ErrorAction SilentlyContinue)) { if (-not $cd.PSIsContainer) { continue } foreach ($cf in @(Get-ChildItem -LiteralPath $cd.FullName -Recurse -File -Filter '*.conf' -ErrorAction SilentlyContinue)) { $hit = $false foreach ($ln in @(Get-Content -LiteralPath $cf.FullName -ErrorAction SilentlyContinue)) { $t = $ln.Trim() if ($t.StartsWith('#')) { continue } if ($t -match 'php-cgi' -or $t -match '^ScriptAlias\s+\S*php' -or $t -match '^Action\s+application/x-httpd-php' -or $t -match '^AddHandler\s+cgi-script\s+.*\.php') { $hit = $true; break } } if ($hit) { $CgiHits.Add("Apache CGI ($($cf.FullName))") } } } } if (@(Get-Process -Name php-cgi -ErrorAction SilentlyContinue).Count -gt 0) { $CgiHits.Add((T 'php-cgi.exe 가 돌고 있어요' 'php-cgi.exe is running')) } $script:PhpGuided = @{} function PhpGuide([string]$dir, [string]$v, [string]$need) { $key = $dir.ToLower() if ($script:PhpGuided.ContainsKey($key)) { return } $script:PhpGuided[$key] = $true $mm = ($v.Split('.')[0..1]) -join '.' $target = $need if ($target) { $target += (T ' 이상' ' or later') } else { $e = PhpEolDate $mm $live = $false if ($e) { $live = ([datetime]::ParseExact($e, 'yyyy-MM-dd', $null) -ge $Today.Date) } if ($live -and $script:Cve4577Fixed.ContainsKey($mm) -and (Is4577 $v)) { $target = $script:Cve4577Fixed[$mm] + (T ' 이상' ' or later') } elseif ($live) { $target = T "$mm 줄의 가장 새 버전" "the newest $mm.x release" } else { $br = @($script:PhpEol.Keys | Where-Object { [datetime]::ParseExact($script:PhpEol[$_], 'yyyy-MM-dd', $null) -ge $Today.Date } | Sort-Object) -join '·' $target = T "공식 지원 중인 버전 ($br)" "a supported branch ($br)" } } $l = $dir.ToLower() $kind = 'web' if ($l -like '*\xampp\*') { $kind = 'xampp' } elseif ($l -like '*\wamp*') { $kind = 'wamp' } elseif ($l -like '*\laragon\*') { $kind = 'laragon' } elseif ($l -like '*iis express*') { $kind = 'iisx' } elseif ($IisText -and $IisText.ToLower().Contains(($dir.TrimEnd('\') + '\php-cgi.exe').ToLower())) { $kind = 'iis' } $names = @{ xampp = 'XAMPP'; wamp = 'WampServer'; laragon = 'Laragon'; iisx = 'IIS Express'; iis = 'IIS (FastCGI)'; web = (T '직접 설치한 PHP' 'PHP installed by hand') } $bak = $dir + '.bak-' + $Today.ToString('yyyyMMdd') $exe = $dir.TrimEnd('\') + '\php.exe' Add-Detail (T "PHP 업데이트 방법 ($($names[$kind]) · $dir)" "How to update PHP ($($names[$kind]) · $dir)") Add-Detail (T "1) 먼저 지금 PHP 폴더를 통째로 복사해 둬요: Copy-Item `"$dir`" `"$bak`" -Recurse" "1) First copy the whole PHP folder: Copy-Item `"$dir`" `"$bak`" -Recurse") switch ($kind) { 'xampp' { Add-Detail (T "2) XAMPP 제어판에서 Apache 를 멈추고, 'Thread Safe · x64' ZIP 을 받아 $dir 안 파일을 새 버전으로 바꿔요. php.ini 는 남겨 두고 Apache 를 다시 시작해요. PHP 큰 버전(7→8)이 바뀌면 httpd-xampp.conf 의 LoadModule 줄도 바꿔요" "2) Stop Apache in the XAMPP Control Panel, download the 'Thread Safe, x64' ZIP and replace the files in $dir. Keep php.ini, then start Apache again. If the major version changes (7 to 8), also update the LoadModule line in httpd-xampp.conf") } 'wamp' { Add-Detail (T '2) WampServer 아이콘 메뉴 PHP > Version 에서 새 버전을 골라요. 목록에 없으면 WampServer 공식 추가 꾸러미로 새 버전을 설치한 뒤 골라요' '2) In the WampServer tray menu choose PHP > Version and pick the new release. If it is not listed, install it from the official WampServer add-ons first') } 'laragon' { Add-Detail (T '2) 지금과 같은 종류(x64 · Thread Safe 또는 Non Thread Safe) ZIP 을 받아 C:\laragon\bin\php\ 아래 새 폴더에 풀고, Laragon 메뉴 PHP > Version 에서 새 버전을 고른 뒤 Apache·Nginx 를 다시 시작해요' '2) Download the ZIP of the same build (x64, Thread Safe or Non Thread Safe), unzip it into a new folder under C:\laragon\bin\php\, choose it in the Laragon menu PHP > Version, then restart Apache or Nginx') } 'iisx' { Add-Detail (T "2) 'Non Thread Safe · x64' ZIP 을 받아 $dir 안 파일을 새 버전으로 바꿔요(php.ini 는 남김). 그다음 IIS Express 를 다시 켜요" "2) Download the 'Non Thread Safe, x64' ZIP and replace the files in $dir (keep php.ini). Then start IIS Express again") } 'iis' { Add-Detail (T "2) 관리자 PowerShell 에서 iisreset /stop 으로 IIS 를 멈추고, 'Non Thread Safe · x64' ZIP 을 받아 $dir 안 파일을 새 버전으로 바꿔요(php.ini 는 남김). 그다음 iisreset /start" "2) Stop IIS with iisreset /stop in an admin PowerShell, download the 'Non Thread Safe, x64' ZIP and replace the files in $dir (keep php.ini). Then run iisreset /start") } default { Add-Detail (T "2) 웹서버(Apache·IIS 등)를 멈추고, 지금과 같은 종류(x64 · Thread Safe 또는 Non Thread Safe) ZIP 을 받아 $dir 안 파일을 새 버전으로 바꿔요(php.ini 는 남김). 그다음 웹서버를 다시 시작해요" "2) Stop the web server (Apache, IIS and so on), download the ZIP of the same build (x64, Thread Safe or Non Thread Safe) and replace the files in $dir (keep php.ini). Then start the web server again") } } Add-Detail (T "3) 확인: & `"$exe`" -v → 새 버전 번호가 나오면 이 점검을 다시 돌려요" "3) Check: & `"$exe`" -v then run this check again") Add-Detail (T "올릴 버전: $target · PHP 공식 윈도우 내려받기: https://windows.php.net/download/" "Target: $target · Official PHP for Windows: https://windows.php.net/download/") Add-Detail (T '새 버전이 켜지지 않으면 그 버전이 요구하는 Microsoft Visual C++ 재배포 패키지를 설치해요(내려받기 쪽에 적혀 있어요)' 'If the new build does not start, install the Microsoft Visual C++ Redistributable it needs (listed on the download page)') } if ($PhpVers.Count -eq 0) { Add-Result 'pass' 'P02' (T 'PHP 가 안 보여요' 'No PHP found') } else { foreach ($pv in $PhpVers) { if (-not $pv.Version) { Add-Result 'unk' 'P02' "$(T 'PHP 버전을 읽지 못했어요' 'Could not read the PHP version'): $($pv.Dir)" continue } $v = $pv.Version $mm = ($v.Split('.')[0..1]) -join '.' $eol = PhpEolDate $mm $bad = $false $need = '' if (-not $eol) { Add-Result 'low' 'P02' "PHP $v ($($pv.Dir)) $(T '는 비교표에 없는 버전이에요. 버전만 알려 드려요' 'is not in the version table. Version only')" } else { $left = ([datetime]::ParseExact($eol, 'yyyy-MM-dd', $null) - $Today.Date).TotalDays if ($left -lt 0) { Add-Result 'high' 'P02' "PHP $v ($($pv.Dir)) $(T "는 공식 보안 지원이 $eol 에 끝난 버전이에요" "reached end of security support on $eol")" $bad = $true } elseif ($left -le 60) { Add-Result 'low' 'P02' "PHP $v ($($pv.Dir)) $(T "는 공식 보안 지원이 $eol 에 끝나요" "security support ends on $eol")" } } if (IsP2s $v) { $need = if ($script:P2sFixed.ContainsKey($mm)) { $script:P2sFixed[$mm] } else { '8.2.35' } Add-Result 'crit' 'P02' "PHP $v ($($pv.Dir)) $(T "는 PHP2SHELL(CVE-2026-109618·CVE-2026-109619) 원격 코드 실행에 걸리는 버전이에요. $need 이상으로 올리세요" "is hit by PHP2SHELL (CVE-2026-109618, CVE-2026-109619) remote code execution. Upgrade to $need or later")" $bad = $true } if (Is4577 $v) { if ($CgiHits.Count -gt 0) { Add-Result 'crit' 'P02' "PHP $v ($($pv.Dir)) $(T '는 CVE-2024-4577 영향 버전이고, 웹서버가 php-cgi 를 쓰고 있어요' 'is affected by CVE-2024-4577 and the web server uses php-cgi')" } else { Add-Result 'high' 'P02' "PHP $v ($($pv.Dir)) $(T '는 CVE-2024-4577 영향 버전이에요 (CGI 로 쓰면 원격 실행 위험)' 'is affected by CVE-2024-4577 (remote code risk when used as CGI)')" } $bad = $true } if ($bad) { PhpGuide $pv.Dir $v $need } if (-not $bad -and $eol) { Add-Result 'pass' 'P02' "PHP $v ($($pv.Dir)) $(T '는 지원 중인 버전이에요 (같은 줄의 최신 버전인지는 따로 확인)' 'is a supported branch (check that it is the newest patch release)')" } } } $anyAffected = $false foreach ($pv in $PhpVers) { if ($pv.Version -and (Is4577 $pv.Version)) { $anyAffected = $true } } if ($CgiHits.Count -gt 0) { if ($anyAffected) { Add-Result 'crit' 'P08' (T '웹서버가 PHP 를 CGI(php-cgi.exe)로 부르고, CVE-2024-4577 영향 버전이 있어요' 'The web server calls PHP as CGI (php-cgi.exe) and an affected PHP version is present') } else { Add-Result 'med' 'P08' (T '웹서버가 PHP 를 CGI(php-cgi.exe)로 불러요. 버전은 고쳐진 버전이에요' 'The web server calls PHP as CGI (php-cgi.exe). The PHP version is patched') } foreach ($h in $CgiHits) { Add-Detail $h } } elseif ($PhpVers.Count -gt 0 -and -not $IsAdmin) { Add-Result 'unk' 'P08' (T 'IIS 설정은 관리자만 읽을 수 있어요. 관리자로 다시 돌리면 더 봐요' 'Only Administrators can read the IIS settings. Run as Administrator to see more') } else { Add-Result 'pass' 'P08' (T 'PHP 를 CGI 로 부르는 설정이 안 보여요' 'No PHP CGI setup found') } function IniLast([string]$path, [string]$key) { $val = $null if (-not (Test-Path -LiteralPath $path)) { return $null } foreach ($ln in @(Get-Content -LiteralPath $path -ErrorAction SilentlyContinue)) { $t = $ln.Trim() if ($t -eq '' -or $t.StartsWith(';') -or $t.StartsWith('#') -or $t.StartsWith('[')) { continue } $p = $t.IndexOf('=') if ($p -lt 1) { continue } if ($t.Substring(0, $p).Trim() -ne $key) { continue } $v = $t.Substring($p + 1).Trim() if ($v.StartsWith('"')) { $v = $v.Substring(1) $q = $v.IndexOf('"') if ($q -ge 0) { $v = $v.Substring(0, $q) } } else { $c = $v.IndexOf(';') if ($c -ge 0) { $v = $v.Substring(0, $c) } $v = $v.Trim() } $val = $v } return $val } if ($PhpDirs.Count -gt 0) { $b3 = @(); $b4 = @(); $p4 = @(); $b5 = @(); $b6 = @() foreach ($d in $PhpDirs) { $ini = Join-Path $d 'php.ini' $label = $ini if (-not (Test-Path -LiteralPath $ini)) { if ($env:PHPRC -and (Test-Path -LiteralPath (Join-Path $env:PHPRC 'php.ini'))) { $ini = Join-Path $env:PHPRC 'php.ini'; $label = $ini } else { $label = "$d ($(T 'php.ini 없음, 기본값' 'no php.ini, defaults'))" } } $aui = IniLast $ini 'allow_url_include'; if ($null -eq $aui) { $aui = 'Off' } $df = IniLast $ini 'disable_functions'; if ($null -eq $df) { $df = '' } $exp = IniLast $ini 'expose_php'; if ($null -eq $exp) { $exp = 'On' } $de = IniLast $ini 'display_errors'; if ($null -eq $de) { $de = 'On' } if (IsOn $aui) { $b3 += $label } $list = @($df.ToLower().Replace(' ', '').Split(',')) $missing = @() foreach ($w in @('exec', 'system', 'passthru', 'shell_exec', 'proc_open', 'popen')) { if ($list -notcontains $w) { $missing += $w } } if ($missing.Count -eq 6) { $b4 += $label } elseif ($missing.Count -gt 0) { $p4 += "$label ($(T '안 막힘' 'not blocked'): $($missing -join ' '))" } if (IsOn $exp) { $b5 += $label } if (IsOn $de) { $b6 += $label } } if ($b3.Count -gt 0) { Add-Result 'high' 'P03' (T 'allow_url_include 가 켜져 있어요' 'allow_url_include is On'); foreach ($x in $b3) { Add-Detail $x } } else { Add-Result 'pass' 'P03' (T 'allow_url_include 가 꺼져 있어요' 'allow_url_include is Off') } if ($b4.Count -gt 0) { Add-Result 'med' 'P04' (T 'disable_functions 에 exec·system 같은 명령 실행 함수가 없어요' 'disable_functions does not block exec, system and similar functions'); foreach ($x in $b4) { Add-Detail $x } } if ($p4.Count -gt 0) { Add-Result 'low' 'P04' (T 'disable_functions 에 일부 함수가 빠졌어요' 'disable_functions misses some functions'); foreach ($x in $p4) { Add-Detail $x } } if ($b4.Count -eq 0 -and $p4.Count -eq 0) { Add-Result 'pass' 'P04' (T 'disable_functions 가 명령 실행 함수를 막고 있어요' 'disable_functions blocks command functions') } if ($b5.Count -gt 0) { Add-Result 'low' 'P05' (T 'expose_php 가 켜져 있어 PHP 버전이 응답 머리에 보여요' 'expose_php is On, so the PHP version shows in response headers'); foreach ($x in $b5) { Add-Detail $x } } else { Add-Result 'pass' 'P05' (T 'expose_php 가 꺼져 있어요' 'expose_php is Off') } if ($b6.Count -gt 0) { Add-Result 'med' 'P06' (T 'display_errors 가 켜져 있어 오류 내용이 방문자에게 보일 수 있어요' 'display_errors is On, so visitors may see error details'); foreach ($x in $b6) { Add-Detail $x } } else { Add-Result 'pass' 'P06' (T 'display_errors 가 꺼져 있어요' 'display_errors is Off') } } else { Add-Result 'pass' 'P03' (T 'PHP 가 안 보여요' 'No PHP found') } # ===================================================================== # P07 : 업로드 폴더 안 PHP / PHP inside upload folders # ===================================================================== Step (T '업로드 폴더' 'upload folders') if ($WebRoots.Count -eq 0) { Add-Result 'unk' 'P07' (T '웹 폴더를 못 찾았어요 (-Web 으로 알려 주세요)' 'No web folder found (use -Web)') } else { $hits = @() foreach ($f in $PhpFiles) { $inUpload = $false foreach ($u in $UploadDirs) { if ($f.ToLower().StartsWith($u.ToLower() + $Sep)) { $inUpload = $true; break } } if (-not $inUpload) { continue } $fi = New-Object System.IO.FileInfo($f) if ($fi.Name.ToLower() -eq 'index.php' -and $fi.Length -le 100) { continue } $hits += $f } if ($hits.Count -gt 0) { Add-Result 'high' 'P07' (T "업로드 폴더 안에 PHP 파일이 $($hits.Count)개 있어요" "$($hits.Count) PHP file(s) inside upload folders") $hits | Select-Object -First $MaxList | ForEach-Object { Add-Detail $_ } } else { Add-Result 'pass' 'P07' (T '업로드 폴더 안에 PHP 파일이 없어요' 'No PHP files inside upload folders') } } # ===================================================================== # P01 : 웹쉘 의심 파일 / suspected web shells # ===================================================================== if ($Quick) { Add-Result 'unk' 'P01' (T '-Quick 이라 웹쉘 찾기를 건너뛰었어요' 'Web shell scan skipped (-Quick)') } elseif ($WebRoots.Count -eq 0) { Add-Result 'unk' 'P01' (T '웹 폴더를 못 찾았어요 (-Web 으로 알려 주세요)' 'No web folder found (use -Web)') } else { Step (T "웹쉘 찾기 (오래 걸릴 수 있어요, 최대 $ScanLimit 초)" "web shell scan (may take a while, up to $ScanLimit s)") $strong = @(); $weak = @(); $timedOut = $WalkTimedOut foreach ($f in $PhpFiles) { if ($Sw.Elapsed.TotalSeconds -gt $ScanLimit) { $timedOut = $true; break } $txt = ReadLatin1 $f if ($null -eq $txt) { continue } $names = @() foreach ($k in $RxStrong.Keys) { if ($RxStrong[$k].IsMatch($txt)) { $names += $k } } $long = $RxLong.IsMatch($txt) if ($long -and $RxEvalWord.IsMatch($txt)) { $names += 'packed_eval' } if ($names.Count -gt 0) { $strong += "$f ($($names -join ', '))"; continue } foreach ($k in $RxWeak.Keys) { if (-not $RxWeak[$k].IsMatch($txt)) { continue } if ($k -eq 'hex_payload' -and -not $RxHexNeed.IsMatch($txt)) { continue } $names += $k } if ($long -and $RxDecWord.IsMatch($txt)) { $names += 'packed' } if ($names.Count -gt 0) { $weak += "$f ($($names -join ', '))" } } foreach ($f in $HtFiles) { $txt = ReadLatin1 $f if ($txt -and $RxHt.IsMatch($txt)) { $strong += "$f (htaccess_handler)" } } foreach ($u in $UploadDirs) { if ($Sw.Elapsed.TotalSeconds -gt $ScanLimit) { $timedOut = $true; break } foreach ($f in @(Get-ChildItem -LiteralPath $u -Recurse -File -ErrorAction SilentlyContinue)) { if ($ImgExt -notcontains $f.Extension.ToLower() -or $f.Length -ge 5MB) { continue } $txt = ReadLatin1 $f.FullName if ($txt -and $txt.IndexOf('