Skip to content

Instantly share code, notes, and snippets.

@brohee
Created October 15, 2015 00:01
Show Gist options
  • Save brohee/e0be67593b71d2845b86 to your computer and use it in GitHub Desktop.
Save brohee/e0be67593b71d2845b86 to your computer and use it in GitHub Desktop.
// http://security.stackexchange.com/questions/102703/help-generating-wordlist-using-crunch
// I need to configure crunch so that it produces a wordlist with the following set of rules:
//
// Exactly 10 characters long
// Contains exactly 4 letters, which have to be a-f (all lowercase)
// Contains exactly 6 numbers, which have to be 2-9
// The letters and numbers can be anywhere in the word
//
fn all_words(prefix: &str, letters: u32, numbers: u32) {
if letters == 0 && numbers == 0 {
println!("{}", prefix);
return;
}
if letters > 0 {
for c in b'a'..b'f'+1 {
let mut new_prefix = String::from(prefix);
new_prefix.push(c as char);
all_words(&new_prefix, letters-1, numbers);
}
}
if numbers > 0 {
for n in b'2'..b'9'+1 {
let mut new_prefix = String::from(prefix);
new_prefix.push(n as char);
all_words(&new_prefix, letters, numbers-1);
}
}
}
fn main() {
all_words("", 4, 6);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment