[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HNG74Y94SA3AVF8BHPVBFM":3,"skill-same:01M6HNG74Y94SA3AVF8BHPVBFM":124},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":67,"commitSha":68,"skillDirectory":69,"forksCount":70,"repositoryHtmlUrl":71,"repositoryHomepageUrl":6,"ownerHtmlUrl":72,"ownerBlogUrl":6,"ownerDescription":73,"updatedAt":74,"install":75,"resources":88},"01M6HNG74Y94SA3AVF8BHPVBFM","performing-sqlite-database-forensics",null,"Perform forensic analysis of SQLite databases to recover deleted records from freelists and WAL files, decode encoded timestamps, and extract evidence from browser history, messaging apps, and mobile device databases.","HenriqueMC17\u002Fagente-core","HenriqueMC17","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F206460478?v=4","01M6HB63HBBF18AC4H09XTB549","Henrique Monteiro Cardoso","01M6HB63NGSQXWKWCFWW2B20W0",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"performing","database","forensics","sqlite","performing sqlite database forensics","write-ahead-log","timestamps","apps","files","log","databases","deleted-records","browser-history","cybersecurity","wal","freelist","database-forensics","analysis","messaging","browser","2026-11-10 10:12:30",false,"---\nname: performing-sqlite-database-forensics\ndescription: Perform forensic analysis of SQLite databases to recover deleted records from freelists and WAL files, decode encoded timestamps, and extract evidence from browser history, messaging apps, and mobile device databases.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags:\n- sqlite\n- database-forensics\n- freelist\n- wal\n- write-ahead-log\n- browser-history\n- mobile-forensics\n- deleted-records\n- b-tree\n- unallocated-space\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- RS.AN-01\n- RS.AN-03\n- DE.AE-02\n- RS.MA-01\nmitre_attack:\n- T1005\n- T1074\n- T1119\n- T1070\n- T1059\ncategory: performing-sqlite-database-forensics\n---\n# Performing SQLite Database Forensics\n\n## Overview\n\nSQLite 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.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing sqlite database forensics\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- DB Browser for SQLite (sqlitebrowser)\n- SQLite command-line tools (sqlite3)\n- Python 3.8+ with sqlite3 module\n- Belkasoft Evidence Center or Axiom (commercial)\n- Hex editor (HxD, 010 Editor) for manual page inspection\n- Understanding of B-tree data structures\n\n## SQLite Internal Structure\n\n### Database Header (First 100 Bytes)\n\n| Offset | Size | Description |\n|--------|------|-------------|\n| 0 | 16 | Magic string: \"SQLite format 3\\000\" |\n| 16 | 2 | Page size (512-65536 bytes) |\n| 18 | 1 | File format write version |\n| 19 | 1 | File format read version |\n| 24 | 4 | File change counter |\n| 28 | 4 | Database size in pages |\n| 32 | 4 | First freelist trunk page number |\n| 36 | 4 | Total freelist pages |\n| 52 | 4 | Text encoding (1=UTF-8, 2=UTF-16le, 3=UTF-16be) |\n| 96 | 4 | Version-valid-for number |\n\n### Page Types\n\n| Type | ID | Description |\n|------|----|-------------|\n| B-tree Interior | 0x05 | Internal table node |\n| B-tree Leaf | 0x0D | Table leaf page containing actual records |\n| Index Interior | 0x02 | Internal index node |\n| Index Leaf | 0x0A | Index leaf page |\n| Freelist Trunk | - | Tracks freed pages |\n| Freelist Leaf | - | Freed page with recoverable data |\n| Overflow | - | Continuation of large records |\n\n## Deleted Record Recovery\n\n### Method 1: Freelist Page Analysis\n\nWhen records are deleted, SQLite may place their pages on the freelist rather than overwriting them immediately.\n\n```python\nimport struct\nimport sqlite3\nimport os\n\n\ndef analyze_freelist(db_path: str) -> dict:\n    \"\"\"Analyze SQLite freelist to identify pages containing deleted data.\"\"\"\n    with open(db_path, \"rb\") as f:\n        # Read header\n        header = f.read(100)\n        page_size = struct.unpack(\">H\", header[16:18])[0]\n        if page_size == 1:\n            page_size = 65536\n        first_freelist_page = struct.unpack(\">I\", header[32:36])[0]\n        total_freelist_pages = struct.unpack(\">I\", header[36:40])[0]\n\n        freelist_info = {\n            \"page_size\": page_size,\n            \"first_freelist_page\": first_freelist_page,\n            \"total_freelist_pages\": total_freelist_pages,\n            \"trunk_pages\": [],\n            \"leaf_pages\": []\n        }\n\n        if first_freelist_page == 0:\n            return freelist_info\n\n        # Walk the freelist trunk chain\n        trunk_page = first_freelist_page\n        while trunk_page != 0:\n            offset = (trunk_page - 1) * page_size\n            f.seek(offset)\n            page_data = f.read(page_size)\n\n            next_trunk = struct.unpack(\">I\", page_data[0:4])[0]\n            leaf_count = struct.unpack(\">I\", page_data[4:8])[0]\n\n            leaves = []\n            for i in range(leaf_count):\n                leaf_page = struct.unpack(\">I\", page_data[8 + i * 4:12 + i * 4])[0]\n                leaves.append(leaf_page)\n\n            freelist_info[\"trunk_pages\"].append({\n                \"page_number\": trunk_page,\n                \"next_trunk\": next_trunk,\n                \"leaf_count\": leaf_count,\n                \"leaf_pages\": leaves\n            })\n            freelist_info[\"leaf_pages\"].extend(leaves)\n            trunk_page = next_trunk\n\n    return freelist_info\n\n\ndef extract_freelist_content(db_path: str, output_dir: str):\n    \"\"\"Extract raw content from freelist pages for analysis.\"\"\"\n    info = analyze_freelist(db_path)\n    os.makedirs(output_dir, exist_ok=True)\n\n    with open(db_path, \"rb\") as f:\n        page_size = info[\"page_size\"]\n        for page_num in info[\"leaf_pages\"]:\n            offset = (page_num - 1) * page_size\n            f.seek(offset)\n            page_data = f.read(page_size)\n            output_file = os.path.join(output_dir, f\"freelist_page_{page_num}.bin\")\n            with open(output_file, \"wb\") as out:\n                out.write(page_data)\n\n    return len(info[\"leaf_pages\"])\n```\n\n### Method 2: WAL (Write-Ahead Log) Analysis\n\nThe WAL file contains pending transactions that have not yet been checkpointed back to the main database.\n\n```python\ndef parse_wal_header(wal_path: str) -> dict:\n    \"\"\"Parse SQLite WAL file header and frame inventory.\"\"\"\n    with open(wal_path, \"rb\") as f:\n        header = f.read(32)\n        magic = struct.unpack(\">I\", header[0:4])[0]\n        file_format = struct.unpack(\">I\", header[4:8])[0]\n        page_size = struct.unpack(\">I\", header[8:12])[0]\n        checkpoint_seq = struct.unpack(\">I\", header[12:16])[0]\n        salt1 = struct.unpack(\">I\", header[16:20])[0]\n        salt2 = struct.unpack(\">I\", header[20:24])[0]\n\n        wal_info = {\n            \"magic\": hex(magic),\n            \"format\": file_format,\n            \"page_size\": page_size,\n            \"checkpoint_sequence\": checkpoint_seq,\n            \"frames\": []\n        }\n\n        # Parse frames (24-byte header + page_size data each)\n        frame_offset = 32\n        frame_num = 0\n        file_size = os.path.getsize(wal_path)\n\n        while frame_offset + 24 + page_size \u003C= file_size:\n            f.seek(frame_offset)\n            frame_header = f.read(24)\n            page_number = struct.unpack(\">I\", frame_header[0:4])[0]\n            db_size_after = struct.unpack(\">I\", frame_header[4:8])[0]\n\n            wal_info[\"frames\"].append({\n                \"frame_number\": frame_num,\n                \"page_number\": page_number,\n                \"db_size_pages\": db_size_after,\n                \"offset\": frame_offset\n            })\n            frame_offset += 24 + page_size\n            frame_num += 1\n\n    return wal_info\n```\n\n### Method 3: Unallocated Space Within Pages\n\nDeleted cells within active B-tree pages leave data in the unallocated region between the cell pointer array and the cell content area.\n\n```python\ndef analyze_unallocated_space(db_path: str, page_number: int) -> dict:\n    \"\"\"Analyze unallocated space within a specific B-tree page.\"\"\"\n    with open(db_path, \"rb\") as f:\n        header = f.read(100)\n        page_size = struct.unpack(\">H\", header[16:18])[0]\n        if page_size == 1:\n            page_size = 65536\n\n        offset = (page_number - 1) * page_size\n        f.seek(offset)\n        page_data = f.read(page_size)\n\n        # Parse page header (8 or 12 bytes depending on type)\n        page_type = page_data[0]\n        first_freeblock = struct.unpack(\">H\", page_data[1:3])[0]\n        cell_count = struct.unpack(\">H\", page_data[3:5])[0]\n        cell_content_offset = struct.unpack(\">H\", page_data[5:7])[0]\n        if cell_content_offset == 0:\n            cell_content_offset = 65536\n\n        header_size = 12 if page_type in (0x02, 0x05) else 8\n        cell_pointer_end = header_size + cell_count * 2\n\n        unallocated_start = cell_pointer_end\n        unallocated_end = cell_content_offset\n        unallocated_size = unallocated_end - unallocated_start\n\n        return {\n            \"page_number\": page_number,\n            \"page_type\": hex(page_type),\n            \"cell_count\": cell_count,\n            \"unallocated_start\": unallocated_start,\n            \"unallocated_end\": unallocated_end,\n            \"unallocated_size\": unallocated_size,\n            \"unallocated_data\": page_data[unallocated_start:unallocated_end].hex()\n        }\n```\n\n## Common Forensic Databases\n\n| Application | Database File | Key Tables |\n|------------|--------------|------------|\n| Chrome | History | urls, visits, downloads, keyword_search_terms |\n| Firefox | places.sqlite | moz_places, moz_historyvisits |\n| Safari | History.db | history_items, history_visits |\n| WhatsApp | msgstore.db | messages, chat_list |\n| Signal | signal.sqlite | sms, mms |\n| iMessage | sms.db | message, handle, chat |\n| Android SMS | mmssms.db | sms, mms, threads |\n| Skype | main.db | Messages, Conversations |\n\n## Timestamp Decoding\n\n```python\nfrom datetime import datetime, timedelta\n\ndef decode_chrome_timestamp(chrome_ts: int) -> datetime:\n    \"\"\"Convert Chrome\u002FWebKit timestamp to datetime (microseconds since 1601-01-01).\"\"\"\n    epoch_delta = 11644473600\n    return datetime.utcfromtimestamp((chrome_ts \u002F 1000000) - epoch_delta)\n\ndef decode_unix_timestamp(unix_ts: int) -> datetime:\n    \"\"\"Convert Unix timestamp to datetime.\"\"\"\n    return datetime.utcfromtimestamp(unix_ts)\n\ndef decode_mac_absolute_time(mac_ts: float) -> datetime:\n    \"\"\"Convert Mac Absolute Time (seconds since 2001-01-01).\"\"\"\n    mac_epoch = datetime(2001, 1, 1)\n    return mac_epoch + timedelta(seconds=mac_ts)\n\ndef decode_mozilla_timestamp(moz_ts: int) -> datetime:\n    \"\"\"Convert Mozilla PRTime (microseconds since Unix epoch).\"\"\"\n    return datetime.utcfromtimestamp(moz_ts \u002F 1000000)\n```\n\n## References\n\n- SQLite File Format: https:\u002F\u002Fwww.sqlite.org\u002Ffileformat2.html\n- Belkasoft SQLite Analysis: https:\u002F\u002Fbelkasoft.com\u002Fsqlite-analysis\n- Spyder Forensics SQLite Training: https:\u002F\u002Fwww.spyderforensics.com\u002Fsqlite-forensic-fundamentals-2025\u002F\n- Forensic Analysis of Damaged SQLite Databases: https:\u002F\u002Fwww.forensicfocus.com\u002Farticles\u002Fforensic-analysis-of-damaged-sqlite-databases\u002F\n\n## Example Output\n\n```text\n$ python3 sqlite_forensics.py --db \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory \\\n    --wal \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory-wal \\\n    --journal \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory-journal \\\n    --output \u002Fanalysis\u002Fsqlite_report\n\nSQLite Database Forensic Analyzer v2.0\n========================================\nDatabase:    \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory\nSize:        48.2 MB\nSQLite Ver:  3.39.5\nPage Size:   4096 bytes\nTotal Pages: 12,345\nEncoding:    UTF-8\n\n[+] Analyzing WAL (Write-Ahead Log)...\n    WAL file:       History-wal (2.1 MB)\n    WAL frames:     512\n    Checkpointed:   No (contains uncommitted data)\n    Recoverable rows from WAL: 234\n\n[+] Analyzing journal file...\n    Journal file:   History-journal (0 bytes - rolled back)\n\n[+] Scanning for deleted records (freelist pages)...\n    Freelist pages:     456\n    Deleted records recovered: 1,892\n\n[+] Analyzing table: urls\n    Active rows:     12,456\n    Deleted rows:    1,234 (recovered from freelist)\n    WAL-only rows:   89\n\n--- Recovered Deleted URLs (Last 10) ---\nRow ID | URL                                              | Title                    | Visit Count | Last Visit (UTC)\n-------|--------------------------------------------------|--------------------------|-------------|---------------------\n89234  | https:\u002F\u002Fmega.nz\u002Ffolder\u002FxYz123#key=AbCdEf        | MEGA                     | 5           | 2024-01-16 03:20:00\n89235  | https:\u002F\u002Ftransfer.sh\u002Fabc123\u002Fdata.7z               | transfer.sh              | 1           | 2024-01-16 03:25:00\n89240  | https:\u002F\u002Ftemp-mail.org\u002Fen\u002F                        | Temp Mail                | 3           | 2024-01-15 13:00:00\n89241  | https:\u002F\u002Fbrowserleaks.com\u002Fip                      | IP Leak Test             | 1           | 2024-01-15 12:55:00\n89245  | https:\u002F\u002Fwww.virustotal.com\u002Fgui\u002Ffile\u002Fa1b2c3...    | VirusTotal               | 2           | 2024-01-15 14:30:00\n89250  | https:\u002F\u002Fgithub.com\u002Fgentilkiwi\u002Fmimikatz\u002Freleases  | Mimikatz Releases        | 1           | 2024-01-15 16:00:00\n89260  | https:\u002F\u002Fraw.githubusercontent.com\u002F...\u002Fpayload.ps1| GitHub Raw               | 1           | 2024-01-15 14:34:00\n89270  | https:\u002F\u002Fpastebin.com\u002Fedit\u002FkL9mN2pQ               | Pastebin - Edit          | 2           | 2024-01-15 14:42:00\n89280  | https:\u002F\u002Fduckduckgo.com\u002F?q=clear+browser+history  | DuckDuckGo               | 1           | 2024-01-17 22:00:00\n89285  | https:\u002F\u002Fduckduckgo.com\u002F?q=anti+forensics+tools   | DuckDuckGo               | 1           | 2024-01-17 22:05:00\n\n[+] Analyzing table: downloads\n    Active rows:     234\n    Deleted rows:    12 (recovered)\n\n--- Recovered Deleted Downloads ---\nRow ID | Filename               | URL                                    | Size      | Start Time (UTC)\n-------|------------------------|----------------------------------------|-----------|---------------------\n5012   | payload.ps1            | https:\u002F\u002Fraw.githubusercontent.com\u002F...  | 4,096     | 2024-01-15 14:34:00\n5015   | mimikatz_trunk.zip     | https:\u002F\u002Fgithub.com\u002F...\u002Freleases\u002F...    | 1,892,352 | 2024-01-15 16:00:00\n5018   | netscan_portable.zip   | https:\u002F\u002Fwww.softperfect.com\u002F...        | 5,242,880 | 2024-01-15 15:05:00\n\n[+] Slack space analysis...\n    Pages with slack space data: 234\n    Partial strings recovered:   67 fragments\n\nSummary:\n  Total records analyzed:  14,578 (active) + 3,126 (deleted\u002FWAL)\n  Evidence-relevant URLs:  23 (flagged)\n  Deleted downloads:       12 (3 tool-related)\n  Anti-forensics evidence: Browser history deletion detected\n  Report: \u002Fanalysis\u002Fsqlite_report\u002Fsqlite_forensics.json\n  Recovered DB: \u002Fanalysis\u002Fsqlite_report\u002FHistory_recovered.db\n```\n","# Performing SQLite Database Forensics\n\n## Overview\n\nSQLite 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.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing sqlite database forensics\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- DB Browser for SQLite (sqlitebrowser)\n- SQLite command-line tools (sqlite3)\n- Python 3.8+ with sqlite3 module\n- Belkasoft Evidence Center or Axiom (commercial)\n- Hex editor (HxD, 010 Editor) for manual page inspection\n- Understanding of B-tree data structures\n\n## SQLite Internal Structure\n\n### Database Header (First 100 Bytes)\n\n| Offset | Size | Description |\n|--------|------|-------------|\n| 0 | 16 | Magic string: \"SQLite format 3\\000\" |\n| 16 | 2 | Page size (512-65536 bytes) |\n| 18 | 1 | File format write version |\n| 19 | 1 | File format read version |\n| 24 | 4 | File change counter |\n| 28 | 4 | Database size in pages |\n| 32 | 4 | First freelist trunk page number |\n| 36 | 4 | Total freelist pages |\n| 52 | 4 | Text encoding (1=UTF-8, 2=UTF-16le, 3=UTF-16be) |\n| 96 | 4 | Version-valid-for number |\n\n### Page Types\n\n| Type | ID | Description |\n|------|----|-------------|\n| B-tree Interior | 0x05 | Internal table node |\n| B-tree Leaf | 0x0D | Table leaf page containing actual records |\n| Index Interior | 0x02 | Internal index node |\n| Index Leaf | 0x0A | Index leaf page |\n| Freelist Trunk | - | Tracks freed pages |\n| Freelist Leaf | - | Freed page with recoverable data |\n| Overflow | - | Continuation of large records |\n\n## Deleted Record Recovery\n\n### Method 1: Freelist Page Analysis\n\nWhen records are deleted, SQLite may place their pages on the freelist rather than overwriting them immediately.\n\n```python\nimport struct\nimport sqlite3\nimport os\n\n\ndef analyze_freelist(db_path: str) -> dict:\n    \"\"\"Analyze SQLite freelist to identify pages containing deleted data.\"\"\"\n    with open(db_path, \"rb\") as f:\n        # Read header\n        header = f.read(100)\n        page_size = struct.unpack(\">H\", header[16:18])[0]\n        if page_size == 1:\n            page_size = 65536\n        first_freelist_page = struct.unpack(\">I\", header[32:36])[0]\n        total_freelist_pages = struct.unpack(\">I\", header[36:40])[0]\n\n        freelist_info = {\n            \"page_size\": page_size,\n            \"first_freelist_page\": first_freelist_page,\n            \"total_freelist_pages\": total_freelist_pages,\n            \"trunk_pages\": [],\n            \"leaf_pages\": []\n        }\n\n        if first_freelist_page == 0:\n            return freelist_info\n\n        # Walk the freelist trunk chain\n        trunk_page = first_freelist_page\n        while trunk_page != 0:\n            offset = (trunk_page - 1) * page_size\n            f.seek(offset)\n            page_data = f.read(page_size)\n\n            next_trunk = struct.unpack(\">I\", page_data[0:4])[0]\n            leaf_count = struct.unpack(\">I\", page_data[4:8])[0]\n\n            leaves = []\n            for i in range(leaf_count):\n                leaf_page = struct.unpack(\">I\", page_data[8 + i * 4:12 + i * 4])[0]\n                leaves.append(leaf_page)\n\n            freelist_info[\"trunk_pages\"].append({\n                \"page_number\": trunk_page,\n                \"next_trunk\": next_trunk,\n                \"leaf_count\": leaf_count,\n                \"leaf_pages\": leaves\n            })\n            freelist_info[\"leaf_pages\"].extend(leaves)\n            trunk_page = next_trunk\n\n    return freelist_info\n\n\ndef extract_freelist_content(db_path: str, output_dir: str):\n    \"\"\"Extract raw content from freelist pages for analysis.\"\"\"\n    info = analyze_freelist(db_path)\n    os.makedirs(output_dir, exist_ok=True)\n\n    with open(db_path, \"rb\") as f:\n        page_size = info[\"page_size\"]\n        for page_num in info[\"leaf_pages\"]:\n            offset = (page_num - 1) * page_size\n            f.seek(offset)\n            page_data = f.read(page_size)\n            output_file = os.path.join(output_dir, f\"freelist_page_{page_num}.bin\")\n            with open(output_file, \"wb\") as out:\n                out.write(page_data)\n\n    return len(info[\"leaf_pages\"])\n```\n\n### Method 2: WAL (Write-Ahead Log) Analysis\n\nThe WAL file contains pending transactions that have not yet been checkpointed back to the main database.\n\n```python\ndef parse_wal_header(wal_path: str) -> dict:\n    \"\"\"Parse SQLite WAL file header and frame inventory.\"\"\"\n    with open(wal_path, \"rb\") as f:\n        header = f.read(32)\n        magic = struct.unpack(\">I\", header[0:4])[0]\n        file_format = struct.unpack(\">I\", header[4:8])[0]\n        page_size = struct.unpack(\">I\", header[8:12])[0]\n        checkpoint_seq = struct.unpack(\">I\", header[12:16])[0]\n        salt1 = struct.unpack(\">I\", header[16:20])[0]\n        salt2 = struct.unpack(\">I\", header[20:24])[0]\n\n        wal_info = {\n            \"magic\": hex(magic),\n            \"format\": file_format,\n            \"page_size\": page_size,\n            \"checkpoint_sequence\": checkpoint_seq,\n            \"frames\": []\n        }\n\n        # Parse frames (24-byte header + page_size data each)\n        frame_offset = 32\n        frame_num = 0\n        file_size = os.path.getsize(wal_path)\n\n        while frame_offset + 24 + page_size \u003C= file_size:\n            f.seek(frame_offset)\n            frame_header = f.read(24)\n            page_number = struct.unpack(\">I\", frame_header[0:4])[0]\n            db_size_after = struct.unpack(\">I\", frame_header[4:8])[0]\n\n            wal_info[\"frames\"].append({\n                \"frame_number\": frame_num,\n                \"page_number\": page_number,\n                \"db_size_pages\": db_size_after,\n                \"offset\": frame_offset\n            })\n            frame_offset += 24 + page_size\n            frame_num += 1\n\n    return wal_info\n```\n\n### Method 3: Unallocated Space Within Pages\n\nDeleted cells within active B-tree pages leave data in the unallocated region between the cell pointer array and the cell content area.\n\n```python\ndef analyze_unallocated_space(db_path: str, page_number: int) -> dict:\n    \"\"\"Analyze unallocated space within a specific B-tree page.\"\"\"\n    with open(db_path, \"rb\") as f:\n        header = f.read(100)\n        page_size = struct.unpack(\">H\", header[16:18])[0]\n        if page_size == 1:\n            page_size = 65536\n\n        offset = (page_number - 1) * page_size\n        f.seek(offset)\n        page_data = f.read(page_size)\n\n        # Parse page header (8 or 12 bytes depending on type)\n        page_type = page_data[0]\n        first_freeblock = struct.unpack(\">H\", page_data[1:3])[0]\n        cell_count = struct.unpack(\">H\", page_data[3:5])[0]\n        cell_content_offset = struct.unpack(\">H\", page_data[5:7])[0]\n        if cell_content_offset == 0:\n            cell_content_offset = 65536\n\n        header_size = 12 if page_type in (0x02, 0x05) else 8\n        cell_pointer_end = header_size + cell_count * 2\n\n        unallocated_start = cell_pointer_end\n        unallocated_end = cell_content_offset\n        unallocated_size = unallocated_end - unallocated_start\n\n        return {\n            \"page_number\": page_number,\n            \"page_type\": hex(page_type),\n            \"cell_count\": cell_count,\n            \"unallocated_start\": unallocated_start,\n            \"unallocated_end\": unallocated_end,\n            \"unallocated_size\": unallocated_size,\n            \"unallocated_data\": page_data[unallocated_start:unallocated_end].hex()\n        }\n```\n\n## Common Forensic Databases\n\n| Application | Database File | Key Tables |\n|------------|--------------|------------|\n| Chrome | History | urls, visits, downloads, keyword_search_terms |\n| Firefox | places.sqlite | moz_places, moz_historyvisits |\n| Safari | History.db | history_items, history_visits |\n| WhatsApp | msgstore.db | messages, chat_list |\n| Signal | signal.sqlite | sms, mms |\n| iMessage | sms.db | message, handle, chat |\n| Android SMS | mmssms.db | sms, mms, threads |\n| Skype | main.db | Messages, Conversations |\n\n## Timestamp Decoding\n\n```python\nfrom datetime import datetime, timedelta\n\ndef decode_chrome_timestamp(chrome_ts: int) -> datetime:\n    \"\"\"Convert Chrome\u002FWebKit timestamp to datetime (microseconds since 1601-01-01).\"\"\"\n    epoch_delta = 11644473600\n    return datetime.utcfromtimestamp((chrome_ts \u002F 1000000) - epoch_delta)\n\ndef decode_unix_timestamp(unix_ts: int) -> datetime:\n    \"\"\"Convert Unix timestamp to datetime.\"\"\"\n    return datetime.utcfromtimestamp(unix_ts)\n\ndef decode_mac_absolute_time(mac_ts: float) -> datetime:\n    \"\"\"Convert Mac Absolute Time (seconds since 2001-01-01).\"\"\"\n    mac_epoch = datetime(2001, 1, 1)\n    return mac_epoch + timedelta(seconds=mac_ts)\n\ndef decode_mozilla_timestamp(moz_ts: int) -> datetime:\n    \"\"\"Convert Mozilla PRTime (microseconds since Unix epoch).\"\"\"\n    return datetime.utcfromtimestamp(moz_ts \u002F 1000000)\n```\n\n## References\n\n- SQLite File Format: https:\u002F\u002Fwww.sqlite.org\u002Ffileformat2.html\n- Belkasoft SQLite Analysis: https:\u002F\u002Fbelkasoft.com\u002Fsqlite-analysis\n- Spyder Forensics SQLite Training: https:\u002F\u002Fwww.spyderforensics.com\u002Fsqlite-forensic-fundamentals-2025\u002F\n- Forensic Analysis of Damaged SQLite Databases: https:\u002F\u002Fwww.forensicfocus.com\u002Farticles\u002Fforensic-analysis-of-damaged-sqlite-databases\u002F\n\n## Example Output\n\n```text\n$ python3 sqlite_forensics.py --db \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory \\\n    --wal \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory-wal \\\n    --journal \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory-journal \\\n    --output \u002Fanalysis\u002Fsqlite_report\n\nSQLite Database Forensic Analyzer v2.0\n========================================\nDatabase:    \u002Fevidence\u002Fchrome\u002FDefault\u002FHistory\nSize:        48.2 MB\nSQLite Ver:  3.39.5\nPage Size:   4096 bytes\nTotal Pages: 12,345\nEncoding:    UTF-8\n\n[+] Analyzing WAL (Write-Ahead Log)...\n    WAL file:       History-wal (2.1 MB)\n    WAL frames:     512\n    Checkpointed:   No (contains uncommitted data)\n    Recoverable rows from WAL: 234\n\n[+] Analyzing journal file...\n    Journal file:   History-journal (0 bytes - rolled back)\n\n[+] Scanning for deleted records (freelist pages)...\n    Freelist pages:     456\n    Deleted records recovered: 1,892\n\n[+] Analyzing table: urls\n    Active rows:     12,456\n    Deleted rows:    1,234 (recovered from freelist)\n    WAL-only rows:   89\n\n--- Recovered Deleted URLs (Last 10) ---\nRow ID | URL                                              | Title                    | Visit Count | Last Visit (UTC)\n-------|--------------------------------------------------|--------------------------|-------------|---------------------\n89234  | https:\u002F\u002Fmega.nz\u002Ffolder\u002FxYz123#key=AbCdEf        | MEGA                     | 5           | 2024-01-16 03:20:00\n89235  | https:\u002F\u002Ftransfer.sh\u002Fabc123\u002Fdata.7z               | transfer.sh              | 1           | 2024-01-16 03:25:00\n89240  | https:\u002F\u002Ftemp-mail.org\u002Fen\u002F                        | Temp Mail                | 3           | 2024-01-15 13:00:00\n89241  | https:\u002F\u002Fbrowserleaks.com\u002Fip                      | IP Leak Test             | 1           | 2024-01-15 12:55:00\n89245  | https:\u002F\u002Fwww.virustotal.com\u002Fgui\u002Ffile\u002Fa1b2c3...    | VirusTotal               | 2           | 2024-01-15 14:30:00\n89250  | https:\u002F\u002Fgithub.com\u002Fgentilkiwi\u002Fmimikatz\u002Freleases  | Mimikatz Releases        | 1           | 2024-01-15 16:00:00\n89260  | https:\u002F\u002Fraw.githubusercontent.com\u002F...\u002Fpayload.ps1| GitHub Raw               | 1           | 2024-01-15 14:34:00\n89270  | https:\u002F\u002Fpastebin.com\u002Fedit\u002FkL9mN2pQ               | Pastebin - Edit          | 2           | 2024-01-15 14:42:00\n89280  | https:\u002F\u002Fduckduckgo.com\u002F?q=clear+browser+history  | DuckDuckGo               | 1           | 2024-01-17 22:00:00\n89285  | https:\u002F\u002Fduckduckgo.com\u002F?q=anti+forensics+tools   | DuckDuckGo               | 1           | 2024-01-17 22:05:00\n\n[+] Analyzing table: downloads\n    Active rows:     234\n    Deleted rows:    12 (recovered)\n\n--- Recovered Deleted Downloads ---\nRow ID | Filename               | URL                                    | Size      | Start Time (UTC)\n-------|------------------------|----------------------------------------|-----------|---------------------\n5012   | payload.ps1            | https:\u002F\u002Fraw.githubusercontent.com\u002F...  | 4,096     | 2024-01-15 14:34:00\n5015   | mimikatz_trunk.zip     | https:\u002F\u002Fgithub.com\u002F...\u002Freleases\u002F...    | 1,892,352 | 2024-01-15 16:00:00\n5018   | netscan_portable.zip   | https:\u002F\u002Fwww.softperfect.com\u002F...        | 5,242,880 | 2024-01-15 15:05:00\n\n[+] Slack space analysis...\n    Pages with slack space data: 234\n    Partial strings recovered:   67 fragments\n\nSummary:\n  Total records analyzed:  14,578 (active) + 3,126 (deleted\u002FWAL)\n  Evidence-relevant URLs:  23 (flagged)\n  Deleted downloads:       12 (3 tool-related)\n  Anti-forensics evidence: Browser history deletion detected\n  Report: \u002Fanalysis\u002Fsqlite_report\u002Fsqlite_forensics.json\n  Recovered DB: \u002Fanalysis\u002Fsqlite_report\u002FHistory_recovered.db\n```\n",{"name":5,"tags":49,"author":53,"domain":37,"license":15,"version":54,"category":5,"nist_csf":55,"subdomain":60,"description":7,"mitre_attack":61},[27,40,39,38,29,36,50,35,51,52],"mobile-forensics","b-tree","unallocated-space","mahipal","1.0",[56,57,58,59],"RS.AN-01","RS.AN-03","DE.AE-02","RS.MA-01","digital-forensics",[62,63,64,65,66],"T1005","T1074","T1119","T1070","T1059","main","5eea5b3296f4673b5f481e8bcc1ba76281149f16","modules\u002Fperforming-sqlite-database-forensics",0,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core","https:\u002F\u002Fgithub.com\u002FHenriqueMC17","Qualquer tecnologia suficientemente avançada é indistinguível da mágica.","2026-09-28 22:40:38",{"source":8,"skillName":5,"commands":76,"prompt":86,"zipAvailable":87},[77,80,83],{"tool":78,"command":79},"npx","npx skills add HenriqueMC17\u002Fagente-core --skill performing-sqlite-database-forensics",{"tool":81,"command":82},"bunx","bunx skills add HenriqueMC17\u002Fagente-core --skill performing-sqlite-database-forensics",{"tool":84,"command":85},"pnpm","pnpm dlx skills add HenriqueMC17\u002Fagente-core --skill performing-sqlite-database-forensics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002FSKILL.md",true,[89,95,100,106,110,114,120],{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"assets\u002Ftemplate.md","ASSET","资产文件",613,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Fassets\u002Ftemplate.md",{"path":96,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":98,"sourceHtmlUrl":99},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002FLICENSE",{"path":101,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Fapi-reference.md","REFERENCE","参考文档",1939,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Freferences\u002Fapi-reference.md",{"path":107,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fstandards.md",967,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Freferences\u002Fstandards.md",{"path":111,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":112,"sourceHtmlUrl":113},"references\u002Fworkflows.md",894,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Freferences\u002Fworkflows.md",{"path":115,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":118,"sourceHtmlUrl":119},"scripts\u002Fagent.py","SCRIPT","脚本",7901,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Fscripts\u002Fagent.py",{"path":121,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":122,"sourceHtmlUrl":123},"scripts\u002Fprocess.py",7234,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fperforming-sqlite-database-forensics\u002Fscripts\u002Fprocess.py",[125,154,180,202,218,239],{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":134,"publishedAt":44},"01M6HPFF0RCN0X6WT5EBSV71GY","validating-backup-integrity-for-recovery","Validate backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to ensure backups are reliable for disaster recovery and ransomware response scenarios.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[131],{"categoryNo":132,"categoryName":133,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[135,136,137,138,139,140,37,141,142,143,144,145,146,147,148,149,150,151,152,153],"integrity","backup","recovery","validating backup integrity for recovery","for","testing","validate","verification","hash-verification","incident-response","ransomware","detection","t1078","t1490","disaster-recovery","restore","incident","disaster recovery","ransomware response",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":44},"01M6HPFAWJVFK25Q33K3T7WQ8G","triaging-vulnerabilities-with-ssvc-framework","Triage and prioritize vulnerabilities using CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree framework to produce actionable remediation priorities.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[],[161,162,163,164,165,37,166,167,168,169,170,171,172,173,174,175,176,177,178,179],"vulnerabilities","framework","ssvc","triaging vulnerabilities with ssvc framework","with","triage and prioritize","CISA","vulnerability-management","risk-management","cvss","remediation","vulnerability","prioritization","decision-tree","prioritize","decision","priorities","actionable","tree",{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":44},"01M6HPF6JS9X72WP59094H3ASQ","triaging-security-incident","Performs initial triage of security incidents to determine severity, scope, and required response actions using the NIST SP 800-61r3 and SANS PICERL frameworks. Classifies incidents by type, assigns priority based on business impact, and routes...","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-incident\u002FSKILL.md",[],[187,188,151,37,189,190,191,147,148,41,192,193,194,195,196,197,198,199,200,201],"security","triaging security incident","actions","soc","NIST","severity-classification","incident-triage","SANS-PICERL","SOC-operations","picerl","conversion","isolation","scope","impact","consistency",{"skillNo":203,"name":204,"nameZh":6,"description":205,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":206,"categories":207,"keywords":208,"publishedAt":44},"01M6HPF2EX6ZYNYYHKBRJN7GEF","triaging-security-incident-with-ir-playbook","Classify and prioritize security incidents using structured IR playbooks to determine severity, assign response teams, and initiate appropriate response procedures.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-incident-with-ir-playbook\u002FSKILL.md",[],[187,209,210,188,151,165,37,211,190,144,212,213,147,148,214,192,175,215,216,217],"playbook","triaging security incident with ir playbook","teams","IR-playbook","severity","classification","classify","incidents","initiate",{"skillNo":219,"name":220,"nameZh":6,"description":221,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":222,"categories":223,"keywords":224,"publishedAt":44},"01M6HPEY9XPGE7X95AG4XJFQAW","triaging-security-alerts-in-splunk","Triages security alerts in Splunk Enterprise Security by classifying severity, investigating notable events, correlating related telemetry, and making escalation or closure decisions using SPL queries and the Incident Review dashboard. Use when...","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-alerts-in-splunk\u002FSKILL.md",[],[187,225,226,227,228,229,37,230,231,232,190,233,147,234,235,236,195,237,151,238],"security alerts","splunk","triaging security alerts in splunk","alerts","review","siem","dashboard","search","correlation-search","t1566","notable-events","incident-review","cm","de",{"skillNo":240,"name":241,"nameZh":6,"description":242,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":243,"categories":244,"keywords":245,"publishedAt":44},"01M6HPET6XGEPEJPN7V032JGZ0","tracking-threat-actor-infrastructure","Threat actor infrastructure tracking involves monitoring and mapping adversary-controlled assets including command-and-control (C2) servers, phishing domains, exploit kit hosts, bulletproof hosting, a","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftracking-threat-actor-infrastructure\u002FSKILL.md",[],[246,247,248,249,37,250,251,252,253,254,255,234,256,257,237,258,238,259,260,261],"infrastructure","tracking threat actor infrastructure","tracking","threat","monitoring","mitre-attack","threat-actor","threat-intelligence","command-and-control","dns","command","exploit","intelligence","domains","kit","hosts"]