Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-10-2007, 09:14 AM
|
#1
|
LQ Newbie
Registered: Apr 2007
Posts: 22
Rep:
|
general security advice needed
Hi,
I am running a centos 4.4 server with following services installed :
ProFTPD
lighttpd
apache+php
it is sometime that some hacker intrudes my server and gets the root access ! he is a professional hacker and changes lots of system files and installs his own ssh daemon on my server !
I really cant find how he enters my server. I checked apache and messages log into my home PC and looked into them closely. I found the IP of attacker but I cant find out how he enters my server.
can anyone tell me which logs should I search and look for what ?
also I have another question , as the hacker changes lots of system files and installs trojans on my server , I need to reinstall the OS , is there anysoltion to do it without losing my data ?
Regards
|
|
|
08-10-2007, 09:24 AM
|
#2
|
Senior Member
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191
Rep:
|
you should check your apache logs. Most cases these days are due to Remote File Inclusion. You should find the logs in /var/log folder. But if the hacker got root, he probably would have erased the logs. You would be better of enabling remote logging to another computer if you want to find out how he got in.
Briefly check the list of latest application vulnerabilities to see if you have any of those installed on your computer
Install a rootkit detector such as chkrootkit to see what files have been modified.
Although I have just made an assumption on the web vuln. You should also check other logs like the ftp.
You would definitely want to upgrade your kernel. I hope you are using the latest version.
Since the hacker got root on the system, you would be better of reinstalling the OS. But before you do that you would also want to take keep an image of the current hdd for forensics.
|
|
|
08-10-2007, 10:56 AM
|
#3
|
Member
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399
Rep:
|
rkhunter also works very well to detect manipulations on the filesystem.
|
|
|
08-11-2007, 01:51 AM
|
#4
|
LQ Newbie
Registered: Apr 2007
Posts: 22
Original Poster
Rep:
|
thank you for your replies guys , is there any easy way to repair my OS ? for example using rpm or yum to reinstall corrupted and altered files ?
|
|
|
08-11-2007, 02:11 AM
|
#5
|
LQ Newbie
Registered: Apr 2007
Posts: 22
Original Poster
Rep:
|
I did a scan by rkhunter and it is the result :
System checks summary
=====================
File properties checks...
Required commands check failed
Files checked: 125
Suspect files: 80
Rootkit checks...
Rootkits checked : 114
Possible rootkits: 2
Rootkit names : Dreams Rootkit, Sin Rootkit
, how may I fix it ? is it possible to do without reinstalling the OS ? how may I delete those rootkits ?
|
|
|
08-11-2007, 12:54 PM
|
#6
|
Member
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301
Rep:
|
Well, you could remove the rootkits, but there may be others undetected, so it is recommended to reinstall.
In the future, make regular backups so you can restore from them without having to reinstall everything.
But more important would be preventing the hacker from hacking you.
Here are the steps I would take if I were you:
1. Reinstall the OS and everything you use.
2. Install nmap ( http://insecure.org/nmap/ )
3. Scan the computer for open ports (type "nmap localhost" in a terminal) and close the programs I don't need, and block the programs that shouldn't be accessed remotely with an iptables firewall (deny all ports except the ones you must have open. google for a good tutorial on how to do this).
4. Install an intrusion detection system, such as snort ( http://www.snort.org/) and closely monitor everything.
5. Create a cron job that backs up your log files often, or mails them to you at a remote address.
6. Have strong passwords (letters lowercase+uppercase, numbers and special characters, at least 7 characters long) on everything, and change them often.
7. Have the latest version of everything you use.
|
|
|
08-12-2007, 12:40 PM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,415
|
Quote:
Originally Posted by Valkyrie_of_valhalla
Well, you could remove the rootkits, but there may be others undetected, so it is recommended to reinstall.
In the future, make regular backups so you can restore from them without having to reinstall everything.
But more important would be preventing the hacker from hacking you.
Here are the steps I would take if I were you:
1. Reinstall the OS and everything you use.
2. Install nmap ( http://insecure.org/nmap/ )
|
Those wouldn't be the first steps I'd suggest. Reinstalling "everything" without making sure the vulnerabilities (the crackers point(s) of entry) are dealt with first (and regardless of any network access restrictions, logging or proactive auditing) is a recipe for trouble, and you don't even need nmap for step two.
If you don't have any clue what went wrong then yes, you can still blindly reinstall "everything", but then you'd have to totally isolate the box: you can't come out of the initial post-install reboot into any runlevel that is multi-user and network capable unless you change the ingress and egress policies on the host-based firewall to be restrictive and drop everything. If this is a colo host then you can't do w/o network (checked any adjacent hosts you own first?) and you must set the policies to only accept network traffic from and to your remote management client. Additionally all network-capable services like FTP, HTTP, etc, etc (with the exception of user (not root) accessable SSH if remote) should be off.
So the *right* way would be to find out what went wrong. Use this checklist: Intruder Detection Checklist (CERT): http://www.cert.org/tech_tips/intrud...checklist.html to find signs and please boot a Live CD like HELIX or KNOPPIX when investigating (OK, won't work if you run a colo box). Wrt to Rootkit Hunter findings: you posted only the summary which is nice for a first glance, but no actual "evidence". The logfile should reveal more (as would in your case running rpm -Vv). (While not valid in your case, since you already know the cracker got root, you should also be aware tools like Rootkit Hunter and Chkrootkit aren't infallible and can produce false positives.) As Linux Security forum moderator and being part of the Rootkit Hunter team I'm interested in *what* exactly it found on your box, so if you could post the relevant parts of rkhunter.log I'd appreciate it. At least give me results from this back:
Code:
#!/bin/bash
ROOTDIR="/"; for f in ${ROOTDIR}dev/.haos/haos1/.f/Denyed ${ROOTDIR}dev/ttyoa \
${ROOTDIR}dev/ttyof ${ROOTDIR}dev/ttyop ${ROOTDIR}dev/ttyos ${ROOTDIR}usr/lib/.lib \
${ROOTDIR}usr/lib/sn/.X ${ROOTDIR}usr/lib/sn/.sys ${ROOTDIR}usr/lib/ld/.X \
"${ROOTDIR}usr/man/man1/.." ${ROOTDIR}usr/man/man1/.../.m ${ROOTDIR}usr/man/man1/.../.w \
${ROOTDIR}usr/bin/sense ${ROOTDIR}usr/bin/sl2 ${ROOTDIR}usr/bin/logclear \
"${ROOTDIR}usr/bin/(swapd)" ${ROOTDIR}usr/bin/snfs ${ROOTDIR}usr/lib/libsss \
${ROOTDIR}dev/ida/.hpd; do [ -e "${f}" ] && { file "${f}"; stat "${f}"; }; done; exit 0
Since you already know the box was compromised you should also read: Steps for Recovering from a UNIX or NT System Compromise (CERT): http://www.cert.org/tech_tips/root_compromise.html and *before* reinstalling the OS you should repartition and reformat. (If you're paranoid you could zero out the drive with DBAN or similar.) Even if this looks more like a pro forma thing, nuking the drive(s) ensures that from a system integrity point of view you start with a *real* clean slate. More info in the LQ Security references: http://www.linuxquestions.org/questi...threadid=45261
Also, if the backup format allows for any gaps not to be filled (meaning everything that is not a bit-for-bit copy) and if the source and destination cannot be verified separately and independantly (Aide, Samhain etc, etc) and if the system isn't hardened appropriately, then making backups is *not* automagically a valid and secure way to "restore from them without having to reinstall everything"!
|
|
|
08-13-2007, 05:30 AM
|
#8
|
LQ Newbie
Registered: Apr 2007
Posts: 22
Original Poster
Rep:
|
Thank you for your detailed reply. I executed your script , it didnt return anything.
about rkhunter log , I looked into it closely and deleted all of suspicious files. but I am having problem deleting some files.
can you please look into the following post ?
http://www.linuxquestions.org/questi...=1#post2857152
my box is a dedicated box in a datacenter so I dont have physical access to it. but I can boot it into rescue mode by my control panel.
|
|
|
08-13-2007, 12:32 PM
|
#9
|
Moderator
Registered: May 2001
Posts: 29,415
|
Quote:
Originally Posted by SPEEDEX
I executed your script , it didnt return anything.
about rkhunter log , I looked into it closely and deleted all of suspicious files.
|
Heh, I suggested you run investigation booting a Live CD (OK, I didn't know the box was in colo)...
Deleting files is the *best* way to help a cracker: you're helping her thwart your own investigation.
Quote:
but I am having problem deleting some files.
can you please look into the following post ?
|
Looked at it. Unfortunately that's the least of your problems.
Quote:
my box is a dedicated box in a datacenter so I dont have physical access to it. but I can boot it into rescue mode by my control panel.
|
Whatever rescue mode it is it probably isn't going to be any good since it allows network access.
I'd alert the colo people (and any privileged users) your box was compromised and ask them to make a filesystem level backup, database dump, whatever is necessary (no 'dd' copy), and keep that backup apart from the other backups since it's no good for restoring files. Then ask them to nuke the disk(s) and reinstall from scratch. Make sure they hand off the box with all services except your panel down (hope it's a non-vulnerable one/version itself) and if they can manage it tied to your management IP.
If you can expect no help from your colo people, have any questions or whatever else related just say so and we will discuss it.
|
|
|
All times are GMT -5. The time now is 09:47 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|