| name | building-threat-actor-profile-from-osint |
| description | 使用开源情报(OSINT)技术构建全面的威胁行为者档案,记录对手的动机、能力、基础设施和 TTP,用于主动防御。 |
| domain | cybersecurity |
| subdomain | threat-intelligence |
| tags | ["osint","threat-actor","profiling","maltego","spiderfoot","attribution","threat-intelligence","reconnaissance"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
从 OSINT 构建威胁行为者档案
概述
利用 OSINT 进行威胁行为者画像,系统性地收集和分析公开可用信息,以构建对手组织的全面档案。本技能涵盖从公开来源(安全厂商报告、粘贴站点、暗网论坛、社交媒体、代码仓库)收集情报、跨平台关联指标、使用 Maltego 和 SpiderFoot 等工具映射对手基础设施,以及生成指导防御策略和归因评估的结构化威胁行为者档案。
前置条件
- Python 3.9+,安装
shodan、requests、beautifulsoup4、maltego-trx、stix2 库
- SpiderFoot 或 SpiderFoot HX
- Maltego CE 或 Maltego XL 用于链接分析
- API 密钥:Shodan、VirusTotal、AlienVault OTX、PassiveTotal/RiskIQ
- MITRE ATT&CK 知识用于 TTP 映射
- 了解 STIX 2.1 入侵集合、威胁行为者和身份 SDO
核心概念
威胁行为者画像的 OSINT 来源
主要情报来源包括:厂商威胁报告(Mandiant、CrowdStrike、Recorded Future、Talos)、政府建议(CISA、NSA、FBI 联合建议)、学术研究论文、恶意软件仓库(VirusTotal、MalwareBazaar、Malpedia)、粘贴站点(Pastebin、GitHub Gists)、代码仓库、社交媒体账号、暗网论坛和证书透明度日志。
结构化分析技术
画像使用菱形模型(对手、基础设施、能力、受害者)、竞争假说分析(ACH)进行归因置信度评估,以及 MITRE ATT&CK 映射进行 TTP 记录。Maltego 等链接分析工具可视化指标、基础设施和行为者之间的关系。
档案组成要素
完整的威胁行为者档案包括:各厂商的别名和命名规范、可疑来源和赞助方、动机(间谍、财务、黑客主义、破坏),以及目标行业和地区、已知攻击活动和行动、映射到 ATT&CK 的 TTP、工具集和恶意软件家族、基础设施模式和历史时间线。
实践步骤
步骤 1:从多个来源收集情报
import requests
import json
from datetime import datetime
class OSINTCollector:
def __init__(self, vt_key=None, otx_key=None, shodan_key=None):
self.vt_key = vt_key
self.otx_key = otx_key
self.shodan_key = shodan_key
self.collected_data = {"sources": [], "indicators": [], "reports": []}
def search_alienvault_otx(self, actor_name):
"""在 AlienVault OTX 中搜索威胁行为者情报包。"""
headers = {"X-OTX-API-KEY": self.otx_key}
url = f"https://otx.alienvault.com/api/v1/search/pulses?q={actor_name}&limit=20"
resp = requests.get(url, headers=headers)
if resp.status_code == 200:
data = resp.json()
pulses = data.get("results", [])
for pulse in pulses:
self.collected_data["reports"].append({
"source": "AlienVault OTX",
"title": pulse.get("name", ""),
"created": pulse.get("created", ""),
"description": pulse.get("description", )[:],
: pulse.get(, []),
: (pulse.get(, [])),
: pulse.get(, ),
})
ioc pulse.get(, []):
.collected_data[].append({
: ioc.get(, ),
: ioc.get(, ),
: ,
: pulse.get(, ),
})
()
.collected_data
():
headers = {: .vt_key}
url =
params = {: }
resp = requests.get(url, headers=headers, params=params)
resp.status_code == :
results = resp.json().get(, [])
()
results
[]
():
results = []
ip indicators:
url =
resp = requests.get(url)
resp.status_code == :
data = resp.json()
results.append({
: ip,
: data.get(, ),
: data.get(, ),
: data.get(, ),
: data.get(, []),
: data.get(, []),
: data.get(, ),
: data.get(, ),
})
()
results
collector = OSINTCollector(
vt_key=,
otx_key=,
shodan_key=,
)
data = collector.search_alienvault_otx()
步骤 2:构建结构化威胁行为者档案
from stix2 import ThreatActor, IntrusionSet, Identity, Relationship, Bundle
from datetime import datetime
identity = Identity(
name="网络安全分析师",
identity_class="individual",
)
threat_actor = ThreatActor(
name="APT29",
description="APT29(也称为 Cozy Bear、Midnight Blizzard、NOBELIUM、The Dukes)"
"是归因于俄罗斯对外情报局(SVR)的俄罗斯国家支持的威胁组织。"
"该组织至少自 2008 年起活跃,主要针对 NATO 国家的政府、外交、"
"智库、医疗和能源机构实施网络间谍活动。",
aliases=["Cozy Bear", "Midnight Blizzard", "NOBELIUM", "The Dukes",
"Dark Halo", "UNC2452", "YTTRIUM", "Blue Kitsune", "Iron Ritual"],
roles=["agent"],
sophistication="strategic",
resource_level="government",
primary_motivation="organizational-gain",
secondary_motivations=["ideology"],
threat_actor_types=["nation-state"],
goals=["收集外国政府情报",
"长期持续访问高价值目标",
"供应链入侵以获得广泛访问"],
created_by_ref=identity.id,
)
intrusion_set = IntrusionSet(
name="APT29",
description="归因于俄罗斯 SVR 的入侵集合 APT29。",
aliases=["Cozy Bear", "Midnight Blizzard"],
first_seen="2008-01-01T00:00:00Z",
goals=["espionage"],
resource_level="government",
primary_motivation="organizational-gain",
)
relationship = Relationship(
relationship_type="attributed-to",
source_ref=intrusion_set.,
target_ref=threat_actor.,
)
bundle = Bundle(objects=[identity, threat_actor, intrusion_set, relationship])
(, ) f:
f.write(bundle.serialize(pretty=))
()
步骤 3:将 TTP 映射到 MITRE ATT&CK
from attackcti import attack_client
lift = attack_client()
apt29_techs = lift.get_techniques_used_by_group("G0016")
profile_ttps = {
"initial_access": [],
"execution": [],
"persistence": [],
"defense_evasion": [],
"credential_access": [],
"lateral_movement": [],
"collection": [],
"c2": [],
"exfiltration": [],
}
tactic_mapping = {
"initial-access": "initial_access",
"execution": "execution",
"persistence": "persistence",
"defense-evasion": "defense_evasion",
"credential-access": "credential_access",
"lateral-movement": "lateral_movement",
"collection": "collection",
"command-and-control": "c2",
"exfiltration": "exfiltration",
}
for tech in apt29_techs:
tech_id = ""
for ref in tech.get("external_references", []):
if ref.get("source_name") == "mitre-attack":
tech_id = ref.get("external_id", "")
break
for phase in tech.get("kill_chain_phases", []):
tactic = phase.get("phase_name", )
key = tactic_mapping.get(tactic)
key:
profile_ttps[key].append({
: tech_id,
: tech.get(, ),
: tech.get(, )[:],
})
()
tactic, techs profile_ttps.items():
techs:
()
t techs[:]:
()
步骤 4:使用 SpiderFoot 关联基础设施
import subprocess
import json
def run_spiderfoot_scan(target, scan_name="actor_recon"):
"""对目标域名或 IP 运行 SpiderFoot 扫描。"""
cmd = [
"python3", "-m", "spiderfoot", "-s", target,
"-m", "sfp_dns,sfp_whois,sfp_shodan,sfp_virustotal,sfp_certspotter",
"-o", "json", "-q",
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
if result.returncode == 0:
findings = json.loads(result.stdout) if result.stdout else []
print(f"[+] SpiderFoot: 为 {target} 找到 {len(findings)} 个发现")
return findings
return []
def correlate_infrastructure(indicators):
"""查找基础设施指标之间的关系。"""
ip_to_domains = {}
domain_to_ips = {}
registrar_patterns = {}
for indicator in indicators:
ioc_type = indicator.get("type", "")
value = indicator.get("value", "")
if ioc_type == "IP_ADDRESS":
if value not in ip_to_domains:
ip_to_domains[value] = set()
ioc_type == :
value domain_to_ips:
domain_to_ips[value] = ()
shared_ips = {ip: domains ip, domains ip_to_domains.items() (domains) > }
()
{: shared_ips, : registrar_patterns}
步骤 5:生成威胁行为者档案报告
def generate_dossier(actor_name, profile_data, ttp_data, infrastructure_data):
dossier = f"""# 威胁行为者档案: {actor_name}
## 生成时间: {datetime.now().isoformat()}
## 摘要
{profile_data.get('description', '')}
## 归因
- **可疑来源**: {profile_data.get('origin', '未知')}
- **赞助方**: {profile_data.get('sponsorship', '未知')}
- **置信度**: {profile_data.get('confidence', '中等')}
- **首次发现**: {profile_data.get('first_seen', '未知')}
## 别名
{', '.join(profile_data.get('aliases', []))}
## 目标
- **行业**: {', '.join(profile_data.get('sectors', []))}
- **地区**: {', '.join(profile_data.get('regions', []))}
- **动机**: {profile_data.get('motivation', '未知')}
## TTP 摘要(MITRE ATT&CK)
"""
for tactic, techs in ttp_data.items():
if techs:
dossier += f"\n### {tactic.replace('_', ' ').title()}\n"
for t in techs:
dossier += f"- **{t['id']}**: {t['name']}\n"
dossier += f"""
## 基础设施模式
- 已知 C2 服务器: {len(infrastructure_data.get(, []))} 个
- 域名模式:
- 托管偏好:
## 建议措施
1. 在 EDR/SIEM 中监控已知 TTP
2. 封锁已知基础设施指标
3. 在网络流量中狩猎行为模式
4. 针对主要技术缺口实施检测
"""
(, ) f:
f.write(dossier)
()
generate_dossier(, {
: ,
: , : ,
: , : ,
: [, , , ],
: [, , , , ],
: [, , ],
: ,
}, profile_ttps, {: [], : [], : []})
验收标准
- 从至少 3 个 OSINT 来源收集情报
- 正确创建 STIX 2.1 威胁行为者和入侵集合对象
- TTP 已映射到 ATT&CK 并包含技术 ID 和过程示例
- 基础设施指标已跨来源关联
- 档案包含带有置信度级别的归因评估
- 档案可直接用于检测工程和威胁狩猎
参考资料