NetBSD Problem Report #10206

Received: (qmail 5077 invoked from network); 27 May 2000 23:46:42 -0000
Message-Id: <20000527234634.0070FDE@proven.weird.com>
Date: Sat, 27 May 2000 19:46:34 -0400 (EDT)
From: woods@weird.com (Greg A. Woods)
Sender: woods@proven.weird.com
Reply-To: woods@planix.com (Greg A. Woods)
To: gnats-bugs@gnats.netbsd.org
Subject: of what use are even 128-byte passwords if people can still choose easily guessable ones?
X-Send-Pr-Version: 3.95

>Number:         10206
>Category:       bin
>Synopsis:       of what use are even 128-byte passwords if people can still choose easily guessable ones?
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    elad
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat May 27 23:47:00 +0000 2000
>Closed-Date:    Wed Sep 14 11:42:01 +0000 2005
>Last-Modified:  Thu Nov 19 02:50:02 +0000 2009
>Originator:     Greg A. Woods
>Release:        2000/05/27
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:

Tested on NetBSD-1.4V, and successfully back-ported to NetBSD-1.3.3 too.

>Description:

	NetBSD currently allows the user to choose a password of up to
	128 bytes.  However there's still no protection against users
	choosing very easy to guess passwords.

	Software (cracklib, npasswd, et al) to protect from this
	vulnerability has been available since perhaps as early as 1993
	and indeed such protection has been available by default in
	several systems for some time now.

>How-To-Repeat:

	try setting your password to "cat".  Remember that you have to
	try at least twice to bypass the default minimum password
	length...  If you have set up a proper /etc/login.conf you may
	have to choose a longer, but just as easy to guess, password to
	demonstrate the problem....

>Fix:

	Integrate Alec Muffet's CrackLib into NetBSD.

	To do so apply the following patch in /usr/src and then unpack
	the enclosed shar file (also in /usr/src):

	Note that these changes do *not* add dictionary checking to the
	kerberos stuff -- I'll leave that as an exercise to the reader
	(and to someone who uses Kerberos to test! ;-).

	Though these changes move getnewpass() into a separate source
	file and reuse it in both local_passwd.c and yp_passwd.c, they
	don't move it to libutil.  That should probably be done too, in
	which case the kerberos krb*_chpw() functions could just use the
	new common routine and benefit automatically from the new
	checking....

	(Note also that yppasswd hasn't really been tested....)

Index: Makefile
===================================================================
RCS file: /cvs/NetBSD/src/Makefile,v
retrieving revision 1.1.1.6
diff -c -r1.1.1.6 Makefile
*** Makefile	2000/03/20 23:15:00	1.1.1.6
--- Makefile	2000/05/13 19:29:12
***************
*** 92,101 ****
--- 92,105 ----
  .if ${MKMAN} != "no" && !defined(_BUILD)
  	${MAKE} whatis.db
  .endif
+ 	${MAKE} crackdict

  whatis.db:
  	(cd ${.CURDIR}/share/man && ${MAKE} makedb)

+ crackdict:
+ 	(cd ${.CURDIR}/usr.sbin/mkcrackdict && ${MAKE} distribution)
+ 
  # wrt info/dir below:  It's safe to move this over top of /usr/share/info/dir,
  # as the build will automatically remove/replace the non-pkg entries there.

***************
*** 148,153 ****
--- 152,158 ----
  .if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
  	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_J} _SLAVE_BUILD= build)
  .endif
+ 	${MAKE} crackdict
  	${MAKE} whatis.db
  	@echo -n "Build finished at: "
  	@date
Index: distrib/sets/lists/base/mi
===================================================================
RCS file: /cvs/NetBSD/src/distrib/sets/lists/base/mi,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 mi
*** distrib/sets/lists/base/mi	2000/03/20 23:25:09	1.1.1.5
--- distrib/sets/lists/base/mi	2000/05/26 16:39:12
***************
*** 41,46 ****
--- 41,48 ----
  ./dev/fd
  ./dev/log
  ./etc
+ ./etc/banners
+ ./etc/banners.deny
  ./etc/disklabels
  ./etc/kerberosIV
  ./etc/kerberosV
***************
*** 340,345 ****
--- 342,348 ----
  ./usr/bin/tcopy
  ./usr/bin/tee
  ./usr/bin/telnet
+ ./usr/bin/testpasswd
  ./usr/bin/tftp
  ./usr/bin/time
  ./usr/bin/tip
***************
*** 445,450 ****
--- 448,456 ----
  ./usr/lib
  ./usr/libdata
  ./usr/libdata/lint
+ ./usr/libdata/pw_dict.hwm
+ ./usr/libdata/pw_dict.pwd
+ ./usr/libdata/pw_dict.pwi
  ./usr/libexec
  ./usr/libexec/atrun
  ./usr/libexec/comsat
***************
*** 466,471 ****
--- 472,478 ----
  ./usr/libexec/makewhatis
  ./usr/libexec/named-xfer
  ./usr/libexec/ntalkd
+ ./usr/libexec/pkcrackdict
  ./usr/libexec/postfix
  ./usr/libexec/rexecd
  ./usr/libexec/rlogind
***************
*** 482,487 ****
--- 489,495 ----
  ./usr/libexec/smrsh
  ./usr/libexec/telnetd
  ./usr/libexec/tftpd
+ ./usr/libexec/unpkcrackdict
  ./usr/libexec/uucp
  ./usr/libexec/uucp/uuchk
  ./usr/libexec/uucp/uucico
***************
*** 579,584 ****
--- 587,593 ----
  ./usr/sbin/mdsetimage
  ./usr/sbin/mk-amd-map
  ./usr/sbin/mkalias
+ ./usr/sbin/mkcrackdict
  ./usr/sbin/mknetid
  ./usr/sbin/mld6query
  ./usr/sbin/mopa.out
Index: distrib/sets/lists/comp/mi
===================================================================
RCS file: /cvs/NetBSD/src/distrib/sets/lists/comp/mi,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 mi
*** distrib/sets/lists/comp/mi	2000/03/20 23:25:17	1.1.1.7
--- distrib/sets/lists/comp/mi	2000/05/26 17:00:56
***************
*** 1108,1113 ****
--- 1108,1114 ----
  ./usr/libdata/lint/llib-lbz2.ln		comp-c-lintlib
  ./usr/libdata/lint/llib-lc.ln		comp-c-lintlib
  ./usr/libdata/lint/llib-lcompat.ln		comp-c-lintlib
+ ./usr/libdata/lint/llib-lcrack.ln		comp-c-lintlib
  ./usr/libdata/lint/llib-lcrypt.ln		comp-c-lintlib
  ./usr/libdata/lint/llib-lcurses.ln		comp-c-lintlib
  ./usr/libdata/lint/llib-ledit.ln		comp-c-lintlib
***************
*** 1478,1483 ****
--- 1479,1485 ----
  ./usr/share/man/cat2/waitpid.0	comp-syscall-catman
  ./usr/share/man/cat2/write.0	comp-syscall-catman
  ./usr/share/man/cat2/writev.0	comp-syscall-catman
+ ./usr/share/man/cat3/FascistCheck.0	comp-c-catman
  ./usr/share/man/cat3/MD4Data.0	comp-c-catman
  ./usr/share/man/cat3/MD4End.0	comp-c-catman
  ./usr/share/man/cat3/MD4File.0	comp-c-catman
***************
*** 1620,1625 ****
--- 1622,1628 ----
  ./usr/share/man/cat3/cosf.0	comp-c-catman
  ./usr/share/man/cat3/cosh.0	comp-c-catman
  ./usr/share/man/cat3/coshf.0	comp-c-catman
+ ./usr/share/man/cat3/crack.0	comp-c-catman
  ./usr/share/man/cat3/creat.0	comp-c-catman
  ./usr/share/man/cat3/crypt.0	comp-c-catman
  ./usr/share/man/cat3/ctermid.0	comp-c-catman
***************
*** 2978,2983 ****
--- 2981,2987 ----
  ./usr/share/man/man2/waitpid.2		comp-syscall-man
  ./usr/share/man/man2/write.2		comp-syscall-man
  ./usr/share/man/man2/writev.2		comp-syscall-man
+ ./usr/share/man/man3/FascistCheck.3		comp-c-man
  ./usr/share/man/man3/MD4Data.3		comp-c-man
  ./usr/share/man/man3/MD4End.3		comp-c-man
  ./usr/share/man/man3/MD4File.3		comp-c-man
***************
*** 3120,3125 ****
--- 3124,3130 ----
  ./usr/share/man/man3/cosf.3		comp-c-man
  ./usr/share/man/man3/cosh.3		comp-c-man
  ./usr/share/man/man3/coshf.3		comp-c-man
+ ./usr/share/man/man3/crack.3		comp-c-man
  ./usr/share/man/man3/creat.3		comp-c-man
  ./usr/share/man/man3/crypt.3		comp-c-man
  ./usr/share/man/man3/ctermid.3		comp-c-man
Index: distrib/sets/lists/man/mi
===================================================================
RCS file: /cvs/NetBSD/src/distrib/sets/lists/man/mi,v
retrieving revision 1.1.1.6
diff -c -r1.1.1.6 mi
*** distrib/sets/lists/man/mi	2000/03/20 23:25:27	1.1.1.6
--- distrib/sets/lists/man/mi	2000/05/26 16:43:02
***************
*** 282,287 ****
--- 282,288 ----
  ./usr/share/man/cat1/tee.0
  ./usr/share/man/cat1/telnet.0
  ./usr/share/man/cat1/test.0
+ ./usr/share/man/cat1/testpasswd.0
  ./usr/share/man/cat1/tftp.0
  ./usr/share/man/cat1/time.0
  ./usr/share/man/cat1/tip.0
***************
*** 778,783 ****
--- 779,785 ----
  ./usr/share/man/cat8/mfs.0
  ./usr/share/man/cat8/mk-amd-map.0
  ./usr/share/man/cat8/mkalias.0
+ ./usr/share/man/cat8/mkcrackdict.0
  ./usr/share/man/cat8/mknetid.0
  ./usr/share/man/cat8/mknod.0
  ./usr/share/man/cat8/mld6query.0
***************
*** 840,845 ****
--- 842,848 ----
  ./usr/share/man/cat8/pim6sd.0
  ./usr/share/man/cat8/ping.0
  ./usr/share/man/cat8/ping6.0
+ ./usr/share/man/cat8/pkcrackdict.0
  ./usr/share/man/cat8/portmap.0
  ./usr/share/man/cat8/pppd.0
  ./usr/share/man/cat8/pppstats.0
***************
*** 945,950 ****
--- 948,954 ----
  ./usr/share/man/cat8/tunefs.0
  ./usr/share/man/cat8/umount.0
  ./usr/share/man/cat8/unlink.0
+ ./usr/share/man/cat8/unpkcrackdict.0
  ./usr/share/man/cat8/usbdevs.0
  ./usr/share/man/cat8/user.0
  ./usr/share/man/cat8/useradd.0
***************
*** 1238,1243 ****
--- 1242,1248 ----
  ./usr/share/man/man1/tee.1
  ./usr/share/man/man1/telnet.1
  ./usr/share/man/man1/test.1
+ ./usr/share/man/man1/testpasswd.1
  ./usr/share/man/man1/tftp.1
  ./usr/share/man/man1/time.1
  ./usr/share/man/man1/tip.1
***************
*** 1736,1741 ****
--- 1741,1747 ----
  ./usr/share/man/man8/mfs.8
  ./usr/share/man/man8/mk-amd-map.8
  ./usr/share/man/man8/mkalias.8
+ ./usr/share/man/man8/mkcrackdict.8
  ./usr/share/man/man8/mknetid.8
  ./usr/share/man/man8/mknod.8
  ./usr/share/man/man8/mld6query.8
***************
*** 1798,1803 ****
--- 1804,1810 ----
  ./usr/share/man/man8/pim6sd.8
  ./usr/share/man/man8/ping.8
  ./usr/share/man/man8/ping6.8
+ ./usr/share/man/man8/pkcrackdict.8
  ./usr/share/man/man8/portmap.8
  ./usr/share/man/man8/pppd.8
  ./usr/share/man/man8/pppstats.8
***************
*** 1903,1908 ****
--- 1910,1916 ----
  ./usr/share/man/man8/tunefs.8
  ./usr/share/man/man8/umount.8
  ./usr/share/man/man8/unlink.8
+ ./usr/share/man/man8/unpkcrackdict.8
  ./usr/share/man/man8/usbdevs.8
  ./usr/share/man/man8/user.8
  ./usr/share/man/man8/useradd.8
Index: distrib/sets/lists/misc/mi
===================================================================
RCS file: /cvs/NetBSD/src/distrib/sets/lists/misc/mi,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 mi
*** distrib/sets/lists/misc/mi	2000/03/20 23:25:27	1.1.1.4
--- distrib/sets/lists/misc/mi	2000/05/13 21:01:56
***************
*** 5,10 ****
--- 5,11 ----
  ./usr/share/dict/web2
  ./usr/share/dict/web2a
  ./usr/share/dict/words
+ ./usr/share/dict/words.cracklib
  ./usr/share/doc/psd/00.contents
  ./usr/share/doc/psd/05.sysman/0.t
  ./usr/share/doc/psd/05.sysman/1.0.t
Index: lib/Makefile
===================================================================
RCS file: /cvs/NetBSD/src/lib/Makefile,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 Makefile
*** lib/Makefile	2000/03/21 00:13:06	1.1.1.4
--- lib/Makefile	2000/05/12 05:21:10
***************
*** 4,11 ****
  SRCTOP=	..
  .include <bsd.crypto.mk>

! SUBDIR=	csu libarch libbz2 libc libcompat libcrypt libcurses libedit \
! 	libkvm libl libm libmenu libntp libossaudio libpcap libposix \
  	libresolv librmt librpcsvc libskey libterm libusb libutil libwrap \
  	liby libz

--- 4,11 ----
  SRCTOP=	..
  .include <bsd.crypto.mk>

! SUBDIR=	csu libarch libbz2 libc libcompat libcrack libcrypt libcurses libedit \
! 	libident libkvm libl libm libmenu libntp libossaudio libpcap libposix \
  	libresolv librmt librpcsvc libskey libterm libusb libutil libwrap \
  	liby libz

Index: libexec/Makefile
===================================================================
RCS file: /cvs/NetBSD/src/libexec/Makefile,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 Makefile
*** libexec/Makefile	2000/03/21 00:24:19	1.1.1.4
--- libexec/Makefile	2000/05/12 17:19:04
***************
*** 5,13 ****
  .include <bsd.crypto.mk>

  SUBDIR=	atrun comsat fingerd ftpd getNAME getty identd ld.aout_so \
! 	ld.elf_so lfs_cleanerd mail.local makekey makewhatis rexecd \
  	rlogind rmail rshd rpc.rquotad rpc.rstatd rpc.rusersd rpc.rwalld \
! 	rpc.sprayd talkd telnetd tftpd uucpd

  .if defined(CRYPTOPATH)
  .sinclude "${CRYPTOPATH}/libexec/Makefile.frag"
--- 5,14 ----
  .include <bsd.crypto.mk>

  SUBDIR=	atrun comsat fingerd ftpd getNAME getty identd ld.aout_so \
! 	ld.elf_so lfs_cleanerd mail.local makekey makewhatis \
! 	pkcrackdict rexecd \
  	rlogind rmail rshd rpc.rquotad rpc.rstatd rpc.rusersd rpc.rwalld \
! 	rpc.sprayd talkd telnetd tftpd unpkcrackdict uucpd

  .if defined(CRYPTOPATH)
  .sinclude "${CRYPTOPATH}/libexec/Makefile.frag"
Index: share/tmac/doc-syms
===================================================================
RCS file: /cvs/NetBSD/src/share/tmac/doc-syms,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 doc-syms
*** share/tmac/doc-syms	2000/03/21 00:32:00	1.1.1.5
--- share/tmac/doc-syms	2000/05/26 17:47:55
***************
*** 414,419 ****
--- 414,420 ----
  .if "\\$1"libahdi" \&AHDI Disk Partition Library (libahdi, -lahdi)
  .if "\\$1"libc" \&Standard C Library (libc, -lc)
  .if "\\$1"libcompat" \&Compatibility Library (libcompat, -lcompat)
+ .if "\\$1"libcrack" \&CrackLib Library (libcrack, -lcrack)
  .if "\\$1"libcrypt" \&Crypt Library (libcrypt, -lcrypt)
  .if "\\$1"libcurses" \&Curses Library (libcurses, -lcurses)
  .if "\\$1"libedit" \&Command Line Editor Library (libedit, -ledit)
Index: share/tmac/doc2html
===================================================================
RCS file: /cvs/NetBSD/src/share/tmac/doc2html,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 doc2html
*** share/tmac/doc2html	2000/03/21 00:32:00	1.1.1.1
--- share/tmac/doc2html	2000/05/26 17:47:55
***************
*** 567,572 ****
--- 567,573 ----
  .if "\\$1"libahdi" \&AHDI Disk Partition Library (libahdi, -lahdi)
  .if "\\$1"libc" \&Standard C Library (libc, -lc)
  .if "\\$1"libcompat" \&Compatibility Library (libcompat, -lcompat)
+ .if "\\$1"libcrack" \&CrackLib Library (libcrack, -lcrack)
  .if "\\$1"libcrypt" \&Crypt Library (libcrypt, -lcrypt)
  .if "\\$1"libcurses" \&Curses Library (libcurses, -lcurses)
  .if "\\$1"libedit" \&Command Line Editor Library (libedit, -ledit)
Index: usr.bin/Makefile
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/Makefile,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 Makefile
*** usr.bin/Makefile	2000/03/21 01:04:07	1.1.1.5
--- usr.bin/Makefile	2000/05/27 18:38:53
***************
*** 17,25 ****
  	modstat msgc msgs netgroup netstat newsyslog nfsstat nice nl nohup \
  	pagesize passwd paste patch pr printenv printf quota rdist \
  	renice rev rlogin rpcgen rpcinfo rs rsh rup \
! 	ruptime rusers rwall rwho script sed shar shlock \
  	showmount shuffle skey skeyinfo skeyinit soelim split \
! 	su systat tail talk tcopy tee telnet tftp time \
  	tip tn3270 top touch tput tr true tset tsort tty ul \
  	uname unexpand unifdef uniq units unvis usbhidctl users \
  	uudecode uuencode vacation vgrind vi vis vmstat w \
--- 17,25 ----
  	modstat msgc msgs netgroup netstat newsyslog nfsstat nice nl nohup \
  	pagesize passwd paste patch pr printenv printf quota rdist \
  	renice rev rlogin rpcgen rpcinfo rs rsh rup \
! 	ruptime rusers rwall rwho sccs script sed shar shlock \
  	showmount shuffle skey skeyinfo skeyinit soelim split \
! 	su systat tail talk tcopy tee telnet testpasswd tftp time \
  	tip tn3270 top touch tput tr true tset tsort tty ul \
  	uname unexpand unifdef uniq units unvis usbhidctl users \
  	uudecode uuencode vacation vgrind vi vis vmstat w \
Index: usr.bin/passwd/Makefile
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/Makefile,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 Makefile
*** usr.bin/passwd/Makefile	2000/03/21 01:07:36	1.1.1.2
--- usr.bin/passwd/Makefile	2000/05/27 22:12:52
***************
*** 5,13 ****
  .include <bsd.crypto.mk>

  PROG=	passwd
! SRCS=	local_passwd.c yp_passwd.c passwd.c
! DPADD+= ${LIBRPCSVC} ${LIBCRYPT} ${LIBUTIL}
! LDADD+= -lrpcsvc -lcrypt -lutil
  CPPFLAGS+=-I${.CURDIR} -DYP -DLOGIN_CAP

  LINKS=	${BINDIR}/passwd ${BINDIR}/yppasswd
--- 5,13 ----
  .include <bsd.crypto.mk>

  PROG=	passwd
! SRCS=	local_passwd.c yp_passwd.c getnewpass.c passwd.c
! DPADD+= ${LIBRPCSVC} ${LIBCRYPT} ${LIBUTIL} ${LIBCRACK}
! LDADD+= -lrpcsvc -lcrypt -lutil -lcrack
  CPPFLAGS+=-I${.CURDIR} -DYP -DLOGIN_CAP

  LINKS=	${BINDIR}/passwd ${BINDIR}/yppasswd
Index: usr.bin/passwd/extern.h
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/extern.h,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 extern.h
*** usr.bin/passwd/extern.h	2000/03/21 01:07:36	1.1.1.2
--- usr.bin/passwd/extern.h	2000/05/27 22:51:07
***************
*** 42,48 ****
  	PW_DONT_USE
  };

! void to64(char *, long, int);

  #ifdef KERBEROS5
  int	krb5_init __P((const char *));
--- 42,49 ----
  	PW_DONT_USE
  };

! #define PASS_TYPE_YP	"YP"
! #define PASS_TYPE_LOCAL	"local"

  #ifdef KERBEROS5
  int	krb5_init __P((const char *));
***************
*** 71,73 ****
--- 72,76 ----
  int	local_arg_end __P((void));
  void	local_end __P((void));
  int	local_chpw __P((const char *));
+ 
+ char	*getnewpasswd __P((struct passwd *, int, char **, uid_t, char *));
Index: usr.bin/passwd/local_passwd.c
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/local_passwd.c,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 local_passwd.c
*** usr.bin/passwd/local_passwd.c	2000/03/21 01:07:36	1.1.1.4
--- usr.bin/passwd/local_passwd.c	2000/05/27 22:51:21
***************
*** 55,144 ****
  #include <time.h>
  #include <unistd.h>
  #include <util.h>
! #include <login_cap.h>

  #include "extern.h"

- static	char   *getnewpasswd __P((struct passwd *, int));
- 
  static uid_t uid;
  static int force_local;

- char *tempname;
- 
- static unsigned char itoa64[] =		/* 0 ... 63 => ascii - 64 */
- 	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- 
- void
- to64(s, v, n)
- 	char *s;
- 	long v;
- 	int n;
- {
- 	while (--n >= 0) {
- 		*s++ = itoa64[v&0x3f];
- 		v >>= 6;
- 	}
- }
- 
- static char *
- getnewpasswd(pw, min_pw_len)
- 	struct passwd *pw;
- 	int min_pw_len;
- {
- 	int tries;
- 	char *p, *t;
- 	char buf[_PASSWORD_LEN+1], salt[9];
- 	
- 	(void)printf("Changing local password for %s.\n", pw->pw_name);
- 
- 	if (uid && pw->pw_passwd[0] &&
- 	    strcmp(crypt(getpass("Old password:"), pw->pw_passwd),
- 	    pw->pw_passwd)) {
- 		errno = EACCES;
- 		pw_error(NULL, 1, 1);
- 	}
- 
- 	for (buf[0] = '\0', tries = 0;;) {
- 		p = getpass("New password:");
- 		if (!*p) {
- 			(void)printf("Password unchanged.\n");
- 			pw_error(NULL, 0, 0);
- 		}
- 		if (min_pw_len > 0 && strlen(p) < min_pw_len) {
- 			(void) printf("Password is too short.\n");
- 			continue;
- 		}
- 		if (strlen(p) <= 5 && ++tries < 2) {
- 			(void)printf("Please enter a longer password.\n");
- 			continue;
- 		}
- 		for (t = p; *t && islower(*t); ++t);
- 		if (!*t && ++tries < 2) {
- 			(void)printf("Please don't use an all-lower case "
- 				     "password.\nUnusual capitalization, "
- 				     "control characters or digits are "
- 				     "suggested.\n");
- 			continue;
- 		}
- 		(void)strncpy(buf, p, sizeof(buf) - 1);
- 		buf[sizeof(buf) - 1] = '\0';
- 		if (!strcmp(buf, getpass("Retype new password:")))
- 			break;
- 		(void)printf("Mismatch; try again, EOF to quit.\n");
- 	}
- 	/* grab a random printable character that isn't a colon */
- 	(void)srandom((int)time((time_t *)NULL));
- #ifdef NEWSALT
- 	salt[0] = _PASSWORD_EFMT1;
- 	to64(&salt[1], (long)(29 * 25), 4);
- 	to64(&salt[5], random(), 4);
- #else
- 	to64(&salt[0], random(), 2);
- #endif
- 	return(crypt(buf, salt));
- }
- 
  int
  local_init(progname)
  	const char *progname;
--- 55,69 ----
  #include <time.h>
  #include <unistd.h>
  #include <util.h>
! #ifdef LOGIN_CAP
! # include <login_cap.h>
! #endif

  #include "extern.h"

  static uid_t uid;
  static int force_local;

  int
  local_init(progname)
  	const char *progname;
***************
*** 201,210 ****
  	/* Save the old pw information for comparing on pw_copy(). */
  	old_pw = *pw;

  	/*
  	 * Get class restrictions for this user, then get the new password. 
  	 */
- #ifdef LOGIN_CAP
  	if((lc = login_getclass(pw->pw_class))) {
  		min_pw_len = (int) login_getcapnum(lc, "minpasswordlen", 0, 0);
  		pw_expiry  = (int) login_getcaptime(lc, "passwordtime", 0, 0);
--- 126,135 ----
  	/* Save the old pw information for comparing on pw_copy(). */
  	old_pw = *pw;

+ #ifdef LOGIN_CAP
  	/*
  	 * Get class restrictions for this user, then get the new password. 
  	 */
  	if((lc = login_getclass(pw->pw_class))) {
  		min_pw_len = (int) login_getcapnum(lc, "minpasswordlen", 0, 0);
  		pw_expiry  = (int) login_getcaptime(lc, "passwordtime", 0, 0);
***************
*** 212,218 ****
  	}
  #endif

! 	pw->pw_passwd = getnewpasswd(pw, min_pw_len);
  	pw->pw_change = pw_expiry ? pw_expiry + time(NULL) : 0;

  	/*
--- 137,143 ----
  	}
  #endif

! 	pw->pw_passwd = getnewpasswd(pw, min_pw_len, (char **) NULL, uid, PASS_TYPE_LOCAL);
  	pw->pw_change = pw_expiry ? pw_expiry + time(NULL) : 0;

  	/*
Index: usr.bin/passwd/passwd.1
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/passwd.1,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 passwd.1
*** usr.bin/passwd/passwd.1	2000/03/21 01:07:37	1.1.1.2
--- usr.bin/passwd/passwd.1	2000/05/26 17:35:30
***************
*** 88,94 ****
  .Dv _PASSWORD_LEN
  (currently 128 characters).
  Numbers, upper case letters and meta characters
! are encouraged.
  .Pp
  All options may not be available on all systems.
  .Bl -tag -width flag
--- 88,105 ----
  .Dv _PASSWORD_LEN
  (currently 128 characters).
  Numbers, upper case letters and meta characters
! are encouraged.  The password must also
! .Em not
! appear in the dictionary (or any of the various 
! .Dq obvious
! permutations of words in the dictionary) used by
! .Xr FascistCheck 3 ,
! or any of the words in the user's
! .Ar gecos
! field.  Passwords can be checked against this function ahead of time
! using the
! .Xr testpasswd 1
! command.
  .Pp
  All options may not be available on all systems.
  .Bl -tag -width flag
***************
*** 161,171 ****
  .Sh SEE ALSO
  .Xr chpass 1 ,
  .Xr login 1 ,
  .Xr passwd 5 ,
  .Xr pwd_mkdb 8 ,
  .Xr vipw 8
  .Rs
! .%A Robert Morris
  .%A Ken Thompson
  .%T "UNIX password security"
  .Re
--- 172,185 ----
  .Sh SEE ALSO
  .Xr chpass 1 ,
  .Xr login 1 ,
+ .Xr testpasswd 1 ,
+ .Xr FascistCheck 3 ,
  .Xr passwd 5 ,
+ .Xr mkkcrackdict 8
  .Xr pwd_mkdb 8 ,
  .Xr vipw 8
  .Rs
! .%A Robert H. Morris
  .%A Ken Thompson
  .%T "UNIX password security"
  .Re
***************
*** 174,176 ****
--- 188,210 ----
  .Nm
  command appeared in
  .At v6 .
+ .\"
+ .Sh BUGS
+ There is no way to disable the checks done by
+ .Xr FascistCheck 3
+ other than by creating an empty dictionary and there is no way to
+ specify an alternate dictionary either.  The
+ .Nm
+ command will fail if the dictionary does not exist.
+ .Pp
+ The password will not be tested for crackability against words at the
+ end of a
+ .Ar gecos
+ field longer than 1024 characters.
+ .\"
+ .Sh SECURITY CONSIDERATIONS
+ The
+ .Lb libcrack
+ is only as good as the dictionaries you give it to work with.  If the
+ attacker has a better dictionary then he or she may be able to guess
+ passwords that had been approved by this program.
Index: usr.bin/passwd/passwd.c
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/passwd.c,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 passwd.c
*** usr.bin/passwd/passwd.c	2000/03/21 01:07:37	1.1.1.3
--- usr.bin/passwd/passwd.c	2000/05/27 22:47:11
***************
*** 51,56 ****
--- 51,57 ----
  #include <stdio.h>
  #include <string.h>
  #include <unistd.h>
+ #include <pwd.h>

  #include "extern.h"

***************
*** 62,68 ****
  	int (*pw_arg) __P((char, const char *));
  	int (*pw_arg_end) __P((void));
  	void (*pw_end) __P((void));
- 
  	int (*pw_chpw) __P((const char*));
  	int invalid;
  #define	INIT_INVALID 1
--- 63,68 ----
Index: usr.bin/passwd/yp_passwd.c
===================================================================
RCS file: /cvs/NetBSD/src/usr.bin/passwd/yp_passwd.c,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 yp_passwd.c
*** usr.bin/passwd/yp_passwd.c	2000/03/21 01:07:37	1.1.1.4
--- usr.bin/passwd/yp_passwd.c	2000/05/27 22:50:14
***************
*** 73,96 ****

  static	int yflag;

- static	char		*getnewpasswd __P((struct passwd *, char **));
  static	int		 ypgetpwnam __P((const char *));
- static	void		 pw_error __P((char *, int, int));

  static uid_t uid;
  char *domain;

- static void
- pw_error(name, err, eval)
- 	char *name;
- 	int err, eval;
- {
- 
- 	if (err)
- 		warn("%s", name);
- 	errx(eval, "YP passwd database unchanged");
- }
- 
  int
  yp_init(progname)
  	const char *progname;
--- 73,83 ----
***************
*** 202,208 ****
  		    strerror(EACCES));

  	/* prompt for new password */
! 	yppasswd.newpw.pw_passwd = getnewpasswd(pw, &yppasswd.oldpass);

  	/* tell rpc.yppasswdd */
  	yppasswd.newpw.pw_name	= strdup(pw->pw_name);
--- 189,195 ----
  		    strerror(EACCES));

  	/* prompt for new password */
! 	yppasswd.newpw.pw_passwd = getnewpasswd(pw, 0, &yppasswd.oldpass, uid, PASS_TYPE_YP);

  	/* tell rpc.yppasswdd */
  	yppasswd.newpw.pw_name	= strdup(pw->pw_name);
***************
*** 232,299 ****
  		printf("The YP password has been changed on %s, %s\n",
  		    master, "the master YP passwd server.");
  	return(0);
- }
- 
- static char *
- getnewpasswd(pw, old_pass)
- 	struct passwd *pw;
- 	char **old_pass;
- {
- 	int tries;
- 	char *p, *t;
- 	static char buf[_PASSWORD_LEN+1];
- 	char salt[9];
- 	
- 	(void)printf("Changing YP password for %s.\n", pw->pw_name);
- 
- 	if (old_pass) {
- 		*old_pass = NULL;
- 	
- 		if (pw->pw_passwd[0]) {
- 			if (strcmp(crypt(p = getpass("Old password:"),
- 					 pw->pw_passwd),  pw->pw_passwd)) {
- 				   (void)printf("Sorry.\n");
- 				   pw_error(NULL, 0, 1);
- 			}
- 		} else {
- 			p = "";
- 		}
- 
- 		*old_pass = strdup(p);
- 	}
- 	for (buf[0] = '\0', tries = 0;;) {
- 		p = getpass("New password:");
- 		if (!*p) {
- 			(void)printf("Password unchanged.\n");
- 			pw_error(NULL, 0, 0);
- 		}
- 		if (strlen(p) <= 5 && ++tries < 2) {
- 			(void)printf("Please enter a longer password.\n");
- 			continue;
- 		}
- 		for (t = p; *t && islower(*t); ++t);
- 		if (!*t && ++tries < 2) {
- 			(void)printf("Please don't use an all-lower case "
- 				     "password.\nUnusual capitalization, "
- 				     "control characters or digits are "
- 				     "suggested.\n");
- 			continue;
- 		}
- 		(void)strncpy(buf, p, sizeof(buf) - 1);
- 		if (!strcmp(buf, getpass("Retype new password:")))
- 			break;
- 		(void)printf("Mismatch; try again, EOF to quit.\n");
- 	}
- 	/* grab a random printable character that isn't a colon */
- 	(void)srandom((int)time((time_t *)NULL));
- #ifdef NEWSALT
- 	salt[0] = _PASSWORD_EFMT1;
- 	to64(&salt[1], (long)(29 * 25), 4);
- 	to64(&salt[5], random(), 4);
- #else
- 	to64(&salt[0], random(), 2);
- #endif
- 	return(strdup(crypt(buf, salt)));
  }

  static int
--- 219,224 ----
Index: usr.sbin/Makefile
===================================================================
RCS file: /cvs/NetBSD/src/usr.sbin/Makefile,v
retrieving revision 1.1.1.6
diff -c -r1.1.1.6 Makefile
*** usr.sbin/Makefile	2000/03/21 01:11:19	1.1.1.6
--- usr.sbin/Makefile	2000/05/12 17:09:30
***************
*** 10,20 ****
  SUBDIR=	ac accton amd apm apmd arp bad144 bind bootp catman \
  	chown chroot chrtbl cnwctl config cron dbsym dev_mkdb \
  	dhcp diskpart dumpfs dumplfs edquota eeprom \
! 	envstat eshconfig greconfig \
  	grfconfig grfinfo gspa hilinfo inetd iostat ipf iteconfig kgmon \
  	kvm_mkdb lastlogin link lpr mailwrapper map-mbone \
  	mdconfig mdsetimage \
! 	memswitch mopd mountd mrinfo mrouted mtrace mtree \
  	netgroup_mkdb nfsd nfsiod pkg_install portmap pppd pstat \
  	pwd_mkdb quot quotacheck quotaon rarpd rbootd rdate \
  	repquota rmt rpc.bootparamd rpc.lockd rpc.pcnfsd \
--- 10,20 ----
  SUBDIR=	ac accton amd apm apmd arp bad144 bind bootp catman \
  	chown chroot chrtbl cnwctl config cron dbsym dev_mkdb \
  	dhcp diskpart dumpfs dumplfs edquota eeprom \
! 	envstat eshconfig etcupd greconfig \
  	grfconfig grfinfo gspa hilinfo inetd iostat ipf iteconfig kgmon \
  	kvm_mkdb lastlogin link lpr mailwrapper map-mbone \
  	mdconfig mdsetimage \
! 	memswitch mkcrackdict mopd mountd mrinfo mrouted mtrace mtree \
  	netgroup_mkdb nfsd nfsiod pkg_install portmap pppd pstat \
  	pwd_mkdb quot quotacheck quotaon rarpd rbootd rdate \
  	repquota rmt rpc.bootparamd rpc.lockd rpc.pcnfsd \

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	lib/libcrack
#	lib/libcrack/HISTORY
#	lib/libcrack/LICENCE
#	lib/libcrack/Makefile
#	lib/libcrack/POSTER
#	lib/libcrack/README
#	lib/libcrack/crack.3
#	lib/libcrack/crack.h
#	lib/libcrack/fascist.c
#	lib/libcrack/genrules.pl
#	lib/libcrack/packlib.c
#	lib/libcrack/rules.c
#	lib/libcrack/shlib_version
#	lib/libcrack/stringlib.c
#	libexec/pkcrackdict
#	libexec/pkcrackdict/Makefile
#	libexec/pkcrackdict/pkcrackdict.8
#	libexec/pkcrackdict/pkcrackdict.c
#	libexec/unpkcrackdict
#	libexec/unpkcrackdict/Makefile
#	libexec/unpkcrackdict/unpkcrackdict.8
#	libexec/unpkcrackdict/unpkcrackdict.c
#	usr.bin/passwd/getnewpass.c
#	usr.bin/testpasswd
#	usr.bin/testpasswd/Makefile
#	usr.bin/testpasswd/testpasswd.1
#	usr.bin/testpasswd/testpasswd.c
#	usr.sbin/mkcrackdict
#	usr.sbin/mkcrackdict/Makefile
#	usr.sbin/mkcrackdict/mkcrackdict.8
#	usr.sbin/mkcrackdict/mkcrackdict.sh
#
echo c - lib/libcrack
mkdir -p lib/libcrack > /dev/null 2>&1
echo x - lib/libcrack/HISTORY
sed 's/^X//' >lib/libcrack/HISTORY << 'END-of-lib/libcrack/HISTORY'
Xv2.7    mkdict/tr problem eliminated;
X	misc fixes suggested by Andrey Savochkin <saw@msu.ru> (with thanks)
Xv2.6    buffer overflow problems addressed - 1st attempt
X	permutations of fascist deconstructors fixed/enhanced
Xv2.5    added decent info to the "shadow" directory patches.
Xv2.4    forwarded to ch & jfh3 for beta testing/comments
Xv2.3-   internal beta test versions
END-of-lib/libcrack/HISTORY
echo x - lib/libcrack/LICENCE
sed 's/^X//' >lib/libcrack/LICENCE << 'END-of-lib/libcrack/LICENCE'
X(*
XThis document is freely plagiarised from the 'Artistic Licence',
Xdistributed as part of the Perl v4.0 kit by Larry Wall, which is
Xavailable from most major archive sites
X*)
X
XThis documents purpose is to state the conditions under which these
XPackages (See definition below) viz: "Crack", the Unix Password Cracker,
Xand "CrackLib", the Unix Password Checking library, which are held in
Xcopyright by Alec David Edward Muffett, may be copied, such that the
Xcopyright holder maintains some semblance of artistic control over the
Xdevelopment of the packages, while giving the users of the package the
Xright to use and distribute the Package in a more-or-less customary
Xfashion, plus the right to make reasonable modifications. 
X
XSo there.
X
X***************************************************************************
X
XDefinitions:
X
X
XA "Package" refers to the collection of files distributed by the
XCopyright Holder, and derivatives of that collection of files created
Xthrough textual modification, or segments thereof. 
X
X"Standard Version" refers to such a Package if it has not been modified,
Xor has been modified in accordance with the wishes of the Copyright
XHolder.
X
X"Copyright Holder" is whoever is named in the copyright or copyrights
Xfor the package.
X
X"You" is you, if you're thinking about copying or distributing this
XPackage.
X
X"Reasonable copying fee" is whatever you can justify on the basis of
Xmedia cost, duplication charges, time of people involved, and so on.
X(You will not be required to justify it to the Copyright Holder, but
Xonly to the computing community at large as a market that must bear the
Xfee.)
X
X"Freely Available" means that no fee is charged for the item itself,
Xthough there may be fees involved in handling the item.  It also means
Xthat recipients of the item may redistribute it under the same
Xconditions they received it.
X
X
X1.  You may make and give away verbatim copies of the source form of the
XStandard Version of this Package without restriction, provided that you
Xduplicate all of the original copyright notices and associated
Xdisclaimers.
X
X2.  You may apply bug fixes, portability fixes and other modifications
Xderived from the Public Domain or from the Copyright Holder.  A Package
Xmodified in such a way shall still be considered the Standard Version.
X
X3.  You may otherwise modify your copy of this Package in any way,
Xprovided that you insert a prominent notice in each changed file stating
Xhow and when AND WHY you changed that file, and provided that you do at
Xleast ONE of the following:
X
Xa) place your modifications in the Public Domain or otherwise make them
XFreely Available, such as by posting said modifications to Usenet or an
Xequivalent medium, or placing the modifications on a major archive site
Xsuch as uunet.uu.net, or by allowing the Copyright Holder to include
Xyour modifications in the Standard Version of the Package.
X
Xb) use the modified Package only within your corporation or organization.
X
Xc) rename any non-standard executables so the names do not conflict with
Xstandard executables, which must also be provided, and provide separate
Xdocumentation for each non-standard executable that clearly documents
Xhow it differs from the Standard Version.
X
Xd) make other distribution arrangements with the Copyright Holder.
X
X4.  You may distribute the programs of this Package in object code or
Xexecutable form, provided that you do at least ONE of the following:
X
Xa) distribute a Standard Version of the executables and library files,
Xtogether with instructions (in the manual page or equivalent) on where
Xto get the Standard Version.
X
Xb) accompany the distribution with the machine-readable source of the
XPackage with your modifications.
X
Xc) accompany any non-standard executables with their corresponding
XStandard Version executables, giving the non-standard executables
Xnon-standard names, and clearly documenting the differences in manual
Xpages (or equivalent), together with instructions on where to get the
XStandard Version.
X
Xd) make other distribution arrangements with the Copyright Holder.
X
X5.  You may charge a reasonable copying fee for any distribution of this
XPackage.  You may charge any fee you choose for support of this Package. 
XYOU MAY NOT CHARGE A FEE FOR THIS PACKAGE ITSELF.  However, you may
Xdistribute this Package in aggregate with other (possibly commercial)
Xprograms as part of a larger (possibly commercial) software distribution
Xprovided that YOU DO NOT ADVERTISE this package as a product of your
Xown. 
X
X6.  The name of the Copyright Holder may not be used to endorse or
Xpromote products derived from this software without specific prior
Xwritten permission.
X
X7.  THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
XWARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
XMERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X
X				The End
END-of-lib/libcrack/LICENCE
echo x - lib/libcrack/Makefile
sed 's/^X//' >lib/libcrack/Makefile << 'END-of-lib/libcrack/Makefile'
X###
X# This program is copyright Alec Muffett 1993. The author disclaims all
X# responsibility or liability with respect to it's usage or its effect
X# upon hardware or computer systems, and maintains copyright as set out
X# in the "LICENCE" document which accompanies distributions of Crack v4.0
X# and upwards.
X###
X
XLIB=	crack
X
XSRCS=	fascist.c packlib.c rules.c stringlib.c
X
XINCS=	crack.h
X
XINCSDIR= /usr/include
X
XMAN=	crack.3
XMLINKS=	crack.3 FascistCheck.3
X
XCPPFLAGS= -DIN_CRACKLIB
X
X.include <bsd.lib.mk>
END-of-lib/libcrack/Makefile
echo x - lib/libcrack/POSTER
sed 's/^X//' >lib/libcrack/POSTER << 'END-of-lib/libcrack/POSTER'
X
XCrackLib is a library containing a C function (well, lots of functions
Xreally, but you only need to use one of them) which may be used in a
X"passwd"-like program.
X
XThe idea is simple: try to prevent users from choosing passwords that
Xcould be guessed by "Crack" by filtering them out, at source.
X
XCrackLib is an offshoot of the the version 5 "Crack" software, and
Xcontains a considerable number of ideas nicked from the new software. 
XAt the time of writing, Crack 5 is incomplete (still awaiting purchase
Xof my home box) - but I though I could share this with you. 
X
XNOTE THIS WELL: CrackLib is NOT a replacement "passwd" program. 
XCrackLib is a LIBRARY.  CrackLib is what trendy marketdroid types would
Xprobably call an "enabler". 
X
XThe idea is that you wire it into your _own_ "passwd" program (if you
Xhave source); alternatively, you wire it into something like "shadow"
Xfrom off of the net.  You can use it almost _everywhere_. 
X
XFOR YOUR INFORMATION:
X
XCrackLib has been tested mostly on Suns.  If you can point me at ways
Xround portability problems (eg: static linking, other libraries, etc)
XI'd be most grateful. 
X
XA reference copy of CrackLib can be found at the following location: 
X 
X	http://www.crypto.dircon.co.uk/download/cracklib,2.7.tgz
X
X
X					- alec
X
XAlec's home page is here:
X
X	http://www.crypto.dircon.co.uk/
END-of-lib/libcrack/POSTER
echo x - lib/libcrack/README
sed 's/^X//' >lib/libcrack/README << 'END-of-lib/libcrack/README'
XCrackLib:	A ProActive Password Sanity Library
XBy: 		Alec Muffett
XAddress:	alecm@crypto.dircon.co.uk
XDate:		Sun Dec 14 22:16:48 GMT 1997
X
X- This software is not my fault in any way, nor indeed anybody's -
X
X
X*** What is CrackLib ***
X
X
XCrackLib is a library containing a C function (well, lots of functions
Xreally, but you only need to use one of them) which may be used in a
X"passwd"-like program.
X
XThe idea is simple: try to prevent users from choosing passwords that
Xcould be guessed by "Crack" by filtering them out, at source.
X
XCrackLib is an offshoot of the the version 5 "Crack" software, and
Xcontains a considerable number of ideas nicked from the new software.
X
XAt the time of writing, Crack 5 is incomplete (still awaiting purchase
Xof my home box) - but I though I could share this with you.
X
X[ Incidentally, if Dell or anyone would like to "donate" a Linuxable
X486DX2-66MHz box (EISA/16Mb RAM/640MB HD/AHA1740) as a development
Xplatform for Crack, I'd be more than grateful to hear from you.  8-) ]
X
X
XNOTE THIS WELL: CrackLib is NOT a replacement "passwd" program.
XCrackLib is a LIBRARY.  CrackLib is what trendy marketdroid types would
Xprobably call an "enabler".
X
XThe idea is that you wire it into your _own_ "passwd" program (if you
Xhave source); alternatively, you wire it into something like "shadow"
Xfrom off of the net.  You can use it in other things, too.
X
XYou can use it almost _everywhere_.
X
X
X*** Advantages of CrackLib ***
X
X
X1) it WORKS!
X
XI wrote something similar ("goodpass") a few years back, which went out
Xwith Crack v3.x.
X
XGoodpass was slow and buggy and I think it was used (at least in part)
Xin "npasswd".  Hopefully, CrackLib will supplant "goodpass" entirely.
X
X
X2) it's FAST!
X
XCrackLib finds potential passwords quickly, by using an index file to
Xaccess dictionary words, and by keeping a table to assist binary
Xsearching.
X
X
X3) it's SMALL!
X
XCrackLib's dictionary is modified-DAWG compressed with a chunksize of 16
Xwords (see Crack v5.0 docs (when it comes out) for details) - and then
Xthe index file is built, with one entry per chunk.
X
XThe upshot of all this is that CrackLib can do indexed, binary searches
Xin a 1.4 million word dictionary (raw size ~ 15Mb), but the CrackLib
Xfiles (data+index+watermarks) occupy only ~ 7Mb.  (45% original size)
X
XIt's even efficient over NFS !
X
X
X4) it's MIND-NUMBINGLY THOROUGH!
X
X(is this beginning to read like a B-movie flyer, or what?)
X
XCrackLib makes literally hundreds of tests to determine whether you've
Xchosen a bad password.
X
X* It tries to generate words from your username and gecos entry to tries
Xto match them against what you've chosen.
X
X* It checks for simplistic patterns.
X
X* It then tries to reverse-engineer your password into a dictionary
Xword, and searches for it in your dictionary.
X
X- after all that, it's PROBABLY a safe(-ish) password.  8-)
X
X
X*** Instructions for building CrackLib...
X
X
XSTEP 0) Engage your brain.
X
XI'm interested in improving the CrackLib software, doing bugfixes,
X"guessing technique" improvements, and portability enhancements. 
X
XI'm NOT interested in unhelpful comments like "well, _my_ operating
Xsystem doesn't come with a dictionary".  If it doesn't, either complain
Xto your vendor, or GO AND GET a dictionary off the net. 
X
XCrackLib is NOT a TOOL.  It is not a complete package.  It is not
Xsomething you can utilise directly. 
X
XIt is a resource, an aid, something to enhance the functionality of
Xother software.  You need to (either) write OR modify other software to
Xuse it.  If you can't do this, then you shouldn't be wasting your time
Xwith it. 
X
XRegarding bugs and portability problems: please try to work them out for
Xyourself, and then (please) TELL me about them.  This will help me
Ximprove future versions. 
X
X
XSTEP 1) Edit the Makefile to set your preferred value of DICTPATH
X
XThis it the directory+filename-prefix that your version of CrackLib will
Xgo hunting for, and it must be visible to all programs on all hosts that
Xuse CrackLib
X
XHence, if you want to use a CrackLib binary on a distributed network,
Xthese files are probably best placed on an NFS server.
X
XNote: You have to specify a FILENAME PREFIX too, eg:
X
X	DICTPATH=/usr/local/lib/pw_dict
X
Xwhich will generate:
X
X	/usr/local/lib/pw_dict.pwd
X	/usr/local/lib/pw_dict.pwi
X	/usr/local/lib/pw_dict.hwm
X
Xwhich are the files that CrackLib needs.
X
XThese files are NOT byte-order independent, in fact they are probably
XARCHITECTURE SPECIFIC, mostly due to speed constraints.  If this is a
Xproblem, I suggest you use:
X
X	DICTPATH=/usr/local/lib/pw_dict.sun4
X	DICTPATH=/usr/local/lib/pw_dict.i386
X	DICTPATH=/usr/local/lib/pw_dict.cray
X
X...etc, and build several sets of files, as appropriate.
X
X
X(Hackers Note: Strictly, only *.pwi and *.hwm should be architecture
Xdependent; however, if you build two dictionaries on two different
Xplatforms, you MAY wind up with different *.pwd files too, due to
Xincompatibilities in the std Unix utilities, or from using different
XSOURCEDICTs.
X
XI may try to work this out in the next release.  In the mean time, if
Xyour *.pwd files are EXACTLY identical (use "cmp" to test), you can
Xdelete the multiple copies and use softlinks instead.)
X
X
XSTEP 2) Add to the SOURCEDICT variable, any files continaing extra words
Xthat you wish CrackLib to use.  CrackLib merges all of these files
Xtogether, removes redundant characters, and compresses them.  Generally,
Xthe output file is 40..60% the size of all the input files, combined.
X
XMore word lists (dictionaries) can be found all over the Internet, two
Xsuch example locations are here:
X
X	ftp://ftp.ox.ac.uk/pub/wordlists/
X	ftp://ftp.uu.net/doc/dictionaries/
X
XNOTE: THE DEFAULT VALUE OF "SOURCEDICT" CONTAINS "/usr/dict/words" -
Xthis is a file which can be found on many BSD-type Unix systems,
Xcontaining a list of words, one per line, suitable for use with
X"cracklib".  If you do not have such a file, refer to STEP 0.
X
X
XSTEP 3) do:
X
X	% make all
X
Xthen do:
X
X	% make install
X
Xwhich will build the CrackLib dictionary in $DICTPATH.
X
X
X*** NOTE THIS WELL ***
X
XIf you supply massive amounts of text to CrackLib to use a a dictionary,
Xyou must have enough free space available for use by the "sort" command,
Xwhen the dictionary is built.
X
XSo: If you do not have (say) about 20Mb free in /usr/tmp (or whatever
Xtemporary area your "sort" command uses), have a look at the
X"util/mkdict" script.
X
XYou can usually tweak the "sort" command to use any large area of disk
Xyou desire, by use of the "-T" option, and "mkdict" has a hook for this.
X
X
XSTEP 4) Wire a call to "FascistCheck()" into your "passwd" program
X
X
X- Left as an exercise for the reader.
X
X
X*** Example of how to invoke CrackLib
X
XInsert a call to the routine FascistCheck, which is defined thusly:
X
XNAME
X	FascistCheck - check a potential password for guessability
X
X
XSYNOPSIS
X
X	char *FascistCheck(char *pw, char *dictpath);
X
X
XDESCRIPTION
X
X	FascistCheck() takes 2 arguments:
X
X	pw - a string continaing the users chosen "potential password"
X
X	dictpath - the full path name + filename prefix of the
X	CrackLib dictionary, specified in the installation Makefile.
X	(If you still haven't sussed, I'm talking about DICTPATH).
X
X
XRETURN VALUE
X
X	FascistCheck() returns the NULL pointer for a good password,
X	or a pointer to a diagnostic string if it is a bad password.
X
X
XBUGS
X	- it can't catch everything. Just most things.
X
X	- it calls getpwuid(getuid()) to look up the user,
X	  this MAY affect poorly written programs
X
X	- using more than one pw_dict file, eg:
X
X		char *msg;
X		if (msg = FascistCheck(pw, "onepath") ||
X		    msg = FascistCheck(pw, "anotherpath"))
X		{
X		    printf("Bad Password: because %s\n", msg);
X		}
X
X	   ...works, but it's a kludge. AVOID IT IF POSSIBLE.
X	   Using just the one dictionary is more efficient, anyway.
X
X	- PWOpen() routines should cope with having more than 1
X	  dictionary open at a time.  I'll fix this RSN.
X
X
XWORKED EXAMPLE
X
X---- modified extract from BSD distribution - "local_passwd.c" ----
X
X#ifndef CRACKLIB_DICTPATH /* if possible, get from the same Makefile as CrackLib */
X#define CRACKLIB_DICTPATH "/usr/local/lib/pw_dict"
X#endif		/* see examples on how to import DICTPATH into CRACKLIB_DICTPATH */
X...
X...
X...
X	for (buf[0] = '\0', tries = 0;;) {
X		p = getpass("New password:");
X		if (!*p) {
X			(void)printf("Password unchanged.\n");
X			pw_error(NULL, 0, 0);
X		}
X
X#ifndef CRACKLIB_DICTPATH
X		if (strlen(p) <= 5 && (uid != 0 || ++tries < 2)) {
X			(void)printf("Please enter a longer password.\n");
X			continue;
X		}
X		for (t = p; *t && islower(*t); ++t);
X		if (!*t && (uid != 0 || ++tries < 2)) {
X			(void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");
X			continue;
X		}
X#else
X		{
X			char *msg;
X			if (msg = (char *) FascistCheck(pwbuf, CRACKLIB_DICTPATH)) {
X				printf("Please use a different password.\n");
X				printf("The one you have chosen is unsuitable because %s.\n", msg);
X				continue;	/* go round and round until they get it right */
X			}
X		}
X#endif /* CRACKLIB_DICTPATH */
X
X		(void)strcpy(buf, p);
X		if (!strcmp(buf, getpass("Retype new password:")))
X			break;
X		(void)printf("Mismatch; try again, EOF to quit.\n");
X	}
X---- end of extract ----
END-of-lib/libcrack/README
echo x - lib/libcrack/crack.3
sed 's/^X//' >lib/libcrack/crack.3 << 'END-of-lib/libcrack/crack.3'
X.\"
X.\" This program is copyright Alec Muffett 1993. The author disclaims all 
X.\" responsibility or liability with respect to it's usage or its effect 
X.\" upon hardware or computer systems, and maintains copyright as set out 
X.\" in the "LICENCE" document which accompanies distributions of Crack v5.0 
X.\" and upwards.
X.\"
X.\" This manual page written by Greg A. Woods <woods@planix.com>
X.\" derived from original text in CrackLib "README" file.
X.\" Copyright for this rendition contributed to the "Public Domain".
X.\"
X.Dd May 12, 2000
X.Dt crack 3
X.Os
X.Sh "NAME"
X.Nm FascistCheck
X.Nd check a potential password for guess-ability
X.\"
X.Sh "LIBRARY"
X.Lb libcrack
X.\"
X.Sh "SYNOPSIS"
X.Fd #include <stdio.h>
X.Fd #include <crack.h>
X.Ft char *
X.Fn FascistCheck "char *pw" "const char *pw_dict" "char *pw_name" "char *pw_gecos"
X.\"
X.Sh "DESCRIPTION"
XThis function is the primary programming interface to the CrackLib
Xlibrary for checking the crack-ability of a proposed password.
X.Pp
X.Fn FascistCheck
Xtakes two mandatory arguments and two optional arguments:
X.Bl -tag -width pw_gecos
X.It Fa pw
Xa string continuing the user's chosen
X.Dq "potential password" .
X.It Fa pw_dict
Xthe full path name and filename prefix for the files that make up the
Xthe CrackLib dictionary.  The system default value is defined by
X.Dv _PATH_CRACKLIB_DICT
Xin
X.Aq Pa crack.h .
X.It Fa pw_name
Xoptionally specifies the user name.
X.It Fa pw_gecos
Xoptionally specifies the user's full name.
X.El
X.Pp
XIf both
X.Fa pw_name
Xand
X.Fa pw_gecos
Xare given the value of the
X.Dv NULL
Xpointer then internal calls to
X.Fn getpwuid
Xwill be avoided, making this function easier to use from within programs
Xsuch as
X.Xr passwd 8
Xif your system
X.Fn getpw*
Xlibrary routines are not re-entrant.
X.\"
X.Sh "RETURN VALUES"
X.Fm FascistCheck
Xreturns the
X.Dv NULL
Xpointer for a good password, or a pointer to a diagnostic string
Xexplaining why it thinks the password is a bad (guess-able) password.
X.\"
X.Sh "FILES"
X.Bl -tag -width _PATH_CRACKLIB_DICT -compact
X.It Dv _PATH_CRACKLIB_DICT
XThree architecture dependent data files are formed using this prefix
Xdefined in
X.Aq Pa crack.h .
XThese files contain a packed representation of dictionary words that
Xshould not be used for passwords.
X.El
X.\"
X.\".Sh EXAMPLES
X.\"
X.\".Sh DIAGNOSTICS
X.\"
X.Sh SEE ALSO
X.Xr catcrackdict 8 ,
X.Xr getpwuid 3 ,
X.Xr mkcrackdict 8 ,
X.Xr passwd 1,
X.Xr testpasswd 1
X.\"
X.\".Sh STANDARDS
X.\"
X.\".Sh "HISTORY"
X.\"
X.Sh "AUTHOR"
XAlec Muffett
X.Li <alecm@crypto.dircon.co.uk>
X.\"
X.Sh "BUGS"
XIt's only as good as the dictionaries you have it use and it can't catch
Xevery obvious permutation of words, just most things.
X.Pp
XThe internal
X.Fn PWOpen
Xroutines should cope with having more than one dictionary open at a
Xtime.  I'll fix this RSN.  Using more than one
X.Fa pw_dict
Xfile, eg:
X.Bd -literal -offset indent
Xchar *msg;
Xif (msg = FascistCheck(pw, "/one/path/a_pw_dict") ||
X    msg = FascistCheck(pw, "/another/path/another_pw_dict")) {
X	printf("Bad Password: because %s\n", msg);
X}
X.Ed
X.Pp
Xworks, but it's a kludge.  AVOID IT IF POSSIBLE.
XBesides, using just the one dictionary is more efficient.
X.\"
X.Sh SECURITY CONSIDERATIONS
XThis function is designed to help enhance the security of a system using
Xbasic password protection by advising (or forcing, depending on how it
Xis used) the user to choose a password that is hard to guess.  However
Xthis ability is governed almost solely by the quality of the search
Xdictionary.  Any attacker with a better dictionary will still stand a
Xgood chance of guessing a password.  Password security should not rely
Xon this feature alone but should also include mechanisms to prevent
Xhigh-speed guessing attacks, secure logging of repeated failures, etc.
END-of-lib/libcrack/crack.3
echo x - lib/libcrack/crack.h
sed 's/^X//' >lib/libcrack/crack.h << 'END-of-lib/libcrack/crack.h'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X/*
X * note this does not include the filename suffixes of .hwm, .pwd, and .pwi
X *
X * XXX keep this in sync with DICTPATH in usr.sbin/mkcrackdict.sh
X */
X#define	_PATH_CRACKLIB_DICT	"/usr/libdata/pw_dict"
X
X#define STRINGSIZE	1024
X#define TRUNCSTRINGSIZE	(STRINGSIZE/4)
X
Xtypedef unsigned char int8;
Xtypedef unsigned short int int16;
Xtypedef unsigned long int int32;
X#ifndef NUMWORDS
X#define NUMWORDS 	16
X#endif
X#define MAXWORDLEN	32
X#define MAXBLOCKLEN 	(MAXWORDLEN * NUMWORDS)
X
Xstruct pi_header
X{
X    int32 pih_magic;
X    int32 pih_numwords;
X    int16 pih_blocklen;
X    int16 pih_pad;
X};
X
Xtypedef struct
X{
X    FILE *ifp;
X    FILE *dfp;
X    FILE *wfp;
X
X    int32 flags;
X#define PFOR_WRITE	0x0001
X#define PFOR_FLUSH	0x0002
X#define PFOR_USEHWMS	0x0004
X
X    int32 hwms[256];
X
X    struct pi_header header;
X
X    int count;
X    char data[NUMWORDS][MAXWORDLEN];
X} PWDICT;
X
X#ifdef IN_CRACKLIB
X
X#define PIH_MAGIC 0x70775631
X
X#define CRACK_TOLOWER(a) 	(isupper(a)?tolower(a):(a)) 
X#define CRACK_TOUPPER(a) 	(islower(a)?toupper(a):(a)) 
X#define STRCMP(a,b)		strcmp((a),(b))
X
X/* from rules.c */
Xextern int Suffix __P((char *, char *));
Xextern char *Reverse __P((char *));
Xextern char *Uppercase __P((char *));
Xextern char *Lowercase __P((char *));
Xextern char *Capitalise __P((char *));
Xextern char *Pluralise __P((char *));
Xextern char *Substitute __P((char *, int, int));
Xextern char *Purge __P((char *, int));
Xextern char *Mangle __P((char *, char *));
Xextern int PMatch __P((char *, char *));
X
X/* from stringlib.c */
Xextern char *Trim __P((char *));
Xextern char *Clone __P((char *));
X
X#endif /* IN_CRACKLIB */
X
X#define PW_WORDS(x) ((x)->header.pih_numwords)
X
X/* from packlib.c */
Xextern PWDICT *PWOpen __P((char *, char *));
Xextern int PutPW __P((PWDICT *, char *));
Xextern char *GetPW __P((PWDICT *, int32));
Xextern int32 FindPW __P((PWDICT *, char *));
Xextern int PWClose __P((PWDICT *));
X
X/* from stringlib.c */
Xextern char Chop __P((char *));
X
X/* from fascist.c */
Xextern char *FascistCheck __P((char *, char *, char *, char *));
Xextern char *FascistLook __P((PWDICT *, char *, char *, char *));
END-of-lib/libcrack/crack.h
echo x - lib/libcrack/fascist.c
sed 's/^X//' >lib/libcrack/fascist.c << 'END-of-lib/libcrack/fascist.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all
X * responsibility or liability with respect to it's usage or its effect
X * upon hardware or computer systems, and maintains copyright as set out
X * in the "LICENCE" document which accompanies distributions of Crack v4.0
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X
X#ifndef lint
X#if 0
Xstatic char vers_id[] = "fascist.c : v2.3p3 Alec Muffett 14 dec 1997";
X#else
X__RCSID("$NetBSD$");
X#endif
X#endif
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <string.h>
X#include <ctype.h>
X#include <pwd.h>
X
X#include "crack.h"
X
X#define ISSKIP(x) (isspace(x) || ispunct(x))
X
X#define MINDIFF 5
X#define MINLEN 6
X#define MAXSTEP 4
X
X#undef DEBUG
X#undef DEBUG2
X
Xstatic int GTry __P((char *, char *));
Xstatic char *FascistUname __P((char *, uid_t, char *));
Xstatic char *FascistGecos __P((char *, uid_t, char *));
X
Xstatic char *r_destructors[] = {
X    ":",                        /* noop - must do this to test raw word. */
X
X#ifdef DEBUG2
X    (char *) 0,
X#endif
X
X    "[",                        /* trimming leading/trailing junk */
X    "]",
X    "[[",
X    "]]",
X    "[[[",
X    "]]]",
X
X    "/?p@?p",                   /* purging out punctuation/symbols/junk */
X    "/?s@?s",
X    "/?X@?X",
X
X    /* attempt reverse engineering of password strings */
X
X    "/$s$s",
X    "/$s$s/0s0o",
X    "/$s$s/0s0o/2s2a",
X    "/$s$s/0s0o/2s2a/3s3e",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1i",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1l",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1i/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1i/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1l/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/1s1l/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/5s5s/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/1s1i",
X    "/$s$s/0s0o/2s2a/3s3e/1s1l",
X    "/$s$s/0s0o/2s2a/3s3e/1s1i/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/1s1i/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/1s1l/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/1s1l/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/4s4h",
X    "/$s$s/0s0o/2s2a/3s3e/4s4a",
X    "/$s$s/0s0o/2s2a/3s3e/4s4h",
X    "/$s$s/0s0o/2s2a/5s5s",
X    "/$s$s/0s0o/2s2a/5s5s/1s1i",
X    "/$s$s/0s0o/2s2a/5s5s/1s1l",
X    "/$s$s/0s0o/2s2a/5s5s/1s1i/4s4a",
X    "/$s$s/0s0o/2s2a/5s5s/1s1i/4s4h",
X    "/$s$s/0s0o/2s2a/5s5s/1s1l/4s4a",
X    "/$s$s/0s0o/2s2a/5s5s/1s1l/4s4h",
X    "/$s$s/0s0o/2s2a/5s5s/4s4a",
X    "/$s$s/0s0o/2s2a/5s5s/4s4h",
X    "/$s$s/0s0o/2s2a/5s5s/4s4a",
X    "/$s$s/0s0o/2s2a/5s5s/4s4h",
X    "/$s$s/0s0o/2s2a/1s1i",
X    "/$s$s/0s0o/2s2a/1s1l",
X    "/$s$s/0s0o/2s2a/1s1i/4s4a",
X    "/$s$s/0s0o/2s2a/1s1i/4s4h",
X    "/$s$s/0s0o/2s2a/1s1l/4s4a",
X    "/$s$s/0s0o/2s2a/1s1l/4s4h",
X    "/$s$s/0s0o/2s2a/4s4a",
X    "/$s$s/0s0o/2s2a/4s4h",
X    "/$s$s/0s0o/2s2a/4s4a",
X    "/$s$s/0s0o/2s2a/4s4h",
X    "/$s$s/0s0o/3s3e",
X    "/$s$s/0s0o/3s3e/5s5s",
X    "/$s$s/0s0o/3s3e/5s5s/1s1i",
X    "/$s$s/0s0o/3s3e/5s5s/1s1l",
X    "/$s$s/0s0o/3s3e/5s5s/1s1i/4s4a",
X    "/$s$s/0s0o/3s3e/5s5s/1s1i/4s4h",
X    "/$s$s/0s0o/3s3e/5s5s/1s1l/4s4a",
X    "/$s$s/0s0o/3s3e/5s5s/1s1l/4s4h",
X    "/$s$s/0s0o/3s3e/5s5s/4s4a",
X    "/$s$s/0s0o/3s3e/5s5s/4s4h",
X    "/$s$s/0s0o/3s3e/5s5s/4s4a",
X    "/$s$s/0s0o/3s3e/5s5s/4s4h",
X    "/$s$s/0s0o/3s3e/1s1i",
X    "/$s$s/0s0o/3s3e/1s1l",
X    "/$s$s/0s0o/3s3e/1s1i/4s4a",
X    "/$s$s/0s0o/3s3e/1s1i/4s4h",
X    "/$s$s/0s0o/3s3e/1s1l/4s4a",
X    "/$s$s/0s0o/3s3e/1s1l/4s4h",
X    "/$s$s/0s0o/3s3e/4s4a",
X    "/$s$s/0s0o/3s3e/4s4h",
X    "/$s$s/0s0o/3s3e/4s4a",
X    "/$s$s/0s0o/3s3e/4s4h",
X    "/$s$s/0s0o/5s5s",
X    "/$s$s/0s0o/5s5s/1s1i",
X    "/$s$s/0s0o/5s5s/1s1l",
X    "/$s$s/0s0o/5s5s/1s1i/4s4a",
X    "/$s$s/0s0o/5s5s/1s1i/4s4h",
X    "/$s$s/0s0o/5s5s/1s1l/4s4a",
X    "/$s$s/0s0o/5s5s/1s1l/4s4h",
X    "/$s$s/0s0o/5s5s/4s4a",
X    "/$s$s/0s0o/5s5s/4s4h",
X    "/$s$s/0s0o/5s5s/4s4a",
X    "/$s$s/0s0o/5s5s/4s4h",
X    "/$s$s/0s0o/1s1i",
X    "/$s$s/0s0o/1s1l",
X    "/$s$s/0s0o/1s1i/4s4a",
X    "/$s$s/0s0o/1s1i/4s4h",
X    "/$s$s/0s0o/1s1l/4s4a",
X    "/$s$s/0s0o/1s1l/4s4h",
X    "/$s$s/0s0o/4s4a",
X    "/$s$s/0s0o/4s4h",
X    "/$s$s/0s0o/4s4a",
X    "/$s$s/0s0o/4s4h",
X    "/$s$s/2s2a",
X    "/$s$s/2s2a/3s3e",
X    "/$s$s/2s2a/3s3e/5s5s",
X    "/$s$s/2s2a/3s3e/5s5s/1s1i",
X    "/$s$s/2s2a/3s3e/5s5s/1s1l",
X    "/$s$s/2s2a/3s3e/5s5s/1s1i/4s4a",
X    "/$s$s/2s2a/3s3e/5s5s/1s1i/4s4h",
X    "/$s$s/2s2a/3s3e/5s5s/1s1l/4s4a",
X    "/$s$s/2s2a/3s3e/5s5s/1s1l/4s4h",
X    "/$s$s/2s2a/3s3e/5s5s/4s4a",
X    "/$s$s/2s2a/3s3e/5s5s/4s4h",
X    "/$s$s/2s2a/3s3e/5s5s/4s4a",
X    "/$s$s/2s2a/3s3e/5s5s/4s4h",
X    "/$s$s/2s2a/3s3e/1s1i",
X    "/$s$s/2s2a/3s3e/1s1l",
X    "/$s$s/2s2a/3s3e/1s1i/4s4a",
X    "/$s$s/2s2a/3s3e/1s1i/4s4h",
X    "/$s$s/2s2a/3s3e/1s1l/4s4a",
X    "/$s$s/2s2a/3s3e/1s1l/4s4h",
X    "/$s$s/2s2a/3s3e/4s4a",
X    "/$s$s/2s2a/3s3e/4s4h",
X    "/$s$s/2s2a/3s3e/4s4a",
X    "/$s$s/2s2a/3s3e/4s4h",
X    "/$s$s/2s2a/5s5s",
X    "/$s$s/2s2a/5s5s/1s1i",
X    "/$s$s/2s2a/5s5s/1s1l",
X    "/$s$s/2s2a/5s5s/1s1i/4s4a",
X    "/$s$s/2s2a/5s5s/1s1i/4s4h",
X    "/$s$s/2s2a/5s5s/1s1l/4s4a",
X    "/$s$s/2s2a/5s5s/1s1l/4s4h",
X    "/$s$s/2s2a/5s5s/4s4a",
X    "/$s$s/2s2a/5s5s/4s4h",
X    "/$s$s/2s2a/5s5s/4s4a",
X    "/$s$s/2s2a/5s5s/4s4h",
X    "/$s$s/2s2a/1s1i",
X    "/$s$s/2s2a/1s1l",
X    "/$s$s/2s2a/1s1i/4s4a",
X    "/$s$s/2s2a/1s1i/4s4h",
X    "/$s$s/2s2a/1s1l/4s4a",
X    "/$s$s/2s2a/1s1l/4s4h",
X    "/$s$s/2s2a/4s4a",
X    "/$s$s/2s2a/4s4h",
X    "/$s$s/2s2a/4s4a",
X    "/$s$s/2s2a/4s4h",
X    "/$s$s/3s3e",
X    "/$s$s/3s3e/5s5s",
X    "/$s$s/3s3e/5s5s/1s1i",
X    "/$s$s/3s3e/5s5s/1s1l",
X    "/$s$s/3s3e/5s5s/1s1i/4s4a",
X    "/$s$s/3s3e/5s5s/1s1i/4s4h",
X    "/$s$s/3s3e/5s5s/1s1l/4s4a",
X    "/$s$s/3s3e/5s5s/1s1l/4s4h",
X    "/$s$s/3s3e/5s5s/4s4a",
X    "/$s$s/3s3e/5s5s/4s4h",
X    "/$s$s/3s3e/5s5s/4s4a",
X    "/$s$s/3s3e/5s5s/4s4h",
X    "/$s$s/3s3e/1s1i",
X    "/$s$s/3s3e/1s1l",
X    "/$s$s/3s3e/1s1i/4s4a",
X    "/$s$s/3s3e/1s1i/4s4h",
X    "/$s$s/3s3e/1s1l/4s4a",
X    "/$s$s/3s3e/1s1l/4s4h",
X    "/$s$s/3s3e/4s4a",
X    "/$s$s/3s3e/4s4h",
X    "/$s$s/3s3e/4s4a",
X    "/$s$s/3s3e/4s4h",
X    "/$s$s/5s5s",
X    "/$s$s/5s5s/1s1i",
X    "/$s$s/5s5s/1s1l",
X    "/$s$s/5s5s/1s1i/4s4a",
X    "/$s$s/5s5s/1s1i/4s4h",
X    "/$s$s/5s5s/1s1l/4s4a",
X    "/$s$s/5s5s/1s1l/4s4h",
X    "/$s$s/5s5s/4s4a",
X    "/$s$s/5s5s/4s4h",
X    "/$s$s/5s5s/4s4a",
X    "/$s$s/5s5s/4s4h",
X    "/$s$s/1s1i",
X    "/$s$s/1s1l",
X    "/$s$s/1s1i/4s4a",
X    "/$s$s/1s1i/4s4h",
X    "/$s$s/1s1l/4s4a",
X    "/$s$s/1s1l/4s4h",
X    "/$s$s/4s4a",
X    "/$s$s/4s4h",
X    "/$s$s/4s4a",
X    "/$s$s/4s4h",
X    "/0s0o",
X    "/0s0o/2s2a",
X    "/0s0o/2s2a/3s3e",
X    "/0s0o/2s2a/3s3e/5s5s",
X    "/0s0o/2s2a/3s3e/5s5s/1s1i",
X    "/0s0o/2s2a/3s3e/5s5s/1s1l",
X    "/0s0o/2s2a/3s3e/5s5s/1s1i/4s4a",
X    "/0s0o/2s2a/3s3e/5s5s/1s1i/4s4h",
X    "/0s0o/2s2a/3s3e/5s5s/1s1l/4s4a",
X    "/0s0o/2s2a/3s3e/5s5s/1s1l/4s4h",
X    "/0s0o/2s2a/3s3e/5s5s/4s4a",
X    "/0s0o/2s2a/3s3e/5s5s/4s4h",
X    "/0s0o/2s2a/3s3e/5s5s/4s4a",
X    "/0s0o/2s2a/3s3e/5s5s/4s4h",
X    "/0s0o/2s2a/3s3e/1s1i",
X    "/0s0o/2s2a/3s3e/1s1l",
X    "/0s0o/2s2a/3s3e/1s1i/4s4a",
X    "/0s0o/2s2a/3s3e/1s1i/4s4h",
X    "/0s0o/2s2a/3s3e/1s1l/4s4a",
X    "/0s0o/2s2a/3s3e/1s1l/4s4h",
X    "/0s0o/2s2a/3s3e/4s4a",
X    "/0s0o/2s2a/3s3e/4s4h",
X    "/0s0o/2s2a/3s3e/4s4a",
X    "/0s0o/2s2a/3s3e/4s4h",
X    "/0s0o/2s2a/5s5s",
X    "/0s0o/2s2a/5s5s/1s1i",
X    "/0s0o/2s2a/5s5s/1s1l",
X    "/0s0o/2s2a/5s5s/1s1i/4s4a",
X    "/0s0o/2s2a/5s5s/1s1i/4s4h",
X    "/0s0o/2s2a/5s5s/1s1l/4s4a",
X    "/0s0o/2s2a/5s5s/1s1l/4s4h",
X    "/0s0o/2s2a/5s5s/4s4a",
X    "/0s0o/2s2a/5s5s/4s4h",
X    "/0s0o/2s2a/5s5s/4s4a",
X    "/0s0o/2s2a/5s5s/4s4h",
X    "/0s0o/2s2a/1s1i",
X    "/0s0o/2s2a/1s1l",
X    "/0s0o/2s2a/1s1i/4s4a",
X    "/0s0o/2s2a/1s1i/4s4h",
X    "/0s0o/2s2a/1s1l/4s4a",
X    "/0s0o/2s2a/1s1l/4s4h",
X    "/0s0o/2s2a/4s4a",
X    "/0s0o/2s2a/4s4h",
X    "/0s0o/2s2a/4s4a",
X    "/0s0o/2s2a/4s4h",
X    "/0s0o/3s3e",
X    "/0s0o/3s3e/5s5s",
X    "/0s0o/3s3e/5s5s/1s1i",
X    "/0s0o/3s3e/5s5s/1s1l",
X    "/0s0o/3s3e/5s5s/1s1i/4s4a",
X    "/0s0o/3s3e/5s5s/1s1i/4s4h",
X    "/0s0o/3s3e/5s5s/1s1l/4s4a",
X    "/0s0o/3s3e/5s5s/1s1l/4s4h",
X    "/0s0o/3s3e/5s5s/4s4a",
X    "/0s0o/3s3e/5s5s/4s4h",
X    "/0s0o/3s3e/5s5s/4s4a",
X    "/0s0o/3s3e/5s5s/4s4h",
X    "/0s0o/3s3e/1s1i",
X    "/0s0o/3s3e/1s1l",
X    "/0s0o/3s3e/1s1i/4s4a",
X    "/0s0o/3s3e/1s1i/4s4h",
X    "/0s0o/3s3e/1s1l/4s4a",
X    "/0s0o/3s3e/1s1l/4s4h",
X    "/0s0o/3s3e/4s4a",
X    "/0s0o/3s3e/4s4h",
X    "/0s0o/3s3e/4s4a",
X    "/0s0o/3s3e/4s4h",
X    "/0s0o/5s5s",
X    "/0s0o/5s5s/1s1i",
X    "/0s0o/5s5s/1s1l",
X    "/0s0o/5s5s/1s1i/4s4a",
X    "/0s0o/5s5s/1s1i/4s4h",
X    "/0s0o/5s5s/1s1l/4s4a",
X    "/0s0o/5s5s/1s1l/4s4h",
X    "/0s0o/5s5s/4s4a",
X    "/0s0o/5s5s/4s4h",
X    "/0s0o/5s5s/4s4a",
X    "/0s0o/5s5s/4s4h",
X    "/0s0o/1s1i",
X    "/0s0o/1s1l",
X    "/0s0o/1s1i/4s4a",
X    "/0s0o/1s1i/4s4h",
X    "/0s0o/1s1l/4s4a",
X    "/0s0o/1s1l/4s4h",
X    "/0s0o/4s4a",
X    "/0s0o/4s4h",
X    "/0s0o/4s4a",
X    "/0s0o/4s4h",
X    "/2s2a",
X    "/2s2a/3s3e",
X    "/2s2a/3s3e/5s5s",
X    "/2s2a/3s3e/5s5s/1s1i",
X    "/2s2a/3s3e/5s5s/1s1l",
X    "/2s2a/3s3e/5s5s/1s1i/4s4a",
X    "/2s2a/3s3e/5s5s/1s1i/4s4h",
X    "/2s2a/3s3e/5s5s/1s1l/4s4a",
X    "/2s2a/3s3e/5s5s/1s1l/4s4h",
X    "/2s2a/3s3e/5s5s/4s4a",
X    "/2s2a/3s3e/5s5s/4s4h",
X    "/2s2a/3s3e/5s5s/4s4a",
X    "/2s2a/3s3e/5s5s/4s4h",
X    "/2s2a/3s3e/1s1i",
X    "/2s2a/3s3e/1s1l",
X    "/2s2a/3s3e/1s1i/4s4a",
X    "/2s2a/3s3e/1s1i/4s4h",
X    "/2s2a/3s3e/1s1l/4s4a",
X    "/2s2a/3s3e/1s1l/4s4h",
X    "/2s2a/3s3e/4s4a",
X    "/2s2a/3s3e/4s4h",
X    "/2s2a/3s3e/4s4a",
X    "/2s2a/3s3e/4s4h",
X    "/2s2a/5s5s",
X    "/2s2a/5s5s/1s1i",
X    "/2s2a/5s5s/1s1l",
X    "/2s2a/5s5s/1s1i/4s4a",
X    "/2s2a/5s5s/1s1i/4s4h",
X    "/2s2a/5s5s/1s1l/4s4a",
X    "/2s2a/5s5s/1s1l/4s4h",
X    "/2s2a/5s5s/4s4a",
X    "/2s2a/5s5s/4s4h",
X    "/2s2a/5s5s/4s4a",
X    "/2s2a/5s5s/4s4h",
X    "/2s2a/1s1i",
X    "/2s2a/1s1l",
X    "/2s2a/1s1i/4s4a",
X    "/2s2a/1s1i/4s4h",
X    "/2s2a/1s1l/4s4a",
X    "/2s2a/1s1l/4s4h",
X    "/2s2a/4s4a",
X    "/2s2a/4s4h",
X    "/2s2a/4s4a",
X    "/2s2a/4s4h",
X    "/3s3e",
X    "/3s3e/5s5s",
X    "/3s3e/5s5s/1s1i",
X    "/3s3e/5s5s/1s1l",
X    "/3s3e/5s5s/1s1i/4s4a",
X    "/3s3e/5s5s/1s1i/4s4h",
X    "/3s3e/5s5s/1s1l/4s4a",
X    "/3s3e/5s5s/1s1l/4s4h",
X    "/3s3e/5s5s/4s4a",
X    "/3s3e/5s5s/4s4h",
X    "/3s3e/5s5s/4s4a",
X    "/3s3e/5s5s/4s4h",
X    "/3s3e/1s1i",
X    "/3s3e/1s1l",
X    "/3s3e/1s1i/4s4a",
X    "/3s3e/1s1i/4s4h",
X    "/3s3e/1s1l/4s4a",
X    "/3s3e/1s1l/4s4h",
X    "/3s3e/4s4a",
X    "/3s3e/4s4h",
X    "/3s3e/4s4a",
X    "/3s3e/4s4h",
X    "/5s5s",
X    "/5s5s/1s1i",
X    "/5s5s/1s1l",
X    "/5s5s/1s1i/4s4a",
X    "/5s5s/1s1i/4s4h",
X    "/5s5s/1s1l/4s4a",
X    "/5s5s/1s1l/4s4h",
X    "/5s5s/4s4a",
X    "/5s5s/4s4h",
X    "/5s5s/4s4a",
X    "/5s5s/4s4h",
X    "/1s1i",
X    "/1s1l",
X    "/1s1i/4s4a",
X    "/1s1i/4s4h",
X    "/1s1l/4s4a",
X    "/1s1l/4s4h",
X    "/4s4a",
X    "/4s4h",
X    "/4s4a",
X    "/4s4h",
X
X    /* done */
X    (char *) 0
X};
X
Xstatic char *r_constructors[] = {
X    ":",
X
X#ifdef DEBUG2
X    (char *) 0,
X#endif
X
X    "r",
X    "d",
X    "f",
X    "dr",
X    "fr",
X    "rf",
X    (char *) 0
X};
X
Xstatic int
XGTry(rawtext, password)
X    char *rawtext;
X    char *password;
X{
X    int i;
X    size_t len;
X    char *mp;
X
X    /* use destructors to turn password into rawtext */
X    /* note use of Reverse() to save duplicating all rules */
X
X    len = strlen(password);
X
X    for (i = 0; r_destructors[i]; i++)
X    {
X	if (!(mp = Mangle(password, r_destructors[i])))
X	{
X	    continue;
X	}
X
X#ifdef DEBUG
X	printf("%-16s = %-16s (destruct %s)\n", mp, rawtext, r_destructors[i]);
X#endif
X
X	if (!strncmp(mp, rawtext, len))
X	{
X	    return (1);
X	}
X
X#ifdef DEBUG
X	printf("%-16s = %-16s (destruct %s reversed)\n", Reverse(mp), rawtext, r_destructors[i]);
X#endif
X
X	if (!strncmp(Reverse(mp), rawtext, len))
X	{
X	    return (1);
X	}
X    }
X
X    for (i = 0; r_constructors[i]; i++)
X    {
X	if (!(mp = Mangle(rawtext, r_constructors[i])))
X	{
X	    continue;
X	}
X
X#ifdef DEBUG
X	printf("%-16s = %-16s (construct %s)\n", mp, password, r_constructors[i]);
X#endif
X
X	if (!strncmp(mp, password, len))
X	{
X	    return (1);
X	}
X    }
X
X    return (0);
X}
X
Xstatic char *
XFascistUname(password, uid, pw_name)
X    char *password;
X    uid_t uid;
X    char *pw_name;
X{
X    struct passwd *pwp;
X    char tbuffer[STRINGSIZE];
X
X    if (!pw_name)
X    {
X	if (!(pwp = getpwuid(uid)))
X	{
X	    return ("you are not registered in the password file");
X	}
X	strncpy(tbuffer, pwp->pw_name, STRINGSIZE);
X    }
X    else
X    {
X	strncpy(tbuffer, pw_name, STRINGSIZE);
X    }
X
X    /* lets get really paranoid and assume a dangerously long pw_name entry */
X
X    tbuffer[STRINGSIZE-1] = '\0';
X    if (GTry(tbuffer, password))
X    {
X	return ("it is based on your username");
X    }
X
X    return ((char *) 0);
X}
X
Xstatic char *
XFascistGecos(password, uid, pw_gecos)
X    char *password;
X    uid_t uid;
X    char *pw_gecos;
X{
X    int i;
X    int j;
X    int wc;
X    char *ptr;
X    int gwords;
X    struct passwd *pwp;
X    char gbuffer[STRINGSIZE];
X    char tbuffer[STRINGSIZE];
X    char *uwords[STRINGSIZE];
X    char longbuffer[STRINGSIZE * 2];
X
X    if (!pw_gecos)
X    {
X	if (!(pwp = getpwuid(uid)))
X	{
X	    return ("you are not registered in the password file");
X	}
X	strncpy(tbuffer, pwp->pw_gecos, STRINGSIZE);
X    }
X    else
X    {
X	strncpy(tbuffer, pw_gecos, STRINGSIZE);
X    }
X
X    /* it never used to be that you got pw_gecos strings > 1024 chars, but now... */
X
X    tbuffer[STRINGSIZE-1] = '\0';
X    strcpy(gbuffer, Lowercase(tbuffer));
X
X    wc = 0;
X    ptr = gbuffer;
X    gwords = 0;
X    uwords[0] = (char *)0;
X
X    while (*ptr)
X    {
X	while (*ptr && ISSKIP(*ptr))
X	{
X	    ptr++;
X	}
X
X	if (ptr != gbuffer)
X	{
X	    ptr[-1] = '\0';
X	}
X
X	gwords++;
X	uwords[wc++] = ptr;
X
X	if (wc == STRINGSIZE)
X	{
X	    uwords[--wc] = (char *) 0;  /* to hell with it */
X	    break;
X	} else
X	{
X	    uwords[wc] = (char *) 0;
X	}
X
X	while (*ptr && !ISSKIP(*ptr))
X	{
X	    ptr++;
X	}
X
X	if (*ptr)
X	{
X	    *(ptr++) = '\0';
X	}
X    }
X
X#ifdef DEBUG
X    for (i = 0; uwords[i]; i++)
X    {
X	printf("gecosword %s\n", uwords[i]);
X    }
X#endif
X
X    for (i = 0; uwords[i]; i++)
X    {
X	if (GTry(uwords[i], password))
X	{
X	    return ("it is based upon your password entry");
X	}
X    }
X
X    /* since uwords are taken from gbuffer, no uword can be longer than gbuffer */
X
X    for (j = 1; (j < gwords) && uwords[j]; j++)
X    {
X	for (i = 0; i < j; i++)
X	{
X	    strcpy(longbuffer, uwords[i]);
X	    strcat(longbuffer, uwords[j]);
X
X	    if (GTry(longbuffer, password))
X	    {
X		return ("it is derived from your password entry");
X	    }
X
X	    strcpy(longbuffer, uwords[j]);
X	    strcat(longbuffer, uwords[i]);
X
X	    if (GTry(longbuffer, password))
X	    {
X		return ("it's derived from your password entry");
X	    }
X
X	    longbuffer[0] = uwords[i][0];
X	    longbuffer[1] = '\0';
X	    strcat(longbuffer, uwords[j]);
X
X	    if (GTry(longbuffer, password))
X	    {
X		return ("it is derivable from your password entry");
X	    }
X
X	    longbuffer[0] = uwords[j][0];
X	    longbuffer[1] = '\0';
X	    strcat(longbuffer, uwords[i]);
X
X	    if (GTry(longbuffer, password))
X	    {
X		return ("it's derivable from your password entry");
X	    }
X	}
X    }
X
X    return ((char *) 0);
X}
X
Xchar *
XFascistLook(pwp, instring, pw_name, pw_gecos)
X    PWDICT *pwp;
X    char *instring;
X    char *pw_name;
X    char *pw_gecos;
X{
X    int i;
X    char *ptr;
X    char *jptr;
X    char junk[STRINGSIZE];
X    char *password;
X    char rpassword[STRINGSIZE];
X    int32 notfound;
X
X    notfound = PW_WORDS(pwp);
X    /* already truncated if from FascistCheck() */
X    /* but pretend it wasn't ... */
X    strncpy(rpassword, instring, TRUNCSTRINGSIZE);
X    rpassword[TRUNCSTRINGSIZE - 1] = '\0';
X    password = rpassword;
X
X    if (strlen(password) < 4)
X    {
X	return ("it's WAY too short");
X    }
X
X    if (strlen(password) < MINLEN)
X    {
X	return ("it is too short");
X    }
X
X    jptr = junk;
X    *jptr = '\0';
X
X    for (i = 0; i < STRINGSIZE && password[i]; i++)
X    {
X	if (!strchr(junk, password[i]))
X	{
X	    *(jptr++) = password[i];
X	    *jptr = '\0';
X	}
X    }
X
X    if (strlen(junk) < MINDIFF)
X    {
X	return ("it does not contain enough DIFFERENT characters");
X    }
X
X    strcpy(password, Lowercase(password));
X
X    Trim(password);
X
X    while (*password && isspace(*password))
X    {
X	password++;
X    }
X
X    if (!*password)
X    {
X	return ("it is all whitespace");
X    }
X
X    i = 0;
X    ptr = password;
X    while (ptr[0] && ptr[1])
X    {
X	if ((ptr[1] == (ptr[0] + 1)) || (ptr[1] == (ptr[0] - 1)))
X	{
X	    i++;
X	}
X	ptr++;
X    }
X
X    if (i > MAXSTEP)
X    {
X	return ("it is too simplistic/systematic");
X    }
X
X    if (PMatch("aadddddda", password))  /* smirk */
X    {
X	return ("it looks like a National Insurance number.");
X    }
X
X    if ((ptr = FascistUname(password, getuid(), pw_name)))
X    {
X	return (ptr);
X    }
X
X    if ((ptr = FascistGecos(password, getuid(), pw_gecos)))
X    {
X	return (ptr);
X    }
X
X    /* it should be safe to use Mangle with its reliance on STRINGSIZE
X       since password cannot be longer than TRUNCSTRINGSIZE;
X       nonetheless this is not an elegant solution */
X
X    for (i = 0; r_destructors[i]; i++)
X    {
X	char *a;
X
X	if (!(a = Mangle(password, r_destructors[i])))
X	{
X	    continue;
X	}
X
X#ifdef DEBUG
X	printf("%-16s (dict)\n", a);
X#endif
X
X	if (FindPW(pwp, a) != notfound)
X	{
X	    return ("it is based on a dictionary word");
X	}
X    }
X
X    strcpy(password, Reverse(password));
X
X    for (i = 0; r_destructors[i]; i++)
X    {
X	char *a;
X
X	if (!(a = Mangle(password, r_destructors[i])))
X	{
X	    continue;
X	}
X#ifdef DEBUG
X	printf("%-16s (reversed dict)\n", a);
X#endif
X	if (FindPW(pwp, a) != notfound)
X	{
X	    return ("it is based on a (reversed) dictionary word");
X	}
X    }
X
X    return ((char *) 0);
X}
X
Xchar *
XFascistCheck(password, path, pw_name, pw_gecos)
X    char *password;
X    char *path;
X    char *pw_name;
X    char *pw_gecos;
X{
X    static char lastpath[STRINGSIZE];
X    static PWDICT *pwp;
X    char pwtrunced[STRINGSIZE];
X
X    /* security problem: assume we may have been given a really long
X       password (buffer attack) and so truncate it to a workable size;
X       try to define workable size as something from which we cannot
X       extend a buffer beyond its limits in the rest of the code */
X
X    strncpy(pwtrunced, password, TRUNCSTRINGSIZE);
X    pwtrunced[TRUNCSTRINGSIZE - 1] = '\0'; /* enforce */
X
X    /* perhaps someone should put something here to check if password
X       is really long and syslog() a message denoting buffer attacks?  */
X
X    if (pwp && strncmp(lastpath, path, STRINGSIZE))
X    {
X	PWClose(pwp);
X	pwp = (PWDICT *)0;
X    }
X
X    if (!pwp)
X    {
X	if (!(pwp = PWOpen(path, "r")))
X	{
X	    perror("PWOpen");
X	    exit(-1);
X	}
X	strncpy(lastpath, path, STRINGSIZE);
X    }
X
X    return (FascistLook(pwp, pwtrunced, pw_name, pw_gecos));
X}
END-of-lib/libcrack/fascist.c
echo x - lib/libcrack/genrules.pl
sed 's/^X//' >lib/libcrack/genrules.pl << 'END-of-lib/libcrack/genrules.pl'
X#!/usr/local/bin/perl
X
X###
X# This program is copyright Alec Muffett 1997. The author disclaims all
X# responsibility or liability with respect to it's usage or its effect
X# upon hardware or computer systems, and maintains copyright as set out
X# in the "LICENCE" document which accompanies distributions of Crack v5.0
X# and upwards.
X###
X
X%perms = ();
X
Xsub Permute
X{
X    my $depth = shift;
X    my $i;
X
X    if ($depth == 0)
X    {
X	@stack = ();
X    }
X    for ($i = 0; $i <= $#set; $i++)
X    {
X	$stack[$depth] = $set[$i];
X
X	if ($depth == $#set)
X	{
X	    %output = ();
X	    foreach (@stack) 
X	    { 
X		$output{$_}++; 
X	    }
X	    $perm = join(" ", sort(keys(%output)));
X	    $perms{$perm}++;
X	}
X	else
X	{
X	    &Permute($depth + 1);
X	}
X    }
X}
X
X@maps = ([ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4a' ],
X	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4h' ],
X	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4a' ],
X	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4h' ]);
X
X@set = (0 .. 5);
X
X# why be elegant when you can use brute force?  moreover, it's easier
X# to think brute-force at 1am in the morning, and leaves you with time
X# for coffee...
X
X&Permute(0);
X
Xforeach $perm (sort(keys(%perms)))
X{
X    foreach $aref (@maps)
X    {
X	foreach $i (split(" ", $perm))
X	{
X	    print ${$aref}[$i];
X	}
X	print "\n";
X    }
X}
X
Xexit 0;
END-of-lib/libcrack/genrules.pl
echo x - lib/libcrack/packlib.c
sed 's/^X//' >lib/libcrack/packlib.c << 'END-of-lib/libcrack/packlib.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X
X#ifndef lint
X#if 0
Xstatic char vers_id[] = "packlib.c : v2.3p2 Alec Muffett 18 May 1993";
X#else
X__RCSID("$NetBSD$");
X#endif
X#endif
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <string.h>
X#include <ctype.h>
X#include <pwd.h>
X
X#include "crack.h"
X
XPWDICT *
XPWOpen(prefix, mode)
X    char *prefix;
X    char *mode;
X{
X    static PWDICT pdesc;
X    char iname[STRINGSIZE];
X    char dname[STRINGSIZE];
X    char wname[STRINGSIZE];
X    FILE *dfp;
X    FILE *ifp;
X    FILE *wfp;
X
X    if (pdesc.header.pih_magic == PIH_MAGIC)
X    {
X	fprintf(stderr, "%s: another dictionary already open\n", prefix);
X	return ((PWDICT *) 0);
X    }
X
X    memset(&pdesc, '\0', sizeof(pdesc));
X
X    sprintf(iname, "%s.pwi", prefix);
X    sprintf(dname, "%s.pwd", prefix);
X    sprintf(wname, "%s.hwm", prefix);
X
X    if (!(pdesc.dfp = fopen(dname, mode)))
X    {
X	perror(dname);
X	return ((PWDICT *) 0);
X    }
X
X    if (!(pdesc.ifp = fopen(iname, mode)))
X    {
X	fclose(pdesc.dfp);
X	perror(iname);
X	return ((PWDICT *) 0);
X    }
X
X    if ((pdesc.wfp = fopen(wname, mode)))
X    {
X	pdesc.flags |= PFOR_USEHWMS;
X    }
X
X    ifp = pdesc.ifp;
X    dfp = pdesc.dfp;
X    wfp = pdesc.wfp;
X
X    if (mode[0] == 'w')
X    {
X	pdesc.flags |= PFOR_WRITE;
X	pdesc.header.pih_magic = PIH_MAGIC;
X	pdesc.header.pih_blocklen = NUMWORDS;
X	pdesc.header.pih_numwords = 0;
X
X	fwrite((char *) &pdesc.header, sizeof(pdesc.header), 1, ifp);
X    } else
X    {
X	pdesc.flags &= ~PFOR_WRITE;
X
X	if (!fread((char *) &pdesc.header, sizeof(pdesc.header), 1, ifp))
X	{
X	    fprintf(stderr, "%s: error reading header\n", prefix);
X
X	    pdesc.header.pih_magic = 0;
X	    fclose(ifp);
X	    fclose(dfp);
X	    return ((PWDICT *) 0);
X	}
X
X	if (pdesc.header.pih_magic != PIH_MAGIC)
X	{
X	    fprintf(stderr, "%s: magic mismatch\n", prefix);
X
X	    pdesc.header.pih_magic = 0;
X	    fclose(ifp);
X	    fclose(dfp);
X	    return ((PWDICT *) 0);
X	}
X
X	if (pdesc.header.pih_blocklen != NUMWORDS)
X	{
X	    fprintf(stderr, "%s: size mismatch\n", prefix);
X
X	    pdesc.header.pih_magic = 0;
X	    fclose(ifp);
X	    fclose(dfp);
X	    return ((PWDICT *) 0);
X	}
X
X	if (pdesc.flags & PFOR_USEHWMS)
X	{
X	    if (fread(pdesc.hwms, 1, sizeof(pdesc.hwms), wfp) != sizeof(pdesc.hwms))
X	    {
X		pdesc.flags &= ~PFOR_USEHWMS;
X	    }
X	}
X    }
X
X    return (&pdesc);
X}
X
Xint
XPWClose(pwp)
X    PWDICT *pwp;
X{
X    if (pwp->header.pih_magic != PIH_MAGIC)
X    {
X	fprintf(stderr, "PWClose: close magic mismatch\n");
X	return (-1);
X    }
X
X    if (pwp->flags & PFOR_WRITE)
X    {
X	pwp->flags |= PFOR_FLUSH;
X	PutPW(pwp, (char *) 0);	/* flush last index if necess */
X
X	if (fseek(pwp->ifp, 0L, 0))
X	{
X	    fprintf(stderr, "index magic fseek failed\n");
X	    return (-1);
X	}
X
X	if (!fwrite((char *) &pwp->header, sizeof(pwp->header), 1, pwp->ifp))
X	{
X	    fprintf(stderr, "index magic fwrite failed\n");
X	    return (-1);
X	}
X
X	if (pwp->flags & PFOR_USEHWMS)
X	{
X	    int i;
X	    for (i=1; i<=0xff; i++)
X	    {
X	    	if (!pwp->hwms[i])
X	    	{
X	    	    pwp->hwms[i] = pwp->hwms[i-1];
X	    	}
X#ifdef DEBUG
X	    	printf("hwm[%02x] = %d\n", i, pwp->hwms[i]);
X#endif
X	    }
X	    fwrite(pwp->hwms, 1, sizeof(pwp->hwms), pwp->wfp);
X	}
X    }
X
X    fclose(pwp->ifp);
X    fclose(pwp->dfp);
X
X    pwp->header.pih_magic = 0;
X
X    return (0);
X}
X
Xint
XPutPW(pwp, string)
X    PWDICT *pwp;
X    char *string;
X{
X    if (!(pwp->flags & PFOR_WRITE))
X    {
X	return (-1);
X    }
X
X    if (string)
X    {
X	strncpy(pwp->data[pwp->count], string, MAXWORDLEN);
X	pwp->data[pwp->count][MAXWORDLEN - 1] = '\0';
X
X	pwp->hwms[string[0] & 0xff]= pwp->header.pih_numwords;
X
X	++(pwp->count);
X	++(pwp->header.pih_numwords);
X
X    } else if (!(pwp->flags & PFOR_FLUSH))
X    {
X	return (-1);
X    }
X
X    if ((pwp->flags & PFOR_FLUSH) || !(pwp->count % NUMWORDS))
X    {
X	int i;
X	int32 datum;
X	register char *ostr;
X
X	datum = (int32) ftell(pwp->dfp);
X
X	fwrite((char *) &datum, sizeof(datum), 1, pwp->ifp);
X
X	fputs(pwp->data[0], pwp->dfp);
X	putc(0, pwp->dfp);
X
X	ostr = pwp->data[0];
X
X	for (i = 1; i < NUMWORDS; i++)
X	{
X	    register int j;
X	    register char *nstr;
X	    nstr = pwp->data[i];
X
X	    if (nstr[0])
X	    {
X		for (j = 0; ostr[j] && nstr[j] && (ostr[j] == nstr[j]); j++);
X		putc(j & 0xff, pwp->dfp);
X		fputs(nstr + j, pwp->dfp);
X	    }
X	    putc(0, pwp->dfp);
X
X	    ostr = nstr;
X	}
X
X	memset(pwp->data, '\0', sizeof(pwp->data));
X	pwp->count = 0;
X    }
X    return (0);
X}
X
Xchar *
XGetPW(pwp, number)
X    PWDICT *pwp;
X    int32 number;
X{
X    int32 datum;
X    register int i;
X    register char *ostr;
X    register char *nstr;
X    register char *bptr;
X    char buffer[NUMWORDS * MAXWORDLEN];
X    static char data[NUMWORDS][MAXWORDLEN];
X    static int32 prevblock = 0xffffffff;
X    int32 thisblock;
X
X    thisblock = number / NUMWORDS;
X
X    if (prevblock == thisblock)
X    {
X	return (data[number % NUMWORDS]);
X    }
X
X    if (fseek(pwp->ifp, sizeof(struct pi_header) + (thisblock * sizeof(int32)), 0))
X    {
X	perror("(index fseek failed)");
X	return ((char *) 0);
X    }
X
X    if (!fread((char *) &datum, sizeof(datum), 1, pwp->ifp))
X    {
X	perror("(index fread failed)");
X	return ((char *) 0);
X    }
X
X    if (fseek(pwp->dfp, datum, 0))
X    {
X	perror("(data fseek failed)");
X	return ((char *) 0);
X    }
X
X    if (!fread(buffer, 1, sizeof(buffer), pwp->dfp))
X    {
X	perror("(data fread failed)");
X	return ((char *) 0);
X    }
X
X    prevblock = thisblock;
X
X    bptr = buffer;
X
X    for (ostr = data[0]; (*(ostr++) = *(bptr++)); /* nothing */ )
X    {
X	;
X    }
X
X    ostr = data[0];
X
X    for (i = 1; i < NUMWORDS; i++)
X    {
X	nstr = data[i];
X	strcpy(nstr, ostr);
X
X	ostr = nstr + *(bptr++);
X	while ((*(ostr++) = *(bptr++)))
X	{
X	   ;
X	}
X
X	ostr = nstr;
X    }
X
X    return (data[number % NUMWORDS]);
X}
X
Xint32
XFindPW(pwp, string)
X    PWDICT *pwp;
X    char *string;
X{
X    register int32 lwm;
X    register int32 hwm;
X    register int32 middle;
X    register char *this;
X    int idx;
X
X    if (pwp->flags & PFOR_USEHWMS)
X    {
X	idx = string[0] & 0xff;
X    	lwm = idx ? pwp->hwms[idx - 1] : 0;
X    	hwm = pwp->hwms[idx];
X    } else
X    {
X    	lwm = 0;
X    	hwm = PW_WORDS(pwp) - 1;
X    }
X
X#ifdef DEBUG
X    printf("---- %lu, %lu ----\n", lwm, hwm);
X#endif
X
X    for (;;)
X    {
X	int cmp;
X
X#ifdef DEBUG
X	printf("%lu, %lu\n", lwm, hwm);
X#endif
X
X	middle = lwm + ((hwm - lwm + 1) / 2);
X
X	if (middle == hwm)
X	{
X	    break;
X	}
X
X	this = GetPW(pwp, middle);
X	cmp = strcmp(string, this);		/* INLINE ? */
X
X	if (cmp < 0)
X	{
X	    hwm = middle;
X	} else if (cmp > 0)
X	{
X	    lwm = middle;
X	} else
X	{
X	    return (middle);
X	}
X    }
X
X    return (PW_WORDS(pwp));
X}
END-of-lib/libcrack/packlib.c
echo x - lib/libcrack/rules.c
sed 's/^X//' >lib/libcrack/rules.c << 'END-of-lib/libcrack/rules.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X
X#ifndef lint
X#if 0
Xstatic char vers_id[] = "rules.c : v5.0p3 Alec Muffett 20 May 1993";
X#else
X__RCSID("$NetBSD$");
X#endif
X#endif
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <string.h>
X#include <ctype.h>
X#include <pwd.h>
X
X#include "crack.h"
X
X#ifdef IN_CRACKLIB
X# define Debug(level, stuff)	fprintf stuff
X#endif
X
X#define RULE_NOOP	':'
X#define RULE_PREPEND	'^'
X#define RULE_APPEND	'$'
X#define RULE_REVERSE	'r'
X#define RULE_UPPERCASE	'u'
X#define RULE_LOWERCASE	'l'
X#define RULE_PLURALISE	'p'
X#define RULE_CAPITALISE	'c'
X#define RULE_DUPLICATE	'd'
X#define RULE_REFLECT	'f'
X#define RULE_SUBSTITUTE	's'
X#define RULE_MATCH	'/'
X#define RULE_NOT	'!'
X#define RULE_LT		'<'
X#define RULE_GT		'>'
X#define RULE_EXTRACT	'x'
X#define RULE_OVERSTRIKE	'o'
X#define RULE_INSERT	'i'
X#define RULE_EQUALS	'='
X#define RULE_PURGE	'@'
X#define RULE_CLASS	'?'	/* class rule? socialist ethic in cracker? */
X
X#define RULE_DFIRST	'['
X#define RULE_DLAST	']'
X#define RULE_MFIRST	'('
X#define RULE_MLAST	')'
X
Xstatic int MatchClass __P((int, int));
Xstatic char *PolyStrchr __P((char *, int));
Xstatic char *PolySubst __P((char *, int, int));
Xstatic char *PolyPurge __P((char *, int));
Xstatic int Char2Int __P((int));
X
Xint
XSuffix(myword, suffix)
X    char *myword;
X    char *suffix;
X{
X    register int i;
X    register int j;
X    i = strlen(myword);
X    j = strlen(suffix);
X
X    if (i > j)
X    {
X	return (STRCMP((myword + i - j), suffix));
X    } else
X    {
X	return (-1);
X    }
X}
X
Xchar *
XReverse(str)			/* return a pointer to a reversal */
X    register char *str;
X{
X    register int i;
X    register int j;
X    static char area[STRINGSIZE];
X    j = i = strlen(str);
X    while (*str)
X    {
X	area[--i] = *str++;
X    }
X    area[j] = '\0';
X    return (area);
X}
X
Xchar *
XUppercase(str)			/* return a pointer to an uppercase */
X    register char *str;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*str)
X    {
X	*(ptr++) = CRACK_TOUPPER(*str);
X	str++;
X    }
X    *ptr = '\0';
X
X    return (area);
X}
X
Xchar *
XLowercase(str)			/* return a pointer to an lowercase */
X    register char *str;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*str)
X    {
X	*(ptr++) = CRACK_TOLOWER(*str);
X	str++;
X    }
X    *ptr = '\0';
X
X    return (area);
X}
X
Xchar *
XCapitalise(str)			/* return a pointer to an capitalised */
X    register char *str;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X
X    while (*str)
X    {
X	*(ptr++) = CRACK_TOLOWER(*str);
X	str++;
X    }
X
X    *ptr = '\0';
X    area[0] = CRACK_TOUPPER(area[0]);
X    return (area);
X}
X
Xchar *
XPluralise(string)		/* returns a pointer to a plural */
X    register char *string;
X{
X    register int length;
X    static char area[STRINGSIZE];
X    length = strlen(string);
X    strcpy(area, string);
X
X    if (!Suffix(string, "ch") ||
X	!Suffix(string, "ex") ||
X	!Suffix(string, "ix") ||
X	!Suffix(string, "sh") ||
X	!Suffix(string, "ss"))
X    {
X	/* bench -> benches */
X	strcat(area, "es");
X    } else if (length > 2 && string[length - 1] == 'y')
X    {
X	if (strchr("aeiou", string[length - 2]))
X	{
X	    /* alloy -> alloys */
X	    strcat(area, "s");
X	} else
X	{
X	    /* gully -> gullies */
X	    strcpy(area + length - 1, "ies");
X	}
X    } else if (string[length - 1] == 's')
X    {
X	/* bias -> biases */
X	strcat(area, "es");
X    } else
X    {
X	/* catchall */
X	strcat(area, "s");
X    }
X
X    return (area);
X}
X
Xchar *
XSubstitute(string, old, new)	/* returns pointer to a swapped about copy */
X    register char *string;
X    register char old;
X    register char new;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*string)
X    {
X	*(ptr++) = (*string == old ? new : *string);
X	string++;
X    }
X    *ptr = '\0';
X    return (area);
X}
X
Xchar *
XPurge(string, target)		/* returns pointer to a purged copy */
X    char *string;
X    char target;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*string)
X    {
X	if (*string != target)
X	{
X	    *(ptr++) = *string;
X	}
X	string++;
X    }
X    *ptr = '\0';
X    return (area);
X}
X/* -------- CHARACTER CLASSES START HERE -------- */
X
X/*
X * this function takes two inputs, a class identifier and a character, and
X * returns non-null if the given character is a member of the class, based
X * upon restrictions set out below
X */
X
Xstatic int
XMatchClass(class, input)
X    register char class;
X    register char input;
X{
X    register char c;
X    register int retval;
X    retval = 0;
X
X    switch (class)
X    {
X	/* ESCAPE */
X
X    case '?':			/* ?? -> ? */
X	if (input == '?')
X	{
X	    retval = 1;
X	}
X	break;
X
X	/* ILLOGICAL GROUPINGS (ie: not in ctype.h) */
X
X    case 'V':
X    case 'v':			/* vowels */
X	c = CRACK_TOLOWER(input);
X	if (strchr("aeiou", c))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'C':
X    case 'c':			/* consonants */
X	c = CRACK_TOLOWER(input);
X	if (strchr("bcdfghjklmnpqrstvwxyz", c))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'W':
X    case 'w':			/* whitespace */
X	if (strchr("\t ", input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'P':
X    case 'p':			/* punctuation */
X	if (strchr(".`,:;'!?\"", input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'S':
X    case 's':			/* symbols */
X	if (strchr("$%%^&*()-_+=|\\[]{}#@/~", input))
X	{
X	    retval = 1;
X	}
X	break;
X
X	/* LOGICAL GROUPINGS */
X
X    case 'L':
X    case 'l':			/* lowercase */
X	if (islower(input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'U':
X    case 'u':			/* uppercase */
X	if (isupper(input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'A':
X    case 'a':			/* alphabetic */
X	if (isalpha(input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'X':
X    case 'x':			/* alphanumeric */
X	if (isalnum(input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    case 'D':
X    case 'd':			/* digits */
X	if (isdigit(input))
X	{
X	    retval = 1;
X	}
X	break;
X
X    default:
X	Debug(1, (stderr, "MatchClass: unknown class %c\n", class));
X	return (0);
X	/* NOTREACHED */
X    }
X
X    if (isupper(class))
X    {
X	return (!retval);
X    }
X    return (retval);
X}
X
Xstatic char *
XPolyStrchr(string, class)
X    register char *string;
X    register int class;
X{
X    while (*string)
X    {
X	if (MatchClass(class, *string))
X	{
X	    return (string);
X	}
X	string++;
X    }
X    return ((char *) 0);
X}
X
Xstatic char *
XPolySubst(string, class, new)	/* returns pointer to a swapped about copy */
X    register char *string;
X    register int class;
X    register int new;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*string)
X    {
X	*(ptr++) = (MatchClass(class, *string) ? new : *string);
X	string++;
X    }
X    *ptr = '\0';
X    return (area);
X}
X
Xstatic char *
XPolyPurge(string, class)	/* returns pointer to a purged copy */
X    register char *string;
X    register int class;
X{
X    register char *ptr;
X    static char area[STRINGSIZE];
X    ptr = area;
X    while (*string)
X    {
X	if (!MatchClass(class, *string))
X	{
X	    *(ptr++) = *string;
X	}
X	string++;
X    }
X    *ptr = '\0';
X    return (area);
X}
X/* -------- BACK TO NORMALITY -------- */
X
Xstatic int
XChar2Int(character)
X    int character;
X{
X    if (isdigit(character))
X    {
X	return (character - '0');
X    } else if (islower(character))
X    {
X	return (character - 'a' + 10);
X    } else if (isupper(character))
X    {
X	return (character - 'A' + 10);
X    }
X    return (-1);
X}
X
Xchar *
XMangle(input, control)		/* returns a pointer to a controlled Mangle */
X    char *input;
X    char *control;
X{
X    int limit;
X    register char *ptr;
X    static char area[STRINGSIZE];
X    char area2[STRINGSIZE];
X    area[0] = '\0';
X    strcpy(area, input);
X
X    for (ptr = control; *ptr; ptr++)
X    {
X	switch (*ptr)
X	{
X	case RULE_NOOP:
X	    break;
X	case RULE_REVERSE:
X	    strcpy(area, Reverse(area));
X	    break;
X	case RULE_UPPERCASE:
X	    strcpy(area, Uppercase(area));
X	    break;
X	case RULE_LOWERCASE:
X	    strcpy(area, Lowercase(area));
X	    break;
X	case RULE_CAPITALISE:
X	    strcpy(area, Capitalise(area));
X	    break;
X	case RULE_PLURALISE:
X	    strcpy(area, Pluralise(area));
X	    break;
X	case RULE_REFLECT:
X	    strcat(area, Reverse(area));
X	    break;
X	case RULE_DUPLICATE:
X	    strcpy(area2, area);
X	    strcat(area, area2);
X	    break;
X	case RULE_GT:
X	    if (!ptr[1])
X	    {
X		Debug(1, (stderr, "Mangle: '>' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		limit = Char2Int(*(++ptr));
X		if (limit < 0)
X		{
X		    Debug(1, (stderr, "Mangle: '>' weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		}
X		if (strlen(area) <= limit)
X		{
X		    return ((char *) 0);
X		}
X	    }
X	    break;
X	case RULE_LT:
X	    if (!ptr[1])
X	    {
X		Debug(1, (stderr, "Mangle: '<' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		limit = Char2Int(*(++ptr));
X		if (limit < 0)
X		{
X		    Debug(1, (stderr, "Mangle: '<' weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		}
X		if (strlen(area) >= limit)
X		{
X		    return ((char *) 0);
X		}
X	    }
X	    break;
X	case RULE_PREPEND:
X	    if (!ptr[1])
X	    {
X		Debug(1, (stderr, "Mangle: prepend missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		area2[0] = *(++ptr);
X		strcpy(area2 + 1, area);
X		strcpy(area, area2);
X	    }
X	    break;
X	case RULE_APPEND:
X	    if (!ptr[1])
X	    {
X		Debug(1, (stderr, "Mangle: append missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register char *string;
X		string = area;
X		while (*(string++));
X		string[-1] = *(++ptr);
X		*string = '\0';
X	    }
X	    break;
X	case RULE_EXTRACT:
X	    if (!ptr[1] || !ptr[2])
X	    {
X		Debug(1, (stderr, "Mangle: extract missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register int i;
X		int start;
X		int length;
X		start = Char2Int(*(++ptr));
X		length = Char2Int(*(++ptr));
X		if (start < 0 || length < 0)
X		{
X		    Debug(1, (stderr, "Mangle: extract: weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		}
X		strcpy(area2, area);
X		for (i = 0; length-- && area2[start + i]; i++)
X		{
X		    area[i] = area2[start + i];
X		}
X		/* cant use strncpy() - no trailing NUL */
X		area[i] = '\0';
X	    }
X	    break;
X	case RULE_OVERSTRIKE:
X	    if (!ptr[1] || !ptr[2])
X	    {
X		Debug(1, (stderr, "Mangle: overstrike missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register int i;
X		i = Char2Int(*(++ptr));
X		if (i < 0)
X		{
X		    Debug(1, (stderr, "Mangle: overstrike weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		} else
X		{
X		    ++ptr;
X		    if (area[i])
X		    {
X			area[i] = *ptr;
X		    }
X		}
X	    }
X	    break;
X	case RULE_INSERT:
X	    if (!ptr[1] || !ptr[2])
X	    {
X		Debug(1, (stderr, "Mangle: insert missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register int i;
X		register char *p1;
X		register char *p2;
X		i = Char2Int(*(++ptr));
X		if (i < 0)
X		{
X		    Debug(1, (stderr, "Mangle: insert weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		}
X		p1 = area;
X		p2 = area2;
X		while (i && *p1)
X		{
X		    i--;
X		    *(p2++) = *(p1++);
X		}
X		*(p2++) = *(++ptr);
X		strcpy(p2, p1);
X		strcpy(area, area2);
X	    }
X	    break;
X	    /* THE FOLLOWING RULES REQUIRE CLASS MATCHING */
X
X	case RULE_PURGE:	/* @x or @?c */
X	    if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
X	    {
X		Debug(1, (stderr, "Mangle: delete missing arguments in '%s'\n", control));
X		return ((char *) 0);
X	    } else if (ptr[1] != RULE_CLASS)
X	    {
X		strcpy(area, Purge(area, *(++ptr)));
X	    } else
X	    {
X		strcpy(area, PolyPurge(area, ptr[2]));
X		ptr += 2;
X	    }
X	    break;
X	case RULE_SUBSTITUTE:	/* sxy || s?cy */
X	    if (!ptr[1] || !ptr[2] || (ptr[1] == RULE_CLASS && !ptr[3]))
X	    {
X		Debug(1, (stderr, "Mangle: subst missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else if (ptr[1] != RULE_CLASS)
X	    {
X		strcpy(area, Substitute(area, ptr[1], ptr[2]));
X		ptr += 2;
X	    } else
X	    {
X		strcpy(area, PolySubst(area, ptr[2], ptr[3]));
X		ptr += 3;
X	    }
X	    break;
X	case RULE_MATCH:	/* /x || /?c */
X	    if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
X	    {
X		Debug(1, (stderr, "Mangle: '/' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else if (ptr[1] != RULE_CLASS)
X	    {
X		if (!strchr(area, *(++ptr)))
X		{
X		    return ((char *) 0);
X		}
X	    } else
X	    {
X		if (!PolyStrchr(area, ptr[2]))
X		{
X		    return ((char *) 0);
X		}
X		ptr += 2;
X	    }
X	    break;
X	case RULE_NOT:		/* !x || !?c */
X	    if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
X	    {
X		Debug(1, (stderr, "Mangle: '!' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else if (ptr[1] != RULE_CLASS)
X	    {
X		if (strchr(area, *(++ptr)))
X		{
X		    return ((char *) 0);
X		}
X	    } else
X	    {
X		if (PolyStrchr(area, ptr[2]))
X		{
X		    return ((char *) 0);
X		}
X		ptr += 2;
X	    }
X	    break;
X	    /*
X	     * alternative use for a boomerang, number 1: a standard throwing
X	     * boomerang is an ideal thing to use to tuck the sheets under
X	     * the mattress when making your bed.  The streamlined shape of
X	     * the boomerang allows it to slip easily 'twixt mattress and
X	     * bedframe, and it's curve makes it very easy to hook sheets
X	     * into the gap.
X	     */
X
X	case RULE_EQUALS:	/* =nx || =n?c */
X	    if (!ptr[1] || !ptr[2] || (ptr[2] == RULE_CLASS && !ptr[3]))
X	    {
X		Debug(1, (stderr, "Mangle: '=' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register int i;
X		if ((i = Char2Int(ptr[1])) < 0)
X		{
X		    Debug(1, (stderr, "Mangle: '=' weird argument in '%s'\n", control));
X		    return ((char *) 0);
X		}
X		if (ptr[2] != RULE_CLASS)
X		{
X		    ptr += 2;
X		    if (area[i] != *ptr)
X		    {
X			return ((char *) 0);
X		    }
X		} else
X		{
X		    ptr += 3;
X		    if (!MatchClass(*ptr, area[i]))
X		    {
X			return ((char *) 0);
X		    }
X		}
X	    }
X	    break;
X
X	case RULE_DFIRST:
X	    if (area[0])
X	    {
X		register int i;
X		for (i = 1; area[i]; i++)
X		{
X		    area[i - 1] = area[i];
X		}
X		area[i - 1] = '\0';
X	    }
X	    break;
X
X	case RULE_DLAST:
X	    if (area[0])
X	    {
X		register int i;
X		for (i = 1; area[i]; i++);
X		area[i - 1] = '\0';
X	    }
X	    break;
X
X	case RULE_MFIRST:
X	    if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
X	    {
X		Debug(1, (stderr, "Mangle: '(' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		if (ptr[1] != RULE_CLASS)
X		{
X		    ptr++;
X		    if (area[0] != *ptr)
X		    {
X			return ((char *) 0);
X		    }
X		} else
X		{
X		    ptr += 2;
X		    if (!MatchClass(*ptr, area[0]))
X		    {
X			return ((char *) 0);
X		    }
X		}
X	    }
X	    /* FALLTHROUGH */
X
X	case RULE_MLAST:
X	    if (!ptr[1] || (ptr[1] == RULE_CLASS && !ptr[2]))
X	    {
X		Debug(1, (stderr, "Mangle: ')' missing argument in '%s'\n", control));
X		return ((char *) 0);
X	    } else
X	    {
X		register int i;
X
X		for (i = 0; area[i]; i++);
X
X		if (i > 0)
X		{
X		    i--;
X		} else
X		{
X		    return ((char *) 0);
X		}
X
X		if (ptr[1] != RULE_CLASS)
X		{
X		    ptr++;
X		    if (area[i] != *ptr)
X		    {
X			return ((char *) 0);
X		    }
X		} else
X		{
X		    ptr += 2;
X		    if (!MatchClass(*ptr, area[i]))
X		    {
X			return ((char *) 0);
X		    }
X		}
X	    }
X	    /* FALLTHROUGH */
X
X	default:
X	    Debug(1, (stderr, "Mangle: unknown command %c in %s\n", *ptr, control));
X	    return ((char *) 0);
X	    /* NOTREACHED */
X	}
X    }
X    if (!area[0])		/* have we deweted de poor widdle fing away? */
X    {
X	return ((char *) 0);
X    }
X    return (area);
X}
X
Xint
XPMatch(control, string)
Xregister char *control;
Xregister char *string;
X{
X    while (*string && *control)
X    {
X    	if (!MatchClass(*control, *string))
X    	{
X    	    return(0);
X    	}
X
X    	string++;
X    	control++;
X    }
X
X    if (*string || *control)
X    {
X    	return(0);
X    }
X
X    return(1);
X}
END-of-lib/libcrack/rules.c
echo x - lib/libcrack/shlib_version
sed 's/^X//' >lib/libcrack/shlib_version << 'END-of-lib/libcrack/shlib_version'
X#	$NetBSD: shlib_version,v 1.2 1999/02/25 08:02:19 abs Exp $
X#	Remember to update distrib/sets/lists/base/shl.* when changing
X#
Xmajor=2
Xminor=7
END-of-lib/libcrack/shlib_version
echo x - lib/libcrack/stringlib.c
sed 's/^X//' >lib/libcrack/stringlib.c << 'END-of-lib/libcrack/stringlib.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X
X#ifndef lint
X#if 0
Xstatic char vers_id[] = "stringlib.c : v2.3p2 Alec Muffett 18 May 1993";
X#else
X__RCSID("$NetBSD$");
X#endif
X#endif
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <ctype.h>
X#include <pwd.h>
X
X#include "crack.h"
X
Xchar
XChop(string)
X    register char *string;
X{
X    register char c;
X    register char *ptr;
X    c = '\0';
X
X    for (ptr = string; *ptr; ptr++);
X    if (ptr != string)
X    {
X	c = *(--ptr);
X	*ptr = '\0';
X    }
X    return (c);
X}
X
Xchar *
XTrim(string)
X    register char *string;
X{
X    register char *ptr;
X    for (ptr = string; *ptr; ptr++);
X
X    while ((--ptr >= string) && isspace(*ptr));
X
X    *(++ptr) = '\0';
X
X    return (ptr);
X}
X
Xchar *
XClone(string)
X    char *string;
X{
X    register char *retval;
X    retval = (char *) malloc(strlen(string) + 1);
X    if (retval)
X    {
X	strcpy(retval, string);
X    }
X    return (retval);
X}
END-of-lib/libcrack/stringlib.c
echo c - libexec/pkcrackdict
mkdir -p libexec/pkcrackdict > /dev/null 2>&1
echo x - libexec/pkcrackdict/Makefile
sed 's/^X//' >libexec/pkcrackdict/Makefile << 'END-of-libexec/pkcrackdict/Makefile'
X#ident	"$Name$:$Id$"
X
XMAN=	pkcrackdict.8
XPROG=	pkcrackdict
XLDADD+= -lcrack
X
X.include <bsd.prog.mk>
END-of-libexec/pkcrackdict/Makefile
echo x - libexec/pkcrackdict/pkcrackdict.8
sed 's/^X//' >libexec/pkcrackdict/pkcrackdict.8 << 'END-of-libexec/pkcrackdict/pkcrackdict.8'
X.\"
X.\" This manual page written by Greg A. Woods <woods@planix.com>
X.\" derived from original text in CrackLib "README" file.
X.\" Copyright for this rendition contributed to the "Public Domain".
X.\"
X.Dd May 16, 2000
X.Dt pkcrackdict 1
X.Os
X.Sh "NAME"
X.Nm /usr/libexec/pkcrackdict
X.\"
X.Sh "SYNOPSIS"
X.Nm
X.Ar dict_prefix
X.\"
X.Sh "DESCRIPTION"
X.Nm
Xis used to create a specially formatted dictionary for use with the
X.Lb libcrack
X.Pp
XThe pathname prefix given as
X.Ar dict_prefix
Xwill be used to construct the full names of the three data files that
X.Nm
Xcreates.  These files have the suffixes
X.Pa .hwm ,
X.Pa .pwd ,
Xand
X.Pa .pwi .
X.Pp
X.Nm
Xis normally invoked by
X.Xr mkcrackdict 8 .
X.\"
X.\".Sh RETURN VALUES
X.\"
X.\".Sh ENVIRONMENT
X.\"
X.Sh FILES
X.Bl -tag -width /usr/libdata/pw_dict.pwd -compact
X.It Pa /usr/libdata/pw_dict.hwm
X.It Pa /usr/libdata/pw_dict.pwd
X.It Pa /usr/libdata/pw_dict.pwi
XThis is the prefix of three files containing an efficient binary
Xrepresentation of the word list.
X.El
X.\"
X.\".Sh EXAMPLES
X.\"
X.\".Sh DIAGNOSTICS
X.\"
X.Sh SEE ALSO
X.Xr FascistCheck 3 ,
X.Xr mkcrackdict 8 ,
X.Xr unpkcrackdict 8
X.\"
X.Sh STANDARDS
XThis command does not adhere to any known standards.
X.\"
X.Sh HISTORY
X.Nm
Xwas provided in the original CrackLib (2.7) distribution.
X.\"
X.Sh AUTHORS
XAlec Muffett
X.Li <alecm@crypto.dircon.co.uk>
X.\"
X.\".Sh BUGS
X.\"
X.\".Sh SECURITY CONSIDERATIONS
END-of-libexec/pkcrackdict/pkcrackdict.8
echo x - libexec/pkcrackdict/pkcrackdict.c
sed 's/^X//' >libexec/pkcrackdict/pkcrackdict.c << 'END-of-libexec/pkcrackdict/pkcrackdict.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X#include <stdio.h>
X#include <crack.h>
X
Xint	main __P((int, char **));
X
Xint
Xmain(argc, argv)
X    int argc;
X    char *argv[];
X{
X    int32 readed;
X    int32 wrote;
X    PWDICT *pwp;
X    char buffer[STRINGSIZE];
X
X    /* XXX should default to the system crackdict if no argument */
X    if (argc <= 1 || argc > 2)
X    {
X	fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
X	return (-1);
X    }
X
X    if (!(pwp = PWOpen(argv[1], "w")))
X    {
X	perror(argv[1]);
X	return (-1);
X    }
X
X    wrote = 0;
X
X    for (readed = 0; fgets(buffer, STRINGSIZE, stdin); /* nothing */)
X    {
X    	readed++;
X
X	buffer[MAXWORDLEN - 1] = '\0';
X
X	Chop(buffer);
X
X	if (!buffer[0])
X	{
X	    fprintf(stderr, "skipping line: %lu\n", readed);
X	    continue;
X	}
X
X	if (PutPW(pwp, buffer))
X	{
X	    fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);
X	}
X
X	wrote++;
X    }
X
X    PWClose(pwp);
X
X    printf("%lu %lu\n", readed, wrote);
X
X    return (0);
X}
END-of-libexec/pkcrackdict/pkcrackdict.c
echo c - libexec/unpkcrackdict
mkdir -p libexec/unpkcrackdict > /dev/null 2>&1
echo x - libexec/unpkcrackdict/Makefile
sed 's/^X//' >libexec/unpkcrackdict/Makefile << 'END-of-libexec/unpkcrackdict/Makefile'
X#ident	"$Name$:$Id$"
X
XMAN=	unpkcrackdict.8
XPROG=	unpkcrackdict
XLDADD+= -lcrack
X
X.include <bsd.prog.mk>
END-of-libexec/unpkcrackdict/Makefile
echo x - libexec/unpkcrackdict/unpkcrackdict.8
sed 's/^X//' >libexec/unpkcrackdict/unpkcrackdict.8 << 'END-of-libexec/unpkcrackdict/unpkcrackdict.8'
X.\"
X.\" This manual page written by Greg A. Woods <woods@planix.com>
X.\" derived from original text in CrackLib "README" file.
X.\" Copyright for this rendition contributed to the "Public Domain".
X.\"
X.Dd May 16, 2000
X.Dt unpkcrackdict 1
X.Os
X.Sh "NAME"
X.Nm /usr/libexec/unpkcrackdict
X.\"
X.Sh "SYNOPSIS"
X.Nm
X.Ar dict_prefix
X.\"
X.Sh "DESCRIPTION"
X.Nm
Xis used to dump a specially formatted dictionary for use with the
X.Lb libcrack
X.Pp
XThe pathname prefix given as
X.Ar dict_prefix
Xwill be used to construct the full names of the three data files that
X.Nm
Xreads.  These files have the suffixes
X.Pa .hwm ,
X.Pa .pwd ,
Xand
X.Pa .pwi .
X.\"
X.\".Sh RETURN VALUES
X.\"
X.\".Sh ENVIRONMENT
X.\"
X.Sh FILES
X.Bl -tag -width /usr/libdata/pw_dict.pwd -compact
X.It Pa /usr/libdata/pw_dict.hwm
X.It Pa /usr/libdata/pw_dict.pwd
X.It Pa /usr/libdata/pw_dict.pwi
XThis is the prefix of three files containing an efficient binary
Xrepresentation of the word list.
X.El
X.\"
X.\".Sh EXAMPLES
X.\"
X.\".Sh DIAGNOSTICS
X.\"
X.Sh SEE ALSO
X.Xr FascistCheck 3 ,
X.Xr mkcrackdict 8 ,
X.Xr pkcrackdict 8
X.\"
X.Sh STANDARDS
XThis command does not adhere to any known standards.
X.\"
X.Sh HISTORY
X.Nm
Xwas provided in the original CrackLib (2.7) distribution.
X.\"
X.Sh AUTHORS
XAlec Muffett
X.Li <alecm@crypto.dircon.co.uk>
X.\"
X.\".Sh BUGS
X.\"
X.\".Sh SECURITY CONSIDERATIONS
END-of-libexec/unpkcrackdict/unpkcrackdict.8
echo x - libexec/unpkcrackdict/unpkcrackdict.c
sed 's/^X//' >libexec/unpkcrackdict/unpkcrackdict.c << 'END-of-libexec/unpkcrackdict/unpkcrackdict.c'
X/*
X * This program is copyright Alec Muffett 1993. The author disclaims all 
X * responsibility or liability with respect to it's usage or its effect 
X * upon hardware or computer systems, and maintains copyright as set out 
X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
X * and upwards.
X */
X
X#include <sys/cdefs.h>
X#include <stdio.h>
X#include <crack.h>
X
Xint	main __P((int, char **));
X
Xint
Xmain(argc, argv)
X    int argc;
X    char *argv[];
X{
X    int32 i;
X    PWDICT *pwp;
X
X    if (argc <= 1)
X    {
X	fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
X	return (-1);
X    }
X
X    if (!(pwp = PWOpen (argv[1], "r")))
X    {
X	perror ("PWOpen");
X	return (-1);
X    }
X
X    for (i=0; i < PW_WORDS(pwp); i++)
X    {
X    	register char *c;
X
X	if (!(c = (char *) GetPW (pwp, i)))
X	{
X	    fprintf(stderr, "error: GetPW %ld failed\n", (long) i);
X	    continue;
X	}
X
X	printf ("%s\n", c);
X    }
X
X    return (0);
X}
END-of-libexec/unpkcrackdict/unpkcrackdict.c
echo x - usr.bin/passwd/getnewpass.c
sed 's/^X//' >usr.bin/passwd/getnewpass.c << 'END-of-usr.bin/passwd/getnewpass.c'
X/*	$NetBSD$	*/
X
X/*-
X * Copyright (c) 1990, 1993, 1994
X * 	The Regents of the University of California.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#include <sys/cdefs.h>
X#ifndef lint
X__RCSID("$NetBSD$");
X#endif /* not lint */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <ctype.h>
X#include <err.h>
X#include <errno.h>
X#include <pwd.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <time.h>
X#include <unistd.h>
X#include <util.h>
X#include <crack.h>
X
X#include "extern.h"
X
Xstatic void to64 __P((char *, long, int));
Xstatic char *check_oldpass __P((char *, char *));
X
Xstatic unsigned char itoa64[] =		/* 0 ... 63 => ascii - 64 */
X	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
X
Xstatic void
Xto64(s, v, n)
X	char *s;
X	long v;
X	int n;
X{
X	while (--n >= 0) {
X		*s++ = itoa64[v&0x3f];
X		v >>= 6;
X	}
X}
X
Xstatic char *
Xcheck_oldpass(oldpasswd, pass_type)
X	char *oldpasswd;
X	char *pass_type;
X{
X	char *p;
X
X	if (strcmp(crypt(p = getpass("Old password:"), oldpasswd), oldpasswd)) {
X		errno = EACCES;
X		pw_error(pass_type, 1, 1);
X	}
X	return p;
X}
X
X
Xchar *
Xgetnewpasswd(pw, min_pw_len, old_pass, uid, pass_type)
X	struct passwd *pw;
X	int min_pw_len;
X	char **old_pass;
X	uid_t uid;
X	char *pass_type;
X{
X	int tries;
X	char *p, *t;
X	char buf[_PASSWORD_LEN+1], salt[9];
X	
X	(void) printf("Changing %s password for %s.\n", pass_type, pw->pw_name);
X
X	if (strcmp(PASS_TYPE_YP, pass_type) == 0) {
X		if (old_pass) {
X			*old_pass = NULL;
X			
X			if (pw->pw_passwd[0]) {	/* root must always give old YP passwd */
X				p = check_oldpass(pw->pw_passwd, pass_type);
X			} else {
X				p = "";
X			}
X			*old_pass = strdup(p);
X		}
X	} else if (uid && pw->pw_passwd[0]) {
X		(void) check_oldpass(pw->pw_passwd, pass_type);
X	}
X	for (buf[0] = '\0', tries = 0;;) {
X		p = getpass("New password:");
X		if (!*p) {
X			(void) printf("Password unchanged.\n");
X			pw_error(NULL, 0, 0);
X		}
X		if (min_pw_len > 0) {
X			if (strlen(p) < min_pw_len) {
X				(void) printf("Please your password must be at least %d characters long.\n", min_pw_len);
X				continue;
X			}
X		} else if (strlen(p) <= 5 && ++tries < 2) {
X			(void) printf("Please enter a longer password.\n");
X			continue;
X		}
X		for (t = p; *t && islower(*t); ++t)
X			/* NOP */ ;
X		if (!*t && ++tries < 2) {
X			(void) printf("Please don't use an all-lower case password.\n"
X				      "Unusual capitalization, control characters or digits are suggested.\n");
X			continue;
X		}
X		if ((t = FascistCheck(p, _PATH_CRACKLIB_DICT, pw->pw_name, pw->pw_gecos))) {
X			printf("Please use a different password.  The one you have chosen is unsuitable\n"
X			       "because %s.\n", t);
X			continue;
X		}
X		(void) strncpy(buf, p, sizeof(buf) - 1);
X		buf[sizeof(buf) - 1] = '\0';
X		if (!strcmp(buf, getpass("Retype new password:")))
X			break;
X		(void) printf("Mismatch; try again, EOF to quit.\n");
X	}
X	/* grab a random printable character that isn't a colon */
X	(void) srandom((int) time((time_t *) NULL));
X#ifdef NEWSALT
X	salt[0] = _PASSWORD_EFMT1;
X	to64(&salt[1], (long) (29 * 25), 4);
X	to64(&salt[5], random(), 4);
X#else
X	to64(&salt[0], random(), 2);
X#endif
X	return(strdup(crypt(buf, salt)));
X}
END-of-usr.bin/passwd/getnewpass.c
echo c - usr.bin/testpasswd
mkdir -p usr.bin/testpasswd > /dev/null 2>&1
echo x - usr.bin/testpasswd/Makefile
sed 's/^X//' >usr.bin/testpasswd/Makefile << 'END-of-usr.bin/testpasswd/Makefile'
X#ident	"$Name$:$Id$"
X
XPROG=	testpasswd
XLDADD+=	-lcrack
X
X.include <bsd.prog.mk>
END-of-usr.bin/testpasswd/Makefile
echo x - usr.bin/testpasswd/testpasswd.1
sed 's/^X//' >usr.bin/testpasswd/testpasswd.1 << 'END-of-usr.bin/testpasswd/testpasswd.1'
X.\"
X.\" This manual page written by Greg A. Woods <woods@planix.com>
X.\" derived from original text in CrackLib "README" file.
X.\" Copyright for this rendition contributed to the "Public Domain".
X.\"
X.Dd May 14, 2000
X.Dt testpasswd 1
X.Os
X.Sh "NAME"
X.Nm testpasswd
X.\"
X.Sh "SYNOPSIS"
X.Nm
X.\"
X.Sh "DESCRIPTION"
X.Nm
Xis used for testing passwords against the CrackLib dictionary using
Xvarious matching algorithms to compare
X.Dq obvious
Xpermutations.  The words in the 
X.Xr passwd 5
X.Ar gecos
Xfield for the invoking user will also be matched against.
X.Pp
XPasswords are entered on the standard input to avoid the blatant
Xsecurity risk of having them appear on the command line for all to see
Xwith
X.Xr ps 1 .
XA diagnostic message
X.Dq "is hard to crack"
Xwill be printed to show that the password is hard to guess, or other
Xmessages will be given to explain why the password is guessable.
X.Pp
XIf
X.Dv stdin
Xis a terminal then multiple passwords will be accepted for testing until
Xthe user types the
X.Dv EOF
Xcharacter at the beginning of a line.
X.\"
X.Sh RETURN VALUES
XIf
X.Nm
Xis on the end of a pipe it will have an exit code of one (1) if the
Xpassword is easily guessed, or zero (0) if the password is hard to
Xguess.
X.\"
X.\".Sh ENVIRONMENT
X.\"
X.\".Sh FILES
X.\"
X.Sh EXAMPLES
X.Bd -unfilled -offset indent
X$ testpasswd   
Xenter passwords to test, one per line, up to 128 characters long;
X- end input with an EOF(^D) character...
Xbaseball 
Xbaseball: is crackable: it is based on a dictionary word
Xgreg.woods
Xgreg.woods: is crackable : it is based on your username
Xxyzzy
Xxyzzy: is crackable: it is too short
Xcat
Xcat: is crackable: it's WAY too short
Xasdfasdf
Xasdfasdf: is crackable: it does not contain enough DIFFERENT characters
X^D
X$ echo bigdog | testpasswd  
Xis crackable: it is based on a dictionary word
X$ echo $?
X1
X$ echo big.dog | testpasswd
Xis hard to crack
X$ echo $?                   
X0
X.Ed
X.\"
X.\".Sh DIAGNOSTICS
X.\"
X.Sh SEE ALSO
X.Xr passwd 1 ,
X.Xr FascistCheck 3 ,
X.Xr passwd 5 ,
X.Xr mkcrackdict 8
X.\"
X.Sh STANDARDS
XThis command does not adhere to any known standards.
X.\"
X.Sh HISTORY
XA similar program called
X.Nm testlib
Xwas provided in the original CrackLib (2.7) distribution.
X.\"
X.Sh AUTHORS
XAlec Muffett
X.Li <alecm@crypto.dircon.co.uk>
X.br
XGreg A. Woods
X.Li <woods@planix.com>
X.\"
X.Sh BUGS
XOnly one word to be tested is read from
X.Dv stdin
Xif it is not a
X.Dv tty .
X.Pp
XPasswords are echoed to the terminal unless they are read from
X.Dv stdin .
X.Pp
XThere is no way to specify a different user's
X.Ar gecos
Xfield for testing.
X.\"
X.Sh SECURITY CONSIDERATIONS
X.Nm
Xis only as good as the dictionary it works from.  If the attacker has a
Xbetter dictionary then he or she may be able to guess passwords that
Xhad been approved by this program.
X.Pp
XAny password used as an example in this or any related document should
X.Em not
Xbe used regardless of whether it is approved by any given invocation of
X.Nm
Xor not!
END-of-usr.bin/testpasswd/testpasswd.1
echo x - usr.bin/testpasswd/testpasswd.c
sed 's/^X//' >usr.bin/testpasswd/testpasswd.c << 'END-of-usr.bin/testpasswd/testpasswd.c'
X/*
X * This program's Copyright is in the Public Domain.
X
X * It is derived, in part, from CrackLib's "testlib" utility.
X */
X
X#include <sys/cdefs.h>
X#include <termios.h>
X#include <stdio.h>
X#include <string.h>
X#include <err.h>
X#include <pwd.h>
X#include <crack.h>
X
Xstatic char *argv0 = "testpasswd";
X
Xint main __P((int, char **));
X
Xstatic char *ccval __P((int));
X
X/* ARGSUSED */
Xint
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	PWDICT *pwdb;
X	char *pw;
X	size_t len;
X	struct termios tios;
X	int onatty = 0;
X
X	argv0 = (argv0 = strrchr(argv[0], '/')) ? argv0 + 1 : argv[0];
X	if (argc != 1) {
X		fprintf(stderr, "Usage: %s\n", argv0);
X		fprintf(stderr, "Passwords are accepted only on stdin for security reasons.\n");
X		exit(2);
X		/* NOTREACHED */
X	}
X	if (!(pwdb = PWOpen(_PATH_CRACKLIB_DICT, "r"))) {
X		err(1, "%s*", _PATH_CRACKLIB_DICT);
X		/* NOTREACHED */
X	}
X        if (tcgetattr(fileno(stdin), &tios) >= 0) {
X		printf("enter passwords to test, one per line, up to %d characters long;\n", _PASSWORD_LEN);
X		printf("- end input with an EOF(%s) character...\n", ccval(tios.c_cc[VEOF]));
X		onatty = 1;
X	}
X	while ((pw = fgetln(stdin, &len))) {
X		char shortpw[_PASSWORD_LEN + 1];
X		char *why;
X
X		if (*pw == '\n') {
X			printf("(read an empty line)\n");
X			if (onatty)
X				exit(1);
X			continue;
X		}
X                if (pw[len - 1] == '\n')
X                        pw[len - 1] = '\0';
X		memset(shortpw, '\0', sizeof(shortpw));
X		strncpy(shortpw, pw, sizeof(shortpw)-1);
X		why = FascistLook(pwdb, shortpw, (char *) NULL, (char *) NULL);
X		/*
X		 * XXX the English grammar of the printed result is less than
X		 * perfect...
X		 */
X		if (onatty)
X			printf("%s: %s%s\n", shortpw, why ? "is crackable: " : "", why ? why : "is hard to crack");
X		else {
X			printf("%s%s\n", why ? "is crackable: " : "", why ? why : "is hard to crack");
X			exit(why ? 1 : 0);
X			/* NOTREACHED */
X		}
X	}
X		    
X	PWClose(pwdb);
X	exit(0);
X	/* NOTREACHED */
X}
X
X/*
X * this routine stolen in part from usr.bin/stty/print.c
X */
Xstatic char *
Xccval(c)
X        int c;
X{
X        static char buf[5];
X        char *bp;
X
X        if (c == _POSIX_VDISABLE)
X                return ("<undef>");
X
X        bp = buf;
X        if (c & 0200) {
X                *bp++ = 'M';
X                *bp++ = '-';
X                c &= 0177;
X        }
X        if (c == 0177) {
X                *bp++ = '^';
X                *bp++ = '?';
X        }
X        else if (c < 040) {
X                *bp++ = '^';
X                *bp++ = c + '@';
X        }
X        else
X                *bp++ = c;
X        *bp = '\0';
X        return (buf);
X}
END-of-usr.bin/testpasswd/testpasswd.c
echo c - usr.sbin/mkcrackdict
mkdir -p usr.sbin/mkcrackdict > /dev/null 2>&1
echo x - usr.sbin/mkcrackdict/Makefile
sed 's/^X//' >usr.sbin/mkcrackdict/Makefile << 'END-of-usr.sbin/mkcrackdict/Makefile'
X#ident	"$Name$:$Id$"
X
XMAN=	mkcrackdict.8
XSCRIPTS=mkcrackdict.sh
X
X# source-files that are made into word lists
X#
XWORD_FILES=	/usr/share/misc/acronyms \
X		/usr/share/misc/airport \
X		/usr/share/misc/birthtoken \
X		/usr/share/misc/country \
X		/usr/share/misc/domains \
X		/usr/share/misc/flowers \
X		/usr/share/misc/inter.phone \
X		/usr/share/misc/language \
X		/usr/share/misc/na.phone \
X		/usr/share/misc/zipcodes
X
XCRACKLIB_DICT=	/usr/share/dict/words.cracklib
X
X# dictionary files already in list form
X#
XDICT_FILES=	/usr/share/dict/eign \
X		/usr/share/dict/propernames \
X		/usr/share/dict/web2 \
X		/usr/share/dict/web2a \
X		${CRACKLIB_DICT}
X
X${CRACKLIB_DICT}: ${WORD_FILES}
X	@echo -n 'Creating additional cracklib input dictionary...'
X	@cat ${WORD_FILES} | tr -cs "[A-Z][a-z][0-9]'" '[\012*]' | sort -uf > $@
X	@echo ' Done.'
X	chown ${BINOWN}:${BINGRP} $@
X	chmod ${NONBINMODE} $@
X
Xdistribution: ${CRACKLIB_DICT}
X	/usr/sbin/mkcrackdict ${DICT_FILES}
X
X.include <bsd.prog.mk>
END-of-usr.sbin/mkcrackdict/Makefile
echo x - usr.sbin/mkcrackdict/mkcrackdict.8
sed 's/^X//' >usr.sbin/mkcrackdict/mkcrackdict.8 << 'END-of-usr.sbin/mkcrackdict/mkcrackdict.8'
X.\"
X.\" This manual page written by Greg A. Woods <woods@planix.com>
X.\" derived from original text in CrackLib "README" file.
X.\" Copyright for this rendition contributed to the "Public Domain".
X.\"
X.Dd May 16, 2000
X.Dt mkcrackdict 1
X.Os
X.Sh "NAME"
X.Nm mkcrackdict
X.\"
X.Sh "SYNOPSIS"
X.Nm
X.Ar word_list
X.Op Ar ...
X.\"
X.Sh "DESCRIPTION"
X.Nm
Xis a simple script that is used to create a specially formatted
Xdictionary for use with the
X.Lb libcrack
X.Pp
X.Nm expects its argument(s) to be one or more filenames containing lists
Xof words, one per line.
X.Pp
XNote that you can create a list of words suitable for feeding to this
Xscript from any arbitrary document by using the following filter:
X.Pp
X.Dl tr -cs "'[A-Z][a-z][0-9]'" '[\012*]'
X.Pp
X.Nm
Xwill sort the list and remove duplicate words (and empty lines, etc.).
XThe cleaned up lists are fed to
X.Xr pkcrackdict 8
Xwhich does the actual work of creating the files
X.Pa /usr/libdata/pw_dict* .
X.Pp
XMore word lists (dictionaries) can be found all over the Internet, two
Xsuch example locations are here:
X.Pp
X.Dl ftp://ftp.ox.ac.uk/pub/wordlists/
X.br
X.Dl ftp://ftp.uu.net/doc/dictionaries/
X.\"
X.\".Sh RETURN VALUES
X.\"
X.Sh ENVIRONMENT
X.Ev TMPDIR
Xcan be used to specify an alternate temporary directory for
X.Xr sort 1 .
X.\"
X.Sh FILES
X.Bl -tag -width /usr/libdata/pw_dict.pwd -compact
X.It Pa /usr/libdata/pw_dict.hwm
X.It Pa /usr/libdata/pw_dict.pwd
X.It Pa /usr/libdata/pw_dict.pwi
XThe three files containing an efficient binary representation of the
Xword list.
X.It Pa /usr/share/dict/propernames
X.It Pa /usr/share/dict/web2
X.It Pa /usr/share/dict/web2a
X.It Pa /usr/share/dict/words.cracklib
XThese are examples of word lists suitable for processing by
X.Nm mkcrakdict .
XThe list in
X.Pa words.cracklib
Xis constructed from various interesting files in
X.Pa /usr/share/misc .
X.El
X.\"
X.\".Sh EXAMPLES
X.\"
X.\".Sh DIAGNOSTICS
X.\"
X.Sh SEE ALSO
X.Xr passwd 1 ,
X.Xr sort 1 ,
X.Xr testpasswd 1 ,
X.Xr FascistCheck 3 ,
X.Xr passwd 5 ,
X.Xr pkcrackdict 8 ,
X.Xr unpkcrackdict 8
X.\"
X.\"
X.Sh STANDARDS
XThis command does not adhere to any known standards.
X.\"
X.Sh HISTORY
X.Nm
Xwas provided in the original CrackLib (2.7) distribution.
X.\"
X.Sh AUTHORS
XAlec Muffett
X.Li <alecm@crypto.dircon.co.uk>
X.\"
X.\".Sh BUGS
X.\"
X.Sh SECURITY CONSIDERATIONS
XThe
X.Lb libcrack
Xis only as good as the dictionaries you give it to work with.  If the
Xattacker has a better dictionary then he or she may be able to guess
Xpasswords that had been approved by this program.
END-of-usr.sbin/mkcrackdict/mkcrackdict.8
echo x - usr.sbin/mkcrackdict/mkcrackdict.sh
sed 's/^X//' >usr.sbin/mkcrackdict/mkcrackdict.sh << 'END-of-usr.sbin/mkcrackdict/mkcrackdict.sh'
X#! /bin/sh
X:
X#ident "$Name$:$Id$"
X
X#
X#	mkcrackdict - create libcrack's database
X#
X# Usage:
X#	mkcrackdict wordlist [...]
X
X###
X# This program is copyright Alec Muffett 1993. The author disclaims all
X# responsibility or liability with respect to it's usage or its effect
X# upon hardware or computer systems, and maintains copyright as set out
X# in the "LICENCE" document which accompanies distributions of Crack v4.0
X# and upwards.
X###
X
X### in case of explosion, invoke "sort" with "-T" option pointing to a
X### lot of free space in a directory somewhere; or set the environment
X### variable TMPDIR to point at such a directory....
X
XSORT="sort"
X###SORT="sort -T /tmp"
X
X# Note that you can create a list of words suitable for feeding to
X# this script from any arbitrary document using the following filter:
X# 
X#	tr -cs "[A-Z][a-z][0-9]'" '[\012*]'
X
X# XXX keep this in sync with _PATH_CRACKLIB_DICT in lib/libcrack/crack.h
X# and of course with distrib/sets/lists/base/mi
X#
XDICTPATH=/usr/libdata/pw_dict
X
X### XXX Note that there should be a command-line option to allow the
X### user to specify the target DICTPATH
X
Xcat $* |
X	tr '[A-Z]' '[a-z]' |
X	tr -cd '\012[a-z][0-9]' |
X	$SORT -u |
X	egrep -v -e '^#' -e '^$' |
X	/usr/libexec/pkcrackdict $DICTPATH
END-of-usr.sbin/mkcrackdict/mkcrackdict.sh
exit

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: bin-bug-people->security-officer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Sun May 28 01:11:32 PDT 2000 
Responsible-Changed-Why:  
This is really an issue for the security officer. 
State-Changed-From-To: open->closed
State-Changed-By: elad@netbsd.org
State-Changed-When: Sat, 13 Aug 2005 21:48:12 +0000
State-Changed-Why:
Both crack and libcrack are available from pkgsrc/security.


State-Changed-From-To: closed->open
State-Changed-By: david@netbsd.org
State-Changed-When: Mon, 15 Aug 2005 17:34:33 +0000
State-Changed-Why:
Packages were available when the bug was filed, but this is about the default security of the base system.


From: Elad Efrat <elad@NetBSD.org>
To: david@NetBSD.org
Cc: gnats-bugs@netbsd.org
Subject: re: security/10206
Date: Mon, 15 Aug 2005 21:00:03 +0300

 David,

 There are also plenty of PRs about system integrity, and we don't enable
 Veriexec by default. The way I see it, NetBSD should provide the tools
 for an admin to customize the security of her system the way she sees
 fit.

 This whole PR is based on the assumption that we are not doing anything
 to prevent brute-force password cracking.

 How many guesses does it take to pick a password? Should we be enforcing
 this for *all* users, even those who use NetBSD in environments where
 these concerns no longer hold?

 Unless you are taking measures to prevent an attacker from infinitely
 trying all password combinations, your password *will* be cracked. This
 is why many people use public keys, and why many admins care about
 rate-limiting login attempts; *this* is where we should aim if we want
 to have a take on solving this problem.

 IMHO, enforcing 10-char, upper/lower/digit/punctuation passwords is
 archaic. And given JtR allows you to specify possible password patterns,
 and the power of today's computers, and the ability to no transparent
 processing distribution, I don't see how any of the suggested in this
 patch solves the problem.

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: David Maxwell <david@crlf.net>
To: gnats-bugs@netbsd.org
Cc: security-officer@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: security/10206
Date: Mon, 15 Aug 2005 14:22:46 -0400

 Elad wrote:  
 >  There are also plenty of PRs about system integrity, and we don't enable
 >  Veriexec by default. The way I see it, NetBSD should provide the tools
 >  for an admin to customize the security of her system the way she sees
 >  fit.

 Agreed. Currently, the admin can not customize her system to either
 request or require good passwords.

 >  This whole PR is based on the assumption that we are not doing anything
 >  to prevent brute-force password cracking.

 No. It affects passwords that will be exposed over NIS, shared with
 other systems that don't use shadow password files, or used in other
 protocols that expose a hash.

 Brute-force is relevant to this, partially, but preventing brute-force
 attacks would not eliminate the desirability of good passwords.

 >  How many guesses does it take to pick a password? Should we be enforcing
 >  this for *all* users, even those who use NetBSD in environments where
 >  these concerns no longer hold?

 No, we should provide the tools for an admin to customize the security
 of her system the way she sees fit. Right now, we don't provide the
 tools.

 >  Unless you are taking measures to prevent an attacker from infinitely
 >  trying all password combinations, your password *will* be cracked. This
 >  is why many people use public keys, and why many admins care about
 >  rate-limiting login attempts; *this* is where we should aim if we want
 >  to have a take on solving this problem.

 If you're concerned about Internet-accessible hosts, what you say is
 true, but there are many other system environments.

 >  IMHO, enforcing 10-char, upper/lower/digit/punctuation passwords is
 >  archaic. And given JtR allows you to specify possible password patterns,
 >  and the power of today's computers, and the ability to no transparent
 >  processing distribution, I don't see how any of the suggested in this
 >  patch solves the problem.

 The 'power of today's computers' may impact DES, but impact other hashes
 less. 

 Additionally, many corporations have Security Guideline Documents, about
 what types of passwords an acceptable system may allow. Whether right or
 wrong about the requirements of passwords, we want to make NetBSD usable
 in those environments.

Responsible-Changed-From-To: security-officer->elad
Responsible-Changed-By: elad@netbsd.org
Responsible-Changed-When: Mon, 15 Aug 2005 20:32:50 +0000
Responsible-Changed-Why:
I'll take care of writing our own password strength testing code. If, when
I'm done, the (IMHO pointless! :) libcrack will be desired, I'll take the
job of integrating it.


From: Elad Efrat <elad@NetBSD.org>
To: tech-security@netbsd.org
Cc: gnats-bugs@netbsd.org
Subject: re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 01:05:22 +0300

 Hi,

 I've written concept code, still work in progress, that allows an
 admin to set a password policy in /etc/passwd.conf.

 The current version has the following options when setting a policy:
 minlen, maxlen, upper, lower, digits, punct.

 minlen/maxlen - define the min. and max. length of the password. Zero
 means no limit.
 upper/lower/digits/punct - define what character sets are required to
 be in the password. The first word should be ``yes'' or ``no''; an
 optional argument can be in the form of ``N,M'', requiring at least
 N characters of that class, but not more than M characters. Zero means
 no limit here too.

 An example entry in /etc/passwd.conf for at least 8 character passwords
 combining both upper/lower case and digits can be:

 policy:
   minlen = 8
   upper = yes
   lower = yes
   digits = yes

 The code is available from
 ftp://ftp.netbsd.org/pub/NetBSD/misc/elad/policy.c. It can very easily
 be extended to support more policies. (for example, dictionary lists, if
 people still care :)

 Comments?

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: Alan Barrett <apb@cequrux.com>
To: tech-security@NetBSD.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 00:26:07 +0200

 On Wed, 17 Aug 2005, Elad Efrat wrote:
 > An example entry in /etc/passwd.conf for at least 8 character passwords
 > combining both upper/lower case and digits can be:
 > 
 > policy:
 >   minlen = 8
 >   upper = yes
 >   lower = yes
 >   digits = yes

 If I understand correctly, "upper = yes" really means "uppercase
 characters are required", and "upper = no" really means "uppercase
 characters are optional (not required)".  Or do I misunderstand, and
 "upper = no" really means "uppercase characters are prohibited"?

 I'd prefer to see keywords like "required", "optional" and "prohibited",
 rather than "yes" and "no".

 --apb (Alan Barrett)

From: Alan Barrett <apb@cequrux.com>
To: tech-security@NetBSD.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 00:38:28 +0200

 On Wed, 17 Aug 2005, Alan Barrett wrote:
 > I'd prefer to see keywords like "required", "optional" and "prohibited",
 > rather than "yes" and "no".

 Actually, the prohibited/optional/required status could just be implied
 by the numeric ranges, but then you'd have to use "0 means 0", not "0
 means infinity".  For example, "upper: 0" could mean "prohibited";
 "upper: 1-*" could mean "1 or more required"; "upper: 1-3" could mean
 "at least 1, but no more than 3"; "upper: 0-*" could mean "any number,
 zero or more".

 --apb (Alan Barrett)

From: "Steven M. Bellovin" <smb@cs.columbia.edu>
To: Elad Efrat <elad@NetBSD.org>
Cc: tech-security@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept) 
Date: Tue, 16 Aug 2005 19:12:29 -0400

 In message <43026322.7060500@NetBSD.org>, Elad Efrat writes:
 >Hi,
 >
 >I've written concept code, still work in progress, that allows an
 >admin to set a password policy in /etc/passwd.conf.
 >
 >
 Hmm -- at the rump session of CRYPTO 2005 tonight, there's a talk 
 "Passwords -- No Longer Viable"...

 		--Steven M. Bellovin, http://www.cs.columbia.edu/~smb


From: Elad Efrat <elad@NetBSD.org>
To: Alan Barrett <apb@cequrux.com>
Cc: tech-security@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 06:56:04 +0300

 Alan Barrett wrote:

 > I'd prefer to see keywords like "required", "optional" and "prohibited",
 > rather than "yes" and "no".

 Agreed; I'll change "yes" to "required" and "no" to "optional", and add
 a "prohibited".

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: Elad Efrat <elad@NetBSD.org>
To: Alan Barrett <apb@cequrux.com>
Cc: tech-security@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 06:58:02 +0300

 Alan Barrett wrote:

 > Actually, the prohibited/optional/required status could just be implied
 > by the numeric ranges, but then you'd have to use "0 means 0", not "0
 > means infinity".  For example, "upper: 0" could mean "prohibited";
 > "upper: 1-*" could mean "1 or more required"; "upper: 1-3" could mean
 > "at least 1, but no more than 3"; "upper: 0-*" could mean "any number,
 > zero or more".

 Yes, but then we'd lose a bit of the readability. This is hardly
 time-critical code, and in fact should be very clear to the admin as to
 what the configuration means.

 I can change the range syntax, though.

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: Bernd Ernesti <netbsd@lists.veego.de>
To: Elad Efrat <elad@NetBSD.org>
Cc: tech-security@NetBSD.org, gnats-bugs@NetBSD.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Wed, 17 Aug 2005 08:35:28 +0200

 On Wed, Aug 17, 2005 at 06:58:02AM +0300, Elad Efrat wrote:
 > Alan Barrett wrote:
 > 
 > > Actually, the prohibited/optional/required status could just be implied
 > > by the numeric ranges, but then you'd have to use "0 means 0", not "0
 > > means infinity".  For example, "upper: 0" could mean "prohibited";
 > > "upper: 1-*" could mean "1 or more required"; "upper: 1-3" could mean
 > > "at least 1, but no more than 3"; "upper: 0-*" could mean "any number,
 > > zero or more".
 > 
 > Yes, but then we'd lose a bit of the readability. This is hardly
 > time-critical code, and in fact should be very clear to the admin as to
 > what the configuration means.

 Thats what a manpage is for.

 > I can change the range syntax, though.

 I like the idea from Alan, so you have more flexibility to use a finer
 policy.
 And don't forget to use sane defaults if that files doesn't exist or
 defines not all entries.

 Bernd

From: Nino Dehne <ndehne@gmail.com>
To: Alan Barrett <apb@cequrux.com>
Cc: gnats-bugs@NetBSD.org, tech-security@netbsd.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Fri, 19 Aug 2005 05:52:37 +0200

 Alan Barrett wrote:
 > Actually, the prohibited/optional/required status could just be implied
 > by the numeric ranges, but then you'd have to use "0 means 0", not "0
 > means infinity".  For example, "upper: 0" could mean "prohibited";
 > "upper: 1-*" could mean "1 or more required"; "upper: 1-3" could mean
 > "at least 1, but no more than 3"; "upper: 0-*" could mean "any number,
 > zero or more".

 How about the ability to specify a regex that the password must match?

 Regards,

 ND

From: Elad Efrat <elad@NetBSD.org>
To: Nino Dehne <ndehne@gmail.com>
Cc: Alan Barrett <apb@cequrux.com>, gnats-bugs@NetBSD.org,
	tech-security@netbsd.org
Subject: Re: security/10206 - proposed solution (concept)
Date: Fri, 19 Aug 2005 11:32:31 +0300

 Nino Dehne wrote:

 > How about the ability to specify a regex that the password must match?

 This would take even another step towards making brute-force a whole lot
 easier with JtR, for example.

 My own way would be to simply enforce the length and use some
 brute-force detection to prevent the attacks. If an admin don't look at
 the logs, it doesn't matter if you have 2 or 2000 failed login
 attempts...

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: Elad Efrat <elad@NetBSD.org>
To: tech-security@netbsd.org
Cc: gnats-bugs@netbsd.org
Subject: Re: security/10206 - proposed solution
Date: Sat, 27 Aug 2005 20:22:51 +0300

 ftp://ftp.netbsd.org/pub/NetBSD/misc/elad/pw_policy/

 Please have a look first at the README file, it describes how new
 policies can be added, suggested defaults, how existing programs can
 make use of it, etc.

 There is no man-page yet.

 -e.

 -- 
 Elad Efrat
 PGP Key ID: 0x666EB914

From: Elad Efrat <elad@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/10206 CVS commit: src
Date: Wed, 14 Sep 2005 11:36:53 +0000 (UTC)

 Module Name:	src
 Committed By:	elad
 Date:		Wed Sep 14 11:36:53 UTC 2005

 Modified Files:
 	src/distrib/sets/lists/base: shl.mi
 	src/distrib/sets/lists/comp: mi
 	src/lib/libutil: Makefile shlib_version
 Added Files:
 	src/lib/libutil: pw_policy.3 pw_policy.c

 Log Message:
 Introduce pw_policy(3), an easily extendable way of defining password
 policies and enforcing them in programs.

 Man-page written with much help and tips from David Maxwell, Hubert
 Feyrer, and Thomas Klausner.

 This bumps libutil minor to 7.

 XXX: Need default policy to go in /etc/passwd.conf, and integration
      into local/yp/PAM password changing code.

 PR/10206.


 To generate a diff of this commit:
 cvs rdiff -r1.319 -r1.320 src/distrib/sets/lists/base/shl.mi
 cvs rdiff -r1.812 -r1.813 src/distrib/sets/lists/comp/mi
 cvs rdiff -r1.47 -r1.48 src/lib/libutil/Makefile
 cvs rdiff -r0 -r1.1 src/lib/libutil/pw_policy.3 src/lib/libutil/pw_policy.c
 cvs rdiff -r1.36 -r1.37 src/lib/libutil/shlib_version

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: elad@netbsd.org
State-Changed-When: Wed, 14 Sep 2005 11:42:01 +0000
State-Changed-Why:
Recently added pw_policy(3) to address this issue.
I'm glad we could celebrate a 5-year-anniversary for this PR before closing it.


From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: <gnats-bugs@gnats.netbsd.org>
Cc: 
Subject: Re: bin/10206: of what use are even 128-byte passwords if people can 
 still choose easily guessable ones?
Date: Wed, 18 Nov 2009 18:31:10 +0100

 Just for the record: There is a PAM module in
 pkgsrc/security/pam-passwdqc which does password
 strength checking. The passwdqc code seems to be
 commonly used in Linux distributions.
 There is a bug in NetBSD's pam_unix module which
 makes that it ignores the previously checked
 password, this is fixed in
 lib/libpam/modules/pam_unix/pam_unix.c rev 1.14

 best regards
 Matthias



 ---------------------------------------------------------------------------=
 ---------------------
 ---------------------------------------------------------------------------=
 ---------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
 Prof. Dr. Sebastian M. Schmidt
 ---------------------------------------------------------------------------=
 ---------------------
 ---------------------------------------------------------------------------=
 ---------------------

From: "Greg A. Woods" <woods@planix.ca>
To: NetBSD GNATS <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: bin/10206: of what use are even 128-byte passwords if people can  still choose easily guessable ones?
Date: Wed, 18 Nov 2009 21:45:57 -0500

 --pgp-sign-Multipart_Wed_Nov_18_21:45:54_2009-1
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: quoted-printable

 At Wed, 18 Nov 2009 17:35:02 +0000 (UTC), Matthias Drochner <M.Drochner@fz-=
 juelich.de> wrote:
 Subject: Re: bin/10206: of what use are even 128-byte passwords if people c=
 an  still choose easily guessable ones?
 >=20
 >  Just for the record: There is a PAM module in
 >  pkgsrc/security/pam-passwdqc which does password
 >  strength checking.

 It doesn't seem to be any better than the unused and unusable and
 incompletely documented code that was thrown haphazardly into NetBSD as
 pw_policy(3).

 It's also PAM specific, and I'm sure you know what I think about PAM.

 (that said, apparently it is usable on systems without PAM, but likely
 not usefully without proper integration)

 --=20
 						Greg A. Woods
 						Planix, Inc.

 <woods@planix.com>       +1 416 218 0099        http://www.planix.com/

 --pgp-sign-Multipart_Wed_Nov_18_21:45:54_2009-1
 Content-Type: application/pgp-signature
 Content-Transfer-Encoding: 7bit

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (NetBSD)

 iD8DBQBLBLFiZn1xt3i/9H8RAvvUAJ4kpnFEoogZ1I54SqCSLxNjQoCE9QCfXqPn
 gzIQk+0Z+A9BRK/cna3BUFo=
 =SWQm
 -----END PGP SIGNATURE-----

 --pgp-sign-Multipart_Wed_Nov_18_21:45:54_2009-1--

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.