Skip to content

Instantly share code, notes, and snippets.

@ReeseWang
Created February 3, 2025 11:13
Show Gist options
  • Save ReeseWang/a9bf0478b1e5ef6f465b35fd3372cbc4 to your computer and use it in GitHub Desktop.
Save ReeseWang/a9bf0478b1e5ef6f465b35fd3372cbc4 to your computer and use it in GitHub Desktop.
Batch extract encrypted .zip files when only the password pattern is known.
#!/usr/bin/env bash
# This script is designed for situations where there is only one file per .zip file.
args=( *.zip )
zip2john "${args[@]}" > hashes.txt
john --format=PKZIP '--mask=?d?d?d?d?d?d' hashes.txt
john --show hashes.txt | head -n -2 | while IFS=':' read -r col1 password filepath zipfile remainder; do
unzip -oP "$password" -j "$zipfile" "$filepath"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment