<# .SYNOPSIS PHPCheck.net LAN check – passive security check for web servers on your own network. .DESCRIPTION Checks internal (or public) web servers for typical weaknesses – just like the quick/in-depth check on https://phpcheck.net, but locally on your own LAN: * PHP version (from the server headers) against the current security releases * HTTPS redirect, TLS certificate (expiry, self-signed, name, key length) * Accepted TLS versions (TLS 1.0 / 1.1 / 1.2 / 1.3) * Security headers, cookie attributes * Disclosed software versions (server banner, ASP.NET, CMS generator, Node.js/Express) Only normal page requests are made (GET /) – no attacks, no exploits, no password tests, no directory scans. Results stay on this PC. The only outbound connection: downloading the current version data from phpcheck.net (can be disabled with -Offline; the built-in data is used then). Please only check systems you manage or are authorised to check. .PARAMETER Target One or more targets: host name, IP address or URL. Examples: intranet.company.local, 192.168.1.20, https://wiki.company.local:8443/ .PARAMETER TargetFile Text file with one target per line (empty lines and lines starting with # are ignored). .PARAMETER Port Optional ports for targets without a scheme (e.g. 80,443,8080,8443). 443/8443/4443/9443 are checked via HTTPS, 80/8080/8000/8081 via HTTP, other ports HTTPS first, then HTTP. .PARAMETER Report Path of the HTML report. Default: PHPCheck-LAN-Report_.html in the current folder. .PARAMETER NoReport Do not write an HTML report (console output only). .PARAMETER Json Additionally save the results as a JSON file (e.g. for monitoring). .PARAMETER Open Open the HTML report in the default browser after the check. .PARAMETER Offline Do not download current version data from phpcheck.net, use the built-in data only. .PARAMETER VersionUrl Address of the version data (default: https://phpcheck.net/api/versions.json). .PARAMETER TimeoutSec Timeout per connection in seconds (default: 6). .PARAMETER Language Output language: en or de (default: en). .EXAMPLE PS C:\> .\phpcheck-lan.ps1 intranet.company.local .EXAMPLE PS C:\> .\phpcheck-lan.ps1 -Target 192.168.1.20,192.168.1.21 -Port 80,443,8443 -Open .EXAMPLE PS C:\> .\phpcheck-lan.ps1 -TargetFile .\servers.txt -Json .\result.json .NOTES Version 1.7 · https://phpcheck.net/en/lan-check Runs on Windows PowerShell 5.1 and PowerShell 7 (Windows, Linux, macOS). Exit code: 0 = all good, 1 = recommendations, 2 = critical items, 3 = at least one target unreachable. #> #Requires -Version 5.1 [CmdletBinding()] param( [Parameter(Position = 0)][string[]]$Target, [string]$TargetFile, [int[]]$Port, [string]$Report, [switch]$NoReport, [string]$Json, [switch]$Open, [switch]$Offline, [string]$VersionUrl = 'https://phpcheck.net/api/versions.json', [ValidateRange(1, 60)][int]$TimeoutSec = 6, [ValidateSet('de', 'en')][string]$Language ) Set-StrictMode -Version 2.0 $ErrorActionPreference = 'Stop' $ScriptVersion = '1.7' $UserAgent = "PHPCheck-LAN/$ScriptVersion (+https://phpcheck.net/lan-check; passive security check)" if (-not $Language) { $Language = 'en' } function T([string]$de, [string]$en) { if ($Language -eq 'de') { return $de } return $en } # --------------------------------------------------------------------------- # Built-in version data (as of 19 Nov 2026) – updated online if reachable # --------------------------------------------------------------------------- $VersionData = @{ date = '19.11.2026' php = @{ advisory_de = 'CVE-2026-109618 / CVE-2026-109619 („PHP2Shell“, CVSS 9.2)' advisory_en = 'CVE-2026-109618 / CVE-2026-109619 ("PHP2Shell", CVSS 9.2)' release_de = 'Sicherheitsrelease vom 19.11.2026 (bis zu 17 Lücken, u. a. CVE-2026-129289 in PHP-FPM und CVE-2026-115560; die kritischen sind nur bei abweichender Konfiguration ausnutzbar)' release_en = 'security release of 19 Nov 2026 (up to 17 vulnerabilities, incl. CVE-2026-129289 in PHP-FPM and CVE-2026-115560; the critical ones are only exploitable with non-default configurations)' # fixed = first version with the PHP2Shell fix, latest = current security release branches = [ordered]@{ '8.6' = @{ fixed = '8.6.0'; latest = '8.6.0'; eol = '2030-12-31' } '8.5' = @{ fixed = '8.5.12'; latest = '8.5.13'; eol = '2029-12-31' } '8.4' = @{ fixed = '8.4.27'; latest = '8.4.28'; eol = '2028-12-31' } '8.3' = @{ fixed = '8.3.36'; latest = '8.3.37'; eol = '2027-12-31' } '8.2' = @{ fixed = '8.2.35'; latest = '8.2.36'; eol = '2026-12-31' } } } node = @{ advisory_de = 'Node.js-Sicherheitsupdate vom 21.10.2026 (u. a. CVE-2026-111497)' advisory_en = 'Node.js security release of 21 Oct 2026 (incl. CVE-2026-111497)' fixed = [ordered]@{ '26' = '26.12.1'; '24' = '24.22.1'; '22' = '22.23.4' } } software = [ordered]@{ nginx = @{ label = 'nginx'; date = '14.10.2026'; fixed = [ordered]@{ '1.30' = '1.30.6'; '1.31' = '1.31.7' }; min = '1.30'; backport = ''; de = '5 Lücken vom 14.10.2026, u. a. CVE-2026-15176 und CVE-2026-93479 (Heap-Overflow, mögliche Codeausführung). Ob ein Server angreifbar ist, hängt von der Konfiguration ab (alias + rewrite, regex-map, SSI mit aio, HTTP/3, SSL-Session-Cache).'; en = '5 vulnerabilities of 14 Oct 2026, incl. CVE-2026-15176 and CVE-2026-93479 (heap overflow, possible code execution). Whether a server is exploitable depends on its configuration (alias + rewrite, regex map, SSI with aio, HTTP/3, SSL session cache).' } apache = @{ label = 'Apache httpd'; date = '11.11.2026'; fixed = [ordered]@{ '2.4' = '2.4.71' }; min = '2.4'; backport = ''; de = 'Apache 2.4.71 vom 11.11.2026 schließt 3 Lücken, darunter die kritische CVE-2026-119618 in mod_http2 (CVSS 9.8, mögliche Codeausführung ohne Anmeldung). Betroffen sind 2.4.55 bis 2.4.70, wenn HTTP/2 aktiv ist. Übergangslösung: HTTP/2 abschalten (Protocols http/1.1).'; en = 'Apache 2.4.71 of 11 Nov 2026 fixes 3 vulnerabilities, including the critical CVE-2026-119618 in mod_http2 (CVSS 9.8, possible unauthenticated code execution). Versions 2.4.55 to 2.4.70 are affected when HTTP/2 is enabled. Interim mitigation: disable HTTP/2 (Protocols http/1.1).' } openssl = @{ label = 'OpenSSL'; date = '10.11.2026'; fixed = [ordered]@{ '1.0.2' = '1.0.2zt'; '1.1.1' = '1.1.1zk'; '3.0' = '3.0.24'; '3.5' = '3.5.10'; '4.0' = '4.0.4'; '4.1' = '4.1.1' }; min = ''; backport = ''; safe = '3.5.10 / 4.0.4 / 4.1.1'; de = 'OpenSSL-Sicherheitsupdate vom 10.11.2026 (5 Lücken, alle mit niedriger Schwere, v. a. QUIC und AES-GCM-SIV). Die Zweige 3.4 und 3.6 werden nicht mehr unterstützt; Fixes für 3.0, 1.1.1 und 1.0.2 gibt es nur mit kostenpflichtigem Support.'; en = 'OpenSSL security release of 10 Nov 2026 (5 vulnerabilities, all low severity, mainly QUIC and AES-GCM-SIV). Branches 3.4 and 3.6 are no longer supported; fixes for 3.0, 1.1.1 and 1.0.2 are only available with paid support.' } wordpress = @{ label = 'WordPress'; date = '28.10.2026'; fixed = [ordered]@{ '7.1' = '7.1.4'; '7.0' = '7.0.8'; '6.9' = '6.9.11'; '6.8' = '6.8.12'; '6.7' = '6.7.11'; '6.6' = '6.6.11'; '6.5' = '6.5.14'; '6.4' = '6.4.14'; '6.3' = '6.3.14'; '6.2' = '6.2.15'; '6.1' = '6.1.16'; '6.0' = '6.0.18'; '5.9' = '5.9.20'; '5.8' = '5.8.19'; '5.7' = '5.7.21'; '5.6' = '5.6.23'; '5.5' = '5.5.24'; '5.4' = '5.4.25'; '5.3' = '5.3.27'; '5.2' = '5.2.30'; '5.1' = '5.1.28'; '5.0' = '5.0.31'; '4.9' = '4.9.35'; '4.8' = '4.8.34'; '4.7' = '4.7.39' }; min = '4.7'; backport = ''; severity = 'bad'; safe = '7.1.4'; de = 'WordPress 7.1.4 vom 28.10.2026 schließt CVE-2026-119977 (Codeausführung ohne Anmeldung während eines Core-Updates). Die Lücke wird aktiv ausgenutzt (CISA KEV seit 03.11.2026). Fixes gibt es für alle Zweige ab 4.7. Wichtig: Das Update selbst läuft noch über den alten, anfälligen Updater – vorher den Webzugriff auf wp-content/upgrade sperren.'; en = 'WordPress 7.1.4 of 28 Oct 2026 fixes CVE-2026-119977 (unauthenticated code execution during a core update). The flaw is actively exploited (CISA KEV since 3 Nov 2026). Fixes exist for all branches from 4.7. Important: the update itself still runs through the old, vulnerable updater – block web access to wp-content/upgrade first.' } } exchange = @{ date = '10.11.2026' builds = [ordered]@{ '15.2.2562' = @{ name = 'Exchange Server SE (RTM)'; latest = '15.2.2562.57'; esu = $false; date = '' } '15.2.1748' = @{ name = 'Exchange Server 2019 CU15'; latest = '15.2.1748.55'; esu = $true; date = '13.10.2026' } '15.2.1544' = @{ name = 'Exchange Server 2019 CU14'; latest = '15.2.1544.50'; esu = $true; date = '13.10.2026' } '15.1.2507' = @{ name = 'Exchange Server 2016 CU23'; latest = '15.1.2507.77'; esu = $true; date = '13.10.2026' } } } emudhra = @{ fingerprints = @{ 'E7568FE6E12331F4FD7DE61DA4C7559D0F8EB192A218D4741A3BA75184333838' = 'EM EV TLS CA - G3B' '98B896625C0C230ADEEC3EB2CF6AAD5001ECF9156A68644E82374CE5833BC25B' = 'EM OV TLS CA - G3B' '42C4ACCD12C4F59597925E1A08A7A90102608543809308D50EC427E118BA1493' = 'EM DV TLS CA - G3B' '432EC25F0D28DE9006D97BF752F17BBB2CD41F669933FCB072D9A1148D0261F3' = 'EM EV TLS CA - G3C' 'CB6E15165AC802E9B3F993F16C25D41F4E81C21EBDE71AE1B012AC00BF9C7C3F' = 'EM OV TLS CA - G3C' '0164D7CEAE5BB909C272AF151FF44B1177AE9B47D9424B94F1D9558C30934D19' = 'EM DV TLS CA - G3C' } names = '(?i)EM (?:DV|OV|EV) TLS CA\s*-\s*G3[BC]|emSign ECC Root CA\s*-\s*G3|emSign Root TLS CA\s*-\s*G3' } kev = $null # actively exploited vulnerabilities (CISA) – online via phpcheck.net only } $VersionSource = T 'eingebaut' 'built-in' if (-not $Offline) { try { # Otherwise Windows PowerShell 5.1 may not use TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 $online = Invoke-RestMethod -Uri $VersionUrl -TimeoutSec 8 -UserAgent $UserAgent if ($online -and $online.php -and $online.php.branches) { $br = [ordered]@{} foreach ($p in $online.php.branches.PSObject.Properties) { $lt = [string]$p.Value.fixed; if ($p.Value.PSObject.Properties['latest']) { $lt = [string]$p.Value.latest } $br[$p.Name] = @{ fixed = [string]$p.Value.fixed; latest = $lt; eol = [string]$p.Value.eol } } $relDe = $VersionData.php.release_de; $relEn = $VersionData.php.release_en if ($online.php.PSObject.Properties['release_de']) { $relDe = [string]$online.php.release_de; $relEn = [string]$online.php.release_en } $nf = [ordered]@{} foreach ($p in $online.node.fixed.PSObject.Properties) { $nf[$p.Name] = [string]$p.Value } $VersionData = @{ date = [string]$online.date php = @{ advisory_de = [string]$online.php.advisory_de; advisory_en = [string]$online.php.advisory_en; release_de = $relDe; release_en = $relEn; branches = $br } node = @{ advisory_de = [string]$online.node.advisory_de; advisory_en = [string]$online.node.advisory_en; fixed = $nf } software = $VersionData.software exchange = $VersionData.exchange emudhra = $VersionData.emudhra kev = $VersionData.kev } # Security updates for other software (nginx, Apache, OpenSSL, WordPress) – if provided by the server if ($online.PSObject.Properties['software'] -and $online.software) { $sw = [ordered]@{} foreach ($p in $online.software.PSObject.Properties) { $v = $p.Value $fx = [ordered]@{} foreach ($q in $v.fixed.PSObject.Properties) { $fx[$q.Name] = [string]$q.Value } $mn = ''; if ($v.PSObject.Properties['min']) { $mn = [string]$v.min } $bp = ''; if ($v.PSObject.Properties['backport']) { $bp = [string]$v.backport } $sv = ''; if ($v.PSObject.Properties['severity']) { $sv = [string]$v.severity } $sf = ''; if ($v.PSObject.Properties['safe']) { $sf = [string]$v.safe } $sw[$p.Name] = @{ label = [string]$v.label; date = [string]$v.date; fixed = $fx; min = $mn; backport = $bp; severity = $sv; safe = $sf; de = [string]$v.de; en = [string]$v.en } } if ($sw.Count -gt 0) { $VersionData.software = $sw } } # Exchange builds, eMudhra data and actively exploited vulnerabilities (CISA KEV) if ($online.PSObject.Properties['exchange'] -and $online.exchange) { $eb = [ordered]@{} foreach ($p in $online.exchange.builds.PSObject.Properties) { $bd = ''; if ($p.Value.PSObject.Properties['date']) { $bd = [string]$p.Value.date }; $eb[$p.Name] = @{ name = [string]$p.Value.name; latest = [string]$p.Value.latest; esu = [bool]$p.Value.esu; date = $bd } } if ($eb.Count -gt 0) { $VersionData.exchange = @{ date = [string]$online.exchange.date; builds = $eb } } } if ($online.PSObject.Properties['emudhra'] -and $online.emudhra) { $ef = @{} foreach ($p in $online.emudhra.fingerprints.PSObject.Properties) { $ef[$p.Name] = [string]$p.Value } if ($ef.Count -gt 0) { $VersionData.emudhra = @{ fingerprints = $ef; names = [string]$online.emudhra.names } } } if ($online.PSObject.Properties['kev'] -and $online.kev -and $online.kev.items) { $km = [ordered]@{} foreach ($p in $online.kev.map.PSObject.Properties) { $km[$p.Name] = [string]$p.Value } $VersionData.kev = @{ date = [string]$online.kev.date; recent = [int]$online.kev.recent_days; show = [int]$online.kev.show_days; map = $km; items = @($online.kev.items) } } $VersionSource = ([uri]$VersionUrl).Host } } catch { Write-Verbose "Versionsdaten nicht abrufbar: $($_.Exception.Message)" } } # --------------------------------------------------------------------------- # Network helper (C#, so that certificate, TLS version and raw headers are reliably available) # --------------------------------------------------------------------------- if (-not ('PHPCheckLan.Net' -as [type])) { Add-Type -IgnoreWarnings -TypeDefinition @' #pragma warning disable using System; using System.Collections.Generic; using System.IO; using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; namespace PHPCheckLan { public class HttpResult { public int Status; public string StatusLine = ""; public List Headers = new List(); public string Body = ""; public string Error = null; public X509Certificate2 Cert = null; public string PolicyErrors = ""; public string TlsProtocol = ""; public int KeySize = 0; public string KeyAlg = ""; public List ChainInfo = new List(); // "Subject|Issuer|SHA256" of the chain sent by the server public string Header(string name) { foreach (string[] h in Headers) if (string.Equals(h[0], name, StringComparison.OrdinalIgnoreCase)) return h[1]; return null; } public string[] AllHeaders(string name) { List l = new List(); foreach (string[] h in Headers) if (string.Equals(h[0], name, StringComparison.OrdinalIgnoreCase)) l.Add(h[1]); return l.ToArray(); } } public static class Net { static TcpClient Connect(string host, int port, int timeoutMs) { TcpClient tcp = new TcpClient(); IAsyncResult ar = tcp.BeginConnect(host, port, null, null); if (!ar.AsyncWaitHandle.WaitOne(timeoutMs)) { try { tcp.Close(); } catch { } throw new TimeoutException("Timeout"); } tcp.EndConnect(ar); tcp.ReceiveTimeout = timeoutMs; tcp.SendTimeout = timeoutMs; return tcp; } static void AuthDefault(SslStream ssl, string host) { try { ssl.AuthenticateAsClient(host, null, (SslProtocols)0, false); } // OS default catch (ArgumentException) { ssl.AuthenticateAsClient(host, null, (SslProtocols)(3072 | 768 | 192), false); } catch (NotSupportedException) { ssl.AuthenticateAsClient(host, null, (SslProtocols)(3072 | 768 | 192), false); } } static void CollectChain(X509Chain ch, List list) { if (ch == null) return; List certs = new List(); foreach (X509ChainElement el in ch.ChainElements) certs.Add(el.Certificate); foreach (X509Certificate2 x in ch.ChainPolicy.ExtraStore) certs.Add(x); System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create(); foreach (X509Certificate2 x in certs) { byte[] raw = x.RawData; string fp = BitConverter.ToString(sha.ComputeHash(raw)).Replace("-", ""); string entry = x.Subject + "|" + x.Issuer + "|" + fp; if (!list.Contains(entry)) list.Add(entry); } } public static string Flatten(Exception ex) { Exception e = ex; while (e.InnerException != null) e = e.InnerException; return e.Message.Trim(); } public static HttpResult Get(string scheme, string host, int port, string path, int timeoutMs, string ua) { HttpResult r = new HttpResult(); TcpClient tcp = null; Stream s = null; try { tcp = Connect(host, port, timeoutMs); s = tcp.GetStream(); if (scheme == "https") { byte[] cap = null; SslPolicyErrors pe = SslPolicyErrors.None; // Store an independent copy of the certificate right away: under .NET Framework (Windows PowerShell 5.1) // the original becomes invalid when the connection is closed. List chainInfo = new List(); SslStream ssl = new SslStream(s, false, delegate(object o, X509Certificate c, X509Chain ch, SslPolicyErrors e) { try { if (c != null) cap = c.GetRawCertData(); } catch { } try { CollectChain(ch, chainInfo); } catch { } pe = e; return true; }); s = ssl; AuthDefault(ssl, host); r.TlsProtocol = ssl.SslProtocol.ToString(); r.ChainInfo = chainInfo; r.PolicyErrors = pe.ToString(); if (cap != null) { r.Cert = new X509Certificate2(cap); try { // 1.2.840.113549.1.1.1 = RSA (also works with older .NET Framework) if (r.Cert.PublicKey.Oid.Value == "1.2.840.113549.1.1.1") { r.KeyAlg = "RSA"; r.KeySize = r.Cert.PublicKey.Key.KeySize; } else r.KeyAlg = r.Cert.PublicKey.Oid.FriendlyName; } catch { } } } bool defPort = (scheme == "https" && port == 443) || (scheme == "http" && port == 80); string hostHdr = (host.Contains(":") ? "[" + host + "]" : host) + (defPort ? "" : ":" + port); string req = "GET " + path + " HTTP/1.1\r\nHost: " + hostHdr + "\r\nUser-Agent: " + ua + "\r\nAccept: text/html,application/xhtml+xml,*/*;q=0.8\r\nAccept-Encoding: identity\r\nConnection: close\r\n\r\n"; byte[] b = Encoding.ASCII.GetBytes(req); s.Write(b, 0, b.Length); s.Flush(); ReadResponse(s, r); } catch (Exception ex) { r.Error = Flatten(ex); } finally { if (s != null) { try { s.Dispose(); } catch { } } if (tcp != null) { try { tcp.Close(); } catch { } } } return r; } static int IndexOf(byte[] hay, int len, byte[] needle, int start) { for (int i = start; i <= len - needle.Length; i++) { bool ok = true; for (int j = 0; j < needle.Length; j++) if (hay[i + j] != needle[j]) { ok = false; break; } if (ok) return i; } return -1; } static void ReadResponse(Stream s, HttpResult r) { MemoryStream ms = new MemoryStream(); byte[] buf = new byte[16384]; byte[] sep = Encoding.ASCII.GetBytes("\r\n\r\n"); byte[] chunkEnd = Encoding.ASCII.GetBytes("\r\n0\r\n"); int headerEnd = -1; long contentLength = -1; bool chunked = false; const int Max = 524288; while (true) { int n; try { n = s.Read(buf, 0, buf.Length); } catch (IOException) { if (ms.Length == 0) throw; break; } if (n <= 0) break; ms.Write(buf, 0, n); byte[] all = ms.GetBuffer(); int len = (int)ms.Length; if (headerEnd < 0) { headerEnd = IndexOf(all, len, sep, 0); if (headerEnd >= 0) { ParseHeaders(Encoding.GetEncoding("ISO-8859-1").GetString(all, 0, headerEnd), r); string cl = r.Header("Content-Length"); long v; if (cl != null && long.TryParse(cl.Trim(), out v)) contentLength = v; string te = r.Header("Transfer-Encoding"); chunked = te != null && te.ToLowerInvariant().Contains("chunked"); if (r.Status == 204 || r.Status == 304 || (r.Status >= 300 && r.Status < 400 && contentLength < 0 && !chunked)) break; } } if (headerEnd >= 0) { int bodyLen = len - headerEnd - 4; if (contentLength >= 0 && bodyLen >= contentLength) break; if (chunked && IndexOf(all, len, chunkEnd, Math.Max(headerEnd, len - n - 8)) >= 0) break; if (bodyLen > Max) break; } else if (len > 65536) break; } byte[] data = ms.ToArray(); if (headerEnd < 0) { if (data.Length == 0) throw new IOException("Keine Antwort / no response"); ParseHeaders(Encoding.GetEncoding("ISO-8859-1").GetString(data), r); return; } byte[] body = new byte[Math.Max(0, data.Length - headerEnd - 4)]; Array.Copy(data, headerEnd + 4, body, 0, body.Length); if (chunked) body = Dechunk(body); r.Body = Encoding.UTF8.GetString(body); } static void ParseHeaders(string raw, HttpResult r) { string[] lines = raw.Split(new string[] { "\r\n" }, StringSplitOptions.None); r.StatusLine = lines.Length > 0 ? lines[0] : ""; string[] parts = r.StatusLine.Split(' '); int st; if (parts.Length > 1 && int.TryParse(parts[1], out st)) r.Status = st; for (int i = 1; i < lines.Length; i++) { int c = lines[i].IndexOf(':'); if (c > 0) r.Headers.Add(new string[] { lines[i].Substring(0, c).Trim(), lines[i].Substring(c + 1).Trim() }); } } static byte[] Dechunk(byte[] b) { MemoryStream o = new MemoryStream(); int p = 0; try { while (p < b.Length) { int e = p; while (e < b.Length - 1 && !(b[e] == 13 && b[e + 1] == 10)) e++; string hex = Encoding.ASCII.GetString(b, p, e - p).Split(';')[0].Trim(); int size = Convert.ToInt32(hex, 16); if (size == 0) break; p = e + 2; int take = Math.Min(size, b.Length - p); o.Write(b, p, take); p += size + 2; } } catch { } return o.ToArray(); } /// Test a TLS version: "yes" = accepted, "no" = rejected, "err:..." = not testable public static string ProbeTls(string host, int port, int proto, int timeoutMs) { TcpClient tcp = null; SslStream ssl = null; try { tcp = Connect(host, port, timeoutMs); ssl = new SslStream(tcp.GetStream(), false, delegate(object o, X509Certificate c, X509Chain ch, SslPolicyErrors e) { return true; }); ssl.AuthenticateAsClient(host, null, (SslProtocols)proto, false); return "yes"; } catch (TimeoutException) { return "err:timeout"; } catch (SocketException ex) { return "err:" + ex.Message; } catch (ArgumentException) { return "err:unsupported"; } catch (NotSupportedException) { return "err:unsupported"; } catch (Exception) { return "no"; } finally { if (ssl != null) { try { ssl.Dispose(); } catch { } } if (tcp != null) { try { tcp.Close(); } catch { } } } } } } '@ } $TimeoutMs = $TimeoutSec * 1000 # --------------------------------------------------------------------------- # Helper functions # --------------------------------------------------------------------------- function New-Finding([string]$Cat, [string]$Title, [string]$Status, [string]$Detail, [string]$Fix = '') { [pscustomobject]@{ Cat = $Cat; Title = $Title; Status = $Status; Detail = $Detail; Fix = $Fix } } function ConvertTo-Version([string]$v) { $p = @($v -split '\.' | ForEach-Object { [int]($_ -replace '\D', '') }) while ($p.Count -lt 3) { $p += 0 } return New-Object Version ($p[0], $p[1], $p[2]) } function Format-TlsName([string]$p) { switch ($p) { 'Tls' { return 'TLS 1.0' } 'Tls11' { return 'TLS 1.1' } 'Tls12' { return 'TLS 1.2' } 'Tls13' { return 'TLS 1.3' } } return $p } function Format-Date([datetime]$d) { if ($Language -eq 'de') { return $d.ToString('dd.MM.yyyy') } return $d.ToString('yyyy-MM-dd') } function Get-UrlParts([string]$url) { $u = [uri]$url $hostName = $u.Host.Trim('[', ']') return @{ Scheme = $u.Scheme.ToLowerInvariant(); Host = $hostName; Port = $u.Port; Path = $u.PathAndQuery; Url = $u.AbsoluteUri } } function Invoke-Fetch([string]$url) { $p = Get-UrlParts $url $r = [PHPCheckLan.Net]::Get($p.Scheme, $p.Host, $p.Port, $p.Path, $TimeoutMs, $UserAgent) return @{ Url = $p.Url; Parts = $p; Res = $r } } # Follow redirects (max. 5) function Invoke-Chain([string]$url) { $chain = @() $current = $url for ($i = 0; $i -le 5; $i++) { $step = Invoke-Fetch $current $chain += $step $r = $step.Res if ($r.Error) { break } if ($r.Status -ge 300 -and $r.Status -lt 400 -and $r.Header('Location')) { try { $current = ([uri]::new([uri]$current, $r.Header('Location'))).AbsoluteUri } catch { break } } else { break } } return , $chain } function Get-PhpAssessment([string]$version) { $adv = T $VersionData.php.advisory_de $VersionData.php.advisory_en if ($version -notmatch '^(\d+)\.(\d+)(?:\.(\d+))?') { return @('warn', (T 'PHP-Version nicht eindeutig erkennbar.' 'PHP version could not be determined.'), '') } $branch = "$($Matches[1]).$($Matches[2])" $patch = '0'; if ($Matches[3]) { $patch = $Matches[3] } $full = "$branch.$patch" $branches = $VersionData.php.branches if (-not $branches.Contains($branch)) { $newest = @($branches.Keys)[0] if ((ConvertTo-Version $branch) -gt (ConvertTo-Version $newest)) { return @('info', (T "PHP $full ist neuer als die bekannten Versionsdaten (Stand $($VersionData.date))." "PHP $full is newer than the known version data (as of $($VersionData.date))."), '') } return @('bad', (T "PHP $branch ist End of Life – keine offiziellen Sicherheitsupdates mehr. Betroffen von $adv ohne offiziellen Fix." "PHP $branch is end of life – no more official security updates. Affected by $adv without an official fix."), (T 'Dringend auf eine unterstützte PHP-Version migrieren. Bis dahin ggf. Distributions-Backports prüfen.' 'Migrate to a supported PHP version urgently. Until then, check for distribution backports.')) } $b = $branches[$branch] if ((ConvertTo-Version $full) -lt (ConvertTo-Version $b.fixed)) { return @('bad', (T "PHP $full ist anfällig für $adv. Behoben ab $($b.fixed), aktuell ist $($b.latest)." "PHP $full is vulnerable to $adv. Fixed in $($b.fixed), current is $($b.latest)."), (T "Sofort auf PHP $($b.latest) oder neuer aktualisieren. Linux-Distributionen spielen Fixes teils per Backport ein – dann im Paket-Changelog nach den CVE-Nummern suchen." "Update to PHP $($b.latest) or later immediately. Linux distributions often backport fixes – check the package changelog for the CVE numbers.")) } if ((ConvertTo-Version $full) -lt (ConvertTo-Version $b.latest)) { return @('warn', (T "PHP $full ist gegen PHP2Shell gepatcht, enthält aber noch nicht das $($VersionData.php.release_de). Behoben ab $($b.latest)." "PHP $full is patched against PHP2Shell but does not yet include the $($VersionData.php.release_en). Fixed in $($b.latest)."), (T "Zeitnah auf PHP $($b.latest) oder neuer aktualisieren. Linux-Distributionen spielen Fixes teils per Backport ein – dann im Paket-Changelog nach den CVE-Nummern suchen. Mehr: https://phpcheck.net/ratgeber/php-sicherheitsrelease-november-2026-php-fpm-cve-2026-129289" "Update to PHP $($b.latest) or later soon. Linux distributions often backport fixes – check the package changelog for the CVE numbers. More: https://phpcheck.net/en/guides/php-security-release-november-2026-php-fpm-cve-2026-129289")) } $eol = [datetime]::ParseExact($b.eol, 'yyyy-MM-dd', $null) $days = [int][math]::Floor(($eol - (Get-Date)).TotalDays) if ($days -lt 180) { return @('warn', (T "PHP $full ist gepatcht, aber der Security-Support für $branch endet am $(Format-Date $eol) (in $days Tagen)." "PHP $full is patched, but security support for $branch ends on $(Format-Date $eol) (in $days days)."), (T 'Migration auf eine neuere PHP-Version einplanen.' 'Plan the migration to a newer PHP version.')) } return @('ok', (T "PHP $full enthält den aktuellen Sicherheitsfix. Support bis $(Format-Date $eol)." "PHP $full includes the latest security fix. Supported until $(Format-Date $eol)."), '') } # Version comparison incl. letter suffix (OpenSSL 1.1.1zj): -1 / 0 / 1 function Compare-AdvVersion([string]$a, [string]$b) { $ma = [regex]::Match($a, '^(\d+(?:\.\d+)*)([a-z]*)', 'IgnoreCase') $mb = [regex]::Match($b, '^(\d+(?:\.\d+)*)([a-z]*)', 'IgnoreCase') $na = @($ma.Groups[1].Value -split '\.' | ForEach-Object { [int]$_ }) $nb = @($mb.Groups[1].Value -split '\.' | ForEach-Object { [int]$_ }) $len = [math]::Max($na.Count, $nb.Count) for ($i = 0; $i -lt $len; $i++) { $x = 0; if ($i -lt $na.Count) { $x = $na[$i] } $y = 0; if ($i -lt $nb.Count) { $y = $nb[$i] } if ($x -lt $y) { return -1 } if ($x -gt $y) { return 1 } } $la = $ma.Groups[2].Value.ToLowerInvariant(); $lb = $mb.Groups[2].Value.ToLowerInvariant() if ($la.Length -ne $lb.Length) { if ($la.Length -lt $lb.Length) { return -1 } return 1 } return [math]::Sign([string]::CompareOrdinal($la, $lb)) } # Check a version against a current security update. Returns: finding or $null function Get-AdvisoryFinding([string]$key, [string]$version, [bool]$distro) { if (-not $VersionData.ContainsKey('software') -or -not $VersionData.software.Contains($key)) { return $null } if ($version -notmatch '^\d+(\.\d+)*[a-z]*$') { return $null } $a = $VersionData.software[$key] $label = $a.label $info = T $a.de $a.en $title = T "Sicherheitsupdate $label ($($a.date))" "Security update $label ($($a.date))" $back = '' if ($distro) { $back = T ' Hinweis: Die Distribution spielt Fixes evtl. per Backport ein, ohne die Versionsnummer zu ändern – dann im Paket-Changelog nach den CVE-Nummern suchen.' ' Note: the distribution may backport fixes without changing the version number – check the package changelog for the CVE numbers.' } $branch = $null foreach ($b in $a.fixed.Keys) { $hit = ($version -eq $b) -or $version.StartsWith("$b.") -or ($version -match ('^' + [regex]::Escape($b) + '[a-z]')) if ($hit -and (-not $branch -or $b.Length -gt $branch.Length)) { $branch = $b } } $hb = $null foreach ($b in $a.fixed.Keys) { if (-not $hb -or (Compare-AdvVersion $b $hb) -gt 0) { $hb = $b } } $allFixed = (@($a.fixed.Values) -join ' / ') if ($a.ContainsKey('safe') -and $a.safe) { $allFixed = $a.safe } $sev = 'warn' if ($a.ContainsKey('severity') -and $a.severity) { $sev = $a.severity } if ($branch) { $fix = $a.fixed[$branch] if ((Compare-AdvVersion $version $fix) -lt 0) { return New-Finding 'Software' $title $sev ((T "$label $version enthält das Update noch nicht (behoben ab $fix). " "$label $version does not include the update yet (fixed in $fix). ") + $info + $back) (T "Auf $label $fix oder neuer aktualisieren." "Update to $label $fix or later.") } return New-Finding 'Software' $title 'ok' (T "$label $version enthält das aktuelle Sicherheitsupdate." "$label $version includes the latest security update.") } $numOnly = $version -replace '[a-z]+$', '' if ((Compare-AdvVersion $numOnly $hb) -gt 0) { return $null } if ($a.backport -and (Compare-AdvVersion $version $a.backport) -ge 0) { return New-Finding 'Software' $title 'info' ((T "Für den Zweig von $label $version gibt es ein Sicherheitsupdate. " "There is a security update for the $label $version release line. ") + $info) (T "Die neueste Version dieses Zweigs installieren (oder auf $($a.fixed[$hb]) wechseln)." "Install the latest release of this line (or move to $($a.fixed[$hb])).") } return New-Finding 'Software' $title $sev ((T "${label} ${version}: Für diesen Versionszweig gibt es keinen Fix mehr. " "${label} ${version}: this release line gets no fix. ") + $info + $back) (T "Auf einen unterstützten Zweig wechseln (aktuell sicher: $allFixed)." "Move to a supported release line (currently safe: $allFixed).") } # eMudhra incident (October 2026): compromised intermediates in the chain sent by the server? function Get-EmudhraFinding($chainInfo) { if (-not $chainInfo -or $chainInfo.Count -eq 0) { return $null } $bad = @(); $any = $false foreach ($entry in $chainInfo) { $parts = $entry -split '\|' $names = "$($parts[0]) $($parts[1])" $fp = ''; if ($parts.Count -ge 3) { $fp = $parts[2].ToUpperInvariant() } if ($VersionData.emudhra.fingerprints.ContainsKey($fp)) { $bad += $VersionData.emudhra.fingerprints[$fp] } else { $m = [regex]::Match($names, $VersionData.emudhra.names) if ($m.Success) { $bad += $m.Value } } if ($names -match '(?i)emudhra|emsign') { $any = $true } } $title = T 'Zertifikatskette: eMudhra-Vorfall' 'Certificate chain: eMudhra incident' if ($bad.Count -gt 0) { $list = ($bad | Select-Object -Unique) -join ', ' return New-Finding 'Transport' $title 'bad' (T "Die Kette enthält ein kompromittiertes eMudhra-Zertifikat ($list). Die Schlüssel dieser Zwischenzertifikate waren schwach; Browser und Betriebssysteme blockieren sie seit dem 17.–20.10.2026." "The chain contains a compromised eMudhra certificate ($list). The keys of these intermediates were weak; browsers and operating systems have blocked them since 17–20 Oct 2026.") (T 'Sofort ein neues Zertifikat aus einer anderen Zertifizierungsstelle bzw. Hierarchie ausstellen lassen.' 'Immediately obtain a new certificate from a different CA / hierarchy.') } if ($any) { return New-Finding 'Transport' $title 'info' (T 'Zertifikat von eMudhra/emSign, aber nicht aus den kompromittierten Zwischenzertifikaten.' 'Certificate from eMudhra/emSign, but not from the compromised intermediates.') } return New-Finding 'Transport' $title 'ok' (T 'Keine der im Oktober 2026 kompromittierten eMudhra-Zwischenzertifikate in der Kette.' 'None of the eMudhra intermediates compromised in October 2026 are in the chain.') } # Exchange build from the OWA login page or the X-OWA-Version header function Get-ExchangeBuild($res) { $h = $res.Header('X-OWA-Version') if ($h -and $h -match '^(\d+\.\d+\.\d+\.\d+)') { return $Matches[1] } $m = [regex]::Match($res.Body, '(?i)/owa/(?:auth/)?(\d{2}\.\d+\.\d+(?:\.\d+)?)/') if ($m.Success) { return $m.Groups[1].Value } return $null } function Get-ExchangeFinding([string]$build) { $p = $build -split '\.' $prefix = ($p | Select-Object -First 3) -join '.' $title = T 'Microsoft Exchange (Outlook im Web)' 'Microsoft Exchange (Outlook on the web)' $hc = T ' Die Anmeldeseite zeigt nicht immer den exakten SU-Stand – auf dem Server mit dem Exchange Health Checker gegenprüfen.' ' The login page does not always show the exact SU level – double-check on the server with the Exchange Health Checker.' $builds = $VersionData.exchange.builds if ($builds.Contains($prefix)) { $k = $builds[$prefix] $esu = '' $bdate = $VersionData.exchange.date if ($k.ContainsKey('date') -and $k.date) { $bdate = $k.date } $sevEx = 'warn' if ($k.esu) { $sevEx = 'bad' } if ($k.esu) { $esu = (T ' Das Sicherheitsupdate vom November 2026 gab es nur noch für Exchange SE.' ' The November 2026 security update was released for Exchange SE only.') + (T " Für $($k.name) gab es im Oktober 2026 das letzte Sicherheitsupdate – nur noch über das kostenpflichtige ESU-Programm. Migration auf Exchange SE einplanen." " $($k.name) received its last security update in October 2026 – only via the paid ESU programme. Plan the migration to Exchange SE.") } if ($p.Count -ge 4 -and ([version]$build) -lt ([version]$k.latest)) { return New-Finding 'Software' $title $sevEx ((T "$($k.name), Build ${build}: älter als das Security Update vom $bdate ($($k.latest))." "$($k.name), build ${build}: older than the security update of $bdate ($($k.latest)).") + $esu + $hc) (T "Aktuelles Security Update installieren (Ziel-Build $($k.latest))." "Install the latest security update (target build $($k.latest)).") } if ($k.esu) { return New-Finding 'Software' $title 'bad' ((T "$($k.name), Build $build." "$($k.name), build $build.") + $esu) (T 'Auf Exchange Server SE migrieren.' 'Migrate to Exchange Server SE.') } return New-Finding 'Software' $title 'ok' ((T "$($k.name), Build $build." "$($k.name), build $build.") + $hc) } if ((ConvertTo-Version $prefix) -gt (ConvertTo-Version '15.2.2562')) { return New-Finding 'Software' $title 'info' (T "Exchange-Build $build – neuer als die bekannten Daten." "Exchange build $build – newer than the known data.") } return New-Finding 'Software' $title 'bad' (T "Exchange-Build ${build}: veraltetes, nicht mehr unterstütztes Cumulative Update bzw. Version ohne Sicherheitsupdates. Exchange-Server werden regelmäßig aktiv angegriffen." "Exchange build ${build}: outdated, unsupported cumulative update or version without security updates. Exchange servers are attacked actively and regularly.") (T 'Auf ein unterstütztes CU mit aktuellem Security Update bzw. auf Exchange SE aktualisieren.' 'Update to a supported CU with the latest security update or to Exchange SE.') } # Detected products (for notes on actively exploited vulnerabilities) function Get-DetectedProducts($res, [string]$server) { $body = $res.Body $xpb = (@($res.AllHeaders('X-Powered-By')) -join ' ') $ck = (@($res.AllHeaders('Set-Cookie')) -join ' ').ToLowerInvariant() $list = New-Object System.Collections.Generic.List[string] if ($server -match '(?i)Apache/\d' -or ($server -match '(?i)^Apache' -and $server -notmatch '(?i)Coyote')) { $list.Add('Apache') } if ($server -match '(?i)nginx') { $list.Add('nginx') } if ($server -match '(?i)Microsoft-IIS') { $list.Add('Microsoft IIS') } if ($server -match '(?i)Apache-Coyote' -or $body -match 'Apache Tomcat/\d') { $list.Add('Apache Tomcat') } if ($xpb -match '(?i)PHP' -or $ck -match 'phpsessid') { $list.Add('PHP') } if ($body -match '(?i)/wp-content/|generator"[^>]*WordPress') { $list.Add('WordPress') } if ($body -match '\bNextcloud\b' -and ($body -match 'data-requesttoken|/core/')) { $list.Add('Nextcloud') } if ($res.Header('X-Plex-Protocol') -or $body -match 'Plex Media Server') { $list.Add('Plex') } if ($body -match '(?i)Synology|DiskStation') { $list.Add('Synology DSM') } if ($body -match '(?i)\bQNAP\b|QTS') { $list.Add('QNAP QTS') } if ($server -match '(?i)cpsrvd' -or $ck -match 'cprelogin|cpsession') { $list.Add('cPanel') } if ($xpb -match '(?i)plesk' -or $res.Header('X-Powered-By-Plesk')) { $list.Add('Plesk') } if ($res.Header('MicrosoftSharePointTeamServices')) { $list.Add('Microsoft SharePoint') } if ($body -match '(?i)zimbra' -and $body -match '(?i)zLoginForm|ZmLogin') { $list.Add('Zimbra') } if ($body -match '(?i)[^<]*phpMyAdmin') { $list.Add('phpMyAdmin') } if ($body -match 'rcmloginuser') { $list.Add('Roundcube') } # Java applications (Java4Shell, CVE-2026-114938) if ($res.Header('X-Jenkins') -or $res.Header('X-Hudson')) { $list.Add('Jenkins') } if ($res.Header('X-Confluence-Request-Time') -or $body -match '(?i)confluence-base-url|id="com-atlassian-confluence"') { $list.Add('Confluence') } elseif ($ck -match 'atlassian\.xsrf\.token' -or $body -match '(?i)data-name="jira"|id="jira"|ajs-jira-') { $list.Add('Jira') } if ($ck -match 'kc_restart|auth_session_id' -or $body -match '(?i)/resources/[a-z0-9]+/(login|welcome)/keycloak') { $list.Add('Keycloak') } if ($res.Header('X-Artifactory-Id') -or $res.Header('X-JFrog-Version') -or $server -match '(?i)artifactory') { $list.Add('JFrog Artifactory') } if ($body -match 'PingFederate' -or $ck -match 'pf-hfa-') { $list.Add('PingFederate') } if ($server -match '(?i)jetty') { $list.Add('Jetty') } if (("$server $xpb") -match '(?i)wildfly|jboss|undertow') { $list.Add('WildFly / JBoss') } if (("$server $xpb") -match '(?i)glassfish|payara') { $list.Add('GlassFish / Payara') } if (("$server $xpb") -match '(?i)weblogic') { $list.Add('Oracle WebLogic') } if ($body -match 'Whitelabel Error Page' -or $res.Header('X-Application-Context')) { $list.Add('Spring Boot') } if ($res.Header('X-Elastic-Product') -or $body -match '"lucene_version"') { $list.Add('Elasticsearch') } if ($ck -match 'jsessionid' -or $xpb -match '(?i)servlet') { $list.Add('Java (Servlet)') } return , $list } # Note on actively exploited vulnerabilities (CISA KEV, online data only) function Get-KevFinding([string]$product) { if (-not $VersionData.kev -or -not $VersionData.kev.map.Contains($product)) { return $null } $re = $VersionData.kev.map[$product] $hits = @($VersionData.kev.items | Where-Object { [regex]::IsMatch(("$($_.vendor) | $($_.product)"), $re) }) if ($hits.Count -eq 0) { return $null } $latest = $hits[0] $age = ((Get-Date) - [datetime]::ParseExact([string]$latest.added, 'yyyy-MM-dd', $null)).TotalDays $status = 'info'; if ($age -le $VersionData.kev.recent) { $status = 'warn' } $cves = (@($hits | Select-Object -First 4 | ForEach-Object { $_.cve }) -join ', ') $months = [int][math]::Round($VersionData.kev.show / 30) return New-Finding 'Software' (T "Aktiv ausgenutzte Lücken: $product" "Actively exploited vulnerabilities: $product") $status (T "$($hits.Count) Lücke(n) in $product wurden in den letzten $months Monaten in die CISA-Liste aktiv ausgenutzter Schwachstellen aufgenommen ($cves). Neuester Eintrag: $($latest.added) – $($latest.name). Ob genau dieses System betroffen ist, lässt sich von außen nicht feststellen." "$($hits.Count) vulnerability/ies in $product were added to CISA's list of actively exploited vulnerabilities in the last $months months ($cves). Latest entry: $($latest.added) – $($latest.name). Whether this exact system is affected cannot be determined from outside.") (T "Patchstand von $product prüfen und die Hersteller-Updates einspielen." "Check the patch level of $product and install the vendor updates.") } function Get-NodeHint { $fixed = ($VersionData.node.fixed.Values) -join ' / ' return (T "Auf dem Server `„node -v`“ ausführen: benötigt wird mindestens $fixed ($($VersionData.node.advisory_de)). Ältere Hauptversionen sind End of Life." "Run ""node -v"" on the server: at least $fixed is required ($($VersionData.node.advisory_en)). Older major versions are end of life.") } # --------------------------------------------------------------------------- # Prepare targets # --------------------------------------------------------------------------- $inputs = @() if ($Target) { $inputs += $Target } if ($TargetFile) { if (-not (Test-Path -LiteralPath $TargetFile)) { throw (T "Datei nicht gefunden: $TargetFile" "File not found: $TargetFile") } $inputs += Get-Content -LiteralPath $TargetFile | ForEach-Object { $_.Trim() } | Where-Object { $_ -and -not $_.StartsWith('#') } } $inputs = @($inputs | ForEach-Object { $_ -split '[,;\s]+' } | Where-Object { $_ } | Select-Object -Unique) if ($inputs.Count -eq 0) { Write-Host (T 'Kein Ziel angegeben. Beispiel: .\phpcheck-lan.ps1 intranet.firma.local' 'No target given. Example: .\phpcheck-lan.ps1 intranet.company.local') -ForegroundColor Yellow Write-Host (T 'Hilfe: Get-Help .\phpcheck-lan.ps1 -Detailed' 'Help: Get-Help .\phpcheck-lan.ps1 -Detailed') exit 3 } $httpsPorts = @(443, 8443, 4443, 9443) $httpPorts = @(80, 8080, 8000, 8081, 8008) # Returns a list of candidate URLs per input (in order) + whether a port was given explicitly function Get-Candidates([string]$in) { if ($in -match '^(?i)https?://') { return , @(@{ Urls = @($in); Explicit = -not ([uri]$in).IsDefaultPort; Label = $in }) } $hostPart = $in; $path = '/' $slash = $in.IndexOf('/') if ($slash -gt 0) { $hostPart = $in.Substring(0, $slash); $path = $in.Substring($slash) } $explicitPort = $null if ($hostPart -match '^\[(.+)\]:(\d+)$') { $hostPart = "[$($Matches[1])]"; $explicitPort = [int]$Matches[2] } elseif ($hostPart -match '^([^:]+):(\d+)$') { $hostPart = $Matches[1]; $explicitPort = [int]$Matches[2] } elseif ($hostPart -match ':' -and $hostPart -notmatch '^\[') { $hostPart = "[$hostPart]" } # IPv6 without brackets $ports = @() if ($explicitPort) { $ports = @($explicitPort) } elseif ($Port) { $ports = $Port } $list = @() if ($ports.Count -eq 0) { $list += @{ Urls = @("https://$hostPart$path", "http://$hostPart$path"); Explicit = $false; Label = $in } } else { foreach ($p in $ports) { if ($httpsPorts -contains $p) { $u = @("https://${hostPart}:$p$path") } elseif ($httpPorts -contains $p) { $u = @("http://${hostPart}:$p$path") } else { $u = @("https://${hostPart}:$p$path", "http://${hostPart}:$p$path") } $label = $in; if (-not $explicitPort) { $label = "${in}:$p" } $list += @{ Urls = $u; Explicit = $true; Label = $label } } } return , $list } # --------------------------------------------------------------------------- # Check a single target # --------------------------------------------------------------------------- function Test-WebTarget($cand) { $catT = T 'Transport' 'Transport'; $catP = 'PHP'; $catS = T 'Software' 'Software'; $catH = 'Header'; $catC = 'Cookies' $f = New-Object System.Collections.Generic.List[object] $chain = $null foreach ($u in $cand.Urls) { $c = Invoke-Chain $u if (-not $c[0].Res.Error) { $chain = $c; break } $lastError = $c[0].Res.Error } $result = [ordered]@{ Target = $cand.Label; Url = $cand.Urls[0]; FinalUrl = ''; Reachable = $false; Error = '' Score = $null; Groups = $null; Critical = 0; Warnings = 0; Php = ''; Server = ''; Tls = ''; CertUntil = '' Chain = @(); Findings = $f } if (-not $chain) { $result.Error = $lastError $f.Add((New-Finding $catT (T 'Erreichbarkeit' 'Reachability') 'bad' ((T 'Nicht erreichbar: ' 'Not reachable: ') + $lastError) (T 'Hostname/IP, Port und Firewall prüfen.' 'Check host name/IP, port and firewall.'))) return [pscustomobject]$result } $result.Reachable = $true $first = $chain[0] $last = $chain[$chain.Count - 1] $res = $last.Res if ($res.Error) { $res = $chain[[math]::Max(0, $chain.Count - 2)].Res; $last = $chain[[math]::Max(0, $chain.Count - 2)] } $result.Url = $first.Url $result.FinalUrl = $last.Url $result.Chain = @($chain | ForEach-Object { [ordered]@{ Url = $_.Url; Status = $_.Res.Status; Error = $_.Res.Error } }) $finalHttps = $last.Parts.Scheme -eq 'https' $tlsStep = $null foreach ($s in $chain) { if ($s.Parts.Scheme -eq 'https' -and $s.Res.Cert) { $tlsStep = $s } } # ---- Transport: encryption / redirect ------------------------------------------------------ $tRedir = T 'HTTP → HTTPS-Weiterleitung' 'HTTP → HTTPS redirect' if (-not $finalHttps) { $f.Add((New-Finding $catT (T 'Verschlüsselung' 'Encryption') 'warn' ` (T 'Die Seite wird nur unverschlüsselt (HTTP) ausgeliefert. Anmeldedaten und Inhalte sind im Netzwerk mitlesbar.' 'The site is served unencrypted (HTTP) only. Credentials and content can be read on the network.') ` (T 'HTTPS mit einem Zertifikat der internen CA (z. B. AD CS) oder Let''s Encrypt (DNS-Challenge) einrichten und HTTP umleiten.' 'Set up HTTPS with a certificate from your internal CA (e.g. AD CS) or Let''s Encrypt (DNS challenge) and redirect HTTP.'))) } elseif (-not $cand.Explicit) { $p = $first.Parts $hc = Invoke-Chain ("http://" + $(if ($p.Host -match ':') { "[$($p.Host)]" } else { $p.Host }) + $p.Path) if ($hc[0].Res.Error) { $f.Add((New-Finding $catT $tRedir 'ok' (T 'Port 80 ist nicht erreichbar – die Seite ist nur per HTTPS erreichbar.' 'Port 80 is not reachable – the site is only available via HTTPS.'))) } elseif (@($hc | Where-Object { $_.Parts.Scheme -eq 'https' }).Count -gt 0) { $f.Add((New-Finding $catT $tRedir 'ok' (T 'Unverschlüsselte Aufrufe werden auf HTTPS umgeleitet.' 'Unencrypted requests are redirected to HTTPS.'))) } else { $f.Add((New-Finding $catT $tRedir 'warn' (T 'Über HTTP wird die Seite ohne Umleitung auf HTTPS ausgeliefert.' 'Over HTTP the site is served without a redirect to HTTPS.') (T 'Dauerhafte Weiterleitung (301) von HTTP auf HTTPS einrichten.' 'Set up a permanent (301) redirect from HTTP to HTTPS.'))) } } # ---- TLS certificate ------------------------------------------------------------------------ $cert = $null if ($tlsStep) { $r = $tlsStep.Res $cert = $r.Cert } if ($tlsStep -and $cert -and $cert.NotAfter) { $tCert = T 'TLS-Zertifikat' 'TLS certificate' $days = [int][math]::Floor(($cert.NotAfter - (Get-Date)).TotalDays) $result.CertUntil = $cert.NotAfter.ToString('yyyy-MM-dd') $issuer = $cert.GetNameInfo([System.Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $true) $subject = $cert.GetNameInfo([System.Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false) $selfSigned = $cert.Subject -eq $cert.Issuer if ($days -lt 0) { $f.Add((New-Finding $catT $tCert 'bad' (T "Das Zertifikat ist seit $(-$days) Tagen abgelaufen ($(Format-Date $cert.NotAfter))." "The certificate expired $(-$days) days ago ($(Format-Date $cert.NotAfter)).") (T 'Zertifikat sofort erneuern.' 'Renew the certificate immediately.'))) } elseif ($days -le 14) { $f.Add((New-Finding $catT $tCert 'warn' (T "Das Zertifikat läuft in $days Tagen ab ($(Format-Date $cert.NotAfter))." "The certificate expires in $days days ($(Format-Date $cert.NotAfter)).") (T 'Zertifikat zeitnah erneuern bzw. automatische Erneuerung prüfen.' 'Renew the certificate soon or check automatic renewal.'))) } else { $f.Add((New-Finding $catT $tCert 'ok' (T "Gültig bis $(Format-Date $cert.NotAfter) (noch $days Tage) · ausgestellt für $subject von $issuer." "Valid until $(Format-Date $cert.NotAfter) ($days days left) · issued to $subject by $issuer."))) } if ($selfSigned) { $f.Add((New-Finding $catT (T 'Zertifikat selbstsigniert' 'Self-signed certificate') 'warn' ` (T 'Das Zertifikat ist selbstsigniert. Browser zeigen Warnungen, und Nutzer gewöhnen sich ans Wegklicken – ein Angreifer im Netz (Man-in-the-Middle) fällt dann nicht mehr auf.' 'The certificate is self-signed. Browsers show warnings and users get used to clicking them away – an attacker on the network (man-in-the-middle) then goes unnoticed.') ` (T 'Zertifikat von der internen CA (z. B. Active Directory Certificate Services) ausstellen und die CA per GPO verteilen.' 'Issue the certificate from your internal CA (e.g. Active Directory Certificate Services) and distribute the CA via GPO.'))) } elseif ($r.PolicyErrors -match 'RemoteCertificateChainErrors') { $f.Add((New-Finding $catT (T 'Zertifikatskette' 'Certificate chain') 'warn' ` (T "Die Zertifikatskette ist auf diesem PC nicht vertrauenswürdig (Aussteller: $issuer). Entweder fehlt hier das Root-Zertifikat der internen CA oder der Server liefert die Zwischenzertifikate nicht mit." "The certificate chain is not trusted on this PC (issuer: $issuer). Either the internal CA root certificate is missing here or the server does not send the intermediate certificates.") ` (T 'Root-CA per GPO verteilen bzw. auf dem Server die vollständige Kette (Zwischenzertifikate) hinterlegen.' 'Distribute the root CA via GPO, or configure the full chain (intermediates) on the server.'))) } if ($r.PolicyErrors -match 'RemoteCertificateNameMismatch') { $f.Add((New-Finding $catT (T 'Zertifikatsname' 'Certificate name') 'warn' ` (T "Das Zertifikat passt nicht zum aufgerufenen Namen `„$($tlsStep.Parts.Host)`“ (ausgestellt für $subject)." "The certificate does not match the requested name ""$($tlsStep.Parts.Host)"" (issued to $subject).") ` (T 'Zertifikat mit passendem Namen (Subject Alternative Name) ausstellen bzw. die Seite über den Namen im Zertifikat aufrufen.' 'Issue a certificate with the matching name (Subject Alternative Name) or access the site using the name in the certificate.'))) } $sig = '' try { $sig = $cert.SignatureAlgorithm.FriendlyName } catch { } if ($sig -match '(?i)sha1|md5') { $f.Add((New-Finding $catT (T 'Signaturalgorithmus' 'Signature algorithm') 'warn' (T "Das Zertifikat ist mit dem veralteten Verfahren $sig signiert." "The certificate is signed with the outdated algorithm $sig.") (T 'Neues Zertifikat mit SHA-256 ausstellen.' 'Issue a new certificate using SHA-256.'))) } if ($r.KeyAlg -eq 'RSA' -and $r.KeySize -gt 0 -and $r.KeySize -lt 2048) { $f.Add((New-Finding $catT (T 'Schlüssellänge' 'Key length') 'warn' (T "RSA-Schlüssel mit nur $($r.KeySize) Bit." "RSA key with only $($r.KeySize) bits.") (T 'Neues Zertifikat mit mindestens 2048 Bit (besser 3072) oder ECDSA erzeugen.' 'Create a new certificate with at least 2048 bits (better 3072) or ECDSA.'))) } $em = Get-EmudhraFinding $r.ChainInfo if ($em) { $f.Add($em) } # ---- TLS versions ------------------------------------------------------------------------ $tp = $tlsStep.Parts $probe = [ordered]@{} foreach ($pv in @(@('TLS 1.0', 192), @('TLS 1.1', 768), @('TLS 1.2', 3072), @('TLS 1.3', 12288))) { $probe[$pv[0]] = [PHPCheckLan.Net]::ProbeTls($tp.Host, $tp.Port, $pv[1], $TimeoutMs) } $fmt = @($probe.Keys | ForEach-Object { $v = $probe[$_] if ($v -eq 'yes') { "${_}: " + (T 'ja' 'yes') } elseif ($v -eq 'no') { "${_}: " + (T 'nein' 'no') } else { "${_}: " + (T 'n. t.' 'n/t') } }) -join ' · ' $result.Tls = Format-TlsName $r.TlsProtocol $old = @(@('TLS 1.0', 'TLS 1.1') | Where-Object { $probe[$_] -eq 'yes' }) $tTls = T 'TLS-Versionen' 'TLS versions' if ($old.Count -gt 0) { $f.Add((New-Finding $catT $tTls 'warn' (T "Der Server akzeptiert noch veraltete Protokolle: $($old -join ', '). ($fmt)" "The server still accepts outdated protocols: $($old -join ', '). ($fmt)") (T 'TLS 1.0 und 1.1 deaktivieren – nur TLS 1.2 und 1.3 erlauben (Windows: SChannel-Registry bzw. IIS Crypto; Apache: SSLProtocol; nginx: ssl_protocols).' 'Disable TLS 1.0 and 1.1 – allow only TLS 1.2 and 1.3 (Windows: SChannel registry or IIS Crypto; Apache: SSLProtocol; nginx: ssl_protocols).'))) } elseif ($probe['TLS 1.2'] -ne 'yes' -and $probe['TLS 1.3'] -ne 'yes') { $f.Add((New-Finding $catT $tTls 'info' (T "Ausgehandelt: $(Format-TlsName $r.TlsProtocol). Einzeltest nicht eindeutig ($fmt)." "Negotiated: $(Format-TlsName $r.TlsProtocol). Individual test inconclusive ($fmt)."))) } else { $f.Add((New-Finding $catT $tTls 'ok' (T "Nur aktuelle Protokolle. Ausgehandelt: $(Format-TlsName $r.TlsProtocol). ($fmt)" "Only current protocols. Negotiated: $(Format-TlsName $r.TlsProtocol). ($fmt)"))) } } # ---- PHP & Software --------------------------------------------------------------------------- $server = $res.Header('Server'); if (-not $server) { $server = '' } $result.Server = $server $xpb = @($res.AllHeaders('X-Powered-By')) $phpVer = $null foreach ($h in (@($server) + $xpb)) { if ($h -match '(?i)PHP/(\d+\.\d+(?:\.\d+)?)') { $phpVer = $Matches[1]; break } } if ($phpVer) { $result.Php = $phpVer $a = Get-PhpAssessment $phpVer $f.Add((New-Finding $catP (T 'PHP-Version & PHP2Shell' 'PHP version & PHP2Shell') $a[0] $a[1] $a[2])) $f.Add((New-Finding $catP (T 'PHP-Version sichtbar' 'PHP version visible') 'warn' (T "Der Server verrät die PHP-Version ($phpVer). Das erleichtert Angreifern die Suche nach passenden Lücken." "The server reveals the PHP version ($phpVer). This helps attackers find matching vulnerabilities.") (T 'In der php.ini expose_php = Off setzen.' 'Set expose_php = Off in php.ini.'))) } else { $phpHint = ($res.AllHeaders('Set-Cookie') -join ' ') -match '(?i)PHPSESSID' -or ($xpb -join ' ') -match '(?i)php' if ($phpHint) { $f.Add((New-Finding $catP (T 'PHP-Version & PHP2Shell' 'PHP version & PHP2Shell') 'info' (T 'PHP wird verwendet, die Version ist aber ausgeblendet (gut). Den Patchstand bitte direkt auf dem Server mit „php -v“ prüfen.' 'PHP is used, but the version is hidden (good). Please verify the patch level directly on the server with "php -v".'))) } else { $f.Add((New-Finding $catP (T 'PHP-Version & PHP2Shell' 'PHP version & PHP2Shell') 'info' (T 'Keine PHP-Version in den Antwort-Headern sichtbar.' 'No PHP version visible in the response headers.'))) } } if ($server -match '\d+\.\d+') { $f.Add((New-Finding $catS (T 'Server-Banner' 'Server banner') 'warn' (T "Der Server-Header verrät Software und Version: `„$server`“." "The Server header reveals software and version: ""$server"".") (T 'Versionsangabe ausblenden (Apache: ServerTokens Prod; nginx: server_tokens off; IIS: removeServerHeader="true").' 'Hide the version (Apache: ServerTokens Prod; nginx: server_tokens off; IIS: removeServerHeader="true").'))) } elseif ($server) { $f.Add((New-Finding $catS (T 'Server-Banner' 'Server banner') 'ok' (T "Server-Header ohne Versionsnummer: `„$server`“." "Server header without version number: ""$server""."))) } # Current security updates (Apache, nginx, OpenSSL) based on the version number in the Server header $distro = $server -match '(?i)\((Ubuntu|Debian|CentOS|Red Hat|Rocky|AlmaLinux|Fedora|SUSE)\)|deb\d|ubuntu' foreach ($pair in @(@('apache', '(?i)Apache/(\d+\.\d+\.\d+)'), @('nginx', '(?i)nginx/(\d+\.\d+\.\d+)'), @('openssl', '(?i)OpenSSL/(\d+\.\d+\.\d+[a-z]*)'))) { $mm = [regex]::Match($server, $pair[1]) if ($mm.Success) { $adv = Get-AdvisoryFinding $pair[0] $mm.Groups[1].Value $distro if ($adv) { $f.Add($adv) } } } foreach ($xh in @('X-AspNet-Version', 'X-AspNetMvc-Version')) { $v = $res.Header($xh) if ($v) { $f.Add((New-Finding $catS 'ASP.NET' 'warn' (T "$xh legt die Version offen: $v." "$xh discloses the version: $v.") (T 'In der web.config <httpRuntime enableVersionHeader="false" /> setzen bzw. MvcHandler.DisableMvcResponseHeader = true.' 'Set <httpRuntime enableVersionHeader="false" /> in web.config or MvcHandler.DisableMvcResponseHeader = true.'))) } } $otherXpb = @($xpb | Where-Object { $_ -notmatch '(?i)PHP' }) if (($otherXpb -join ' ') -match '(?i)express|next\.js|nuxt|node') { $f.Add((New-Finding $catS 'Node.js' 'warn' (T "Die Anwendung läuft erkennbar mit Node.js (X-Powered-By: $($otherXpb -join ', ')). Die Node.js-Version ist von außen nicht feststellbar." "The application evidently runs on Node.js (X-Powered-By: $($otherXpb -join ', ')). The Node.js version cannot be determined from outside.") (Get-NodeHint))) } elseif ($otherXpb.Count -gt 0) { $f.Add((New-Finding $catS 'X-Powered-By' 'info' (T "X-Powered-By: $($otherXpb -join ', ')" "X-Powered-By: $($otherXpb -join ', ')") (T 'Header entfernen – er hilft nur Angreifern.' 'Remove the header – it only helps attackers.'))) } if ($res.Body -match '(?is)<meta[^>]+name\s*=\s*["'']generator["''][^>]*content\s*=\s*["'']([^"'']+)["'']' -or $res.Body -match '(?is)<meta[^>]+content\s*=\s*["'']([^"'']+)["''][^>]*name\s*=\s*["'']generator["'']') { $gen = $Matches[1].Trim() $wm = [regex]::Match($gen, '(?i)WordPress\s+(\d+\.\d+(?:\.\d+)?)') if ($wm.Success) { $adv = Get-AdvisoryFinding 'wordpress' $wm.Groups[1].Value $false if ($adv) { $f.Add($adv) } } if ($gen -match '\d+\.\d+') { $f.Add((New-Finding $catS (T 'CMS-Version' 'CMS version') 'warn' (T "Der Seitenquelltext verrät das CMS mit Version: `„$gen`“." "The page source reveals the CMS and version: ""$gen"".") (T 'CMS aktuell halten und den Generator-Tag entfernen (WordPress: remove_action(''wp_head'', ''wp_generator'')).' 'Keep the CMS up to date and remove the generator tag (WordPress: remove_action(''wp_head'', ''wp_generator'')).'))) } else { $f.Add((New-Finding $catS (T 'CMS' 'CMS') 'info' (T "Generator: `„$gen`“ (ohne Versionsnummer)." "Generator: ""$gen"" (no version number)."))) } } # ---- Exchange, Nextcloud and actively exploited vulnerabilities ------------------------------- $exBuild = $null foreach ($st in $chain) { if (-not $st.Res.Error) { $b = Get-ExchangeBuild $st.Res; if ($b) { $exBuild = $b } } } if ($exBuild) { $f.Add((Get-ExchangeFinding $exBuild)) } $products = Get-DetectedProducts $res $server if ($products.Contains('Nextcloud')) { $f.Add((New-Finding $catS (T 'Nextcloud: Collabora Online (CVE-2026-110447)' 'Nextcloud: Collabora Online (CVE-2026-110447)') 'warn' (T 'Nextcloud erkannt. Die App „Collabora Online – Built-in CODE Server“ hat eine aktiv ausgenutzte Lücke (Befehlsausführung, CVSS 9.2); Angreifer haben darüber Webshells abgelegt.' 'Nextcloud detected. The app "Collabora Online – Built-in CODE Server" has an actively exploited vulnerability (command execution, CVSS 9.2); attackers have used it to plant web shells.') (T 'Falls installiert: sofort auf 26.4.303 oder neuer aktualisieren und den Server auf unbekannte PHP-Dateien prüfen.' 'If installed: update to 26.4.303 or later immediately and check the server for unknown PHP files.'))) } if ($products.Contains('Plex')) { $f.Add((New-Finding $catS 'Plex Media Server (Plex2Shell)' 'warn' (T 'Plex Media Server erkannt. Vier verkettbare Lücken („Plex2Shell“) werden aktiv ausgenutzt, u. a. für Krypto-Miner.' 'Plex Media Server detected. Four chainable vulnerabilities ("Plex2Shell") are being actively exploited, e.g. for crypto miners.') (T 'Auf Version 1.43.3.10861 oder neuer aktualisieren und den Server nicht direkt ins Internet stellen.' 'Update to version 1.43.3.10861 or later and do not expose the server directly to the internet.'))) } # Java4Shell / "Java2Shell" (CVE-2026-114938): the Java version cannot be determined from outside $jPre = @($products | Where-Object { @('Jenkins', 'Jira', 'Confluence', 'Keycloak', 'JFrog Artifactory', 'PingFederate') -contains $_ }) $jAny = @($products | Where-Object { @('Apache Tomcat', 'Java (Servlet)', 'Jetty', 'WildFly / JBoss', 'GlassFish / Payara', 'Oracle WebLogic', 'Spring Boot', 'Elasticsearch') -contains $_ }) if (($jPre.Count + $jAny.Count) -gt 0) { $jList = (@($jPre) + @($jAny)) -join ', ' $jStatus = 'info'; $jExtra = '' if ($jPre.Count -gt 0) { $jStatus = 'warn' $jExtra = T " Für $($jPre -join ', ') wurde Codeausführung ohne Anmeldung demonstriert." " For $($jPre -join ', '), code execution without login has been demonstrated." } $f.Add((New-Finding $catS 'Java4Shell (CVE-2026-114938)' $jStatus ((T "Java-Anwendung erkannt: $jList. Die Lücke Java4Shell (anfangs Java2Shell genannt, CVSS 9.2) steckt im Base64-Decoder von Java und kann Codeausführung ohne Anmeldung ermöglichen. Betroffen sind Java 17 (ab 17.0.6), 21, 25 und 27 auf x86-64-Servern mit AVX-512 (Intel ab Ice Lake, AMD ab Zen 4); Java 8 und 11 sind nicht betroffen. Welche Java-Version läuft, lässt sich von außen nicht feststellen. Angriffe sind bisher nicht bekannt." "Java application detected: $jList. The Java4Shell flaw (initially called Java2Shell, CVSS 9.2) is in Java's Base64 decoder and can allow unauthenticated code execution. Java 17 (from 17.0.6), 21, 25 and 27 on x86-64 servers with AVX-512 (Intel Ice Lake or newer, AMD Zen 4 or newer) are affected; Java 8 and 11 are not. Which Java version is running cannot be determined from outside. No attacks are known so far.") + $jExtra) (T 'Auf dem Server java -version prüfen: sicher ab 17.0.21.1 / 21.0.13.1 / 25.0.5.1 / 27.0.1.1 (bzw. das gepatchte Paket des Anbieters), danach alle Java-Prozesse neu starten. Übergangslösung: JVM-Option -XX:-UseBASE64Intrinsics. Mehr: https://phpcheck.net/ratgeber/java4shell-java2shell-cve-2026-114938' 'Run java -version on the server: safe from 17.0.21.1 / 21.0.13.1 / 25.0.5.1 / 27.0.1.1 (or your vendor''s patched package), then restart all Java processes. Interim mitigation: JVM option -XX:-UseBASE64Intrinsics. More: https://phpcheck.net/en/guides/java4shell-java2shell-cve-2026-114938'))) } $shown = 0 foreach ($pr in $products) { if ($shown -ge 5 -or $pr -eq 'Nextcloud' -or $pr -eq 'Plex') { continue } $kf = Get-KevFinding $pr if ($kf) { $f.Add($kf); $shown++ } } # ---- Security-Header ------------------------------------------------------------------------ $missing = T 'Header fehlt.' 'Header missing.' if ($finalHttps) { $hsts = $res.Header('Strict-Transport-Security') if (-not $hsts) { $f.Add((New-Finding $catH 'Strict-Transport-Security (HSTS)' 'warn' $missing (T 'Strict-Transport-Security: max-age=31536000 setzen (erst nach erfolgreichem HTTPS-Test).' 'Set Strict-Transport-Security: max-age=31536000 (only after HTTPS works reliably).'))) } elseif ($hsts -match 'max-age\s*=\s*(\d+)' -and [int64]$Matches[1] -lt 15552000) { $f.Add((New-Finding $catH 'Strict-Transport-Security (HSTS)' 'info' (T "max-age ist kurz ($($Matches[1]) s)." "max-age is short ($($Matches[1]) s).") (T 'Mindestens 6 Monate (15552000) empfohlen.' 'At least 6 months (15552000) recommended.'))) } else { $f.Add((New-Finding $catH 'Strict-Transport-Security (HSTS)' 'ok' $hsts)) } } $csp = $res.Header('Content-Security-Policy') if ($csp) { $f.Add((New-Finding $catH 'Content-Security-Policy' 'ok' (T 'Gesetzt.' 'Set.'))) } else { $f.Add((New-Finding $catH 'Content-Security-Policy' 'warn' $missing (T 'CSP definieren, z. B. mit „default-src ''self''“ beginnen.' 'Define a CSP, e.g. start with "default-src ''self''".'))) } $xfo = $res.Header('X-Frame-Options') if ($xfo -or ($csp -and $csp -match '(?i)frame-ancestors')) { $f.Add((New-Finding $catH (T 'Clickjacking-Schutz' 'Clickjacking protection') 'ok' $(if ($xfo) { "X-Frame-Options: $xfo" } else { 'CSP frame-ancestors' }))) } else { $f.Add((New-Finding $catH (T 'Clickjacking-Schutz' 'Clickjacking protection') 'warn' $missing (T 'X-Frame-Options: SAMEORIGIN oder CSP frame-ancestors setzen.' 'Set X-Frame-Options: SAMEORIGIN or CSP frame-ancestors.'))) } $xcto = $res.Header('X-Content-Type-Options') if ($xcto -and $xcto -match '(?i)nosniff') { $f.Add((New-Finding $catH 'X-Content-Type-Options' 'ok' 'nosniff')) } else { $f.Add((New-Finding $catH 'X-Content-Type-Options' 'warn' $missing 'X-Content-Type-Options: nosniff')) } $rp = $res.Header('Referrer-Policy') if ($rp) { $f.Add((New-Finding $catH 'Referrer-Policy' 'ok' $rp)) } else { $f.Add((New-Finding $catH 'Referrer-Policy' 'info' $missing 'Referrer-Policy: strict-origin-when-cross-origin')) } $pp = $res.Header('Permissions-Policy') if ($pp) { $f.Add((New-Finding $catH 'Permissions-Policy' 'ok' (T 'Gesetzt.' 'Set.'))) } else { $f.Add((New-Finding $catH 'Permissions-Policy' 'info' $missing 'Permissions-Policy: camera=(), microphone=(), geolocation=()')) } # ---- Cookies -------------------------------------------------------------------------------- $cookies = @() foreach ($s in $chain) { if (-not $s.Res.Error) { $cookies += @($s.Res.AllHeaders('Set-Cookie')) } } foreach ($ck in ($cookies | Select-Object -Unique)) { $name = ($ck -split '=', 2)[0].Trim() $attrs = ($ck -split ';' | Select-Object -Skip 1 | ForEach-Object { $_.Trim().ToLowerInvariant() }) $miss = @() if ($finalHttps -and -not ($attrs -contains 'secure')) { $miss += 'Secure' } if (-not ($attrs -contains 'httponly')) { $miss += 'HttpOnly' } if (-not ($attrs | Where-Object { $_ -like 'samesite=*' })) { $miss += 'SameSite' } $session = $name -match '(?i)sess|sid|auth|token|login|asp\.net|jsession|laravel|wordpress_logged' if ($miss.Count -eq 0) { $f.Add((New-Finding $catC (T "Cookie `„$name`“" "Cookie ""$name""") 'ok' (T 'Secure, HttpOnly und SameSite gesetzt.' 'Secure, HttpOnly and SameSite set.'))) } else { $st = 'info'; if ($session -and ($miss -contains 'Secure' -or $miss -contains 'HttpOnly')) { $st = 'warn' } $f.Add((New-Finding $catC (T "Cookie `„$name`“" "Cookie ""$name""") $st ((T 'Es fehlt: ' 'Missing: ') + ($miss -join ', ')) (T 'Cookie-Attribute in der Anwendung bzw. Serverkonfiguration ergänzen.' 'Add the cookie attributes in the application or server configuration.'))) } } # ---- Score ---------------------------------------------------------------------------------- $warn = @($f | Where-Object { $_.Status -eq 'warn' }).Count $bad = @($f | Where-Object { $_.Status -eq 'bad' }).Count $result.Warnings = $warn $result.Critical = $bad $sc = Get-Scores $f $result.Score = $sc.Score $result.Groups = $sc.Groups return [pscustomobject]$result } # --------------------------------------------------------------------------- # Rating by severity (as on phpcheck.net, see inc/scoring.php) # --------------------------------------------------------------------------- $SevCritical = 8; $SevHigh = 4; $SevMedium = 2; $SevLow = 1; $SevMinimal = 0.5 $ScoreRules = @( @('(?i)^PHP(-Version| version)', 'bad', $SevCritical), @('(?i)^PHP(-Version| version)', 'warn', $SevMedium), @('(?i)Microsoft Exchange', 'bad', $SevCritical), @('(?i)Microsoft Exchange', 'warn', $SevHigh), @('(?i)Nextcloud: Collabora|Plex Media Server', '*', $SevHigh), @('(?i)Aktiv ausgenutzt|Actively exploited', 'warn', $SevMedium), @('(?i)Java4Shell', 'warn', $SevMedium), @('(?i)Sicherheitsupdate|Security update', 'warn', $SevMedium), @('(?i)^Node\.js', 'warn', $SevMedium), @('(?i)CMS-Version|CMS version', 'warn', $SevLow), @('(?i)PHP-Version sichtbar|PHP version visible', 'warn', $SevLow), @('(?i)Server-Banner|Server banner|ASP\.NET|X-Powered-By', 'warn', $SevMinimal), @('(?i)Zertifikatskette: eMudhra|Certificate chain: eMudhra', 'bad', $SevCritical), @('(?i)Erreichbarkeit|Reachability', '*', 0), @('(?i)Interner Fehler|Internal error', '*', 0), @('(?i)^TLS-Zertifikat|^TLS certificate', 'bad', $SevCritical), @('(?i)^TLS-Zertifikat|^TLS certificate', 'warn', $SevMedium), @('(?i)selbstsigniert|Self-signed', 'warn', $SevMedium), @('(?i)Zertifikatskette|Certificate chain|Zertifikatsname|Certificate name', 'warn', $SevLow), @('(?i)Signaturalgorithmus|Signature algorithm|Schlüssellänge|Key length', 'warn', $SevMedium), @('(?i)TLS-Versionen|TLS versions', 'warn', $SevMedium), @('(?i)^Verschlüsselung|^Encryption', 'warn', $SevHigh), @('HTTP → HTTPS', 'warn', $SevMedium), @('(?i)Strict-Transport-Security', 'warn', $SevMedium), @('(?i)Content-Security-Policy|Clickjacking', 'warn', $SevLow), @('(?i)X-Content-Type-Options', 'warn', $SevMinimal), @('(?i)^Cookie', 'warn', $SevLow) ) $ScoreGroups = [ordered]@{ software = @{ weight = 35; cats = @('PHP', 'Software'); label = (T 'Software & Patches' 'Software & patches') } transport = @{ weight = 25; cats = @('Transport'); label = (T 'Verschlüsselung' 'Encryption') } browser = @{ weight = 15; cats = @('Header', 'Cookies'); label = (T 'Browser-Schutz' 'Browser protection') } } function Get-FindingWeight($fd) { if ($fd.Status -ne 'bad' -and $fd.Status -ne 'warn') { return 0 } foreach ($rule in $ScoreRules) { if (($rule[1] -eq '*' -or $rule[1] -eq $fd.Status) -and $fd.Title -match $rule[0]) { $w = [double]$rule[2] if ($fd.Status -eq 'bad' -and $w -gt 0 -and $w -lt $SevHigh) { $w = $SevHigh } # red = at least "high" return $w } } if ($fd.Status -eq 'bad') { return $SevHigh } return $SevLow } function Get-SeverityLabel([double]$w) { if ($w -ge $SevCritical) { return (T 'kritisch' 'critical') } if ($w -ge $SevHigh) { return (T 'hoch' 'high') } if ($w -ge $SevMedium) { return (T 'mittel' 'medium') } if ($w -gt 0) { return (T 'niedrig' 'low') } return '' } function Get-Scores($findings) { $points = @{} foreach ($fd in $findings) { $w = Get-FindingWeight $fd $fd | Add-Member -NotePropertyName Weight -NotePropertyValue $w -Force $grp = 'software' foreach ($k in $ScoreGroups.Keys) { if ($ScoreGroups[$k].cats -contains $fd.Cat) { $grp = $k } } if (-not $points.ContainsKey($grp)) { $points[$grp] = 0.0 } $points[$grp] += $w } $groups = [ordered]@{} $sum = 0.0; $sumW = 0 foreach ($k in $ScoreGroups.Keys) { if (-not $points.ContainsKey($k)) { continue } $gs = [int][math]::Max(0, [math]::Round(100 - $points[$k] * 9)) $groups[$ScoreGroups[$k].label] = $gs $sum += $gs * $ScoreGroups[$k].weight; $sumW += $ScoreGroups[$k].weight } $total = 100 if ($sumW -gt 0) { $total = [int][math]::Round($sum / $sumW) } if (@($findings | Where-Object { $_.Status -eq 'bad' }).Count -gt 0) { $total = [math]::Min($total, 49) } return @{ Score = $total; Groups = $groups } } function Get-Verdict($r) { if (-not $r.Reachable) { return @('bad', (T 'Nicht erreichbar' 'Not reachable')) } if ($r.Critical -gt 0) { return @('bad', (T 'Handlungsbedarf' 'Action required')) } if ($r.Score -ge 80) { return @('ok', (T 'Gut abgesichert' 'Well protected')) } return @('warn', (T 'Verbesserungswürdig' 'Room for improvement')) } # --------------------------------------------------------------------------- # Run # --------------------------------------------------------------------------- $candidates = @() foreach ($in in $inputs) { $candidates += Get-Candidates $in } Write-Host '' Write-Host ' PHPCheck.net LAN-Check' -ForegroundColor Cyan -NoNewline Write-Host (" v$ScriptVersion · " + (T "Versionsdaten: $($VersionData.date) ($VersionSource)" "Version data: $($VersionData.date) ($VersionSource)")) -ForegroundColor DarkGray Write-Host (' ' + (T 'Passiv: nur normale Seitenaufrufe, keine Angriffe.' 'Passive: normal page requests only, no attacks.')) -ForegroundColor DarkGray # Local certificate store (Windows only): does this PC still trust the root affected by the eMudhra incident? $StoreNote = '' if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { try { $roots = @(Get-ChildItem -Path 'Cert:\LocalMachine\Root', 'Cert:\CurrentUser\Root' -ErrorAction SilentlyContinue | Where-Object { $_.Subject -match '(?i)emSign ECC Root CA - G3|emSign Root TLS CA - G3' }) $blocked = @(Get-ChildItem -Path 'Cert:\LocalMachine\Disallowed' -ErrorAction SilentlyContinue | ForEach-Object { $_.Thumbprint }) $open = @($roots | Where-Object { $blocked -notcontains $_.Thumbprint }) if ($open.Count -gt 0) { $StoreNote = T "Dieser PC vertraut noch der Root „$(($open | Select-Object -First 1).GetNameInfo('SimpleName', $false))“ aus dem eMudhra-Vorfall (Oktober 2026). Windows-Updates einspielen bzw. die Zertifikatsliste aktualisieren." "This PC still trusts the root ""$(($open | Select-Object -First 1).GetNameInfo('SimpleName', $false))"" from the eMudhra incident (October 2026). Install Windows updates or refresh the certificate list." Write-Host (' ' + $StoreNote) -ForegroundColor Yellow } } catch { } } Write-Host '' $results = @() $n = 0 foreach ($c in $candidates) { $n++ Write-Progress -Activity 'PHPCheck.net LAN-Check' -Status $c.Label -PercentComplete ([int](100 * ($n - 1) / $candidates.Count)) try { $r = Test-WebTarget $c } catch { # Unexpected error for one target: report it (with line number) and continue with the next target $ii = $_.InvocationInfo $msg = $_.Exception.Message Write-Host ((T 'Interner Fehler bei ' 'Internal error for ') + $c.Label + ': ' + $msg) -ForegroundColor Red Write-Host (" " + (T 'Zeile' 'Line') + " $($ii.ScriptLineNumber): $($ii.Line.Trim())") -ForegroundColor DarkGray Write-Host (" PowerShell $($PSVersionTable.PSVersion) · " + (T 'Bitte diese Meldung an phpcheck.net senden.' 'Please report this message to phpcheck.net.')) -ForegroundColor DarkGray $fl = New-Object System.Collections.Generic.List[object] $fl.Add((New-Finding 'Transport' (T 'Interner Fehler' 'Internal error') 'bad' "$msg (Zeile/line $($ii.ScriptLineNumber))")) $r = [pscustomobject][ordered]@{ Target = $c.Label; Url = $c.Urls[0]; FinalUrl = ''; Reachable = $false; Error = $msg; Score = $null; Groups = $null; Critical = 0; Warnings = 0 Php = ''; Server = ''; Tls = ''; CertUntil = ''; Chain = @(); Findings = $fl } } $results += $r $v = Get-Verdict $r $col = @{ ok = 'Green'; warn = 'Yellow'; bad = 'Red' }[$v[0]] Write-Host ('■ ' + $r.Target) -ForegroundColor White -NoNewline if ($r.Reachable) { Write-Host (" $($r.Score)/100 · $($v[1])") -ForegroundColor $col } else { Write-Host (" $($v[1])") -ForegroundColor $col } if ($r.FinalUrl -and $r.FinalUrl -ne $r.Url) { Write-Host (" → $($r.FinalUrl)") -ForegroundColor DarkGray } if ($r.Groups) { Write-Host (' ' + ((@($r.Groups.Keys) | ForEach-Object { "${_}: $($r.Groups[$_])" }) -join ' · ')) -ForegroundColor DarkGray } foreach ($fd in ($r.Findings | Sort-Object { @{ bad = 0; warn = 1; info = 2; ok = 3 }[$_.Status] })) { $tag = @{ ok = '[ OK ]'; warn = '[ !! ]'; bad = '[KRIT]'; info = '[INFO]' }[$fd.Status] if ($Language -ne 'de' -and $fd.Status -eq 'bad') { $tag = '[CRIT]' } $tc = @{ ok = 'Green'; warn = 'Yellow'; bad = 'Red'; info = 'Cyan' }[$fd.Status] Write-Host " $tag " -ForegroundColor $tc -NoNewline $sev = '' if ($fd.PSObject.Properties['Weight']) { $sl = Get-SeverityLabel $fd.Weight; if ($sl) { $sev = " [$((T 'Schwere' 'Severity')): $sl]" } } Write-Host "$($fd.Title)${sev}: " -NoNewline Write-Host $fd.Detail -ForegroundColor Gray if ($fd.Fix -and $fd.Status -ne 'ok') { Write-Host (" → " + $fd.Fix) -ForegroundColor DarkGray } } Write-Host '' } Write-Progress -Activity 'PHPCheck.net LAN-Check' -Completed # Summary if ($results.Count -gt 1) { Write-Host (T 'Übersicht' 'Summary') -ForegroundColor Cyan $results | Select-Object @{ n = (T 'Ziel' 'Target'); e = { $_.Target } }, @{ n = 'Score'; e = { if ($_.Reachable) { $_.Score } else { '–' } } }, @{ n = (T 'Bewertung' 'Rating'); e = { (Get-Verdict $_)[1] } }, @{ n = (T 'Kritisch' 'Critical'); e = { $_.Critical } }, @{ n = (T 'Hinweise' 'Warnings'); e = { $_.Warnings } }, @{ n = 'PHP'; e = { $_.Php } }, @{ n = 'TLS'; e = { $_.Tls } }, @{ n = (T 'Zertifikat bis' 'Cert until'); e = { $_.CertUntil } } | Format-Table -AutoSize | Out-String -Width 250 | Write-Host } # --------------------------------------------------------------------------- # HTML report # --------------------------------------------------------------------------- function HE([string]$s) { return [System.Net.WebUtility]::HtmlEncode($s) } if (-not $NoReport) { if (-not $Report) { $Report = Join-Path (Get-Location).Path ('PHPCheck-LAN-Report_' + (Get-Date -Format 'yyyy-MM-dd_HHmm') + '.html') } $now = Get-Date $catNames = [ordered]@{ 'Transport' = (T 'Verschlüsselung & Transport' 'Encryption & transport'); 'PHP' = 'PHP'; 'Software' = (T 'Software & Offenlegung' 'Software & disclosure'); 'Header' = 'Security-Header'; 'Cookies' = 'Cookies' } $statusText = @{ ok = 'OK'; warn = (T 'Hinweis' 'Warning'); bad = (T 'Kritisch' 'Critical'); info = 'Info' } $sb = New-Object System.Text.StringBuilder [void]$sb.Append(@" <!doctype html> <html lang="$Language"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <title>PHPCheck.net LAN-Report – $(Format-Date $now)
PHPCheck.net · LAN-Check
$(if ($StoreNote) { '

' + (HE $StoreNote) + '

' })

$(HE (T "Erstellt am $(Format-Date $now) um $($now.ToString('HH:mm')) Uhr auf $([Environment]::MachineName) · Versionsdaten: $($VersionData.date) ($VersionSource) · Skript v$ScriptVersion" "Created on $(Format-Date $now) at $($now.ToString('HH:mm')) on $([Environment]::MachineName) · version data: $($VersionData.date) ($VersionSource) · script v$ScriptVersion"))

"@) if ($results.Count -gt 1) { [void]$sb.Append("") $i = 0 foreach ($r in $results) { $i++; $v = Get-Verdict $r $sc = '–'; if ($r.Reachable) { $sc = $r.Score } [void]$sb.Append("") } [void]$sb.Append('
$(HE (T 'Ziel' 'Target'))Score$(HE (T 'Bewertung' 'Rating'))PHPTLS$(HE (T 'Zertifikat bis' 'Cert until'))
$(HE $r.Target)$sc$(HE $v[1])$(HE $r.Php)$(HE $r.Tls)$(HE $r.CertUntil)
') } $i = 0 foreach ($r in $results) { $i++; $v = Get-Verdict $r $sc = '–'; if ($r.Reachable) { $sc = $r.Score } $sub = $r.Url; if ($r.FinalUrl -and $r.FinalUrl -ne $r.Url) { $sub = "$($r.Url) → $($r.FinalUrl)" } if ($r.Server) { $sub += " · Server: $($r.Server)" } [void]$sb.Append("
$sc

$(HE $r.Target)

$(HE $v[1])

$(HE $sub)

$(if ($r.Groups) { '

' + (HE ((@($r.Groups.Keys) | ForEach-Object { "${_}: $($r.Groups[$_])" }) -join ' · ')) + '

' })
") foreach ($cat in $catNames.Keys) { $items = @($r.Findings | Where-Object { $_.Cat -eq $cat -or ($cat -eq 'Software' -and $_.Cat -eq 'Software') } | Sort-Object { @{ bad = 0; warn = 1; info = 2; ok = 3 }[$_.Status] }) if ($items.Count -eq 0) { continue } [void]$sb.Append("

$(HE $catNames[$cat])

") foreach ($fd in $items) { $fix = ''; if ($fd.Fix -and $fd.Status -ne 'ok') { $fix = "
$(HE $fd.Fix)
" } [void]$sb.Append("
$(HE $statusText[$fd.Status])
$(HE $fd.Title)$(if ($fd.PSObject.Properties['Weight'] -and (Get-SeverityLabel $fd.Weight)) { ' ' + (HE ((T 'Schwere: ' 'Severity: ') + (Get-SeverityLabel $fd.Weight))) + '' })
$(HE $fd.Detail)
$fix
") } } [void]$sb.Append('
') } [void]$sb.Append("
") $enc = New-Object System.Text.UTF8Encoding $true [System.IO.File]::WriteAllText([System.IO.Path]::GetFullPath($Report), $sb.ToString(), $enc) Write-Host ((T 'HTML-Report: ' 'HTML report: ') + [System.IO.Path]::GetFullPath($Report)) -ForegroundColor Cyan if ($Open) { try { Invoke-Item -LiteralPath $Report } catch { } } } if ($Json) { $out = [ordered]@{ generator = "PHPCheck-LAN $ScriptVersion"; created = (Get-Date).ToString('o'); versionData = $VersionData.date; versionSource = $VersionSource results = @($results | ForEach-Object { [ordered]@{ target = $_.Target; url = $_.Url; finalUrl = $_.FinalUrl; reachable = $_.Reachable; error = $_.Error; score = $_.Score rating = (Get-Verdict $_)[1]; groups = $_.Groups; critical = $_.Critical; warnings = $_.Warnings; php = $_.Php; server = $_.Server; tls = $_.Tls; certUntil = $_.CertUntil findings = @($_.Findings | ForEach-Object { $wt = 0; if ($_.PSObject.Properties['Weight']) { $wt = $_.Weight }; [ordered]@{ category = $_.Cat; title = $_.Title; status = $_.Status; weight = $wt; detail = $_.Detail; fix = $_.Fix } }) } }) } $enc = New-Object System.Text.UTF8Encoding $false [System.IO.File]::WriteAllText([System.IO.Path]::GetFullPath($Json), ($out | ConvertTo-Json -Depth 8), $enc) Write-Host ((T 'JSON: ' 'JSON: ') + [System.IO.Path]::GetFullPath($Json)) -ForegroundColor Cyan } # Exit code for monitoring / scheduled tasks $code = 0 if (@($results | Where-Object { -not $_.Reachable }).Count -gt 0) { $code = 3 } elseif (@($results | Where-Object { $_.Critical -gt 0 }).Count -gt 0) { $code = 2 } elseif (@($results | Where-Object { $_.Warnings -gt 0 }).Count -gt 0) { $code = 1 } exit $code