
3. Step 1: Which services do we really need?
In this section we will see which services are running on our freshly installed system, decide which we really
need, and do away with the rest. If you are not familiar with how servers and TCP connections work, you
may want to read the section on servers and ports in the Appendix first. If not familiar with the netstat utility,
you may want to read a quick overview of it beforehand. There is also a section in the Appendix on ports, and
corresponding services. You may want to look that over too.
Our goal is to turn off as many services as possible. If we can turn them all off, or at least off to outside
connections, so much the better. Some rules of thumb we will use to guide us:
It is perfectly possible to have a fully functional Internet connection with no servers running that are
accessible to outside connections. Not only possible, but desirable in many cases. The principle here
is that you will never be successfully broken into via a port that is not opened because no server is
listening on it. No server == no port open == not vulnerable. At least to outside connections.
•
If you don't recognize a particular service, chances are good you don't really need it. We will assume
that and so we'll turn it off. This may sound dangerous, but is a good rule of thumb to go by.
•
Some services are just not intended to be run over the Internet −− even if you decide it is something
you really do need. We'll flag these as dangerous, and address these in later sections, should you
decide you do really need them, and there is no good alternative.
•
3.1. System Audit
So what is really running on our system anyway? Let's not take anything for granted about what "should" be
running, or what we "think" is running.
Which services get installed and started will vary greatly depending on which version of Red Hat, and which
installation options were chosen. Earlier releases were very much prone to start many services and then let
the user figure out which ones were needed, and which ones weren't. Recent versions are much more
cautious. But this makes providing a ready made list of likely services impossible. Not to worry, as we
shouldn't trust what is supposed to be running anyway. What we need to do is list for ourselves all running
services.
Now open an xterm, and su to root. You'll need to widen the window wide so the lines do not wrap. Use this
command: netstat −tap |grep LISTEN. This will give us a list of all currently running servers as
indicated by the keyword LISTEN, along with the "PID" and "Program Name" that started each particular
service.
# netstat −tap |grep LISTEN
*:exec *:* LISTEN 988/inetd
*:login *:* LISTEN 988/inetd
*:shell *:* LISTEN 988/inetd
*:printer *:* LISTEN 988/inetd
*:time *:* LISTEN 988/inetd
*:x11 *:* LISTEN 1462/X
*:http *:* LISTEN 1078/httpd
bigcat:domain *:* LISTEN 956/named
bigcat:domain *:* LISTEN 956/named
*:ssh *:* LISTEN 972/sshd
*:auth *:* LISTEN 388/in.identd
3. Step 1: Which services do we really need? 7
Commenti su questo manuale