LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-11-2018, 12:02 PM   #1
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Rep: Reputation: 0
Seems like Server is Compromised


I think my VPS server running Debian 9.0 is compromised. Its a new setup with few basic applications installed, as of now only SSH and fail2ban are running on the system.

As soon as the server was up I did below changes.

1. generated a new ssh key and disabled password authentication.
2, installed and configured fail2ban for ssh
3. createad a firewall rule to block all ports except ssh


I was under the impression that I got the server fully secured, I saw that fail2ban blocked few IPs after they attempted a brute force attack or scan. Then I did a check on outgoing connections using below command.

Quote:
netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v '127.0.0.1'
This returned an unfamiliar ip, the connect was there only for few seconds. Later I saw another ip using the same command. Further googling led me to NetHogs and I can see that there are quite few ips trying making connections.


Code:
  NetHogs version 0.8.5-2

    PID USER     PROGRAM                                       DEV        SENT      RECEIVED
   5331 wally    sshd: wally@pts/0                             ens3        0.207       0.063 KB/sec
      ? root     xxx.xx.xxx.xx:24363-77.72.85.17:56793                    0.000       0.011 KB/sec
      ? root     xxx.xx.xxx.xx:9094-5.188.11.78:44273                     0.000       0.011 KB/sec
      ? root     xxx.xx.xxx.xx:6936-77.72.85.17:56793                     0.000       0.000 KB/sec
      ? root     xxx.xx.xxx.xx:3428-5.101.66.252:57886                    0.000       0.000 KB/sec
      ? root     xxx.xx.xxx.xx:5708-5.188.11.78:44273                     0.000       0.000 KB/sec
      ? root     xxx.xx.xxx.xx:38473-191.101.167.77:59146                 0.000       0.000 KB/sec
      ? root     xxx.xx.xxx.xx:15516-191.101.167.77:59146                 0.000       0.000 KB/sec
      ? root     xxx.xx.xxx.xx:30882-5.188.11.25:42365                    0.000       0.000 KB/sec
      ? root     unknown TCP                                               0.000       0.000 KB/sec

  TOTAL                                                                    0.207       0.084 KB/sec

could some one explain to me whats going on. I can't find any process attached to these connections.

Thanks
 
Old 04-11-2018, 01:22 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by tux75 View Post
with few basic applications installed
Might have been "secure" when ya got it...

Your use of the term "applications" is curious to me.
Tell us, does "basic applications" include a desktop?
 
Old 04-11-2018, 03:01 PM   #3
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Habitual View Post
Tell us, does "basic applications" include a desktop?
by applications I meant software packages. like apache or mysql.
 
Old 04-11-2018, 03:58 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Code:
netstat -atnp
will add the name of the process to the display.
 
Old 04-12-2018, 04:01 AM   #5
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Original Poster
Rep: Reputation: 0
There aren't any processes pertaining to those IPs

Code:
# netstat -atnp
Active Internet connections (servers and established)
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      27435/sshd
tcp        0    404 xxx.xx.xxx.xx:22       yyy.y.yy.yyy:1727       ESTABLISHED 30137/sshd: wally [
 
Old 04-12-2018, 04:22 AM   #6
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Original Poster
Rep: Reputation: 0
IPs in red, are unknown to me.

Code:
# netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v '127.0.0.1'
and
Address
0.0.0.0:*
212.85.73.131:39528
yyy.y.yy.yyy:1157

# netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v '127.0.0.1'
and
Address
0.0.0.0:*
151.101.28.204:80
yyy.y.yy.yyy:1157
#
 
Old 04-12-2018, 02:50 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by tux75 View Post
There aren't any processes pertaining to those IPs

Code:
# netstat -atnp
Active Internet connections (servers and established)
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      27435/sshd
tcp        0    404 xxx.xx.xxx.xx:22       yyy.y.yy.yyy:1727       ESTABLISHED 30137/sshd: wally [
The process is sshd in both cases...the second entry shows an established ssh connection from the yyy.y.yy.yyy IP address...user is wally

Last edited by scasey; 04-12-2018 at 03:15 PM.
 
Old 04-12-2018, 02:59 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by tux75 View Post
IPs in red, are unknown to me.

Code:
# netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v '127.0.0.1'
and
Address
0.0.0.0:*
212.85.73.131:39528
yyy.y.yy.yyy:1157

# netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v '127.0.0.1'
and
Address
0.0.0.0:*
151.101.28.204:80
yyy.y.yy.yyy:1157
#
Code:
whois 212.85.73.131
will display information about the IP address...in that case, it's a "Dynamic private network" of an ISP (Bahnhof) in Sweden.

I think the other one is showing you that you are connected to a foreign webpage...the IP resolves to a hosting company in San Francisco ...did you have a browser running?

Again... Add the -p to see the process, and maybe stop tweaking the output of netstat...it's pretty clear as it stands, and there's more information (other than the Foreign IP) than you're sharing that helps understanding what you're seeing.

Last edited by scasey; 04-12-2018 at 03:15 PM.
 
Old 04-17-2018, 10:57 AM   #9
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by scasey View Post
The process is sshd in both cases...the second entry shows an established ssh connection from the yyy.y.yy.yyy IP address...user is wally
Yes this is the connection I made to the server.
 
Old 04-17-2018, 11:02 AM   #10
tux75
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by scasey View Post
Code:
whois 212.85.73.131
will display information about the IP address...in that case, it's a "Dynamic private network" of an ISP (Bahnhof) in Sweden.

I think the other one is showing you that you are connected to a foreign webpage...the IP resolves to a hosting company in San Francisco ...did you have a browser running?

Again... Add the -p to see the process, and maybe stop tweaking the output of netstat...it's pretty clear as it stands, and there's more information (other than the Foreign IP) than you're sharing that helps understanding what you're seeing.
I monitored the connection randomly for few days and didn't find anymore suspicions connections. I used the connection to browse the web and seems like these were the IPs from that connection. May be I got bit paranoid :-)

Quote:
and there's more information (other than the Foreign IP) than you're sharing that helps understanding what you're seeing
What is this information will be?

Thanks a lot for the help
 
Old 04-17-2018, 11:36 AM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by tux75 View Post
What is this information will be?

Thanks a lot for the help
Code:
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      27435/sshd
tcp        0    404 xxx.xx.xxx.xx:22       yyy.y.yy.yyy:1727       ESTABLISHED 30137/sshd: wally [
As the header line says, the Local IP and port, the Foreign IP and Port, the State (very useful see man netstat) and the PID and Program name...your logic is hiding all that from you.

You're most welcome.
 
  


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
Server compromised? sminogue Linux - Security 2 12-15-2011 01:54 PM
server compromised? eco Linux - Security 3 09-03-2010 11:58 AM
Server Compromised? stlyz3 Linux - Security 6 09-07-2005 04:28 PM
Server was compromised, need help Asiana Linux - Security 3 06-02-2004 12:39 PM

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

All times are GMT -5. The time now is 06:08 AM.

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