home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / internet / compro_1.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  14.0 KB  |  297 lines

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