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

building-incident-timeline-with-timesketch

building-incident-timeline-with-timesketch

使用 Timesketch 构建协作式取证事件时间线,对多源事件数据进行摄入、规范化和分析,用于攻击链重建和调查文档化。

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: building-incident-timeline-with-timesketch description: 使用 Timesketch 构建协作式取证事件时间线,对多源事件数据进行摄入、规范化和分析,用于攻击链重建和调查文档化。 domain: cybersecurity subdomain: incident-response tags: [timesketch, timeline-analysis, forensic-timeline, plaso, dfir, incident-investigation, collaborative-forensics] version: "1.0" author: mahipal license: Apache-2.0

使用 Timesketch 构建事件时间线

概述

Timesketch 是由 Google 开发的开源协作式取证时间线分析工具,使安全团队能够在事件调查期间可视化和分析来自多个来源的按时间顺序排列的数据。它摄入来自端点、服务器和云服务的日志和制品(Artifact),将其规范化为统一的可搜索时间线,并提供强大的分析能力,包括内置分析器、打标签(Tagging)、素描(Sketch)注释和故事构建。Timesketch 与 Plaso(log2timeline)集成进行制品解析,并支持直接 CSV/JSONL 摄入以在主动事件期间快速构建时间线。

架构与组件

核心组件

  • Timesketch 服务器:具有 REST API 的 Web 应用,用于时间线管理
  • OpenSearch/Elasticsearch:时间线事件的后端存储和搜索引擎
  • PostgreSQL:素描(Sketch)、故事和用户数据的元数据存储
  • Redis:后台处理的任务队列管理
  • Celery Workers:时间线上传和分析器的异步处理

数据流

证据来源 --> Plaso/log2timeline --> Plaso 存储文件 (.plaso)
     |                                           |
     v                                           v
  CSV/JSONL --> Timesketch 导入器 --> OpenSearch 索引
                                           |
                                           v
                                    Timesketch Web UI
                                    (搜索、分析、故事)

部署

Docker 部署(推荐)

# 克隆 Timesketch 仓库
git clone https://github.com/google/timesketch.git
cd timesketch

# 运行部署辅助脚本
cd docker
sudo docker compose up -d

# 默认访问:https://localhost:443
# 首次运行时生成管理员凭据

系统要求

  • 最低 8 GB RAM(大型调查建议 16+ GB)
  • 最低 4 个 CPU 核心
  • OpenSearch 索引的 SSD 存储
  • 已安装 Docker 和 Docker Compose

数据摄入方法

方法 1:Plaso 集成(全面)

# 使用 log2timeline 处理磁盘镜像
log2timeline.py --storage-file evidence.plaso /path/to/disk/image

# 处理 Windows 事件日志
log2timeline.py --parsers winevtx --storage-file windows_events.plaso /path/to/evtx/

# 处理多个证据来源
log2timeline.py --parsers "winevtx,prefetch,amcache,shimcache,userassist" \
  --storage-file full_analysis.plaso /path/to/mounted/image/

# 将 Plaso 文件导入 Timesketch
timesketch_importer -s "Case-2025-001" -t "Endpoint-WKS01" evidence.plaso

方法 2:CSV 导入(快速摄入)

message,datetime,timestamp_desc,source,hostname
"User login detected","2025-01-15T08:30:00Z","Event Recorded","Security Log","DC01"
"PowerShell execution","2025-01-15T08:31:15Z","Event Recorded","PowerShell","WKS042"
# 直接导入 CSV
timesketch_importer -s "Case-2025-001" -t "Quick-Triage" events.csv

方法 3:JSONL 导入(结构化数据)

{"message": "Suspicious logon from 10.1.2.3", "datetime": "2025-01-15T08:30:00Z", "timestamp_desc": "Event Recorded", "source_short": "Security", "hostname": "DC01"}

方法 4:Sigma 规则集成

# 上传 Sigma 规则用于自动检测
timesketch_importer --sigma-rules /path/to/sigma/rules/

分析工作流程

步骤 1:创建调查素描(Sketch)

1. 登录 Timesketch Web 界面
2. 创建新素描(调查案例)
3. 将相关时间线添加到素描中
4. 设置素描描述和标签

步骤 2:运行内置分析器

Timesketch 包含自动识别以下内容的分析器:

  • 浏览器搜索分析器:从浏览器历史中提取搜索查询
  • 事件链分析器:链接相关事件(下载 -> 执行)
  • 域名分析器:提取并分类域名
  • 特征提取分析器:识别 IP、URL、哈希
  • 地理位置分析器:将事件映射到地理位置
  • 相似度评分器:在时间线之间查找相似事件
  • Sigma 分析器:将事件与 Sigma 检测规则进行匹配
  • 账户查找器:识别用户账户活动模式
  • 标签器(Tagger):根据预定义规则应用标签

步骤 3:搜索和过滤

# Timesketch 查询语言中的搜索示例

# 查找与特定用户相关的所有事件
source_short:Security AND message:"john.admin"

# 查找 PowerShell 执行事件
data_type:"windows:evtx:record" AND event_identifier:4104

# 查找横向移动(Lateral Movement)指标
source_short:Security AND event_identifier:4624 AND xml_string:"LogonType\">3"

# 在特定时间范围内查找事件
datetime:[2025-01-15T00:00:00 TO 2025-01-15T23:59:59]

# 查找文件创建事件
data_type:"fs:stat" AND timestamp_desc:"Creation Time"

# 按标签搜索
tag:"suspicious" OR tag:"lateral_movement"

步骤 4:构建调查故事

1. 在素描中创建新故事
2. 添加支持每个发现的搜索视图
3. 用调查员注释标注关键事件
4. 将事件链接到 MITRE ATT&CK 技术
5. 按时间顺序记录攻击叙事
6. 导出故事以纳入事件报告

高级功能

协作调查

  • 多名分析师同时在同一素描上工作
  • 评论和注释持久化在事件上
  • 已保存的搜索在团队间共享
  • 调查故事在上下文中记录发现

API 自动化

from timesketch_api_client import config
from timesketch_api_client import client as ts_client

# 连接到 Timesketch
ts = ts_client.TimesketchApi(
    host_uri="https://timesketch.local",
    username="analyst",
    password="password"
)

# 获取素描
sketch = ts.get_sketch(1)

# 搜索事件
search = sketch.explore(
    query_string='event_identifier:4624 AND LogonType:3',
    return_fields='datetime,message,hostname,source_short'
)

# 为事件添加标签
for event in search.get('objects', []):
    sketch.tag_event(event['_id'], ['lateral_movement'])

与 Dissect 集成

# 使用 Dissect 进行更快的制品解析(Plaso 的替代方案)
target-query -f timesketch://timesketch.local/case-001 \
  targets/hostname/ -q "windows.evtx" --limit 0

时间线构建的关键数据源

来源解析器取证价值
Windows 事件日志(.evtx)winevtx认证、进程执行、服务
Prefetch 文件prefetch程序执行历史
MFT ($MFT)mft文件系统活动
注册表配置单元winreg系统配置、持久化(Persistence)
浏览器历史chrome/firefoxWeb 活动、下载
SyslogsyslogLinux/网络设备事件
CloudTrail 日志jsonlAWS API 活动
Azure 活动日志jsonlAzure 资源操作
防火墙日志csv/jsonl网络连接
代理日志csv/jsonlHTTP/HTTPS 流量

MITRE ATT&CK 映射

技术时间线指标
初始访问(TA0001)第一个恶意事件、钓鱼邮件接收
执行(T1059)PowerShell/CMD 事件、进程创建
持久化(TA0003)注册表修改、计划任务、服务
横向移动(TA0008)远程登录、SMB 连接、RDP 会话
数据外泄(TA0010)大量数据传输、云存储上传

参考资料

Skills enregistrées