j-dahl7/defender-storage-malware-sentinel
GitHub: j-dahl7/defender-storage-malware-sentinel
一个端到端实验室,演示 Defender for Storage 恶意软件扫描与 Sentinel 事件关联,检测并响应 Blob 外泄风险。
Stars: 0 | Forks: 0
# Defender for Storage Malware Scanning + Sentinel Exfil Detection Lab
端到端实验室,展示 Defender for Storage 的上传时恶意软件扫描功能
以及 Sentinel 的关联规则,将单一检测扩展为具备外泄上下文的完整事件。
## 你将获得
- **Bicep 基础设施** (`infra/main.bicep`) — 存储账户、三个容器
(`ingest` / `processed` / `quarantine`)、指向 Sentinel 的诊断设置、
每账户启用 `OnUploadMalwareScanning` 的 Defender for Storage 设置。
- **Sentinel 规则** (`infra/sentinel-rules.bicep`) — 五条分析规则:
1. 上传恶意文件到 Blob (`Storage.Blob_Malware*` 告警)
2. 检测后读取感染文件 Blob(外泄确认)
3. 尝试匿名访问实验室账户
4. 地理异常调用方(基于 7 天 IP 基线)
5. 认证失败后的批量下载(凭证喷洒 → 外泄)
- **工作簿** (`infra/workbook.json`) — KPI 磁贴、检测时间线、
近期恶意软件上传记录、顶级调用方 IP、匿名尝试图表。
- **攻击脚本** (`attacks/`) — EICAR 基准测试、匿名探测、
外泄模拟、可选的 MalwareBazaar 样本下载器(受保护)。
- **部署脚本** (`scripts/deploy-lab.sh`) — 一次性端到端部署。
## 先决条件
- 具有修改 `Microsoft.Security/pricings` 权限的 Azure 订阅
(安全管理员或所有者角色)。
- 已存在的 Sentinel 工作区 — 默认使用
资源组 `sentinel-urbac-lab-rg` 中的 `sentinel-urbac-lab-law`。如不同请通过环境变量覆盖。
- Azure CLI 2.60+、Python 3.11+(用于外泄模拟器)。
## 部署
```
cd scripts
SUBSCRIPTION= LOCATION=eastus2 ./deploy-lab.sh
```
部署脚本执行以下操作:
1. 在订阅范围内启用 Defender for Storage Standard(`DefenderForStorageV2`)
并扩展 `OnUploadMalwareScanning`。
2. 创建资源组 `storage-malware-lab-rg`。
3. 部署存储账户及每账户 Defender 设置。
4. 部署五条 Sentinel 分析规则。
5. 发布工作簿。
## 运行攻击模拟
```
# Grant yourself Storage Blob Data Contributor on the account first.
export STORAGE_ACCOUNT=stmalwr
# Safe baseline — uploads EICAR. Should trigger Rule 1 within ~60-120s.
./attacks/upload-eicar.sh
# Probe anonymous access. All requests 403/409 (account blocks public access),
# but the attempts land in StorageBlobLogs → Rule 3.
./attacks/simulate-anon.sh
# After Rule 1 fires, run the exfil sim against the flagged blob to
# trigger Rule 2 (post-detection blob read correlation).
BLOB_NAME=eicar-.com python attacks/simulate-exfil.py
# Optional — pulls recent MalwareBazaar samples. Gated by ENABLE_LIVE_SAMPLES=1.
ENABLE_LIVE_SAMPLES=1 ./attacks/upload-malwarebazaar.sh
```
## 成本
- Defender for Storage(Standard / DefenderForStorageV2):每个账户每月约 $10 基础费用,
按日折算。
- 恶意软件扫描:每扫描 1 GB 收取 $0.15(每个账户每月前 5 GB 免费)。
- 日志分析数据摄入:实验室流量下每天数百行记录,完全在免费额度内。
- 实验室总费用:每月低于 $15。拆除命令:`az group delete -n storage-malware-lab-rg`。
## 拆除
```
az group delete --name storage-malware-lab-rg --yes --no-wait
# Optional: disable the subscription-level plan if you don't want billing
# continuing on other storage accounts.
az rest --method PUT \
--url "https://management.azure.com/subscriptions//providers/Microsoft.Security/pricings/StorageAccounts?api-version=2024-01-01" \
--body '{"properties":{"pricingTier":"Free"}}'
```
标签:Atomic Red Team, Azure 部署, Bicep 基础设施即代码, BurpSuite集成, Defender for Storage, DNS 解析, EICAR, HTTP工具, OnUploadMalwareScanning, Security Defender, Sentinel 威胁检测, Tactics 战术, 凭证喷洒, 分析规则, 匿名访问, 存储安全, 安全信息和事件管理 SIEM, 工作簿, 异常IP检测, 恶意软件扫描, 批量下载, 攻击模拟, 数据泄露检测, 检测与响应, 逆向工具, 驱动签名利用