Bash script that automatically tests passwords from a list to decrypt password-protected 7z/ZIP archives. Tests each password sequentially and reports the correct one.
- Automatic password testing from text file list
- Removes trailing spaces from passwords
- Sequential testing with progress output
- Directory cleanup between attempts
- Success/failure reporting
- Works with 7z and ZIP encrypted archives
- Linux operating system
- Bash shell
- 7-Zip tool (p7zip-full package)
Debian/Ubuntu/Linux Mint:
sudo apt-get install p7zip-full- Clone or download this repository
- Make the script executable:
chmod +x 7z-password-tester.sh./7z-password-tester.shThe script will test passwords from passwordlist against zipped_file.zip.
-
Prepare password list:
- Edit
passwordlistfile - Add one password per line
- Script automatically removes trailing spaces
- Edit
-
Prepare encrypted archive:
- Replace
zipped_file.zipwith your encrypted file - Or modify script to use different filename
- Replace
-
Run the script:
./7z-password-tester.shTesting password: 'examplepassword1'
Password 'examplepassword1' failed or produced empty files.
Testing password: 'examplepassword2'
Password 'examplepassword2' failed or produced empty files.
Testing password: 'avatar'
Good password is: avatar
7z-password-tester.sh- Main bash scriptpasswordlist- Example password list (for testing)zipped_file.zip- Example encrypted ZIP file (for testing)README.md- This documentationCHANGELOG.md- Version historyLICENSE- GPL v2 or later
- Reads passwords line by line from
passwordlist - Removes trailing spaces using
sed - For each password:
- Attempts to extract archive using
7z x -p"password" - Checks if extraction produced non-empty files
- Reports success or moves to next password
- Attempts to extract archive using
- Cleans up failed attempts (removes
unzippeddirectory) - Reports final result
- Extracted files go to
unzipped/directory - Directory is created/removed automatically
- Only successful extraction keeps the directory
Edit line 24 in script:
7z x -p"$password" your_archive.7z -o"unzipped" > /dev/null 2>&1Edit line 18 and 20:
sed -i 's/[[:space:]]*$//' your_passwordlist.txt
...
done < your_passwordlist.txtReplace unzipped with your preferred directory name throughout the script.
- Do not commit real passwords to version control
- The included
passwordlistcontains:- 999 most common passwords from darkweb2017 dataset
- 16 example passwords at the end (examplepassword1-15 + avatar)
- Correct password for test file:
avatar(last password in list)
- The included
zipped_file.zipis a test file (password: avatar) - For real use, you can use included list or create your own
For extended password testing, use these wordlists:
-
SecLists - Comprehensive password lists
10k-most-common.txt- Top 10,000 passwordsdarkweb2017_top-10000.txt- Top 10,000 from darkweb leaksPasswords/Common-Credentials/- Multiple wordlists
-
CrackStation - 1.5 billion unique passwords
Download and replace passwordlist file with your chosen wordlist.
Test with included files:
./7z-password-tester.shExpected result: Script will find password "avatar" after testing 16 passwords.
See CHANGELOG.md for version history.
GPL v2 or later