# 耶尔森菌（软件）

**耶尔森菌**（Yersinia）是一个用于实施二层攻击的开源框架，旨在利用交换网络中运行于数据链路层的网络协议的弱点。它用于分析和测试已部署的网络与系统，附带 [GTK](https://www.edgepedia.org/zh/gtk) 图形界面、ncurses 终端界面，以及一种通过 Cisco CLI 模拟提供远程管理的守护进程模式。<sup>[1](https://packages.debian.org/sid/yersinia)</sup><sup> • </sup><sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup> 该工具由 David·Barroso 与 Alfredo Andrés 编写，以 GNU 通用公共许可证第 2 版发布，并在 Debian、Ubuntu、[Kali Linux](https://www.edgepedia.org/zh/kali-linux) 和 Fedora EPEL 中分发。<sup>[3](https://gitextract.com/tomac/yersinia)</sup><sup> • </sup><sup>[4](https://packages.ubuntu.com/yersinia)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 针对交换网络协议的二层攻击框架<sup>[1](https://packages.debian.org/sid/yersinia)</sup> |
| 覆盖协议 | STP 与 RSTP、CDP、HSRP、DHCP、DTP、IEEE 802.1Q、IEEE 802.1X、ISL、VTP 和 MPLS<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup> |
| 界面 | GTK 图形界面（`-G`）、ncurses 交互会话（`-I`）、通过 Cisco CLI 模拟提供远程管理的守护进程（`-D`）<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup> |
| 作者 | David·Barroso（tomac）与 Alfredo Andrés<sup>[3](https://gitextract.com/tomac/yersinia)</sup> |
| 许可证 | GNU 通用公共许可证第 2 版<sup>[3](https://gitextract.com/tomac/yersinia)</sup> |
| 最新版本 | 0.8.2，日期 2017/08/24<sup>[3](https://gitextract.com/tomac/yersinia)</sup> |
| 依赖 | libpcap 至少 0.8、libnet 至少 1.1.2、图形界面需 GTK 至少 2.6.0<sup>[5](https://github.com/tomac/yersinia/blob/master/INSTALL)</sup> |
| 分发 | Debian（sid 中为 0.8.2-2.4）、Ubuntu、Kali Linux、Fedora EPEL<sup>[1](https://packages.debian.org/sid/yersinia)</sup><sup> • </sup><sup>[4](https://packages.ubuntu.com/yersinia)</sup><sup> • </sup><sup>[6](https://pkg.kali.org/pkg/yersinia/news/)</sup> |

## 历史

该项目最初是一个名为 STomP 的工具。其变更日志记录了最初的 0.1.0 版本、一个包含两种拒绝服务攻击和一种非 DoS 攻击并支持多网卡的 0.2.0 版本，以及一个日期为 2003/01/15、增加了线程支持的 0.3.0 版本。2004/02/06，名称从 STomP 改为耶尔森菌，STP 攻击函数也从 `attack_*` 重命名为 `attack_stp_*`。<sup>[3](https://gitextract.com/tomac/yersinia)</sup>

该名称来自*鼠疫耶尔森菌*（*Yersinia pestis*），即引起鼠疫的细菌。<sup>[3](https://gitextract.com/tomac/yersinia)</sup> 作者在 Black Hat Europe 2005 上以“耶尔森菌，一个二层攻击框架”为题介绍了该工具，演讲者为 Berrueta 与 Andrés，其中逐一讲解了针对 STP、DHCP、HSRP、DTP 及相关协议的攻击与缓解措施。<sup>[7](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)</sup>

开发缓慢但并未停滞。0.8.2 版于 2017/08/24 发布，修复了 IP 地址使用颠倒的问题，上游源码现位于 GitHub 的 tomac/yersinia。<sup>[3](https://gitextract.com/tomac/yersinia)</sup> 各分发版的维护者一直保持软件包更新：Debian 于 2023 年 11 月接受了 0.8.2-2.2，于 2025 年 11 月接受了 0.8.2-2.3（修复了该软件包在 GCC 14 下构建失败的问题，缺陷编号 #1075697），并于 2026 年 6 月接受了 0.8.2-2.4；Kali Linux 于 2026-06-29 将 0.8.2-2.4 导入 kali-rolling。<sup>[8](https://tracker.debian.org/pkg/yersinia/news/)</sup><sup> • </sup><sup>[9](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075697)</sup><sup> • </sup><sup>[6](https://pkg.kali.org/pkg/yersinia/news/)</sup> Debian 软件包由 Noël Köthe 维护。<sup>[1](https://packages.debian.org/sid/yersinia)</sup>

## 协议与攻击

当前版本为十种协议实现了攻击与分析模块：[生成树协议](https://www.edgepedia.org/zh/spanning-tree-protocol)（STP 与 RSTP）、Cisco 发现协议（CDP）、热备份路由器协议（HSRP）、[动态主机配置协议](https://www.edgepedia.org/zh/dynamic-host-configuration-protocol)（DHCP）、动态中继协议（DTP）、[IEEE 802.1Q](https://www.edgepedia.org/zh/ieee-802-1q)、IEEE 802.1X、交换机间链路协议（ISL）、VLAN 中继协议（VTP）和多协议标签交换（MPLS）。<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup> 手册页指出，已实现的攻击中有些会造成网络拒绝服务，有些有助于实施更高级的攻击，还有些两者兼有，并警告 DoS 攻击可能使网络处于不稳定状态。<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup>

**生成树攻击。** 项目文档描述了六种 STP 攻击。在根桥声明攻击中，耶尔森菌监听网络以识别当前根桥，然后发送优先级更低的配置 BPDU 以夺取根角色。一种相关的[拒绝服务攻击](https://www.edgepedia.org/zh/denial-of-service-attack)发送优先级自动递减的配置 BPDU，迫使 STP 树中发生无限的根选举。另一种攻击使用随机生成的源 MAC 持续发送拓扑变更通知（TCN）BPDU，使根交换机确认该变更，并让树中每个成员重新计算其 STP 引擎。还有一种攻击先成为根，然后停止发送 BPDU，直到最大老化计时器（通常为 20 秒）到期，从而迫使反复选举。<sup>[10](https://github.com/tomac/yersinia)</sup>《LAN Switch Security》一书描述了根桥声明变体的实际运作：耶尔森菌每 2 秒发送一个 BPDU，其优先级与当前根桥相同，但 [MAC 地址](https://www.edgepedia.org/zh/mac-address)在数值上略低，从而赢得根桥选举。<sup>[11](https://s1.sargarmi.af/drive1/Library/F7/LAN%20Switch%20Security%20-%20What%20Hackers%20Know%20About%20Your%20Switches-sargarmi.af.pdf)</sup> 这些攻击要求所连接的端口不过滤 BPDU，因此攻击者可以先进行侦察，再构造能赢得选举的 BPDU。<sup>[12](https://sar.ac.id/stmik_ebook/prog_file_file/DEEGEJU4Lj.pdf)</sup>

**CDP 攻击。** 针对 Cisco 发现协议，该工具可以向网络泛洪携带伪造数据的 CDP 包，模拟真实的 Cisco 设备。目标设备会为其 CDP 表中的每个新“邻居”分配内存，文档展示了一台 Cisco 路由器在泛洪下耗尽处理器内存（%SYS-2-MALLOCFAIL 消息）。第二种已实现的攻击建立一个虚拟 Cisco 设备，意在迷惑网络管理员。<sup>[10](https://github.com/tomac/yersinia)</sup>

**DHCP 与 HSRP 攻击。** 对于 DHCP，Black Hat 演讲展示了一种恶意 DHCP 服务器攻击，攻击者比合法服务器更快地应答客户端请求，并在 DHCP 提供报文中将网关地址设为攻击者的地址，使客户端流量流经攻击者，形成中间人位置。<sup>[7](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)</sup> 一篇使用该工具的论文将其 DHCP 攻击选项列为：发送原始包、发送 DISCOVER 包、创建 DHCP 恶意服务器和发送 RELEASE 包。<sup>[13](https://www.diva-portal.org/smash/get/diva2%3A1667487/FULLTEXT01.pdf)</sup> 对于默认使用明文认证（默认口令为“cisco”）并向 UDP 端口 1985 发送数据报的 HSRP，耶尔森菌可以发送原始 HSRP 包，并以伪造 IP 地址或攻击者的真实 IP 地址成为活动节点，从而使攻击者处于中间人位置。<sup>[7](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)</sup>

## 界面与操作

耶尔森菌从命令行运行，使用模式标志：`-G` 启动 GTK 图形会话，`-I` 启动交互式 ncurses 会话，`-D` 启动用于远程管理的网络监听器，后者模拟 Cisco CLI。其他选项包括 `-M` 禁用 MAC 欺骗、`-l` 将会话记录到文件，以及 `-c` 从文件读写配置变量。<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup> 在 GTK 界面中，左侧窗格列出协议及包计数器（例如 CDP、DHCP、802.1Q、802.1X、DTP、HSRP、ISL、MPLS、STP），工具栏提供发起攻击、编辑网卡、捕获流量和清除统计信息的功能。<sup>[14](https://nostarch.com/download/samples/PracticalIoTHacking_ch04_sample.pdf)</sup> 每种协议模式都显示详细的包字段；对于 STP，这些字段包括 BPDU 版本（0 为 STP，2 为 RSTP，3 为 MSTP）、BPDU 类型、桥与根标识、路径开销、问候时间（默认 2 秒）、最大老化时间（默认 20 秒）和转发延迟。<sup>[2](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)</sup>

该程序在类 Unix 系统上构建，依赖 libpcap 包捕获库（至少 0.8 版）和 libnet 包构造库（至少 1.1.2 版）；GTK 2 界面要求 GTK 至少 2.6.0 版。INSTALL 文件列出了测试过的系统，包括 Linux 2.4.x 和 2.6.x、OpenBSD 3.4、Solaris 5.8 64 位 SPARC 和 FreeBSD 5.2.1，并指出该软件不能在 Windows 上运行。<sup>[5](https://github.com/tomac/yersinia/blob/master/INSTALL)</sup><sup> • </sup><sup>[3](https://gitextract.com/tomac/yersinia)</sup>

## 缓解措施

项目文档为每一类攻击配以交换机侧的防御措施，主要取自 Cisco 的指导。针对 STP 攻击，建议使用端口安全并在不需要 STP 的端口上禁用 STP，在 PortFast 端口上启用 BPDU 防护，使进入转发状态的端口无法参与这些攻击，并使用根防护功能防止恶意设备成为根。<sup>[10](https://github.com/tomac/yersinia)</sup> 针对恶意 DHCP 服务器，建议使用 DHCP 监听，它将接口指定为可信或不可信，以确定哪些接口可以应答 DHCP 请求。<sup>[7](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)</sup> Cisco 自己的文档解释了该机制：DHCP 监听验证来自不可信源的消息、限制 DHCP 流量速率，并建立租用地址的绑定数据库，动态 ARP 检查等下游功能利用该数据库验证 ARP 包。<sup>[15](https://www.cisco.com/c/en/us/support/docs/switches/lan-switch-software/222274-troubleshoot-dynamic-arp-inspection-dai.html)</sup> 针对 HSRP 接管，推荐的缓解措施是 MD5 认证（自 [IOS 12](https://www.edgepedia.org/zh/ios-12).3(2)T 起可用）和 IPsec。<sup>[7](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)</sup>

## 评价与使用

安全文献将耶尔森菌视为二层测试的标准参考工具。《LAN Switch Security》一书称其为“二层黑客的瑞士军刀”，是攻击包括 STP 在内的多种二层协议的工具。<sup>[16](https://victek.org/Repositorios/Redes/LAN%20Security_%20Cisco.pdf)</sup> 一本面向 Cisco 的工程手册用它演示 DTP 和 STP 攻击，并指出其 GTK 图形界面被用于攻击演练。<sup>[12](https://sar.ac.id/stmik_ebook/prog_file_file/DEEGEJU4Lj.pdf)</sup> 另一本网络著作将其描述为测试二层安全的最佳免费工具之一。<sup>[17](https://ptgmedia.pearsoncmg.com/images/9780132566452/samplepages/0132566451.pdf)</sup> 它被打包在 Kali Linux 中，作为分析和测试已部署网络安全性的工具呈现给渗透测试人员和网络管理员。<sup>[6](https://pkg.kali.org/pkg/yersinia/news/)</sup><sup> • </sup><sup>[18](https://www.toolkitly.com/compare-ai-tools/674-705/668/yersinia-vs-intrace)</sup>

该工具在某些方面也显露出老态。由于上游开发在 2017 年后暂停，而各分发版针对更新的工具链重新构建它，用户报告了诸如 GTK 图形界面在近期 Kali 和 Ubuntu 发行版上无法启动的问题，yersinia.log 中记录了 `pcap_open_live` 失败。<sup>[19](https://github.com/tomac/yersinia/issues/86)</sup> Debian 的 GCC 14 构建失败直到 2025 年 11 月的软件包修订才得以解决。<sup>[9](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075697)</sup>

## References

1. [Debian -- Details of package yersinia in sid](https://packages.debian.org/sid/yersinia)
2. [Ubuntu Manpage: Yersinia - A Framework for layer 2 attacks](https://manpages.ubuntu.com/manpages/stonking/man8/yersinia.8.html)
3. [Full Code of tomac/yersinia (changelog, FAQ, license), GitExtract](https://gitextract.com/tomac/yersinia)
4. [Ubuntu – Package Search Results: yersinia](https://packages.ubuntu.com/yersinia)
5. [yersinia/INSTALL at master, tomac/yersinia, GitHub](https://github.com/tomac/yersinia/blob/master/INSTALL)
6. [Kali Linux Package Tracker: News for package yersinia](https://pkg.kali.org/pkg/yersinia/news/)
7. [Berrueta, D., Andrés, A. (2005). Yersinia, a framework for layer 2 attacks. Black Hat Europe.](https://blackhat.com/presentations/bh-europe-05/BH_EU_05-Berrueta_Andres/BH_EU_05_Berrueta_Andres.pdf)
8. [Debian Package Tracker: News for package yersinia](https://tracker.debian.org/pkg/yersinia/news/)
9. [Bug#1075697: yersinia: ftbfs with GCC-14, Debian Bug report logs](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075697)
10. [tomac/yersinia: A framework for layer 2 attacks, GitHub](https://github.com/tomac/yersinia)
11. [LAN Switch Security: What Hackers Know About Your Switches (sample)](https://s1.sargarmi.af/drive1/Library/F7/LAN%20Switch%20Security%20-%20What%20Hackers%20Know%20About%20Your%20Switches-sargarmi.af.pdf)
12. [Cisco Networks: Engineers' Handbook of Routing, Switching, and Security](https://sar.ac.id/stmik_ebook/prog_file_file/DEEGEJU4Lj.pdf)
13. [Table 4.2: Software used during the third test, DiVA portal thesis](https://www.diva-portal.org/smash/get/diva2%3A1667487/FULLTEXT01.pdf)
14. [Practical IoT Hacking, sample chapter (No Starch Press)](https://nostarch.com/download/samples/PracticalIoTHacking_ch04_sample.pdf)
15. [Troubleshoot Dynamic ARP Inspection (DAI) and IP Source Guard (IPSG) in Catalyst Switches, Cisco](https://www.cisco.com/c/en/us/support/docs/switches/lan-switch-software/222274-troubleshoot-dynamic-arp-inspection-dai.html)
16. [LAN Switch Security (Cisco Press), PDF](https://victek.org/Repositorios/Redes/LAN%20Security_%20Cisco.pdf)
17. [Layer 2 attack-tool reference, Pearson sample pages (9780132566451)](https://ptgmedia.pearsoncmg.com/images/9780132566452/samplepages/0132566451.pdf)
18. [Yersinia vs Intrace, Toolkitly](https://www.toolkitly.com/compare-ai-tools/674-705/668/yersinia-vs-intrace)
19. [yersinia's GUI (-G) doesn't launch anymore, Issue #86, tomac/yersinia, GitHub](https://github.com/tomac/yersinia/issues/86)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Network monitoring and analysis tools

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/yersinia-software

English original: https://www.edgepedia.org/yersinia-software
