You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/zips-tricks.md
+160-3Lines changed: 160 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,168 @@ The [Zip file format specification](https://pkware.cachefly.net/webdocs/casestud
14
14
15
15
It's crucial to note that password-protected zip files **do not encrypt filenames or file sizes** within, a security flaw not shared with RAR or 7z files which encrypt this information. Furthermore, zip files encrypted with the older ZipCrypto method are vulnerable to a **plaintext attack** if an unencrypted copy of a compressed file is available. This attack leverages the known content to crack the zip's password, a vulnerability detailed in [HackThis's article](https://www.hackthis.co.uk/articles/known-plaintext-attack-cracking-zip-files) and further explained in [this academic paper](https://www.cs.auckland.ac.nz/~mike/zipattacks.pdf). However, zip files secured with **AES-256** encryption are immune to this plaintext attack, showcasing the importance of choosing secure encryption methods for sensitive data.
Modern Android malware droppers use malformed ZIP metadata to break static tools (jadx/apktool/unzip) while keeping the APK installable on-device. The most common tricks are:
22
+
23
+
- Fake encryption by setting the ZIP General Purpose Bit Flag (GPBF) bit 0
24
+
- Abusing large/custom Extra fields to confuse parsers
25
+
- File/directory name collisions to hide real artifacts (e.g., a directory named `classes.dex/` next to the real `classes.dex`)
26
+
27
+
### 1) Fake encryption (GPBF bit 0 set) without real crypto
-`unzip` prompts for a password for core APK files even though a valid APK cannot have encrypted `classes*.dex`, `resources.arsc`, or `AndroidManifest.xml`:
You should now see `General Purpose Flag 0000` on core entries and tools will parse the APK again.
106
+
107
+
### 2) Large/custom Extra fields to break parsers
108
+
109
+
Attackers stuff oversized Extra fields and odd IDs into headers to trip decompilers. In the wild you may see custom markers (e.g., strings like `JADXBLOCK`) embedded there.
22
110
111
+
Inspection:
23
112
113
+
```bash
114
+
zipdetails -v sample.apk | sed -n '/Extra ID/,+4p'| head -n 50
115
+
```
116
+
117
+
Examples observed: unknown IDs like `0xCAFE` ("Java Executable") or `0x414A` ("JA:") carrying large payloads.
118
+
119
+
DFIR heuristics:
120
+
- Alert when Extra fields are unusually large on core entries (`classes*.dex`, `AndroidManifest.xml`, `resources.arsc`).
121
+
- Treat unknown Extra IDs on those entries as suspicious.
122
+
123
+
Practical mitigation: rebuilding the archive (e.g., re-zipping extracted files) strips malicious Extra fields. If tools refuse to extract due to fake encryption, first clear GPBF bit 0 as above, then repackage:
124
+
125
+
```bash
126
+
mkdir /tmp/apk
127
+
unzip -qq normalized.apk -d /tmp/apk
128
+
(cd /tmp/apk && zip -qr ../clean.apk .)
129
+
```
130
+
131
+
### 3) File/Directory name collisions (hiding real artifacts)
132
+
133
+
A ZIP can contain both a file `X` and a directory `X/`. Some extractors and decompilers get confused and may overlay or hide the real file with a directory entry. This has been observed with entries colliding with core APK names like `classes.dex`.
134
+
135
+
Triage and safe extraction:
136
+
137
+
```bash
138
+
# List potential collisions (names that differ only by trailing slash)
0 commit comments