unpack encrypted file using passwords list

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
KozakMak
Senior Member
Senior Member
Posts: 371
Joined: 2021-05-24, 12:39 UTC
Location: UA

unpack encrypted file using passwords list

Post by *KozakMak »

there is a password-protected zip archive
there is a txt file with a list of passwords

How can I quickly go through this list and unpack the archive?
OS: Win10 | TC: latest x64
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1013
Joined: 2004-07-29, 11:00 UTC

Re: unpack encrypted file using passwords list

Post by *ZoSTeR »

 
You could use 7-Zip with a CMD file like this:

Code: Select all

@echo off
setlocal enabledelayedexpansion
cls

set archive=%1
set szexe="C:\PathTo\7-Zip24\7z.exe"
set pw_list="C:\PathTo\7-Zip24\passwords.txt"

for /F "usebackq delims=" %%P in (%pw_list%) do (
	%szexe% t -p%%P %archive% > nul 2>&1
	if !errorlevel! EQU 0 (echo Password: && echo %%P && pause && goto :eof)
)
pause
Put the CMD file on a button with parameter "%P%N"
KozakMak
Senior Member
Senior Member
Posts: 371
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: unpack encrypted file using passwords list

Post by *KozakMak »

does not work(
ZoSTeR wrote: 2024-04-18, 09:45 UTC You could use 7-Zip
will https://www.7-zip.org/a/7zr.exe be enough?
ZoSTeR wrote: 2024-04-18, 09:45 UTC set szexe="C:\PathTo\7-Zip24\7z.exe"
without set will be better... using path
ZoSTeR wrote: 2024-04-18, 09:45 UTC set pw_list="C:\PathTo\7-Zip24\passwords.txt"
can you make that .txt = archive name? e.g for encryptedarchive.zip searching encryptedarchive.txt in same folder
OS: Win10 | TC: latest x64
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1013
Joined: 2004-07-29, 11:00 UTC

Re: unpack encrypted file using passwords list

Post by *ZoSTeR »

KozakMak wrote: 2024-04-18, 10:29 UTC does not work(
will https://www.7-zip.org/a/7zr.exe be enough?
7zr only supports 7z files, you could use 7za.exe for more formats.
without set will be better... using path
I'm note quite sure what you mean. Do you have the 7-Zip path in your "path" environment variable? Then you could use 7za.exe instead of %szexe%, see "rem" line below.
Or do you have the 7za.exe in the same folder as the archives? Then you could use the second "rem" line.
can you make that .txt = archive name? e.g for encryptedarchive.zip searching encryptedarchive.txt in same folder
Use this CMD file with parameters

Code: Select all

%P%N
and adjust the szexe path.

Code: Select all

@echo off
setlocal enabledelayedexpansion

set archive=%1
set pw_list=%~dpn1.txt

set szexe="c:\PathTo\7za.exe"
 
for /F "usebackq delims=" %%P in ("%pw_list%") do (
	%szexe% l -p%%P %archive%  > nul 2>&1
	rem or 7za.exe l -p%%P %archive%  > nul 2>&1
	rem %~dp17za.exe l -p%%P %archive%  > nul 2>&1
	if !errorlevel! EQU 0 (echo Password: && echo %%P && pause && goto :eof)
)
pause
For debugging:

Code: Select all

setlocal enabledelayedexpansion

set archive=%1
set pw_list=%~dpn1.txt

set szexe="c:\PathTo\7za.exe"
 
for /F "usebackq delims=" %%P in ("%pw_list%") do (
	%szexe% l -p%%P %archive%
	rem or 7za.exe l -p%%P %archive%
	rem %~dp17za.exe l -p%%P %archive%
	if !errorlevel! EQU 0 (echo Password: && echo %%P && pause && goto :eof)
)
pause
* Edit: replaced t(est) with l(ist) argument. Should be faster.
Last edited by ZoSTeR on 2024-04-18, 14:54 UTC, edited 1 time in total.
KozakMak
Senior Member
Senior Member
Posts: 371
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: unpack encrypted file using passwords list

Post by *KozakMak »

ZoSTeR wrote: 2024-04-18, 11:34 UTC 7zr only supports 7z files, you could use 7za.exe for more formats.
thx! now all works! 8)
OS: Win10 | TC: latest x64
Post Reply