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.
|
 |
02-24-2006, 10:06 AM
|
#1
|
Member
Registered: Mar 2004
Location: Maine
Distribution: gentoo 2004.1, ubuntu 4.10, FC3
Posts: 97
Rep:
|
Crap, I got hacked! Help!
My web server at work had two files uploaded to it that run remote commands via php. I'm not sure when, the files have last modified dates of 11/2005. I only have 4 user accounts on the server and they all have decent passwords...
My only thought is that I frequently chmod 777 -R my /var/www/html directory because I work on the websites with others and we get permissions problems sometimes... but someone would have to be a user first, before they could upload/save files to a directory... right?
Fedora Core 3 x86
dual opteron 2.0ghz
The server is on the DMZ of our sonicwall (firewall hardware). We've been getting the repetative ssh login attempts that seem to be going around, but they all seem to fail.
I don't know if it helps, but one of the files would only let you run commands if you authenticated yourself, on prompt, with the name "sh4rky" and the password "roxx"
and everything's in german.
What kind of measures can I take here to protect myself?
|
|
|
02-24-2006, 10:45 AM
|
#2
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
Once hackers have been able to hack into your system (bypassing security/firewalls), your system is compromised.
A full re-install is the only option. Sorry to bring you the bad news.
Hackers most likely try to obtain root access when they're inside, so your user authentication may be of secundary importance. But that depends on the security measures you've taken.
You talk about the PhP code. Was it run as root?
For the future, a few general tips may help prevent mayhem:
-regular backups;
-tighter security: less programs running as root, strict file permissions, no unnecessary opened ports,
latest updates - also for the firewall -, ... come to mind. An additional firewall on your webserver (iptables)
or access restrictions like tcpwrappers or something like tripwire may be handy.
|
|
|
02-24-2006, 11:30 AM
|
#3
|
Member
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112
Rep:
|
Also, instead of chomoding the files with 777 make a group for your 4 users who need access to the files and give that group full permissions instead of having read, write and execute permissions for everyone.
|
|
|
02-24-2006, 02:36 PM
|
#4
|
Moderator
Registered: May 2001
Posts: 29,415
|
My web server at work had two files uploaded to it that run remote commands via php. I'm not sure when, the files have last modified dates of 11/2005.
Are distro release, Apache PHP and any PHP apps updated to "latest"?
Do the system and application logs go that far back?
My only thought is that I frequently chmod 777 -R my /var/www/html directory because I work on the websites with others and we get permissions problems sometimes.
Even though it's clear the box is misconfigured (thats bad and purpose doesnt matter) it's more likely something flawed in any PHP apps or PHP.
but someone would have to be a user first, before they could upload/save files to a directory... right?
Right. Prolly Apache in your case :-]
I don't know if it helps, but one of the files would only let you run commands if you authenticated yourself, on prompt, with the name "sh4rky" and the password "roxx"
Save me a copy?
What kind of measures can I take here to protect myself?
In the first place please let the box be run by a capable admin or scale up your knowledge. Misconfiguration is one of the top-20 mistakes. Next to the other advice already given, please check out any recent thread about PHP-related compromises in this forum (we've been going over it quite extensively) and check out the LQ FAQ: Security references. We've added a piece at the end on LAMP security with emphasis on PHP.
* These are the days of the botnets and many crews are primarily interested in trying to getting their quota of slaves ready. Since obsolete, unrestricted, outdated and misconfigured installations of Apache/PHP apps/PHP already allow for enough rights to run whatever it is they need to run the chances of a full scale root account compromise appear to be less. Note: this is not to argue it did not happen to you! The reason I always recite the mantra "Repartition, Reformat, Re-install from scratch" is simply because newbies do not have the time and knowledge to set up a system in a way that provides enough clues to resurrect a box safely. Even then there will be no evidence passwords aren't nicked. Since you already have shown MAC-times for the files to be more than two months ago I agree you should have the box re-installed from scratch and hardened properly.
** Since this is a box in a work environment, see if you can get your hands on a staging box to fsck around with (on the intranet) and only copy over stuff to the (properly hardened) production box (in the DMZ) that's finalised and well-tested.
*** If you can't hand off the box to an admin you can ask questions here, but please make sure you have read enough of the core docs.
|
|
|
02-26-2006, 07:44 PM
|
#5
|
Member
Registered: Oct 2003
Location: King George, VA
Distribution: RHEL/CentOS/Scientific/Fedora, LinuxMint
Posts: 370
Rep:
|
Quote:
Originally Posted by timmeke
Once hackers have been able to hack into your system (bypassing security/firewalls), your system is compromised.
A full re-install is the only option. Sorry to bring you the bad news.
Hackers most likely try to obtain root access when they're inside, so your user authentication may be of secundary importance. But that depends on the security measures you've taken.
You talk about the PhP code. Was it run as root?
For the future, a few general tips may help prevent mayhem:
-regular backups;
-tighter security: less programs running as root, strict file permissions, no unnecessary opened ports,
latest updates - also for the firewall -, ... come to mind. An additional firewall on your webserver (iptables)
or access restrictions like tcpwrappers or something like tripwire may be handy.
|
Once criminals have been able to hack into your system (bypassing security/firewalls), your system is compromised.
A full re-install is the only option. Sorry to bring you the bad news.
Criminals most likely try to obtain root access when they're inside, so your user authentication may be of secundary importance. But that depends on the security measures you've taken.
You talk about the PhP code. Was it run as root?
For the future, a few general tips may help prevent mayhem:
-regular backups;
-tighter security: less programs running as root, strict file permissions, no unnecessary opened ports,
latest updates - also for the firewall -, ... come to mind. An additional firewall on your webserver (iptables)
or access restrictions like tcpwrappers or something like tripwire may be handy.
|
|
|
02-27-2006, 02:20 AM
|
#6
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
doublejoon,
duely noted...
|
|
|
02-28-2006, 12:54 PM
|
#7
|
Member
Registered: Mar 2004
Location: Maine
Distribution: gentoo 2004.1, ubuntu 4.10, FC3
Posts: 97
Original Poster
Rep:
|
Thanks guys. Great idea Cramer.
I work for a small company that wants to move to linux but I'm the only one who knows anything, and I would like to defend myself a little and say I've been able to swap an entire e-commerce windows-hosted website with an as400 backend to a linux-hosted website with an as400 backend. It wasn't easy, and I learned a lot.
What I know about linux I've gotten from hating Windows in my private time (for about 5 years now, I might add), it's just that at home I have not had to protect myself from ravenous criminals.
I mean, I've installed and loved gentoo (2004.1 when it was new). That means I'm L33T, right? 
No not stage 1.
Anyway, I've learned one thing at least: I would not be so stressed right now if this was someone else's problem. I should stop trying to do everything and just make websites.
|
|
|
02-28-2006, 01:06 PM
|
#8
|
Member
Registered: Mar 2004
Location: Maine
Distribution: gentoo 2004.1, ubuntu 4.10, FC3
Posts: 97
Original Poster
Rep:
|
Oh, right, so I forgot to say what else I've found since my first freak out.
I went through my apache logs (in urchin) for the day that the files had as their last modified dates. Just for kicks, I drilled down the domain starting from .de and one german domain stood out 10:1 traffic compared to others. Then I looked within a week radius of the date and the domain kept coming up... but not much outside of that week. What was the domain? uni-leipzig.de
So needless to say it may be a highjacked lab PC, or it may be the criminal. Either way one measure I've taken is to deny the domain (we don't sell outside of the US and Canada anyway).
I've also been able to deduce that they didn't run anything as root and couldn't use sudo. I WOULD format the machine, but I still haven't learned how to secure it so they could easily do the same thing again and then I would have wasted a lot of time giving myself a false piece of mind.
No damage has been done now. I will try to figure out how to secure my development server that is pretty similar, except that it's a single amd64 with fc3 64bit and not a dual opteron with fc3 32bit.
Quote:
Originally Posted by timmeke
doublejoon,
duely noted...
|
and now dually noted
Last edited by devfreak; 02-28-2006 at 01:07 PM.
|
|
|
All times are GMT -5. The time now is 12:43 PM.
|
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
|
|