vRanger
May 23rd, 2014, 06:56 PM
I'm using Ubuntu 14.04 for an email server. (Does it make any difference if is command line only or not?) Anyway, here are my questions, all related:
1) Is there a fool proof way that cannot be defeated by crafty intruder that will show the open connections to the server, whether it is ssh, or telnet, or html.
2) What are the connection types that would allow crafty intruder to make changes to my server that normally only root user can make. e.g. ssh for sure, but html, others?
3) For ways that crafty intruder might have modified my system, using commands like below or other suggested commands, how can I tell if they (the commands themselves) have been modified?
So far I use:
:~$ sudo netstat -taupen
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 0 11743 2251/master
tcp 0 0 127.0.0.1:9998 0.0.0.0:* LISTEN 111 10116 1472/amavisd (maste
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 0 9891 1233/dovecot
tcp 0 0 127.0.0.1:10031 0.0.0.0:* LISTEN 106 11825 2277/perl
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 0 9899 1233/dovecot
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 11864 2344/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 9159 1070/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 0 11655 2251/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 11867 2344/apache2
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 0 9884 1233/dovecot
tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN 0 302173 14797/python
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 0 9900 1233/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 0 9892 1233/dovecot
tcp 0 0 127.0.0.1:10024 0.0.0.0:* LISTEN 111 10115 1472/amavisd (maste
tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN 0 11753 2251/master
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 105 10079 1280/mysqld
tcp 0 0 192.168.x.x:443 192.168.x.x:63477 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:59309 127.0.0.1:3306 ESTABLISHED 0 909458 5833/auth
tcp 0 0 127.0.0.1:3306 127.0.0.1:36726 ESTABLISHED 105 1252074 1280/mysqld
tcp 0 0 127.0.0.1:3306 127.0.0.1:36965 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:143 127.0.0.1:36943 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:3306 127.0.0.1:36719 ESTABLISHED 105 1252061 1280/mysqld
tcp 0 280 10.x.x.x:22 10.x.x.x:60252 ESTABLISHED 0 1264577 18807/sshd: x
tcp 0 0 127.0.0.1:36719 127.0.0.1:3306 ESTABLISHED 106 1252060 4917/perl
tcp 0 0 127.0.0.1:3306 127.0.0.1:59309 ESTABLISHED 105 909459 1280/mysqld
tcp 0 0 127.0.0.1:36726 127.0.0.1:3306 ESTABLISHED 106 1252388 4966/perl
tcp6 0 0 :::22 :::* LISTEN 0 9161 1070/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 0 9440 1038/dhclient3
:~$ w
10:47:58 up 6 days, 18:58, 2 users, load average: 0.06, 0.03, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
testuser pts/0 10.x.x.x 10:40 6.00s 0.24s 0.00s w
:~$ sudo lsof -i | grep -i established
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 1280 mysql 37u IPv4 909459 0t0 TCP ip6-localhost:mysql->ip6-localhost:59309 (ESTABLISHED)
mysqld 1280 mysql 166u IPv4 1252061 0t0 TCP ip6-localhost:mysql->ip6-localhost:36719 (ESTABLISHED)
mysqld 1280 mysql 172u IPv4 1252074 0t0 TCP ip6-localhost:mysql->ip6-localhost:36726 (ESTABLISHED)
cbpolicyd 4917 cluebringer 10u IPv4 1252060 0t0 TCP ip6-localhost:36719->ip6-localhost:mysql (ESTABLISHED)
cbpolicyd 4966 cluebringer 10u IPv4 1252388 0t0 TCP ip6-localhost:36726->ip6-localhost:mysql (ESTABLISHED)
auth 5833 root 12u IPv4 909458 0t0 TCP ip6-localhost:59309->ip6-localhost:mysql (ESTABLISHED)
sshd 18807 root 3u IPv4 1264577 0t0 TCP 10.x.x.x:ssh->10.x.x.x:60252 (ESTABLISHED)
sshd 18977 x 3u IPv4 1264577 0t0 TCP 10.x.x.x:ssh->10.x.x.x:60252 (ESTABLISHED)
1) Is there a fool proof way that cannot be defeated by crafty intruder that will show the open connections to the server, whether it is ssh, or telnet, or html.
2) What are the connection types that would allow crafty intruder to make changes to my server that normally only root user can make. e.g. ssh for sure, but html, others?
3) For ways that crafty intruder might have modified my system, using commands like below or other suggested commands, how can I tell if they (the commands themselves) have been modified?
So far I use:
:~$ sudo netstat -taupen
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 0 11743 2251/master
tcp 0 0 127.0.0.1:9998 0.0.0.0:* LISTEN 111 10116 1472/amavisd (maste
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 0 9891 1233/dovecot
tcp 0 0 127.0.0.1:10031 0.0.0.0:* LISTEN 106 11825 2277/perl
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 0 9899 1233/dovecot
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 11864 2344/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 9159 1070/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 0 11655 2251/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 11867 2344/apache2
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 0 9884 1233/dovecot
tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN 0 302173 14797/python
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 0 9900 1233/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 0 9892 1233/dovecot
tcp 0 0 127.0.0.1:10024 0.0.0.0:* LISTEN 111 10115 1472/amavisd (maste
tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN 0 11753 2251/master
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 105 10079 1280/mysqld
tcp 0 0 192.168.x.x:443 192.168.x.x:63477 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:59309 127.0.0.1:3306 ESTABLISHED 0 909458 5833/auth
tcp 0 0 127.0.0.1:3306 127.0.0.1:36726 ESTABLISHED 105 1252074 1280/mysqld
tcp 0 0 127.0.0.1:3306 127.0.0.1:36965 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:143 127.0.0.1:36943 TIME_WAIT 0 0 -
tcp 0 0 127.0.0.1:3306 127.0.0.1:36719 ESTABLISHED 105 1252061 1280/mysqld
tcp 0 280 10.x.x.x:22 10.x.x.x:60252 ESTABLISHED 0 1264577 18807/sshd: x
tcp 0 0 127.0.0.1:36719 127.0.0.1:3306 ESTABLISHED 106 1252060 4917/perl
tcp 0 0 127.0.0.1:3306 127.0.0.1:59309 ESTABLISHED 105 909459 1280/mysqld
tcp 0 0 127.0.0.1:36726 127.0.0.1:3306 ESTABLISHED 106 1252388 4966/perl
tcp6 0 0 :::22 :::* LISTEN 0 9161 1070/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 0 9440 1038/dhclient3
:~$ w
10:47:58 up 6 days, 18:58, 2 users, load average: 0.06, 0.03, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
testuser pts/0 10.x.x.x 10:40 6.00s 0.24s 0.00s w
:~$ sudo lsof -i | grep -i established
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 1280 mysql 37u IPv4 909459 0t0 TCP ip6-localhost:mysql->ip6-localhost:59309 (ESTABLISHED)
mysqld 1280 mysql 166u IPv4 1252061 0t0 TCP ip6-localhost:mysql->ip6-localhost:36719 (ESTABLISHED)
mysqld 1280 mysql 172u IPv4 1252074 0t0 TCP ip6-localhost:mysql->ip6-localhost:36726 (ESTABLISHED)
cbpolicyd 4917 cluebringer 10u IPv4 1252060 0t0 TCP ip6-localhost:36719->ip6-localhost:mysql (ESTABLISHED)
cbpolicyd 4966 cluebringer 10u IPv4 1252388 0t0 TCP ip6-localhost:36726->ip6-localhost:mysql (ESTABLISHED)
auth 5833 root 12u IPv4 909458 0t0 TCP ip6-localhost:59309->ip6-localhost:mysql (ESTABLISHED)
sshd 18807 root 3u IPv4 1264577 0t0 TCP 10.x.x.x:ssh->10.x.x.x:60252 (ESTABLISHED)
sshd 18977 x 3u IPv4 1264577 0t0 TCP 10.x.x.x:ssh->10.x.x.x:60252 (ESTABLISHED)