Linux 開源、穩定、低成本特性使其成為伺服器首選,但隨著普及率提升,也成為攻擊目標。漏洞掃描器分為主機型(本機檢測)與網路型(遠端掃描)兩大類。本文介紹經典與現代工具,助管理員建立纵深防禦。
現代首選,支援 Linux/Unix/macOS,涵蓋:
# 安裝
dnf install lynis # RHEL/Fedora
apt install lynis # Debian/Ubuntu
# 或下載最新版
git clone https://github.com/CISOfy/lynis
# 掃描
lynis audit system --quick # 快速檢查
lynis audit system --profile custom # 自訂配置
lynis show versions # 檢查更新
輸出含強化建議、風險評分、合規對照表,適合納入 CI/CD 與定期稽核。
基於 SCAP(Security Content Automation Protocol)標準,使用 OVAL/XCCDF 內容:
dnf install openscap-scanner scap-security-guide
# 掃描 RHEL 8 CIS Benchmark
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis \
--results results.xml --report report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
產出機器可讀結果與人類可讀 HTML 報告,支援 Ansible 整合(ansible-collection-redhat.rhel_system_roles)。
早期 TAMU Tiger 衍生版,檢查項目:
apt install tiger
tiger -H html -q # 產出 HTML 報告
dnf install chkrootkit rkhunter
chkrootkit # 快速掃描已知 rootkit 特徵
rkhunter --update
rkhunter --propupd # 建立檔案屬性基準
rkhunter -c --sk # 完整掃描(略過部分測試)
注意:誤報率較高,需人工複核。建議搭配 AIDE/Tripwire 檔案完整性監控。
dnf install aide
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
# 定期檢查
aide --check
建立資料庫基準,偵測二進位檔、配置檔、關鍵目錄異動。整合 systemd timer 定期執行並郵件通報。
systemd-analyze security # 服務安全等級評估
systemd-analyze verify *.service # 單元檔語法檢查
systemd-cgtop # 即時 cgroup 資源佔用
# 基本掃描
nmap -sS -T4 192.168.1.0/24 # SYN 掃描
nmap -sV -O 192.168.1.100 # 服務版本 + OS 指紋
nmap --script vuln 192.168.1.100 # NSE 漏洞腳本掃描
nmap -p- --min-rate 1000 10.0.0.1 # 全埠口快速掃描
NSE 腳本庫(/usr/share/nmap/scripts)涵蓋 CVE 檢測、惡意軟體偵測、配置錯誤識別。
架構:gvmd(管理)、openvas-scanner(掃描)、gsad(Web UI)。支援 NVT(Network Vulnerability Tests)每日更新,涵蓋 10 萬+ 漏洞特徵。
# Docker 快速部署
docker run -d -p 9392:9392 --name openvas mikesplain/openvas
企業級功能:排程掃描、資產管理、風險評分、報表匯出、API 整合。
免費版限 16 IP,專業版支援:
# ZAP 基線掃描
docker run -t owasp/zap2docker-stable zap-baseline.py -t https://target.com
# Nikto 靜態分析
nikto -h https://target.com -ssl
trivy image ubuntu:22.04 # 容器鏡像漏洞
trivy fs /path/to/project # 檔案系統/程式碼
trivy k8s cluster # Kubernetes 叢集配置
trivy config --policy /policy.rego . # 自訂 Rego 策略
支援 OS 套件、語言套件、IaC (Terraform/Kubernetes/Dockerfile)、Secret 洩漏。
syft packages dir:/path -o json > sbom.json
grype sbom:sbom.json
kube-bench run --targets master,node,etcd,policies
kube-hunter --remote
| 需求 | 推薦工具 | 授權 | 備註 |
|---|---|---|---|
| 主機基線稽核 | Lynis | GPLv3 | 輕量、無需資料庫、適合自動化 |
| 合規認證 (CIS/PCI) | OpenSCAP | GPLv2 | 標準化內容、機器可讀結果 |
| Rootkit 偵測 | rkhunter + AIDE | GPL | 特徵掃描 + 完整性基準 |
| 網路資產發現 | Nmap | GPL | 腳本擴充性強 |
| 企業級漏洞管理 | OpenVAS / Nessus | GPL / 商業 | 資產追蹤、趨勢分析、報表 |
| Web 應用掃描 | ZAP | Apache 2.0 | 主動/被動掃描、API 測試 |
| 容器/雲原生 | Trivy | Apache 2.0 | 全棧掃描、SBOM、策略即代碼 |
| Kubernetes | kube-bench | Apache 2.0 | CIS Benchmark 自動化 |
安全非一次性專案,而是持續流程。工具僅是放大鏡,關鍵在於流程制度化、責任明確化、知識沉澱化。