Detects ransomware precursors in network traffic before encryption, using Zeek, Suricata, Arkime, SIEM rules, and threat intel to identify C2 beacons, credential dumping, reconnaissance, and staging behaviors.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 为勒索软件部署前的网络活动构建检测规则(从 Cobalt Strike 部署到加密开始平均只需 17 分钟)
Detects pre-encryption ransomware precursors in network traffic using Zeek, Suricata, Arkime, SIEM rules, and threat intel. For building detection rules, monitoring initial access, and incident response.
Detects pre-encryption ransomware precursors in network traffic using Zeek, Suricata, Arkime, SIEM rules for C2 beacons, credential harvesting, and reconnaissance scans.
Analyzes PCAPs, Zeek logs, and NetFlow data to detect C2 beacons, lateral movement, data exfiltration, and exploit attempts in security incidents using Wireshark and tcpdump.
Share bugs, ideas, or general feedback.
不适用场景:不适用于加密后的响应处置(参见 recovering-from-ransomware-attack)。本技能专注于加密前的检测窗口期,此时遏制措施可以防止数据损失。
将可网络观测的指标映射到各个加密前阶段:
| 杀伤链阶段 | 网络指标 | 检测来源 |
|---|---|---|
| 初始访问 | RDP 暴力破解、VPN 凭据填充、钓鱼回调 | 防火墙日志、IDS、代理日志 |
| C2 建立 | Cobalt Strike 信标(HTTPS/DNS)、Sliver/Brute Ratel 回调 | Zeek SSL/HTTP 日志、DNS 日志 |
| 凭据收集 | NTLM 中继、Kerberoasting、DCSync 流量 | Zeek Kerberos/NTLM 日志、DC 日志 |
| 侦察 | 内部端口扫描、AD 枚举(LDAP/SMB) | Zeek conn.log、流量数据 |
| 横向移动 | PsExec/WMI/WinRM 流量、RDP 跳板、SMB 文件复制 | Zeek SMB/DCE-RPC 日志 |
| 暂存 | 数据聚合、压缩包创建、云上传准备 | 代理日志、DNS 日志、DLP |
Suricata 常见勒索软件前驱规则:
# 检测 Cobalt Strike 默认 HTTPS 信标配置文件
alert tls $HOME_NET any -> $EXTERNAL_NET any (msg:"RANSOMWARE PRECURSOR - Cobalt Strike Default TLS Certificate"; tls.cert_subject; content:"Major Cobalt Strike"; sid:3000001; rev:1;)
# Cobalt Strike DNS 信标
alert dns $HOME_NET any -> any 53 (msg:"RANSOMWARE PRECURSOR - Cobalt Strike DNS Beacon Pattern"; dns.query; pcre:"/^[a-z0-9]{3}\.[a-z]{4,8}\./"; threshold:type both, track by_src, count 50, seconds 60; sid:3000002; rev:1;)
# Mimikatz 网络特征(DCSync - DRS GetNCChanges)
alert tcp $HOME_NET any -> $HOME_NET 135 (msg:"RANSOMWARE PRECURSOR - Possible DCSync/Mimikatz"; content:"|05 00 0b|"; offset:0; depth:3; content:"|e3 51 4d 2b 4b 47 15 d2|"; sid:3000003; rev:1;)
# 内部网络扫描(大量连接,少量字节)
alert tcp $HOME_NET any -> $HOME_NET any (msg:"RANSOMWARE PRECURSOR - Internal Port Scan"; flags:S; threshold:type both, track by_src, count 100, seconds 10; sid:3000004; rev:1;)
# SMB 上 PsExec 服务安装
alert tcp $HOME_NET any -> $HOME_NET 445 (msg:"RANSOMWARE PRECURSOR - PsExec Service Install"; content:"|ff|SMB"; content:"PSEXESVC"; nocase; sid:3000005; rev:1;)
# 内部主机 RDP 暴力破解(横向移动)
alert tcp $HOME_NET any -> $HOME_NET 3389 (msg:"RANSOMWARE PRECURSOR - Internal RDP Brute Force"; flow:to_server,established; threshold:type both, track by_src, count 20, seconds 60; sid:3000006; rev:1;)
# 大型 SMB 文件传输(数据暂存)
alert tcp $HOME_NET any -> $HOME_NET 445 (msg:"RANSOMWARE PRECURSOR - Large SMB Transfer Possible Staging"; flow:to_server,established; dsize:>60000; threshold:type both, track by_src, count 100, seconds 300; sid:3000007; rev:1;)
Zeek 行为检测脚本:
# detect_ransomware_precursors.zeek
# 检测大量 SMB 连接失败(凭据测试)
@load base/protocols/smb
module RansomwarePrecursor;
export {
redef enum Notice::Type += {
SMB_Brute_Force,
Suspicious_Internal_Scan,
Excessive_DNS_Queries,
SMB_Admin_Share_Access,
};
const smb_fail_threshold = 10 &redef;
const scan_threshold = 50 &redef;
const dns_query_threshold = 200 &redef;
}
global smb_fail_count: table[addr] of count &default=0 &create_expire=5min;
global conn_count: table[addr] of set[addr] &create_expire=1min;
event smb2_message(c: connection, hdr: SMB2::Header, is_orig: bool) {
if (hdr$status != 0) {
++smb_fail_count[c$id$orig_h];
if (smb_fail_count[c$id$orig_h] >= smb_fail_threshold) {
NOTICE([$note=SMB_Brute_Force,
$msg=fmt("Host %s has %d failed SMB attempts", c$id$orig_h, smb_fail_count[c$id$orig_h]),
$src=c$id$orig_h,
$identifier=cat(c$id$orig_h)]);
}
}
}
event new_connection(c: connection) {
if (c$id$orig_h in Site::local_nets && c$id$resp_h in Site::local_nets) {
if (c$id$orig_h !in conn_count)
conn_count[c$id$orig_h] = set();
add conn_count[c$id$orig_h][c$id$resp_h];
if (|conn_count[c$id$orig_h]| >= scan_threshold) {
NOTICE([$note=Suspicious_Internal_Scan,
$msg=fmt("Host %s connected to %d internal hosts in 1 min", c$id$orig_h, |conn_count[c$id$orig_h]|),
$src=c$id$orig_h,
$identifier=cat(c$id$orig_h)]);
}
}
}
Splunk 勒索软件前驱链关联:
| tstats count FROM datamodel=Network_Traffic
WHERE earliest=-24h All_Traffic.dest_port IN (445, 135, 139, 3389, 5985, 5986)
AND All_Traffic.src_ip IN 10.0.0.0/8
AND All_Traffic.dest_ip IN 10.0.0.0/8
BY All_Traffic.src_ip, All_Traffic.dest_port, _time span=1h
| stats dc(All_Traffic.dest_port) as port_count,
values(All_Traffic.dest_port) as ports,
count as total_conns
BY All_Traffic.src_ip
| where port_count >= 3 AND total_conns > 50
| rename All_Traffic.src_ip as src_ip
| lookup threat_intel_ioc ip as src_ip OUTPUT threat_type
| eval risk_score = case(
port_count >= 5 AND total_conns > 200, "CRITICAL",
port_count >= 3 AND total_conns > 50, "HIGH",
1=1, "MEDIUM")
| table src_ip, ports, port_count, total_conns, risk_score, threat_type
Microsoft Sentinel KQL - 勒索软件前驱关联:
let timeframe = 24h;
let RDPBruteForce = SecurityEvent
| where TimeGenerated > ago(timeframe)
| where EventID == 4625
| where LogonType == 10
| summarize FailedRDP = count() by TargetAccount, IpAddress, bin(TimeGenerated, 1h)
| where FailedRDP > 10;
let SuspiciousSMB = SecurityEvent
| where TimeGenerated > ago(timeframe)
| where EventID == 5145
| where ShareName has "ADMIN$" or ShareName has "C$" or ShareName has "IPC$"
| summarize AdminShareAccess = count() by SubjectUserName, IpAddress, bin(TimeGenerated, 1h)
| where AdminShareAccess > 5;
let ServiceInstalls = SecurityEvent
| where TimeGenerated > ago(timeframe)
| where EventID == 7045
| where ServiceName has_any ("PSEXESVC", "meterpreter", "beacon");
RDPBruteForce
| join kind=inner SuspiciousSMB on IpAddress
| project TimeGenerated, IpAddress, TargetAccount, FailedRDP, SubjectUserName, AdminShareAccess
| extend AlertTitle = "Ransomware Precursor: RDP Brute Force + Admin Share Access"
配置已知勒索软件基础设施的自动 IOC 订阅:
# 下载并更新勒索软件 C2 封锁列表
# abuse.ch Feodo Tracker(Cobalt Strike、TrickBot、BazarLoader C2)
curl -s https://feodotracker.abuse.ch/downloads/ipblocklist.csv | \
grep -v "^#" | cut -d, -f2 > /opt/threat-intel/feodo_ips.txt
# abuse.ch URLhaus(恶意软件分发 URL)
curl -s https://urlhaus.abuse.ch/downloads/csv_recent/ | \
grep -v "^#" | cut -d, -f3 > /opt/threat-intel/urlhaus_urls.txt
# abuse.ch ThreatFox(勒索软件 IOC)
curl -s https://threatfox.abuse.ch/export/csv/recent/ | \
grep -i "ransomware" | cut -d, -f3 > /opt/threat-intel/ransomware_iocs.txt
# CISA 已知被利用漏洞(初始访问向量)
curl -s https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json | \
python3 -c "import json,sys; data=json.load(sys.stdin); [print(v['cveID'],v['vendorProject'],v['product']) for v in data['vulnerabilities'] if 'ransomware' in v.get('knownRansomwareCampaignUse','').lower()]"
根据前驱置信度定义分类流程:
| 告警类型 | 置信度 | 响应时间 | 处置措施 |
|---|---|---|---|
| 已确认 Cobalt Strike 信标 | 高 | 15 分钟 | 立即隔离主机,触发 IR |
| 非 DC 发起的 DCSync/Kerberoasting | 高 | 15 分钟 | 禁用账户,隔离主机,触发 IR |
| 内部端口扫描 + 管理共享访问 | 中高 | 30 分钟 | 调查源主机,检查 EDR 遥测数据 |
| 内部主机 RDP 暴力破解 | 中 | 1 小时 | 确认是否为合法管理操作,检查主机 |
| 异常 DNS 查询量 | 低中 | 4 小时 | 检查 DNS 隧道,与其他告警关联分析 |
| 术语 | 定义 |
|---|---|
| 勒索软件前驱(Ransomware Precursor) | 勒索软件加密前的网络活动,包括 C2 通信、横向移动和数据暂存 |
| 驻留时间(Dwell Time) | 从初始入侵到勒索软件部署的时间,平均 21 天,但有时短至 17 分钟 |
| 初始访问经纪人(IAB) | 在暗网市场向勒索软件运营者出售已入侵网络访问权限的威胁行为者 |
| 信标(Beaconing) | 植入物(Cobalt Strike、Sliver)定期向 C2 回调,通过分析连接时序模式可检测 |
| Kerberoasting | 请求 Kerberos 服务票据进行离线破解的凭据收集技术,可通过异常 TGS-REQ 模式检测 |
| DCSync | 使用目录复制服务从域控制器提取密码哈希的技术,是勒索软件的关键前驱指标 |
背景:一家制造企业的 SOC 收到来自工程部门工作站(10.1.5.42)异常 SMB 流量的告警。该工作站在凌晨 2:00 的 5 分钟内连接了 47 台内部主机的 445 端口。
分析步骤:
注意事项:
## 勒索软件前驱检测告警
**告警 ID**:[SIEM 生成的 ID]
**检测时间**:[时间戳]
**源主机**:[IP / 主机名]
**置信度**:[高 / 中 / 低]
**杀伤链阶段**:[初始访问 / C2 / 凭据收集 / 侦察 / 横向移动 / 暂存]
### 已检测指标
| 指标 | 来源 | 详情 | MITRE ATT&CK |
|------|------|------|--------------|
| [类型] | [Zeek/Suricata/SIEM] | [描述] | [T-ID] |
### 关联事件链
1. [时间戳] - [事件 1]
2. [时间戳] - [事件 2]
3. [时间戳] - [事件 3]
### 建议处置措施
- [ ] 将源主机从网络隔离
- [ ] 检查主机上的 EDR 遥测数据
- [ ] 重置受影响用户账户的凭据
- [ ] 封锁已识别的 C2 基础设施
- [ ] 上报至事件响应团队