Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- # Generate passwords using the following techniques:
- # 1. gecos based
- # 2. word
- # 3. reversed word
- # 4. word based (mixed case)
- # 5. word based with number at end
- # 6. word based with special characters at front and back
- # 7. reversed word based with special characters at front and back
- # 8. keyboard based
- # 9. word based with special character replacement
- # 10. word based with 2 extra symbols in the middle
- # 11. word based with extra symbol and special character replacement
- # 12. 5 random alphanumeric characters
- # 13. 8 random alphanumeric characters
- # 14. 6 random lower case alphabetic characters
- # 15. 7 random lower case alphabetic characters
- # 16. 8 lower case alphabetic characters randomly choosen from the
- # following three sets which have the indicated probabilities
- # of being choosen:
- #
- # @ascii1 {asdfghjkl} .7
- # @ascii2 {ertyuicvbnm} .29
- # @ascii3 {qwzxop} .01
- # 17. The above (16) is modified by choosing two characters from
- # the machine name tyro, keeping them in the same order and
- # inserting them in the interior (not at front or end) of 6
- # characters choosen as in 16.
- #
- # Three files are required in the current directory
- # 1. ./students - list of ringer logins - one/line
- # 2. ./nisfile - some type of password files through gcos field
- # 3. ./words.linux - dictionary of words on which to base passwords
- #
- %keyb = ( '1' , '2q',
- '2' , '1qw3',
- '3' , '2we4',
- '4' , '3er5',
- '5' , '4rt6',
- '6' , '5ty7',
- '7' , '6yu8',
- '8' , '7ui9',
- '9' , '8io0',
- '0' , '9op-',
- '-' , '0p=',
- '=' , '-',
- 'q' , '12wa',
- 'w' , '2qase3',
- 'e' , '3wsdr4',
- 'r' , '4edft5',
- 't' , '5rfgy6',
- 'y' , '6tghu7',
- 'u' , '7yhji8',
- 'i' , '8ujko9',
- 'o' , '9iklp0',
- 'p' , '0ol;-',
- 'a' , 'zswq',
- 's' , 'wazxde',
- 'd' , 'esxcfr',
- 'f' , 'rdcvgt',
- 'g' , 'tfvbhy',
- 'h' , 'ygbnju',
- 'j' , 'uhnmki',
- 'k' , 'ijm,lo',
- 'l' , 'ok,.;p',
- ';' , 'pl./',
- 'z' , 'axs',
- 'x' , 'szcd',
- 'c' , 'dxvf',
- 'v' , 'fcbg',
- 'b' , 'gvnh',
- 'n' , 'hbmj',
- 'm' , 'jn,k',
- ',' , 'km.l',
- '.' , 'l,/;',
- '/' , ';.'
- );
- %equiv = ( 'a' , '@',
- 'A' , '@',
- 'c' , '(',
- 'C' , '(',
- 'd' , '.',
- 'D' , '.',
- 'i' , '!',
- 'I' , '!',
- 'l' , '|',
- 'L' , '|',
- 'o' , '0',
- 'O' , '0',
- 'v' , '^',
- 'V' , '^',
- 'n' , '#',
- 'N' , '#',
- 's' , '$',
- 'S' , '$'
- );
- @sym = ('~','`','!','@','#','$','%','^','&','*','_','-',' ','=','|',':','?','/','.','>','<',',');
- @ascii = (0..9,'A'..'Z','a'..'z');
- @lcascii = ('a'..'z');
- @ascii1 = ('a','s','d','f','g','h','j','k','l');
- @ascii2 = ('e','r','t','y','u','i','c','v','b','n','m');
- @ascii3 = ('q','w','z','x','o','p');
- @mname = ('t','y','r','o');
- $students = "./students";
- $users = "./nisfile";
- #$words = "/usr/dict/words";
- $words = "words.linux";
- @students = `cat $students`;
- chop @students;
- @users = `cat $users`;
- chop @users;
- @words = `cat $words`;
- chop @words;
- foreach $student (@students) {
- open(PASS,">passwd.$student.pw") or warn "Unable to open passwd.$student:$!\n";
- open(CLEAR,">passwd.$student.clear") or warn "Unable to open passwd.$student.clear:$!\n";
- undef %pwusers;
- # 1. gecos based
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( !$fields[4] );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- @name = split(/ /,$fields[4]);
- $pw = $name[$#name];
- $pw = substr($pw,0,8);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 2. word (all lower case)
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,8);
- $fields[1] = crypt($word,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$word\n";
- # 3. reverse word (all lower case)
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,8);
- @letters = split(//,$word);
- @letters = reverse(@letters);
- $word = join('',@letters);
- $fields[1] = crypt($word,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$word\n";
- # 4. word based (mixed case)
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,8);
- @letters = split(//,$word);
- foreach $c (@letters) {
- if ( int(rand 2) ) {
- $c = uc $c;
- } else {
- $c = lc $c;
- }
- }
- $pw = join("",@letters);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 5. word based with number at back
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,7);
- $pw = $word . int rand(10);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 6. word based with special characters at front and back
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,6);
- $pw = $sym[int(rand @sym)] . $word . $sym[int(rand @sym)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 7. reversed word based with special characters at front and back
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,6);
- @letters = split(//,$word);
- @letters = reverse @letters;
- $pw = join("",@letters);
- $pw = $sym[int(rand @sym)] . $pw . $sym[int(rand @sym)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 8. keyboard based
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- @keys = keys(%keyb);
- $pw = $keys[int(rand @keys)];
- $prev = $pw;
- $nbh = $keyb{$pw};
- @nbhs = split(//,$nbh);
- $let = $nbhs[int(rand @nbhs)];
- $pw .= $let;
- $cur = $let;
- for($i=2; $i<8; $i ) {
- $nbh = $keyb{$cur};
- @nbhs = split(//,$nbh);
- do {
- $let = $nbhs[int(rand @nbhs)];
- } while ( $let eq $prev && $cur ne '=' );
- $pw .= $let;
- $prev = $cur;
- $cur = $let;
- }
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 9. word based with special character replacement
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,8);
- @letters = split(//,$word);
- foreach $c (@letters) {
- if ( int(rand 2) ) {
- $c = uc $c;
- } else {
- $c = lc $c;
- }
- $c = $equiv{$c} if defined $equiv{$c};
- }
- $pw = join("",@letters);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 10. word based with 2 extra symbols in the middle
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,6);
- @letters = split(//,$word);
- splice(@letters,int(rand(@letters-2)) 1,0,$sym[int(rand @sym)]);
- splice(@letters,int(rand(@letters-2)) 1,0,$sym[int(rand @sym)]);
- $pw = join("",@letters);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 11. word based with extra symbol and special character replacement
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $word = baseword();
- $word = substr($word,0,7);
- @letters = split(//,$word);
- foreach $c (@letters) {
- $c = $equiv{$c} if defined $equiv{$c};
- }
- splice(@letters,int(rand(@letters-2)) 1,0,$sym[int(rand @sym)]);
- $pw = join("",@letters);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 12. 5 random alphanumeric characters
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = $ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 13. 8 random alphanumeric characters
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = $ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)].$ascii[int(rand @ascii)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 14. 6 random lower case alphabetic characters
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = $lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 15. 7 random lower case alphabetic characters
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = $lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)].$lcascii[int(rand @lcascii)];
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 16. 8 lower case alphabetic characters randomly choosen from the
- # following three sets which have the indicated probabilities
- # of being choosen:
- #
- # @ascii1 {asdfghjkl} .7
- # @ascii2 {ertyuicvbnm} .29
- # @ascii3 {qwzxop} .01
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = "";
- foreach (1..8) {
- $n = int(rand 100);
- if ( $n == 0 ) {
- $pw .= $ascii3[int(int(rand @ascii3))];
- } elsif ( $n < 30 ) {
- $pw .= $ascii2[int(int(rand @ascii2))];
- } else {
- $pw .= $ascii1[int(int(rand @ascii1))];
- }
- }
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- # 17. The above (16) is modified by choosing two characters from
- # the machine name tyro, keeping them in the same order and
- # inserting them in the interior (not at front or end) of 6
- # characters choosen as in 16.
- do {
- @fields = split(/:/,$users[int(rand @users)]);
- } while ( exists $pwusers{$fields[0]} );
- $pwusers{$fields[0]} = 1;
- $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[int(rand 64),int(rand 64)];
- $pw = "";
- foreach (1..6) {
- $n = int(rand 100);
- if ( $n == 0 ) {
- $pw .= $ascii3[int(int(rand @ascii3))];
- } elsif ( $n < 30 ) {
- $pw .= $ascii2[int(int(rand @ascii2))];
- } else {
- $pw .= $ascii1[int(int(rand @ascii1))];
- }
- }
- # Select characters from machine name
- @letters = split(//,$pw);
- $num1 = int(rand($#mname));
- $ch1 = $mname[$num1];
- $num2 = $num1 1 int(rand($#mname-$num1));
- $ch2 = $mname[$num2];
- # Insert machine name characters into the 6 chosen characters
- $pos1 = int(rand($#mname)) 1;
- $pos2 = $pos1 1 int(rand($#mname-$pos1));
- splice(@letters,$pos1,0,$ch1);
- splice(@letters,$pos2,0,$ch2);
- $pw = join('',@letters);
- $fields[1] = crypt($pw,$salt);
- $#fields -= 1;
- print PASS join(":",@fields),"\n";
- print CLEAR "$fields[0]:$pw\n";
- close PASS;
- close CLEAR;
- }
- sub baseword {
- while ( (@_ = split(//,($wd = $words[int(rand @words)]))) < 6 )
- {
- }
- return($wd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement