整合
流量產生器是多層示範環境中的一個元件。部署所有元件後的完整架構如下:
Traffic Generator -> F5 XC HTTP LB (WAF/Bot/API/CSD) -> Origin Server | CDN Simulator (optional)graph LR
TG[Traffic Generator VM] -->|Attack Traffic<br/>HTTPS| XCHLB[F5 XC HTTP LB]
XCHLB -->|WAF / Bot / API / CSD| ORIGIN[Origin Server VM<br/>Juice Shop, DVWA,<br/>VAmPI, httpbin, whoami]
CDN[CDN Simulator<br/>optional] -->|Cached Requests| XCHLB
TG -.->|Direct Baseline<br/>HTTP optional| ORIGIN每個元件均透過 Terraform 獨立部署與設定。流量產生器以 F5 XC 負載平衡器的 FQDN 為目標,而非直接指向來源伺服器。
來源伺服器整合
Section titled “來源伺服器整合”來源伺服器提供流量產生器攻擊套件所目標的後端應用程式:
| 流量套件 | 來源應用程式 | 路徑 |
|---|---|---|
| api-attacks | VAmPI | /vampi/ |
| bot-simulation | 所有應用程式 | 所有路徑 |
| cdn-load-testing | CDN 模擬器 | CDN 端點 |
| crapi-exploits | crAPI | /crapi/ |
| csd-demo-attacks | CSD 示範 | /csd-demo/ |
| dvga-exploits | DVGA | /dvga/ |
| dvwa-exploits | DVWA | /dvwa/ |
| javascript-exploits | CSD 示範 | /csd-demo/ |
| juice-shop-exploits | Juice Shop | /juice-shop/ |
| mitre-attack | 所有應用程式 | 所有路徑 |
| owasp-scanning | 所有應用程式 | 所有路徑 |
| performance-testing | 所有應用程式 | 所有路徑 |
| reconnaissance | 所有應用程式 | 所有路徑 |
| restaurant-exploits | Restaurant API | /restaurant/ |
| ssl-scanning | F5 XC LB(非直接指向來源) | N/A |
| traffic-generation | 所有應用程式 | 所有路徑 |
| web-app-attacks | Juice Shop、DVWA | /juice-shop/、/dvwa/ |
- 首先部署來源伺服器 — 它提供後端應用程式
- 以來源伺服器作為來源池,設定 F5 XC HTTP 負載平衡器
- 將 WAF、Bot Defense、API Security 及 CSD 政策附加至負載平衡器
- 部署流量產生器,並將
target_fqdn設定為 F5 XC LB 網域
流量產生器的 config.env 將其連接至其餘架構:
# Target the F5 XC load balancer (traffic passes through security policies)TARGET_FQDN=demo.example.com
# Optional: target the origin server directly (bypasses F5 XC)TARGET_ORIGIN_IP=20.10.5.100設定 TARGET_FQDN 後,所有套件腳本均會將流量傳送至 https://<TARGET_FQDN>/...。F5 XC 負載平衡器接收請求後,套用安全政策,並將允許的流量轉送至來源伺服器。
CSD 示範整合
Section titled “CSD 示範整合”javascript-exploits 套件專為來源伺服器上的用戶端防禦(Client-Side Defense)示範而設計,用於驗證 CSD 第二階段功能:
第二階段流程:
- 來源伺服器在
/csd-demo/路徑托管 CSD 示範頁面 - F5 XC CSD 將其監控 JavaScript 注入頁面
- 流量產生器的 javascript-exploits 套件嘗試:
- 注入模擬 Magecart 側錄程式的內嵌腳本
- 修改 DOM 元素以重新導向表單提交
- 載入未經授權的第三方 JavaScript
- F5 XC CSD 偵測到這些修改後,在 CSD 儀表板中回報
使用 javascript-exploits 套件的方式:
# Ensure CSD is enabled on the F5 XC HTTP LB for the /csd-demo/ path# Then run the suite/opt/traffic-generator/suites/runner.sh javascript-exploitsCDN 模擬器整合
Section titled “CDN 模擬器整合”部署 CDN 模擬器後,架構將新增快取層:
Traffic Generator -> CDN Simulator -> F5 XC HTTP LB -> Origin ServerCDN 模擬器位於 F5 XC 負載平衡器前端,負責快取回應並新增類 CDN 標頭。若要透過 CDN 傳送流量:
# Set TARGET_FQDN to the CDN Simulator's endpoint instead of F5 XC directlyTARGET_FQDN=cdn.demo.example.com此設定有助於示範 F5 XC 如何處理透過 CDN 傳入的流量,包括:
- 識別 CDN 代理標頭背後的真實用戶端 IP
- 對可能已被 CDN 修改的請求套用 WAF 規則
- 當 CDN 修改瀏覽器指紋時的 Bot Defense 分類
直接流量與負載平衡器流量比較
Section titled “直接流量與負載平衡器流量比較”流量產生器支援同時透過 F5 XC 及直接向來源傳送流量。此比較可示範 F5 XC 安全功能的價值:
透過 F5 XC(預設)
Section titled “透過 F5 XC(預設)”# Traffic goes: Generator -> F5 XC LB -> OriginTARGET_FQDN=demo.example.com /opt/traffic-generator/suites/runner.sh web-app-attacks預期結果:WAF 封鎖 SQL 注入、XSS 及命令注入酬載。安全事件儀表板顯示已封鎖的請求及違規詳情。
直接傳送至來源(基準)
Section titled “直接傳送至來源(基準)”# Traffic goes: Generator -> Origin (no security layer)TARGET_FQDN=20.10.5.100 /opt/traffic-generator/suites/runner.sh web-app-attacks預期結果:所有酬載不經過濾直接到達來源應用程式。Juice Shop 及 DVWA 處理攻擊酬載。此情形示範缺乏 F5 XC 保護時的結果。
並排示範流程
Section titled “並排示範流程”若要呈現具說服力的示範,請以兩種方式執行相同套件:
- 直接對來源執行
web-app-attacks— 顯示攻擊成功 - 透過 F5 XC 執行
web-app-attacks— 顯示攻擊被封鎖 - 開啟 F5 XC 安全事件儀表板以顯示已封鎖的請求
- 比較套件的
meta.json結果:直接執行顯示較多「passed」(攻擊成功),透過負載平衡器執行顯示較多「failed」(攻擊被封鎖)
TGEN_IP=$(terraform output -raw public_ip)ORIGIN_IP="20.10.5.100"LB_FQDN="demo.example.com"
# Run 1: Direct (baseline)ssh azureuser@${TGEN_IP} "TARGET_FQDN=${ORIGIN_IP} /opt/traffic-generator/suites/runner.sh web-app-attacks"
# Run 2: Through F5 XCssh azureuser@${TGEN_IP} "TARGET_FQDN=${LB_FQDN} /opt/traffic-generator/suites/runner.sh web-app-attacks"
# Compare resultsssh azureuser@${TGEN_IP} 'for d in $(ls -t /opt/traffic-generator/results/ | head -2); do echo "=== $d ==="; cat /opt/traffic-generator/results/$d/meta.json; echo; done'多元件 Terraform 部署
Section titled “多元件 Terraform 部署”部署完整實驗室環境時,請為每個元件使用獨立的 Terraform 工作區或目錄:
# 1. Deploy origin servercd origin-serverterraform apply -var="subscription_id=YOUR_SUB_ID"ORIGIN_IP=$(terraform output -raw public_ip)
# 2. Configure F5 XC (manual or via separate Terraform)# Create origin pool -> HTTP LB -> attach WAF/Bot/API/CSD policies# LB_FQDN=demo.example.com
# 3. Deploy traffic generator targeting the F5 XC LBcd ../traffic-generatorterraform apply \ -var="subscription_id=YOUR_SUB_ID" \ -var="target_fqdn=demo.example.com" \ -var="target_origin_ip=${ORIGIN_IP}"
# 4. Generate trafficTGEN_IP=$(terraform output -raw public_ip)ssh azureuser@${TGEN_IP} '/opt/traffic-generator/suites/runner.sh web-app-attacks'