forked from hashcat/hashcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm02400.pm
63 lines (44 loc) · 1.11 KB
/
m02400.pm
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::MD5 qw (md5);
use POSIX qw (strftime ceil);
sub module_constraints { [[-1, -1], [-1, -1], [1, 55], [-1, -1], [-1, -1]] }
sub pseudo_base64
{
my $itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
my $md5 = shift;
my $s64 = "";
for my $i (0..3) {
my $v = unpack "V", substr ($md5, $i*4, 4);
for (1..4) {
$s64 .= substr ($itoa64, $v & 0x3f, 1);
$v >>= 6;
}
}
return $s64;
}
sub module_generate_hash
{
my $word = shift;
my $word_len = length ($word);
my $pad_len = ceil ($word_len / 16) * 16;
my $digest = md5 ($word . "\0" x ($pad_len - $word_len));
my $hash = sprintf ("%s", pseudo_base64 ($digest));
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;