Answer first visits to / and favicon with an instant WordPress lure
Unknown IPs get a small WordPress-looking page or icon and are not held; later requests are trapped as before. Switch: Flypaper__Drip__Lure. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2437880013
commit
4b946453fb
18 files changed
+360
-2
No files matched your search
@@ -0,0 +1,90 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Flypaper.Core.Strategies;
|
||||
|
||||
public static class LureContent
|
||||
{
|
||||
public const string PagePath = "/";
|
||||
|
||||
public const string IconPath = "/favicon.ico";
|
||||
|
||||
public static readonly IReadOnlyDictionary<string, string> Headers = new Dictionary<string, string>
|
||||
{
|
||||
["X-Powered-By"] = "PHP/8.1.27",
|
||||
["Link"] = "</wp-json/>; rel=\"https://api.w.org/\""
|
||||
};
|
||||
|
||||
public static bool Handles(string? path) =>
|
||||
string.Equals(path, PagePath, StringComparison.Ordinal) || string.Equals(path, IconPath, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static byte[] Page() => Encoding.UTF8.GetBytes("""
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="generator" content="WordPress 6.4.3">
|
||||
<title>Intranet – Just another WordPress site</title>
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="stylesheet" href="/wp-content/themes/twentytwentyfour/style.css?ver=1.0">
|
||||
<link rel="alternate" type="application/rss+xml" title="Intranet » Feed" href="/feed/">
|
||||
<link rel="https://api.w.org/" href="/wp-json/">
|
||||
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="/xmlrpc.php?rsd">
|
||||
</head>
|
||||
<body class="home blog">
|
||||
<header><h1>Intranet</h1><p>Just another WordPress site</p></header>
|
||||
<nav>
|
||||
<a href="/wp-login.php">Log in</a>
|
||||
<a href="/wp-admin/">Dashboard</a>
|
||||
<a href="/wp-content/uploads/backup/">Backups</a>
|
||||
<a href="/wp-config.php.bak">Config</a>
|
||||
</nav>
|
||||
<main><article><h2>Hello world!</h2><p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p></article></main>
|
||||
<footer><p>Proudly powered by <a href="https://wordpress.org/">WordPress</a></p></footer>
|
||||
</body>
|
||||
</html>
|
||||
""");
|
||||
|
||||
public static byte[] Icon()
|
||||
{
|
||||
const int size = 16;
|
||||
using var stream = new MemoryStream();
|
||||
using var writer = new BinaryWriter(stream);
|
||||
writer.Write((ushort)0);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((byte)size);
|
||||
writer.Write((byte)size);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((ushort)32);
|
||||
var imageSize = 40 + size * size * 4 + size * 4;
|
||||
writer.Write(imageSize);
|
||||
writer.Write(22);
|
||||
writer.Write(40);
|
||||
writer.Write(size);
|
||||
writer.Write(size * 2);
|
||||
writer.Write((ushort)1);
|
||||
writer.Write((ushort)32);
|
||||
writer.Write(0);
|
||||
writer.Write(size * size * 4);
|
||||
writer.Write(0);
|
||||
writer.Write(0);
|
||||
writer.Write(0);
|
||||
writer.Write(0);
|
||||
for (var y = 0; y < size; y++)
|
||||
{
|
||||
for (var x = 0; x < size; x++)
|
||||
{
|
||||
var dx = x - 7.5;
|
||||
var dy = y - 7.5;
|
||||
var inside = dx * dx + dy * dy <= 56;
|
||||
writer.Write(inside ? 0xFF8A5A21u : 0u);
|
||||
}
|
||||
}
|
||||
|
||||
writer.Write(new byte[size * 4]);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user