Reputation: 8068
I'm trying to unzip a file using perl on linux. The file is password protected, and am looping through possible password in a brute force attack (yes this is a homework assignment)
I have isolated and removed ther error code 20992 (bad password), but am still getting another error code which is not listed anywhere in the docs, and couldn't find anything relevant using The Googles either.
The error is:
512 error: invalid compressed data to inflate secret_brute.txt
Has anyone seen this error message? If so, what mean?
#!/usr/bin/perl
@aaaa_zzzz = ("aaaa" .. "zzzz");
foreach(@aaaa_zzzz){
$output = system("unzip -P $_ -q -o secret_brute.zip");
if($output !~ m/20992/){ # <-- filtering out other error message
chomp($output);
print "$_ : $output\n";
}
}
Edit
Per request: Secret_brute.zip
Upvotes: 1
Views: 7664
Reputation: 118138
Here is a list of exit codes from unzip.
As mentioned, perldoc -f system explains how to get the exit value of unzip
:
If you'd like to manually inspect
system
's failure, you can check all possible failure modes by inspecting$?
like this:
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
In this case, a value of 512
would map to:
2
: A generic error in the zipfile format was detected. Processing may have completed successfully anyway; some broken zipfiles created by other archivers have simple work-arounds.
On the other hand, 20992
would map to:
82
: No files were found due to bad decryption password(s). (If even one file is successfully processed, however, the exit status is1
.)
Upvotes: 5