home *** CD-ROM | disk | FTP | other *** search
/ Hacker Chronicles 1 / HACKER1.ISO / phrk3 / phrack25.5 < prev    next >
Text File  |  1992-09-26  |  15KB  |  309 lines

  1.                                 ==Phrack Inc.==
  2.  
  3.                      Volume Three, Issue 25, File 5 of 11
  4.  
  5.         <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  6.         <><><><>                                              <><><><>
  7.         <><><>                Unix Cracking Tips                <><><>
  8.         <><>                                                      <><>
  9.         <>                     by Dark OverLord                     <>
  10.         <><>                                                      <><>
  11.         <><><>                  March 17, 1989                  <><><>
  12.         <><><><>                                              <><><><>
  13.         <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  14.  
  15.  
  16. The purpose of this file is to present tips for budding Unix hackers.  The
  17. audience this is aimed at are those that are experienced at working with basic
  18. Unix, but not in the cracking aspects.
  19.  
  20. Most of the following material is based on actual experience with BSD boxes
  21. (with some help from my friends).  Many of the bugs here may not apply to your
  22. system; your mileage will vary.
  23.  
  24.  
  25. When Cracking A System Remember --
  26.  
  27.      o ALWAYS cover your tracks
  28.      o Don't get caught
  29.      o Don't get malicious
  30.      o Get off as soon as possible
  31.      o Keep a bottle of "Wild Turkey" near the terminal (IMPORTANT!)
  32.  
  33.  
  34. About Logging:  Remember that many systems use paper terminals so that if a
  35. warning message goes to the console, you can't erase it.
  36.  
  37. Hint:  If you know that you are going to be ringing a few bells, you may wish
  38.        to send a bunch of bogus messages to the console so it runs out of paper
  39.        before the important messages get there.
  40.  
  41.  
  42. After you gain superuser privileges and you wish to stay root, here are
  43. a few suggestions for installing backdoors:
  44.  
  45. - Disable checks for superuser in the kernel
  46. - Install new system calls
  47. - Patch a system binary to contain a backdoor
  48. - Leave /dev/mem readable
  49.  
  50.  
  51. An ancient method of extracting data from anything is to sort through its
  52. trash.  The same applies to Unix and newly allocated data.  One trick is to
  53. look for old data in newly allocated data (eg: Allocate a large amount of
  54. memory and search through it for old [useful?] data).  Given enough time and an
  55. intelligent search algorithms, you could find quite a bit of information
  56. including people's passwords and other private stuff like mail, et al.
  57.  
  58.  
  59. If the device "/dev/kmem" is readable, you should be able to write a quick C
  60. program that intercepts the I/O to other terminals and catch other people's
  61. password etc.
  62.  
  63. If the device "/dev/kmem" is writeable, it is possible to change your userid by
  64. editing the user structure.
  65.  
  66.  
  67. A Common Trick:  When looking to gain more system privileges, one of the first
  68. things to investigate are other users' .rhost files since these can be used to
  69. grant access to other accounts without the use of a password.  See the Unix
  70. manual entry for rlogin for more information.
  71.  
  72.  
  73. Another thing to look for are writeable .profile, .cshrc or .logins (to name a
  74. few).  It these are left writeable, it is all too easy to install a Trojan
  75. horse.
  76.  
  77.  
  78. Look for readable .netrc files since these files may contain passwords to other
  79. accounts.
  80.  
  81.  
  82. If the man command is setuid, it might be possible to get a shell by typing
  83. "!/bin/csh" from within the pager.
  84.  
  85.  
  86. Some types of terminals can be "instructed" to issue commands using various
  87. escape sequences.  This makes it possible to mail someone a "letter bomb" that
  88. (when read) will send commands to the user's shell.
  89.  
  90.  
  91. It is possible to mail commands to a system.  This is a feature of the
  92. debugging mode of Unix's sendmail.  This trick was made fairly public through
  93. its use by the Internet Worm.  The way it is done is by connecting to the SMTP
  94. socket/port and turning on the debug mode.  The recipient that is mailed to is
  95. "| sed '1,/$/d' | /bin/sh ; exit 0" and then the commands for the shell are
  96. placed in the body of the letter/data section.
  97.  
  98.  
  99. Under Unix it is trivial to forge mail.  The easiest way this is done is by
  100. connecting to the SMTP port and pretending to be a foreign mailer program.
  101.  
  102.  
  103. Some systems will crash if you issue the command "eval `\!\!`" from within the
  104. C shell (/bin/csh).
  105.  
  106.  
  107. When searching for data, do not forget to look for possible un-mounted file
  108. systems.  [eg:  Look for disk partitions that are unaccounted for.]
  109.  
  110.  
  111. Other things to try are illegal system calls and system calls with
  112. illegal (strange?) arguments.  A good example is the fchown system call
  113. under 4.3-Tahoe Release from Berkeley.  If you give it a negative
  114. number for the group argument it grants permission for you to change
  115. the ownership of any file.  Another example (on many systems) is the
  116. "access" system call used by many, many programs.  Its problem is that
  117. is only checks permissions on the requested file and neglects to check
  118. the permissions of links and directories that lead to the file.  I have
  119. seen some systems that allow any user to use the chroot system call;
  120. this is VERY foolish since all I have to do in construct my own
  121. sub-environment (with my own configuration files) and execute certain
  122. commands from within it.
  123.  
  124.  
  125. Yet another thing to look for are system structures stored in user accessible
  126. memory.  These structures can be modified to suit your purposes.
  127.  
  128.  
  129. Look for sloppy permission/ownership on system directories and on system
  130. configuration files.  These can allow you to modify and/or control many aspects
  131. of system behavior.  Here are a few files to look out for:  "/etc/rc",
  132. "/etc/passwd", "/etc/group", "/etc/profile", "/usr/lib/crontab" or
  133. "/usr/spool/cron/crontabs/*".
  134.  
  135. Hint:  AT&T 3b1 systems are notorious for this problem.
  136.  
  137.  
  138. If the system you are hacking has readable system logfiles and it logs failed
  139. login attempts, a possible leak might be if a user had accidentally typed their
  140. password at the login prompt.  You should scan through these logs looking to
  141. strange and nonexistent account names and use these as the password for users
  142. that logged in around that time (the command "last" will list the login time of
  143. users).
  144.  
  145.  
  146. Check to see if the system has source code on-line.  There is nothing more
  147. useful then having system source code on-line for browsing.  Look for source
  148. code (normally found in the directory /usr/src) and scan it for programming
  149. errors (or download it so you spend less time on the system).
  150.  
  151.  
  152. Look for other people's back doors.  If you can find any, they can make your
  153. life a bit easier.
  154.  
  155.  
  156. Check to see if the system has a good auditing system.  If so, run it since it
  157. may find a few security problems for you.
  158.  
  159.  
  160. Look for setuid shell scripts that may be on the system.  There is no
  161. way way to secure a setuid shell script under the current release of
  162. BSDish Unixes in the current market.  The command "find / -perm -6000 -ls"
  163. will print out all setuid and setgid files on a system.  Look
  164. through this list for setuid shell scripts.  One way in defeating a
  165. setuid script is to make a link named "-i" to the file, then execute
  166. the link.  Another way is to send it a signal at the right moment
  167. during its start up.  The simplest way do this is to
  168. write a quick C program that sets a block on the signal, then sends
  169. itself the signal, and then execs a setuid script. (Note:  The signal
  170. will not be processed because of the block, thus leaving it for the
  171. setuid script).   Either of these bugs should give you an interactive
  172. shell running as the userid of the setuid script.
  173.  
  174.  
  175. If you are familiar with programming with assemblers/dissemblers, you can look
  176. for bugs and/or modify existing software to suit your needs since most
  177. installations do not strip debugging symbols from system binaries and leave the
  178. executables readable.  There is an enormous amount of hacking information that
  179. can be learned this way.
  180.  
  181.  
  182. Under UNIX-V7 & 4.1BSD, programs that were setgid were only a security problem
  183. because if you were able to get them to dump a core file, the core would be
  184. owned by you and setgid to the groupid of the program that generated it.  Since
  185. you owned this file, you could copy a shell of a command script into it and
  186. have it run as the groupid of the file.  This will allow you access to to any
  187. file that is owned by the group.
  188.  
  189.  
  190. If the system you are hacking supports bidirectional modems, it is possible to
  191. use them for stealing passwords.  This can be done by using tip to connect to
  192. the modem and then waiting for a user to call.  When a user calls in, you
  193. simply answer the phone and simulate the login process.  Once the user has
  194. surrendered their password, you simulate line noise and hang up.
  195.  
  196.  
  197. The Unix login program (the program that prompts you for the account name and
  198. password) is tricky in the way that the error message for bad accounts and bad
  199. passwords are the same.  This is to stop account/password guessing.  I guess it
  200. works if your only access to a system is either a terminal line or a modem
  201. connection.  If you have access through a LAN you can check account names with
  202. the finger command.  This neat little Unix goodie will give you all sorts of
  203. information about people's accounts.  If the finger utility is turned off,
  204. there is another way through a program called ftp.  The ftp (File Transfer
  205. Program) command can be used to confirm the existence of a user account/bad
  206. password selection.  I have also noted that the ftp command does not do as much
  207. logging, thus repeated bad password guesses not logged as much via ftp.
  208. [See next section also.]
  209.  
  210.  
  211. If the Unix system you wish to crack is networked via UUCP or TCP/IP, it should
  212. be fairly simple to extract the password file from the remote system using the
  213. ftp utility.  Once you have a copy of the password file, you can simply back
  214. away from the system (thus reducing the chances of getting caught!).
  215.  
  216.  
  217. See Phrack Inc. Issue 22, File 6 -- "Yet Another File On Hacking Unix by
  218. >Unknown User<" for a slow but effective password grinder.
  219.  
  220.  
  221. Another network based attack involves tapping in on the LAN (Local Area
  222. Network) and listening for people's passwords since most systems transmit them
  223. in clear text.
  224.  
  225.  
  226. On systems that disable account logins after N number of bad logins, it is
  227. sometimes useful to use the feature to lock out staff members from logging in
  228. thus giving you [the cracker] more time to clean up after yourself and escape.
  229.  
  230.  
  231. Here are a few bugs in the su (set userid) command that may come in handy:
  232.  
  233. The first was that the "-c" option did not check to see if the user being su'ed
  234. to had a valid shell.  The "-c" option is used to instruct the su command to
  235. run another command instead of a shell [eg:  "su davis -c foobar" tells su to
  236. run foobar instead of davis's default shell].  This comes in handy with
  237. accounts like "sync::0:1::/:/bin/sync" because you can execute any arbitrary
  238. command [eg: su sync -c /bin/csh].
  239.  
  240. Another bug in the su command exists in some System V ports where if su was
  241. unable to open the password file ("etc/passwd"), it would grant root access
  242. (without checking the reason for the failure).  I guess the programming can
  243. tell that something is wrong and grants access so someone can fix things.  The
  244. security problem occurs when when su is executed with a full file descriptor
  245. table; this will force su to fail its open request on the password file.
  246.  
  247.  
  248. Some Unix system's mkdir (MaKe DIRectory) command can be subverted into aiding
  249. you in gaining root.  This is done by exploiting a race condition that can
  250. occur between processes.  The following command script will eventually cause
  251. the error to occur and cause the password file to be owned by you:
  252.  
  253.     while : ; do
  254.         nice -10 (mkdir a;rm -fr a) &
  255.         (rm -fr a; ln /etc/passwd a) &
  256.     done
  257.  
  258. The race condition happens when the "ln" command runs while the mkdir command
  259. is in the middle of running.  This works because the mkdir does its job by
  260. doing the two system calls:  mknod and then chown.  If the now inode (allocated
  261. by mknod) is replaced with a link to the password file before the chown system
  262. call is made, then the password file is "chown"ed instead.  To become root from
  263. here, all you have to do is add a new entry into the password file.
  264.  
  265.  
  266. The print command ("lpr" or "lp") has an option to delete a file after it is
  267. printed.  This option will work (print & delete the file) even if you do not
  268. own the file.
  269.  
  270.  
  271. The mail command has the option to save your mail after you read to another
  272. file.  Some versions of this command will save (append) your mail to a file
  273. after it is read.  A bug exists where the mail program does not check to see if
  274. you have write permission to the file you are saving the mail to, thus allowing
  275. you to (for example) add new accounts to the password file.
  276.  
  277.  
  278. A quick word on the crypt command (and vi -x since it uses the crypt command):
  279. The algorithm used is not hard to break (it takes about twenty minutes to
  280. decrypt a file with the right tools).  See the "Bell Systems Technical
  281. Journal," Vol. 63, 8, part 2 for more information.
  282.  
  283.  
  284. If the UUCP configuration files are readable [default on many systems], you can
  285. obtain the login names, passwords, and phone numbers to all of the mail links
  286. to and from the system you are hacking.  With the use of the a public domain
  287. program, "uupc", you can make the connections yourself and intercept and/or
  288. filter all incoming mail.
  289.  
  290. There are so many ways to crack Unix just through UUCP that I am not going to
  291. expand and list the many ways and their permutations.  Instead, I am going to
  292. save them for an article to be done at some random time in the future.
  293.  
  294.  
  295. If you are hacking on a system that supports sharable memory you may be able to
  296. access these memory segments.  On Sun systems, there is a command called ipcs.
  297. This command lists available sharable memory segments.  If this command does
  298. not exist (nor has a equivalent command available), you may have to either
  299. write one or use blind exploration.  Once you have identified these segments,
  300. you can gain control to the data contained therein and/or other programs
  301. utilizing the data contained within.
  302.  
  303.  
  304. If you are caught:  Grasp the bottle of "Wild Turkey" (the one near your
  305. terminal) and drink it.
  306. _______________________________________________________________________________
  307.  
  308. Downloaded From P-80 International Information Systems 304-744-2253 12yrs+
  309.