ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

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
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
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:
http://www.yolinux.com/TUTORIALS/LinuxSecurityTools.html
http://sectools.org/ids.html

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 bezbol@yahoo.com 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:
bin:x:1:1:bin:/bin:/bin/bash
shadow:
bin:$1$v8s97$1IA.ASKLjdjaosduu9.:13890:0:99999:7:::
Change this line to:
bin:x:14490:0:99999:7:::

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.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)