跳到正文
Skillpedia
数据库35k · #8309

performing-sqlite-database-forensics

它能做什么

这个工具用于调查 SQLite 数据库,许多应用都用它来存储信息。它会查找已被删除或尚未永久保存的数据,比如浏览记录或消息。

适用场景

  • ✓进行安全事件调查时。
  • ✓测试使用 SQLite 的应用的安全性时。
  • ✓尝试从数据库中恢复丢失的信息时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-sqlite-database-forensics/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-sqlite-database-forensics/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“从 WhatsApp 数据库中恢复已删除的数据。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会检查 SQLite 数据库的内部结构,查找被标记为已删除但尚未真正清除的数据片段。它还会分析日志文件,这些文件记录了数据在最终写入前的变更。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Performing SQLite Database Forensics

Overview

SQLite is the most widely deployed database engine in the world, used by virtually every mobile application, web browser, and many desktop applications to store user data. In digital forensics, SQLite databases are critical evidence sources containing browser history, messaging records, call logs, GPS locations, application preferences, and cached content. Forensic analysis goes beyond simple SQL queries to examine the internal B-tree page structures, freelist pages containing deleted records, Write-Ahead Log (WAL) files preserving transaction history, and unallocated space within database pages where recoverable data may persist after deletion.

When to Use

  • When conducting security assessments that involve performing sqlite database forensics
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • DB Browser for SQLite (sqlitebrowser)
  • SQLite command-line tools (sqlite3)
  • Python 3.8+ with sqlite3 module
  • Belkasoft Evidence Center or Axiom (commercial)
  • Hex editor (HxD, 010 Editor) for manual page inspection
  • Understanding of B-tree data structures

SQLite Internal Structure

Database Header (First 100 Bytes)

Offset Size Description
0 16 Magic string: "SQLite format 3\000"
16 2 Page size (512-65536 bytes)
18 1 File format write version
19 1 File format read version
24 4 File change counter
28 4 Database size in pages
32 4 First freelist trunk page number
36 4 Total freelist pages
52 4 Text encoding (1=UTF-8, 2=UTF-16le, 3=UTF-16be)
96 4 Version-valid-for number

Page Types

Type ID Description
B-tree Interior 0x05 Internal table node
B-tree Leaf 0x0D Table leaf page containing actual records
Index Interior 0x02 Internal index node
Index Leaf 0x0A Index leaf page
Freelist Trunk - Tracks freed pages
Freelist Leaf - Freed page with recoverable data
Overflow - Continuation of large records

Deleted Record Recovery

Method 1: Freelist Page Analysis

When records are deleted, SQLite may place their pages on the freelist rather than overwriting them immediately.

import struct
import sqlite3
import os


def analyze_freelist(db_path: str) -> dict:
    """Analyze SQLite freelist to identify pages containing deleted data."""
    with open(db_path, "rb") as f:
        # Read header
        header = f.read(100)
        page_size = struct.unpack(">H", header[16:18])[0]
        if page_size == 1:
            page_size = 65536
        first_freelist_page = struct.unpack(">I", header[32:36])[0]
        total_freelist_pages = struct.unpack(">I", header[36:40])[0]

        freelist_info = {
            "page_size": page_size,
            "first_freelist_page": first_freelist_page,
            "total_freelist_pages": total_freelist_pages,
            "trunk_pages": [],
            "leaf_pages": []
        }

        if first_freelist_page == 0:
            return freelist_info

        # Walk the freelist trunk chain
        trunk_page = first_freelist_page
        while trunk_page != 0:
            offset = (trunk_page - 1) * page_size
            f.seek(offset)
            page_data = f.read(page_size)

            next_trunk = struct.unpack(">I", page_data[0:4])[0]
            leaf_count = struct.unpack(">I", page_data[4:8])[0]

            leaves = []
            for i in range(leaf_count):
                leaf_page = struct.unpack(">I", page_data[8 + i * 4:12 + i * 4])[0]
                leaves.append(leaf_page)

            freelist_info["trunk_pages"].append({
                "page_number": trunk_page,
                "next_trunk": next_trunk,
                "leaf_count": leaf_count,
                "leaf_pages": leaves
            })
            freelist_info["leaf_pages"].extend(leaves)
            trunk_page = next_trunk

    return freelist_info


def extract_freelist_content(db_path: str, output_dir: str):
    """Extract raw content from freelist pages for analysis."""
    info = analyze_freelist(db_path)
    os.makedirs(output_dir, exist_ok=True)

    with open(db_path, "rb") as f:
        page_size = info["page_size"]

…
常见问题

什么是 SQLite 数据库?

这是一种轻量、简单的数据库类型,被手机和电脑上的许多应用用来存储信息。

这里的“已删除数据”是什么意思?

指数据库中曾经存在、但后来被移除的信息。工具会尝试在这些数据被永久覆盖之前把它找回来。

什么是 WAL 文件?

WAL 是 Write-Ahead Log(预写式日志)的缩写。它记录数据库在永久保存之前所做的变更,有助于数据恢复。

详情

作者的原始描述

Performs forensic analysis of SQLite databases by examining B-tree page structures, recovering deleted records from freelist pages and Write-Ahead Log (WAL) files, decoding encoded timestamps, and extracting evidence from browser history, messaging apps, and mobile device databases. Use when recovering deleted or unallocated data from a SQLite database during digital forensics or mobile/browser ev

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#8309
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能