ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am a very novice unix user, i help managing a web hosting server and recently got infected by a worm or malware that introduced several lines in almost all index (htm, html, php, and so on) files of our domains. These string in most cases doesnt affect and doesnt appear on the webs affected but for obvious reasons we would like to clean them.
In another forum i got the following suggestion:
If in infected page attached some links and all of them is identical (i.e. it is something like:
URL(somedomain. com. index .htm)
(spaced since i cant post URls)
then you can use standard nix tools like find, grep or sed and replace this code with something neutral. just search google for "sed delete last string" "sed replace string" or something else.
EN OF QUOTE.
I have never used this sed command and am not sure if this can help.
Plainl the question is if there would be a command to perform this cleanup and also if you can suggest a way to find the worm or malware that produced this (since clenaning manually doesnt work, because it reappears after a while).
for x in `find /var/www/htdocs -name 'index.*'`; do
echo "Working on file: $x"
sed -i.bak 's|domain.tld/index.htm|mysite.tld/index.html|g' $x
This changes the text "domain.tld/index.htm" to "mysite.tld/index.html" in all files with names starting "index." located beneath /var/www/htdocs. The originals are kept in files with the same name plus a .bak extension.
The 'find' cmd is recursive.
If the prob keeps re-occuring, you ned to fix that first, even if it means a re-install.
Check the Security forum for tips eg chkrootkit and rkhunter tools, also Tripwire.
You really need to make sure the systems are up to date and keep them that way.