md5/sha1 php brutforcer
Posted on Февраль 8th, 2009 in Инструмент аудитора | 1 Comment »
#!/usr/bin/php
3
4
5 /* $Id: brute_force.php 417 2007-08-17 14:35:06Z zapotek $ */
6
7 /**
8 * @author: zapotek
9 * @version: 0.2
10 * @name: MD5/SHA1 BruteForcer
11 * @description:
12 * A simple brute forcer for MD5 and SHA1 hashes.
13 */
14
15 define( 'VERSION', 0.2 );
16
17 require_once( 'function.brute_force.php' );
18 require_once( 'function.getopt.php' );
19
20 echo "MD5/SHA1 Bruteforcer v" . VERSION . "\n".
21 "by Zapotek
22 "
23
24 // get input options
25 $args = @getopt( 'h:m:s:', $argv );
26
27 // read the hash
28 $hash = $args['h'];
29 // get the maximum string length
30 $max_len = $args['m'];
31 // get stats preference
32 $stats = $args['s'] == 'on' ? 1 : 0 ;
33
34 // check for sufficient input
35 if( !$hash ){
36 echo "Usage:\n\t" .
37 $argv[0] . " -h
38 "\t
39 "\t
40 "\t
41 exit;
42 }
43
44 // decide the hash algorithm based on hash size
45 switch( strlen( $hash ) ){
46
47 case 32;
48 $algo = "MD5";
49 break;
50
51 case 40;
52 $algo = "SHA1";
53 break;
54
55 default;
56 echo "Could not determine the encryption algorithm.\n";
57 echo "Ensure that the Hash is correct and try again.\n";
58 exit;
59 }
60
61 echo "\n$algo hash:\t$hash\n" . str_repeat( "-", 65 );
62
63 $start = strtotime( "now" );
64
65 $len = 0;
66
67 // loop until we crack the hash or reach the user defined limit
68 while( ++$len && ( $max_len-- || !$max_len ) ){
69
70 echo "\nAttacking with $len byte strings\n" .
71 str_repeat( "-", 65 ) .
72 "\nEstimated string pool:\t" . pow( 75, $len ) . " strings\n" .
73 str_repeat( "-", 65 ) . "\n";
74
75 $str = brute_force( $hash, $algo, $len, $stats );
76
77 if( $str ){
78 echo "\nDecrypted string:\t$str\n" .
79 str_repeat( "-", 65 ) .
80 "\nOperation took:\t\t".
81 date( "H:i:s", mktime( 0, 0, strtotime( "now" ) - $start ) ) .
82 "\n" . str_repeat( "-", 65 ) . "\n";
83 exit;
84 }
85
86 echo "\n[ $len byte keyspace exhausted. Moving on... ]\n\n";
87 }
88
89 // if we exhausted the keyspace something's wrong...
90 echo "\nKeyspace exhausted.\n".
91 "If you got here before the end of *TIME* " .
92 "you provided either an invalid hash or an invalid max string length...\n"
93
94 ?>
One Response
adminpass