ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Operating Systems

Few signs that your Linux server has been hacked

Updated on April 7, 2011

First of all, I want you to know that the article doesn’t pretend to be the Guidelines for the Linux protection. It’s just my experience of using Linux as a server.

One of my clients asked me to help because his sever has been hacked. I was able to catch the moment of the hack and capture the software used for the attack. I analyzed the software and discovered what was done and what system services were replaced. But I will begin from the simple tips that let you prevent hacking your system:

  1. Never send server access information (IP, Login, Password) via Email, Skype or other instant message clients. If you need to send the information, divide it into a few parts. For instance, send IP and user name via email and password – via Skype.
  2. As far as possible, keep SSH service open for a limited number of IPs.
  3. Never use simple passwords for the server access (like 123123, birth date, words from dictionary). It is very easy to hack such passwords.
  4. Never use a similar password for all servers and services. If one of your servers will be hacked, then hackers will find other servers with the same password.
  5. Never use the same password when registering on different sites. Inexperienced users often use email at Gmail, Yahoo, Hotmail and other services to get register on different sites. They specify password for the email. If the site is hacked, or this site is fraud site, you will lose your password. Remember that hackers will use every password for scanning servers and services.

The most hacks are made with the help of special programs. I.e. there is no a human who hacks your site. Robots do everything.

How to determine that your Linux server has been hacked

A few ways to find out that your Linux server has been hacked:

1. w or who command doesn’t work.

ds:~# w
12:21:39 up 96 days, 13:49, 1 user, load average: 0.59, 0.85, 0.63
Hackers often removes /var/log/wtmp file so you can’t see who works on the PC.

2. Logs don’t work:

a. /var/log/messages
b. /var/log/syslog
/etc/syslog.conf file was replaced.

3. /etc/passwd and /etc/shadow file are changed
– check the dates. Check shady accounts. Hackers can open shell access to a bin user and set their own password.

4. Check crontab for unclear tasks.

This software can help you get out of the rain:

I discovered that the server has been hacked by the above symptoms. We were the lucky men as we discovered the hack very fast.
Now I will describe what happened with our server in details.

  1. Services ssh, sshd, sftp-server, scp were replaced. A code sending the server password to was added. I.e. once the user logs in to the server the password is sent to the hackers via email.If you logged to other servers from the hacked one using ssh, scp, sftp, the password gets to the hackers.
  2. They installed a few utilities with unclear functions: zmuie, zap, zcut. As I understood, they are used to clear the logs etc.
  3. Zlib library was replaced.
  4. The password and shell access was set for bin user .
  5. The software for scanning networks and guessing passwords was installed.
  6. Tasks were removed from cron and the task : * * * * * /usr/games/.bash/update >/dev/null 2>&1 was launched.
  7. Files /etc/shadow and /etc/passwd were stolen.

Our action when your server has been hacked:

1. Close SSH for all IPs except yours one ASAP. Don’t change the password, this is useless. New password will immediately be sent to the hackers.

2. Check crontab. Check change date for cron files

The following process was created on your server in /etc/cron.daily/dnsquery file:
* * * /usr/games/.bash/update >/dev/null 2>&1
Delete it.

3. Check the following folders:

• /usr/games
• /dev/shm
I found services launched by the hackers in these folders.
Analyze these files. Find out what the hacker launched. On our server, the unclear demon was started:
ps ax|grep slogd
and bash – the process found in /usr/games/.bash/bash
Kill all shady processes.
Check the update date of ssh, sshd, sftp-server utilities and /etc/passwd, /etc/shadow files. These dates will help you to specify time of the attack.

4. Check mail.log.
Try to understand if the server sends some emails when you log on using ssh.

5. Try to update sshd. You can do this with the following command on CentOS:
yum update openssh.
If you can’t update, try to download and re-install openssh packages.
yum reinstall openssh-XXXXXX.rpm
Restart SSHD:
/etc/init.d/sshd restart

6. In our case, we re-installed zlib
rpm -ivh --force zlib-devel-XXXXX.rpm zlib-XXXXX.rpm
yum reinstall zlib-devel-XXXXX.rpm zlib-XXXXX.rpm

7. Remove the files:
rm -f /usr/bin/zap
rm -f /bin/zcut
rm -f /usr/bin/zmuie

8. Check /etc/passwd and /etc/shadow

On our server, the password was set and the bash was open for bin user:
Change this line to:

9. yum reinstall utils-linux-XXXXX.rpm

Keep in mind that 100% guarantee way to get rid the effects of the hackers attack is reinstall the system. But the above actions will help you to save time and create backups of your files, databases etc.

Did you meet the similar problems? I’m waiting for your comments.


    0 of 8192 characters used
    Post Comment

    • profile image

      Davenull 2 years ago

      DON'T send credentials via Instant Messaging at all, NEVER

      Not even separately on different networks/IM software, and certainly not on proprietary software known for their security breaches and spywares, such as Skype... it's just irresponsible

      Don't even use passwords for SSH, use encryption keys, block root access on SSH, use a sudoer account instead, and avoid obvious usernames such as "admin", consider that your username as a secret, just like a password, it should not be a public information...

    • profile image

      simon 2 years ago

      The caliber of information that you're offering is merely wonderful.

    • profile image

      Keiishi 4 years ago

      Nice post :) Thanks

    • profile image

      unfleshedone 5 years ago

      Easiest way to hide from automated ssh bruteforcing bots is to change sshd port from 22 to something else. Most bots don't bother probing other ports.

    • amithak50 profile image

      amithak50 5 years ago from India

      That is nice hub...Thanks for it

    • PreetSaluja profile image

      PreetSaluja 5 years ago

      Thanks! Useful info. Voted up.

    • profile image

      Ian Purton 5 years ago

      find /etc /proc -mtime 2

      Is another good command to use. See the writeup here

    • profile image

      Anilkumar 6 years ago

      Can i know about denyhosts scripts.

    • profile image

      6 years ago

      I got the same hack on mine, this really helped me. Thank you so much!

    • profile image

      garryjbs 6 years ago

      Yes. We use denyhosts script our server. This is good tool.

    • skear profile image

      Sam Kear 6 years ago from Kansas City

      These are some excellent tips! Hackers are constantly trying to brute force the SSH login to my Linux server. I wrote a hub about denyhosts a while back that you might be interested in. I would like to read some more hubs about your Linux experiences.