austin-weeks/miasma

GitHub: austin-weeks/miasma

Miasma 是一个Rust编写的工具,通过发送毒化数据陷阱AI网络爬虫,保护网站内容免受恶意抓取。

Stars: 1089 | Forks: 24

# 🌀 Miasma [![无 AI](https://custom-icon-badges.demolab.com/badge/No%20AI-2f2f2f?logo=non-ai&logoColor=white&logoSize=auto)](#) [![crates.io](https://img.shields.io/crates/v/miasma?logo=rust)](https://crates.io/crates/miasma) [![下载量](https://img.shields.io/crates/dr/miasma?logo=rust)](https://crates.io/crates/miasma) [![Crate 依赖](https://img.shields.io/deps-rs/miasma/latest?logo=rust)](https://crates.io/crates/miasma/0.1.15/dependencies) [![发布](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/0c8b2ccf93174914.svg)](https://github.com/austin-weeks/miasma/actions/workflows/Release.yaml) [![最新发布以来的 GitHub 提交数](https://img.shields.io/github/commits-since/austin-weeks/miasma/latest?logo=github)](#) Web crawlers getting stuck in a cloud of poison miasma. AI 公司以庞大的规模不断抓取互联网内容,将其全部吞没用作其下个模型的训练数据。如果你拥有一个公开网站,_他们已经在窃取你的作品了。_ _Miasma_ 来帮你反击!启动服务器并将所有恶意流量指向它。_Miasma_ 将从 [毒泉](https://rnsaffn.com/poison3) 发送投毒的训练数据,并附带多个自引用链接。对于这些垃圾机器来说,这简直是一场无穷无尽的残羹盛宴。 _Miasma_ 速度极快且内存占用极小——你不必浪费计算资源来抵御互联网的吸血鬼。 ## 使用方法 你可以在本地运行 _Miasma_,或使用官方 [Docker 镜像](https://hub.docker.com/r/austinweeks/miasma)。 ### 本地运行 使用 [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) 安装(推荐): ``` cargo install miasma ``` 或者,从 [发布页面](https://github.com/austin-weeks/miasma/releases) 下载预构建的二进制文件。 Packaging status

使用默认配置启动 _Miasma_: ``` miasma ``` 查看所有可用 [配置选项](#configuration): ``` miasma --help ``` ### 使用 Docker 运行 使用官方 [Docker 镜像](https://hub.docker.com/r/austinweeks/miasma) 运行 _Miasma_: ``` docker run --rm -p 9999:9999 austinweeks/miasma:latest ``` 传递与在本地使用时相同的 [配置标志](#configuration): ``` docker run --rm -p 9999:9999 austinweeks/miasma:latest \ --link-prefix '/naughty-bots' \ --max-in-flight 30 ``` 或者,在 Docker Compose 集群中运行: ``` services: miasma: image: austinweeks/miasma:latest command: ["--link-prefix", "/naughty-bots", "--max-in-flight", "30"] ports: - 9999:9999 ``` ## 如何诱捕抓取器 让我们通过一个例子来讲解如何使用 _Miasma_ 设置一个服务器来诱捕抓取器。我们选择 `/naughty-bots` 作为服务器路径来引导抓取器流量。我们将使用 [_Nginx_](https://nginx.org/) 作为服务器的反向代理,但通过其他多种设置也可以达到相同的效果。 完成后,抓取器将像这样被诱捕:

Flow chart depicting cycle of trapped scrapers.

### 嵌入隐藏链接 在我们的网站内,我们将包含几个指向 `/naughty-bots` 的隐藏链接。 ``` ``` `style="display: none;"`、`aria-hidden="true"` 和 `tabindex="-1"` 属性确保链接对人类访客完全不可见,并且会被屏幕阅读器和键盘导航忽略。它们**仅**对抓取器可见。 ### 配置我们的 Nginx 代理 由于我们的隐藏链接指向 `/naughty-bots`,我们将配置此路径来代理 _Miasma_。假设我们在端口 `9855` 上运行 _Miasma_。 我们还将基于抓取器的用户代理设置激进的速率限制,以帮助确保我们不会意外地对自己进行 DDoS 攻击。 ``` http { # Reserve 8MB memory for tracking user agents limit_req_zone $http_user_agent zone=miasma:8m rate=1r/s; server { location ~ ^/naughty-bots($|/.*)$ { # Rate limit via the 'miasma' zone with no 429 delay limit_req_status 429; limit_req zone=miasma burst=5 nodelay; # Proxy requests to Miasma proxy_pass http://localhost:9855; } } } ``` 这将匹配 `/naughty-bots` 路径的所有变体 -> `/naughty-bots`、`/naughty-bots/`、`/naughty-bots/12345` 等。 ### 运行 _Miasma_ 最后,我们将启动 _Miasma_ 并指定 `/naughty-bots` 作为链接前缀。这指示 _Miasma_ 以 `/naughty-bots/` 开头生成链接,确保抓取器通过我们的 _Nginx_ 代理被正确路由回 _Miasma_。 让我们将最大并发连接数限制为 50。在 50 个连接时,我们可以预期峰值内存使用量为 50-60 MB。请注意,超过此限制的任何请求将立即收到 **429** 响应,而不是加入队列。 我们还将强制 _Miasma_ 对所有响应进行 gzip 压缩,而不管抓取器的 `Accept-Encoding` 头如何。由于 gzip 压缩的响应明显更小,这将有助于我们降低出口成本。 虽然我们可以将抓取器永远困住,但我们将使用链接计数和最大深度选项,让抓取器在消耗约 10 万个投毒页面后离开。通过此设置,每个抓取器总共将收到大约 **250MB** 的数据。 ``` miasma --link-prefix '/naughty-bots' -p 9855 -c 50 --force-gzip --link-count 5 --max-depth 8 ``` ### 尽情享受! 让我们部署并观察行为不当的机器人贪婪地从我们无穷无尽的垃圾机器中进食!

### `robots.txt` 务必通过你的 [`robots.txt`](https://developers.google.com/search/docs/crawling-indexing/robots/intro) 保护行为良好的机器人和搜索引擎免受 _Miasma_ 影响! ``` User-agent: * Disallow: /naughty-bots ``` ## 配置 _Miasma_ 可以通过其 CLI 选项进行配置: | 选项 | 默认值 | 描述 | | ------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `port` | `9999` | 服务器应绑定的端口。 | | `host` | `localhost` | 服务器应绑定的主机地址。 | | `unix-socket` | | 绑定到 Unix 域套接字而不是 TCP 地址。_仅在类 Unix 系统上可用。_ | | `max-in-flight` | `500` | 允许的最大并发请求数。超过并发限制时收到的请求将收到 _429_ 响应。**_Miasma_ 的内存使用量随并发请求数线性增长 - 如果关注内存使用,请将此值设置得较低。** | | `link-prefix` | `/` | 自指向链接的前缀。这应该是你托管 _Miasma_ 的路径,例如 `/naughty-bots`。 | | `link-count` | `5` | 每个响应页面中包含的自指向链接数量。 | | `max-depth` | `none` | 当抓取器达到指定深度后停止生成链接。这允许你在提供所需数量的投毒数据后切断抓取器。_与 `link-count` 结合使用,可以将活动抓取器的数量保持在可管理的水平。_ | | `force-gzip` | `false` | 无论客户端的 _Accept-Encoding_ 头如何,始终对响应进行 gzip 压缩。**强制压缩有助于降低出口成本。** | | `unsafe-allow-html` | `false` | 不转义投毒源响应中的 HTML 字符。默认启用转义以防止意外的客户端 JavaScript 执行。**请谨慎使用此选项。** | | `poison-source` | `https://rnsaffn.com/poison2/` | 投毒训练数据的代理源。 | ## 免责声明 _Miasma_ 与 [毒泉](https://rnsaffn.com/poison3) 无关。我们无法控制其响应内容,也无法保证其内容的安全性。你**绝不应**将用户引导至你的 _Miasma_ 位置。 _Miasma_ 对受影响抓取器运营商的任何报复行为概不负责。遵守适用法律和托管服务提供商政策是你的责任。参见 [LICENSE](LICENSE) (GPL-v3) 了解完整的保证和责任限制详情。 _封面艺术由 [@cerberussaturn07](https://www.instagram.com/cerberussaturn07/) 创作_
标签:AI对抗, AI训练数据保护, Docker, ProjectDiscovery, Rust, Web安全, 反爬虫, 可视化界面, 安全防御评估, 数据保护, 数据毒化, 数据污染, 爬虫陷阱, 网络安全, 网络流量审计, 网络蜜罐, 蓝队分析, 训练数据干扰, 请求拦截, 轻量级服务器, 通知系统, 隐私保护