home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3889 / Crack.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-08-23  |  3.3 KB  |  184 lines

  1. #!/bin/sh
  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. # For Bourne shell version, CRACK home cannot be relative to ~username
  10. # (unless you have a really weird 'sh')
  11. ###
  12.  
  13. CRACK_HOME="/aber/aem/SEC/CRACK32"              # This is an ENVIRONMENT var.
  14. export CRACK_HOME
  15.  
  16. trash="/dev/null"
  17. remote="FALSE"
  18. default_bin="generic"
  19. tmpfile="/tmp/cpwfs.$$"
  20. net_cf="Scripts/network.conf"
  21.  
  22. ###
  23. # Check existance of a home directory
  24. ###
  25.  
  26. if [ -d $CRACK_HOME ]
  27. then
  28.     cd $CRACK_HOME || exit 1
  29. else
  30.     echo "Error: The directory $CRACK_HOME does not exist."
  31.     echo ""
  32.     echo "Please set the value of CRACK_HOME in the Crack script to the CRACK31"
  33.     echo "installation directory."
  34.     echo ""
  35.     echo "The current working directory is" `pwd`
  36.     exit 1
  37. fi
  38.  
  39. ###
  40. # Announce ourselves.
  41. ###
  42.  
  43. echo "Crack 3.2a Password Cracker by ADE Muffett, 1991"
  44.  
  45. ###
  46. # Check that we have arguments
  47. ###
  48.  
  49. if [ "$1" = "" ]
  50. then
  51.     echo "Usage:    $0 [options] [bindir] passwdfile [...]"
  52.     echo "Or:       $0 -network [options] passwdfile [...]"
  53.     echo "With options:-"
  54.     echo "    -v              - to produce verbose output (if configured)"
  55.     echo "    -nnicevalue     - to run niced"
  56.     echo "    -rpointfile     - to recover a crashed-out job"
  57.     echo "    -Rpointfile     - to recover (with verify) a crashed-out job"
  58.     exit 1
  59. fi
  60.  
  61. ###
  62. # Parse command line
  63. ###
  64.  
  65. argl=""
  66.  
  67. while :
  68. do
  69.     case $1 in
  70.         -network)
  71.             if [ ! -f $net_cf ]
  72.             then
  73.                 echo "$0: error: no file $net_cf"
  74.                 exit 1
  75.             fi
  76.             shift
  77.             Scripts/Crack.network $*
  78.             exit 0
  79.             ;;
  80.  
  81.         -remote)
  82.             echo "Invoked: $0 $*"
  83.             set remote="TRUE"
  84.             shift
  85.             ;;
  86.         -v*|-n*|-r*|-R*)
  87.             argl="$argl $1"
  88.             shift
  89.             ;;
  90.         -*)
  91.             echo "Crack: unknown argument $1"
  92.             shift
  93.             ;;
  94.         *)
  95.             break
  96.             ;;
  97.     esac
  98. done
  99.  
  100. ###
  101. # Test first non-switch argument for existance
  102. ###
  103.  
  104. if [ -f "$1" ]
  105. then
  106.     CRACK_ARCH="$CRACK_HOME/$default_bin"
  107.     if [ ! -d $default_bin ]
  108.     then
  109.         echo "Making default binary directory: $default_bin"
  110.         mkdir $default_bin || exit 1
  111.     fi
  112. elif [ -d "$1" ]
  113. then
  114.     CRACK_ARCH="$CRACK_HOME/$1"
  115.     shift
  116. else
  117.     echo "Crack: error: There is no directory or file $1."
  118.     echo "Crack: warning: Creating directory $1"
  119.     mkdir $1 || exit 1
  120.     CRACK_ARCH="$CRACK_HOME/$1"
  121.     shift
  122. fi
  123.  
  124. export CRACK_ARCH                       # This is an ENVIRONMENT var.
  125.  
  126. ###
  127. # Double check the dictionary directory
  128. ###
  129.  
  130. if [ ! -d $CRACK_HOME/Dicts ]
  131. then
  132.     echo "Crack: error: There is no directory or file Dicts."
  133.     echo "Crack: warning: Creating directory Dicts"
  134.     mkdir Dicts || exit 1
  135. fi
  136.  
  137. ###
  138. # Now to tidy up a bit
  139. ###
  140.  
  141. make -f Scripts/crack.mf cleanprogs >/dev/null 2>&1
  142.  
  143. echo "Using binaries in directory: $CRACK_ARCH"
  144.  
  145. cd $CRACK_ARCH || exit 1
  146.  
  147. ###
  148. # Install makefiles if necessary.
  149. ###
  150.  
  151. if [ ! -f Makefile ]
  152. then
  153.     cp $CRACK_HOME/Scripts/install.mf Makefile
  154. fi
  155.  
  156. make crack-pwc || exit 1
  157.  
  158. cd $CRACK_HOME
  159.  
  160. make -f Scripts/crack.mf dictstamp || exit 1
  161.  
  162. ###
  163. # Check how we have been invoked : ergo how we get our data.
  164. ###
  165.  
  166. if [ "$remote" = "TRUE" ]
  167. then
  168.     cat > $tmpfile
  169. else
  170.     Scripts/joinfiles $* > $tmpfile || exit 1
  171. fi
  172.  
  173. echo "Backgrounding program. Output will be written to a file in this directory."
  174.  
  175. nohup $CRACK_ARCH/crack-pwc $argl -i$tmpfile Dicts/dict.* </dev/null >$trash 2>&1 &
  176.  
  177. sleep 1
  178.  
  179. test -f nohup.out && rm nohup.out
  180.  
  181. ###
  182. # There are horrible timeraces involved in removing $tmpfile, so I dont.
  183. ###
  184.