The script you linked seems quite simple. You can do something like this by the following
one-liner:
find $DIRS -print0 | xargs -0 perl -p -i.bak -e 's/\Qcode to be removed\E//'
Here $DIRS
stand for the directories you have your files in and code to be removed
stands for the malicious code. The \Q
will quote any special characters up to the \E
. The original files are backuped into .bak
files. If you do not want this remove the .bak
, i.e. only -i
, but do not combine it with -e
, i.e. -i -e
not -ie
.
BE CAREFUL YOU MIGHT DELETE IMPORTANT STUFF IF YOU DO IT WRONG! MAKE BACKUPS BY YOURSELF FIRST!
Update:
Script version:
#!/usr/bin/env perl -i.bak
use strict;
use warnings;
my $code = <<'END-OF-MALICIOUS-CODE';
xo=new Date(2010,11,3,2,21,4);t=xo.getSeconds();var huur=[36/t,36/t, ....
END-OF-MALICIOUS-CODE
chomp $code; # remove trailing newline
while (<>) {
s/\Q$code\E//;
print;
}
But this into a file, best with a .pl
extension, e.g. remcode.pl
.
Optionally make it executable (chmod +x file.pl
), otherwise you have to call it with perl
explicitly:
find $DIRS -print0 | xargs -0 perl remcode.pl
You could do the 'find' part as well as perl code, but that it not needed.
No guarantees! Test it on a couple of files first!