Mailinglist Archive: opensuse-security (601 mails)

< Previous Next >
Re: [suse-security] password generator - Doh!
  • From: John Pinder <jpinder@xxxxxxx>
  • Date: Fri, 11 Aug 2000 02:03:28 -0700
  • Message-id: <3993C160.3122BAFE@xxxxxxx>
Hi,

First, let me apologize to everyone I sent the first version of this
program to. I've just had a chance to review the code, and all I
can say is I am _really_ sorry.

I have fixed the filename problem, and cut the program down to
size. It follows:

John

PS - SuSE people: I am not going to make a habit of this.

#####Begin Program
#!/usr/bin/perl -w

my $VERSION = 0.03;

#This script is Copyright(c) 2000 John Pinder. All Rights Reserved.
#Licensed under the same terms as Perl itself
#This software comes with NO WARRANTY!
#Written for Perl 5.005_02, on Linux 2.2.5 x86.



# THIS SCRIPT GENERATES PASSWORDS USING PERL RAND() FUNCTION
# randomness will depend on your RNG (/dev/random)


use Getopt::Long;

$help_test = "0";#keep help option happy, if not invoked: assign
default value



&GetOptions(
"characters=i" => \$num_characters,
"passwords=i" => \$num_passwords,
"filename=s" => \$output_file,
"help!" => \$help_test
);


if ($help_test == "1")
{
print "Options are as follows:\n";
print " --characters=n n is the number of bases to
generate, per sequence\n";
print " --passwords=n n is the number of
sequences to generate\n";
print " --filename=_____ enter the filename you want to
use, with NO extension\n";
print " --help this option prints this help
screen.\n\n";
print "For example, password_gen --characters 8 --passwords 20
--filename Garbage.txt\n";
print "will generate a file named Garbage.txt, containing 20
passwords of 8 characters each\n\n";

exit;
}

srand;
#for older Perl, use: srand ( time() - ($$ + ($$ << 15)) ) if $] <
5.004

@characters = qw( A B C D E F G H I J K L M N O P Q R S T U V W X Y
Z a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7
8 9 0 ! @ . );

$password_count = 0;#explicitly set to 0 (it's a counter, it counts
sequences)

while ($password_count < $num_passwords)# $num_seq is number of
sequences to be generated
{
$password_count++;
if ($password_count > 1) {
open(OUT, ">>$output_file");
print OUT "\n";
close(OUT);
}

#explicitly set counters to 0
$character_counter = 0;



while ($character_counter < $num_characters)# $num_passwords is
(big surprise) the number of passwords to be generated
{

$character_counter++;

open(OUT, ">>$output_file");
print OUT randselect( \@characters );
close(OUT);



}

}

sub randselect {
$_[0]->[rand @{ $_[0] } ]
} #Thank you O'Reilly!

#########End Program

< Previous Next >
Follow Ups
References