Add WinZip test.pl and test.sh
[hashcat.git] / tools / test.pl
index ec85e99..9ef274b 100755 (executable)
@@ -45,7 +45,7 @@ my $hashcat = "./hashcat";
 
 my $MAX_LEN = 55;
 
-my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 190, 200, 300, 400, 500, 900, 1000, 1100, 1400, 1410, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7100, 7200, 7300, 7400, 7500, 7600, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500);
+my @modes = (0, 10, 11, 12, 20, 21, 22, 23, 30, 40, 50, 60, 100, 101, 110, 111, 112, 120, 121, 122, 125, 130, 131, 132, 133, 140, 141, 150, 160, 190, 200, 300, 400, 500, 900, 1000, 1100, 1400, 1410, 1420, 1430, 1440, 1441, 1450, 1460, 1500, 1600, 1700, 1710, 1711, 1720, 1730, 1740, 1722, 1731, 1750, 1760, 1800, 2100, 2400, 2410, 2500, 2600, 2611, 2612, 2711, 2811, 3000, 3100, 3200, 3710, 3711, 3300, 3500, 3610, 3720, 3800, 3910, 4010, 4110, 4210, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 5100, 5300, 5400, 5500, 5600, 5700, 5800, 6000, 6100, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7100, 7200, 7300, 7400, 7500, 7600, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8900, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200, 11300, 11400, 11500, 11600, 11900, 12000, 12100, 12200, 12300, 12400, 12600, 12700, 12800, 12900, 13000, 13100, 13200, 13300, 13400, 13500, 13600);
 
 my %is_unicode      = map { $_ => 1 } qw(30 40 130 131 132 133 140 141 1000 1100 1430 1440 1441 1730 1740 1731 5500 5600 8000 9400 9500 9600 9700 9800 11600 13500);
 my %less_fifteen    = map { $_ => 1 } qw(500 1600 1800 2400 2410 3200 6300 7400 10500 10700);
@@ -2369,6 +2369,40 @@ sub verify
 
       next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in})));
     }
+    elsif ($mode == 13600)
+    {
+      ($hash_in, $word) = split ":", $line;
+
+      next unless defined $hash_in;
+      next unless defined $word;
+
+      my @data = split ('\*', $hash_in);
+
+      next unless scalar @data == 10;
+
+      my $tag_start     = shift @data;
+      my $type          = shift @data;
+      my $mode          = shift @data;
+      my $magic         = shift @data;
+      my $salt          = shift @data;
+      my $verify_bytes  = shift @data;
+      my $length        = shift @data;
+      my $data          = shift @data;
+      my $auth          = shift @data;
+      my $tag_end       = shift @data;
+
+      next unless ($tag_start eq '$zip2$');
+      next unless ($tag_end   eq '$/zip2$');
+
+      $param  = $type;
+      $param2 = $mode;
+      $param3 = $magic;
+      $param4 = $salt;
+      $param5 = $length;
+      $param6 = $data;
+
+      next unless (exists ($db->{$hash_in}) and (! defined ($db->{$hash_in})));
+    }
     else
     {
       print "ERROR: hash mode is not supported\n";
@@ -2675,6 +2709,14 @@ sub verify
 
       return unless (substr ($line, 0, $len) eq $hash_out);
     }
+    elsif ($mode == 13600)
+    {
+      $hash_out = gen_hash ($mode, $word, undef, undef, $param, $param2, $param3, $param4, $param5, $param6);
+
+      $len = length $hash_out;
+
+      return unless (substr ($line, 0, $len) eq $hash_out);
+    }
     else
     {
       $hash_out = gen_hash ($mode, $word, $salt, $iter);
@@ -3123,6 +3165,10 @@ sub passthrough
 
       $tmp_hash = gen_hash ($mode, $word_buf, $salt_buf);
     }
+    elsif ($mode == 13600)
+    {
+      $tmp_hash = gen_hash ($mode, $word_buf, substr ($salt_buf, 0, 32));
+    }
     else
     {
       print "ERROR: Unsupported hash type\n";
@@ -3906,6 +3952,20 @@ sub single
         }
       }
     }
+    elsif ($mode == 13600)
+    {
+      for (my $i = 1; $i < 16; $i++)
+      {
+        if ($len != 0)
+        {
+          rnd ($mode, $len, 32);
+        }
+        else
+        {
+          rnd ($mode, $i, 32);
+        }
+      }
+    }
   }
 }
 
@@ -6987,8 +7047,6 @@ END_CODE
 
     $tmp_hash = sprintf ('$axcrypt_sha1$%s', substr ($hash_buf, 0, 32));
   }
-
-
   elsif ($mode == 13400)
   {
     my @salt_arr = split ('\*', $salt_buf);
@@ -7160,6 +7218,79 @@ END_CODE
 
     $tmp_hash = sprintf ("%s:%s", $hash_buf, $salt_buf);
   }
+  elsif ($mode == 13600)
+  {
+    my $iterations = 1000;
+
+    my $type = 0;
+
+    if (defined $additional_param)
+    {
+      $type = $additional_param;
+    }
+
+    my $mode = 1 + int rand (3);
+
+    if (defined $additional_param2)
+    {
+      $mode = $additional_param2;
+    }
+
+    my $magic = 0;
+
+    if (defined $additional_param3)
+    {
+      $magic = $additional_param3;
+    }
+
+    if (defined $additional_param4)
+    {
+      $salt_buf = $additional_param4;
+    }
+
+    $salt_buf = substr ($salt_buf, 0, 8 + ($mode * 8));
+
+    my $compress_length = 0;
+
+    if (defined $additional_param5)
+    {
+      $compress_length = $additional_param5;
+    }
+
+    my $data = "";
+
+    if (defined $additional_param6)
+    {
+      $data = $additional_param6;
+    }
+
+    my $key_len = (8 * ($mode & 3) + 8) * 2;
+
+    my $out_len = $key_len + 2;
+
+    my $salt_buf_bin = pack ("H*", $salt_buf);
+
+    my $hasher = Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA1');
+
+    my $pbkdf2 = Crypt::PBKDF2->new
+    (
+      hasher      => $hasher,
+      iterations  => $iterations,
+      output_len  => $out_len
+    );
+
+    my $key = $pbkdf2->PBKDF2_hex ($salt_buf_bin, $word_buf);
+
+    my $verify_bytes = substr ($key, -4); $verify_bytes =~ s/^0+//; #lol
+
+    $key = substr ($key, $key_len, $key_len);
+
+    my $key_bin = pack ("H*", $key);
+
+    my $auth = hmac_hex ($data, $key_bin, \&sha1, 64);
+
+    $tmp_hash = sprintf ('$zip2$*%u*%u*%u*%s*%s*%u*%s*%s*$/zip2$', $type, $mode, $magic, $salt_buf, $verify_bytes, $compress_length, $data, substr ($auth, 0, 20));
+  }
 
   return ($tmp_hash);
 }