-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpzip.plx
executable file
·42 lines (34 loc) · 1.07 KB
/
pzip.plx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Term::ANSIColor qw( :constants );
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
Archive::Zip::setErrorHandler( sub{
die "error with the zip archive: $!\n";
} ); # turn off default error msgs
my $usage = "usage: $0 -f [zip file] -w [wordlist]\n";
GetOptions (
'file=s' => \my $zipfile,
'wordlist=s' => \my $wordlist,
) or die $usage;
die $usage unless(defined($zipfile) && defined($wordlist));
open my $WORDLIST, '<', $wordlist
or die "couldn't open wordlist: $!\n";
# try all password and reopen the archive each time (required)
my $found = 0;
my $pwd;
while(defined($pwd = <$WORDLIST>)) {
chomp $pwd;
my $zip = Archive::Zip->new;
$zip->read($zipfile);
my $file = $zip->memberNamed(($zip->memberNames)[0]);
$file->password($pwd);
if($file->contents ne "") {
$found = 1;
last;
}
warn BLUE, "[\$] trying $pwd", RESET, "\n";
}
print GREEN, "[+] password found: $pwd\n", RESET if $found;
print RED, "[-] password not found..\n", RESET if !defined($pwd);