home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / general / comsec.faq < prev    next >
Encoding:
Text File  |  2003-06-11  |  12.1 KB  |  277 lines

  1. Archive-name: computer-security/compromise-faq
  2. Posting-frequency: monthly
  3. Last-Modified: 1994/06/01
  4. Version: 1.6
  5.  
  6.  
  7.         Compromise:  What if your Machines are Compromised by an Intruder.
  8.  
  9.         This FAQ deals with some suggestions for securing your Unix machine
  10. after it has already been compromised.  Even if your machines have not been
  11. compromised, there are many helpful tips on securing machine in this paper.
  12. I would appreciate any suggestions.  This FAQ will be posted monthly.
  13.  
  14.  
  15. 1.  Try to trace/follow the intruder back to his origin via looking at
  16.   a) who
  17.   b) w
  18.   c) last
  19.   d) lastcomm
  20.   e) netstat
  21.   f) snmpnetstat
  22.   g) and router information.
  23.   h) /var/adm/messages (many crackers send e-mail to their "home" accounts)
  24.   i) syslog (sends logs to other hosts as well)
  25.   j) wrapper logs
  26.   k) do a 'finger' to all local users(and check where they last logged in from)
  27.  
  28.  
  29.         Footnote: 'who', 'w', 'last', and 'lastcomm' are commands that  rely
  30. on /var/adm/pacct, /usr/adm/wtmp, and /etc/utmp to report the information to
  31. you.  Most backdoors will keep the intruder from being shown in these logs.
  32. Even if the intruder has not installed any backdoors yet, it is trivial to
  33. remove any detection in these logs.  But they may just forget about one or two
  34. of them.  Especially if you have some additional, non-standard ones.
  35.  
  36.  
  37.         Suggestion: Install xinetd or tcp_wrapper that will log all
  38. connections to your machine to see if someone is knocking on its doors.
  39. Forward syslogs to another machine so intruder will not easily detect  the
  40. logs and modify. Other possibilities: netlog from net.tamu.edu:/pub/security.
  41.  
  42.  
  43.         It might be wise to monitor the intruder via some ethernet sniffer
  44. to see how he is exploiting his systems before taking corrective measures.
  45.  
  46. 2.  Close the machine from outside access.  Remove from network to stop
  47. further access via intruder.  If the intruder finds out that the
  48. administrator is unto him, he may try to hide his tracks by rm -rf /.
  49.  
  50. 3.  Check the binaries with the originals.  Especially check the following
  51. binaries because they are commonly replaced backdoors for regaining access:
  52.  
  53.   a) /bin/login
  54.   b) all the /usr/etc/in.* files (ie. in.telnetd)
  55.   c) and /lib/libc.so.* (on Suns).
  56.   d) anything called from inetd
  57.  
  58.  
  59.         Other commonly replaced backdoor binaries:
  60.   a) netstat - allows hiding connections
  61.   b) ps - allows hiding processes (ie Crack)
  62.   c) ls - allows hiding directories
  63.   d) ifconfig - hides the fact that promiscuity mode is on the ethernet
  64.   e) sum - fools the checksum for binaries, not necessarily replaced anymore
  65. because its possible to change the checksum of the binaries to the correct
  66. value without modifying sum. *EMPHASIZE* Do NOT Rely on sum.
  67.  
  68.         Use 'ls -lac' to find the real modification time of files.  Check
  69. /etc/wtmp (if you still have one) for any system time adjustments.  Check the
  70. files with the distribution media (CD or tape) or calculate MD5 checksums and
  71. compare them with the originals kept offline (you did calculate them sometime
  72. ago, didn't you?) Suggestion: cmp(1) the files with copies that are known to
  73. be good.
  74.  
  75.         Another popular backdoor is suid'ing a common command (ie.
  76. /bin/time) to allow root access with regular accounts.
  77.  
  78. To find all suid programs you may use:
  79.  
  80.         find / -type f -perm -4000 -ls
  81.  
  82.  
  83.         To be thorough you may need to re-load the entire OS to make sure
  84. there are no backdoors.  Tripwire helps prevent modifying binaries and system
  85. files (ie. inetd.conf) on the system, without the administrator knowing.
  86.  
  87. 4.  Implement some password scheme for your users to verify that they change
  88. their passwords often.  Install anlpasswd, npasswd, or passwd+ in place of
  89. passwd (or yppasswd) so that your users are forced to set reasonable
  90. passwords. Then run Crack to make sure that your users aren't bypassing the
  91. password check.  Crack ensures that users are picking difficult passwords.
  92. With the network, clear text passwords are a problem.  Other possible
  93. choices:  smart hubs (stops ethernet sniffing of the whole LAN) and one-time
  94. password technology.
  95.  
  96.  
  97. 5.  Check all the users' .rhosts and .forward files to make sure none of them
  98. are weird or out of the ordinary. If .rhosts file contains '+ +', the account
  99. can be accessed anywhere by anyone without a password.  COPS has a scripts
  100. for checking .rhosts.
  101.  
  102.          find / -name .rhosts -ls -o -name .forward -ls
  103.  
  104. Look also for all the files created/modified in the time you are suspecting
  105. the break-in has taken place, eg:
  106.  
  107.         find / -ctime -2 -ctime +1 -ls
  108.  
  109. To find all the files modified not less than one day ago, but not more than 2.
  110.  
  111. All .login, .logout, .profile, .cshrc files are also worth looking at (at
  112. least for the modification date/time).  Make sure there are no '.rhosts' for
  113. the locked or special accounts (like 'news', 'sundiag', 'sync', etc.)
  114. The shell for such accounts should be something like '/bin/false' anyway (and
  115. not '/bin/sh') to make them more secure. Also search for directories that have
  116. like ". ", ".. " as names.  They are usually found in /tmp , /var/tmp,
  117. /usr/spool/* and any other publicly writeable directory.
  118.  
  119.  
  120. 6.  Check to make sure your NFS exports are not world writable to everyone.
  121. NFSwatch, a program by David Curry, will log any NFS transactions that are
  122. taking place.  Try 'showmount -e' to see whether system agrees with your
  123. opinion of what are you exporting and where.  There are bugs in some nfsd
  124. implementations which ignore the access lists when they exceed some limit (256
  125. bytes).  Check also what are you IMPORTING!!!  Use 'nosuid' flag whenever
  126. possible. You do not want to be cracked by a sysadm from another host (or a
  127. cracker there) running suid programs mounted via NFS, do you?
  128.  
  129.  
  130. 7.  Make sure you have implemented the newest sendmail daemon. Old sendmail
  131. daemons allowed remote execution of commands on any Unix machine. See the
  132. computer-security/security-patch FAQ.
  133.  
  134. 8.  Try to install all the security patches available from the vendor on your
  135. machine.  See the computer-security/security-patch FAQ.
  136.  
  137. 9.  Here is a check list:
  138.  
  139.  o Do an rpcinfo -p  on your machine to make sure it is not running any
  140. processes that are not needed. (ie. rexd).
  141.  
  142.  o Check for '+' in /etc/hosts.equiv.
  143.  
  144.  o Check whether tftp is disabled on your system.  If not - disable it, or at
  145. least use '-s' flag to chroot it to some safe area, if you really can't live
  146. without it (it is mostly used for booting up Xterminals, but sometimes can be
  147. avoided by NFS-mounting appropriate disks).  Under no circumstances you should
  148. run it as root.  Change the line describing it in /etc/inetd.conf to something
  149. like:
  150.  
  151.     tftp dgram  udp  wait  nobody  /usr/etc/in.tftpd  in.tftpd -s /tftpboot
  152.  
  153. or better yet, use tcpd wrapper program to protect it from addresses which
  154. should not get access to tftp and log all other connections:
  155.  
  156.     tftp dgram  udp  wait  nobody  /usr/etc/tcpd  in.tftpd -s /tftpboot
  157.  
  158. and edit appropriately /etc/hosts.allow to restrict access to in.tftpd to
  159. only those addresses that really need it.
  160.  
  161.  o Check crontabs and at-jobs.  Make sure there are no delayed bombs which
  162. will explode after you think you have got rid of all the nasty things left by
  163. a intruder.
  164.  
  165.  o Check /etc/rc.boot /etc/rc.local  (SYSV: /etc/rc?.d/* ) and other files
  166. ith the copies kept off-line).  Check all other files containing system
  167. configuration (sendmail.cf, sendmail.fc, hosts.allow, at.allow, at.deny,
  168. cron.allow, hosts, hosts.lpd, etc.)  In 'aliases' look for aliases expanding
  169. to some unusual programs (uudecode is one but example).
  170.  
  171.  o Check your inetd.conf and /etc/services files to find if there are no
  172. additional services set up by an intruder.
  173.  
  174.  o Copy all the log files you still have (pacct, wtmp, lastlog, sulog, syslog,
  175. authlog, any additional logs you have set up earlier) to some safe place
  176. (offline) so you may examine them later.  Otherwise, do not be surprised if
  177. they disappear the next day when the cracker realises he forgot to remove one
  178. of them.  Use your own imagination to find what other traces he could have
  179. left in your system (What about /tmp/* files?  Check them BEFORE you reboot).
  180.  
  181.  o Make backup copy of /etc/passwd (best offline) then change all root
  182. passwords (after verifying that 'su' and 'passwd' are not the trojan versions
  183. left by an intruder).  It may sound like a horrible thing to do
  184. (especially if you have something like 2000 users) but *do* lock them all by
  185. putting '*' in the password field.  If the intruder has a copy of your
  186. passwords file he may possibly sooner or later guess all the passwords
  187. contained there (It is all the matter of proper dictionaries).  In fact he
  188. could have inserted few passwords that he only knows for some users who for
  189. example have not logged in for a long time.
  190.  
  191.         On the NIS servers check not only the real /etc/passwd /etc/groups etc
  192. files but also those used for building NIS maps (if they are different).
  193.  
  194.  o Check if your anonymous ftp (and other services) are configured properly
  195. (if you have any of course)  See the computer-security/anonymous-ftp FAQ.
  196.  
  197.  o If you want to make your life easier next time (or if you still cannot get
  198. rid of an intruder) consider installing 'ident' daemon.  Together with tcpd on
  199. a set of hosts it can be used to find what accounts the intruder is using.
  200.  
  201.  o Make sure the only 'secure' terminal is console (if at all).  This way you
  202. prevent root logins just from the net.  Maybe it is not a big deal as if
  203. somebody knows the root password he may already know other peoples' passwords
  204. too, but maybe not?
  205.  
  206.  o And remember...  There are so many ways that somebody could have modified
  207. your system, that you really have to have your eyes and ears wide open for a
  208. loooooong long time.  Above, are the pointers just to the most obvious things
  209. to check.
  210.  
  211.  
  212. 10.  Mail all the sites that you were able to find out that the intruder was
  213. going through and warn them.  Also, CC: cert@cert.org.  Check all the sites in
  214. your near-by, ie. in your domain/institution/whatever.  It's usually trivial
  215. for a hacker to get to another system by a simple 'rlogin' if the two systems
  216. have a common subset of users (and using .rhosts to make the access easier).
  217.  
  218.  
  219. 11.  A preventive from stopping many intruders from even trying your network
  220. is to install a firewall.
  221.  
  222.         Side-effects: Firewalls may be expensive; filtering may slow down the
  223. network. Consider blocking nfs (port 2049/udp) and portmap(111/udp) on your
  224. router. The authentication and access controls of these protocols is often
  225. minimal.  Suggestion: Block all udp ports except DNS and NTP ports. Kill all
  226. source routing packets.  Kill all ip-forwarding packets.
  227.  
  228.  
  229. Acknowledgements
  230.  
  231. Thanks to the following people for adding and shaping this FAQ:
  232.  
  233. Tomasz Surmacz <tsurmacz@asic.ict.pwr.wroc.pl>
  234. Wes Morgan (morgan@engr.uky.edu)
  235. Peter Van Epp <vanepp@sfu.ca>
  236. Richard Jones <electron@suburbia.apana.org.au>
  237. Wieste Venema <wietse@wzv.win.tue.nl>
  238. Adrian Rodriguez <adrian@caip.rutgers.edu>
  239.  
  240.  
  241. Copyright
  242.  
  243. This paper is Copyright (c) 1994
  244.  by Christopher Klaus of Internet Security Systems, Inc.
  245.  
  246.         Permission is hereby granted to give away free copies.  You may
  247. distribute, transfer, or spread this paper.  You may not pretend that you
  248. wrote it.  This copyright notice must be maintained in any copy made.
  249.  
  250.  
  251. Disclaimer
  252.  
  253.         The information within this paper may change without notice. Use of
  254. this information constitutes acceptance for use in an AS IS condition.
  255. There are NO warranties with regard to this information.  In no event shall
  256. the author be liable for any damages whatsoever arising out of or in
  257. connection with the use or spread of this information.  Any use of this
  258. information is at the user's own risk.
  259.  
  260.  
  261.  
  262. Address of Author
  263.  
  264.         Please send suggestions, updates, and comments to:
  265.  
  266.         Christopher Klaus <cklaus@shadow.net>
  267.         of Internet Security Systems, Inc. <iss@shadow.net>
  268.  
  269.  
  270.  
  271. --
  272. Christopher William Klaus  <cklaus@shadow.net>  <iss@shadow.net>
  273. Internet Security Systems, Inc.
  274. 2209 Summit Place Drive,
  275. Atlanta,GA 30350-2430. (404)998-5871.
  276.  
  277.