Skip to content

Instantly share code, notes, and snippets.

@dbankier
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbankier/344c3545ec31b25f3686 to your computer and use it in GitHub Desktop.
Save dbankier/344c3545ec31b25f3686 to your computer and use it in GitHub Desktop.
Restricted Password List Generator

Basically, you forgot the password (for something, e.g. keystore) and need to generate a list of possible passwords to restrict the brute force possibilities.

For example you think it could be password, android or welcome, but could also be P@ssw0rd, aNdRoId! or Welcome1!.

Just modify the base_words (line 4) and suffixes (line 5) and run the script (you need node). It will output each possibility to the console. Or pipe it to a file.

./word_generator > words.txt
#!/usr/bin/env node
//example world list
var base_words= ["password", "android", "welcome"];
var suffixes = ["", "1", "!", "1!"];
function buildWords(letters) {
if (letters.length === 0) {
return suffixes;
}
var first = letters[0];
var rest = buildWords(letters.slice(1));
return first.reduce(function(acc, letter) {
return acc.concat(rest.map(function(r) { return letter + r;}));
}, []);
}
function getLetters(word) {
var letters = word.split("").map(function(l) {
var ret = [];
l = l.toLowerCase();
ret.push(l);
ret.push(l.toUpperCase());
if (l === "e") {
ret.push("3");
} else if (l === "a") {
ret.push("@");
} else if (l === "i") {
ret.push("!");
ret.push("1");
} else if (l === "s") {
ret.push("5");
ret.push("$");
} else if (l === "o") {
ret.push("0");
}
return ret;
});
return letters;
}
function buildWordList(word) {
return buildWords(getLetters(word));
}
base_words.forEach(function(word) {
var word_list = buildWordList(word);
var length = word_list.length;
word_list.forEach(function(o, idx) {
console.log(o);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment