Created
March 17, 2014 16:26
-
-
Save Ninjex/9602684 to your computer and use it in GitHub Desktop.
Substitute character values in a password file, generating new strings. Save to the desired file. -- Not very efficient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| @convert = { | |
| "e" => ["e", "3"], "l" => ["l", "1"], "o" => ["o", "0"], | |
| "a" => ["a", "4"], "t" => ["t", "7"], "s" => ["s", "5", "$"], | |
| "c" => ["c", "("], "g" => ["g", "6"], "p" => ["p", "9"], | |
| "b" => ["b", "8"] | |
| } | |
| @arrays = @convert.values # Grab all arrays in the hash | |
| @elements = @arrays.first.product(*@arrays.drop(1)) # Grab each element value | |
| def perms(input) | |
| perms = [] | |
| @elements.each do |value| | |
| perms << [@convert.keys, value].transpose.each_with_object(input.dup){|sub, str| str.gsub!(*sub)} | |
| end | |
| return perms.uniq | |
| end | |
| print "Password File: " | |
| password_file = gets.chomp | |
| print "Save File: " | |
| save_file = gets.chomp | |
| outfile = File.open(save_file, 'a+') # File to write perms to | |
| passfile = File.open(password_file, "r") # Regular dictionary | |
| passfile.each_line do |line| | |
| values = perms(line) | |
| values.each do |perm| | |
| outfile.write("#{perm}") | |
| end | |
| end | |
| passfile.close | |
| outfile.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment