Remove the unused content choice and the plain-text hold method
The link labyrinth held every catch that mattered, text-drip was never used. Flypaper__Drip__Content now only triggers the removed-settings warning. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b946453fb
commit
c5167262b9
21 files changed
+26
-187
No files matched your search
@@ -20,7 +20,6 @@ All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
|
|||||||
| `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` |
|
| `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` |
|
||||||
| `Flypaper__DataProtection__KeysPath` | Keys for login cookies and forms | `/data/keys` |
|
| `Flypaper__DataProtection__KeysPath` | Keys for login cookies and forms | `/data/keys` |
|
||||||
| `Flypaper__GeoIp__Directory` | Folder for the DB-IP databases; empty disables GeoIP | `/data/geoip` |
|
| `Flypaper__GeoIp__Directory` | Folder for the DB-IP databases; empty disables GeoIP | `/data/geoip` |
|
||||||
| `Flypaper__Drip__Content` | Hold method: `Html`, `Text` or `Alternating` | `Html` |
|
|
||||||
| `Flypaper__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` |
|
| `Flypaper__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` |
|
||||||
| `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` |
|
| `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` |
|
||||||
| `Flypaper__Drip__HeadStartSize` | Bytes sent immediately before dripping starts (`0` = off) | `1024` |
|
| `Flypaper__Drip__HeadStartSize` | Bytes sent immediately before dripping starts (`0` = off) | `1024` |
|
||||||
@@ -40,7 +39,6 @@ general reset button removes all saved values; the hold method section has its o
|
|||||||
|
|
||||||
| Setting | Default |
|
| Setting | Default |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Hold method: content (HTML filler text, random plain text, or alternating per catch) | HTML filler text |
|
|
||||||
| Hold method: pause between chunks, min and max (10 ms to 30 s) | 50 ms / 1000 ms |
|
| Hold method: pause between chunks, min and max (10 ms to 30 s) | 50 ms / 1000 ms |
|
||||||
| Hold method: chunk size, min and max (1 to 4096 bytes) | 1 / 64 bytes |
|
| Hold method: chunk size, min and max (1 to 4096 bytes) | 1 / 64 bytes |
|
||||||
| Hold method: head start, sent without delay before the drip (0 to 65536 bytes) | 1024 bytes |
|
| Hold method: head start, sent without delay before the drip (0 to 65536 bytes) | 1024 bytes |
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ flowchart LR
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Trap** for everything that reaches the trap port: whatever host or path a bot asks for
|
- **Trap** for everything that reaches the trap port: whatever host or path a bot asks for
|
||||||
- **Slow delivery** of endless generated HTML or plain text (or both, alternating per catch)
|
- **Slow delivery** of endless generated HTML (link labyrinth)
|
||||||
with irregular timing; content, pauses, chunk sizes and hold time are set in the dashboard
|
with irregular timing; content, pauses, chunk sizes and hold time are set in the dashboard
|
||||||
- **Limits**: maximum connections overall and per IP, maximum hold time per catch
|
- **Limits**: maximum connections overall and per IP, maximum hold time per catch
|
||||||
- **Dashboard**: totals, a world map, top countries, providers, IPs and paths, the latest
|
- **Dashboard**: totals, a world map, top countries, providers, IPs and paths, the latest
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public static class FlypaperCoreExtensions
|
|||||||
services.TryAddSingleton<IConnectionGovernor, ConnectionGovernor>();
|
services.TryAddSingleton<IConnectionGovernor, ConnectionGovernor>();
|
||||||
services.TryAddSingleton<IRandomSource, SystemRandomSource>();
|
services.TryAddSingleton<IRandomSource, SystemRandomSource>();
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITarpitStrategy, HtmlDripStrategy>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITarpitStrategy, HtmlDripStrategy>());
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITarpitStrategy, TextDripStrategy>());
|
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITarpitStrategy, RobotsStaticStrategy>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<ITarpitStrategy, RobotsStaticStrategy>());
|
||||||
services.AddSingleton<ITarpitStrategy>(_ => LureStrategy.Page());
|
services.AddSingleton<ITarpitStrategy>(_ => LureStrategy.Page());
|
||||||
services.AddSingleton<ITarpitStrategy>(_ => LureStrategy.Icon());
|
services.AddSingleton<ITarpitStrategy>(_ => LureStrategy.Icon());
|
||||||
|
|||||||
@@ -40,14 +40,7 @@ public sealed class ConfiguredStrategySelector(
|
|||||||
var maze = options.CurrentValue.LinkSpacing > 0
|
var maze = options.CurrentValue.LinkSpacing > 0
|
||||||
&& candidates.Any(strategy => strategy.Name == MazeDripStrategy.PageName);
|
&& candidates.Any(strategy => strategy.Name == MazeDripStrategy.PageName);
|
||||||
var page = maze ? MazeDripStrategy.PageName : HtmlDripStrategy.StrategyName;
|
var page = maze ? MazeDripStrategy.PageName : HtmlDripStrategy.StrategyName;
|
||||||
string[] wanted = options.CurrentValue.Content switch
|
var matching = candidates.Where(strategy => strategy.Name == page).ToList();
|
||||||
{
|
|
||||||
DripContent.Text => [TextDripStrategy.StrategyName],
|
|
||||||
DripContent.Alternating => [page, TextDripStrategy.StrategyName],
|
|
||||||
_ => [page]
|
|
||||||
};
|
|
||||||
|
|
||||||
var matching = candidates.Where(strategy => wanted.Contains(strategy.Name)).ToList();
|
|
||||||
var chosen = matching.Count == 0
|
var chosen = matching.Count == 0
|
||||||
? candidates.FirstOrDefault()
|
? candidates.FirstOrDefault()
|
||||||
: matching[random.Next(0, matching.Count)];
|
: matching[random.Next(0, matching.Count)];
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Flypaper.Core.Strategies;
|
|||||||
namespace Flypaper.Core.Settings;
|
namespace Flypaper.Core.Settings;
|
||||||
|
|
||||||
public sealed record HoldMethodSettings(
|
public sealed record HoldMethodSettings(
|
||||||
DripContent Content,
|
|
||||||
TimeSpan MinDelay,
|
TimeSpan MinDelay,
|
||||||
TimeSpan MaxDelay,
|
TimeSpan MaxDelay,
|
||||||
int MinChunkSize,
|
int MinChunkSize,
|
||||||
@@ -21,7 +20,6 @@ public sealed record HoldMethodSettings(
|
|||||||
|
|
||||||
public IReadOnlyDictionary<string, string> ToConfiguration() => new Dictionary<string, string>
|
public IReadOnlyDictionary<string, string> ToConfiguration() => new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
[SettingKeys.DripContent] = Content.ToString(),
|
|
||||||
[SettingKeys.DripMinDelay] = MinDelay.ToString("c", CultureInfo.InvariantCulture),
|
[SettingKeys.DripMinDelay] = MinDelay.ToString("c", CultureInfo.InvariantCulture),
|
||||||
[SettingKeys.DripMaxDelay] = MaxDelay.ToString("c", CultureInfo.InvariantCulture),
|
[SettingKeys.DripMaxDelay] = MaxDelay.ToString("c", CultureInfo.InvariantCulture),
|
||||||
[SettingKeys.DripMinChunkSize] = MinChunkSize.ToString(CultureInfo.InvariantCulture),
|
[SettingKeys.DripMinChunkSize] = MinChunkSize.ToString(CultureInfo.InvariantCulture),
|
||||||
@@ -43,7 +41,6 @@ public sealed record HoldMethodSettings(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public sealed record HoldMethodInput(
|
public sealed record HoldMethodInput(
|
||||||
string? Content,
|
|
||||||
string? MinDelayMs,
|
string? MinDelayMs,
|
||||||
string? MaxDelayMs,
|
string? MaxDelayMs,
|
||||||
string? MinChunkSize,
|
string? MinChunkSize,
|
||||||
|
|||||||
@@ -48,14 +48,6 @@ public static class RuntimeSettingsParser
|
|||||||
{
|
{
|
||||||
var errors = new Dictionary<string, string>();
|
var errors = new Dictionary<string, string>();
|
||||||
|
|
||||||
DripContent? content = Enum.TryParse<DripContent>(input.Content, ignoreCase: true, out var parsed) && Enum.IsDefined(parsed)
|
|
||||||
? parsed
|
|
||||||
: null;
|
|
||||||
if (content is null)
|
|
||||||
{
|
|
||||||
errors[nameof(input.Content)] = "Bitte eine Methode wählen.";
|
|
||||||
}
|
|
||||||
|
|
||||||
var minDelay = ParseInt(input.MinDelayMs, nameof(input.MinDelayMs), MinDelayMs, MaxDelayMs, errors);
|
var minDelay = ParseInt(input.MinDelayMs, nameof(input.MinDelayMs), MinDelayMs, MaxDelayMs, errors);
|
||||||
var maxDelay = ParseInt(input.MaxDelayMs, nameof(input.MaxDelayMs), MinDelayMs, MaxDelayMs, errors);
|
var maxDelay = ParseInt(input.MaxDelayMs, nameof(input.MaxDelayMs), MinDelayMs, MaxDelayMs, errors);
|
||||||
var minChunk = ParseInt(input.MinChunkSize, nameof(input.MinChunkSize), 1, MaxChunkSize, errors);
|
var minChunk = ParseInt(input.MinChunkSize, nameof(input.MinChunkSize), 1, MaxChunkSize, errors);
|
||||||
@@ -84,7 +76,6 @@ public static class RuntimeSettingsParser
|
|||||||
|
|
||||||
return new HoldMethodParseResult(
|
return new HoldMethodParseResult(
|
||||||
new HoldMethodSettings(
|
new HoldMethodSettings(
|
||||||
content!.Value,
|
|
||||||
TimeSpan.FromMilliseconds(minDelay!.Value),
|
TimeSpan.FromMilliseconds(minDelay!.Value),
|
||||||
TimeSpan.FromMilliseconds(maxDelay!.Value),
|
TimeSpan.FromMilliseconds(maxDelay!.Value),
|
||||||
minChunk!.Value,
|
minChunk!.Value,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ public static class SettingKeys
|
|||||||
public const string RepeatHoldDuration = "Flypaper:RepeatHoldDuration";
|
public const string RepeatHoldDuration = "Flypaper:RepeatHoldDuration";
|
||||||
public const string IgnorePrivateNetworks = "Flypaper:IgnorePrivateNetworks";
|
public const string IgnorePrivateNetworks = "Flypaper:IgnorePrivateNetworks";
|
||||||
public const string RetentionDays = "Flypaper:Retention:Days";
|
public const string RetentionDays = "Flypaper:Retention:Days";
|
||||||
public const string DripContent = "Flypaper:Drip:Content";
|
|
||||||
public const string DripMinDelay = "Flypaper:Drip:MinDelay";
|
public const string DripMinDelay = "Flypaper:Drip:MinDelay";
|
||||||
public const string DripMaxDelay = "Flypaper:Drip:MaxDelay";
|
public const string DripMaxDelay = "Flypaper:Drip:MaxDelay";
|
||||||
public const string DripMinChunkSize = "Flypaper:Drip:MinChunkSize";
|
public const string DripMinChunkSize = "Flypaper:Drip:MinChunkSize";
|
||||||
@@ -23,7 +22,7 @@ public static class SettingKeys
|
|||||||
[MaxConnections, MaxConnectionsPerIp, IgnorePrivateNetworks, RetentionDays];
|
[MaxConnections, MaxConnectionsPerIp, IgnorePrivateNetworks, RetentionDays];
|
||||||
|
|
||||||
public static readonly IReadOnlyList<string> HoldMethod =
|
public static readonly IReadOnlyList<string> HoldMethod =
|
||||||
[DripContent, DripMinDelay, DripMaxDelay, DripMinChunkSize, DripMaxChunkSize, DripHeadStartSize, DripMatchPath, DripLinkSpacing, DripBaitPaths, MaxHoldDuration, RepeatWindowDays, RepeatHoldDuration];
|
[DripMinDelay, DripMaxDelay, DripMinChunkSize, DripMaxChunkSize, DripHeadStartSize, DripMatchPath, DripLinkSpacing, DripBaitPaths, MaxHoldDuration, RepeatWindowDays, RepeatHoldDuration];
|
||||||
|
|
||||||
public static readonly IReadOnlySet<string> All =
|
public static readonly IReadOnlySet<string> All =
|
||||||
new HashSet<string>(General.Concat(HoldMethod), StringComparer.OrdinalIgnoreCase);
|
new HashSet<string>(General.Concat(HoldMethod), StringComparer.OrdinalIgnoreCase);
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace Flypaper.Core.Strategies;
|
|
||||||
|
|
||||||
public enum DripContent
|
|
||||||
{
|
|
||||||
Html,
|
|
||||||
Text,
|
|
||||||
Alternating
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,6 @@ public sealed class DripOptions
|
|||||||
{
|
{
|
||||||
public const string SectionName = "Flypaper:Drip";
|
public const string SectionName = "Flypaper:Drip";
|
||||||
|
|
||||||
public DripContent Content { get; set; } = DripContent.Html;
|
|
||||||
|
|
||||||
public TimeSpan MinDelay { get; set; } = TimeSpan.FromMilliseconds(50);
|
public TimeSpan MinDelay { get; set; } = TimeSpan.FromMilliseconds(50);
|
||||||
|
|
||||||
public TimeSpan MaxDelay { get; set; } = TimeSpan.FromSeconds(1);
|
public TimeSpan MaxDelay { get; set; } = TimeSpan.FromSeconds(1);
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
using Flypaper.Core.Abstractions;
|
|
||||||
|
|
||||||
namespace Flypaper.Core.Strategies;
|
|
||||||
|
|
||||||
public static class TextContent
|
|
||||||
{
|
|
||||||
public static IEnumerable<string> Generate(IRandomSource random)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var builder = new StringBuilder();
|
|
||||||
var sentences = random.Next(1, 7);
|
|
||||||
for (var i = 0; i < sentences; i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
builder.Append(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Append(LoremText.Sentence(random));
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return builder.Append(random.Next(0, 4) == 0 ? "\n\n" : "\n").ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using Flypaper.Core.Abstractions;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace Flypaper.Core.Strategies;
|
|
||||||
|
|
||||||
public sealed class TextDripStrategy(
|
|
||||||
IOptionsMonitor<DripOptions> options,
|
|
||||||
IRandomSource random,
|
|
||||||
TimeProvider timeProvider) : DripStrategy(options, random, timeProvider)
|
|
||||||
{
|
|
||||||
public const string StrategyName = "text-drip";
|
|
||||||
|
|
||||||
public override string Name => StrategyName;
|
|
||||||
|
|
||||||
public override string MediaType => "text/plain; charset=utf-8";
|
|
||||||
|
|
||||||
protected override IEnumerable<string> Content(IRandomSource random, ITrapChannel channel, DripOptions options) => TextContent.Generate(random);
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,8 @@ public static class FlypaperHttpExtensions
|
|||||||
"Flypaper:Http:KnownHosts",
|
"Flypaper:Http:KnownHosts",
|
||||||
"Flypaper:Http:TrapPaths",
|
"Flypaper:Http:TrapPaths",
|
||||||
"Flypaper:Http:ExtraKnownHosts",
|
"Flypaper:Http:ExtraKnownHosts",
|
||||||
"Flypaper:Http:TrapPathsOverride"
|
"Flypaper:Http:TrapPathsOverride",
|
||||||
|
"Flypaper:Drip:Content"
|
||||||
];
|
];
|
||||||
|
|
||||||
public static IServiceCollection AddFlypaperHttp(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddFlypaperHttp(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ namespace Flypaper.Web.Components.Pages.Settings;
|
|||||||
|
|
||||||
public sealed class HoldMethodModel
|
public sealed class HoldMethodModel
|
||||||
{
|
{
|
||||||
public string? Content { get; set; }
|
|
||||||
|
|
||||||
public string? MinDelayMs { get; set; }
|
public string? MinDelayMs { get; set; }
|
||||||
|
|
||||||
public string? MaxDelayMs { get; set; }
|
public string? MaxDelayMs { get; set; }
|
||||||
|
|||||||
@@ -21,28 +21,6 @@
|
|||||||
|
|
||||||
<EditForm Model="Model" FormName="hold-method" OnSubmit="SaveAsync" action="/settings#hold-method" id="hold-method-form">
|
<EditForm Model="Model" FormName="hold-method" OnSubmit="SaveAsync" action="/settings#hold-method" id="hold-method-form">
|
||||||
<div class="s-body">
|
<div class="s-body">
|
||||||
<fieldset class="choices">
|
|
||||||
<legend>Inhalt</legend>
|
|
||||||
<InputRadioGroup @bind-Value="Model!.Content">
|
|
||||||
<div class="choice-grid">
|
|
||||||
@foreach (var choice in Choices)
|
|
||||||
{
|
|
||||||
<label class="choice">
|
|
||||||
<InputRadio Value="@choice.Value" />
|
|
||||||
<span class="choice-body">
|
|
||||||
<strong>@choice.Title</strong>
|
|
||||||
<span>@choice.Text</span>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</InputRadioGroup>
|
|
||||||
@if (_errors.TryGetValue(nameof(HoldMethodModel.Content), out var contentError))
|
|
||||||
{
|
|
||||||
<p class="field-error">@contentError</p>
|
|
||||||
}
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
<SettingsField Label="Pause min." For="drip-min-delay" Unit="ms" Hint="10 bis 30000" Errors="_errors" Key="@nameof(HoldMethodModel.MinDelayMs)">
|
<SettingsField Label="Pause min." For="drip-min-delay" Unit="ms" Hint="10 bis 30000" Errors="_errors" Key="@nameof(HoldMethodModel.MinDelayMs)">
|
||||||
<InputText id="drip-min-delay" @bind-Value="Model!.MinDelayMs" inputmode="numeric" data-bandwidth-input />
|
<InputText id="drip-min-delay" @bind-Value="Model!.MinDelayMs" inputmode="numeric" data-bandwidth-input />
|
||||||
@@ -105,13 +83,6 @@
|
|||||||
<script src="@Assets["settings.js"]" defer></script>
|
<script src="@Assets["settings.js"]" defer></script>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private static readonly (string Value, string Title, string Text)[] Choices =
|
|
||||||
[
|
|
||||||
(nameof(DripContent.Html), "HTML-Fülltext", "Eine endlose Webseite mit Überschriften, Absätzen und vielen Links, die wieder in die Falle führen (Link-Labyrinth). Wirkt auf Crawler am echtesten."),
|
|
||||||
(nameof(DripContent.Text), "Zufallstext", "Schlichter Text ohne Markup, ausgeliefert als text/plain."),
|
|
||||||
(nameof(DripContent.Alternating), "Wechselnd", "Pro Fang zufällig eine der beiden. Gut, um zu vergleichen, was Bots länger hält.")
|
|
||||||
];
|
|
||||||
|
|
||||||
private readonly object _resetModel = new();
|
private readonly object _resetModel = new();
|
||||||
private IReadOnlyDictionary<string, string> _errors = new Dictionary<string, string>();
|
private IReadOnlyDictionary<string, string> _errors = new Dictionary<string, string>();
|
||||||
private bool _hasOverrides;
|
private bool _hasOverrides;
|
||||||
@@ -146,8 +117,7 @@
|
|||||||
private async Task SaveAsync()
|
private async Task SaveAsync()
|
||||||
{
|
{
|
||||||
var result = RuntimeSettingsParser.ParseHoldMethod(new HoldMethodInput(
|
var result = RuntimeSettingsParser.ParseHoldMethod(new HoldMethodInput(
|
||||||
Model!.Content,
|
Model!.MinDelayMs,
|
||||||
Model.MinDelayMs,
|
|
||||||
Model.MaxDelayMs,
|
Model.MaxDelayMs,
|
||||||
Model.MinChunkSize,
|
Model.MinChunkSize,
|
||||||
Model.MaxChunkSize,
|
Model.MaxChunkSize,
|
||||||
@@ -180,7 +150,6 @@
|
|||||||
var drip = Drip.CurrentValue;
|
var drip = Drip.CurrentValue;
|
||||||
return new HoldMethodModel
|
return new HoldMethodModel
|
||||||
{
|
{
|
||||||
Content = drip.Content.ToString(),
|
|
||||||
MinDelayMs = ((int)drip.MinDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture),
|
MinDelayMs = ((int)drip.MinDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture),
|
||||||
MaxDelayMs = ((int)drip.MaxDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture),
|
MaxDelayMs = ((int)drip.MaxDelay.TotalMilliseconds).ToString(CultureInfo.InvariantCulture),
|
||||||
MinChunkSize = drip.MinChunkSize.ToString(CultureInfo.InvariantCulture),
|
MinChunkSize = drip.MinChunkSize.ToString(CultureInfo.InvariantCulture),
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public static partial class StrategyNames
|
|||||||
["maze-drip"] = ("Link-Labyrinth", "Eine Webseite voller Links, die immer zu neuen, erfundenen Seiten führen. Der Bot folgt ihnen und verirrt sich, während alles nur tröpfchenweise ankommt."),
|
["maze-drip"] = ("Link-Labyrinth", "Eine Webseite voller Links, die immer zu neuen, erfundenen Seiten führen. Der Bot folgt ihnen und verirrt sich, während alles nur tröpfchenweise ankommt."),
|
||||||
["index-drip"] = ("Gefälschtes Ordner-Listing", "Eine Dateiliste im Stil von „Index of /…“ mit erfundenen Ordnern und Dateien. Wer weiterklickt, landet im Link-Labyrinth."),
|
["index-drip"] = ("Gefälschtes Ordner-Listing", "Eine Dateiliste im Stil von „Index of /…“ mit erfundenen Ordnern und Dateien. Wer weiterklickt, landet im Link-Labyrinth."),
|
||||||
["html-drip"] = ("Endlose Webseite", "Eine gewöhnlich aussehende Webseite, die nie aufhört und nur Stück für Stück geliefert wird. Der Bot wartet auf das Ende, das nie kommt."),
|
["html-drip"] = ("Endlose Webseite", "Eine gewöhnlich aussehende Webseite, die nie aufhört und nur Stück für Stück geliefert wird. Der Bot wartet auf das Ende, das nie kommt."),
|
||||||
["text-drip"] = ("Endloser Text", "Unendlicher Fließtext ohne Formatierung, der nur tröpfchenweise ankommt. Der Bot wartet auf das Ende, das nie kommt."),
|
|
||||||
["env-drip"] = ("Gefälschte Zugangsdaten (.env)", "Eine erfundene .env-Datei mit Passwörtern und Schlüsseln, die nie endet. Bots, die nach geleakten Zugangsdaten suchen, lesen sie bis zum Ende."),
|
["env-drip"] = ("Gefälschte Zugangsdaten (.env)", "Eine erfundene .env-Datei mit Passwörtern und Schlüsseln, die nie endet. Bots, die nach geleakten Zugangsdaten suchen, lesen sie bis zum Ende."),
|
||||||
["git-drip"] = ("Gefälschtes Git-Projekt", "Eine erfundene Git-Konfiguration, die wie die echte beginnt und nie endet. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
["git-drip"] = ("Gefälschtes Git-Projekt", "Eine erfundene Git-Konfiguration, die wie die echte beginnt und nie endet. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
||||||
["svn-drip"] = ("Gefälschtes Subversion-Projekt", "Erfundene Dateien aus einem .svn-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
["svn-drip"] = ("Gefälschtes Subversion-Projekt", "Erfundene Dateien aus einem .svn-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ public sealed class FileContentTests
|
|||||||
new HtmlDripStrategy(options, random, TimeProvider.System),
|
new HtmlDripStrategy(options, random, TimeProvider.System),
|
||||||
new MazeDripStrategy(MazeKind.Page, options, random, TimeProvider.System),
|
new MazeDripStrategy(MazeKind.Page, options, random, TimeProvider.System),
|
||||||
new MazeDripStrategy(MazeKind.Listing, options, random, TimeProvider.System),
|
new MazeDripStrategy(MazeKind.Listing, options, random, TimeProvider.System),
|
||||||
new TextDripStrategy(options, random, TimeProvider.System),
|
|
||||||
new RobotsStaticStrategy(options),
|
new RobotsStaticStrategy(options),
|
||||||
new MazeDripStrategy(MazeKind.Bait, options, random, TimeProvider.System),
|
new MazeDripStrategy(MazeKind.Bait, options, random, TimeProvider.System),
|
||||||
.. FileContent.Profiles.Select(profile => new FileDripStrategy(profile, options, random, TimeProvider.System))
|
.. FileContent.Profiles.Select(profile => new FileDripStrategy(profile, options, random, TimeProvider.System))
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ namespace Flypaper.Tests.Core;
|
|||||||
|
|
||||||
public sealed class HoldMethodParserTests
|
public sealed class HoldMethodParserTests
|
||||||
{
|
{
|
||||||
private static readonly HoldMethodInput Valid = new("Alternating", "50", "1000", "1", "64", "2048", true, "80", "/Backup-2024, /admin-old/x", "01:00:00", "7", "1.00:00:00");
|
private static readonly HoldMethodInput Valid = new("50", "1000", "1", "64", "2048", true, "80", "/Backup-2024, /admin-old/x", "01:00:00", "7", "1.00:00:00");
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Parses_valid_input()
|
public void Parses_valid_input()
|
||||||
{
|
{
|
||||||
var settings = RuntimeSettingsParser.ParseHoldMethod(Valid).Settings.ShouldNotBeNull();
|
var settings = RuntimeSettingsParser.ParseHoldMethod(Valid).Settings.ShouldNotBeNull();
|
||||||
|
|
||||||
settings.Content.ShouldBe(DripContent.Alternating);
|
|
||||||
settings.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50));
|
settings.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50));
|
||||||
settings.MaxDelay.ShouldBe(TimeSpan.FromSeconds(1));
|
settings.MaxDelay.ShouldBe(TimeSpan.FromSeconds(1));
|
||||||
settings.MinChunkSize.ShouldBe(1);
|
settings.MinChunkSize.ShouldBe(1);
|
||||||
@@ -26,19 +25,6 @@ public sealed class HoldMethodParserTests
|
|||||||
settings.ToConfiguration().Keys.ShouldBe(SettingKeys.HoldMethod, ignoreOrder: true);
|
settings.ToConfiguration().Keys.ShouldBe(SettingKeys.HoldMethod, ignoreOrder: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData("html", DripContent.Html)]
|
|
||||||
[InlineData("Text", DripContent.Text)]
|
|
||||||
public void Accepts_content_case_insensitively(string value, DripContent expected) =>
|
|
||||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { Content = value }).Settings.ShouldNotBeNull().Content.ShouldBe(expected);
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData("")]
|
|
||||||
[InlineData("fake-env")]
|
|
||||||
[InlineData("7")]
|
|
||||||
public void Rejects_unknown_content(string value) =>
|
|
||||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { Content = value }).Errors.Keys.ShouldBe([nameof(HoldMethodInput.Content)]);
|
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("9", "1000")]
|
[InlineData("9", "1000")]
|
||||||
[InlineData("50", "30001")]
|
[InlineData("50", "30001")]
|
||||||
|
|||||||
@@ -14,65 +14,34 @@ public sealed class StrategySelectionTests
|
|||||||
private static readonly TrapContext Http =
|
private static readonly TrapContext Http =
|
||||||
new(new TrapSession(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("203.0.113.9"), DateTimeOffset.UtcNow));
|
new(new TrapSession(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("203.0.113.9"), DateTimeOffset.UtcNow));
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData(DripContent.Html, "html-drip")]
|
|
||||||
[InlineData(DripContent.Text, "text-drip")]
|
|
||||||
public void Selects_the_configured_content(DripContent content, string expected) =>
|
|
||||||
Selector(content).Select(Http).ShouldNotBeNull().Name.ShouldBe(expected);
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Alternating_picks_both_strategies()
|
public void Selects_the_html_page() =>
|
||||||
{
|
Selector().Select(Http).ShouldNotBeNull().Name.ShouldBe("html-drip");
|
||||||
var selector = Selector(DripContent.Alternating);
|
|
||||||
|
|
||||||
var names = Enumerable.Range(0, 50).Select(_ => selector.Select(Http)!.Name).Distinct().ToList();
|
|
||||||
|
|
||||||
names.ShouldBe(["html-drip", "text-drip"], ignoreOrder: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Returns_nothing_for_unsupported_protocols()
|
public void Returns_nothing_for_unsupported_protocols()
|
||||||
{
|
{
|
||||||
var ssh = Http with { Session = Http.Session with { Protocol = TrapProtocol.Ssh } };
|
var ssh = Http with { Session = Http.Session with { Protocol = TrapProtocol.Ssh } };
|
||||||
|
|
||||||
Selector(DripContent.Html).Select(ssh).ShouldBeNull();
|
Selector().Select(ssh).ShouldBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Strategies_describe_themselves_with_their_parameters()
|
public void Strategies_describe_themselves_with_their_parameters()
|
||||||
{
|
{
|
||||||
var options = TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(100), MaxDelay = TimeSpan.FromMilliseconds(250), MinChunkSize = 2, MaxChunkSize = 8 });
|
var options = TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(100), MaxDelay = TimeSpan.FromMilliseconds(250), MinChunkSize = 2, MaxChunkSize = 8 });
|
||||||
var text = new TextDripStrategy(options, new SeededRandomSource(1), TimeProvider.System);
|
var html = new HtmlDripStrategy(options, new SeededRandomSource(1), TimeProvider.System);
|
||||||
|
|
||||||
text.Describe().ShouldBe("text-drip 100-250ms 2-8B head 1024B");
|
html.Describe().ShouldBe("html-drip 100-250ms 2-8B head 1024B");
|
||||||
text.MediaType.ShouldStartWith("text/plain");
|
html.MediaType.ShouldStartWith("text/html");
|
||||||
new HtmlDripStrategy(options, new SeededRandomSource(1), TimeProvider.System).MediaType.ShouldStartWith("text/html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
private static ConfiguredStrategySelector Selector()
|
||||||
public async Task Text_strategy_drips_plain_text()
|
|
||||||
{
|
{
|
||||||
var strategy = new TextDripStrategy(
|
var options = TestOptions.Monitor(new DripOptions());
|
||||||
TestOptions.Monitor(new DripOptions { MinDelay = TimeSpan.FromMilliseconds(1), MaxDelay = TimeSpan.FromMilliseconds(2), MinChunkSize = 32, MaxChunkSize = 64 }),
|
|
||||||
new SeededRandomSource(3),
|
|
||||||
TimeProvider.System);
|
|
||||||
var channel = new FakeTrapChannel();
|
|
||||||
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(200));
|
|
||||||
|
|
||||||
await Should.ThrowAsync<OperationCanceledException>(() => strategy.RunAsync(channel, cts.Token));
|
|
||||||
|
|
||||||
var text = Encoding.UTF8.GetString(channel.Writes.SelectMany(w => w).ToArray());
|
|
||||||
text.Length.ShouldBeGreaterThan(200);
|
|
||||||
text.ShouldNotContain("<");
|
|
||||||
text.ShouldContain("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ConfiguredStrategySelector Selector(DripContent content)
|
|
||||||
{
|
|
||||||
var options = TestOptions.Monitor(new DripOptions { Content = content });
|
|
||||||
var random = new SeededRandomSource(11);
|
var random = new SeededRandomSource(11);
|
||||||
return new ConfiguredStrategySelector(
|
return new ConfiguredStrategySelector(
|
||||||
[new HtmlDripStrategy(options, random, TimeProvider.System), new TextDripStrategy(options, random, TimeProvider.System)],
|
[new HtmlDripStrategy(options, random, TimeProvider.System)],
|
||||||
options,
|
options,
|
||||||
random);
|
random);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,18 @@ namespace Flypaper.Tests.Http;
|
|||||||
public sealed class ContentTypeTests
|
public sealed class ContentTypeTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Html", "/", "text/html; charset=utf-8")]
|
[InlineData("/", "text/html; charset=utf-8")]
|
||||||
[InlineData("Text", "/", "text/plain; charset=utf-8")]
|
[InlineData("/config.json", "application/json")]
|
||||||
[InlineData("Html", "/config.json", "application/json")]
|
[InlineData("/.env", "text/plain; charset=utf-8")]
|
||||||
[InlineData("Html", "/.env", "text/plain; charset=utf-8")]
|
[InlineData("/sitemap.xml", "application/xml")]
|
||||||
[InlineData("Html", "/sitemap.xml", "application/xml")]
|
[InlineData("/SDK/webLanguage", "application/xml")]
|
||||||
[InlineData("Html", "/SDK/webLanguage", "application/xml")]
|
[InlineData("/wp-login.php", "text/html; charset=UTF-8")]
|
||||||
[InlineData("Html", "/wp-login.php", "text/html; charset=UTF-8")]
|
public async Task Trap_answers_with_the_media_type_of_the_selected_strategy(string path, string expected)
|
||||||
public async Task Trap_answers_with_the_media_type_of_the_selected_strategy(string content, string path, string expected)
|
|
||||||
{
|
{
|
||||||
var configuration = new ConfigurationBuilder()
|
var configuration = new ConfigurationBuilder()
|
||||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||||
{
|
{
|
||||||
["Flypaper:MaxHoldDuration"] = "00:00:00.100",
|
["Flypaper:MaxHoldDuration"] = "00:00:00.100",
|
||||||
["Flypaper:Drip:Content"] = content,
|
|
||||||
["Flypaper:Drip:MinDelay"] = "00:00:00.005",
|
["Flypaper:Drip:MinDelay"] = "00:00:00.005",
|
||||||
["Flypaper:Drip:MaxDelay"] = "00:00:00.010"
|
["Flypaper:Drip:MaxDelay"] = "00:00:00.010"
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -89,10 +89,9 @@ public sealed class SettingsOverrideTests : IDisposable
|
|||||||
var store = host.Services.GetRequiredService<RuntimeSettingsStore>();
|
var store = host.Services.GetRequiredService<RuntimeSettingsStore>();
|
||||||
string[] holdKeys = [.. SettingKeys.HoldMethod];
|
string[] holdKeys = [.. SettingKeys.HoldMethod];
|
||||||
|
|
||||||
await store.SaveAsync(new HoldMethodSettings(DripContent.Text, TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "/trap-a/", TimeSpan.FromMinutes(5), 7, TimeSpan.FromHours(24)));
|
await store.SaveAsync(new HoldMethodSettings(TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "/trap-a/", TimeSpan.FromMinutes(5), 7, TimeSpan.FromHours(24)));
|
||||||
await store.SaveAsync(new RuntimeSettings(50, 4, 90, true));
|
await store.SaveAsync(new RuntimeSettings(50, 4, 90, true));
|
||||||
|
|
||||||
drip.CurrentValue.Content.ShouldBe(DripContent.Text);
|
|
||||||
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(200));
|
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(200));
|
||||||
drip.CurrentValue.MaxChunkSize.ShouldBe(16);
|
drip.CurrentValue.MaxChunkSize.ShouldBe(16);
|
||||||
drip.CurrentValue.HeadStartSize.ShouldBe(256);
|
drip.CurrentValue.HeadStartSize.ShouldBe(256);
|
||||||
@@ -103,13 +102,12 @@ public sealed class SettingsOverrideTests : IDisposable
|
|||||||
core.CurrentValue.MaxConnections.ShouldBe(50);
|
core.CurrentValue.MaxConnections.ShouldBe(50);
|
||||||
(await store.HasOverridesAsync(holdKeys)).ShouldBeTrue();
|
(await store.HasOverridesAsync(holdKeys)).ShouldBeTrue();
|
||||||
|
|
||||||
await store.SaveAsync(new HoldMethodSettings(DripContent.Text, TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "", TimeSpan.FromMinutes(5), 0, TimeSpan.FromHours(2)));
|
await store.SaveAsync(new HoldMethodSettings(TimeSpan.FromMilliseconds(200), TimeSpan.FromSeconds(2), 8, 16, 256, false, 0, "", TimeSpan.FromMinutes(5), 0, TimeSpan.FromHours(2)));
|
||||||
drip.CurrentValue.BaitPaths.ShouldBe("");
|
drip.CurrentValue.BaitPaths.ShouldBe("");
|
||||||
|
|
||||||
await store.ResetAsync(holdKeys);
|
await store.ResetAsync(holdKeys);
|
||||||
drip.CurrentValue.BaitPaths.ShouldBe(BaitPaths.Default);
|
drip.CurrentValue.BaitPaths.ShouldBe(BaitPaths.Default);
|
||||||
|
|
||||||
drip.CurrentValue.Content.ShouldBe(DripContent.Html);
|
|
||||||
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50));
|
drip.CurrentValue.MinDelay.ShouldBe(TimeSpan.FromMilliseconds(50));
|
||||||
core.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromHours(1));
|
core.CurrentValue.MaxHoldDuration.ShouldBe(TimeSpan.FromHours(1));
|
||||||
core.CurrentValue.MaxConnections.ShouldBe(50);
|
core.CurrentValue.MaxConnections.ShouldBe(50);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public sealed class StrategyNamesTests
|
|||||||
string[] names =
|
string[] names =
|
||||||
[
|
[
|
||||||
MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName,
|
MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName,
|
||||||
HtmlDripStrategy.StrategyName, TextDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName,
|
HtmlDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName,
|
||||||
LureStrategy.PageName, LureStrategy.IconName,
|
LureStrategy.PageName, LureStrategy.IconName,
|
||||||
.. FileContent.Profiles.Select(profile => profile.Name)
|
.. FileContent.Profiles.Select(profile => profile.Name)
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in new issue
Block a user