#!/usr/bin/perl ############################################################## # Anastasios Monachos - anastasiosm@gmail.com # # Usage: stemext.pl input_password number_of_iterations append_to_start_or_end_of_stem # # Takes three inputs: a word (our stem) eg my_secret_passwordp80, # a number in the range 1-3, and the words post or pre. Then # it generates all combinations of the charset appended at the # beginning or the end on the stem. The second argument # defines how many times the script will go through the charset. # And the third arguments tells where to append the charset. # # Useful when you know that a user chooses for password a # specific word and each time she changes her password, the # only thing she modifies is the last (or the first) 1, 2 or 3 # characters. ############################################################## die "\n Usage: $0 [stem] [number_of_iterations] [append_to_start_or_end_of_stem]\n\n". "\twhere number_of_iterations can take values: 1 or 2 or 3\n". "\tand append_to_start_or_end_of_stem takes the values pre and post.\n\n" unless $#ARGV == 2; my $stem = @ARGV[0]; my $iterations = @ARGV[1]; my $order = @ARGV[2]; # define the characters to be used as extension on our stem parameter $charset=("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); $size = length($charset); # split into individual words and store in array @array = split (//, $charset); if ($order eq 'post') { if ($iterations==1) { for ($count=0; $count < $size;$count++) { print $stem . $array[$count]."\n"; } } if ($iterations==2) { for ($count=0; $count < $size;$count++) { for ($count_inner=0; $count_inner < $size;$count_inner++) { print $stem . $array[$count_inner] . $array[$count]."\n"; } } } if ($iterations==3) { for ($count=0; $count < $size;$count++) { for ($count_inner=0; $count_inner < $size;$count_inner++) { for ($count_core=0; $count_core < $size;$count_core++) { print $stem . $array[$count_core] .$array[$count_inner] . $array[$count]."\n"; } } } } }#end of post if ($order eq 'pre') { if ($iterations==1) { for ($count=0; $count < $size;$count++) { print $array[$count] . $stem."\n"; } } if ($iterations==2) { for ($count=0; $count < $size;$count++) { for ($count_inner=0; $count_inner < $size;$count_inner++) { print $array[$count_inner] . $array[$count] . $stem."\n"; } } } if ($iterations==3) { for ($count=0; $count < $size;$count++) { for ($count_inner=0; $count_inner < $size;$count_inner++) { for ($count_core=0; $count_core < $size;$count_core++) { print $array[$count_core] .$array[$count_inner] . $array[$count].$stem."\n"; } } } } }#end of pre