Archive Password Cracking
Password-protected archives found on targets (tool bundles, deploy packages, loot backups).
Attack selection depends on BOTH the crypto and the per-entry compression method — read them
before spending any wordlist time.
1. Identify before attacking
unzip -v prints the Method per entry (Stored vs Defl:N = Deflate) — this decides which
attack can work (step 4).
zipinfo -v shows general-purpose flags: bit 0 = encrypted, bit 3 = data descriptor (streamed
zip). Data descriptors are fine for bkcrack — do not skip such zips.
- AES entries (WinZip AE-1/AE-2) are NOT ZipCrypto: bkcrack does not apply; only wordlists (or a
converted hash for hashcat) can work.
- Grep the engagement's collected material first —
.bash_history, configs and notes from
compromised hosts sometimes hold the exact passwords/patterns the operator used for local
archives (the same people made both).
2. Attack order
- Context candidates from the same engagement (host passwords,
{name}{date}-style patterns,
project words).
- rockyou pass (fast first sweep).
- Regional list —
Pwdb_top-10000000 and locale common-password lists for Chinese-facing
targets.
- bkcrack known-plaintext (step 4) — small, fully-guessable entries only.
- Other formats: rar/7z need a hashcat-format conversion (rar2john / 7z2hashcat) + the same
wordlist order; bkcrack itself is ZipCrypto-only.
3. Wordlist sweep hygiene
- Cheap validation = the ZipCrypto check byte, BUT never report a hit from the check byte alone:
it is one byte, so ~0.4% of wrong candidates pass it too (≈56k over a 14M list) and the false
positive reaches the report unless you verify. Confirm every candidate by fully decrypting one
entry and matching its CRC before declaring success.
- Run sweeps as background jobs that append progress to a log and write the found password to an
out-file; poll the out-file for hits instead of scraping stdout.
- When you replace the sweep script with a fixed version, delete the old generation's out-files —
a stale false-positive "hit" file reads as a live credential later.
4. bkcrack known-plaintext attack
Not packaged in distro repos — build:
git clone https://github.com/kimci86/bkcrack
cd bkcrack && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j4
# binary: build/src/cli/bkcrack
Invocation:
bkcrack -C archive.zip -c <entry> -p plain.bin -o <offset>
# -x <offset> <hex> adds extra scattered known bytes
Success prints the three internal keys — decrypt with -k/-d, or rewrite the archive under a
new password with -U.
The plaintext must match the ENCRYPTED STREAM, not the file's plain content — the single
biggest trap:
- Stored entries: ciphertext = raw file bytes → known file headers work (ELF/PNG/ZIP magic…).
~12+ contiguous known bytes suffice.
- Deflate entries (
Defl:N): the ciphertext is the COMPRESSED stream. Raw content bytes can
never match it — feeding them always ends in "Could not find the keys". Reproduce the
compressed bytes yourself: deflate your guessed content (zlib raw deflate, wbits=-15) and
pass THOSE bytes. The archiver's compression level is unknown — try levels 1/6/9 per guess.
- Deflate output depends on the whole input block, so only guesses of the ENTIRE entry are
reliable (a ~200-byte Makefile, a short script, a small header). Partial prefix guesses (just a
shebang) do not reliably reproduce a Deflate stream prefix — they still work for Stored entries.
- Cost: minutes per candidate per run → batch guesses in a background loop with a per-run timeout
and a stop-marker on
Keys:; log every attempt so nothing is lost.
5. High-value plaintext guesses
- Kernel-module Makefile: starts
obj-m += ; the classic make -C …/build M=$(PWD) modules body
is near-standard — small files are fully guessable.
- Shell scripts: shebang + common prologue (Stored: direct; Deflate: only if the whole file is
guessable).
- C headers:
#ifndef X_H / #define X_H guards.
- Binaries: ELF header + program headers (Stored entries only).
1---2name: archive-password-cracking3description: "Use when cracking a password-protected zip/7z archive."4version: 1.0.05tags: [pentest, cracking, zip, bkcrack, wordlist, ops]6metadata:7 source: https://skillmd.com/skills/yufeifeio/archive-password-cracking8---910# Archive Password Cracking1112Password-protected archives found on targets (tool bundles, deploy packages, loot backups).13Attack selection depends on BOTH the crypto and the per-entry compression method — read them14before spending any wordlist time.1516## 1. Identify before attacking1718- `unzip -v` prints the Method per entry (`Stored` vs `Defl:N` = Deflate) — this decides which19 attack can work (step 4).20- `zipinfo -v` shows general-purpose flags: bit 0 = encrypted, bit 3 = data descriptor (streamed21 zip). Data descriptors are fine for bkcrack — do not skip such zips.22- AES entries (WinZip AE-1/AE-2) are NOT ZipCrypto: bkcrack does not apply; only wordlists (or a23 converted hash for hashcat) can work.24- Grep the engagement's collected material first — `.bash_history`, configs and notes from25 compromised hosts sometimes hold the exact passwords/patterns the operator used for local26 archives (the same people made both).2728## 2. Attack order29301. Context candidates from the same engagement (host passwords, `{name}{date}`-style patterns,31 project words).322. rockyou pass (fast first sweep).333. Regional list — `Pwdb_top-10000000` and locale common-password lists for Chinese-facing34 targets.354. bkcrack known-plaintext (step 4) — small, fully-guessable entries only.365. Other formats: rar/7z need a hashcat-format conversion (rar2john / 7z2hashcat) + the same37 wordlist order; bkcrack itself is ZipCrypto-only.3839## 3. Wordlist sweep hygiene4041- Cheap validation = the ZipCrypto check byte, BUT never report a hit from the check byte alone:42 it is one byte, so ~0.4% of wrong candidates pass it too (≈56k over a 14M list) and the false43 positive reaches the report unless you verify. Confirm every candidate by fully decrypting one44 entry and matching its CRC before declaring success.45- Run sweeps as background jobs that append progress to a log and write the found password to an46 out-file; poll the out-file for hits instead of scraping stdout.47- When you replace the sweep script with a fixed version, delete the old generation's out-files —48 a stale false-positive "hit" file reads as a live credential later.4950## 4. bkcrack known-plaintext attack5152Not packaged in distro repos — build:5354 git clone https://github.com/kimci86/bkcrack55 cd bkcrack && mkdir build && cd build56 cmake -DCMAKE_BUILD_TYPE=Release .. && make -j457 # binary: build/src/cli/bkcrack5859Invocation:6061 bkcrack -C archive.zip -c <entry> -p plain.bin -o <offset>62 # -x <offset> <hex> adds extra scattered known bytes6364Success prints the three internal keys — decrypt with `-k`/`-d`, or rewrite the archive under a65new password with `-U`.6667**The plaintext must match the ENCRYPTED STREAM, not the file's plain content — the single68biggest trap:**6970- Stored entries: ciphertext = raw file bytes → known file headers work (ELF/PNG/ZIP magic…).71 ~12+ contiguous known bytes suffice.72- **Deflate entries (`Defl:N`): the ciphertext is the COMPRESSED stream. Raw content bytes can73 never match it — feeding them always ends in "Could not find the keys".** Reproduce the74 compressed bytes yourself: deflate your guessed content (zlib raw deflate, `wbits=-15`) and75 pass THOSE bytes. The archiver's compression level is unknown — try levels 1/6/9 per guess.76- Deflate output depends on the whole input block, so only guesses of the ENTIRE entry are77 reliable (a ~200-byte Makefile, a short script, a small header). Partial prefix guesses (just a78 shebang) do not reliably reproduce a Deflate stream prefix — they still work for Stored entries.79- Cost: minutes per candidate per run → batch guesses in a background loop with a per-run timeout80 and a stop-marker on `Keys:`; log every attempt so nothing is lost.8182## 5. High-value plaintext guesses8384- Kernel-module Makefile: starts `obj-m += `; the classic `make -C …/build M=$(PWD) modules` body85 is near-standard — small files are fully guessable.86- Shell scripts: shebang + common prologue (Stored: direct; Deflate: only if the whole file is87 guessable).88- C headers: `#ifndef X_H` / `#define X_H` guards.89- Binaries: ELF header + program headers (Stored entries only).