home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3892 / Crack < prev   
Encoding:
Text File  |  1991-08-23  |  3.8 KB  |  168 lines

  1. #!/bin/csh
  2.  
  3. ###
  4. # This program written by ADE Muffett (aem@aber.ac.uk), August 1991,
  5. # as part of the 'Crack' password cracking package.
  6. ###
  7.  
  8. ###
  9. # You must put DOUBLE QUOTES around this is you work relative to ~username
  10. ###
  11.  
  12. setenv CRACK_HOME "~aem/SEC/CRACK32"
  13.  
  14. set trash="/dev/null"
  15. set remote="FALSE"
  16. set default_bin="generic"
  17. set tmpfile="/tmp/cpwfs.$$"
  18. set net_cf="Scripts/network.conf"
  19.  
  20. ###
  21. # Check existance of a home directory
  22. ###
  23.  
  24. if ( -d $CRACK_HOME ) then
  25.     cd $CRACK_HOME || exit 1
  26. else
  27.     echo "Error: The directory $CRACK_HOME does not exist."
  28.     echo ""
  29.     echo "Please set the value of CRACK_HOME in the Crack script to the CRACK31"
  30.     echo "installation directory."
  31.     echo ""
  32.     echo "The current working directory is" `pwd`
  33.     exit 1
  34. endif
  35.  
  36. ###
  37. # Announce ourselves.
  38. ###
  39.  
  40. echo "Crack 3.2a Password Cracker by ADE Muffett, 1991"
  41.  
  42. ###
  43. # Check that we have arguments
  44. ###
  45.  
  46. if ( "$1" == "" ) then
  47.     echo "Usage:    $0 [options] [bindir] passwdfile [...]"
  48.     echo "Or:       $0 -network [options] passwdfile [...]"
  49.     echo "With options:-"
  50.     echo "    -v              - to produce verbose output (if configured)"
  51.     echo "    -nnicevalue     - to run niced"
  52.     echo "    -rpointfile     - to recover a crashed-out job"
  53.     echo "    -Rpointfile     - to recover (with verify) a crashed-out job"
  54.     exit 1
  55. endif
  56.  
  57. ###
  58. # Parse command line
  59. ###
  60.  
  61. set argl=()
  62.  
  63. while ( 1 )
  64.     switch ( $1 )
  65.         case -network:          # push onto the remote machines
  66.             if ( ! -f $net_cf ) then
  67.                 echo "$0: error: no file $net_cf"
  68.                 exit 1
  69.             endif
  70.             shift
  71.             Scripts/Crack.network $*
  72.             exit 0
  73.             breaksw         # redundant
  74.         case -remote:           # This is being called remotely
  75.             echo "Invoked: $0 $*"
  76.             set remote="TRUE"
  77.             shift
  78.             breaksw
  79.         case -v*:                       # verbose
  80.         case -n*:                       # nice
  81.         case -r*:                       # recover
  82.         case -R*:                       # recover/verify
  83.             set argl=($argl $1)
  84.             shift
  85.             breaksw
  86.         case -*:                        # anything else
  87.             echo "Crack: unknown argument $1"
  88.             shift
  89.             breaksw
  90.         default:
  91.             break
  92.             breaksw                 # redundant
  93.     endsw
  94. end
  95.  
  96. ###
  97. # Test first non-switch argument for existance
  98. ###
  99.  
  100. if ( -f "$1" ) then
  101.     setenv CRACK_ARCH $CRACK_HOME/$default_bin
  102.     if ( ! -d $default_bin ) then
  103.         echo "Making default binary directory: $default_bin"
  104.         mkdir $default_bin || exit 1
  105.     endif
  106. else if ( -d "$1" ) then
  107.     setenv CRACK_ARCH $CRACK_HOME/$1
  108.     shift
  109. else
  110.     echo "Crack: error: There is no directory or file $1."
  111.     echo "Crack: warning: Creating directory $1"
  112.     mkdir $1 || exit 1
  113.     setenv CRACK_ARCH $CRACK_HOME/$1
  114.     shift
  115. endif
  116.  
  117. ###
  118. # Double check the dictionary directory
  119. ###
  120.  
  121. if ( ! -d $CRACK_HOME/Dicts ) then
  122.     echo "Crack: error: There is no directory or file Dicts."
  123.     echo "Crack: warning: Creating directory Dicts"
  124.     mkdir Dicts || exit 1
  125. endif
  126.  
  127. ###
  128. # Now to tidy up a bit
  129. ###
  130.  
  131. make -f Scripts/crack.mf cleanprogs >& /dev/null
  132.  
  133. echo "Using binaries in directory: $CRACK_ARCH"
  134.  
  135. cd $CRACK_ARCH || exit 1                        # Can we get there from here ?
  136.  
  137. ###
  138. # Install makefiles if necessary.
  139. ###
  140.  
  141. if ( ! -f Makefile ) then                       # Has it a Makefile ?
  142.     cp $CRACK_HOME/Scripts/install.mf Makefile
  143. endif
  144.  
  145. make crack-pwc || exit 1                        # Check binaries are OK
  146.  
  147. cd $CRACK_HOME                                  # Get back to home base
  148.  
  149. make -f Scripts/crack.mf dictstamp || exit 1    # Make the dictionaries
  150.  
  151. ###
  152. # Check how we have been invoked : ergo how we get our data.
  153. ###
  154.  
  155. if ( "$remote" == "TRUE" ) then
  156.     cat > $tmpfile                                  # Use stdin
  157. else
  158.     Scripts/joinfiles $* > $tmpfile || exit 1       # Process the passwords
  159. endif
  160.  
  161. echo "Backgrounding program. Output will be written to a file in this directory."
  162.  
  163. $CRACK_ARCH/crack-pwc $argl -i$tmpfile Dicts/dict.* < /dev/null >& $trash &
  164.  
  165. ###
  166. # There are horrible timeraces involved in removing $tmpfile, so I dont.
  167. ###
  168.