> For the complete documentation index, see [llms.txt](https://capcap-1.gitbook.io/capcap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://capcap-1.gitbook.io/capcap/readme/ctf-modules/exploitation/password-attacks/cracking-protected-archives.md).

# Cracking Protected Archives

## Cracking Protected Archives

### Overview

Different archive/encryption types need different cracking approaches. The general rule:

* If the format **natively supports passwords** → use `*2john` to extract hash → crack offline
* If the format **doesn't natively support passwords** (e.g. openssl-encrypted GZIP) → brute-force directly
* Full disk encryption (BitLocker) → specialized extraction tool → hashcat

***

### Finding Archive Files on a Target

```bash
# Pull full list of compressed file extensions from FileInfo
curl -s https://fileinfo.com/filetypes/compressed | html2text | awk '{print tolower($1)}' | grep "\." | tee -a compressed_ext.txt
```

Common archive extensions to look for manually: `.zip .rar .7z .tar .gz .tar.gz .bz2 .kdbx .vhd .vmdk .cpt`

> Note: Not all archive formats support native password protection. TAR/GZIP use external tools like `openssl` or `gpg` for encryption.

***

### 1. Cracking ZIP Files

ZIP natively supports password protection — standard `*2john` workflow.

```bash
# Extract hash
zip2john ZIP.zip > zip.hash

# Inspect the hash (optional)
cat zip.hash
# $pkzip2$... — JtR auto-detects format, no --format needed

# Crack
john --wordlist=/usr/share/wordlists/rockyou.txt zip.hash

# Show result
john zip.hash --show
```

***

### 2. Cracking OpenSSL Encrypted GZIP

GZIP has no native password protection. When encrypted with openssl, there's no hash to extract — you brute-force decryption directly.

#### Identify the file type first

```bash
file GZIP.gzip
# Output: GZIP.gzip: openssl enc'd data with salted password
```

#### Brute-force with openssl loop

```bash
for i in $(cat /usr/share/wordlists/rockyou.txt);do openssl enc -aes-256-cbc -d -in GZIP.gzip -k $i 2>/dev/null | tar xz;done
```

What each part does:

| Part                          | Meaning                                              |
| ----------------------------- | ---------------------------------------------------- |
| `for i in $(cat rockyou.txt)` | Loop through every password                          |
| `openssl enc -aes-256-cbc -d` | Attempt AES-256 decryption                           |
| `-in GZIP.gzip`               | Target file                                          |
| `-k $i`                       | Current password attempt                             |
| `2>/dev/null`                 | Suppress errors from wrong passwords                 |
| `\| tar xz`                   | Pipe decrypted output into tar — extracts if correct |

You'll see repeated errors — that's normal, just wrong passwords failing. When the correct password hits, a file silently extracts.

```bash
# Check for extracted file after loop finishes
ls
```

> \**Why no 2john here?* OpenSSL encryption produces a binary blob with no standard hash structure inside. Every attempt requires a full decryption — slower than offline hash cracking, CPU only.

***

### 3. Cracking BitLocker Encrypted Drives

BitLocker = Windows full disk encryption (AES-128 or AES-256). Common on enterprise laptops and virtual drives (`.vhd` files).

Two unlock methods:

* **Password** — what you crack
* **Recovery key** — 48-digit random number, impractical to brute-force

#### Extract hashes

```bash
bitlocker2john -i Backup.vhd > backup.hashes

# Filter just the password hash ($bitlocker$0$...)
grep "bitlocker\$0" backup.hashes > backup.hash
```

> `bitlocker2john` produces 4 hashes — first two are password hashes, last two are recovery key hashes. Only target `$bitlocker$0$`.

#### Crack with hashcat

```bash
hashcat -a 0 -m 22100 backup.hash /usr/share/wordlists/rockyou.txt
```

> BitLocker uses high iteration AES — expect \~25 H/s on CPU. Very slow without GPU. Use hashcat, not JtR.

***

#### Mounting after cracking

**Windows:** Double-click `.vhd` → mount → double-click BitLocker volume → enter cracked password.

**Linux (dislocker):**

```bash
# Install
sudo apt-get install dislocker

# Create mount points
sudo mkdir -p /media/bitlocker
sudo mkdir -p /media/bitlockermount

# Attach VHD as loop device
sudo losetup -f -P Backup.vhd

# Decrypt with cracked password
sudo dislocker /dev/loop0p2 -u<password> -- /media/bitlocker

# Mount decrypted volume
sudo mount -o loop /media/bitlocker/dislocker-file /media/bitlockermount

# Browse
cd /media/bitlockermount && ls -la

# Unmount when done
sudo umount /media/bitlockermount
sudo umount /media/bitlocker
```

***

### Quick Reference — Tool by File Type

| File type     | Extract hash           | Crack with         | Hashcat mode  |
| ------------- | ---------------------- | ------------------ | ------------- |
| ZIP           | `zip2john`             | JtR / hashcat      | `13600`       |
| RAR           | `rar2john`             | JtR / hashcat      | `13000`       |
| 7z            | `7z2john.pl`           | JtR / hashcat      | `11600`       |
| OpenSSL GZIP  | No hash — openssl loop | `openssl` for loop | N/A           |
| BitLocker VHD | `bitlocker2john`       | hashcat            | `22100`       |
| Office docs   | `office2john.py`       | JtR / hashcat      | `9600` (docx) |
| PDF           | `pdf2john.py`          | JtR / hashcat      | `10500`       |
| SSH key       | `ssh2john`             | JtR / hashcat      | N/A           |
| KeePass       | `keepass2john`         | JtR / hashcat      | `13400`       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://capcap-1.gitbook.io/capcap/readme/ctf-modules/exploitation/password-attacks/cracking-protected-archives.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
