LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 04-07-2010, 01:17 AM   #1
hansemmanuel
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Rep: Reputation: 0
Been hacked?, was: How to disable rm command for an user


I just want to disable rm command for an user..Root only need to use that.

Can anyone help me???
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-07-2010, 01:24 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.7, Solaris 10
Posts: 10,987

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
On my system it looks like

-rwxr-xr-x 1 root root 44008 Mar 1 08:33 /bin/rm

so, if you really want root and ONLY root to be able to use it, remove the perms for others ie

-rwxr-x--- 1 root root 44008 Mar 1 08:33 /bin/rm

I'd leave the group perms on because there are prob scripts that need it that may be run by services that are in root group but not owned by root.
You may still get probs, so keep a strict eye on your logs for a while.
 
0 members found this post helpful.
Old 04-07-2010, 01:25 AM   #3
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Bangalore, India
Distribution: Fedora, Linux Mint 10
Posts: 585

Rep: Reputation: 63
Quote:
Originally Posted by hansemmanuel View Post
I just want to disable rm command for an user..Root only need to use that.

Can anyone help me???
Try this:

Quote:
#chmod o-x /bin/rm
#chmod g-x /bin/rm
 
0 members found this post helpful.
Old 04-07-2010, 01:43 AM   #4
pkhera_2001
Member
 
Registered: Mar 2006
Location: New Delhi, India
Distribution: Fedora, CentOS, RHEL, Ubuntu
Posts: 67

Rep: Reputation: 18
Hi hansemmanuel!

You can either remove the execute permission from the rm command but that will restrict other users also from executing the rm command.

So, you can make "bin" folder under user's home folder containing softlinks to executeables in /bin folder and just remove rm softlink from user's ~/bin folder and set user's default path under ~/.bashrc file to use ~/bin for search for executeables.

Details steps for the same are given on below link:
http://linuxbuddies.com/2008/12/22/h...-certain-user/

Note: As mentioned on link user can overcome this aproach by resetting $PATH variable.

Thanks,
Pkhera
 
0 members found this post helpful.
Old 04-07-2010, 01:43 AM   #5
hansemmanuel
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Suppose I want to disable rm for a particular user...Is there any option for that?
 
Old 04-07-2010, 01:53 AM   #6
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Bangalore, India
Distribution: Fedora, Linux Mint 10
Posts: 585

Rep: Reputation: 63
Quote:
Originally Posted by hansemmanuel View Post
Suppose I want to disable rm for a particular user...Is there any option for that?
You can implement acl on /bin/rm for that particular user.
 
0 members found this post helpful.
Old 04-07-2010, 02:23 AM   #7
rhoekstra
Member
 
Registered: Aug 2004
Location: The Netherlands
Distribution: RedHat 2, 3, 4, 5, Fedora, SuSE, Gentoo
Posts: 296

Rep: Reputation: 32
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...

You'll have to control where a (or 'any') user can write files and that places should not have 'noexec' in the mount option (don't put it on the / filesystem ).

In my opinion it is a regular use of any unix (linux) system to be able for a user to remove files.. the binary rm is just a way to achieve this.. a user could as well write a simple perlscript and use 'unlink' from there.. because the filesystem allows it ....

To prevent a user from deleting (certain) files is to make sure the files (and directories) are not owned by the specific user...

Is it possible to elaborate on your actual problem you want to solve rather than asking about this particular solution? Perhaps your problem is of some other order you can resolve differently... (my question would be: what is the harm in that a user can remove files it has the appropriate rights to?)
 
5 members found this post helpful.
Old 04-07-2010, 02:58 AM   #8
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu 10.04
Posts: 9,195
Blog Entries: 4

Rep: Reputation: 190Reputation: 190
If you do this, then users may not be able to delete their own files. Surely you want them to be able to manage their own home directories?!

By default, users can only use rm to delete files with permissions which allow them to - which is usually only their own. So what is the problem exactly? Do you have users who have managed to delete files you don't want them to? (Maybe you had a user who deleted all the hidden files in their home directory with a dos-style rm *.*?)
 
Old 04-07-2010, 03:02 AM   #9
hansemmanuel
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Original Poster
Rep: Reputation: 0
My actual problem is one webserver is hacked..A malicious script ran on that server.
It is the second time happening like this..
The script is deleting certain important files..as a result webserver is down without it's pages.
The script is using rm command...it is deleting that particular user's file..imagine his name is joe..
what can I do to prevent this??
 
Old 04-07-2010, 03:04 AM   #10
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Bangalore, India
Distribution: Fedora, Linux Mint 10
Posts: 585

Rep: Reputation: 63
Quote:
Originally Posted by hansemmanuel View Post
My actual problem is one webserver is hacked..A malicious script ran on that server.
It is the second time happening like this..
The script is deleting certain important files..as a result webserver is down without it's pages.
The script is using rm command...it is deleting that particular user's file..imagine his name is joe..
what can I do to prevent this??
As i said implement an acl for that user denying rwx permission.
 
Old 04-07-2010, 03:05 AM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,115
Blog Entries: 9

Rep: Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627
One (silly, see post above by rhoekstra) way of doing it would be to
add that user to a specially created group, say norm, and modify
ownerships & permissions on the binary like this:

Code:
chgrp norm /bin/rm
chmod u=rwx,g-rx,o=rx /bin/rm
This will work because the pemissions are evaluated left to
right, and the user who's in norm will not get the "others"
permissions to read or execute (so he can't copy, either).

But it still seems like a weird request, considering that
the user can only a) delete their own files in the first
place and b) will always be able to vandalise them. What's
the point of having all his 0-length files preserved?



Cheers,
Tink
 
1 members found this post helpful.
Old 04-07-2010, 03:06 AM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,115
Blog Entries: 9

Rep: Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627
Quote:
Originally Posted by hansemmanuel View Post
My actual problem is one webserver is hacked..A malicious script ran on that server.
It is the second time happening like this..
The script is deleting certain important files..as a result webserver is down without it's pages.
The script is using rm command...it is deleting that particular user's file..imagine his name is joe..
what can I do to prevent this??


Tighten up security on the server ... and with these
words I'm moving this thread over to our security forum.



Cheers,
Tink
 
Old 04-07-2010, 03:50 AM   #13
penguiniator
Member
 
Registered: Feb 2004
Location: Fife, WA
Distribution: Fedora
Posts: 435
Blog Entries: 3

Rep: Reputation: 59
rm isn't the only program malicious scripts can use to remove files. unlink can wreak havoc, too.
 
Old 04-07-2010, 07:55 AM   #14
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,679
Blog Entries: 1

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
My actual problem is one webserver is hacked..A malicious script ran on that server.
It is the second time happening like this..
The script is deleting certain important files..as a result webserver is down without it's pages.
The script is using rm command...it is deleting that particular user's file..imagine his name is joe..
what can I do to prevent this??
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. If you care to start posting details about the crack, we can help you. If you want a guide on how to start gathering facts, this is a good place to start.
 
4 members found this post helpful.
Old 04-07-2010, 08:17 AM   #15
nonamenobody
Member
 
Registered: Oct 2002
Posts: 138

Rep: Reputation: 20
Quote:
Originally Posted by Hangdog42 View Post
You're looking at the wrong problem. What you need to address is why your server gets cracked repeatedly.
Indeed, it is a bit like saying you want to put a lock on your fridge because someone keeps breaking into your house and eating your cheese - i.e. they are still free to steal your fridge or murder you in your sleep.

First you need to find out how they are getting in. Secondly you primarily restrict the damage that people can do by setting appropriate permissions, not by removing access to certain commands.

Disabling rm will stop them using that one command, they could still use (say) a PHP script to delete the file or the could overwrite the file or move it - if you set appropriate file permissions then all those will be prevented. I think that them deleting the website is the least of your worries, for example what if they were to modified your website so that your visitor's computers were infected by a virus which in turn stole their identity and drained their bank accounts?

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. If you have have a server on the Internet and you don't learn about security, it will get cracked every day. Yes, Linux is a secure operating system and most distros are pretty secure as they shipped, but as soon as you start making services available to Internet you are opening it to potential attack.

Last edited by nonamenobody; 04-07-2010 at 08:24 AM.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable a user sasikumar123 Linux - Newbie 2 08-09-2009 02:59 AM
Been Hacked! May I get control of my Root user again? xpucto Linux - Security 4 11-14-2006 08:46 PM
dbx command for corrosponding commands disable or disable on gdb bshankha AIX 0 09-26-2006 10:38 AM
disable user login ust Linux - General 2 04-01-2004 01:06 PM
top command, being hacked? shanenin Linux - Software 4 10-30-2003 09:25 PM


All times are GMT -5. The time now is 03:00 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration