Been hacked?, was: How to disable rm command for an user
Linux - SecurityThis 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.
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.
If you really have no idea how they are getting in, you need to do a clean install and lock down the box as best you know how.
With all due respect, that is the wrong way to go about this. This apparently has already happened twice and unless the OP takes the time to figure out why, it will keep happening. A clean install might be helpful, but then again they might just be putting the same vulnerabilities in place. Without an investigation, they simply are guessing.
3 members found this post helpful.
Click here to see the post LQ members have rated as the most helpful post in this thread.
With all due respect, that is the wrong way to go about this. This apparently has already happened twice and unless the OP takes the time to figure out why, it will keep happening. A clean install might be helpful, but then again they might just be putting the same vulnerabilities in place. Without an investigation, they simply are guessing.
I see your point, I think I was being a little (or rather, extremely) optimistic. When I said 'lock down the box as best as you know how', I really should have said, 'learn as much as you possibly can about securing Linux and put it into practice'. He needs to take a pro-active approach to security, not just wait vulnerabilities to be exploited and then fix them.
That all said, you are right, the OP needs to find the vulnerability - although I fear that it may prove to be little like searching for a hole in a sieve. Hopefully, just the act of trying to find out how his server was exploited will demonstrate just how insecure it (almost certainly) is.
Is it possible to elaborate on your actual problem you want to solve rather than asking about this particular solution?
Congratulations! That was the first sane question the thread has seen up to that point. I don't get why it needs to take five posts to get there. Anyone with practical knowledge of GNU/Linux should realize what the OP wants to achieve is not the goal but a symptom of something else.
Quote:
Originally Posted by Hangdog42
You're looking at the wrong problem. What you need to address is why your server gets cracked repeatedly. Until you start addressing that, everything else is likely useless.
Yes! One hundred percent on the mark! Kludges, changed permissions, in fact every other suggestion directly addressing the OP's question, is just plain wrong.
Quote:
Originally Posted by hansemmanuel
My actual problem is one webserver is hacked..A malicious script ran on that server.
As Hangdog42 already suggested: read that link as it provides you with steps to perform and give us details we can work with.
In the meanwhile:
- verbosely list (and save) processes, open files, network connections and user login records,
- shut down your web stack (web server, database) and any other Internet-facing services you don't need to access the machine (you only need SSH),
- raise your firewall to only allow traffic between your server and your (home, management) IP (or range).
That should at least stabilize things while you get a grip on how to collect "evidence".
Last edited by unSpawn; 04-07-2010 at 10:49 AM.
Reason: //more *is* more
If it is just that user affected, then you can probably just delete the user (if you are in a hurry) but you must address the security problem.
Note: - something is running rm as a specific user? Has that user installed/run the malware? Why is the whole server dependant on files with user write access?
Last edited by Simon Bridge; 04-07-2010 at 11:33 AM.
This is very tough to do, because this looks like security by obscurity...
say you revoke the rights to execute 'rm' by the chmod commands given.. what prevents me from copying the rm binary to my homedir, giving it execute permissions and then just use that one...
Let's focus on his cracked machine and what to do with it.
Quote:
Originally Posted by Tinkster
But that would stop EVERYONE who's not root; not
what he asked for ;}
With all due respect but what he asked for, or any discussion that does not address helping him clean up his act, is only distraction at this point. Let's focus on his cracked machine and what to do with it. If anyone however feels it is worth discussing secondary issues I will happily prune off that part of the discussion to a spanking brand new thread. I hope y'all catch my drift wrt priorities and such.
With all due respect but what he asked for, or any discussion that does not address helping him clean up his act, is only distraction at this point. Let's focus on his cracked machine and what to do with it. If anyone however feels it is worth discussing secondary issues I will happily prune off that part of the discussion to a spanking brand new thread. I hope y'all catch my drift wrt priorities and such.
It was just a side thought, no need for a new thread.
If it bothers you that much then remove the post.
Quote:
Originally Posted by Tinkster
But that would stop EVERYONE who's not root; not
what he asked for ;}
If anyone however feels it is worth discussing secondary issues...
The problem is that the OP is the one that is directing the discussion towards secondary issues...
Quote:
Actually now i am planning to improve my security by IDS or a logging s/m
Probably a worthwhile additional measure, but its not investigating/fixing the basic security problem (or problems); why are you resisting working on the basic problem?
Actually now i am planning to improve my security by IDS or a logging s/m
which is the better one logwatch? for IDS snort?
Salasi is right. Unless you're willing to start looking at how you were cracked in the first place, adding logwatch or Snort won't do you any good. Heck, it might even make the situation worse by giving you a false sense of security if you put them on a cracked machine .
True, on a cracked system your logfiles can't even be trusted..
Don't know what distro you're using, but is SELinux available? This cripples a hacker enormously for not being able to use binaries that are not meant for him to run.. I'd imagine that the 'apache' user is not allowed, within his (SELinux) domain, to remove any files. I would have to dig into the TEs for that, but it'd make sense.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.