home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume38 / cracklib / part02 < prev    next >
Encoding:
Internet Message Format  |  1993-06-20  |  24.2 KB

  1. From: Alec.Muffett@UK.Sun.COM (Alec David Muffett)
  2. Newsgroups: comp.sources.misc
  3. Subject: v38i002: cracklib - CrackLib: A ProActive Password Security library, Part02/02
  4. Date: 18 Jun 1993 12:44:22 +0100
  5. Sender: aem@aber.ac.uk
  6. Approved: aem@aber.ac.uk
  7. Message-ID: <1vs9qm$btr@uk-usenet.UK.Sun.COM>
  8. X-Md4-Signature: 1bf8ce10d0606bbc653dd90603039958
  9.  
  10. Submitted-by: Alec.Muffett@UK.Sun.COM (Alec David Muffett)
  11. Posting-number: Volume 38, Issue 2
  12. Archive-name: cracklib/part02
  13. Environment: C
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  HISTORY Makefile POSTER cracklib/Makefile
  21. #   cracklib/genrules.pl cracklib/packer.h cracklib/stringlib.c
  22. #   shadow/obscure.c,CL util/Makefile util/mkdict util/packer.c
  23. #   util/testlib.c util/testnum.c util/teststr.c util/unpacker.c
  24. # Wrapped by alecm@uk-usenet on Fri Jun 18 12:37:28 1993
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 2 (of 2)."'
  28. if test -f 'HISTORY' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'HISTORY'\"
  30. else
  31.   echo shar: Extracting \"'HISTORY'\" \(148 characters\)
  32.   sed "s/^X//" >'HISTORY' <<'END_OF_FILE'
  33. Xv2.5    added decent info to the "shadow" directory patches.
  34. X
  35. Xv2.4    forwarded to ch & jfh3 for beta testing/comments
  36. X
  37. Xv2.3-    internal beta test versions
  38. END_OF_FILE
  39.   if test 148 -ne `wc -c <'HISTORY'`; then
  40.     echo shar: \"'HISTORY'\" unpacked with wrong size!
  41.   fi
  42.   # end of 'HISTORY'
  43. fi
  44. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'Makefile'\"
  46. else
  47.   echo shar: Extracting \"'Makefile'\" \(1194 characters\)
  48.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  49. X###
  50. X# This program is copyright Alec Muffett 1993. The author disclaims all
  51. X# responsibility or liability with respect to it's usage or its effect
  52. X# upon hardware or computer systems, and maintains copyright as set out
  53. X# in the "LICENCE" document which accompanies distributions of Crack v4.0
  54. X# and upwards.
  55. X###
  56. X
  57. X###
  58. X# set this to the absolute path (less extn) of compressed dict.
  59. X
  60. XDICTPATH="/usr/local/lib/pw_dict"
  61. X
  62. X###
  63. X# Set this to the path of one or more files continaing wordlists.
  64. X
  65. XSRCDICTS=/usr/dict/words
  66. X###SRCDICTS=/usr/dict/words ./very-big-dict
  67. X
  68. X
  69. Xdefault:
  70. X    @echo "you evidently don't know what you're doing. go read the README"
  71. X
  72. Xall:
  73. X    ( cd cracklib && make && exit $$? )
  74. X    ( cd util && make DICTPATH=$(DICTPATH) && exit $$? )
  75. X###    ( cd passwd && make DICTPATH=$(DICTPATH) passwd && exit $$? )
  76. X    touch all
  77. X
  78. Xclean:
  79. X    -( cd cracklib && make clean && exit $$? )
  80. X    -( cd util && make clean && exit $$? )
  81. X###    -( cd passwd && make clean && exit $$? )
  82. X    -rm -f all installed Part* *.BAK *.bak
  83. X
  84. Xinstall: all
  85. X    @echo 'if "sort" dies from lack of space, see "util/mkdict"'
  86. X    util/mkdict $(SRCDICTS) | util/packer $(DICTPATH)
  87. X    touch installed
  88. X###    @echo 'now go install passwd/passwd where you want it'
  89. END_OF_FILE
  90.   if test 1194 -ne `wc -c <'Makefile'`; then
  91.     echo shar: \"'Makefile'\" unpacked with wrong size!
  92.   fi
  93.   # end of 'Makefile'
  94. fi
  95. if test -f 'POSTER' -a "${1}" != "-c" ; then 
  96.   echo shar: Will not clobber existing file \"'POSTER'\"
  97. else
  98.   echo shar: Extracting \"'POSTER'\" \(1276 characters\)
  99.   sed "s/^X//" >'POSTER' <<'END_OF_FILE'
  100. X
  101. XCrackLib is a library containing a C function (well, lots of functions
  102. Xreally, but you only need to use one of them) which may be used in a
  103. X"passwd"-like program.
  104. X
  105. XThe idea is simple: try to prevent users from choosing passwords that
  106. Xcould be guessed by "Crack" by filtering them out, at source.
  107. X
  108. XCrackLib is an offshoot of the the version 5 "Crack" software, and
  109. Xcontains a considerable number of ideas nicked from the new software. 
  110. XAt the time of writing, Crack 5 is incomplete (still awaiting purchase
  111. Xof my home box) - but I though I could share this with you. 
  112. X
  113. XNOTE THIS WELL: CrackLib is NOT a replacement "passwd" program. 
  114. XCrackLib is a LIBRARY.  CrackLib is what trendy marketdroid types would
  115. Xprobably call an "enabler". 
  116. X
  117. XThe idea is that you wire it into your _own_ "passwd" program (if you
  118. Xhave source); alternatively, you wire it into something like "shadow"
  119. Xfrom off of the net.  You can use it almost _everywhere_. 
  120. X
  121. XFOR YOUR INFORMATION:
  122. X
  123. XCrackLib has been tested mostly on Suns.  If you can point me at ways
  124. Xround portability problems (eg: static linking, other libraries, etc)
  125. XI'd be most grateful. 
  126. X
  127. XA reference copy of CrackLib (+ large dictionary) can be found via
  128. Xanonymous FTP at: 
  129. X    black.ox.ac.uk:~ftp/src/security/cracklib25.tar.Z
  130. X
  131. X
  132. X                    - alec
  133. END_OF_FILE
  134.   if test 1276 -ne `wc -c <'POSTER'`; then
  135.     echo shar: \"'POSTER'\" unpacked with wrong size!
  136.   fi
  137.   # end of 'POSTER'
  138. fi
  139. if test -f 'cracklib/Makefile' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'cracklib/Makefile'\"
  141. else
  142.   echo shar: Extracting \"'cracklib/Makefile'\" \(492 characters\)
  143.   sed "s/^X//" >'cracklib/Makefile' <<'END_OF_FILE'
  144. X###
  145. X# This program is copyright Alec Muffett 1993. The author disclaims all
  146. X# responsibility or liability with respect to it's usage or its effect
  147. X# upon hardware or computer systems, and maintains copyright as set out
  148. X# in the "LICENCE" document which accompanies distributions of Crack v4.0
  149. X# and upwards.
  150. X###
  151. X
  152. XLIB=    libcrack.a
  153. XOBJ=    fascist.o packlib.o rules.o stringlib.o
  154. XCFLAGS= -O -I../cracklib -DIN_CRACKLIB
  155. X
  156. X$(LIB):    $(OBJ)
  157. X    ar rv $(LIB) $?
  158. X    -ranlib $(LIB)
  159. X
  160. Xclean:
  161. X    -rm -f $(OBJ) $(LIB)
  162. END_OF_FILE
  163.   if test 492 -ne `wc -c <'cracklib/Makefile'`; then
  164.     echo shar: \"'cracklib/Makefile'\" unpacked with wrong size!
  165.   fi
  166.   # end of 'cracklib/Makefile'
  167. fi
  168. if test -f 'cracklib/genrules.pl' -a "${1}" != "-c" ; then 
  169.   echo shar: Will not clobber existing file \"'cracklib/genrules.pl'\"
  170. else
  171.   echo shar: Extracting \"'cracklib/genrules.pl'\" \(992 characters\)
  172.   sed "s/^X//" >'cracklib/genrules.pl' <<'END_OF_FILE'
  173. X#!/usr/local/bin/perl
  174. X
  175. X###
  176. X# This program is copyright Alec Muffett 1993. The author disclaims all
  177. X# responsibility or liability with respect to it's usage or its effect
  178. X# upon hardware or computer systems, and maintains copyright as set out
  179. X# in the "LICENCE" document which accompanies distributions of Crack v4.0
  180. X# and upwards.
  181. X###
  182. X
  183. Xsub ByLen {
  184. X    length($a) <=> length($b);
  185. X}
  186. X
  187. X@a1 = ('/$s$s', '/0s0o', '/1s1i', '/2s2a', '/3s3e', '/4s4h');
  188. X@a2 = ('/$s$s', '/0s0o', '/1s1l', '/2s2a', '/3s3e', '/4s4h');
  189. X@a3 = ('/$s$s', '/0s0o', '/1s1i', '/2s2a', '/3s3e', '/4s4a');
  190. X@a4 = ('/$s$s', '/0s0o', '/1s1l', '/2s2a', '/3s3e', '/4s4a');
  191. X
  192. Xsub Permute {
  193. X    local(@args) = @_;
  194. X    local($prefix);
  195. X
  196. X    while ($#args >= 0)
  197. X    {
  198. X        @foo = @args;
  199. X        $prefix = "";
  200. X
  201. X        while ($#foo >= 0)
  202. X        {
  203. X            foreach (@foo)
  204. X            {
  205. X                $foo{"$prefix$_"}++;
  206. X            }
  207. X            $prefix .= shift(@foo);
  208. X        }
  209. X
  210. X        shift(@args);
  211. X    }
  212. X}
  213. X
  214. X&Permute(@a1);
  215. X&Permute(@a2);
  216. X&Permute(@a3);
  217. X&Permute(@a4);
  218. X
  219. Xforeach $key (sort ByLen (keys(%foo)))
  220. X{
  221. X    print $key, "\n";
  222. X}
  223. END_OF_FILE
  224.   if test 992 -ne `wc -c <'cracklib/genrules.pl'`; then
  225.     echo shar: \"'cracklib/genrules.pl'\" unpacked with wrong size!
  226.   fi
  227.   chmod +x 'cracklib/genrules.pl'
  228.   # end of 'cracklib/genrules.pl'
  229. fi
  230. if test -f 'cracklib/packer.h' -a "${1}" != "-c" ; then 
  231.   echo shar: Will not clobber existing file \"'cracklib/packer.h'\"
  232. else
  233.   echo shar: Extracting \"'cracklib/packer.h'\" \(1262 characters\)
  234.   sed "s/^X//" >'cracklib/packer.h' <<'END_OF_FILE'
  235. X/*
  236. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  237. X * responsibility or liability with respect to it's usage or its effect 
  238. X * upon hardware or computer systems, and maintains copyright as set out 
  239. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  240. X * and upwards.
  241. X */
  242. X
  243. X#include <stdio.h>
  244. X
  245. X#define STRINGSIZE    256
  246. X
  247. Xtypedef unsigned char int8;
  248. Xtypedef unsigned short int int16;
  249. Xtypedef unsigned long int int32;
  250. X#ifndef NUMWORDS
  251. X#define NUMWORDS     16
  252. X#endif
  253. X#define MAXWORDLEN    32
  254. X#define MAXBLOCKLEN     (MAXWORDLEN * NUMWORDS)
  255. X
  256. Xstruct pi_header
  257. X{
  258. X    int32 pih_magic;
  259. X    int32 pih_numwords;
  260. X    int16 pih_blocklen;
  261. X    int16 pih_pad;
  262. X};
  263. X
  264. Xtypedef struct
  265. X{
  266. X    FILE *ifp;
  267. X    FILE *dfp;
  268. X    FILE *wfp;
  269. X
  270. X    int32 flags;
  271. X#define PFOR_WRITE    0x0001
  272. X#define PFOR_FLUSH    0x0002
  273. X#define PFOR_USEHWMS    0x0004
  274. X
  275. X    int32 hwms[256];
  276. X
  277. X    struct pi_header header;
  278. X
  279. X    int count;
  280. X    char data[NUMWORDS][MAXWORDLEN];
  281. X} PWDICT;
  282. X
  283. X#define PW_WORDS(x) ((x)->header.pih_numwords)
  284. X#define PIH_MAGIC 0x70775631
  285. X
  286. Xextern PWDICT *PWOpen();
  287. Xextern char *Mangle();
  288. Xextern char *FascistCheck();
  289. X
  290. X#define CRACK_TOLOWER(a)     (isupper(a)?tolower(a):(a)) 
  291. X#define CRACK_TOUPPER(a)     (islower(a)?toupper(a):(a)) 
  292. X#define STRCMP(a,b)        strcmp((a),(b))
  293. END_OF_FILE
  294.   if test 1262 -ne `wc -c <'cracklib/packer.h'`; then
  295.     echo shar: \"'cracklib/packer.h'\" unpacked with wrong size!
  296.   fi
  297.   # end of 'cracklib/packer.h'
  298. fi
  299. if test -f 'cracklib/stringlib.c' -a "${1}" != "-c" ; then 
  300.   echo shar: Will not clobber existing file \"'cracklib/stringlib.c'\"
  301. else
  302.   echo shar: Extracting \"'cracklib/stringlib.c'\" \(1040 characters\)
  303.   sed "s/^X//" >'cracklib/stringlib.c' <<'END_OF_FILE'
  304. X/*
  305. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  306. X * responsibility or liability with respect to it's usage or its effect 
  307. X * upon hardware or computer systems, and maintains copyright as set out 
  308. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  309. X * and upwards.
  310. X */
  311. X
  312. X#include "packer.h"
  313. X
  314. Xstatic char vers_id[] = "stringlib.c : v2.3p2 Alec Muffett 18 May 1993";
  315. X
  316. Xchar
  317. XChop(string)
  318. X    register char *string;
  319. X{
  320. X    register char c;
  321. X    register char *ptr;
  322. X    c = '\0';
  323. X
  324. X    for (ptr = string; *ptr; ptr++);
  325. X    if (ptr != string)
  326. X    {
  327. X    c = *(--ptr);
  328. X    *ptr = '\0';
  329. X    }
  330. X    return (c);
  331. X}
  332. X
  333. Xchar *
  334. XTrim(string)
  335. X    register char *string;
  336. X{
  337. X    register char *ptr;
  338. X    for (ptr = string; *ptr; ptr++);
  339. X
  340. X    while ((--ptr >= string) && isspace(*ptr));
  341. X
  342. X    *(++ptr) = '\0';
  343. X
  344. X    return (ptr);
  345. X}
  346. X
  347. Xchar *
  348. XClone(string)
  349. X    char *string;
  350. X{
  351. X    register char *retval;
  352. X    retval = (char *) malloc(strlen(string) + 1);
  353. X    if (retval)
  354. X    {
  355. X    strcpy(retval, string);
  356. X    }
  357. X    return (retval);
  358. X}
  359. END_OF_FILE
  360.   if test 1040 -ne `wc -c <'cracklib/stringlib.c'`; then
  361.     echo shar: \"'cracklib/stringlib.c'\" unpacked with wrong size!
  362.   fi
  363.   # end of 'cracklib/stringlib.c'
  364. fi
  365. if test -f 'shadow/obscure.c,CL' -a "${1}" != "-c" ; then 
  366.   echo shar: Will not clobber existing file \"'shadow/obscure.c,CL'\"
  367. else
  368.   echo shar: Extracting \"'shadow/obscure.c,CL'\" \(4157 characters\)
  369.   sed "s/^X//" >'shadow/obscure.c,CL' <<'END_OF_FILE'
  370. X/*
  371. X * Copyright 1989, 1990, 1991, 1992, John F. Haugh II
  372. X * All rights reserved.
  373. X *
  374. X * Permission is granted to copy and create derivative works for any
  375. X * non-commercial purpose, provided this copyright notice is preserved
  376. X * in all copies of source code, or included in human readable form
  377. X * and conspicuously displayed on all copies of object code or
  378. X * distribution media.
  379. X */
  380. X
  381. X#include <ctype.h>
  382. X#ifndef BSD
  383. X#include <string.h>
  384. X#include <memory.h>
  385. X#else
  386. X#include <strings.h>
  387. X#define strchr  index
  388. X#define strrchr rindex
  389. X#endif
  390. X#include "config.h"
  391. X
  392. X#ifndef lint
  393. Xstatic  char    sccsid[] = "@(#)obscure.c       3.6     20:37:32        3/7/92";
  394. X#endif
  395. X
  396. Xextern  int     getdef_bool();
  397. Xextern  int     getdef_num();
  398. X
  399. X#ifdef  NEED_STRSTR
  400. X/*
  401. X * strstr - find substring in string
  402. X */
  403. X
  404. Xchar *
  405. Xstrstr (string, pattern)
  406. Xchar    *string;
  407. Xchar    *pattern;
  408. X{
  409. X    char    *cp;
  410. X    int     len;
  411. X
  412. X    len = strlen (pattern);
  413. X
  414. X    for (cp = string;cp = strchr (cp, *pattern);) {
  415. X        if (strncmp (cp, pattern, len) == 0)
  416. X            return cp;
  417. X
  418. X        cp++;
  419. X    }
  420. X    return 0;
  421. X}
  422. X#endif
  423. X
  424. X/*
  425. X * Obscure - see if password is obscure enough.
  426. X *
  427. X *      The programmer is encouraged to add as much complexity to this
  428. X *      routine as desired.  Included are some of my favorite ways to
  429. X *      check passwords.
  430. X */
  431. X
  432. X/*ARGSUSED*/
  433. Xint     obscure (old, new)
  434. Xchar    *old;
  435. Xchar    *new;
  436. X{
  437. X    int     i;
  438. X    char    oldmono[32];
  439. X    char    newmono[32];
  440. X    char    wrapped[64];
  441. X
  442. X    if (old[0] == '\0')
  443. X        return (1);
  444. X
  445. X    if ( strlen(new) < getdef_num("PASS_MIN_LEN", 0) ) {
  446. X        printf ("Too short.  ");
  447. X        return (0);
  448. X    }
  449. X
  450. X    /*
  451. X     * Remaining checks are optional.
  452. X     */
  453. X    if ( !getdef_bool("OBSCURE_CHECKS_ENAB") )
  454. X        return (1);
  455. X
  456. X    for (i = 0;new[i];i++)
  457. X        newmono[i] = tolower (new[i]);
  458. X
  459. X    for (i = 0;old[i];i++)
  460. X        oldmono[i] = tolower (old[i]);
  461. X
  462. X    if (strcmp (new, old) == 0) {   /* the same */
  463. X        printf ("No Change.  ");
  464. X        return (0);
  465. X    }
  466. X    if (palindrome (newmono, oldmono))      /* a palindrome */
  467. X        return (0);
  468. X
  469. X    if (strcmp (newmono, oldmono) == 0) {   /* case shifted */
  470. X        printf ("Case changes only.  ");
  471. X        return (0);
  472. X    }
  473. X    if (similiar (newmono, oldmono))        /* jumbled version */
  474. X        return (0);
  475. X
  476. X    if (simple (old, new))                  /* keyspace size */
  477. X        return (0);
  478. X
  479. X    strcpy (wrapped, oldmono);
  480. X    strcat (wrapped, oldmono);
  481. X    if (strstr (wrapped, newmono)) {
  482. X        printf ("Rotated.  ");
  483. X        return (0);
  484. X    }
  485. X
  486. X
  487. X/*
  488. X#define CRACKLIB_DICTPATH       "/usr/local/lib/pw_dict"
  489. X*/
  490. X
  491. X#ifdef CRACKLIB_DICTPATH
  492. X    {
  493. X        char *msg;
  494. X
  495. X        if (msg = (char *) FascistCheck(new, CRACKLIB_DICTPATH))
  496. X        {
  497. X            printf("Problem: %s.  ");
  498. X            return(0);
  499. X        }
  500. X    }
  501. X#else
  502. X#error /* You need to edit and uncomment the value of CRACKLIB_DICTPATH */
  503. X*** : this is a syntax error - it ought to balls up most compilers : ***
  504. X#endif /* CRACKLIB_DICTPATH */
  505. X
  506. X    return (1);
  507. X}
  508. X
  509. X/*
  510. X * can't be a palindrome - like `R A D A R' or `M A D A M'
  511. X */
  512. X
  513. X/*ARGSUSED*/
  514. Xint     palindrome (old, new)
  515. Xchar    *old;
  516. Xchar    *new;
  517. X{
  518. X    int     i, j;
  519. X
  520. X    i = strlen (new);
  521. X
  522. X    for (j = 0;j < i;j++)
  523. X        if (new[i - j - 1] != new[j])
  524. X            return (0);
  525. X
  526. X    printf ("A palindrome.  ");
  527. X    return (1);
  528. X}
  529. X
  530. X/*
  531. X * more than half of the characters are different ones.
  532. X */
  533. X
  534. X/*ARGSUSED*/
  535. Xint     similiar (old, new)
  536. Xchar    *old;
  537. Xchar    *new;
  538. X{
  539. X    int     i, j;
  540. X    char    *strchr ();
  541. X
  542. X    for (i = j = 0;new[i] && old[i];i++)
  543. X        if (strchr (new, tolower (old[i])))
  544. X            j++;
  545. X
  546. X    if (i >= j * 2)
  547. X        return (0);
  548. X
  549. X    printf ("Too similiar.  ");
  550. X    return (1);
  551. X}
  552. X
  553. X/*
  554. X * a nice mix of characters.
  555. X */
  556. X
  557. X/*ARGSUSED*/
  558. Xint     simple (old, new)
  559. Xchar    *old;
  560. Xchar    *new;
  561. X{
  562. X    int     digits = 0;
  563. X    int     uppers = 0;
  564. X    int     lowers = 0;
  565. X    int     others = 0;
  566. X    int     size;
  567. X    int     i;
  568. X
  569. X    for (i = 0;new[i];i++) {
  570. X        if (isdigit (new[i]))
  571. X            digits++;
  572. X        else if (isupper (new[i]))
  573. X            uppers++;
  574. X        else if (islower (new[i]))
  575. X            lowers++;
  576. X        else
  577. X            others++;
  578. X    }
  579. X
  580. X    /*
  581. X     * The scam is this - a password of only one character type
  582. X     * must be 8 letters long.  Two types, 7, and so on.
  583. X     */
  584. X
  585. X    size = 9;
  586. X    if (digits) size--;
  587. X    if (uppers) size--;
  588. X    if (lowers) size--;
  589. X    if (others) size--;
  590. X
  591. X    if (size <= i)
  592. X        return 0;
  593. X
  594. X    printf ("Too Simple.  Use a longer password, or a mix of upper\n");
  595. X    printf ("and lower case letters and numerics.  ");
  596. X    return 1;
  597. X}
  598. END_OF_FILE
  599.   if test 4157 -ne `wc -c <'shadow/obscure.c,CL'`; then
  600.     echo shar: \"'shadow/obscure.c,CL'\" unpacked with wrong size!
  601.   fi
  602.   # end of 'shadow/obscure.c,CL'
  603. fi
  604. if test -f 'util/Makefile' -a "${1}" != "-c" ; then 
  605.   echo shar: Will not clobber existing file \"'util/Makefile'\"
  606. else
  607.   echo shar: Extracting \"'util/Makefile'\" \(994 characters\)
  608.   sed "s/^X//" >'util/Makefile' <<'END_OF_FILE'
  609. X###
  610. X# This program is copyright Alec Muffett 1993. The author disclaims all
  611. X# responsibility or liability with respect to it's usage or its effect
  612. X# upon hardware or computer systems, and maintains copyright as set out
  613. X# in the "LICENCE" document which accompanies distributions of Crack v4.0
  614. X# and upwards.
  615. X###
  616. X
  617. X###
  618. X# You MIGHT want to remove "-Bstatic" if you're not on SunOS machines.
  619. X# If you ARE, then leave it and suffer a few extra Kb for security's sake
  620. X###
  621. X
  622. XCFLAGS= -O -I../cracklib '-DCRACKLIB_DICTPATH="$(DICTPATH)"' -Bstatic
  623. XLIBS=    ../cracklib/libcrack.a
  624. X
  625. Xall:    packer unpacker testnum teststr testlib
  626. X    touch all
  627. X
  628. Xpacker: packer.o $(LIBS)
  629. X    cc $(CFLAGS) -o $@ $@.o $(LIBS)
  630. X
  631. Xunpacker: unpacker.o $(LIBS)
  632. X    cc $(CFLAGS) -o $@ $@.o $(LIBS)
  633. X
  634. Xtestnum: testnum.o $(LIBS)
  635. X    cc $(CFLAGS) -o $@ $@.o $(LIBS)
  636. X
  637. Xteststr: teststr.o $(LIBS)
  638. X    cc $(CFLAGS) -o $@ $@.o $(LIBS)
  639. X
  640. Xtestlib: testlib.o $(LIBS)
  641. X    cc $(CFLAGS) -o $@ $@.o $(LIBS)
  642. X
  643. Xclean:
  644. X    -rm *.o all
  645. X    -rm teststr testnum testlib packer unpacker
  646. END_OF_FILE
  647.   if test 994 -ne `wc -c <'util/Makefile'`; then
  648.     echo shar: \"'util/Makefile'\" unpacked with wrong size!
  649.   fi
  650.   # end of 'util/Makefile'
  651. fi
  652. if test -f 'util/mkdict' -a "${1}" != "-c" ; then 
  653.   echo shar: Will not clobber existing file \"'util/mkdict'\"
  654. else
  655.   echo shar: Extracting \"'util/mkdict'\" \(583 characters\)
  656.   sed "s/^X//" >'util/mkdict' <<'END_OF_FILE'
  657. X#!/bin/sh
  658. X
  659. X###
  660. X# This program is copyright Alec Muffett 1993. The author disclaims all
  661. X# responsibility or liability with respect to it's usage or its effect
  662. X# upon hardware or computer systems, and maintains copyright as set out
  663. X# in the "LICENCE" document which accompanies distributions of Crack v4.0
  664. X# and upwards.
  665. X###
  666. X
  667. X### in case of explosion, invoke "sort" with "-T" option pointing to a lot
  668. X### of free space in a directory somewhere.
  669. X
  670. XSORT="sort"
  671. X###SORT="sort -T /tmp"
  672. X
  673. Xcat $* |
  674. X    tr '[A-Z]' '[a-z]' |
  675. X    tr -cd '[\012a-z0-9]' |
  676. X    $SORT |
  677. X    uniq |
  678. X    grep -v '^#' |
  679. X    grep -v '^$'
  680. END_OF_FILE
  681.   if test 583 -ne `wc -c <'util/mkdict'`; then
  682.     echo shar: \"'util/mkdict'\" unpacked with wrong size!
  683.   fi
  684.   chmod +x 'util/mkdict'
  685.   # end of 'util/mkdict'
  686. fi
  687. if test -f 'util/packer.c' -a "${1}" != "-c" ; then 
  688.   echo shar: Will not clobber existing file \"'util/packer.c'\"
  689. else
  690.   echo shar: Extracting \"'util/packer.c'\" \(1107 characters\)
  691.   sed "s/^X//" >'util/packer.c' <<'END_OF_FILE'
  692. X/*
  693. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  694. X * responsibility or liability with respect to it's usage or its effect 
  695. X * upon hardware or computer systems, and maintains copyright as set out 
  696. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  697. X * and upwards.
  698. X */
  699. X
  700. X#include "packer.h"
  701. X
  702. Xint
  703. Xmain(argc, argv)
  704. X    int argc;
  705. X    char *argv[];
  706. X{
  707. X    int32 readed;
  708. X    int32 wrote;
  709. X    PWDICT *pwp;
  710. X    char buffer[STRINGSIZE];
  711. X
  712. X    if (argc <= 1)
  713. X    {
  714. X    fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
  715. X    return (-1);
  716. X    }
  717. X
  718. X    if (!(pwp = PWOpen(argv[1], "w")))
  719. X    {
  720. X    perror(argv[1]);
  721. X    return (-1);
  722. X    }
  723. X
  724. X    wrote = 0;
  725. X
  726. X    for (readed = 0; fgets(buffer, STRINGSIZE, stdin); /* nothing */)
  727. X    {
  728. X        readed++;
  729. X
  730. X    buffer[MAXWORDLEN - 1] = '\0';
  731. X
  732. X    Chop(buffer);
  733. X
  734. X    if (!buffer[0])
  735. X    {
  736. X        fprintf(stderr, "skipping line: %lu\n", readed);
  737. X        continue;
  738. X    }
  739. X
  740. X    if (PutPW(pwp, buffer))
  741. X    {
  742. X        fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);
  743. X    }
  744. X
  745. X    wrote++;
  746. X    }
  747. X
  748. X    PWClose(pwp);
  749. X
  750. X    printf("%lu %lu\n", readed, wrote);
  751. X
  752. X    return (0);
  753. X}
  754. END_OF_FILE
  755.   if test 1107 -ne `wc -c <'util/packer.c'`; then
  756.     echo shar: \"'util/packer.c'\" unpacked with wrong size!
  757.   fi
  758.   # end of 'util/packer.c'
  759. fi
  760. if test -f 'util/testlib.c' -a "${1}" != "-c" ; then 
  761.   echo shar: Will not clobber existing file \"'util/testlib.c'\"
  762. else
  763.   echo shar: Extracting \"'util/testlib.c'\" \(687 characters\)
  764.   sed "s/^X//" >'util/testlib.c' <<'END_OF_FILE'
  765. X/*
  766. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  767. X * responsibility or liability with respect to it's usage or its effect 
  768. X * upon hardware or computer systems, and maintains copyright as set out 
  769. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  770. X * and upwards.
  771. X */
  772. X
  773. X#include "packer.h"
  774. X
  775. Xint
  776. Xmain ()
  777. X{
  778. X    int32 i;
  779. X    char buffer[STRINGSIZE];
  780. X
  781. X    printf("enter potential passwords, one per line...\n");
  782. X
  783. X    while (fgets (buffer, STRINGSIZE, stdin))
  784. X    {
  785. X        char *val;
  786. X    Chop(buffer);
  787. X
  788. X    val = FascistCheck(buffer, CRACKLIB_DICTPATH);
  789. X
  790. X    if (!val)
  791. X    {
  792. X        val = "ok";
  793. X    }    
  794. X    printf ("%s: %s\n", buffer, val);
  795. X    }
  796. X
  797. X    return (0);
  798. X}
  799. END_OF_FILE
  800.   if test 687 -ne `wc -c <'util/testlib.c'`; then
  801.     echo shar: \"'util/testlib.c'\" unpacked with wrong size!
  802.   fi
  803.   # end of 'util/testlib.c'
  804. fi
  805. if test -f 'util/testnum.c' -a "${1}" != "-c" ; then 
  806.   echo shar: Will not clobber existing file \"'util/testnum.c'\"
  807. else
  808.   echo shar: Extracting \"'util/testnum.c'\" \(811 characters\)
  809.   sed "s/^X//" >'util/testnum.c' <<'END_OF_FILE'
  810. X/*
  811. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  812. X * responsibility or liability with respect to it's usage or its effect 
  813. X * upon hardware or computer systems, and maintains copyright as set out 
  814. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  815. X * and upwards.
  816. X */
  817. X
  818. X#include "packer.h"
  819. X
  820. Xint
  821. Xmain ()
  822. X{
  823. X    int32 i;
  824. X    PWDICT *pwp;
  825. X    char buffer[STRINGSIZE];
  826. X
  827. X    if (!(pwp = PWOpen (CRACKLIB_DICTPATH, "r")))
  828. X    {
  829. X    perror ("PWOpen");
  830. X    return (-1);
  831. X    }
  832. X
  833. X    printf("enter dictionary word numbers, one per line...\n");
  834. X
  835. X    while (fgets (buffer, STRINGSIZE, stdin))
  836. X    {
  837. X    char *c;
  838. X
  839. X    sscanf (buffer, "%lu", &i);
  840. X
  841. X    printf ("(word %ld) ", i);
  842. X
  843. X    if (!(c = (char *) GetPW (pwp, i)))
  844. X    {
  845. X        c = "(null)";
  846. X    }
  847. X
  848. X    printf ("'%s'\n", c);
  849. X    }
  850. X
  851. X    return (0);
  852. X}
  853. END_OF_FILE
  854.   if test 811 -ne `wc -c <'util/testnum.c'`; then
  855.     echo shar: \"'util/testnum.c'\" unpacked with wrong size!
  856.   fi
  857.   # end of 'util/testnum.c'
  858. fi
  859. if test -f 'util/teststr.c' -a "${1}" != "-c" ; then 
  860.   echo shar: Will not clobber existing file \"'util/teststr.c'\"
  861. else
  862.   echo shar: Extracting \"'util/teststr.c'\" \(790 characters\)
  863.   sed "s/^X//" >'util/teststr.c' <<'END_OF_FILE'
  864. X/*
  865. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  866. X * responsibility or liability with respect to it's usage or its effect 
  867. X * upon hardware or computer systems, and maintains copyright as set out 
  868. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  869. X * and upwards.
  870. X */
  871. X
  872. X#include "packer.h"
  873. X
  874. Xint
  875. Xmain ()
  876. X{
  877. X    int32 i;
  878. X    PWDICT *pwp;
  879. X    char buffer[STRINGSIZE];
  880. X
  881. X    if (!(pwp = PWOpen (CRACKLIB_DICTPATH, "r")))
  882. X    {
  883. X    perror ("PWOpen");
  884. X    return (-1);
  885. X    }
  886. X
  887. X    printf("enter dictionary words, one per line...\n");
  888. X
  889. X    while (fgets (buffer, STRINGSIZE, stdin))
  890. X    {
  891. X        int32 i;
  892. X
  893. X    Chop(buffer);
  894. X    i = FindPW(pwp, buffer);
  895. X    printf ("%s: %lu%s\n", buffer, i, (i==PW_WORDS(pwp) ? " **** NOT FOUND ****" : ""));
  896. X    }
  897. X
  898. X    return (0);
  899. X}
  900. END_OF_FILE
  901.   if test 790 -ne `wc -c <'util/teststr.c'`; then
  902.     echo shar: \"'util/teststr.c'\" unpacked with wrong size!
  903.   fi
  904.   # end of 'util/teststr.c'
  905. fi
  906. if test -f 'util/unpacker.c' -a "${1}" != "-c" ; then 
  907.   echo shar: Will not clobber existing file \"'util/unpacker.c'\"
  908. else
  909.   echo shar: Extracting \"'util/unpacker.c'\" \(866 characters\)
  910.   sed "s/^X//" >'util/unpacker.c' <<'END_OF_FILE'
  911. X/*
  912. X * This program is copyright Alec Muffett 1993. The author disclaims all 
  913. X * responsibility or liability with respect to it's usage or its effect 
  914. X * upon hardware or computer systems, and maintains copyright as set out 
  915. X * in the "LICENCE" document which accompanies distributions of Crack v4.0 
  916. X * and upwards.
  917. X */
  918. X
  919. X#include "packer.h"
  920. X
  921. Xint
  922. Xmain(argc, argv)
  923. X    int argc;
  924. X    char *argv[];
  925. X{
  926. X    int32 i;
  927. X    PWDICT *pwp;
  928. X    char buffer[STRINGSIZE];
  929. X
  930. X    if (argc <= 1)
  931. X    {
  932. X    fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
  933. X    return (-1);
  934. X    }
  935. X
  936. X    if (!(pwp = PWOpen (argv[1], "r")))
  937. X    {
  938. X    perror ("PWOpen");
  939. X    return (-1);
  940. X    }
  941. X
  942. X    for (i=0; i < PW_WORDS(pwp); i++)
  943. X    {
  944. X        register char *c;
  945. X
  946. X    if (!(c = (char *) GetPW (pwp, i)))
  947. X    {
  948. X        fprintf(stderr, "error: GetPW %d failed\n", i);
  949. X        continue;
  950. X    }
  951. X
  952. X    printf ("%s\n", c);
  953. X    }
  954. X
  955. X    return (0);
  956. X}
  957. END_OF_FILE
  958.   if test 866 -ne `wc -c <'util/unpacker.c'`; then
  959.     echo shar: \"'util/unpacker.c'\" unpacked with wrong size!
  960.   fi
  961.   # end of 'util/unpacker.c'
  962. fi
  963. echo shar: End of archive 2 \(of 2\).
  964. cp /dev/null ark2isdone
  965. MISSING=""
  966. for I in 1 2 ; do
  967.     if test ! -f ark${I}isdone ; then
  968.     MISSING="${MISSING} ${I}"
  969.     fi
  970. done
  971. if test "${MISSING}" = "" ; then
  972.     echo You have unpacked both archives.
  973.     rm -f ark[1-9]isdone
  974. else
  975.     echo You still must unpack the following archives:
  976.     echo "        " ${MISSING}
  977. fi
  978. exit 0
  979. exit 0 # Just in case...
  980.