diabliyo

sha1cracker.php

Sep 12th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.33 KB | None | 0 0
  1. #!/usr/bin/php
  2.  
  3. <?php
  4. /*
  5. Version 1.0
  6. Coder   Angel Cantu Jauregui
  7. Date    Sep 3, 2018
  8. Mail    angel.cantu@sie-group.net
  9. Github  URL
  10.  
  11. This tool is only for studing propuse, so if you made a bad use for this program is your reponsability.
  12. The limit for cracking password is between 1 and 8 letters, one hash for file, be careful and good luck ;)
  13. */
  14.  
  15. error_reporting(0);
  16.  
  17. function initzero($a, $b)
  18.     {
  19.     $r=array();
  20.     for( $i=0; $i<$a; $i++ )
  21.         $r[$i]= $b;
  22.     return $r;
  23.     }
  24.  
  25. function arr2text($a)
  26.     {
  27.     $r='';
  28.     foreach( $a as $key )
  29.         $r .= $key;
  30.  
  31.     # echo "\n\nHere... [". $r. "] [". sha1($r). "]\n\n";
  32.     return $r;
  33.     }
  34.  
  35. function crackit($hash)
  36.     {
  37.     $bruteforcing=array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' );
  38.     $a= initzero(7, 0);
  39.     $c= initzero(7, 0);
  40.     $cad= $hash;
  41.     $pwd= initzero(7, "");
  42.  
  43.     for( $a[0]=N, $c[0]=0; $c[0]<=count($bruteforcing); $c[0]++ )
  44.         {
  45.         for( $a[1]=$a[0]-1, $c[1]=0; $c[1]<=count($bruteforcing); $c[1]++ )
  46.             {
  47.             for( $a[2]=$a[1]-1, $c[2]=0; $c[2]<=count($bruteforcing); $c[2]++ )
  48.                 {
  49.                 for( $a[3]=$a[2]-1, $c[3]=0; $c[3]<=count($bruteforcing); $c[3]++ )
  50.                     {
  51.                     for( $a[4]=$a[3]-1, $c[4]=0; $c[4]<=count($bruteforcing); $c[4]++ )
  52.                         {
  53.                         for( $a[5]=$a[4]-1, $c[5]=0; $c[5]<=count($bruteforcing); $c[5]++ )
  54.                             {
  55.                             for( $a[6]=$a[5]-1, $c[6]=0; $c[6]<=count($bruteforcing); $c[6]++ )
  56.                                 {
  57.                                 for( $a[7]=$a[6]-1, $c[7]=0; $c[7]<=count($bruteforcing); $c[7]++ )
  58.                                     {
  59.                                     if( !strcmp($cad, sha1(arr2text($pwd)) ) )
  60.                                         {
  61.                                         echo "\n\n\t*****************************************";
  62.                                         echo "\n\t*\tPassword Reventado es: ". arr2text($pwd). "\t*\n";
  63.                                         echo "\t*****************************************\n\n";
  64.                                         return arr2text($pwd);
  65.                                         }
  66.                                     $pwd[$a[7]]= $bruteforcing[$c[7]];
  67.                                     }
  68.                                 $pwd[$a[6]]=$bruteforcing[$c[6]];
  69.                                 }
  70.                             $pwd[$a[5]]=$bruteforcing[$c[5]];
  71.                             # descomentame para tener "verbose"
  72.                             # echo "\nTesting: ". arr2text($pwd);
  73.                             }
  74.                         $pwd[$a[4]]=$bruteforcing[$c[4]];
  75.                         }
  76.                     $pwd[$a[3]]=$bruteforcing[$c[3]];
  77.                     }
  78.                 $pwd[$a[2]]=$bruteforcing[$c[2]];
  79.                 }
  80.             $pwd[$a[1]]=$bruteforcing[$c[1]];
  81.             }
  82.         $pwd[$a[0]]=$bruteforcing[$c[0]];
  83.         }
  84.     }
  85.  
  86. echo "Cracking SHA1\n**********************\n\n";
  87.  
  88. if( $argc!=2 )
  89.     echo "\n[ERROR] You need the full url from the file..";
  90. else
  91.     {
  92.     if( !file_exists($argv[1]) )
  93.         echo "\n[ERROR] The file is not found..";
  94.     else
  95.         {
  96.         echo "\nOpening file..";
  97.  
  98.         if( ($fp=fopen($argv[1], "r"))==FALSE ) # open stream
  99.             echo "\t[FAILED]";
  100.         else
  101.             {
  102.             echo "\t[DONE]";
  103.  
  104.             $buf= fgets($fp, (10*1024) ); # 10MB stream read
  105.             $buf= substr( $buf, 0, -1);
  106.             echo "\nHash Found: ". $buf. "\t[DONE]";
  107.             $r=0; # init 0 response
  108.  
  109.             if( !($r=crackit($buf)) ) # cracking hash
  110.                 echo "\nCracking Hash\t[FAILED]";
  111.             else
  112.                 echo "\nCracked, the password is: ". $r;
  113.             fclose($fp); # close stream
  114.             unset($r);
  115.             }
  116.         unset($fp);
  117.         }
  118.     }
  119.  
  120. /*
  121. $t= "hello";
  122. echo "\nTesting:\n". $t. " --> ". sha1($t);
  123. */
  124.  
  125. echo "\n\nGood bye...\n";
  126. exit();
  127. ?>
Add Comment
Please, Sign In to add comment