home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / docs / readme.shadow < prev    next >
Text File  |  1992-03-10  |  3KB  |  88 lines

  1.  
  2.   Part of a conversation I had with a guy about cracking shadow passords;
  3. at the end of this is a script that should work with SVR3.2; I'm not
  4. sure about the rest, but minor changes should make it work on
  5. just about anything (for instance, I think on my sun, the variable
  6. $num_fields should be changed to 15 (or you could compile pass.c with
  7. the C2 flag)).  Let me know if you can't get it to work, and I'll
  8. *make* it work :-)  In any case, you'll need to run as root to get the
  9. passwords for cracking.
  10.  
  11. >On system V3.2, both  AT&T, SCO, and us (Interactive) use the following format
  12. > /etc/passwd looks pretty much normal;
  13. > adm:x:4:4:0000-Admin(0000):/usr/adm:
  14. [...]
  15. > except that the passwd field always contains an "x".
  16. > Then, the etc/shadow file, which is owned by root and perms 400 looks
  17. > like;
  18. [...]
  19. > sally:e4T6g5HbjOnck:7449:0:7000
  20. [...]
  21. > The first field is the account name, the second field is the excrypted
  22. > passwd string, and the rest is password aging garbage.
  23. > Ignore the password fields above containing "LOCKED".  I do that by
  24. > hand to secure an account, since the output of crypt will never match it.
  25.  
  26.   Try this on for size:
  27.  
  28. ========== shadow.stuff ================
  29. #!/bin/sh
  30. #
  31. #  Usage: shadow.stuff [shadow_password_file]
  32. #
  33. #   Extracts the correct info from shadow pass to use for processing with
  34. # pass.chk and passwd.chk.
  35. #
  36. # (written by me, modified by John F Haugh II, remodified by me.  Hope
  37. # it still works :-))
  38. #
  39. if test -f "$1" ; then
  40.     shadow=$1
  41. else
  42.     if test -f "/etc/shadow" ; then
  43.         shadow=/etc/shadow
  44.     else
  45.         echo "Can't find shadow password file..."
  46.         exit 1
  47.     fi
  48. fi
  49.  
  50. # This is 15, I think, for a sun?  Others seem to want 13
  51. num_fields=13
  52.  
  53. passwd=/etc/passwd
  54. foo_pass="./shadow.tmp.$$"
  55. ptmp="./pfile.tmp.$$"
  56. stmp="./sfile.tmp.$$"
  57.  
  58. sed -e 's/^/p:/' $passwd | sort > $ptmp
  59. sed -e 's/^/s:/' $shadow | sort > $stmp
  60. cat ./pfile.tmp.$$ ./sfile.tmp.$$ | \
  61.     sort -t':' +1 -2 +0r -1 | \
  62.     sed -e 's/^[sp]://' > $foo_pass
  63.  
  64. awk -F: '{parray[$1] = $0":"parray[$1]} END { \
  65.     for (line in parray) { \
  66.         nf=split(parray[line], pline, ":"); \
  67.         if (nf == '"$num_fields"') {
  68.             print pline[1]":"pline[9]":"pline[3]":"pline[4]":" \
  69.             pline[5]":"pline[6]":"pline[7]; \
  70.                   } \
  71.               } \
  72.         }' $foo_pass
  73.  
  74. rm -f $ptmp $stmp $foo_pass
  75. ==========================================
  76.  
  77.   Ok, the way you use this is just to type "shadow.stuff > tempfile";
  78. this will create a file, "tempfile" (or whatever), that *should*
  79. be the equivalent to a normal password file.  Of course, you'll have
  80. to run this as root so that you can read the shadow password file.
  81. This should work, but no blame if it doesn't, please :-)  Just let
  82. me know if it does or not; I can put it in the normal distribution,
  83. if so.
  84.  
  85.   Hope this helps -- 'luck!
  86.  
  87.  -- dan
  88.