Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
My server's been hacked EMERGENCY

I have following code in hundreds of my html and js files:


I need find and remove the above code using SED in bash. Just cannot figure out that how can i remove/replace string using sed, between a starting and specific ending string.

Thanks in advance

share|improve this question

marked as duplicate by Iain Aug 10 '12 at 9:33

This question was marked as an exact duplicate of an existing question.

up vote 0 down vote accepted

Nevermind. i got its solution just after posting the question :)

sed '/km0ae9gr6m/d' index.html

If above string portion is found, it will remove that line completely.

share|improve this answer
This really doesn't solve your problem as your server has been compromised and without wiping it an reinstalling from a known good backup you can't be sure there aren't more backdoors. – Iain Aug 10 '12 at 9:35
i have already closed all backdoors, its just few files in the backup were infected. so had to clean them up/ – Farhan Aug 10 '12 at 9:49
WRONG. You've closed all the known backdoors, and disinfected the files you know were infected. It's the unknown unknowns that get you. – Tom O'Connor Aug 10 '12 at 10:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.