Files
Flypaper/README.md
T

134 lines
4.6 KiB
Markdown

# Flypaper
An HTTP tarpit for scanning bots. Instead of blocking the bots that probe your server for
`/.env`, `/.git/config` or `/wp-login.php`, Flypaper lets them in and answers with an endless
HTML page, a few bytes at a time. While a scanner waits, it isn't scanning someone else, and
the dashboard shows you who knocked: country, network provider and what they were after.
## How it works
```mermaid
flowchart LR
bot["Scanner bot"] -->|"GET /.env<br/>Host: 203.0.113.7"| proxy["Reverse proxy"]
proxy -->|"known site"| apps["Your apps"]
proxy -->|"unknown host<br/>+ X-Real-IP"| flypaper["Flypaper"]
flypaper -.->|"endless HTML,<br/>a few bytes at a time"| bot
flypaper --> db[("SQLite:<br/>catches, settings")]
you["You (LAN)"] -->|"dashboard, port 8081"| flypaper
```
- Your reverse proxy sends everything it has no site for (its catch-all server) to Flypaper's
trap port `8080`.
- Every request there gets `200 OK` and an endless page in random chunks with random pauses,
within limits per IP, overall and per catch.
- Each catch is logged and stored with its origin (DB-IP GeoIP); the dashboard on port `8081`
shows maps and tables.
- AI assistants such as Claude can query the catches over MCP: [docs/mcp.md](docs/mcp.md).
More: [how it works and all features](docs/overview.md).
## Quick start
```bash
docker run -d --name flypaper --restart unless-stopped \
-p 8080:8080 -p 127.0.0.1:8081:8081 \
-v flypaper-data:/data \
gitea.anticarnist.de/tom/flypaper:latest
```
Or with Compose:
```yaml
services:
flypaper:
image: gitea.anticarnist.de/tom/flypaper:latest
container_name: flypaper
restart: unless-stopped
ports:
- "8080:8080" # trap
- "127.0.0.1:8081:8081" # dashboard
volumes:
- flypaper-data:/data
volumes:
flypaper-data:
```
Port `8080` is the trap, port `8081` the dashboard (keep it in your LAN), and `/data` holds the
database, login keys and GeoIP files. Images exist for `linux/amd64` and `linux/arm64`. Open
<http://localhost:8081>: the first visit sets the admin password (changeable later on the
settings page). Try the trap with `curl -N http://localhost:8080/`.
On Unraid, use the template: [docs/unraid.md](docs/unraid.md).
## Connect your reverse proxy
Make Flypaper the target of your proxy's catch-all (default) server on port `8080`, so every
request for a host you don't serve lands in the trap. The proxy must set `X-Real-IP`; Flypaper
trusts proxies in private networks by default. Turn off response buffering so the drip reaches
the bot.
Plain nginx, with Flypaper on the same host:
```nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_read_timeout 1h;
}
}
```
Nginx Proxy Manager, Caddy and Traefik: [docs/reverse-proxy.md](docs/reverse-proxy.md).
## Configuration
Nothing is required. The most useful optional environment variables:
| Variable | Purpose |
|---|---|
| `Flypaper__Admin__Password` | Fixes the dashboard password instead of setting it on first visit |
| `Flypaper__Http__TrustedProxies__0` | Proxy IP or CIDR allowed to set `X-Real-IP` (default: private networks) |
| `TZ` | Time zone for the dashboard |
Limits and retention are changed on the dashboard's settings page. All variables
and settings: [docs/configuration.md](docs/configuration.md).
## Security
- Keep the dashboard port `8081` internal; never forward it from your public proxy.
- Set the admin password right after the first start: until then, anyone who reaches the
dashboard can set it.
- The limits protect your own bandwidth and sockets, keep them below what your proxy can
handle.
## Development
```bash
dotnet build # .NET 10 SDK
dotnet test
dotnet run --project src/Flypaper.Web # dashboard :5248 (password "dev"), trap :5247
```
Details and project layout: [docs/development.md](docs/development.md).
## Versions
Use `:latest` for the newest release or pin `:X.Y.Z`; changes are listed in
[CHANGELOG.md](CHANGELOG.md), tags and updates in [docs/releases.md](docs/releases.md). The
author's own Unraid deployment lives in [`deploy/unraid/`](deploy/unraid).
## Attribution and license
[IP Geolocation by DB-IP](https://db-ip.com) ([CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)),
world map from [Natural Earth](https://www.naturalearthdata.com) (public domain). Flypaper is
[MIT](LICENSE) licensed; third-party data keeps its own license.