Collecting threat intelligence with misp

From killvxk/cybersecurity-skills-zh · View interactive version

Collecting threat intelligence with misp is an AI agent skill from the GitHub repository killvxk/cybersecurity-skills-zh. MISP(恶意软件信息共享平台)是一个开源威胁情报平台,用于收集、共享、存储和关联定向攻击的失陷指标(IOC)、威胁情报、金融欺诈信息、漏洞信息或反恐信息。

How to use this skill

Skill file

使用 MISP 收集威胁情报

概述

MISP(恶意软件信息共享平台)是一个开源威胁情报平台,用于收集、共享、存储和关联定向攻击的失陷指标(IOC)、威胁情报、金融欺诈信息、漏洞信息或反恐信息。本技能涵盖部署 MISP、配置威胁推送、使用 PyMISP API 进行编程访问,以及构建自动化收集流水线,从多个社区和商业来源聚合 IOC。

前置条件

核心概念

MISP 架构

MISP 采用基于事件的模型,将威胁情报组织为包含属性(IOC)、对象(属性的结构化分组)、Galaxy(链接到 MITRE ATT&CK 的威胁行为者/恶意软件集群)和分类标签的事件。MISP 实例之间的同步使用基于 HTTPS 的推/拉模型,并以 API 密钥进行身份验证。

推送类型

PyMISP API

PyMISP 是通过 REST API 访问 MISP 平台的官方 Python 库。它支持获取事件、添加/更新事件和属性、上传样本,以及在整个 MISP 数据集中搜索。身份验证使用在 Authorization 请求头中传递的 API 密钥。

实践步骤

步骤 1:使用 Docker 部署 MISP

git clone https://github.com/MISP/misp-docker.git
cd misp-docker
cp template.env .env
# 编辑 .env 设置 MISP_BASEURL、MISP_ADMIN_EMAIL、MISP_ADMIN_PASSPHRASE
docker compose up -d

步骤 2:配置默认推送

通过 Web 界面或 API 启用内置 MISP 推送:

from pymisp import PyMISP

misp = PyMISP('https://misp.local', 'YOUR_API_KEY', ssl=False)

# 列出可用推送
feeds = misp.feeds()
for feed in feeds:
    print(f"{feed['Feed']['id']}: {feed['Feed']['name']} - 已启用: {feed['Feed']['enabled']}")

# 启用 CIRCL OSINT 推送
misp.enable_feed(feed_id=1)
misp.cache_feed(feed_id=1)
misp.fetch_feed(feed_id=1)

步骤 3:添加自定义威胁推送

# 添加 abuse.ch URLhaus 推送
feed_data = {
    'name': 'URLhaus 近期 URL',
    'provider': 'abuse.ch',
    'url': 'https://urlhaus.abuse.ch/downloads/csv_recent/',
    'source_format': 'csv',
    'input_source': 'network',
    'publish': False,
    'enabled': True,
    'headers': '',
    'distribution': 0,
    'sharing_group_id': 0,
    'tag_id': 0,
    'default': False,
    'lookup_visible': True
}
result = misp.add_feed(feed_data)
print(f"推送已添加: {result}")

步骤 4:以编程方式搜索和检索事件

from pymisp import PyMISP, MISPEvent
from datetime import datetime, timedelta

misp = PyMISP('https://misp.local', 'YOUR_API_KEY', ssl=False)

# 搜索过去 7 天的事件
result = misp.search(
    controller='events',
    date_from=(datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d'),
    type_attribute='ip-dst',
    to_ids=True,
    pythonify=True
)

for event in result:
    print(f"事件 {event.id}: {event.info}")
    for attr in event.attributes:
        if attr.type == 'ip-dst' and attr.to_ids:
            print(f"  IOC: {attr.value} (类别: {attr.category})")

步骤 5:导出 IOC 到下游工具

# 导出为 STIX 2.1 bundle
stix_output = misp.search(
    controller='events',
    return_format='stix2',
    tags=['tlp:white'],
    published=True
)

# 将 IDS 标记的属性导出为 Suricata 规则
suricata_rules = misp.search(
    controller='attributes',
    return_format='suricata',
    to_ids=True,
    type_attribute=['ip-dst', 'domain', 'url']
)

# 导出为 CSV 以供 SIEM 摄取
csv_output = misp.search(
    controller='attributes',
    return_format='csv',
    type_attribute='ip-dst',
    to_ids=True
)

验收标准

参考资料

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.