Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / bruteForcer.php
1 <?php
2
3 //CHAR AT POSITION "X"
4 function charAt($str, $pos) {
5
6 $pos = ($pos - 1); //Offset
7 return (substr($str, $pos, 1)) ? substr($str, $pos, 1) : -1;
8
9 }
10
11 //NEXT CHARACTER
12 function nextChar ( $in ) {
13
14 $chars = ("abcdefghijklmnopqrstuvwxyz "); // Ends with space
15 //echo(charAt($chars, 7)); //Debug
16 $len = (strlen($chars));
17
18 $char = $in;
19
20 $charpos = ( strpos($chars, $char) );
21 $newcharpos = ($charpos + 1);
22 $char = $chars[$newcharpos];
23
24 $out = $char;
25 return ($out); //Returns "" after last character.
26
27 }
28
29 //BRUTE FORCER
30 function bruteForce ( $word ) {
31
32 $first = ("a");
33 $prelast = ("z");
34 $last = (" ");
35
36 $wpos = 0;
37
38 while ( $word[$wpos] == $prelast ) {
39 $wpos = ($wpos + 1);
40 }
41
42 $word[$wpos] = nextChar($word[$wpos]);
43
44 /*
45 while ( $word[$wpos] != $prelast ) {
46 $word[$wpos] = nextChar($word[$wpos]);
47 if ( $word[$wpos] == $last ) {
48 $word[$wpos] = $prelast;
49 }
50 }
51 */
52
53 return $word;
54 }
55
56
57
58 //===CODE===
59
60 //$test = ("nazdar");
61 //echo ($test["2"]);
62 //die();
63
64 echo(nextChar ("d") . "\n");
65 echo(bruteForce ("ahoj") . "\n----------------------\n\n");
66
67 $ted = ("a");
68 while (1) {
69 echo($ted."\n");
70 $ted = bruteForce($ted);
71 }
72
73 /*
74 $hash = ("79c2b46ce2594ecbcb5b73e928345492");
75 $pass = ("ahoj");
76 //echo(md5("ahoj"));
77
78 $loop = 1;
79 while($loop) {
80
81 $now = $pass;
82
83 if ( md5($now) == $hash ) {
84 die ("Hash: $hash\nVysledek: $now\n");
85 }
86
87 }
88 */
89
90 ?>
This page took 0.350906 seconds and 4 git commands to generate.