/
tripcode_words.php
executable file
·58 lines (48 loc) · 1.61 KB
/
tripcode_words.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// Generate tripcodes containing words. The list of valid words is read from the
// file "/usr/share/dict/words" (modify this depending on your OS), but only
// words of length 5 to 7 are copied to the file "tripcode_words.txt", which is
// then used for tripcode generation. Output is of format "password : result".
function getWords() {
$words = file_get_contents("/usr/share/dict/words");
$words = explode("\n", $words);
$usefulWords = array();
foreach ($words as $word) {
if (strlen($word) > 4 && strlen($word) < 8) {
$usefulWords[] = $word;
}
}
$file = fopen("tripcode_words.txt", "w+");
fwrite($file, implode("\n", $usefulWords));
fclose($file);
}
function tripcode($name) {
if (ereg("(#|!)(.*)", $name, $matches)) {
$cap = $matches[2];
$cap = strtr($cap, "&", "&");
//$cap = strtr($cap, ",", ",");
$salt = substr($cap . "H.", 1, 2);
$salt = ereg_replace("[^\.-z]", ".", $salt);
$salt = strtr($salt, ":;<=>?@[\\]^_`", "ABCDEFGabcdef");
return substr(crypt($cap, $salt), -10) . "";
}
}
function contains($str, $arr) {
foreach ($arr as $elem) {
if (stripos($str, $elem) !== false) { // case-insensitive
return true;
}
}
return false;
}
getWords();
$usefulWords = file_get_contents("tripcode_words.txt");
$usefulWords = explode("\n", $usefulWords);
for ($i = 0; ; $i++) { // watch out - infinite loop
$trip = substr(crypt($i), -15);
$code = tripcode("#" . $trip);
if (contains($code, $usefulWords)) {
echo "$trip : $code \n";
}
}
?>