【问题标题】:How to detect error code for extraction with wrong password at the beginning如何在开始时检测错误代码以提取错误密码
【发布时间】:2014-01-14 13:28:43
【问题描述】:

我正在研究像软件(.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 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 文件,这样它就不会以错误的密码开始提取。或者,在提取开始时检测错误代码的任何方法(不在提取结束附近)。

【问题讨论】:

    标签: batch-file command-line extract winrar unrar


    【解决方案1】:

    WinRAR 的问题我无法帮你解决,但我可以帮你解决 Batch 的问题:

    @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...
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 2020-03-27
    • 2011-12-16
    • 1970-01-01
    • 2012-06-06
    • 2015-01-05
    • 2017-09-24
    相关资源
    最近更新 更多