Batch file 如何在开始时用错误的密码检测提取的错误代码
我正在开发一个类似蛮力攻击的软件(一个.bat文件),它将尝试提取一个带有一些预定义密码的文件。我的算法是这样的:-Batch file 如何在开始时用错误的密码检测提取的错误代码,batch-file,command-line,extract,winrar,unrar,Batch File,Command Line,Extract,Winrar,Unrar,我正在开发一个类似蛮力攻击的软件(一个.bat文件),它将尝试提取一个带有一些预定义密码的文件。我的算法是这样的:- "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
"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
像这样。一切都按照我的预期进行,10%的情况下出现问题
在正常情况下,即对于手动提取(不使用我的软件),我发现:有些rar文件即使使用错误的密码也会开始提取,提取即将完成时,它会显示一条错误消息“文件损坏或密码错误”。在这种情况下,我的软件面临一个很大的问题=>它多次提取同一个文件,因为ERRORLEVEL为0(直到提取即将完成)。有没有办法修改这样的rar文件,这样就不会用错误的密码开始提取。或者,在提取开始时(不接近提取结束时)检测错误代码的任何方法。我无法帮助您解决WinRAR问题,但我可以帮助您解决批处理方法:
@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...
那真的很有用。你能帮我一下吗?