1#!/usr/bin/env perl 2 3## 4## Author......: See docs/credits.txt 5## License.....: MIT 6## 7 8use strict; 9use warnings; 10 11use Crypt::PBKDF2; 12use Digest::SHA qw (sha1); 13use Digest::HMAC qw (hmac_hex); 14 15sub module_constraints { [[8, 63], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } 16 17sub module_generate_hash 18{ 19 my $word = shift; 20 my $salt = shift; 21 my $macap = shift; 22 my $macsta = shift; 23 my $essid = shift; 24 25 if (!defined ($macap)) 26 { 27 $macap = unpack ("H*", random_bytes (6)); 28 } 29 30 if (!defined ($macsta)) 31 { 32 $macsta = unpack ("H*", random_bytes (6)); 33 } 34 35 if (!defined ($essid)) 36 { 37 $essid = unpack ("H*", random_bytes (random_number (0, 32) & 0x1e)); 38 } 39 40 my $pbkdf2 = Crypt::PBKDF2->new 41 ( 42 hash_class => 'HMACSHA1', 43 iterations => 4096, 44 output_len => 32, 45 ); 46 47 my $essid_bin = pack ("H*", $essid); 48 49 my $pmk = $pbkdf2->PBKDF2 ($essid_bin, $word); 50 51 my $macap_bin = pack ("H*", $macap); 52 my $macsta_bin = pack ("H*", $macsta); 53 54 my $data = "PMK Name" . $macap_bin . $macsta_bin; 55 56 my $pmkid = hmac_hex ($data, $pmk, \&sha1); 57 58 my $hash = sprintf ("%s:%s:%s:%s", substr ($pmkid, 0, 32), $macap, $macsta, $essid); 59 60 return $hash; 61} 62 63sub module_verify_hash 64{ 65 print "ERROR: verify currently not supported for WPA-PMKID-PBKDF2 (because of hashcat's output format)\n"; 66 67 exit (1); 68} 69 701; 71