L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Productivité · SKILL.md

implementing-honeypot-for-ransomware-detection

implementing-honeypot-for-ransomware-detection

部署诱饵文件、蜜罐共享和诱骗系统,在最早阶段检测勒索软件活动。配置嵌入 战略文件位置的金丝雀令牌,在勒索软件尝试加密时触发告警;使用模拟高价值 目标的蜜罐网络共享;部署 Thinkst Canary 设备进行全面的基于欺骗的检测。

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: implementing-honeypot-for-ransomware-detection description: > 部署诱饵文件、蜜罐共享和诱骗系统,在最早阶段检测勒索软件活动。配置嵌入 战略文件位置的金丝雀令牌,在勒索软件尝试加密时触发告警;使用模拟高价值 目标的蜜罐网络共享;部署 Thinkst Canary 设备进行全面的基于欺骗的检测。 domain: cybersecurity subdomain: ransomware-defense tags: [ransomware, detection, honeypot, canary, defense, deception] version: 1.0.0 author: mahipal license: Apache-2.0

为勒索软件检测实施蜜罐

使用场景

  • 使用诱饵文件为勒索软件加密尝试部署早期预警检测
  • 创建检测横向移动和加密前数据暂存的蜜罐文件共享
  • 用具有近乎零误报率的欺骗层告警补充 EDR 和 SIEM 检测
  • 通过在文件修改行为上触发告警,检测规避基于签名检测的勒索软件变种
  • 使用受控加密工具测试,验证勒索软件检测能力是否有效

不要将其用作唯一的勒索软件检测机制。蜜罐是高置信度的补充层,而非 EDR、网络监控和备份保护的替代品。

前置条件

  • 可部署诱饵文件的文件服务器或 NAS 基础设施
  • Windows 文件服务器资源管理器(FSRM)或同等文件活动监控工具
  • Thinkst Canary 或类似欺骗平台(可选,用于高级部署)
  • 用于集中蜜罐告警的 SIEM 平台
  • 在文件共享中部署诱饵文件的管理员权限
  • 用于蜜罐系统的网络段(如果部署完整蜜罐服务器)

工作流程

步骤一:在文件共享中部署诱饵文件

在勒索软件加密过程中会遇到的战略位置放置诱饵文件:

# 在所有文件共享中部署诱饵文件
# 文件命名使其在字母顺序和目录顺序中靠前出现
# 勒索软件通常按字母顺序或目录遍历顺序加密

$shares = @("\\fileserver01\finance", "\\fileserver01\hr", "\\fileserver01\engineering")
$canaryNames = @(
    "!_IMPORTANT_DO_NOT_DELETE.docx",
    "000_Budget_2026_FINAL.xlsx",
    "_Confidential_Employee_Records.pdf",
    "AAAA_Quarterly_Report.docx"
)

foreach ($share in $shares) {
    foreach ($name in $canaryNames) {
        $targetPath = Join-Path $share $name
        # 创建看起来合法的诱饵文件内容
        # 文件包含访问时触发的唯一令牌
        $content = "This document contains confidential financial data.`n"
        $content += "Q4 2025 Revenue: $42.3M | Q1 2026 Forecast: $45.1M`n"
        $content += "Prepared by: Finance Department`n"
        Set-Content -Path $targetPath -Value $content
        # 将文件设置为隐藏系统文件,避免用户交互
        $file = Get-Item $targetPath
        $file.Attributes = [System.IO.FileAttributes]::Hidden
    }
}

# 同样在子目录中部署(勒索软件递归遍历)
$subDirs = Get-ChildItem -Path "\\fileserver01\finance" -Directory -Recurse | Select-Object -First 20
foreach ($dir in $subDirs) {
    $canaryPath = Join-Path $dir.FullName "!_Budget_Summary.xlsx"
    Set-Content -Path $canaryPath -Value "Canary file for ransomware detection"
    (Get-Item $canaryPath).Attributes = [System.IO.FileAttributes]::Hidden
}

步骤二:为诱饵文件配置文件完整性监控

Windows FSRM 方式:

# 配置 FSRM 监控勒索软件文件扩展名和诱饵文件修改

Install-WindowsFeature -Name FS-Resource-Manager -IncludeManagementTools

# 为已知勒索软件扩展名创建文件筛选器
$ransomExtensions = @(
    "*.encrypted", "*.locked", "*.crypto", "*.crypt",
    "*.locky", "*.cerber", "*.zepto", "*.thor",
    "*.aesir", "*.zzzzz", "*.wallet", "*.onion",
    "*.wncry", "*.wcry", "*.lockbit", "*.BlackCat",
    "*.ALPHV", "*.rhysida", "*.play"
)

# 为勒索软件扩展名创建文件组
New-FsrmFileGroup -Name "Ransomware_Extensions" -IncludePattern $ransomExtensions

# 创建文件筛选器模板
New-FsrmFileScreenTemplate -Name "Ransomware_Screen" `
    -IncludeGroup "Ransomware_Extensions" `
    -Active:$false  # 被动模式:告警但不阻止

# 应用至所有受监控的共享
$monitoredPaths = @("D:\Shares\Finance", "D:\Shares\HR", "D:\Shares\Engineering")
foreach ($path in $monitoredPaths) {
    New-FsrmFileScreen -Path $path -Template "Ransomware_Screen"
}

使用 PowerShell FileSystemWatcher 进行诱饵文件修改监控:

# 实时诱饵文件监控服务
$canaryPaths = @(
    "D:\Shares\Finance\!_IMPORTANT_DO_NOT_DELETE.docx",
    "D:\Shares\HR\000_Budget_2026_FINAL.xlsx",
    "D:\Shares\Engineering\_Confidential_Employee_Records.pdf"
)

$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "D:\Shares"
$watcher.Filter = "*"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true

$action = {
    $path = $Event.SourceEventArgs.FullPath
    $changeType = $Event.SourceEventArgs.ChangeType
    $timestamp = $Event.TimeGenerated

    # 检查修改的文件是否是诱饵文件
    $isCanary = $false
    foreach ($canary in $canaryPaths) {
        if ($path -eq $canary) { $isCanary = $true; break }
    }

    if ($isCanary -or $changeType -eq "Renamed") {
        $alertMsg = "RANSOMWARE ALERT: Canary file modified! Path: $path | Change: $changeType | Time: $timestamp"
        # 记录到 Windows 事件日志
        Write-EventLog -LogName Application -Source "RansomwareCanary" `
            -EventID 9999 -EntryType Error -Message $alertMsg
        # 通过 syslog 发送 SIEM 告警
        # 触发自动化遏制
    }
}

Register-ObjectEvent $watcher "Changed" -Action $action
Register-ObjectEvent $watcher "Deleted" -Action $action
Register-ObjectEvent $watcher "Renamed" -Action $action

步骤三:部署蜜罐网络共享

创建看起来包含高价值数据的诱骗文件共享:

# 在专用服务器上创建蜜罐共享
# 该服务器监控所有文件访问,对任何活动发出告警

New-Item -Path "D:\HoneypotShares\Executive_Compensation" -ItemType Directory
New-Item -Path "D:\HoneypotShares\M&A_Documents" -ItemType Directory
New-Item -Path "D:\HoneypotShares\Board_Meeting_Notes" -ItemType Directory
New-Item -Path "D:\HoneypotShares\Customer_Database_Exports" -ItemType Directory

# 以广泛读取权限共享(对攻击者有吸引力)
New-SmbShare -Name "Executive_Compensation" `
    -Path "D:\HoneypotShares\Executive_Compensation" `
    -FullAccess "DOMAIN\Domain Users" `
    -Description "Executive Compensation Files - Restricted"

# 填充看起来合法但实为虚假的文档
$docContent = @"
CONFIDENTIAL - Executive Compensation Summary
FY 2026 Base Salary and Bonus Structures
CEO: [REDACTED] | CFO: [REDACTED] | CTO: [REDACTED]
Total Compensation Package: See Appendix A
"@
Set-Content -Path "D:\HoneypotShares\Executive_Compensation\FY2026_Comp_Summary.txt" -Value $docContent

# 在蜜罐共享上启用详细审计日志
$acl = Get-Acl "D:\HoneypotShares"
$auditRule = New-Object System.Security.AccessControl.FileSystemAuditRule(
    "Everyone", "ReadAndExecute,Write,Delete", "ContainerInherit,ObjectInherit",
    "None", "Success,Failure"
)
$acl.AddAuditRule($auditRule)
Set-Acl "D:\HoneypotShares" $acl

# 通过 GPO 启用对象访问审计
auditpol /set /subcategory:"File System" /success:enable /failure:enable

步骤四:部署 Thinkst Canary 令牌

对于使用 Thinkst Canary 或免费 canarytokens.org 服务的组织:

# 通过 API 生成金丝雀令牌(Thinkst Canary)
# 这些令牌在文档被打开或 URL 被访问时触发告警

# Word 文档令牌
curl -X POST "https://CONSOLE.canary.tools/api/v1/canarytoken/create" \
  -d "auth_token=YOUR_API_TOKEN" \
  -d "memo=Finance_Share_Canary" \
  -d "kind=doc-msword" \
  -o /tmp/canary_budget_report.docx

# PDF 文档令牌
curl -X POST "https://CONSOLE.canary.tools/api/v1/canarytoken/create" \
  -d "auth_token=YOUR_API_TOKEN" \
  -d "memo=HR_Share_Canary" \
  -d "kind=pdf-acrobat-reader" \
  -o /tmp/canary_employee_handbook.pdf

# Windows 文件夹令牌(浏览文件夹时告警)
curl -X POST "https://CONSOLE.canary.tools/api/v1/canarytoken/create" \
  -d "auth_token=YOUR_API_TOKEN" \
  -d "memo=Executive_Folder_Browse" \
  -d "kind=windows-dir"

# 部署 Canary 设备(模拟文件服务器)
# 通过 Web 控制台配置,使其看起来像:
# - 带有 SMB 共享的 Windows 文件服务器
# - 包含看起来真实的目录
# - 任何访问都会触发带有源 IP 和活动详情的即时告警

步骤五:与 SIEM 和自动化响应集成

# siem_integration.py - 将蜜罐告警转发到 SIEM 并触发遏制

import json
import requests
import logging
from datetime import datetime

SIEM_WEBHOOK = "https://siem.company.com/api/alerts"
NAC_API = "https://nac.company.com/api/v1/quarantine"
EDR_API = "https://edr.company.com/api/v1/isolate"

def send_ransomware_alert(source_ip: str, canary_path: str, action: str):
    """向 SIEM 发送高优先级告警并触发自动化遏制。"""
    alert = {
        "timestamp": datetime.utcnow().isoformat(),
        "severity": "CRITICAL",
        "category": "Ransomware - Canary File Triggered",
        "source_ip": source_ip,
        "canary_file": canary_path,
        "action_detected": action,
        "automated_response": "Host isolation initiated",
        "mitre_technique": "T1486 - Data Encrypted for Impact",
    }

    # 发送至 SIEM
    try:
        requests.post(SIEM_WEBHOOK, json=alert, timeout=5)
    except requests.RequestException as e:
        logging.error(f"SIEM alert failed: {e}")

    # 自动化遏制 - 通过 NAC 隔离主机
    try:
        requests.post(f"{NAC_API}/{source_ip}",
                      json={"action": "quarantine", "reason": "Ransomware canary triggered"},
                      timeout=5)
    except requests.RequestException as e:
        logging.error(f"NAC quarantine failed: {e}")

    # 自动化遏制 - 通过 EDR 隔离主机
    try:
        requests.post(EDR_API,
                      json={"ip": source_ip, "action": "isolate"},
                      timeout=5)
    except requests.RequestException as e:
        logging.error(f"EDR isolation failed: {e}")

    logging.critical(f"RANSOMWARE CANARY ALERT: {source_ip} modified {canary_path} ({action})")

核心概念

术语定义
诱饵文件放置在战略位置的诱骗文件,当勒索软件修改、重命名或删除时触发告警
蜜罐共享设计用于吸引攻击者的诱骗网络共享,任何访问都是可疑的并触发告警
金丝雀令牌嵌入文档或 URL 中的可追踪令牌,被访问时回传报告,揭示访问者的 IP 和时间
FSRM文件服务器资源管理器——监控文件操作并可筛选勒索软件扩展名的 Windows Server 角色
欺骗层使用诱骗资产以近乎零误报率检测威胁的安全架构层
文件系统监视器监控实时文件系统变化(创建、修改、删除、重命名)的系统服务

工具与系统

  • Thinkst Canary:提供 Canary 设备(模拟服务器)和金丝雀令牌(可追踪文档)的商业欺骗平台
  • Canarytokens.org:Thinkst 提供的免费服务,用于生成基本金丝雀令牌(Word 文档、PDF、URL、DNS)
  • OpenCanary:模拟常见服务(SMB、RDP、SSH)并记录访问尝试的开源蜜罐守护进程
  • FSRM(文件服务器资源管理器):用于文件筛选、配额管理和勒索软件扩展名检测的 Windows Server 内置工具
  • Elastic Endpoint:内部使用诱饵文件进行勒索软件保护,在修改诱饵文件时触发行为告警

常见场景

场景:通过诱饵文件早期检测 BlackByte 勒索软件

背景:一家零售公司在 200 个文件共享和 3 个蜜罐共享中部署了诱饵文件。周六凌晨 3:00,诱饵监控系统在 90 秒内连续生成 47 个告警,因为 12 个共享中的诱饵文件被快速修改。

处置方法:

  1. 诱饵文件告警触发自动化遏制:源工作站(10.2.8.55)在 30 秒内通过 NAC 被隔离
  2. SIEM 关联显示该工作站在 2 小时前有 PsExec 执行的 EDR 告警(被夜班 SOC 遗漏)
  3. 来自另外 3 台工作站的额外诱饵告警表明勒索软件通过计划任务传播
  4. IR 团队隔离受影响的 VLAN,防止其余 188 个文件共享被加密
  5. 12 个受影响的共享在 4 小时内从不可变备份中恢复
  6. 预计避免的损失:基于 95% 的共享得到保护,节省约 230 万美元的停机和恢复成本

常见陷阱:

  • 仅在根目录放置诱饵文件,而勒索软件可能先针对子目录
  • 使用明显的诱饵文件名,被复杂勒索软件识别并跳过
  • 未端到端测试诱饵告警,在真实事件中发现告警未到达 SOC
  • 在合法文件迁移或防病毒扫描期间产生过多诱饵告警,导致告警疲劳

输出格式

## 勒索软件蜜罐部署报告

**组织**:[名称]
**部署日期**:[日期]

### 诱饵文件部署
| 共享 | 部署文件数 | 命名规范 | 告警方式 |
|-------|---------------|-------------------|--------------|
| [共享路径] | [数量] | [模式] | [FSRM/Watcher/Token] |

### 蜜罐共享
| 共享名称 | 位置 | 表面内容 | 监控方式 |
|-----------|----------|-----------------|------------|
| [名称] | [服务器] | [描述] | [审计/Canary] |

### 告警集成
- SIEM:[已连接/未连接]
- 自动化遏制:[EDR 隔离/NAC 隔离/无]
- 告警 SLA:[预期响应时间]

### 测试结果
| 测试日期 | 测试类型 | 诱饵是否触发 | 是否收到告警 | 遏制是否执行 | 告警时间 |
|-----------|----------|-----------------|----------------|---------------------|---------------|
Skills enregistrées