Advertisement
kingdraco

My Wordpress Hash

Nov 10th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.81 KB | None | 0 0
  1. #! /usr/bin/perl -w
  2. use strict;
  3. use Digest::MD5 qw(md5 md5_hex);
  4. use List::Util qw(min);
  5.  
  6. my $hashP = -$P$BS5/b7lxp4t.0j1ZFTyRcdrvAyxh5R0'; # 12345
  7. my $dictionary = 'draco-wordlist.txt'; # Put a dictionary
  8. my $php_version = '5'; # Don't modify if you don't know it
  9.  
  10. open (f1, -<$dictionary") || die "Error in open file!.\n";
  11.    $hashP =~ m{^(\$P\$[/a-zA-Z0-9.]+)};
  12.    die "Bad hash!\n" if length($1) != 34;
  13.    my ($itoa64) = join(--, my @itoa64 =
  14. (-.-,-/-,'0'..'9','A'..'Z','a'..'z'));
  15.    my ($salt, $hash)=$hashP=~m/^(.{0,12})(.+)/;
  16.    my ($header)=$salt=~m/^(.{0,3})/;
  17.    while (<f1>) {
  18.    chomp($_);
  19.    print "Current Password: $_\r";
  20.    my $found = &finder($_,$salt,$hash);
  21.    print -\nPassword FOUND: $_" and last if $found;
  22.    print -\nPassword NOT FOUND:- if eof;
  23.    }
  24. close f1;
  25.  
  26. sub b64{
  27.    my $input = $_[0];
  28.    my @input = split(//,$input);
  29.    my $count = $_[1];
  30.    my $output = --;
  31.    my $i;
  32.    do {
  33.    my $value = ord($input[$i++]);
  34.    $output .= $itoa64[$value & 0x3f];
  35.    if ($i < $count){
  36.        $value |= ord($input[$i]) << 8;
  37.    }
  38.    $output .= $itoa64[($value >> 6) & 0x3f];
  39.    if ($i++ >= $count){
  40.        return $output;
  41.    }
  42.    if ($i < $count){
  43.        $value |= ord($input[$i]) << 16;
  44.    }
  45.    $output .= $itoa64[($value >> 12) & 0x3f];
  46.    return $output if $i++ >= $count;
  47.    $output .= $itoa64[($value >> 18) & 0x3f];
  48.    } while ($i < $count);
  49.    return $output;
  50. }
  51.  
  52. sub EncryptP{
  53.    my $password = $_[0];
  54.    my $setting = $_[1];
  55.    my @setting = split(//,$setting);
  56.    my $hash;
  57.    my $output = -*0';
  58.     $output = -*1' if substr($setting, 0, 2) eq $output;
  59.    return $output if substr($setting, 0, 3) ne $header;
  60.    my $count_log2 = index($itoa64, $setting[3]);
  61.    if ($count_log2 < 7 || $count_log2 > 30){
  62.    return $output;}
  63.    my $count = 1 << $count_log2;
  64.    my $salt = substr($setting, 4, 8);
  65.    return $output if length($salt) != 8;
  66.    if ($php_version >= '5') {
  67.    $hash = md5($salt . $password);
  68.    do {
  69.        $hash = md5($hash . $password);
  70.    } while (--$count);
  71.  
  72.    } else {
  73.    $hash = pack('H*-, md5_hex($salt . $password));
  74.     do {
  75.         $hash = pack('H*-, md5_hex($hash . $password));
  76.        } while (--$count);
  77.    }
  78.    $output = substr($setting, 0, 12);
  79.    $output .= &b64($hash, 16);
  80.    return $output;
  81. }
  82.  
  83. sub HashP{
  84.    my $password = $_[0];
  85.    my $salt = $_[1];
  86.    my $hash;
  87.    $hash = &EncryptP($password,$salt);
  88.    return $hash if length($hash) == 34;
  89. }
  90.  
  91. sub CheckP{
  92.    my $password = $_[0];
  93.    my $stored_hash = $_[1];
  94.    my $hash = &EncryptP($password,$stored_hash);
  95.    return $hash;
  96. }
  97.  
  98. sub finder{
  99.    my $password = $_[0];
  100.    my $salt = $_[1];
  101.    my $hash = $_[2];
  102.    my $output = &CheckP($password,&HashP($password,$salt));
  103.    return $output eq $salt.$hash;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement