1

I am working on a brute force attack like software (a .bat file), which will try to extract a file, with some predefined passwords. My algorithm is somehow like this: -

"C:\Program Files\WinRAR\WinRAR.exe" x -inul -ppassword1 "path to my rar file" 
if %ERRORLEVEL% GEQ 1 GOTO try2
GOTO exit

:try2
"C:\Program Files\WinRAR\WinRAR.exe" x -inul -ppassword2 "path to my rar file" 
if %ERRORLEVEL% GEQ 1 GOTO try3
GOTO exit

:try3
"C:\Program Files\WinRAR\WinRAR.exe" x -inul -ppassword3 "path to my rar file" 
if %ERRORLEVEL% GEQ 1 GOTO try4
GOTO exit

like this. Everything is working according to my expectation with a problem in 10% of the cases.

In normal case i.e, for manual extraction (not with my software) I found: There are certain rar files which starts extracting even with a wrong password and when the extraction is about to complete, it shows an error message "Corrupted file or wrong password" . My software in such cases, faces a great problem => It extracts the same file a number of times because ERRORLEVEL is 0 (until the extraction is about to finish). Is there any way to modify such rar files so that,it will not start extracting with wrong passwords. Or, any way to detect the error code at the beginning of extraction (Not near the end of extraction).

Deb
  • 5,163
  • 7
  • 30
  • 45

1 Answers1

2

I can not help you with the WinRAR problem, but I can help you with the Batch method:

@echo off
setlocal EnableDelayedExpansion

for %%p in (password1 password2 ... passwordEtc
            passwordN passwordM) do (
   "C:\Program Files\WinRAR\WinRAR.exe" x -inul -p%%p "path to my rar file" 
   if !ERRORLEVEL! EQU 0 GOTO exit
)
echo Unable to extract after tried all paswords...
Aacini
  • 65,180
  • 12
  • 72
  • 108
  • That was realy useful. Can You please help me on this [http://stackoverflow.com/questions/21118929/how-to-hide-error-messages-in-7zip-command-line](http://stackoverflow.com/questions/21118929/how-to-hide-error-messages-in-7zip-command-line) ? – Deb Jan 14 '14 at 18:39