ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
QUOTE:
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
done
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.