home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / computer-security / compromise-faq < prev    next >
Encoding:
Text File  |  1995-07-25  |  12.5 KB  |  289 lines

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