Compare commits
7
Commits
7c3657d015
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8328f6998 | ||
|
|
2a639a6b59 | ||
|
|
552abffd29 | ||
|
|
31cef44bf3 | ||
|
|
6e2ff3f7ee | ||
|
|
4168e9990b | ||
|
|
0984af25bc |
No files matched your search
@@ -7,3 +7,5 @@
|
||||
.idea/
|
||||
test/
|
||||
.gitea/
|
||||
unraid/
|
||||
deploy/
|
||||
@@ -59,10 +59,13 @@ jobs:
|
||||
id: sha
|
||||
run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# amd64 only: these builds exist for the Unraid deploy (x86_64), and a
|
||||
# single platform keeps every push fast. Releases are multi-arch.
|
||||
- name: Build and push (:main and :<sha>)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
build-args: |
|
||||
VERSION=0.0.0-dev+${{ steps.sha.outputs.short }}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Builds a release when a version tag (vX.Y.Z) is pushed: the image is tagged
|
||||
# :X.Y.Z, :X.Y, :X and :latest in the Gitea registry, and a Gitea release is
|
||||
# created with the matching section of CHANGELOG.md as notes. Nothing is
|
||||
# deployed; Tom's Unraid follows :main through deploy.yml.
|
||||
# Builds a release when a version tag (vX.Y.Z) is pushed: a multi-arch image
|
||||
# (linux/amd64, linux/arm64) is tagged :X.Y.Z, :X.Y, :X and :latest in the Gitea
|
||||
# registry, and a Gitea release is created with the matching section of
|
||||
# CHANGELOG.md as notes. Nothing is deployed; Tom's Unraid follows :main through
|
||||
# deploy.yml.
|
||||
#
|
||||
# A pre-release tag such as v0.2.0-rc.1 only gets its own :0.2.0-rc.1 tag and a
|
||||
# release marked as pre-release; :latest and the short tags stay on the last
|
||||
@@ -66,10 +67,14 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
# No QEMU: the Dockerfile compiles natively on the runner and cross-publishes
|
||||
# for each architecture; the arm64 runtime stage only copies files. Setting
|
||||
# up QEMU would also register binfmt handlers on the Unraid host kernel.
|
||||
- name: Build and push the release tags
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: |
|
||||
VERSION=${{ steps.version.outputs.version }}
|
||||
|
||||
+21
-1
@@ -6,6 +6,22 @@ All notable changes to Flypaper are documented in this file. The format follows
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.1] - 2026-11-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- Small countries without an outline on the world map (e.g. Hong Kong, Singapore, Macau,
|
||||
Bahrain, Malta) are now shown as markers with the same colour scale and tooltip.
|
||||
- The latest catches table no longer overflows its card; numbers always stay visible.
|
||||
- Requests without a `Host` header show "(ohne Host)" instead of `_`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Common short country names on the map and in the tables, e.g. "Taiwan" instead of
|
||||
"Republik China", "Hongkong", "USA".
|
||||
- Larger hover area for map markers.
|
||||
- Shorter README; reverse proxy, Unraid, configuration and release details moved to `docs/`.
|
||||
|
||||
## [0.1.0] - 2026-11-14
|
||||
|
||||
First release.
|
||||
@@ -28,6 +44,10 @@ First release.
|
||||
with `Flypaper__Admin__Password`.
|
||||
- Daily retention cleanup (90 days by default), `/health` endpoint, Docker image running as
|
||||
non-root with all data under `/data`.
|
||||
- Public images for `linux/amd64` and `linux/arm64` in the Gitea registry.
|
||||
- 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.1.0...main
|
||||
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.1.1...main
|
||||
[0.1.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.1
|
||||
[0.1.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.0
|
||||
+17
-5
@@ -1,4 +1,8 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
# The SDK stage runs natively on the build machine and cross-publishes for the
|
||||
# target architecture. The runtime stage only copies files and sets metadata, so a
|
||||
# multi-arch build needs no QEMU emulation at all.
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
ARG TARGETARCH
|
||||
WORKDIR /src
|
||||
|
||||
COPY Directory.Build.props Directory.Packages.props ./
|
||||
@@ -7,26 +11,34 @@ COPY src/Flypaper.GeoIp/Flypaper.GeoIp.csproj src/Flypaper.GeoIp/
|
||||
COPY src/Flypaper.Http/Flypaper.Http.csproj src/Flypaper.Http/
|
||||
COPY src/Flypaper.Storage/Flypaper.Storage.csproj src/Flypaper.Storage/
|
||||
COPY src/Flypaper.Web/Flypaper.Web.csproj src/Flypaper.Web/
|
||||
RUN dotnet restore src/Flypaper.Web/Flypaper.Web.csproj
|
||||
RUN dotnet restore src/Flypaper.Web/Flypaper.Web.csproj -a $TARGETARCH
|
||||
|
||||
COPY src/ src/
|
||||
ARG VERSION=0.0.0-dev
|
||||
RUN dotnet publish src/Flypaper.Web/Flypaper.Web.csproj -c Release -o /app --no-restore -p:Version=$VERSION
|
||||
RUN dotnet publish src/Flypaper.Web/Flypaper.Web.csproj -c Release -a $TARGETARCH -o /app --no-restore -p:Version=$VERSION \
|
||||
&& mkdir /data
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
ARG VERSION=0.0.0-dev
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /data && chown $APP_UID /data
|
||||
LABEL org.opencontainers.image.title="Flypaper" \
|
||||
org.opencontainers.image.description="Self-hosted tarpit that traps and slows down scanning bots, with event logging and analysis." \
|
||||
org.opencontainers.image.source="https://gitea.anticarnist.de/Tom/Flypaper" \
|
||||
org.opencontainers.image.licenses="MIT" \
|
||||
org.opencontainers.image.version=$VERSION
|
||||
|
||||
ENV ASPNETCORE_HTTP_PORTS= \
|
||||
ConnectionStrings__Flypaper="Data Source=/data/flypaper.db" \
|
||||
Flypaper__DataProtection__KeysPath=/data/keys \
|
||||
Flypaper__GeoIp__Directory=/data/geoip
|
||||
|
||||
COPY --from=build --chown=1654:1654 /data /data
|
||||
COPY --from=build /app .
|
||||
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/flypaper-entrypoint
|
||||
|
||||
USER $APP_UID
|
||||
EXPOSE 8080 8081
|
||||
VOLUME /data
|
||||
|
||||
ENTRYPOINT ["dotnet", "Flypaper.Web.dll"]
|
||||
ENTRYPOINT ["flypaper-entrypoint"]
|
||||
@@ -1,13 +1,9 @@
|
||||
# Flypaper
|
||||
|
||||
Self-hosted tarpit that traps and slows down scanning bots, with event logging and analysis.
|
||||
|
||||
Every server on the internet gets a steady stream of bots probing for `/.env`, `/.git/config`,
|
||||
`/wp-login.php` and friends, usually sent to the bare IP address or to host names that don't
|
||||
exist. Blocklists play whack-a-mole with addresses that change daily. Flypaper takes the
|
||||
opposite approach: it lets the bot in and then answers very, very slowly. While a scanner waits
|
||||
for an endless HTML page that trickles in a few bytes at a time, it isn't scanning someone
|
||||
else, and every catch is logged with its origin for you to look at.
|
||||
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
|
||||
|
||||
@@ -21,64 +17,35 @@ flowchart LR
|
||||
you["You (LAN)"] -->|"dashboard, port 8081"| flypaper
|
||||
```
|
||||
|
||||
1. Your reverse proxy keeps serving your real sites. Everything it has no site for (the
|
||||
default/catch-all server) goes to Flypaper, optionally also a few bait paths on your real
|
||||
domains.
|
||||
2. Flypaper listens on two ports. Port `8080` is the trap: everything that arrives there is
|
||||
caught. Port `8081` serves the dashboard and never traps; keep it inside your LAN.
|
||||
3. A caught request gets `200 OK` and an endless, plausible-looking HTML page: random chunks
|
||||
of 1 to 64 bytes with random pauses of 50 ms to 1 s in between.
|
||||
4. A connection governor caps the number of catches overall and per IP and ends every catch
|
||||
after a maximum hold time. If there is no free slot, the request gets a quick `404`.
|
||||
5. When a catch ends, Flypaper logs one line and stores the event in SQLite, enriched with
|
||||
country, city and network provider (ASN) from the free DB-IP databases.
|
||||
- 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.
|
||||
|
||||
## Features
|
||||
|
||||
- **Traps** for unknown hosts (catch-all) and for configurable trap paths such as `/.env`,
|
||||
`/.git/*` or `/wp-login.php`
|
||||
- **Slow delivery** of endless generated HTML with irregular timing
|
||||
- **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
|
||||
catches with expandable details; login with an admin password
|
||||
- **GeoIP**: country, city and ASN per catch from DB-IP Lite, downloaded and refreshed
|
||||
monthly; existing catches are filled in once the databases are available
|
||||
- **Settings page**: trap paths, extra known hosts, limits and retention, changed at runtime
|
||||
without a restart
|
||||
- **Retention**: old catches are deleted daily (90 days by default); catches from private
|
||||
networks are not stored by default; buttons to delete private or all catches
|
||||
- **One log line per catch**, so `docker logs` alone shows whether the trap works
|
||||
- **Health endpoint** `/health` for container health checks (on the trap port it answers only
|
||||
to private addresses)
|
||||
- **No configuration needed to start**: one volume, two ports, the admin password is set on
|
||||
first visit
|
||||
More: [how it works and all features](docs/overview.md).
|
||||
|
||||
## Quick start
|
||||
|
||||
There is no public image yet; build it from source. No environment variable is required.
|
||||
|
||||
```bash
|
||||
git clone <repository-url> flypaper
|
||||
cd flypaper
|
||||
docker build -t flypaper .
|
||||
docker run -d --name flypaper --restart unless-stopped \
|
||||
-p 8080:8080 -p 127.0.0.1:8081:8081 \
|
||||
-v flypaper-data:/data \
|
||||
flypaper
|
||||
gitea.anticarnist.de/tom/flypaper:latest
|
||||
```
|
||||
|
||||
Or with Compose, in a `compose.yaml` next to the `Dockerfile`:
|
||||
Or with Compose:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
flypaper:
|
||||
build: .
|
||||
image: flypaper:local
|
||||
image: gitea.anticarnist.de/tom/flypaper:latest
|
||||
container_name: flypaper
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080" # trap: point your reverse proxy here
|
||||
- "127.0.0.1:8081:8081" # dashboard: LAN or localhost only
|
||||
- "8080:8080" # trap
|
||||
- "127.0.0.1:8081:8081" # dashboard
|
||||
volumes:
|
||||
- flypaper-data:/data
|
||||
|
||||
@@ -86,141 +53,21 @@ volumes:
|
||||
flypaper-data:
|
||||
```
|
||||
|
||||
- Dashboard: <http://localhost:8081>. On the first visit Flypaper asks you to set the admin
|
||||
password; afterwards you log in with it and can change it on the settings page.
|
||||
- See the trap in action:
|
||||
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/`.
|
||||
|
||||
```bash
|
||||
curl -N http://localhost:8080/
|
||||
```
|
||||
On Unraid, use the template: [docs/unraid.md](docs/unraid.md).
|
||||
|
||||
This catch comes from a private address and is therefore not stored; the log line ends with
|
||||
`(not stored)`.
|
||||
## Connect your reverse proxy
|
||||
|
||||
The container runs as a non-root user (UID 1654) and keeps everything under `/data`: the SQLite
|
||||
database, the Data Protection keys for logins and the GeoIP databases. A named volume gets
|
||||
the right owner automatically; for a bind mount, `chown 1654:1654` the host folder first.
|
||||
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.
|
||||
|
||||
The files in [`deploy/unraid/`](deploy/unraid) and `.gitea/workflows/deploy.yml` are the
|
||||
author's personal deployment (Gitea Actions to Unraid). They are an example only and not
|
||||
needed to run Flypaper.
|
||||
|
||||
## Versions and updates
|
||||
|
||||
Flypaper follows [Semantic Versioning](https://semver.org); every release is listed in
|
||||
[CHANGELOG.md](CHANGELOG.md). The running version is shown in the dashboard footer and in the
|
||||
first log line.
|
||||
|
||||
| Image tag | Meaning |
|
||||
|---|---|
|
||||
| `:latest` | The newest release. The right choice for most setups. |
|
||||
| `:X.Y.Z` | A fixed release, e.g. `:0.1.0`. Pin it if you update deliberately. |
|
||||
| `:X.Y`, `:X` | The newest release of that minor or major line. |
|
||||
| `:main` | Development build of every commit on `main`. May break. |
|
||||
|
||||
There is no public image yet. To build a specific release from source:
|
||||
|
||||
```bash
|
||||
git checkout v0.1.0
|
||||
docker build --build-arg VERSION=0.1.0 -t flypaper:0.1.0 .
|
||||
```
|
||||
|
||||
To update, pull or rebuild the image and recreate the container
|
||||
(`docker compose pull && docker compose up -d`). The database is migrated automatically on
|
||||
start; back up the `/data` volume first. Before 1.0, a minor version may contain breaking
|
||||
changes, so read the changelog.
|
||||
|
||||
## Behind a reverse proxy
|
||||
|
||||
Flypaper is meant to sit behind the reverse proxy that already owns ports 80/443. The proxy
|
||||
forwards to the trap port `8080`; the dashboard port `8081` is never forwarded. Two rules
|
||||
apply to every proxy:
|
||||
|
||||
- **Set `X-Real-IP`** (and `X-Forwarded-For`) to the client address.
|
||||
- **Flypaper must trust the proxy.** By default it trusts every private network (`10/8`,
|
||||
`172.16/12`, `192.168/16`, loopback, `fc00::/7`), which covers a proxy in a Docker network
|
||||
or on the LAN. Headers from public addresses are ignored, so bots can't fake their address.
|
||||
To narrow it down, set `Flypaper__Http__TrustedProxies__0` to the proxy's IP or subnet, e.g.
|
||||
the Docker network's subnet:
|
||||
|
||||
```bash
|
||||
docker network inspect <network> -f '{{(index .IPAM.Config 0).Subnet}}'
|
||||
```
|
||||
|
||||
Also turn off response buffering for Flypaper, otherwise the proxy collects the drip and the
|
||||
bot never sees it. Flypaper sends `X-Accel-Buffering: no`, which nginx honors.
|
||||
|
||||
### What to send to Flypaper
|
||||
|
||||
- **The catch-all server.** Requests for hosts you don't serve (mostly the bare IP) go to
|
||||
Flypaper. This is where almost all scanners end up.
|
||||
- **Optionally, trap paths on your real domains.** Forward only the bait paths, e.g. `/.env`
|
||||
or `/wp-login.php`, from your real sites to Flypaper. Every request on the trap port is
|
||||
caught, so nothing else is needed.
|
||||
|
||||
*Known hosts* (optional) change this for hosts you list: on the trap port, a known host is
|
||||
caught only on the configured trap paths, and its other paths get a plain `404` without being
|
||||
logged. That is useful if your proxy forwards more than the bait paths of a real domain, for
|
||||
example a whole location. Unknown hosts are always caught. The dashboard is never reachable
|
||||
on the trap port.
|
||||
|
||||
### Nginx Proxy Manager
|
||||
|
||||
Put Flypaper into the same Docker network as NPM (the examples use the container name
|
||||
`flypaper`).
|
||||
|
||||
1. **Settings → Default Site → Congratulations Page.** With this setting NPM writes no
|
||||
default server of its own. Any other choice (404, redirect, HTML) creates one, and nginx
|
||||
refuses to start with two default servers.
|
||||
2. Create `/data/nginx/custom/http.conf` in the NPM container (on the host: inside NPM's
|
||||
data volume):
|
||||
|
||||
```nginx
|
||||
# Catch-all: every HTTP request whose Host matches no proxy host goes to Flypaper.
|
||||
server {
|
||||
listen 80 default_server; # the HTTP port NPM listens on inside its container
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
# A variable makes nginx resolve the name per request, so NPM still starts
|
||||
# (and serves your sites) while the Flypaper container is down.
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
set $flypaper http://flypaper:8080;
|
||||
proxy_pass $flypaper;
|
||||
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 1h;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Test and reload: `docker exec <npm-container> nginx -t`, then
|
||||
`docker exec <npm-container> nginx -s reload`.
|
||||
4. Optional trap paths on a real domain: in the proxy host's **Advanced** tab add
|
||||
|
||||
```nginx
|
||||
location ~* ^/(\.env|\.git/|wp-login\.php|xmlrpc\.php) {
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
set $flypaper http://flypaper:8080;
|
||||
proxy_pass $flypaper;
|
||||
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;
|
||||
}
|
||||
```
|
||||
|
||||
To undo the catch-all, delete `custom/http.conf` and reload.
|
||||
|
||||
### Plain nginx
|
||||
|
||||
Same idea: remove any existing `default_server` (on Debian/Ubuntu often
|
||||
`sites-enabled/default`) and add
|
||||
Plain nginx, with Flypaper on the same host:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
@@ -229,7 +76,7 @@ server {
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080; # or a variable + resolver for a Docker name, see above
|
||||
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;
|
||||
@@ -239,136 +86,49 @@ server {
|
||||
}
|
||||
```
|
||||
|
||||
With Flypaper on the same host, nothing else is needed: loopback is trusted by default.
|
||||
|
||||
### Caddy
|
||||
|
||||
```caddyfile
|
||||
# Catch-all for every host on port 80 without its own site block
|
||||
:80 {
|
||||
reverse_proxy flypaper:8080 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
flush_interval -1
|
||||
}
|
||||
}
|
||||
|
||||
# Optional trap paths on a real site
|
||||
example.com {
|
||||
@trap path /.env /.git/* /wp-login.php /xmlrpc.php
|
||||
reverse_proxy @trap flypaper:8080 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
flush_interval -1
|
||||
}
|
||||
reverse_proxy your-app:8080
|
||||
}
|
||||
```
|
||||
|
||||
### Traefik
|
||||
|
||||
Traefik sets `X-Real-Ip` and `X-Forwarded-For` by default. Labels on the Flypaper container
|
||||
(Traefik v3):
|
||||
|
||||
```yaml
|
||||
labels:
|
||||
traefik.enable: "true"
|
||||
# Lowest priority: matches only hosts no other router claims
|
||||
traefik.http.routers.flypaper-catchall.rule: "HostRegexp(`.+`)"
|
||||
traefik.http.routers.flypaper-catchall.entrypoints: web
|
||||
traefik.http.routers.flypaper-catchall.priority: "1"
|
||||
# Optional trap paths on a real site
|
||||
traefik.http.routers.flypaper-bait.rule: "Host(`example.com`) && (Path(`/.env`) || PathPrefix(`/.git/`) || Path(`/wp-login.php`))"
|
||||
traefik.http.routers.flypaper-bait.priority: "1000"
|
||||
traefik.http.services.flypaper.loadbalancer.server.port: "8080"
|
||||
```
|
||||
Nginx Proxy Manager, Caddy, Traefik and bait paths on your real domains:
|
||||
[docs/reverse-proxy.md](docs/reverse-proxy.md).
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment variables
|
||||
Nothing is required. The most useful optional environment variables:
|
||||
|
||||
All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
|
||||
|
||||
| Variable | Purpose | Default |
|
||||
|---|---|---|
|
||||
| `Flypaper__Admin__Password` | Fixes the dashboard password and disables the first-visit setup and the password change | set on first visit |
|
||||
| `Flypaper__Http__TrustedProxies__0` | IP or CIDR of the reverse proxy allowed to set `X-Real-IP` / `X-Forwarded-For`; replaces the default | private networks |
|
||||
| `Flypaper__Http__KnownHosts__0` | Hosts that are caught only on trap paths (`*.example.com` allowed), see above | none |
|
||||
| `Flypaper__Ports__Trap` / `Flypaper__Ports__Dashboard` | Container ports | `8080` / `8081` |
|
||||
| `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` |
|
||||
| `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__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` |
|
||||
| `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` |
|
||||
| `TZ` | Time zone for the dashboard | UTC |
|
||||
|
||||
The defaults of the runtime settings below can also be set this way, e.g.
|
||||
`Flypaper__MaxConnections`. Values saved on the settings page override them.
|
||||
|
||||
### Runtime settings
|
||||
|
||||
Changed on the dashboard's settings page, stored in the database, effective immediately. The
|
||||
reset button removes all saved values.
|
||||
|
||||
| Setting | Default |
|
||||
| Variable | Purpose |
|
||||
|---|---|
|
||||
| Trap paths (exact, or prefix with a trailing `*`) | `/.env`, `/.env.*`, `/.git/*`, `/.aws/*`, `/.DS_Store`, `/wp-login.php`, `/wp-admin/*`, `/xmlrpc.php`, `/phpmyadmin/*`, `/vendor/phpunit/*`, `/server-status`, `/actuator/*`, `/cgi-bin/*`, `/boaform/*` |
|
||||
| Extra known hosts (merged with `KnownHosts`) | none |
|
||||
| Maximum hold time per catch | `01:00:00` |
|
||||
| Maximum connections overall | `1000` |
|
||||
| Maximum connections per IP | `10` |
|
||||
| Keep catches (days, `0` = forever) | `90` |
|
||||
| Don't store catches from private networks | on |
|
||||
| `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) |
|
||||
| `Flypaper__Http__KnownHosts__0` | Host that is caught only on trap paths |
|
||||
| `TZ` | Time zone for the dashboard |
|
||||
|
||||
## Security notes
|
||||
Trap paths, limits and retention are changed on the dashboard's settings page. All variables
|
||||
and settings: [docs/configuration.md](docs/configuration.md).
|
||||
|
||||
- **Keep the dashboard internal.** Publish port `8081` only to your LAN or to localhost and
|
||||
never forward it from your public proxy.
|
||||
- **Finish the setup before the dashboard is reachable by anyone else.** Until a password is
|
||||
set, whoever opens the dashboard first can set it. The setup page disappears once a password
|
||||
exists.
|
||||
- **Use a strong admin password** (at least 12 characters). Only a salted hash is stored. The
|
||||
login runs over plain HTTP unless you put the dashboard behind TLS yourself.
|
||||
- **The limits protect you, not the bots.** Every catch holds a socket in Flypaper and in your
|
||||
proxy for up to the maximum hold time. Keep `MaxConnections` well below what your proxy can
|
||||
handle (nginx: `worker_connections`), and keep the per-IP limit low so a single scanner
|
||||
can't fill all slots.
|
||||
- **An HTTPS catch-all is rarely worth it.** Scanners of unknown hosts mostly speak plain
|
||||
HTTP to the bare IP, and an HTTPS catch-all would need a certificate for names you don't
|
||||
own. Let the proxy reject unknown TLS handshakes instead (nginx: `ssl_reject_handshake on;`).
|
||||
- **Privacy.** Flypaper stores IP addresses, requested URLs and user agents. Keep retention
|
||||
short if that matters in your jurisdiction.
|
||||
## 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
|
||||
|
||||
Requires the .NET 10 SDK.
|
||||
|
||||
```bash
|
||||
dotnet build
|
||||
dotnet build # .NET 10 SDK
|
||||
dotnet test
|
||||
dotnet run --project src/Flypaper.Web
|
||||
dotnet run --project src/Flypaper.Web # dashboard :5248 (password "dev"), trap :5247
|
||||
```
|
||||
|
||||
`dotnet run` starts in the Development environment: the dashboard is at
|
||||
<http://localhost:5248> (password `dev`), the trap at <http://localhost:5247>, the database is
|
||||
`src/Flypaper.Web/flypaper.db`, and GeoIP is off unless `Flypaper__GeoIp__Directory` is set.
|
||||
`docker build -t flypaper .` builds the image.
|
||||
Details and project layout: [docs/development.md](docs/development.md).
|
||||
|
||||
| Project | Contents |
|
||||
|---|---|
|
||||
| `Flypaper.Core` | Protocol-independent core: sessions, governor, strategies, settings |
|
||||
| `Flypaper.Http` | ASP.NET Core middleware, trap matching, forwarded headers |
|
||||
| `Flypaper.GeoIp` | DB-IP download and lookups |
|
||||
| `Flypaper.Storage` | EF Core with SQLite, event writer, retention, dashboard queries |
|
||||
| `Flypaper.Web` | Host, dashboard and settings (Blazor static SSR) |
|
||||
| `Flypaper.Tests` | xUnit, NSubstitute, Shouldly |
|
||||
## Versions
|
||||
|
||||
## Attribution
|
||||
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).
|
||||
|
||||
- [IP Geolocation by DB-IP](https://db-ip.com), licensed under
|
||||
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The dashboard shows this
|
||||
attribution in its footer.
|
||||
- The world map is generated from [Natural Earth](https://www.naturalearthdata.com) data
|
||||
(public domain).
|
||||
## Attribution and license
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE). Third-party data keeps its own license (see *Attribution*).
|
||||
[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.
|
||||
@@ -25,6 +25,12 @@ notes. Nothing is deployed.
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
The registry serves the images to anyone because the `Tom` account is public; packages
|
||||
inherit the visibility of their owner, not of the repository. To show the package on the
|
||||
repository page, link it once: Gitea → Tom → Packages → `flypaper` → Settings → Link to
|
||||
repository `Flypaper` (or `POST /api/v1/packages/Tom/container/flypaper/-/link/Flypaper` with
|
||||
a token that has `write:package`).
|
||||
|
||||
If the release step fails (e.g. the built-in token may not create releases), the images are
|
||||
already pushed. Create the release by hand: Gitea → repo → Releases → New Release, pick the
|
||||
tag, title `Flypaper X.Y.Z`, paste the changelog section.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Started as root (e.g. by the Unraid template): hand /data to the app user, which a
|
||||
# freshly created host folder is not, then drop privileges for good.
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
chown -R "$APP_UID:$APP_UID" /data
|
||||
exec setpriv --reuid="$APP_UID" --regid="$APP_UID" --clear-groups dotnet /app/Flypaper.Web.dll "$@"
|
||||
fi
|
||||
|
||||
exec dotnet /app/Flypaper.Web.dll "$@"
|
||||
@@ -0,0 +1,60 @@
|
||||
# Configuration
|
||||
|
||||
## Data volume
|
||||
|
||||
The container runs as a non-root user (UID 1654) and keeps everything under `/data`: the SQLite
|
||||
database, the Data Protection keys for logins and the GeoIP databases. A named volume gets
|
||||
the right owner automatically; for a bind mount, `chown 1654:1654` the host folder first (or
|
||||
start the container as root once, as the [Unraid template](unraid.md) does).
|
||||
|
||||
## Environment variables
|
||||
|
||||
All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
|
||||
|
||||
| Variable | Purpose | Default |
|
||||
|---|---|---|
|
||||
| `Flypaper__Admin__Password` | Fixes the dashboard password and disables the first-visit setup and the password change | set on first visit |
|
||||
| `Flypaper__Http__TrustedProxies__0` | IP or CIDR of the reverse proxy allowed to set `X-Real-IP` / `X-Forwarded-For`; replaces the default | private networks |
|
||||
| `Flypaper__Http__KnownHosts__0` | Hosts that are caught only on trap paths (`*.example.com` allowed), see [reverse proxy](reverse-proxy.md#what-to-send-to-flypaper) | none |
|
||||
| `Flypaper__Ports__Trap` / `Flypaper__Ports__Dashboard` | Container ports | `8080` / `8081` |
|
||||
| `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` |
|
||||
| `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__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` |
|
||||
| `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` |
|
||||
| `TZ` | Time zone for the dashboard | UTC |
|
||||
|
||||
The defaults of the runtime settings below can also be set this way, e.g.
|
||||
`Flypaper__MaxConnections`. Values saved on the settings page override them.
|
||||
|
||||
## Runtime settings
|
||||
|
||||
Changed on the dashboard's settings page, stored in the database, effective immediately. The
|
||||
reset button removes all saved values.
|
||||
|
||||
| Setting | Default |
|
||||
|---|---|
|
||||
| Trap paths (exact, or prefix with a trailing `*`) | `/.env`, `/.env.*`, `/.git/*`, `/.aws/*`, `/.DS_Store`, `/wp-login.php`, `/wp-admin/*`, `/xmlrpc.php`, `/phpmyadmin/*`, `/vendor/phpunit/*`, `/server-status`, `/actuator/*`, `/cgi-bin/*`, `/boaform/*` |
|
||||
| Extra known hosts (merged with `KnownHosts`) | none |
|
||||
| Maximum hold time per catch | `01:00:00` |
|
||||
| Maximum connections overall | `1000` |
|
||||
| Maximum connections per IP | `10` |
|
||||
| Keep catches (days, `0` = forever) | `90` |
|
||||
| Don't store catches from private networks | on |
|
||||
|
||||
## Security and privacy
|
||||
|
||||
- **Keep the dashboard internal.** Publish port `8081` only to your LAN or to localhost and
|
||||
never forward it from your public proxy.
|
||||
- **Finish the setup before the dashboard is reachable by anyone else.** Until a password is
|
||||
set, whoever opens the dashboard first can set it. The setup page disappears once a password
|
||||
exists.
|
||||
- **Use a strong admin password** (at least 12 characters). Only a salted hash is stored. The
|
||||
login runs over plain HTTP unless you put the dashboard behind TLS yourself.
|
||||
- **The limits protect you, not the bots.** Every catch holds a socket in Flypaper and in your
|
||||
proxy for up to the maximum hold time. Keep `MaxConnections` well below what your proxy can
|
||||
handle (nginx: `worker_connections`), and keep the per-IP limit low so a single scanner
|
||||
can't fill all slots.
|
||||
- **An HTTPS catch-all is rarely worth it**, see [reverse proxy](reverse-proxy.md#what-to-send-to-flypaper).
|
||||
- **Privacy.** Flypaper stores IP addresses, requested URLs and user agents. Keep retention
|
||||
short if that matters in your jurisdiction.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Development
|
||||
|
||||
Requires the .NET 10 SDK.
|
||||
|
||||
```bash
|
||||
dotnet build
|
||||
dotnet test
|
||||
dotnet run --project src/Flypaper.Web
|
||||
```
|
||||
|
||||
`dotnet run` starts in the Development environment: the dashboard is at
|
||||
<http://localhost:5248> (password `dev`), the trap at <http://localhost:5247>, the database is
|
||||
`src/Flypaper.Web/flypaper.db`, and GeoIP is off unless `Flypaper__GeoIp__Directory` is set.
|
||||
`docker build -t flypaper .` builds the image.
|
||||
|
||||
| Project | Contents |
|
||||
|---|---|
|
||||
| `Flypaper.Core` | Protocol-independent core: sessions, governor, strategies, settings |
|
||||
| `Flypaper.Http` | ASP.NET Core middleware, trap matching, forwarded headers |
|
||||
| `Flypaper.GeoIp` | DB-IP download and lookups |
|
||||
| `Flypaper.Storage` | EF Core with SQLite, event writer, retention, dashboard queries |
|
||||
| `Flypaper.Web` | Host, dashboard and settings (Blazor static SSR) |
|
||||
| `Flypaper.Tests` | xUnit, NSubstitute, Shouldly |
|
||||
|
||||
The files in [`deploy/unraid/`](../deploy/unraid) and `.gitea/workflows/` are the author's
|
||||
personal deployment (Gitea Actions to Unraid) and release pipeline. They are an example only and
|
||||
not needed to run Flypaper.
|
||||
@@ -0,0 +1,66 @@
|
||||
# How Flypaper works
|
||||
|
||||
Every server on the internet gets a steady stream of bots probing for `/.env`, `/.git/config`,
|
||||
`/wp-login.php` and friends, usually sent to the bare IP address or to host names that don't
|
||||
exist. Blocklists play whack-a-mole with addresses that change daily. Flypaper takes the
|
||||
opposite approach: it lets the bot in and then answers very, very slowly. While a scanner waits
|
||||
for an endless HTML page that trickles in a few bytes at a time, it isn't scanning someone
|
||||
else, and every catch is logged with its origin for you to look at.
|
||||
|
||||
```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 or trap path<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
|
||||
```
|
||||
|
||||
1. Your reverse proxy keeps serving your real sites. Everything it has no site for (the
|
||||
default/catch-all server) goes to Flypaper, optionally also a few bait paths on your real
|
||||
domains.
|
||||
2. Flypaper listens on two ports. Port `8080` is the trap: everything that arrives there is
|
||||
caught. Port `8081` serves the dashboard and never traps; keep it inside your LAN.
|
||||
3. A caught request gets `200 OK` and an endless, plausible-looking HTML page: random chunks
|
||||
of 1 to 64 bytes with random pauses of 50 ms to 1 s in between.
|
||||
4. A connection governor caps the number of catches overall and per IP and ends every catch
|
||||
after a maximum hold time. If there is no free slot, the request gets a quick `404`.
|
||||
5. When a catch ends, Flypaper logs one line and stores the event in SQLite, enriched with
|
||||
country, city and network provider (ASN) from the free DB-IP databases.
|
||||
|
||||
## Features
|
||||
|
||||
- **Traps** for unknown hosts (catch-all) and for configurable trap paths such as `/.env`,
|
||||
`/.git/*` or `/wp-login.php`
|
||||
- **Slow delivery** of endless generated HTML with irregular timing
|
||||
- **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
|
||||
catches with expandable details; login with an admin password
|
||||
- **GeoIP**: country, city and ASN per catch from DB-IP Lite, downloaded and refreshed
|
||||
monthly; existing catches are filled in once the databases are available
|
||||
- **Settings page**: trap paths, extra known hosts, limits and retention, changed at runtime
|
||||
without a restart
|
||||
- **Retention**: old catches are deleted daily (90 days by default); catches from private
|
||||
networks are not stored by default; buttons to delete private or all catches
|
||||
- **One log line per catch**, so `docker logs` alone shows whether the trap works
|
||||
- **Health endpoint** `/health` for container health checks (on the trap port it answers only
|
||||
to private addresses)
|
||||
- **No configuration needed to start**: one volume, two ports, the admin password is set on
|
||||
first visit
|
||||
|
||||
## Trying the trap locally
|
||||
|
||||
```bash
|
||||
curl -N http://localhost:8080/
|
||||
```
|
||||
|
||||
This catch comes from a private address and is therefore not stored; the log line ends with
|
||||
`(not stored)`.
|
||||
|
||||
## Attribution
|
||||
|
||||
Origins come from [IP Geolocation by DB-IP](https://db-ip.com), licensed under
|
||||
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); the dashboard shows this attribution
|
||||
in its footer. The world map is generated from [Natural Earth](https://www.naturalearthdata.com)
|
||||
data (public domain).
|
||||
@@ -0,0 +1,40 @@
|
||||
# Versions, images and updates
|
||||
|
||||
Flypaper follows [Semantic Versioning](https://semver.org); every release is listed in
|
||||
[CHANGELOG.md](../CHANGELOG.md) and on the
|
||||
[releases page](https://gitea.anticarnist.de/Tom/Flypaper/releases). The running version is
|
||||
shown in the dashboard footer and in the first log line.
|
||||
|
||||
All images live at `gitea.anticarnist.de/tom/flypaper`
|
||||
([package page](https://gitea.anticarnist.de/Tom/-/packages/container/flypaper/latest)); no
|
||||
login is needed to pull.
|
||||
|
||||
| Image tag | Meaning | Platforms |
|
||||
|---|---|---|
|
||||
| `:latest` | The newest release. The right choice for most setups. | amd64, arm64 |
|
||||
| `:X.Y.Z` | A fixed release, e.g. `:0.1.0`. Pin it if you update deliberately. | amd64, arm64 |
|
||||
| `:X.Y`, `:X` | The newest release of that minor or major line, e.g. `:0.1`, `:0`. | amd64, arm64 |
|
||||
| `:main` | Development build of the latest commit on `main`. May break. | amd64 |
|
||||
| `:<sha>` | Development build of one commit (short SHA), e.g. for a rollback. | amd64 |
|
||||
|
||||
arm64 covers e.g. a Raspberry Pi 4/5 with a 64-bit OS.
|
||||
|
||||
Pull a fixed version with `docker pull gitea.anticarnist.de/tom/flypaper:0.1.0`. To build a
|
||||
specific release from source instead:
|
||||
|
||||
```bash
|
||||
git checkout v0.1.0
|
||||
docker build --build-arg VERSION=0.1.0 -t flypaper:0.1.0 .
|
||||
```
|
||||
|
||||
You can always build the current source yourself: clone the repository and replace the
|
||||
`image:` line in your compose file with `build: .`, or run `docker build -t flypaper .`.
|
||||
|
||||
## Updating
|
||||
|
||||
Pull or rebuild the image and recreate the container
|
||||
(`docker compose pull && docker compose up -d`). The database is migrated automatically on
|
||||
start; back up the `/data` volume first. Before 1.0, a minor version may contain breaking
|
||||
changes, so read the changelog.
|
||||
|
||||
How releases are cut is described in [`deploy/unraid/README.md`](../deploy/unraid/README.md#releases).
|
||||
@@ -0,0 +1,153 @@
|
||||
# Behind a reverse proxy
|
||||
|
||||
Flypaper is meant to sit behind the reverse proxy that already owns ports 80/443. The proxy
|
||||
forwards to the trap port `8080`; the dashboard port `8081` is never forwarded. Two rules
|
||||
apply to every proxy:
|
||||
|
||||
- **Set `X-Real-IP`** (and `X-Forwarded-For`) to the client address.
|
||||
- **Flypaper must trust the proxy.** By default it trusts every private network (`10/8`,
|
||||
`172.16/12`, `192.168/16`, loopback, `fc00::/7`), which covers a proxy in a Docker network
|
||||
or on the LAN. Headers from public addresses are ignored, so bots can't fake their address.
|
||||
To narrow it down, set `Flypaper__Http__TrustedProxies__0` to the proxy's IP or subnet, e.g.
|
||||
the Docker network's subnet:
|
||||
|
||||
```bash
|
||||
docker network inspect <network> -f '{{(index .IPAM.Config 0).Subnet}}'
|
||||
```
|
||||
|
||||
Also turn off response buffering for Flypaper, otherwise the proxy collects the drip and the
|
||||
bot never sees it. Flypaper sends `X-Accel-Buffering: no`, which nginx honors.
|
||||
|
||||
## What to send to Flypaper
|
||||
|
||||
- **The catch-all server.** Requests for hosts you don't serve (mostly the bare IP) go to
|
||||
Flypaper. This is where almost all scanners end up.
|
||||
- **Optionally, trap paths on your real domains.** Forward only the bait paths, e.g. `/.env`
|
||||
or `/wp-login.php`, from your real sites to Flypaper. Every request on the trap port is
|
||||
caught, so nothing else is needed.
|
||||
|
||||
*Known hosts* (optional) change this for hosts you list: on the trap port, a known host is
|
||||
caught only on the configured trap paths, and its other paths get a plain `404` without being
|
||||
logged. That is useful if your proxy forwards more than the bait paths of a real domain, for
|
||||
example a whole location. Unknown hosts are always caught. The dashboard is never reachable
|
||||
on the trap port.
|
||||
|
||||
**An HTTPS catch-all is rarely worth it.** Scanners of unknown hosts mostly speak plain HTTP to
|
||||
the bare IP, and an HTTPS catch-all would need a certificate for names you don't own. Let the
|
||||
proxy reject unknown TLS handshakes instead (nginx: `ssl_reject_handshake on;`).
|
||||
|
||||
## Nginx Proxy Manager
|
||||
|
||||
Put Flypaper into the same Docker network as NPM (the examples use the container name
|
||||
`flypaper`).
|
||||
|
||||
1. **Settings → Default Site → Congratulations Page.** With this setting NPM writes no
|
||||
default server of its own. Any other choice (404, redirect, HTML) creates one, and nginx
|
||||
refuses to start with two default servers.
|
||||
2. Create `/data/nginx/custom/http.conf` in the NPM container (on the host: inside NPM's
|
||||
data volume):
|
||||
|
||||
```nginx
|
||||
# Catch-all: every HTTP request whose Host matches no proxy host goes to Flypaper.
|
||||
server {
|
||||
listen 80 default_server; # the HTTP port NPM listens on inside its container
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
# A variable makes nginx resolve the name per request, so NPM still starts
|
||||
# (and serves your sites) while the Flypaper container is down.
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
set $flypaper http://flypaper:8080;
|
||||
proxy_pass $flypaper;
|
||||
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 1h;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Test and reload: `docker exec <npm-container> nginx -t`, then
|
||||
`docker exec <npm-container> nginx -s reload`.
|
||||
4. Optional trap paths on a real domain: in the proxy host's **Advanced** tab add
|
||||
|
||||
```nginx
|
||||
location ~* ^/(\.env|\.git/|wp-login\.php|xmlrpc\.php) {
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
set $flypaper http://flypaper:8080;
|
||||
proxy_pass $flypaper;
|
||||
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;
|
||||
}
|
||||
```
|
||||
|
||||
To undo the catch-all, delete `custom/http.conf` and reload.
|
||||
|
||||
## Plain nginx
|
||||
|
||||
Remove any existing `default_server` (on Debian/Ubuntu often `sites-enabled/default`) and add
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080; # or a variable + resolver for a Docker name, see NPM
|
||||
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;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With Flypaper on the same host, nothing else is needed: loopback is trusted by default.
|
||||
|
||||
## Caddy
|
||||
|
||||
```caddyfile
|
||||
# Catch-all for every host on port 80 without its own site block
|
||||
:80 {
|
||||
reverse_proxy flypaper:8080 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
flush_interval -1
|
||||
}
|
||||
}
|
||||
|
||||
# Optional trap paths on a real site
|
||||
example.com {
|
||||
@trap path /.env /.git/* /wp-login.php /xmlrpc.php
|
||||
reverse_proxy @trap flypaper:8080 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
flush_interval -1
|
||||
}
|
||||
reverse_proxy your-app:8080
|
||||
}
|
||||
```
|
||||
|
||||
## Traefik
|
||||
|
||||
Traefik sets `X-Real-Ip` and `X-Forwarded-For` by default. Labels on the Flypaper container
|
||||
(Traefik v3):
|
||||
|
||||
```yaml
|
||||
labels:
|
||||
traefik.enable: "true"
|
||||
# Lowest priority: matches only hosts no other router claims
|
||||
traefik.http.routers.flypaper-catchall.rule: "HostRegexp(`.+`)"
|
||||
traefik.http.routers.flypaper-catchall.entrypoints: web
|
||||
traefik.http.routers.flypaper-catchall.priority: "1"
|
||||
# Optional trap paths on a real site
|
||||
traefik.http.routers.flypaper-bait.rule: "Host(`example.com`) && (Path(`/.env`) || PathPrefix(`/.git/`) || Path(`/wp-login.php`))"
|
||||
traefik.http.routers.flypaper-bait.priority: "1000"
|
||||
traefik.http.services.flypaper.loadbalancer.server.port: "8080"
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
# Unraid
|
||||
|
||||
[`unraid/flypaper.xml`](../unraid/flypaper.xml) is a Docker template for Unraid. It sets up both
|
||||
ports, the appdata folder `/mnt/user/appdata/flypaper` and the optional variables (under
|
||||
*Show more settings*).
|
||||
|
||||
1. Copy the template to the flash drive, in the Unraid terminal:
|
||||
|
||||
```bash
|
||||
wget -O /boot/config/plugins/dockerMan/templates-user/my-Flypaper.xml \
|
||||
https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.xml
|
||||
```
|
||||
|
||||
2. **Docker → Add Container**, pick *Flypaper* under the user templates, choose free host ports
|
||||
(8080 is often taken on Unraid) and **Apply**.
|
||||
3. Open the WebUI (the dashboard port) and set the admin password.
|
||||
|
||||
Unraid can also read templates from a *template repository* (Docker tab, Advanced View), but
|
||||
that feature is built around GitHub repositories and may not accept this Gitea URL; the manual
|
||||
copy above always works.
|
||||
|
||||
The template starts the container as root (`--user 0:0`) only so it can hand the appdata folder
|
||||
to its app user; Flypaper then drops to UID 1654 for good. Without it, a freshly created appdata
|
||||
folder belongs to root and the database cannot be created.
|
||||
|
||||
## Connecting Nginx Proxy Manager
|
||||
|
||||
Follow the [NPM section](reverse-proxy.md#nginx-proxy-manager). If NPM runs in a user-defined
|
||||
Docker network (e.g. `proxynet`), put Flypaper into the same network (*Network Type* in the
|
||||
template) and use `http://Flypaper:8080` as the target. If NPM can't share a network with it,
|
||||
forward to `http://<unraid-ip>:<trap-port>` instead. Either way the request comes from a
|
||||
private address, which Flypaper trusts by default.
|
||||
|
||||
The template is not part of the official Community Applications yet; that needs a separate
|
||||
submission.
|
||||
@@ -41,7 +41,7 @@ internal sealed class FlypaperMiddleware(
|
||||
|
||||
var trapContext = new TrapContext(
|
||||
session,
|
||||
$"{request.Method} {request.Host}{request.Path}{request.QueryString}",
|
||||
$"{request.Method} {StoredHost(request.Host)}{request.Path}{request.QueryString}",
|
||||
request.Headers.UserAgent.ToString());
|
||||
|
||||
var outcome = await runner.RunAsync(
|
||||
@@ -55,6 +55,9 @@ internal sealed class FlypaperMiddleware(
|
||||
}
|
||||
}
|
||||
|
||||
private static string StoredHost(HostString host) =>
|
||||
string.IsNullOrEmpty(host.Host) || host.Host == "_" ? "" : host.Value!;
|
||||
|
||||
private static bool IsInternalHealthProbe(HttpContext context) =>
|
||||
context.Request.Path.Equals(HttpTrapOptions.HealthPath, StringComparison.OrdinalIgnoreCase)
|
||||
&& context.Connection.RemoteIpAddress is { } remoteIp
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Flypaper.Storage;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Flypaper.Storage.Migrations
|
||||
{
|
||||
[DbContext(typeof(FlypaperDbContext))]
|
||||
[Migration("20261115114013_NormalizeMissingHost")]
|
||||
partial class NormalizeMissingHost
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.15");
|
||||
|
||||
modelBuilder.Entity("Flypaper.Storage.Entities.SettingEntity", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Key");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Flypaper.Storage.Entities.TrapEventEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long?>("Asn")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("BytesSent")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("City")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClientInfo")
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Country")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CountryCode")
|
||||
.HasMaxLength(2)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("DurationMs")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("EndedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Outcome")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Protocol")
|
||||
.IsRequired()
|
||||
.HasMaxLength(16)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Provider")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RemoteIp")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("SessionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("StartedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Strategy")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Target")
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Asn");
|
||||
|
||||
b.HasIndex("CountryCode");
|
||||
|
||||
b.HasIndex("RemoteIp");
|
||||
|
||||
b.HasIndex("StartedAt");
|
||||
|
||||
b.ToTable("TrapEvents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Flypaper.Storage.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class NormalizeMissingHost : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE "TrapEvents"
|
||||
SET "Target" = substr("Target", 1, instr("Target", ' _/')) || substr("Target", instr("Target", ' _/') + 2)
|
||||
WHERE instr("Target", ' _/') > 0;
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@
|
||||
<WorldMap CatchesByCountry="data.CatchesByCountry" />
|
||||
|
||||
<section class="tops">
|
||||
<TopTable Title="Top 10 Länder" KeyLabel="Land" Entries="data.TopCountries" ShowFlags="true" />
|
||||
<TopTable Title="Top 10 Länder" KeyLabel="Land" Entries="data.TopCountries" ShowFlags="true" LabelFormatter="CountryNames.Display" />
|
||||
<TopTable Title="Top 10 Provider (ASN)" KeyLabel="Provider" Entries="data.TopProviders" />
|
||||
<TopTable Title="Top 10 IPs" KeyLabel="IP" Entries="data.TopIps" />
|
||||
<TopTable Title="Top 10 Ziele" KeyLabel="Ziel" Entries="data.TopTargets" />
|
||||
<TopTable Title="Top 10 Ziele" KeyLabel="Ziel" Entries="data.TopTargets" KeyFormatter="Formatting.Target" />
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
@@ -47,40 +47,51 @@
|
||||
<table class="recent-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeit</th>
|
||||
<th>IP</th>
|
||||
<th>Herkunft</th>
|
||||
<th>Provider</th>
|
||||
<th>Ziel</th>
|
||||
<th>User-Agent</th>
|
||||
<th class="num">Dauer</th>
|
||||
<th class="num">Bytes</th>
|
||||
<th>Ausgang</th>
|
||||
<th class="c-time">Zeit</th>
|
||||
<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-agent">User-Agent</th>
|
||||
<th class="c-duration num">Dauer</th>
|
||||
<th class="c-bytes num">Bytes</th>
|
||||
<th class="c-outcome">Ausgang</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var trapEvent in data.Recent)
|
||||
{
|
||||
var started = trapEvent.StartedAt.ToLocalTime();
|
||||
var provider = Formatting.Provider(trapEvent.Asn, trapEvent.Provider);
|
||||
var target = Formatting.Target(trapEvent.Target);
|
||||
var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs));
|
||||
var bytes = trapEvent.BytesSent.ToString("N0");
|
||||
<tr data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false">
|
||||
<td class="nowrap">@trapEvent.StartedAt.ToLocalTime().ToString("dd.MM. HH:mm:ss")</td>
|
||||
<td class="mono">@trapEvent.RemoteIp</td>
|
||||
<td class="nowrap" title="@Origin(trapEvent)">
|
||||
<td class="c-time"><span class="c-date">@started.ToString("dd.MM.") </span>@started.ToString("HH:mm:ss")</td>
|
||||
<td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td>
|
||||
<td class="c-origin" title="@Origin(trapEvent)">
|
||||
@if (trapEvent.CountryCode is { } countryCode)
|
||||
{
|
||||
@($"{Formatting.Flag(countryCode)} {countryCode}")
|
||||
<span class="detail">@Origin(trapEvent)</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="muted">–</span>
|
||||
}
|
||||
</td>
|
||||
<td class="clip" title="@Formatting.Provider(trapEvent.Asn, trapEvent.Provider)">@Formatting.Provider(trapEvent.Asn, trapEvent.Provider)</td>
|
||||
<td class="mono clip" title="@trapEvent.Target">@trapEvent.Target</td>
|
||||
<td class="clip" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||
<td class="num">@Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs))</td>
|
||||
<td class="num">@trapEvent.BytesSent.ToString("N0")</td>
|
||||
<td><span class="outcome @trapEvent.Outcome.ToString().ToLowerInvariant()">@trapEvent.Outcome</span></td>
|
||||
<td class="c-provider" title="@provider">@provider</td>
|
||||
<td class="c-target mono" title="@target">
|
||||
@target
|
||||
<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-xs">Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @trapEvent.Outcome</div>
|
||||
</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()">@trapEvent.Outcome</span></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -103,5 +114,5 @@
|
||||
}
|
||||
|
||||
private static string Origin(TrapEventEntity trapEvent) =>
|
||||
string.Join(", ", new[] { trapEvent.City, trapEvent.Country }.Where(part => !string.IsNullOrEmpty(part)));
|
||||
string.Join(", ", new[] { trapEvent.City, CountryNames.Display(trapEvent.CountryCode, trapEvent.Country) }.Where(part => !string.IsNullOrEmpty(part)));
|
||||
}
|
||||
@@ -43,5 +43,14 @@
|
||||
|
||||
[Parameter] public bool ShowFlags { get; set; }
|
||||
|
||||
private static string Display(TopEntry entry) => entry.Label is null ? entry.Key : $"{entry.Key} · {entry.Label}";
|
||||
[Parameter] public Func<string?, string?>? KeyFormatter { get; set; }
|
||||
|
||||
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
|
||||
|
||||
private string Display(TopEntry entry)
|
||||
{
|
||||
var key = KeyFormatter?.Invoke(entry.Key) ?? entry.Key;
|
||||
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
|
||||
return label is null ? key : $"{key} · {label}";
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,21 @@
|
||||
@foreach (var country in Map.Countries)
|
||||
{
|
||||
var count = Count(country.Code);
|
||||
<path d="@country.Path" class="@($"level-{Level(count)}")"><title>@country.Name: @count.ToString("N0") @(count == 1 ? "Fang" : "Fänge")</title></path>
|
||||
<path d="@country.Path" class="@($"level-{Level(count)}")"><title>@Title(CountryNames.Display(country.Code, country.Name)!, count)</title></path>
|
||||
}
|
||||
@foreach (var marker in Map.Markers)
|
||||
{
|
||||
var count = Count(marker.Code);
|
||||
if (count > 0)
|
||||
{
|
||||
var x = marker.X.ToString(CultureInfo.InvariantCulture);
|
||||
var y = marker.Y.ToString(CultureInfo.InvariantCulture);
|
||||
<g class="@($"marker level-{Level(count)}")">
|
||||
<title>@Title(CountryNames.Display(marker.Code, marker.Name)!, count)</title>
|
||||
<circle class="hit" cx="@x" cy="@y" r="14" />
|
||||
<circle class="dot" cx="@x" cy="@y" r="6" />
|
||||
</g>
|
||||
}
|
||||
}
|
||||
</svg>
|
||||
<div class="map-legend">
|
||||
@@ -31,6 +45,8 @@
|
||||
|
||||
private int Count(string? code) => code is not null && CatchesByCountry.TryGetValue(code, out var count) ? count : 0;
|
||||
|
||||
private static string Title(string name, int count) => $"{name}: {count:N0} {(count == 1 ? "Fang" : "Fänge")}";
|
||||
|
||||
private int Level(int count) =>
|
||||
count == 0 || _max == 0 ? 0 : Math.Max(1, (int)Math.Ceiling(Math.Log(count + 1) / Math.Log(_max + 1) * Levels));
|
||||
}
|
||||
@@ -2,7 +2,11 @@ using System.Text.Json;
|
||||
|
||||
namespace Flypaper.Web.Components.Pages.Dashboard;
|
||||
|
||||
internal sealed record WorldMapData(double Width, double Height, IReadOnlyList<WorldMapCountry> Countries)
|
||||
internal sealed record WorldMapData(
|
||||
double Width,
|
||||
double Height,
|
||||
IReadOnlyList<WorldMapCountry> Countries,
|
||||
IReadOnlyList<WorldMapMarker> Markers)
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
||||
|
||||
@@ -18,3 +22,5 @@ internal sealed record WorldMapData(double Width, double Height, IReadOnlyList<W
|
||||
}
|
||||
|
||||
internal sealed record WorldMapCountry(string? Code, string Name, string Path);
|
||||
|
||||
internal sealed record WorldMapMarker(string Code, string Name, double X, double Y);
|
||||
@@ -1 +1 @@
|
||||
{"width":1000.0,"height":439.1,"countries":[{"code":"AF","name":"Afghanistan","path":"M669.6,108.7L671,108.7L673.1,109.4L674,109.9L675.5,108.8L676.6,109.4L677,107.9L678.5,108L678.7,107.5L678.6,106.1L679.3,104.9L680.9,105.7L681,106.7L681.8,106.9L682.4,109.7L683.8,110.8L684.5,110.1L685.5,109.8L686.6,108.3L688.4,108.5L691.1,108.5L691.8,109.5L690.5,109.9L689.4,110.5L686.6,110.9L684,111.6L683,113.1L684,114.5L684.8,116.2L683.9,117.6L684.4,119L684.1,120.2L681.6,120.1L683.2,122.4L681.8,123.3L681.2,125.4L681.9,127.5L681.1,128.4L680.1,128.1L678.2,128.6L678.1,129.5L676.2,129.5L675.2,131.5L675.8,134.5L672.6,136L670.7,135.7L670.4,136.5L668.7,136L666.1,136.5L661.3,134.7L663,131.5L662.3,129.3L660.2,128.7L659.5,126.5L658,123.7L658.7,121.8L657.4,121.3L657.6,118.8L657.5,114.5L660.5,115.8L662.3,115.4L662.5,113.8L664.4,113.3L665.5,112.3L665.3,109.6L667.2,108.9L667.3,107.7L668.8,108.6L669.6,108.7Z"},{"code":"AL","name":"Albanien","path":"M552.5,97.2L552.5,98L551.7,98.5L551.7,99.6L550.7,101.2L550.2,100.9L550.1,100.2L548.6,99.1L548.2,97.5L548.2,95.3L548.5,94.3L548,93.8L547.8,92.8L548.7,91.2L548.9,91.8L549.5,91.5L550.1,92.4L550.8,92.7L551,93.9L550.8,95L551.3,96.4L552.5,97.2Z"},{"code":"DZ","name":"Algerien","path":"M476.7,143.4L476.8,142.7L476.8,142.5L476.9,138.2L481.3,135.6L483.9,135.1L486.1,134.1L487.2,132.4L490.3,131L490.4,128.4L491.9,128.1L493.1,126.8L496.6,126.2L497.1,124.8L496.4,124.1L495.5,120.4L495.4,118.4L494.4,116.2L496.9,114.3L499.7,113.7L501.3,112.3L503.8,111.3L508.1,110.7L512.3,110.4L513.6,110.9L516,109.6L518.7,109.5L519.8,110.3L521.5,110.1L521.1,111.9L521.6,115.1L521.1,117.9L519.5,119.8L519.8,122.4L522,124.5L522.1,125.3L523.7,126.7L525.1,133L526,136.2L526.2,137.8L525.9,140.7L526.1,142.3L525.8,144.3L526.1,146.6L525.1,148.1L526.8,150.7L526.9,152.2L527.9,154.3L529.2,153.6L531.4,155.3L532.6,157.6L523.5,164.5L515.6,171.8L511.8,173.4L508.7,173.8L508.7,171.4L507.4,170.8L505.7,169.8L505,168L495.8,160L486.7,152.1L476.7,143.4Z"},{"code":"AO","name":"Angola","path":"M536.7,264L535.7,264.8L535.2,265.8L535.1,267.4L534.4,267.8L533.7,265L534.8,263.3L535.7,262.7L536.7,264ZM534.8,269L536,268.5L536.8,268.6L537.8,268.1L546.1,268.1L546.8,271L547.5,273.3L548.2,274.5L549.2,276.5L551.1,276.2L552,275.6L553.6,276.2L554,275.2L554.8,273L556.5,272.9L556.7,272.2L558.1,272.2L557.8,273.6L561.3,273.5L561.3,275.9L561.8,277.4L561.4,279.7L561.5,282L562.4,283.4L562.2,287.9L562.9,287.5L564.1,287.6L565.8,287.1L567.1,287.3L567.4,288.5L567,290.3L567.4,292.1L567,293.5L567.2,294.8L561.3,294.7L560.8,306.7L562.5,309.7L564.3,312L559.1,313.5L552.4,313L550.6,311.2L539.3,311.4L538.9,311.7L537.3,310L535.5,309.9L533.8,310.5L532.5,311.2L532.3,308.9L532.7,305.6L533.8,302.2L533.9,300.6L534.9,297.2L535.6,295.6L537.3,293.2L538.2,291.5L538.5,288.7L538.4,286.6L537.6,285.2L536.9,282.9L536.2,280.6L536.4,279.8L537.3,278.3L536.5,274.7L535.9,272.1L534.5,269.7L534.8,269Z"},{"code":"AR","name":"Argentinien","path":"M343.2,430.7L344.7,432L346.9,434.2L350.6,435.8L354.1,436.5L353.8,437.9L351.7,438.1L350.1,437.1L348.7,437L346.3,437L343.2,430.7ZM347.6,358.1L347.5,361L347.5,364.6L348.3,368L347.9,368.8L348.2,371L348.5,372.8L352.4,375.8L352.6,378.1L354.6,379.6L354.9,381.2L353.5,385.5L350.2,387.3L345.3,388L342.5,387.7L343.6,389.7L343.8,392.1L344.7,393.8L343.6,395L341.2,395.4L338.4,394.2L337.7,395.1L339.1,398.3L341.1,399.3L342.1,398.3L343.4,399.9L341.5,400.9L340.2,402.9L340.9,406.1L341,407.8L338.7,407.8L337.4,409.4L337.6,411.8L340.8,414L343.4,414.6L343.6,417.4L341.5,419.1L341.5,422.6L339.9,423.8L339.5,425.2L341.7,428.2L344,429.9L342.9,429.7L340.6,429.3L334.9,428.9L333.1,427.2L332.1,425L330.6,425.2L329.3,424.1L327.6,421L328.8,419.6L328.7,417.7L327.8,416.2L327.9,413.6L327.1,409.5L326.1,407.6L326.9,407L326.2,405.8L324.8,405.2L325.1,403.9L323.6,402.6L321.6,398.9L322.4,398.3L320.5,394.3L319.9,390.9L319.6,388L320.7,386.8L318.9,383.5L318,380.4L319.2,378.2L318.4,375.4L318.9,372L318,368.8L317.2,368.2L314.4,362.2L315.2,358.6L314.1,355.1L314.3,351.9L315.3,348.6L316.7,346.3L315.7,344.9L316,343.8L314.7,337.7L317.3,336L317.6,332.2L317.1,331.3L318.9,328L322.6,328.8L324.6,331.5L325.2,328.5L328.3,328.7L328.9,329.5L334.8,335.4L337.2,336L340.9,338.7L343.9,340.1L344.6,341.7L342.9,347.1L345.7,348.1L348.8,348.7L350.9,348.1L352.8,345.3L352.8,342.2L354,341.5L355.7,343.6L356.1,346.4L354.1,348.4L352.6,349.9L350.2,353.3L347.6,358.1Z"},{"code":"AM","name":"Armenien","path":"M617.6,104L616.7,104.1L615.2,102.2L615.1,101.7L614,101.7L613.1,100.8L612.6,100.9L611.4,99.9L609.4,99.1L609.3,97.5L608.6,96.3L611.9,95.8L612.6,96.7L613.7,97.3L613.4,98.1L615,99.2L614.5,100.3L615.8,101.2L617,101.7L617.6,104Z"},{"code":"AZ","name":"Aserbaidschan","path":"M615,93.8L615.8,94L617.9,95.9L619.1,96.2L619.3,95.3L620.5,94L622.2,95.7L624,98L625.2,98.2L626.2,99.1L624.2,99.3L624.4,101.9L624.2,103.1L623.5,103.9L623.9,105.5L623.3,105.7L621.4,103.9L621.9,102.3L620.9,101.3L620,101.6L617.6,104L617,101.7L615.8,101.2L614.5,100.3L615,99.2L613.4,98.1L613.7,97.3L612.6,96.7L611.9,95.8L612.4,95.3L614.5,96.2L615.9,96.4L616.1,96.1L614.5,94.3L615,93.8ZM616.7Line truncated
|
||||
{"width":1000.0,"height":439.1,"countries":[{"code":"AF","name":"Afghanistan","path":"M669.6,108.7L671,108.7L673.1,109.4L674,109.9L675.5,108.8L676.6,109.4L677,107.9L678.5,108L678.7,107.5L678.6,106.1L679.3,104.9L680.9,105.7L681,106.7L681.8,106.9L682.4,109.7L683.8,110.8L684.5,110.1L685.5,109.8L686.6,108.3L688.4,108.5L691.1,108.5L691.8,109.5L690.5,109.9L689.4,110.5L686.6,110.9L684,111.6L683,113.1L684,114.5L684.8,116.2L683.9,117.6L684.4,119L684.1,120.2L681.6,120.1L683.2,122.4L681.8,123.3L681.2,125.4L681.9,127.5L681.1,128.4L680.1,128.1L678.2,128.6L678.1,129.5L676.2,129.5L675.2,131.5L675.8,134.5L672.6,136L670.7,135.7L670.4,136.5L668.7,136L666.1,136.5L661.3,134.7L663,131.5L662.3,129.3L660.2,128.7L659.5,126.5L658,123.7L658.7,121.8L657.4,121.3L657.6,118.8L657.5,114.5L660.5,115.8L662.3,115.4L662.5,113.8L664.4,113.3L665.5,112.3L665.3,109.6L667.2,108.9L667.3,107.7L668.8,108.6L669.6,108.7Z"},{"code":"AL","name":"Albanien","path":"M552.5,97.2L552.5,98L551.7,98.5L551.7,99.6L550.7,101.2L550.2,100.9L550.1,100.2L548.6,99.1L548.2,97.5L548.2,95.3L548.5,94.3L548,93.8L547.8,92.8L548.7,91.2L548.9,91.8L549.5,91.5L550.1,92.4L550.8,92.7L551,93.9L550.8,95L551.3,96.4L552.5,97.2Z"},{"code":"DZ","name":"Algerien","path":"M476.7,143.4L476.8,142.7L476.8,142.5L476.9,138.2L481.3,135.6L483.9,135.1L486.1,134.1L487.2,132.4L490.3,131L490.4,128.4L491.9,128.1L493.1,126.8L496.6,126.2L497.1,124.8L496.4,124.1L495.5,120.4L495.4,118.4L494.4,116.2L496.9,114.3L499.7,113.7L501.3,112.3L503.8,111.3L508.1,110.7L512.3,110.4L513.6,110.9L516,109.6L518.7,109.5L519.8,110.3L521.5,110.1L521.1,111.9L521.6,115.1L521.1,117.9L519.5,119.8L519.8,122.4L522,124.5L522.1,125.3L523.7,126.7L525.1,133L526,136.2L526.2,137.8L525.9,140.7L526.1,142.3L525.8,144.3L526.1,146.6L525.1,148.1L526.8,150.7L526.9,152.2L527.9,154.3L529.2,153.6L531.4,155.3L532.6,157.6L523.5,164.5L515.6,171.8L511.8,173.4L508.7,173.8L508.7,171.4L507.4,170.8L505.7,169.8L505,168L495.8,160L486.7,152.1L476.7,143.4Z"},{"code":"AO","name":"Angola","path":"M536.7,264L535.7,264.8L535.2,265.8L535.1,267.4L534.4,267.8L533.7,265L534.8,263.3L535.7,262.7L536.7,264ZM534.8,269L536,268.5L536.8,268.6L537.8,268.1L546.1,268.1L546.8,271L547.5,273.3L548.2,274.5L549.2,276.5L551.1,276.2L552,275.6L553.6,276.2L554,275.2L554.8,273L556.5,272.9L556.7,272.2L558.1,272.2L557.8,273.6L561.3,273.5L561.3,275.9L561.8,277.4L561.4,279.7L561.5,282L562.4,283.4L562.2,287.9L562.9,287.5L564.1,287.6L565.8,287.1L567.1,287.3L567.4,288.5L567,290.3L567.4,292.1L567,293.5L567.2,294.8L561.3,294.7L560.8,306.7L562.5,309.7L564.3,312L559.1,313.5L552.4,313L550.6,311.2L539.3,311.4L538.9,311.7L537.3,310L535.5,309.9L533.8,310.5L532.5,311.2L532.3,308.9L532.7,305.6L533.8,302.2L533.9,300.6L534.9,297.2L535.6,295.6L537.3,293.2L538.2,291.5L538.5,288.7L538.4,286.6L537.6,285.2L536.9,282.9L536.2,280.6L536.4,279.8L537.3,278.3L536.5,274.7L535.9,272.1L534.5,269.7L534.8,269Z"},{"code":"AR","name":"Argentinien","path":"M343.2,430.7L344.7,432L346.9,434.2L350.6,435.8L354.1,436.5L353.8,437.9L351.7,438.1L350.1,437.1L348.7,437L346.3,437L343.2,430.7ZM347.6,358.1L347.5,361L347.5,364.6L348.3,368L347.9,368.8L348.2,371L348.5,372.8L352.4,375.8L352.6,378.1L354.6,379.6L354.9,381.2L353.5,385.5L350.2,387.3L345.3,388L342.5,387.7L343.6,389.7L343.8,392.1L344.7,393.8L343.6,395L341.2,395.4L338.4,394.2L337.7,395.1L339.1,398.3L341.1,399.3L342.1,398.3L343.4,399.9L341.5,400.9L340.2,402.9L340.9,406.1L341,407.8L338.7,407.8L337.4,409.4L337.6,411.8L340.8,414L343.4,414.6L343.6,417.4L341.5,419.1L341.5,422.6L339.9,423.8L339.5,425.2L341.7,428.2L344,429.9L342.9,429.7L340.6,429.3L334.9,428.9L333.1,427.2L332.1,425L330.6,425.2L329.3,424.1L327.6,421L328.8,419.6L328.7,417.7L327.8,416.2L327.9,413.6L327.1,409.5L326.1,407.6L326.9,407L326.2,405.8L324.8,405.2L325.1,403.9L323.6,402.6L321.6,398.9L322.4,398.3L320.5,394.3L319.9,390.9L319.6,388L320.7,386.8L318.9,383.5L318,380.4L319.2,378.2L318.4,375.4L318.9,372L318,368.8L317.2,368.2L314.4,362.2L315.2,358.6L314.1,355.1L314.3,351.9L315.3,348.6L316.7,346.3L315.7,344.9L316,343.8L314.7,337.7L317.3,336L317.6,332.2L317.1,331.3L318.9,328L322.6,328.8L324.6,331.5L325.2,328.5L328.3,328.7L328.9,329.5L334.8,335.4L337.2,336L340.9,338.7L343.9,340.1L344.6,341.7L342.9,347.1L345.7,348.1L348.8,348.7L350.9,348.1L352.8,345.3L352.8,342.2L354,341.5L355.7,343.6L356.1,346.4L354.1,348.4L352.6,349.9L350.2,353.3L347.6,358.1Z"},{"code":"AM","name":"Armenien","path":"M617.6,104L616.7,104.1L615.2,102.2L615.1,101.7L614,101.7L613.1,100.8L612.6,100.9L611.4,99.9L609.4,99.1L609.3,97.5L608.6,96.3L611.9,95.8L612.6,96.7L613.7,97.3L613.4,98.1L615,99.2L614.5,100.3L615.8,101.2L617,101.7L617.6,104Z"},{"code":"AZ","name":"Aserbaidschan","path":"M615,93.8L615.8,94L617.9,95.9L619.1,96.2L619.3,95.3L620.5,94L622.2,95.7L624,98L625.2,98.2L626.2,99.1L624.2,99.3L624.4,101.9L624.2,103.1L623.5,103.9L623.9,105.5L623.3,105.7L621.4,103.9L621.9,102.3L620.9,101.3L620,101.6L617.6,104L617,101.7L615.8,101.2L614.5,100.3L615,99.2L613.4,98.1L613.7,97.3L612.6,96.7L611.9,95.8L612.4,95.3L614.5,96.2L615.9,96.4L616.1,96.1L614.5,94.3L615,93.8ZM616.7Line truncated
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Flypaper.Web.Components.Shared;
|
||||
|
||||
public static class CountryNames
|
||||
{
|
||||
private static readonly Dictionary<string, string> ShortNames = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["BN"] = "Brunei",
|
||||
["BO"] = "Bolivien",
|
||||
["CD"] = "Kongo (Dem. Rep.)",
|
||||
["CG"] = "Kongo",
|
||||
["CI"] = "Elfenbeinküste",
|
||||
["CN"] = "China",
|
||||
["CY"] = "Zypern",
|
||||
["CZ"] = "Tschechien",
|
||||
["FM"] = "Mikronesien",
|
||||
["GB"] = "Vereinigtes Königreich",
|
||||
["HK"] = "Hongkong",
|
||||
["IR"] = "Iran",
|
||||
["KP"] = "Nordkorea",
|
||||
["KR"] = "Südkorea",
|
||||
["LA"] = "Laos",
|
||||
["MD"] = "Moldau",
|
||||
["MK"] = "Nordmazedonien",
|
||||
["MO"] = "Macau",
|
||||
["PS"] = "Palästina",
|
||||
["RU"] = "Russland",
|
||||
["SY"] = "Syrien",
|
||||
["SZ"] = "Eswatini",
|
||||
["TL"] = "Osttimor",
|
||||
["TW"] = "Taiwan",
|
||||
["TZ"] = "Tansania",
|
||||
["US"] = "USA",
|
||||
["VA"] = "Vatikanstadt",
|
||||
["VE"] = "Venezuela",
|
||||
["VN"] = "Vietnam"
|
||||
};
|
||||
|
||||
public static string? Display(string? code, string? name) =>
|
||||
code is not null && ShortNames.TryGetValue(code, out var shortName) ? shortName : name ?? code;
|
||||
}
|
||||
@@ -24,5 +24,24 @@ public static class Formatting
|
||||
_ => $"{bytes} B"
|
||||
};
|
||||
|
||||
public static string? Target(string? target)
|
||||
{
|
||||
var space = target?.IndexOf(' ') ?? -1;
|
||||
if (space < 0)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
var hostAndPath = target![(space + 1)..];
|
||||
if (hostAndPath.StartsWith('/'))
|
||||
{
|
||||
return $"{target[..space]} (ohne Host){hostAndPath}";
|
||||
}
|
||||
|
||||
return hostAndPath == "_" || hostAndPath.StartsWith("_/", StringComparison.Ordinal)
|
||||
? $"{target[..space]} (ohne Host){hostAndPath[1..]}"
|
||||
: target;
|
||||
}
|
||||
|
||||
public static string? Provider(long? asn, string? provider) => asn is null ? provider : $"AS{asn} {provider}".TrimEnd();
|
||||
}
|
||||
@@ -15,4 +15,8 @@
|
||||
<ProjectReference Include="..\Flypaper.Storage\Flypaper.Storage.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="Flypaper.Tests" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -127,8 +127,104 @@ h2 {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.recent-table .clip {
|
||||
max-width: 200px;
|
||||
.recent-table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.recent-table td {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.recent-table tr.open td {
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.recent-table tr.open td.num,
|
||||
.recent-table tr.open td.c-time,
|
||||
.recent-table tr.open td.c-origin,
|
||||
.recent-table tr.open td.c-outcome {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.recent-table tr.open .extra-all {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.recent-table .c-time {
|
||||
width: 116px;
|
||||
}
|
||||
|
||||
.recent-table .c-ip {
|
||||
width: 132px;
|
||||
}
|
||||
|
||||
.recent-table .c-origin {
|
||||
width: 76px;
|
||||
}
|
||||
|
||||
.recent-table .c-duration {
|
||||
width: 92px;
|
||||
}
|
||||
|
||||
.recent-table .c-bytes {
|
||||
width: 104px;
|
||||
}
|
||||
|
||||
.recent-table .c-outcome {
|
||||
width: 116px;
|
||||
}
|
||||
|
||||
.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-agent {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.recent-table tr.open .extra-md {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 899px) {
|
||||
.recent-table .c-origin,
|
||||
.recent-table .c-duration,
|
||||
.recent-table .c-bytes {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.recent-table tr.open .extra-sm {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 599px) {
|
||||
.recent-table .c-outcome,
|
||||
.recent-table .c-date {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.recent-table .c-time {
|
||||
width: 76px;
|
||||
}
|
||||
|
||||
.recent-table .c-ip {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.recent-table tr.open .extra-xs {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.scroll {
|
||||
@@ -401,6 +497,24 @@ tbody th {
|
||||
stroke-width: 0.5;
|
||||
}
|
||||
|
||||
.world-map .marker {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.world-map .marker .hit {
|
||||
fill: transparent;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.world-map .marker .dot {
|
||||
stroke: var(--surface);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.world-map .marker:hover .dot {
|
||||
stroke: var(--text);
|
||||
}
|
||||
|
||||
.world-map path:hover {
|
||||
stroke: var(--text);
|
||||
stroke-width: 1;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Net;
|
||||
using Flypaper.Core;
|
||||
using Flypaper.Core.Abstractions;
|
||||
using Flypaper.Core.Models;
|
||||
using Flypaper.Http;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NSubstitute;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Http;
|
||||
|
||||
public sealed class TargetNormalizationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("_", "GET /boaform/admin/formLogin")]
|
||||
[InlineData("", "GET /boaform/admin/formLogin")]
|
||||
[InlineData("example.com", "GET example.com/boaform/admin/formLogin")]
|
||||
[InlineData("203.0.113.7:8080", "GET 203.0.113.7:8080/boaform/admin/formLogin")]
|
||||
public async Task Stores_missing_or_placeholder_host_as_empty(string host, string expectedTarget)
|
||||
{
|
||||
var sink = Substitute.For<ITrapEventSink>();
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?> { ["Flypaper:MaxConnections"] = "0" })
|
||||
.Build();
|
||||
var services = new ServiceCollection()
|
||||
.AddLogging()
|
||||
.AddSingleton(sink)
|
||||
.AddFlypaperCore(configuration)
|
||||
.AddFlypaperHttp(configuration)
|
||||
.BuildServiceProvider();
|
||||
|
||||
var app = new ApplicationBuilder(services);
|
||||
app.UseFlypaper();
|
||||
app.Run(_ => Task.CompletedTask);
|
||||
|
||||
var context = new DefaultHttpContext { RequestServices = services };
|
||||
context.Connection.RemoteIpAddress = IPAddress.Parse("203.0.113.9");
|
||||
context.Connection.LocalPort = 8080;
|
||||
context.Request.Method = "GET";
|
||||
context.Request.Host = new HostString(host);
|
||||
context.Request.Path = "/boaform/admin/formLogin";
|
||||
|
||||
await app.Build()(context);
|
||||
|
||||
sink.Received(1).Publish(Arg.Is<TrapEvent>(e => e.Target == expectedTarget));
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,24 @@ public sealed class MigrationTests : IDisposable
|
||||
(await db.Settings.Select(s => s.Key).ToListAsync()).ShouldBe(["Flypaper:MaxConnections"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Rewrites_placeholder_host_of_existing_trap_events()
|
||||
{
|
||||
await using var db = new FlypaperDbContext(new DbContextOptionsBuilder<FlypaperDbContext>().UseSqlite($"Data Source={_dbPath}").Options);
|
||||
await db.GetService<IMigrator>().MigrateAsync("RemoveDripIntervalSetting");
|
||||
await db.Database.ExecuteSqlRawAsync(
|
||||
"""
|
||||
INSERT INTO "TrapEvents" ("SessionId", "Protocol", "RemoteIp", "Strategy", "StartedAt", "EndedAt", "DurationMs", "BytesSent", "Outcome", "Target")
|
||||
VALUES ('A', 'Http', '203.0.113.9', 'html-drip', '2026-11-14 10:00:00', '2026-11-14 10:00:05', 5000, 50, 'ClientAborted', 'GET _/boaform/admin/formLogin'),
|
||||
('B', 'Http', '203.0.113.9', 'html-drip', '2026-11-14 10:00:00', '2026-11-14 10:00:05', 5000, 50, 'ClientAborted', 'GET example.com/.env')
|
||||
""");
|
||||
|
||||
await db.Database.MigrateAsync();
|
||||
|
||||
(await db.TrapEvents.OrderBy(e => e.SessionId).Select(e => e.Target).ToListAsync())
|
||||
.ShouldBe(["GET /boaform/admin/formLogin", "GET example.com/.env"]);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SqliteConnection.ClearAllPools();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Flypaper.Web.Components.Shared;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Web;
|
||||
|
||||
public sealed class CountryNamesTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("TW", "Republik China", "Taiwan")]
|
||||
[InlineData("CN", "Volksrepublik China", "China")]
|
||||
[InlineData("HK", "Sonderverwaltungszone Hongkong", "Hongkong")]
|
||||
[InlineData("MO", "Sonderverwaltungszone Macau", "Macau")]
|
||||
[InlineData("US", "Vereinigte Staaten von Amerika", "USA")]
|
||||
[InlineData("ru", "Russische Föderation", "Russland")]
|
||||
public void Uses_common_short_names(string code, string official, string expected) =>
|
||||
CountryNames.Display(code, official).ShouldBe(expected);
|
||||
|
||||
[Theory]
|
||||
[InlineData("DE", "Deutschland", "Deutschland")]
|
||||
[InlineData("NL", null, "NL")]
|
||||
[InlineData(null, "Unbekannt", "Unbekannt")]
|
||||
public void Keeps_other_names(string? code, string? name, string expected) =>
|
||||
CountryNames.Display(code, name).ShouldBe(expected);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Flypaper.Web.Components.Shared;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Web;
|
||||
|
||||
public sealed class FormattingTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("GET /boaform/admin/formLogin", "GET (ohne Host)/boaform/admin/formLogin")]
|
||||
[InlineData("GET _/boaform/admin/formLogin", "GET (ohne Host)/boaform/admin/formLogin")]
|
||||
[InlineData("GET _", "GET (ohne Host)")]
|
||||
[InlineData("GET example.com/.env", "GET example.com/.env")]
|
||||
[InlineData("GET _example.com/.env", "GET _example.com/.env")]
|
||||
[InlineData(null, null)]
|
||||
public void Shows_missing_host_explicitly(string? target, string? expected) =>
|
||||
Formatting.Target(target).ShouldBe(expected);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using Flypaper.Web.Components.Pages.Dashboard;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Web;
|
||||
|
||||
public sealed class WorldMapDataTests
|
||||
{
|
||||
private static readonly string[] Iso3166Alpha2 =
|
||||
"""
|
||||
AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ
|
||||
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR
|
||||
GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO
|
||||
JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR
|
||||
MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO
|
||||
RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV
|
||||
TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW
|
||||
""".Split((char[])[' ', '\n', '\r'], StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
private readonly WorldMapData _map = WorldMapData.Instance;
|
||||
|
||||
[Fact]
|
||||
public void Lists_all_249_iso_codes() => Iso3166Alpha2.Distinct().Count().ShouldBe(249);
|
||||
|
||||
[Fact]
|
||||
public void Every_iso_country_has_a_polygon_or_a_marker()
|
||||
{
|
||||
var drawn = _map.Countries.Select(c => c.Code).OfType<string>().Concat(_map.Markers.Select(m => m.Code)).ToHashSet();
|
||||
|
||||
Iso3166Alpha2.Where(code => !drawn.Contains(code)).ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("HK")]
|
||||
[InlineData("SG")]
|
||||
[InlineData("MO")]
|
||||
[InlineData("BH")]
|
||||
[InlineData("MT")]
|
||||
public void Small_bot_heavy_countries_have_markers(string code) =>
|
||||
_map.Markers.ShouldContain(m => m.Code == code);
|
||||
|
||||
[Fact]
|
||||
public void No_country_has_both_a_polygon_and_a_marker()
|
||||
{
|
||||
var polygons = _map.Countries.Select(c => c.Code).OfType<string>().ToHashSet();
|
||||
|
||||
_map.Markers.Where(m => polygons.Contains(m.Code)).ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Markers_lie_inside_the_map() =>
|
||||
_map.Markers.ShouldAllBe(m => m.X >= 0 && m.X <= _map.Width && m.Y >= 0 && m.Y <= _map.Height);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,19 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
|
||||
<title>Flypaper</title>
|
||||
<rect width="256" height="256" rx="48" fill="#14171c"/>
|
||||
<path d="M-38.4,153.1 L290.2,83.3 L303.6,145.9 L-25.1,215.7 Z" fill="#e09a4f"/>
|
||||
<path d="M-38.4,153.1 L290.2,83.3 L291.5,89.2 L-37.2,159.0 Z" fill="#b5651d"/>
|
||||
<path d="M-26.3,209.9 L302.3,140.0 L303.6,145.9 L-25.1,215.7 Z" fill="#b5651d"/>
|
||||
<line x1="116" y1="150" x2="90" y2="168" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<line x1="114" y1="162" x2="88" y2="186" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<line x1="118" y1="172" x2="98" y2="200" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<line x1="140" y1="150" x2="166" y2="168" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<line x1="142" y1="162" x2="168" y2="186" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<line x1="138" y1="172" x2="158" y2="200" stroke="#0e1014" stroke-width="6" stroke-linecap="round"/>
|
||||
<path d="M135.1,94.2 L135.9,95.5 L136.3,97.0 L136.6,98.6 L136.6,100.3 L136.3,102.1 L135.8,104.1 L135.1,106.1 L134.1,108.3 L132.9,110.4 L131.5,112.7 L129.8,114.9 L128.0,117.2 L126.0,119.4 L123.8,121.6 L121.5,123.8 L119.0,125.9 L116.4,128.0 L113.8,129.9 L111.0,131.8 L108.2,133.5 L105.4,135.1 L102.5,136.5 L99.7,137.8 L96.9,139.0 L94.1,139.9 L91.5,140.7 L88.9,141.3 L86.4,141.6 L84.1,141.8 L81.9,141.8 L79.9,141.6 L78.1,141.2 L76.5,140.7 L75.0,139.9 L73.8,138.9 L72.9,137.8 L72.1,136.5 L71.7,135.0 L71.4,133.4 L71.4,131.7 L71.7,129.9 L72.2,127.9 L72.9,125.9 L73.9,123.7 L75.1,121.6 L76.5,119.3 L78.2,117.1 L80.0,114.8 L82.0,112.6 L84.2,110.4 L86.5,108.2 L89.0,106.1 L91.6,104.0 L94.2,102.1 L97.0,100.2 L99.8,98.5 L102.6,96.9 L105.5,95.5 L108.3,94.2 L111.1,93.0 L113.9,92.1 L116.5,91.3 L119.1,90.7 L121.6,90.4 L123.9,90.2 L126.1,90.2 L128.1,90.4 L129.9,90.8 L131.5,91.3 L133.0,92.1 L134.2,93.1 Z" fill="#e4e7ec" fill-opacity="0.6" stroke="#e4e7ec" stroke-width="2"/>
|
||||
<path d="M183.1,137.8 L182.2,138.9 L181.0,139.9 L179.5,140.7 L177.9,141.2 L176.1,141.6 L174.1,141.8 L171.9,141.8 L169.6,141.6 L167.1,141.3 L164.5,140.7 L161.9,139.9 L159.1,139.0 L156.3,137.8 L153.5,136.5 L150.6,135.1 L147.8,133.5 L145.0,131.8 L142.2,129.9 L139.6,128.0 L137.0,125.9 L134.5,123.8 L132.2,121.6 L130.0,119.4 L128.0,117.2 L126.2,114.9 L124.5,112.7 L123.1,110.4 L121.9,108.3 L120.9,106.1 L120.2,104.1 L119.7,102.1 L119.4,100.3 L119.4,98.6 L119.7,97.0 L120.1,95.5 L120.9,94.2 L121.8,93.1 L123.0,92.1 L124.5,91.3 L126.1,90.8 L127.9,90.4 L129.9,90.2 L132.1,90.2 L134.4,90.4 L136.9,90.7 L139.5,91.3 L142.1,92.1 L144.9,93.0 L147.7,94.2 L150.5,95.5 L153.4,96.9 L156.2,98.5 L159.0,100.2 L161.8,102.1 L164.4,104.0 L167.0,106.1 L169.5,108.2 L171.8,110.4 L174.0,112.6 L176.0,114.8 L177.8,117.1 L179.5,119.3 L180.9,121.6 L182.1,123.7 L183.1,125.9 L183.8,127.9 L184.3,129.9 L184.6,131.7 L184.6,133.4 L184.3,135.0 L183.9,136.5 Z" fill="#e4e7ec" fill-opacity="0.6" stroke="#e4e7ec" stroke-width="2"/>
|
||||
<path d="M148.0,152.0 L147.9,155.1 L147.7,158.3 L147.3,161.3 L146.8,164.3 L146.1,167.2 L145.3,170.0 L144.4,172.6 L143.3,175.1 L142.1,177.5 L140.9,179.6 L139.5,181.5 L138.0,183.2 L136.5,184.6 L134.8,185.8 L133.2,186.8 L131.5,187.5 L129.7,187.9 L128.0,188.0 L126.3,187.9 L124.5,187.5 L122.8,186.8 L121.2,185.8 L119.5,184.6 L118.0,183.2 L116.5,181.5 L115.1,179.6 L113.9,177.5 L112.7,175.1 L111.6,172.6 L110.7,170.0 L109.9,167.2 L109.2,164.3 L108.7,161.3 L108.3,158.3 L108.1,155.1 L108.0,152.0 L108.1,148.9 L108.3,145.7 L108.7,142.7 L109.2,139.7 L109.9,136.8 L110.7,134.0 L111.6,131.4 L112.7,128.9 L113.9,126.5 L115.1,124.4 L116.5,122.5 L118.0,120.8 L119.5,119.4 L121.2,118.2 L122.8,117.2 L124.5,116.5 L126.3,116.1 L128.0,116.0 L129.7,116.1 L131.5,116.5 L133.2,117.2 L134.8,118.2 L136.5,119.4 L138.0,120.8 L139.5,122.5 L140.9,124.4 L142.1,126.5 L143.3,128.9 L144.4,131.4 L145.3,134.0 L146.1,136.8 L146.8,139.7 L147.3,142.7 L147.7,145.7 L147.9,148.9 Z" fill="#2a2f38"/>
|
||||
<path d="M145.0,108.0 L144.9,109.3 L144.7,110.6 L144.4,111.9 L144.0,113.1 L143.4,114.3 L142.7,115.5 L141.9,116.6 L141.0,117.6 L140.0,118.6 L138.9,119.5 L137.8,120.3 L136.5,121.0 L135.2,121.6 L133.8,122.1 L132.4,122.5 L131.0,122.8 L129.5,122.9 L128.0,123.0 L126.5,122.9 L125.0,122.8 L123.6,122.5 L122.2,122.1 L120.8,121.6 L119.5,121.0 L118.2,120.3 L117.1,119.5 L116.0,118.6 L115.0,117.6 L114.1,116.6 L113.3,115.5 L112.6,114.3 L112.0,113.1 L111.6,111.9 L111.3,110.6 L111.1,109.3 L111.0,108.0 L111.1,106.7 L111.3,105.4 L111.6,104.1 L112.0,102.9 L112.6,101.7 L113.3,100.5 L114.1,99.4 L115.0,98.4 L116.0,97.4 L117.1,96.5 L118.2,95.7 L119.5,95.0 L120.8,94.4 L122.2,93.9 L123.6,93.5 L125.0,93.2 L126.5,93.1 L128.0,93.0 L129.5,93.1 L131.0,93.2 L132.4,93.5 L133.8,93.9 L135.2,94.4 L136.5,95.0 L137.8,95.7 L138.9,96.5 L140.0,97.4 L141.0,98.4 L141.9,99.4 L142.7,100.5 L143.4,101.7 L144.0,102.9 L144.4,104.1 L144.7,105.4 L144.9,106.7 Z" fill="#2a2f38"/>
|
||||
<path d="M125.0,103.0 L125.0,103.7 L124.9,104.4 L124.8,105.1 L124.6,105.7 L124.3,106.4 L124.1,107.0 L123.7,107.6 L123.4,108.1 L122.9,108.7 L122.5,109.1 L122.0,109.6 L121.5,109.9 L121.0,110.3 L120.4,110.5 L119.8,110.7 L119.2,110.9 L118.6,111.0 L118.0,111.0 L117.4,111.0 L116.8,110.9 L116.2,110.7 L115.6,110.5 L115.0,110.3 L114.5,109.9 L114.0,109.6 L113.5,109.1 L113.1,108.7 L112.6,108.1 L112.3,107.6 L111.9,107.0 L111.7,106.4 L111.4,105.7 L111.2,105.1 L111.1,104.4 L111.0,103.7 L111.0,103.0 L111.0,102.3 L111.1,101.6 L111.2,100.9 L111.4,100.3 L111.7,99.6 L111.9,99.0 L112.3,98.4 L112.6,97.9 L113.1,97.3 L113.5,96.9 L114.0,96.4 L114.5,96.1 L115.0,95.7 L115.6,95.5 L116.2,95.3 L116.8,95.1 L117.4,95.0 L118.0,95.0 L118.6,95.0 L119.2,95.1 L119.8,95.3 L120.4,95.5 L121.0,95.7 L121.5,96.1 L122.0,96.4 L122.5,96.9 L122.9,97.3 L123.4,97.9 L123.7,98.4 L124.1,99.0 L124.3,99.6 L124.6,100.3 L124.8,100.9 L124.9,101.6 L125.0,102.3 Z" fill="#b3261e"/>
|
||||
<path d="M145.0,103.0 L145.0,103.7 L144.9,104.4 L144.8,105.1 L144.6,105.7 L144.3,106.4 L144.1,107.0 L143.7,107.6 L143.4,108.1 L142.9,108.7 L142.5,109.1 L142.0,109.6 L141.5,109.9 L141.0,110.3 L140.4,110.5 L139.8,110.7 L139.2,110.9 L138.6,111.0 L138.0,111.0 L137.4,111.0 L136.8,110.9 L136.2,110.7 L135.6,110.5 L135.0,110.3 L134.5,109.9 L134.0,109.6 L133.5,109.1 L133.1,108.7 L132.6,108.1 L132.3,107.6 L131.9,107.0 L131.7,106.4 L131.4,105.7 L131.2,105.1 L131.1,104.4 L131.0,103.7 L131.0,103.0 L131.0,102.3 L131.1,101.6 L131.2,100.9 L131.4,100.3 L131.7,99.6 L131.9,99.0 L132.3,98.4 L132.6,97.9 L133.1,97.3 L133.5,96.9 L134.0,96.4 L134.5,96.1 L135.0,95.7 L135.6,95.5 L136.2,95.3 L136.8,95.1 L137.4,95.0 L138.0,95.0 L138.6,95.0 L139.2,95.1 L139.8,95.3 L140.4,95.5 L141.0,95.7 L141.5,96.1 L142.0,96.4 L142.5,96.9 L142.9,97.3 L143.4,97.9 L143.7,98.4 L144.1,99.0 L144.3,99.6 L144.6,100.3 L144.8,100.9 L144.9,101.6 L145.0,102.3 Z" fill="#b3261e"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.6 KiB |
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<Container version="2">
|
||||
<Name>Flypaper</Name>
|
||||
<Repository>gitea.anticarnist.de/tom/flypaper:latest</Repository>
|
||||
<Registry>https://gitea.anticarnist.de/Tom/-/packages/container/flypaper</Registry>
|
||||
<Network>bridge</Network>
|
||||
<MyIP/>
|
||||
<Shell>bash</Shell>
|
||||
<Privileged>false</Privileged>
|
||||
<Support>https://gitea.anticarnist.de/Tom/Flypaper/issues</Support>
|
||||
<Project>https://gitea.anticarnist.de/Tom/Flypaper</Project>
|
||||
<Overview>Self-hosted tarpit that traps and slows down scanning bots, with event logging and analysis. Instead of blocking bots, Flypaper answers them with an endless HTML page that trickles in a few bytes at a time, and logs every catch with its country and network provider.[br][br]
|
||||
The trap port receives everything your reverse proxy has no site for (its catch-all / default server) and, optionally, bait paths such as /.env from your real domains. The dashboard has its own port: keep it inside your LAN. On first visit you set the admin password.[br][br]
|
||||
The container starts as root only to hand the appdata folder to its app user (UID 1654), then drops privileges for good.</Overview>
|
||||
<Category>Security: Network:Proxy</Category>
|
||||
<WebUI>http://[IP]:[PORT:8081]/</WebUI>
|
||||
<TemplateURL>https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.xml</TemplateURL>
|
||||
<Icon>https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.png</Icon>
|
||||
<ExtraParams>--user 0:0</ExtraParams>
|
||||
<PostArgs/>
|
||||
<CPUset/>
|
||||
<DateInstalled/>
|
||||
<DonateText/>
|
||||
<DonateLink/>
|
||||
<Requires/>
|
||||
<Config Name="Trap port" Target="8080" Default="8080" Mode="tcp" Description="Point your reverse proxy's catch-all / default server here. Every request on this port is trapped." Type="Port" Display="always" Required="true" Mask="false">8080</Config>
|
||||
<Config Name="Dashboard port" Target="8081" Default="8081" Mode="tcp" Description="Dashboard and settings. Keep this port inside your LAN and never forward it from your public proxy." Type="Port" Display="always" Required="true" Mask="false">8081</Config>
|
||||
<Config Name="Data" Target="/data" Default="/mnt/user/appdata/flypaper" Mode="rw" Description="Database, login keys and GeoIP databases." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/flypaper</Config>
|
||||
<Config Name="Admin password" Target="Flypaper__Admin__Password" Default="" Mode="" Description="Optional. Fixes the dashboard password and disables the first-visit setup. Leave empty to set it in the dashboard." Type="Variable" Display="advanced" Required="false" Mask="true"/>
|
||||
<Config Name="Trusted proxy" Target="Flypaper__Http__TrustedProxies__0" Default="" Mode="" Description="Optional. IP or CIDR of the reverse proxy allowed to set X-Real-IP / X-Forwarded-For. Default: all private networks." Type="Variable" Display="advanced" Required="false" Mask="false"/>
|
||||
<Config Name="Known host" Target="Flypaper__Http__KnownHosts__0" Default="" Mode="" Description="Optional. A host that is caught only on trap paths; its other paths get a plain 404." Type="Variable" Display="advanced" Required="false" Mask="false"/>
|
||||
</Container>
|
||||
Reference in new issue
Block a user