[alt.sources] alpha perl-cops, patch 1

df@sei.cmu.edu (Dan Farmer) (05/17/91)

  Couple of quick fixes already.  I guess that's why it's an alpha release,
eh?  One missing file, that is in the normal cops distribution -- 
"yagrip.pl".  One quick diff to pass.chk, so that it will output any 
account with a guessed password (use the -p flag to output the guessed 
password as well.)  Also, on suns and some other machines, you'll have 
to either say "perl cops" or "sh cops", since they try to interpret the 
comment on line one as an argument to the shell.  I'll be changing things 
later so that you won't have to do that.  Also, there are some extra files
in their that aren't used that will be deleted in the next release.  Kuang
uses some almost identical routines that will be blended in as well.

 -- dan

#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 05/17/1991 15:19 UTC by df@death.cert.sei.cmu.edu
# Source directory /usr/users/df/COPS/perl
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   2048 -rw------- p-cops.patch1
#   1274 -rw------- yagrip.pl
#
# ============= p-cops.patch1 ==============
if test -f 'p-cops.patch1' -a X"$1" != X"-c"; then
	echo 'x - skipping p-cops.patch1 (File already exists)'
else
echo 'x - extracting p-cops.patch1 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'p-cops.patch1' &&
*** pass.chk.old	Fri May 17 11:09:39 1991
--- pass.chk	Fri May 17 11:07:07 1991
***************
*** 6,12 ****
X  #
X  #  Usage: $0 [options] dictionary
X  #
! #	-P pfile	password file
X  #	-p		print found passwords (incompatible with -M)
X  #       -d		check prefix/suffix of digits [0-9]
X  #       -g		check all words in gcos, plan, project, signature files
--- 6,12 ----
X  #
X  #  Usage: $0 [options] dictionary
X  #
! #	-P pfile	password file (not working)
X  #	-p		print found passwords (incompatible with -M)
X  #       -d		check prefix/suffix of digits [0-9]
X  #       -g		check all words in gcos, plan, project, signature files
***************
*** 21,27 ****
X  # other cops stuff, and some things that just didn't fit, and added some
X  # code to finish the simulation of the old checker. -- dan
X  #
- 
X  require "pass.cache.pl";
X  
X  $Passwd = "/etc/passwd";
--- 21,26 ----
***************
*** 34,48 ****
X  $Move = "/bin/mv";
X  $Create = "/bin/touch";
X  
! &Getopts("dgiprsuUvwyo:P:l:b:e:") || do {
X  	print STDERR "Illegal arguments\n";
X  	&usage();
X  	exit(1);
X  	};
X  	
! sub usage {
! 	print STDERR "usage: pi -firuwyv -p <pwdfile> -l <logfile>\n          -o <nday> -b <bname> -e <ename>\n";
! 	}
X  
X  # sanity checks
X  $opt_P = $Passwd unless $opt_P;
--- 33,45 ----
X  $Move = "/bin/mv";
X  $Create = "/bin/touch";
X  
! &Getopts("pdgrsuUv") || do {
X  	print STDERR "Illegal arguments\n";
X  	&usage();
X  	exit(1);
X  	};
X  	
! sub usage { print STDERR "Usage: $0 -pdgrsuUv\n"; }
X  
X  # sanity checks
X  $opt_P = $Passwd unless $opt_P;
***************
*** 69,75 ****
X  	if ($try = &dopwd()) {
X  		$pwd = ($opt_p) ? $try : "";
X  		# printf "Username: %-8s  <password guessed>  $pwd\n",$P[0];
! 		printf "Warning!  Password Problem: Guessed: %s\t\t$pwd\n",$P[0];
X  		}
X  	$ndone++;
X  	$time = time();
--- 66,72 ----
X  	if ($try = &dopwd()) {
X  		$pwd = ($opt_p) ? $try : "";
X  		# printf "Username: %-8s  <password guessed>  $pwd\n",$P[0];
! 		printf "Warning!  $uid password Problem: Guessed: %s\t\t$pwd\n",$P[0];
X  		}
X  	$ndone++;
X  	$time = time();
SHAR_EOF
chmod 0600 p-cops.patch1 ||
echo 'restore of p-cops.patch1 failed'
Wc_c="`wc -c < 'p-cops.patch1'`"
test 2048 -eq "$Wc_c" ||
	echo 'p-cops.patch1: original size 2048, current size' "$Wc_c"
fi
# ============= yagrip.pl ==============
if test -f 'yagrip.pl' -a X"$1" != X"-c"; then
	echo 'x - skipping yagrip.pl (File already exists)'
else
echo 'x - extracting yagrip.pl (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'yagrip.pl' &&
#Yet Another Getopt Routine In Perl
# jgreely@cis.ohio-state.edu, 89/11/1
#usage:
#&getopt("f:bar") ||
#	die &usage("script","f:bar","oo","[files ...]");
#
sub getopt {
X	local($_,$flag,$opt,$f,$r,@temp) = @_;
X	@temp = split(/(.):/);
X	while ($#temp >= $[) {
X		$flag .= shift(@temp);
X		$opt .= shift(@temp);
X	}
X	while ($_ = $ARGV[0], /^-(.)(.*)/ && shift(@ARGV)) {
X		($f,$r) = ($1,$2);
X		last if $f eq '-';
X		if (index($flag,$f) >= $[) {
X			eval "\$opt_$f++;";
X			$r =~ /^(.)(.*)/,redo if $r ne '';
X		}elsif (index($opt,$f) >= $[) {
X			$r = $r eq '' ? shift(@ARGV) : $r;
X			eval "\$opt_$f = \$r;";
X		}else{
X			print STDERR "Unrecognized switch \"-$f\".\n";
X			return 0;
X		}
X	}
X	return 1;
}
X
#usage: usage:
# &usage(progname,arglist,@names,@last);
#ex:
# &usage("script","f:bar","oo","[file ...]");
#would return
# "usage: script [-f oo] [-bar] [file ...]"
#
sub usage {
X	local($prog,$_,@list) = @_;
X	local($string,$flag,@string,@temp,@last) = ();
X	@temp = split(/(.):/);
X	push(@string,"usage:",$prog);
X	while ($#temp >= $[) {
X		if (($flag = shift(@temp)) ne '') {
X			push(@string,"[-$flag]");
X		}
X		if (($flag = shift(@temp)) ne '') {
X			push(@string,sprintf("[-%s %s]",$flag,shift(@list)));
X		}
X	}
X	push(@string,@list) if $#list >= $[;
X	return join(' ',@string) . "\n";
}
1;
SHAR_EOF
chmod 0600 yagrip.pl ||
echo 'restore of yagrip.pl failed'
Wc_c="`wc -c < 'yagrip.pl'`"
test 1274 -eq "$Wc_c" ||
	echo 'yagrip.pl: original size 1274, current size' "$Wc_c"
fi
exit 0