关于 building-incident-timeline-with-timesketch
面向安全团队的 Timesketch 取证时间线实操指南,涵盖事件调查中的证据导入、分析、协作与报告整理。
主要功能
- 01支持 Plaso 和 CSV/JSONL 导入
- 02内置事件分析器
- 03搜索、标签与注释
- 04协作式调查故事
适用场景
- 01汇总端点与云端证据构建时间线
- 02使用分析器和 Sigma 规则筛查事件
- 03整理调查发现并生成事件报告
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill building-incident-timeline-with-timesketch安装后在 Claude Code 中输入/building-incident-timeline-with-timesketch确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEassets/template.mdreferences/api-reference.mdstandards.mdworkflows.mdscripts/agent.pyprocess.py详细介绍
使用 Timesketch 构建事件时间线
概述
Timesketch 是由 Google 开发的一款开源协作式取证时间线分析工具,使安全团队能够在事件调查期间可视化和分析来自多个来源的时间顺序数据。它摄取来自终端、服务器和云服务的日志与工件,将其规范化为统一的可搜索时间线,并提供强大的分析能力,包括内置分析器、打标签、草图注释和故事构建。Timesketch 与 Plaso(log2timeline)集成以进行工件解析,并支持直接摄取 CSV/JSONL,以便在事件处理过程中快速构建时间线。
何时使用
- 在环境中部署或配置使用 Timesketch 构建事件时间线的能力时
- 在建立与合规要求一致的安全控制时
- 在为该领域构建或改进安全架构时
- 在开展需要此实施的安全评估时
前置条件
- 熟悉事件响应概念和工具
- 可访问测试或实验环境以安全执行
- 已安装 Python 3.8+ 及所需依赖
- 任何测试活动均获得适当授权
架构与组件
核心组件
- Timesketch Server:带有 REST API 的 Web 应用,用于时间线管理
- OpenSearch/Elasticsearch:用于时间线事件的后端存储和搜索引擎
- PostgreSQL:用于草图、故事和用户数据的元数据存储
- Redis:用于后台处理的任务队列管理
- Celery Workers:时间线上传和分析器的异步处理
数据流
Evidence Sources --> Plaso/log2timeline --> Plaso storage file (.plaso)
| |
v v
CSV/JSONL --> Timesketch Importer --> OpenSearch Index
|
v
Timesketch Web UI
(Search, Analyze, Story)
部署
Docker 部署(推荐)
# Clone Timesketch repository
git clone https://github.com/google/timesketch.git
cd timesketch
# Run deployment helper script
cd docker
sudo docker compose up -d
# Default access: https://localhost:443
# Admin credentials generated during first run
系统要求
- 最低 8 GB RAM(大型调查建议 16+ GB)
- 最低 4 个 CPU 核心
- 用于 OpenSearch 索引的 SSD 存储
- 已安装 Docker 和 Docker Compose
数据摄取方法
方法 1:Plaso 集成(全面)
# Process disk image with log2timeline
log2timeline.py --storage-file evidence.plaso /path/to/disk/image
# Process Windows event logs
log2timeline.py --parsers winevtx --storage-file windows_events.plaso /path/to/evtx/
# Process multiple evidence sources
log2timeline.py --parsers "winevtx,prefetch,amcache,shimcache,userassist" \
--storage-file full_analysis.plaso /path/to/mounted/image/
# Import Plaso file into 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"
# Import CSV directly
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 规则集成
# Upload Sigma rules for automated detection
timesketch_importer --sigma-rules /path/to/sigma/rules/
分析工作流
步骤 1:创建调查草图
1. Log into Timesketch web interface
2. Create new sketch (investigation case)
3. Add relevant timelines to the sketch
4. Set sketch description and tags
步骤 2:运行内置分析器
Timesketch 包含可自动识别以下内容的分析器:
- Browser Search Analyzer:从浏览器历史记录中提取搜索查询
- Chain of Events Analyzer:关联相关事件(下载 -> 执行)
- Domain Analyzer:提取并分类域名
- Feature Extraction Analyzer:识别 IP、URL、哈希
- Geo Location Analyzer:将事件映射到地理位置
- Similarity Scorer:查找跨时间线的相似事件
- Sigma Analyzer:将事件与 Sigma 检测规则进行匹配
- Account Finder:识别用户账户活动模式
- Tagger:根据预定义规则应用标签
步骤 3:搜索和过滤
# Search examples in Timesketch query language
# Find all events related to specific user
source_short:Security AND message:"john.admin"
# Find PowerShell execution events
data_type:"windows:evtx:record" AND event_identifier:4104
# Find lateral movement indicators
source_short:Security AND event_identifier:4624 AND xml_string:"LogonType\">3"
# Find events within specific time range
datetime:[2025-01-15T00:00:00 TO 2025-01-15T23:59:59]
# Find file creation events
data_type:"fs:stat" AND timestamp_desc:"Creation Time"
# Search with tags
tag:"suspicious" OR tag:"lateral_movement"
步骤 4:构建调查故事
1. Create new story within the sketch
2. Add search views that support each finding
3. Annotate key events with investigator notes
4. Link events to MITRE ATT&CK techniques
5. Document the attack narrative chronologically
6. Export story for inclusion in incident report
高级功能
协作调查
- 多名分析师同时处理同一个草图
- 评论和注释持久保留在事件上
- 保存的搜索在团队内共享
- 调查故事在上下文中记录发现
API 自动化
from timesketch_api_client import config
from timesketch_api_client import client as ts_client
# Connect to Timesketch
ts = ts_client.TimesketchApi(
host_uri="https://timesketch.local",
username="analyst",
password="password"
)
# Get sketch
sketch = ts.get_sketch(1)
# Search events
search = sketch.explore(
query_string='event_identifier:4624 AND LogonType:3',
return_fields='datetime,message,hostname,source_short'
)
# Add tags to events
for event in search.get('objects', []):
sketch.tag_event(event['_id'], ['lateral_movement'])
与 Dissect 集成
# Use Dissect for faster artifact parsing (alternative to 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 | 系统配置、持久化 |
| 浏览器历史 | chrome/firefox | Web 活动、下载 |
| Syslog | syslog | Linux/网络设备事件 |
| CloudTrail 日志 | jsonl | AWS API 活动 |
| Azure 活动日志 | jsonl | Azure 资源操作 |
| 防火墙日志 | csv/jsonl | 网络连接 |
| 代理日志 | csv/jsonl | HTTP/HTTPS 流量 |
MITRE ATT&CK 映射
| 技术 | 时间线指标 |
|---|---|
| 初始访问 (TA0001) | 首个恶意事件、钓鱼邮件接收 |
| 执行 (T1059) | PowerShell/CMD 事件、进程创建 |
| 持久化 (TA0003) | 注册表修改、计划任务、服务 |
| 横向移动 (TA0008) | 远程登录、SMB 连接、RDP 会话 |
| 数据外泄 (TA0010) | 大规模数据传输、云存储上传 |
参考资料
评论
支持 Markdown