1
mirror of https://github.com/hashcat/hashcat synced 2024-12-01 20:18:12 +01:00
hashcat/tools/test_modules/m11100.pm
mhasbini 1049cc8016 Add unit tests for multiple modules:
10900, 11000, 11100, 11200, 11300 & 11400
2019-02-17 22:48:19 +02:00

51 lines
955 B
Perl

#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::MD5 qw (md5_hex);
sub module_constraints { [[0, 255], [8, 8], [0, 55], [8, 8], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $user = shift // "postgres";
my $digest = md5_hex (md5_hex ($word . $user) . pack ("H*", $salt));
my $hash = sprintf ("\$postgres\$%s*%s*%s", $user, $salt, $digest);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash_in, $word) = split (/:/, $line);
return unless defined $hash_in;
return unless defined $word;
my (undef, $signature, $digest) = split ('\$', $hash_in);
return unless ($signature eq 'postgres');
my ($user, $salt, $hash) = split ('\*', $digest);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt, $user);
return ($new_hash, $word);
}
1;