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

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                     "Crack Version 3.2"
  11.            A Sensible Password Checker for UNIX-
  12.  
  13.  
  14.                      Alec D.E. Muffett
  15.  
  16.          Computer Unit, University College of Wales
  17.                 Aberystwyth, Wales, SY23 3DB
  18.                        aem@aber.ac.uk
  19.                        +44 970 622492
  20.  
  21.  
  22.                           ABSTRACT
  23.  
  24.           Crack[1]  is  a  freely   available   program
  25.      designed to find standard UNIX eight-character DES
  26.      encrypted passwords  by  standard  guessing  tech-
  27.      niques outlined below.  It is written to be flexi-
  28.      ble, configurable and fast, and to be able to make
  29.      use  of  several  networked hosts via the Berkeley
  30.      rsh program (or similar), where possible.
  31.  
  32.  
  33.  
  34. 1.  Intent of this program
  35.  
  36. My intentions, whilst writing this program, were
  37.  
  38. 1)   To provide the average system manager  with  a  simple,
  39.      flexible and fast tool to find passwords which would be
  40.      easily compromised by a dictionary search.
  41.  
  42. 2)   To weaken the complacency which has  developed  amongst
  43.      many (in)?experienced UNIX systems managers about pass-
  44.      word security. Just because the crypt() function cannot
  45.      be  reversed  does  not  mean  that  your passwords are
  46.      secure.  If this program helps  to  raise  the  overall
  47.      quotient  of paranoia just one little bit, then it will
  48.      have served its purpose and is all to the good.
  49.  
  50. I am quite certain that some childish morons out there  will
  51. abuse  the  work that I have put into creating this program.
  52. It's up to them how they use it, but if it's used  for  some
  53. illegal  purpose it's not my intention, nor my fault. I hope
  54. _________________________
  55.   [0]
  56. - UNIX is a trademark of Bell Laboratories.
  57.   [1] Crack  is  available  for  anonymous   FTP   from
  58. wuarchive.wustl.edu (128.252.135.4) in ~/packages
  59.  
  60.  
  61.  
  62.  
  63.                       August 21, 1991
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                            - 2 -
  70.  
  71.  
  72. they get caught.
  73.  
  74. Crack was not designed to do anything nasty, other  than  to
  75. attack  passwords  in  sensible order.  This is why I feel I
  76. can post it to the net without fear of  recrimination.  This
  77. version  of  Crack  is  supplied with a (hopefully) portable
  78. version of fcrypt(), for speed reasons.  Fcrypt() is not yet
  79. widely  available, but several versions have now been posted
  80. to USENET, and with the growing ability to access  anonymous
  81. FTP  databases like Archie, I believe that people who really
  82. want access to such programs as fcrypt() will be able to get
  83. them  easily.   People who need them but don't have the time
  84. to look, on the other hand, will not get them.  This is  not
  85. a  good thing if you are a systems manager, because it gives
  86. the crackers an advantage.  My philosophy  is:  give  it  to
  87. everyone, then at least the people who need it can get it.
  88.  
  89. 2.  Fcrypt() Statistics
  90.  
  91. The version of fcrypt() that comes with Crack  is  some  3.4
  92. times  faster  than the version that was originally supplied
  93. to me, and should outperform most others which are  publicly
  94. available.   I  haven't tried many speed-demon style tricks,
  95. but rather I have gone for portability, elegance and simpli-
  96. city,  where  applicable  8-).   On  a  DECStation 5000/200,
  97. fcrypt() iterates ~550 times  per  second,  and  overall,  I
  98. measure  this  to  be 13 times faster than standard crypt().
  99. There are faster versions available, but  at  least  I  feel
  100. free  to  redistrubute this version without stepping on any-
  101. ones toes.
  102.  
  103. A final note about my motives: If you  think  that  I  am  a
  104. moron  for  writing  and then distributing this program, and
  105. you think that the program is in itself dangerous, I suggest
  106. that  you  carefully  consider the fact that any moron could
  107. have written this program.  Flames to /dev/null, please.
  108.  
  109. 3.  Implementation
  110.  
  111. I have tried to make Crack as portable as  possible  without
  112. compromising speed.  Needless to say, it is imperfect in the
  113. this respect, but I have tried.  If you have  problems  get-
  114. ting  Crack up, please let me know what these problems were,
  115. and what system you were  trying  to  put  Crack  up  on.  I
  116. believe  that  Crack will work on Xenix and various versions
  117. of System V, but it may require a little effort if your UNIX
  118. is not fairly modern.
  119.  
  120. There have been some nasty stories sent  back  to  me  about
  121. problems  encountered  due to the Crack script being written
  122. in c-shell.  Because of this, I enclose a  program  Crack.sh
  123. which  is  a functionally equivalent script in Bourne shell,
  124. using nohup to kick the cracker off into the background.  If
  125. your  version of c-shell is non standard (ie: not BSDish) or
  126.  
  127.  
  128.  
  129.                       August 21, 1991
  130.  
  131.  
  132.  
  133.  
  134.  
  135.                            - 3 -
  136.  
  137.  
  138. you are worried, you may  use  Crack.sh  in  Crack's  place.
  139. Note,  though,  that if you want to use the network options,
  140. you will also have to  edit  Scripts/RCrack  to  change  the
  141. program-name  that is called on remote machines to Crack.sh.
  142. For more on this, see below.
  143.  
  144. To use the Crack -network option, you must have  rsh,  or  a
  145. similar  program.  rsh  is a BSD-ism which has become fairly
  146. common on non-BSD systems.  If you don't have  it  or  some-
  147. thing  similar,  let  me  know what you do have which might,
  148. with a little ingenuity, do the job, and I shall see what  I
  149. can do.  Again, have a look in Scripts/RCrack if you want to
  150. play around.
  151.  
  152.      Note: Xenix users and some others have a rcmd pro-
  153.      gram  instead of rsh.  I'm not sure of the correct
  154.      syntax for this program, but it should not be hard
  155.      to  get  it  to work.  There is a note about it in
  156.      Scripts/RCrack
  157.  
  158.      On such System V based systems, users may also  be
  159.      missing  the  BSD function gethostname().  If this
  160.      is so, but you do have the  uname()  system  call,
  161.      define  the  macro  CRACK_UNAME  in Sources/conf.h
  162.      instead. This ought to fix the problem, but it may
  163.      need  a little user intervention first (it depends
  164.      where your header file for  uname()  is).   Caveat
  165.      Emptor!
  166.  
  167. 4.  Method of Password Cracking
  168.  
  169. Crack does not take the serial approach to password guessing
  170. that  other  programs  like  the COPS password cracker does.
  171. Rather, Crack makes two  passes  over  the  users'  password
  172. entries.
  173.  
  174. The first pass bases its guesses  on  the  contents  of  the
  175. gecos field (containing the users' real name), and the user-
  176. name itself.  The first pass is fast and usually very fruit-
  177. ful, and completes quite quickly.  You would be surprised at
  178. the number of spods out there who  still  think  that  their
  179. middle name, backwards and capitalised, is a good password.
  180.  
  181. The second pass is made by encrypting several  pre-processed
  182. dictionaries  on  the  fly,  and  comparing the results with
  183. users passwords.  Crack optimises the number of calls to the
  184. encryption  function  by sorting the user passwords by their
  185. encryption salt before loading,  so  that  the  dictionaries
  186. only  have  to  be  encrypted  once for each different salt.
  187. This generally saves about 30% of the calls you  would  have
  188. to make to crypt().
  189.  
  190. The preprocessed dictionaries are  created  my  merging  the
  191. source  dictionaries found in the directory DictSrc and then
  192.  
  193.  
  194.  
  195.                       August 21, 1991
  196.  
  197.  
  198.  
  199.  
  200.  
  201.                            - 4 -
  202.  
  203.  
  204. truncating, sorting and uniq'ing the output from the prepro-
  205. cessor.   The default dictionaries named are /usr/dict/words
  206. which  provides  the   bulk   of   the   input   data,   and
  207. DictSrc/bad_pws.dat  which  is meant to provide all of those
  208. non-dictionary passwords, such as 12345678 or qwerty.[2]
  209.  
  210. If you wish to add a dictionary of your own,  just  copy  it
  211. into  the  DictSrc directory and then delete the contents of
  212. the Dicts directory.  Your new dictionary will be merged  in
  213. on the next run.  Do not worry about replication of data, as
  214. the preprocessor driver script sorts  and  uniq's  the  data
  215. before putting it into the Dicts directory.
  216.  
  217. The formats of the output dictionaries are:
  218.  
  219. a)   Unique words that have been forced lowercase, forwards.
  220.      These are the most common passwords you will find, thus
  221.      they are tried first.
  222.  
  223. b)   Dictionary words which have been  artificially  plural-
  224.      ised, because not many dictionaries contain plurals.
  225.  
  226. c)   Dictionary words which were supplied in mixed-case (eg:
  227.      Capitalised).
  228.  
  229. d)   Dictionary words forced lowercase and backwards.
  230.  
  231. e)   Dictionary words, forced lowercase, with a  leading  or
  232.      trailing  0  or  1  (this  may  be  extended by hacking
  233.      Sources/crack-pp.c).
  234.  
  235. f)   Dictionary words, forced uppercase, forwards.
  236.  
  237. g)   Dictionary words, forced uppercase, backwards.
  238.  
  239. h)   Dictionary words which  were  supplied  in  mixed-case,
  240.      backwards (eg: desilatipaC).
  241.  
  242.  
  243. This choice of attack is entirely  empirical,  my  own,  and
  244. made up on the spot.  It has also been horrendously success-
  245. ful, and because Crack uses each of  these  dictionaries  in
  246. turn,  it  tends to get passwords faster than a program like
  247. the COPS password cracker which tries words  every-which-way
  248. for each user.[3]
  249. _________________________
  250.   [2] Extra dictionaries (those used in Dan Klein's pa-
  251. per,  below)  can  be  obtained  via anonymous FTP from
  252. uunet.uu.net (192.48.96.2) as ~/pub/dictionaries.tar.Z
  253.   [3] For more information, see "Foiling the Cracker: A
  254. Survey of, and Improvements to, Password  Security"  by
  255. Daniel Klein, available from major FTP sites.
  256.  
  257.  
  258.  
  259.  
  260.                       August 21, 1991
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                            - 5 -
  267.  
  268.  
  269.      Optimisation  Note:  Crack  has  an   compile-time
  270.      option,  called CRACK_SHORT_PASSWDS, which, if not
  271.      defined, makes the dictionary  preprocessor  throw
  272.      away  words which are less than 5 characters long.
  273.      The reasoning for this is that many sites, with  a
  274.      semi-sensible  passwd program, will not have pass-
  275.      words shorter than 5 characters long.
  276.  
  277.      It is up to you whether you bother  testing  these
  278.      short passwords, but I would recommend that you do
  279.      so at least once, to be safe.  (Setting the option
  280.      also  leads  to  having smaller pre-processed dic-
  281.      tionaries.  The option,  however,  is  defined  by
  282.      default)
  283.  
  284. 5.  Installation
  285.  
  286. Crack is one of those most  unusual  of  beasties,  a  self-
  287. installing   program.    Once  the  necessary  configuration
  288. options have been  set,  the  executables  are  created  via
  289. 'make' by running the main shellscript.
  290.  
  291. Some people have complained about this  apparent  weirdness,
  292. but  it has grown up with Crack ever since the earliest net-
  293. work version, when I could  not  be  bothered  to  log  into
  294. several  different machines with several different architec-
  295. tures, just in order to build the binaries.
  296.  
  297. Crack needs to know where it  has  been  installed.   Please
  298. edit the CRACK_HOME variable in the Crack shellscript to the
  299. correct value.  This variable should be set to  an  absolute
  300. path name (relative to ~user is OK) through which the direc-
  301. tory containing Crack may be accessed on  all  the  machines
  302. that Crack will be run on.
  303.  
  304. The other bit of installation you will have to do is  decide
  305. whether you will want to use the -network option. If you do,
  306. edit the file Sources/conf.h and  define  the  CRACK_NETWORK
  307. symbol.  This forces Crack to create all of its output files
  308. with an embedded hostname  (obtained  by  the  gethostname()
  309. routine)  so that you can keep track of output from all over
  310. the network.  If  you  have  no  gethostname()  but  have  a
  311. uname()  system  call, you can use that instead, by defining
  312. CRACK_UNAME in Sources/conf.h.
  313.  
  314. You will then have to generate a Scripts/network.conf  file.
  315. This  contains  a  list  of  hostnames to rsh to, what their
  316. binary type is (useful  when  running  a  network  Crack  on
  317. several  different  architectures),  a  guesstimate of their
  318. relative power (take your  slowest  machine  as  unary,  and
  319. measure  all  others relative to it), and a list of per-host
  320. default flags.  There is an example of such a file  provided
  321. in the Scripts directory - take a look at it.
  322.  
  323.  
  324.  
  325.  
  326.                       August 21, 1991
  327.  
  328.  
  329.  
  330.  
  331.  
  332.                            - 6 -
  333.  
  334.  
  335. I also recommend that you play around with the  #defines  in
  336. the  file  Sources/conf.h.   Each  switch  has  a small note
  337. explaining its meaning.  Where I've been in doubt about  the
  338. portability  of  certain library functions, usually I've re-
  339. written it, so it shouldn't be much of a  problem.   Let  me
  340. know of your problems. 8-).
  341.  
  342. 6.  Crack Usage
  343.  
  344.  
  345. Crack [options] [bindir] /etc/passwd [...other passwd files]
  346.  
  347. Crack -network [options] /etc/passwd [...other passwd files]
  348.  
  349.  
  350. Where bindir is the optional name of the directory where you
  351. want  the binaries installed.  This is useful where you want
  352. to be able to run versions of  Crack  on  several  different
  353. architectures.  If  bindir does not exist, a warning will be
  354. issued, and the directory, created.
  355.  
  356.      Note: bindir defaults to the name generic  if  not
  357.      supplied.
  358.  
  359.      Yellow Pages (NIS) Users: I have had some  queries
  360.      about  how to get Crack running from a YP password
  361.      file.  There are several methods, but by  far  the
  362.      simplest  is  to  generate a passwd format file by
  363.      running:-
  364.  
  365.                     ypcat passwd > passwd.yp
  366.  
  367.      and then running Crack on this file.
  368.  
  369. 7.  Options
  370.  
  371. -network
  372.      Throws Crack into network mode, in which it  reads  the
  373.      Scripts/network.conf file, splits its input into chunks
  374.      which are sized according to the power  of  the  target
  375.      machine,  and  calls  rsh to run Crack on that machine.
  376.      Options for Crack running on the target machine may  be
  377.      supplied  on  the  command line (eg: verbose or recover
  378.      mode), or in the network.conf file if they  pertain  to
  379.      specific hosts (eg: nice() values).
  380.  
  381. -v   Sets verbose mode, whereby Crack will print every guess
  382.      it is trying on a per-user basis.  This is a very quick
  383.      way of flooding your filestore.  If  you  undefine  the
  384.      CRACK_VERBOSE  symbol  in  Sources/conf.h, verbose mode
  385.      will be permanently disabled.
  386.  
  387. -nvalue
  388.      Sets the process to be nice()ed to value, so  that  the
  389.  
  390.  
  391.  
  392.                       August 21, 1991
  393.  
  394.  
  395.  
  396.  
  397.  
  398.                            - 7 -
  399.  
  400.  
  401.      switch -n19 sets the Crack process to run at the lowest
  402.      priority.
  403.  
  404. -rpointfile
  405.      This is only for use  when  running  in  recover  mode.
  406.      When  a  running  Crack  starts pass 2, it periodically
  407.      saves  its  state  in  a  file  named  point.<pid>   or
  408.      point.<hostname>.<pid> depending on your naming conven-
  409.      tion (see "Installation", above).   This  file  can  be
  410.      used  to  recover  where  you were should a host crash.
  411.      Simply invoke Crack in exactly the same manner  as  the
  412.      last  time,  with the addition of the -rpoint.file.name
  413.      switch.  Crack will startup and read the file, and jump
  414.      to  slightly  before  where  it  left  off.  If you are
  415.      cracking a very large  password  file,  this  can  save
  416.      oodles of time after a crash.
  417.  
  418.      If you are running a network Crack, then the  jobs
  419.      will again be spawned onto all the machines of the
  420.      original Crack.  The program will then check  that
  421.      the  host  it is running on is the same as is men-
  422.      tioned in the pointfile.  If it is  not,  it  will
  423.      silently  die.  Thus, assuming that you supply the
  424.      same  input  data   and   do   not   change   your
  425.      network.conf  file,  Crack  should pick up exactly
  426.      where it left off.  This is a bit  inelegant,  but
  427.      it's better than nothing at the moment.
  428.  
  429. 8.  Multiprocessing and parallelism
  430.  
  431. The method of error recovery outlined above causes headaches
  432. for  users who want to do multiprocessing on parallel archi-
  433. tectures.  Crack is in no way parallel, and because  of  the
  434. way  it's  structured,  readind stdin from shellscript fron-
  435. tends, it is a pain  to  divide  the  work  amongst  several
  436. processes via fork()ing.
  437.  
  438. The hack solution to get several copies of Crack running  on
  439. one  machine  with n processors at the moment is to run with
  440. the CRACK_NETWORK option enabled, and insert n copies of the
  441. entry     for     your    parallel    machine    into    the
  442. Scripts/network.conf file. If you use the -r option in these
  443. circumstances   however,  you  will  get  n  copies  of  the
  444. recovered process running, only one of them  will  have  the
  445. correct  input data.  I'm working on this.  My current solu-
  446. tion is to save the current username in the checkpoint file,
  447. and  test  it  on  startup,  but  doing  this may break your
  448. recovery if you supply different input  data  (so  that  the
  449. data  is  sorted even slightly differently).  Hohum.  If you
  450. want to use this verify username facility, use -R  in  place
  451. of -r.
  452.  
  453. As for not using the network.conf file to provide  multipro-
  454. cessing, I'm working on it.
  455.  
  456.  
  457.  
  458.                       August 21, 1991
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                            - 8 -
  465.  
  466.  
  467. 9.  Notes on fast crypt() implementations
  468.  
  469. The stdlib version of the crypt() subroutine  is  incredibly
  470. slow.   It is a massive bottleneck to the execution of Crack
  471. and on typical platforms that you get at universities, it is
  472. rare to find a machine which will achieve more than 50 stan-
  473. dard crypt()s per second.  On low-end diskless workstations,
  474. you  may  expect 2 or 3 per second.  It was this slowness of
  475. the crypt() algorithm which originally supplied much of  the
  476. security UNIX needed.[4]
  477.  
  478. However, there are now many implementations of  faster  ver-
  479. sions  of  crypt() to be found on the network.  The one sup-
  480. plied with Crack v3.2 and upwards is called fcrypt().
  481.  
  482. fcrypt() was  originally  written  in  May  1986  by  Robert
  483. Baldwin at MIT, and is a good version of the crypt() subrou-
  484. tine.  I received a copy from Icarus Sparry at Bath  Univer-
  485. sity,  who  had made a couple of portability enhancements to
  486. the code.
  487.  
  488. I rewrote most of the tables and the KeySchedule  generating
  489. algorithm  in  the original fdes-init.c to knock 40% off the
  490. execution overhead of fcrypt()  in  the  form  that  it  was
  491. shipped  to  me.   I inlined a bunch of stuff, put it into a
  492. single file, got  some  advice  from  Matt  Bishop  and  Bob
  493. Baldwin  [both  of whom I am greatly indebted to] about what
  494. to do to the xform() routine  and  to  the  fcrypt  function
  495. itself, and tidied up some algorithms.  I've also added more
  496. lookup tables and reduced several formula  for  faster  use.
  497. fcrypt()  is  now  barely recognisable as being based on its
  498. former incarnation.
  499.  
  500. On a DecStation 5000/200, it is also ~13 times  faster  than
  501. the  standard crypt (your mileage may vary with other archi-
  502. tectures and compilers).  This speed puts fcrypt() into  the
  503. "moderately fast" league of crypt implementations.  By using
  504. fcrypt() with Crack, I extracted 135 passwords from my stan-
  505. dard 1087 user password file in a little over 1 hour using 3
  506. networked machines.  This is from a moderately good password
  507. file.
  508.  
  509. Why am I saying this sort of thing ? Am I  scaremongering  ?
  510. In a word, yes.
  511.  
  512. If a fast version of crypt() is wired into  a  program  like
  513. Crack it can break a poorly passworded site open in minutes.
  514. There are such programs available, eg: the "Killer  Cracker"
  515. written  by the anonymous "Doctor Dissector", with anonymous
  516. motives.  It comes with  a  modified  version  of  Baldwin's
  517. _________________________
  518.   [4] See: "Password Security, A Case History"  by  Bob
  519. Morris & Ken Thomson, in the UNIX Programmer Docs.
  520.  
  521.  
  522.  
  523.                       August 21, 1991
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                            - 9 -
  530.  
  531.  
  532. fcrypt, as a MS-DOS executable with a GNU copyleft licence.
  533.  
  534. The point that needs to be  hammered  home  is  that  unless
  535. something  is done, and done soon, about the general quality
  536. of passwords on UNIX systems, then in the  near  future  our
  537. doors  will  be  wide  open to people who have programs like
  538. Crack and questionable motives.
  539.  
  540. 10.  Solutions and Conclusions
  541.  
  542. What can be done about this form of attack ?
  543.  
  544. You must get  a  drop-in  replacement  for  the  passwd  and
  545. yppasswd  commands; one which will stop people from choosing
  546. bad passwords in the first place.  There  are  several  pro-
  547. grams  to  do this; Matt Bishop's passwd+ and Clyde Hoover's
  548. npasswd program are good examples which  are  freely  avail-
  549. able.   Consult an Archie database for more details on where
  550. you can get them from.
  551.  
  552. A little common-sense is all that is required to  vet  pass-
  553. words:   I   enclose  a  module  in  the  Sources  directory
  554. goodpass.c which I use in a modified version of the yppasswd
  555. in order to provide some security.  It is quite heavily cus-
  556. tomised for use in the UK, but it should be easily portable.
  557. The routine is invoked:
  558.  
  559.  
  560.            char *retval = GoodPass(char *input);
  561.  
  562.  
  563. where input is the password under test, and retval  will  be
  564. set  either to NULL (if the password is OK) or to a diagnos-
  565. tic string which says what is wrong with the  password.   It
  566. is far less complex than a system such as passwd+, but still
  567. effective enough to make a password  file  withstand  Crack.
  568. It would be nice if an organisation (such as CERT?) could be
  569. persuaded to supply skeletons of  sensible  passwd  commands
  570. for  the  public  good,  as  well  as an archive of security
  571. related utilities[5] on top of the excellent COPS.  However,
  572. for UNIX security to improve on a global scale, we will also
  573. require pressure on the vendors, so that programs are  writ-
  574. ten correctly from the beginning.
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581. _________________________
  582.   [5] COPS  is  available  for   anonymous   FTP   from
  583. cert.sei.cmu.edu (128.237.253.5) in ~/cops
  584.  
  585.  
  586.  
  587.  
  588.                       August 21, 1991
  589.  
  590.  
  591.