*** ../scrambled_eggs Thu Nov 8 12:24:31 2001 --- ../scrambled_eggs_p Thu Nov 8 12:43:42 2001 *************** *** 16,29 **** REQUIRED OPTIONS: -u[ser] username in database - -A[pp] get/set username and password for application -d[irectory] directory containing the password database OPTIONAL: -p[assword] password for database (if not provided, you will be prompted for one) -e[ncyption] encyption scheme to use (the default is DES if not set) -c[hange] the username/password for the application ! -U[ser] set username for application -P[ass] set password for application (if not provided, you will be prompted for one) --- 16,29 ---- REQUIRED OPTIONS: -u[ser] username in database -d[irectory] directory containing the password database + -l[ist] list applications that are stored in the database OPTIONAL: -p[assword] password for database (if not provided, you will be prompted for one) -e[ncyption] encyption scheme to use (the default is DES if not set) -c[hange] the username/password for the application ! -A[pp] get/set username and password for application -U[ser] set username for application -P[ass] set password for application (if not provided, you will be prompted for one) *************** *** 102,107 **** --- 102,121 ---- the current working directory, to user jim (-U option) YOU WILL BE PROMPTED FOR A PASSWORD (notice there no -p or -P options used) + =over + + =item prompt> scdb.pl -u me -d .scdb -l + + =back + + + list all applications (-l option), + using jim as the scdb user (-u option), from the .scdb directory (-d option) of + the current working directory, to user jim (-U option) + YOU WILL BE PROMPTED FOR A PASSWORD (notice there no -p option used). + This will only list those applications using DES encryption because + no encryption (-e option) is used. + =head1 CAVEATS / TO DO WARNING: IF YOU USE METACHARACTERS IN YOUR PASSWORD; YOU MUST ESCAPE THEM *************** *** 112,120 **** When changing the password for an application, you must supply the username for the application. - Have the ability to retrieve a list of applications - stored in the password file. - =head1 AUTHOR James G. Willmore (jwillmore@cyberia.com -or- owner@ljcomputing.net) --- 126,131 ---- *************** *** 138,158 **** use strict; #define version number ! my $VERSION = "0.1"; #define the vars to use use vars qw/$user $pass $App $dir $User $Pass $encrypt ! $version $help $change $cipher $key $dbh $sth/; #define the options define_options(); - #check to see if help is needed (-h passed to the script) - defined $help ? usage() : check_options(); - #print version if -v or -version is passed to the script if(defined $version){print "$0 version $VERSION\n";exit;} #get password if not defined on the command line (-p passed to script) get_password(1) if !defined $pass; --- 149,169 ---- use strict; #define version number ! my $VERSION = "0.1-patched"; #define the vars to use use vars qw/$user $pass $App $dir $User $Pass $encrypt ! $version $help $list $change $cipher $key $dbh $sth/; #define the options define_options(); #print version if -v or -version is passed to the script if(defined $version){print "$0 version $VERSION\n";exit;} + #check to see if help is needed (-h passed to the script) + defined $help ? usage() : check_options(); + #get password if not defined on the command line (-p passed to script) get_password(1) if !defined $pass; *************** *** 171,176 **** --- 182,190 ---- #set up the encryption set_encryption(); + #list the applications for the ecryption selected if list is defined + read_apps() if defined $list; + #if the Username for the Application is provided #write values to file; otherwise, return the values defined $User ? write_cipher_text() : read_cipher_text(); *************** *** 191,202 **** #get the options passed; print usage when there is an error GetOptions("user=s" => \$user, "pass:s" => \$pass, ! "App=s" => \$App, "dir=s" => \$dir, ! "encryption=s" => \$encrypt, "User:s" => \$User, "Pass:s" => \$Pass, "change" => \$change, "version" => \$version, "help" => \$help); #print the usage message if there is an error getting the options --- 205,217 ---- #get the options passed; print usage when there is an error GetOptions("user=s" => \$user, "pass:s" => \$pass, ! "App:s" => \$App, "dir=s" => \$dir, ! "encryption:s" => \$encrypt, "User:s" => \$User, "Pass:s" => \$Pass, "change" => \$change, + "list" => \$list, "version" => \$version, "help" => \$help); #print the usage message if there is an error getting the options *************** *** 207,214 **** sub check_options{ print "Checking options passed...\n"; usage() unless (defined $user && $user !~ /^-/ && ! defined $dir && $dir !~ /^-/ && ! defined $App && $App !~ /^-/); } sub connect_to_database{ --- 222,229 ---- sub check_options{ print "Checking options passed...\n"; usage() unless (defined $user && $user !~ /^-/ && ! defined $dir && $dir !~ /^-/ );#&& ! #defined $App && $App !~ /^-/); } sub connect_to_database{ *************** *** 304,309 **** --- 319,325 ---- } sub read_cipher_text{ + usage() unless defined $App; $sth = $dbh->prepare("SELECT * FROM eggs WHERE a=?") or die "Can not prepare properly to read the database\n" . $sth->errstr(); $sth->execute($cipher->encrypt_hex("$App")) or *************** *** 319,324 **** --- 335,357 ---- print "Finished reading database\n"; } + sub read_apps{ + $sth = $dbh->prepare("SELECT * FROM eggs") or + die "Can not prepare properly to read the database\n" . $sth->errstr(); + $sth->execute() or + die "Can not search the database properly\n" . $sth->errstr(); + my($a,$b,$c); + $sth->bind_columns(\$a,\$b,\$c); + die "Can not change password properly\nCheck your options\n" if $change; + print "The following applications were found:\n"; + while($sth->fetch){ + print "\t",$cipher->decrypt_hex("$a"),"\n" unless + ($cipher->decrypt_hex("$a") eq ""); + } + print "Finished reading database\n"; + exit; + } + sub usage{ print <