Added EFF wordlist, and updated PHP script and shell script to generate it.

Also updated the generated Javascript to show the source. #6
This commit is contained in:
Douglas Muth 2017-07-09 13:36:07 -04:00
parent 05065bbea4
commit 898377962a
7 changed files with 15652 additions and 11 deletions

View file

@ -19,8 +19,9 @@ if (php_sapi_name() != "cli") {
*/ */
function printSyntax($progname) { function printSyntax($progname) {
print "Syntax: $progname [ --dice n ]\n\n" print "Syntax: $progname [ --dice n | --eff ]\n\n"
. "\t--dice Number of dice to generate a wordlist for. Must be between 5 and 7 inclusive. Defaults to 5.\n" . "\t--dice Number of dice to generate a wordlist for. Must be between 5 and 7 inclusive. Defaults to 5.\n"
. "\t--eff Generate wordlist against the EFF's list, found at https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases"
. "\n" . "\n"
; ;
@ -57,10 +58,20 @@ function parseArgs($argv) {
$retval["dice"] = $value_next; $retval["dice"] = $value_next;
} }
if ($value == "--eff") {
$retval["eff"] = true;
}
} }
if ($retval["dice"] < 5 || $retval["dice"] > 7) { if (isset($retval["dice"])) {
if ($retval["dice"] < 5 || $retval["dice"] > 7) {
printSyntax($progname);
}
} else if (!isset($retval["eff"])) {
printSyntax($progname); printSyntax($progname);
} }
return($retval); return($retval);
@ -139,20 +150,71 @@ function readWordListPeterNorvig($filename, $dice) {
} // End of readWordListPeterNorvig() } // End of readWordListPeterNorvig()
/**
* Read in the EFF's wordlist and return an array with all the words.
*
* @param string $filename The filename
*
* @return array An array of words
*
*/
function readWordListEff($filename) {
$retval = array();
$fp = @fopen($filename, "r");
if (!$fp) {
throw new Exception("Could not open '$filename' for reading");
}
while ($line = fgets($fp)) {
$line = rtrim($line);
list($roll, $word) = explode("\t", $line);
$retval[] = $word;
}
//
// Put the words in alphabetical order for my own sanity.
//
sort($retval);
fclose($fp);
return($retval);
} // End of readWordListEff()
/** /**
* Create our Javascript, but as an array * Create our Javascript, but as an array
* *
* @param array $words Our array of words * @param array $words Our array of words
* *
* @param array $param Our array of params
*
* @return string Javascript which defines an array of those words * @return string Javascript which defines an array of those words
*/ */
function getJsArray($words) { function getJsArray($words, $params) {
$url = "(unknown)";
if (isset($params["dice"])) {
$url = "http://norvig.com/ngrams/";
} else if (isset($params["eff"])) {
$url = "https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases";
}
$retval = "" $retval = ""
. "//\n" . "//\n"
. "// Our wordlist.\n" . "// Our wordlist.\n"
. "//\n" . "//\n"
. "// Originally obtained from http://norvig.com/ngrams/\n" . "// Originally obtained from: $url\n"
. "//\n" . "//\n"
. "var wordlist = [\n" . "var wordlist = [\n"
; ;
@ -186,18 +248,31 @@ function getJsArray($words) {
function main($argv) { function main($argv) {
$params = parseArgs($argv); $params = parseArgs($argv);
//print_r($params); // Debugging
// //
// Read our file // Read our file
// //
$filename = "count_1w.txt"; if (isset($params["dice"])) {
$words = readWordListPeterNorvig($filename, $params["dice"]); $filename = "count_1w.txt";
//print_r($words); // Debugging $words = readWordListPeterNorvig($filename, $params["dice"]);
//print_r($words); // Debugging
} else if (isset($params["eff"])) {
//
// Handle wordllist from https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt
//
$filename = "eff_large_wordlist.txt";
$words = readWordListEff($filename);
//print_r($words); // Debugging
}
// //
// Get our Javascript // Get our Javascript
// //
$js = getJsArray($words); $js = getJsArray($words, $params);
print $js; print $js;

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,12 @@ echo "# Creating wordlist '$JS'..."
echo "# " echo "# "
./create-wordlist.php --dice 7 > ${JS} ./create-wordlist.php --dice 7 > ${JS}
JS="wordlist-5-dice-eff.js"
echo "# "
echo "# Creating EFF 5-dice Wordlist..."
echo "# "
./create-wordlist.php --eff > ${JS}
echo "# " echo "# "
echo "# Done!" echo "# Done!"
echo "# " echo "# "

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
// //
// Our wordlist. // Our wordlist.
// //
// Originally obtained from http://norvig.com/ngrams/ // Originally obtained from: http://norvig.com/ngrams/
// //
var wordlist = [ var wordlist = [
"aaliyah", "aaliyah",

View file

@ -1,7 +1,7 @@
// //
// Our wordlist. // Our wordlist.
// //
// Originally obtained from http://norvig.com/ngrams/ // Originally obtained from: http://norvig.com/ngrams/
// //
var wordlist = [ var wordlist = [
"aaaah", "aaaah",

View file

@ -1,7 +1,7 @@
// //
// Our wordlist. // Our wordlist.
// //
// Originally obtained from http://norvig.com/ngrams/ // Originally obtained from: http://norvig.com/ngrams/
// //
var wordlist = [ var wordlist = [
"aaaa", "aaaa",