Skip to content

Commit 93b11a0

Browse files
authored
Merge pull request #1336 from HackTricks-wiki/update_ELEGANTBOUNCER__When_You_Can_t_Get_the_Samples_but_20250825_125341
ELEGANTBOUNCER When You Can't Get the Samples but Still Need...
2 parents dd01833 + c01eee5 commit 93b11a0

File tree

5 files changed

+403
-3
lines changed

5 files changed

+403
-3
lines changed

src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- [Anti-Forensic Techniques](generic-methodologies-and-resources/basic-forensic-methodology/anti-forensic-techniques.md)
4242
- [Docker Forensics](generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics.md)
4343
- [Image Acquisition & Mount](generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md)
44+
- [Ios Backup Forensics](generic-methodologies-and-resources/basic-forensic-methodology/ios-backup-forensics.md)
4445
- [Linux Forensics](generic-methodologies-and-resources/basic-forensic-methodology/linux-forensics.md)
4546
- [Malware Analysis](generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md)
4647
- [Memory dump analysis](generic-methodologies-and-resources/basic-forensic-methodology/memory-dump-analysis/README.md)
@@ -61,6 +62,7 @@
6162
- [Office file analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md)
6263
- [PDF File analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md)
6364
- [PNG tricks](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/png-tricks.md)
65+
- [Structural File Format Exploit Detection](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/structural-file-format-exploit-detection.md)
6466
- [Video and Audio file analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/video-and-audio-file-analysis.md)
6567
- [ZIPs tricks](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md)
6668
- [Windows Artifacts](generic-methodologies-and-resources/basic-forensic-methodology/windows-forensics/README.md)

src/generic-methodologies-and-resources/basic-forensic-methodology/README.md

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,33 @@ malware-analysis.md
2323
if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in:
2424

2525

26+
{{#ref}}
27+
partitions-file-systems-carving/
28+
{{#endref}}# Basic Forensic Methodology
29+
30+
31+
32+
## Creating and Mounting an Image
33+
34+
35+
{{#ref}}
36+
../../generic-methodologies-and-resources/basic-forensic-methodology/image-acquisition-and-mount.md
37+
{{#endref}}
38+
39+
## Malware Analysis
40+
41+
This **isn't necessary the first step to perform once you have the image**. But you can use this malware analysis techniques independently if you have a file, a file-system image, memory image, pcap... so it's good to **keep these actions in mind**:
42+
43+
44+
{{#ref}}
45+
malware-analysis.md
46+
{{#endref}}
47+
48+
## Inspecting an Image
49+
50+
if you are given a **forensic image** of a device you can start **analyzing the partitions, file-system** used and **recovering** potentially **interesting files** (even deleted ones). Learn how in:
51+
52+
2653
{{#ref}}
2754
partitions-file-systems-carving/
2855
{{#endref}}
@@ -44,6 +71,11 @@ linux-forensics.md
4471
docker-forensics.md
4572
{{#endref}}
4673

74+
75+
{{#ref}}
76+
ios-backup-forensics.md
77+
{{#endref}}
78+
4779
## Deep inspection of specific file-types and Software
4880

4981
If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\
@@ -91,6 +123,54 @@ anti-forensic-techniques.md
91123
file-integrity-monitoring.md
92124
{{#endref}}
93125

94-
{{#include ../../banners/hacktricks-training.md}}
95126

96127

128+
## Deep inspection of specific file-types and Software
129+
130+
If you have very **suspicious** **file**, then **depending on the file-type and software** that created it several **tricks** may be useful.\
131+
Read the following page to learn some interesting tricks:
132+
133+
134+
{{#ref}}
135+
specific-software-file-type-tricks/
136+
{{#endref}}
137+
138+
I want to do a special mention to the page:
139+
140+
141+
{{#ref}}
142+
specific-software-file-type-tricks/browser-artifacts.md
143+
{{#endref}}
144+
145+
## Memory Dump Inspection
146+
147+
148+
{{#ref}}
149+
memory-dump-analysis/
150+
{{#endref}}
151+
152+
## Pcap Inspection
153+
154+
155+
{{#ref}}
156+
pcap-inspection/
157+
{{#endref}}
158+
159+
## **Anti-Forensic Techniques**
160+
161+
Keep in mind the possible use of anti-forensic techniques:
162+
163+
164+
{{#ref}}
165+
anti-forensic-techniques.md
166+
{{#endref}}
167+
168+
## Threat Hunting
169+
170+
171+
{{#ref}}
172+
file-integrity-monitoring.md
173+
{{#endref}}
174+
175+
{{#include ../../banners/hacktricks-training.md}}
176+
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# iOS Backup Forensics (Messaging‑centric triage)
2+
3+
{{#include ../../banners/hacktricks-training.md}}
4+
5+
This page describes practical steps to reconstruct and analyze iOS backups for signs of 0‑click exploit delivery via messaging app attachments. It focuses on turning Apple’s hashed backup layout into human‑readable paths, then enumerating and scanning attachments across common apps.
6+
7+
Goals:
8+
- Rebuild readable paths from Manifest.db
9+
- Enumerate messaging databases (iMessage, WhatsApp, Signal, Telegram, Viber)
10+
- Resolve attachment paths, extract embedded objects (PDF/Images/Fonts), and feed them to structural detectors
11+
12+
13+
## Reconstructing an iOS backup
14+
15+
Backups stored under MobileSync use hashed filenames that are not human‑readable. The Manifest.db SQLite database maps each stored object to its logical path.
16+
17+
High‑level procedure:
18+
1) Open Manifest.db and read the file records (domain, relativePath, flags, fileID/hash)
19+
2) Recreate the original folder hierarchy based on domain + relativePath
20+
3) Copy or hardlink each stored object to its reconstructed path
21+
22+
Example workflow with a tool that implements this end‑to‑end (ElegantBouncer):
23+
24+
```bash
25+
# Rebuild the backup into a readable folder tree
26+
$ elegant-bouncer --ios-extract /path/to/backup --output /tmp/reconstructed
27+
[+] Reading Manifest.db ...
28+
✓ iOS backup extraction completed successfully!
29+
```
30+
31+
Notes:
32+
- Handle encrypted backups by supplying the backup password to your extractor
33+
- Preserve original timestamps/ACLs when possible for evidentiary value
34+
35+
36+
## Messaging app attachment enumeration
37+
38+
After reconstruction, enumerate attachments for popular apps. The exact schema varies by app/version, but the approach is similar: query the messaging database, join messages to attachments, and resolve paths on disk.
39+
40+
### iMessage (sms.db)
41+
Key tables: message, attachment, message_attachment_join (MAJ), chat, chat_message_join (CMJ)
42+
43+
Example queries:
44+
45+
```sql
46+
-- List attachments with basic message linkage
47+
SELECT
48+
m.ROWID AS message_rowid,
49+
a.ROWID AS attachment_rowid,
50+
a.filename AS attachment_path,
51+
m.handle_id,
52+
m.date,
53+
m.is_from_me
54+
FROM message m
55+
JOIN message_attachment_join maj ON maj.message_id = m.ROWID
56+
JOIN attachment a ON a.ROWID = maj.attachment_id
57+
ORDER BY m.date DESC;
58+
59+
-- Include chat names via chat_message_join
60+
SELECT
61+
c.display_name,
62+
a.filename AS attachment_path,
63+
m.date
64+
FROM chat c
65+
JOIN chat_message_join cmj ON cmj.chat_id = c.ROWID
66+
JOIN message m ON m.ROWID = cmj.message_id
67+
JOIN message_attachment_join maj ON maj.message_id = m.ROWID
68+
JOIN attachment a ON a.ROWID = maj.attachment_id
69+
ORDER BY m.date DESC;
70+
```
71+
72+
Attachment paths may be absolute or relative to the reconstructed tree under Library/SMS/Attachments/.
73+
74+
### WhatsApp (ChatStorage.sqlite)
75+
Common linkage: message table ↔ media/attachment table (naming varies by version). Query media rows to obtain on‑disk paths.
76+
77+
Example (generic):
78+
79+
```sql
80+
SELECT
81+
m.Z_PK AS message_pk,
82+
mi.ZMEDIALOCALPATH AS media_path,
83+
m.ZMESSAGEDATE AS message_date
84+
FROM ZWAMESSAGE m
85+
LEFT JOIN ZWAMEDIAITEM mi ON mi.ZMESSAGE = m.Z_PK
86+
WHERE mi.ZMEDIALOCALPATH IS NOT NULL
87+
ORDER BY m.ZMESSAGEDATE DESC;
88+
```
89+
90+
Adjust table/column names to your app version (ZWAMESSAGE/ZWAMEDIAITEM are common in iOS builds).
91+
92+
### Signal / Telegram / Viber
93+
- Signal: the message DB is encrypted; however, attachments cached on disk (and thumbnails) are usually scan‑able
94+
- Telegram: inspect cache directories (photo/video/document caches) and map to chats when possible
95+
- Viber: Viber.sqlite contains message/attachment tables with on‑disk references
96+
97+
Tip: even when metadata is encrypted, scanning the media/cache directories still surfaces malicious objects.
98+
99+
100+
## Scanning attachments for structural exploits
101+
102+
Once you have attachment paths, feed them into structural detectors that validate file‑format invariants instead of signatures. Example with ElegantBouncer:
103+
104+
```bash
105+
# Recursively scan only messaging attachments under the reconstructed tree
106+
$ elegant-bouncer --scan --messaging /tmp/reconstructed
107+
[+] Found N messaging app attachments to scan
108+
✗ THREAT in WhatsApp chat 'John Doe': suspicious_document.pdf → FORCEDENTRY (JBIG2)
109+
✗ THREAT in iMessage: photo.webp → BLASTPASS (VP8L)
110+
```
111+
112+
Detections covered by structural rules include:
113+
- PDF/JBIG2 FORCEDENTRY (CVE‑2021‑30860): impossible JBIG2 dictionary states
114+
- WebP/VP8L BLASTPASS (CVE‑2023‑4863): oversized Huffman table constructions
115+
- TrueType TRIANGULATION (CVE‑2023‑41990): undocumented bytecode opcodes
116+
- DNG/TIFF CVE‑2025‑43300: metadata vs. stream component mismatches
117+
118+
119+
## Validation, caveats, and false positives
120+
121+
- Time conversions: iMessage stores dates in Apple epochs/units on some versions; convert appropriately during reporting
122+
- Schema drift: app SQLite schemas change over time; confirm table/column names per device build
123+
- Recursive extraction: PDFs may embed JBIG2 streams and fonts; extract and scan inner objects
124+
- False positives: structural heuristics are conservative but can flag rare malformed yet benign media
125+
126+
127+
## References
128+
129+
- [ELEGANTBOUNCER: When You Can't Get the Samples but Still Need to Catch the Threat](https://www.msuiche.com/posts/elegantbouncer-when-you-cant-get-the-samples-but-still-need-to-catch-the-threat/)
130+
- [ElegantBouncer project (GitHub)](https://github.com/msuiche/elegant-bouncer)
131+
132+
{{#include ../../banners/hacktricks-training.md}}

src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pdf-file-analysis.md
3535
{{#endref}}
3636

3737

38+
{{#ref}}
39+
structural-file-format-exploit-detection.md
40+
{{#endref}}
41+
42+
3843
{{#ref}}
3944
png-tricks.md
4045
{{#endref}}
@@ -50,5 +55,3 @@ zips-tricks.md
5055
{{#endref}}
5156

5257
{{#include ../../../banners/hacktricks-training.md}}
53-
54-

0 commit comments

Comments
 (0)