Check for Listening Services
Find out whether unneeded services are listening and looking for possible backdoors.
One
of the first things
that should be done after a fresh operating system install is to see
what services are running, and remove any unneeded services from the
system startup process. You could use a port scanner (such as
nmap
[Hack #42]
) and run
it against the host, but if one didn’t come with the
operating system install, you’ll likely have to
connect your fresh (and possibly insecure) machine to the network to
download one. Also, nmap can be fooled if the system is using
firewall rules. With proper firewall rules,
a service can be completely invisible to nmap unless certain criteria
(such as the source IP address) also match. When you have shell
access to the server itself, it is usually more efficient to find
open ports using programs that were installed with the operating
system. One program that will do what we need is
netstat, a program that will display various
network-related information and statistics.
To get a list of listening ports and their owning processes under Linux, run this:
# netstat -luntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1679/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1766/dhclientFrom the output, you can see that this machine is probably a workstation, since it just has a DHCP client running along with an SSH daemon for remote access. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access