LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-24-2014, 12:59 AM   #1
vRanger
LQ Newbie
 
Registered: May 2014
Posts: 9

Rep: Reputation: Disabled
How can I detect or see if there is an intruder currently logged onto my server?


I'm using Ubuntu 14.04 for an email server. 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
Quote:
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
Quote:
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
Quote:
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)
 
Old 05-24-2014, 04:30 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vRanger View Post
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.
First of all: what in this reply was not clear, or what has (seemingly) changed since your subsequent reply?

As for your question: short answer: no. Longer answer: it depends.

You should know that while the threatscape has changed drastically, in the sense that traditional root kits are used less since the start of this millennium, there are enough threats as a lack of knowledge, carelessness, lax (or non-existent!) access restrictions, update schemes, password policies, flaws in service configurations and running outdated software give rise to successful web stack and brute force attacks. Unless a perp has physical access or any other means of subverting a system without leaving a trail (or being able to patch it up), most 'net-based attacks will start with recon and access to lower-privileged resources, leaving a trail. So in essence your question should have been asked prior to any (perceived) security incident. It should have led to properly hardening a server (which provides early warnings and should make it harder for a perp to 0wn a box RSN) and should include creating an audit trail (to log what ops are performed, find anomalous access patterns and be able to respond to early warnings) and the ability to independently verify system integrity.


Quote:
Originally Posted by vRanger View Post
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?
Basically: any your machine provides, or whatever else means a perp is allowed to inject after gaining a foothold.


Quote:
Originally Posted by vRanger View Post
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?
Like I already said here: the default Debian(-like) way of using debsums unfortunately requires you to modify apt-related configuration files before the event. So another way is to download a copy of any suspect packages onto a known clean machine, generate a list of hashes (md5sum or md5deep) and compare hashes ('md5sum -c') with the "victim" system. Also, if a perp doesn't clean up afterwards, see entries in service and system log files, user login records, shell history, left uploads and changed ownership, hashes and MAC times of files and odd traffic behaviour can be signs of an intrusion.
 
Old 06-08-2014, 01:26 AM   #3
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 836
Blog Entries: 3

Rep: Reputation: 297Reputation: 297Reputation: 297
Obviously, commands such as lastlog, w, and the likes can only be trusted to a certain extent, as they can be modified if the attacker has full system access. Chances are, if they haven't 'rooted' your system, they may show up in these outputs.

Quote:
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.
Monitor the outgoing/incoming traffic from a seperate machine using a live medium that you can trust. Tools like wireshark can be useful for monitoring traffic externally. Live medium is better, in the event that if your routed machine were to also be compromised, it could also be hiding traffic and wouldn't be much use!

Quote:
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?
Any software that is running as the root user. Eg; a webserver running as root, could be taken advantage of by a flawed php script that doesn't sanitize input. Also any software that offers a connection to the outside world, regardless of the user it is running as, if there is a flaw that can be used to escalate privileges on the system... this is why it's best to keep software patched and up to date, as it vastly reduces this risk.


Quote:
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?
There is software that can create checksums of system binaries (for instance, everything in /bin and /sbin, and compare them at a later date to see if the checksums have changed. I think tools similar to chkrootkit do this.

Last edited by coralfang; 06-08-2014 at 01:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for user who are logged in, the display first,last name and time logged in LBP74 Programming 1 01-07-2013 04:23 AM
IPs logged as D.C.B.A and some times A.B.C.D how to find which format is logged tkmsr Linux - Security 15 11-18-2010 08:29 AM
[SOLVED] How to detect if logged in via ssh? ccargo Linux - General 8 08-10-2009 03:45 AM
kde much slower to start when logged in as alan than logged in as root arubin Slackware 0 04-26-2004 04:27 PM
mozilla works fine when logged in as a user but crashes when logged in as root jimi Linux - General 6 04-02-2003 08:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration