这是nixda的答案的证明:
我在 Linux 上使用 rar v4 和 unrar v4.10。
我写了一个C代码来测试密码的长度:
int main(void){
char password[150];
int i=0, j =0;
int r;
for (i=0; i<150 ; i++){
r = rand()%10;
password[i]= (char)(((int)'0')+r);
}
char command[300] = {'\0'};
sprintf(command, " rar a -p[%s] hi.rar hi.txt",password);
printf("password: %s\n", command);
system(command);
usleep(50000);
char newcommand[300] = {'\0'};
char newpassword[150] = {'\0'};
for (i= 0 ; i < 301; i++){
for(j=0; j<i; j++){
newpassword[j] = password[j];
}
sprintf(newcommand, " unrar e -p[%s] -o+ hi.rar",newpassword);
if (system(newcommand) >= 0 ){
printf("i: %d\n",i);
printf("password length: %d\n", strlen(newpassword));
// break;
}
strcpy(newpassword, "0");
usleep(500000);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它创建一个 150 个字符长的随机生成的数字(0 到 9)密码,然后压缩一个示例文件(在本例中为 hi.txt)。在代码的第二部分,它尝试使用先前生成的密码从第 1 个字符解压到第 150 个字符。我添加usleep了能够监视输出(或者您可以script在 linux 上使用以保存输出然后读取它们)。
我得到的是它能够在第 126 个索引上解压缩加密文件,毕竟这意味着它会在第 127 个字符之后截断密码(请注意,索引从 开始0)。
Extracting from hi.rar
Extracting hi.txt 40%
CRC failed in the encrypted file hi.txt. Corrupt file or wrong password.
Total errors: 1
i: 124
password length: 124
UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal
Extracting from hi.rar
Extracting hi.txt 40%
CRC failed in the encrypted file hi.txt. Corrupt file or wrong password.
Total errors: 1
i: 125
password length: 125
UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal
Extracting from hi.rar
Extracting hi.txt OK
All OK
i: 126
password length: 126
UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal
Extracting from hi.rar
Extracting hi.txt OK
All OK
i: 127
password length: 127
Extracting from hi.rar
Extracting hi.txt OK
All OK
i: 128
password length: 128
UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal
Extracting from hi.rar
Extracting hi.txt OK
All OK
i: 129
password length: 129
Run Code Online (Sandbox Code Playgroud)