Using SED to fix base64_decode attack/hack


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using SED to fix base64_decode attack/hack
# 1  
Old 03-16-2012
Using SED to fix base64_decode attack/hack

last night our server was hit with an attack that infected every php file on the server and inserted the following code


Code:
/*god_mode_on*/eval(base64_decode

with a ton of other characters after.

As it infected every php file i have been trying to clean it using a
sed command to go through and remove the code from each file.

I have been trying to run


Code:
find . -name "*.php" -type f -exec sed -i '/eval(base64_decode(/d' {} \;

This is workng except it is also removing the <?php from the start
of files. Anyone know how to fix this or how I can run sed again to
insert <php? back in at the start. Preference would be to not lose
it in the first place though.


I have tried running sed a second time against these files with this command



Code:
sed -i '1s/^/<php?\^J/' *.php

And that is inserting the <php? however the ctrlJ is not acting as a line return and is actually inserting <php?/^j at the start of each file

Any help appreciate as I have 10K files to fix

Last edited by pludi; 03-16-2012 at 09:20 AM..
# 2  
Old 03-16-2012
sed

Hi,

You can insert new line with the help of
Code:
\n

in sed if you use other than sun solaris system.

Code:
echo "one two three" | sed 's/ /\n/g'

I am replacing space( ) with new line(\n).

Output:
Code:
one
two
three

Cheers,
RangaSmilie
# 3  
Old 03-16-2012
I hate to say it but it is nearly impossible to fully cleanup from these types of attacks if the site consists of more than a few PHP files. Why not restore the site from a backup?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

How to hack computer games that is paid???

Plz help me to hack computer games that is paid ty (1 Reply)
Discussion started by: 09287501067
1 Replies

2. Cybersecurity

How can someone hack into a Linux server ?

Hi! I have a debian linux VPS and i am wondering how would someone be able to hack into it , in what ways ? I've asked a more knowledgeable friend and he said the only way someone would be able to get into my VPS is via FTP or SSH, are there some other ways someone can enter my machine ? I... (18 Replies)
Discussion started by: ParanoiaUser
18 Replies

3. Shell Programming and Scripting

Fix timestamp with Sed or Awk

Hi I am dealing with the following string: Date: Thur, 13 March 2011 01:01:10 +0000 I asked for help in another topic that converted a similar string: Date: Thur, 13 March 2011 9:50 AM To a 24 hr standard. The problem is that it comes out as: Date: Thur, 13 March 2011 9:50:00 +0000... (4 Replies)
Discussion started by: duonut
4 Replies

4. Solaris

tty hack

hi all, what i want to do when user open terminal like tty5 and do his work i want to see his terminal how can i do this (1 Reply)
Discussion started by: xxmasrawy
1 Replies

5. UNIX for Dummies Questions & Answers

Hack CPU Utilization

Hi friends, I am currently working on an issue where i should write a program which utilizes Cpu as specified by the user. The function should be provided with an argument ( how much percentage of CPU has to be utilized by the process ) for example CPU(75) should utilize 75% of CPU. The function... (11 Replies)
Discussion started by: nerdychandru
11 Replies

6. Linux

sed to fix view names

I have a ddl file which have lots of view in it. I want to replace all the existing views with VW_< view name> . I am prefixing VW to existing view name . For example, In old file grep on view is like this CREATE VIEW OPSDM001.PROVIDER_MBR_PRI ( MBR_PRI_PROV_SYS_ID,... (6 Replies)
Discussion started by: capri_drm
6 Replies
Login or Register to Ask a Question