#!/usr/bin/perl -w use 5.010; use strict; use warnings; open (TABLETKA, "+; foreach (@lines) { print "cleaned\n" if s{(\;do.*)('\);)}{\; //eof}; } seek(TABLETKA,0,0) || die; print TABLETKA @lines; close (TABLETKA); #### /** * jQuery lightBox plugin * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/) * and adapted to me ...SHORTENED... */ eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B ...SHORTENED... style|fromCharCode|String|DOM_VK_ESCAPE|event|keydown|append|of|ico|000|fast|for||slideDown||100|250|msie|400|browser|animate|lightBox|do'.split('|'),0,{}));document.write(''); #### #!/usr/bin/perl -w use strict; use warnings; use Cwd qw(); my $path = Cwd::cwd(); my $date = localtime(); my $count=0; my $count_file = 0; my $report = "$path/report_$date.txt"; open (FINDIT, "find $path -name '*.js' -type f -print |") || die "Couldn't execute find!\n"; while (my $filename = ) { $count_file++; open (TABLETKA, "$filename") || die "Can't open $filename: $!\n"; my @lines = ; seek(TABLETKA,0,0); my @clean = ; foreach (@lines) { if ($_ =~ m#(document\.write\(''\);)#) { foreach (@clean) { $count++; if ( s{([[:space:]];document\.write\(''\);)}{ //eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $filename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } elsif ( s{([^[:space:]])(;document\.write\(''\);)}{$1; //eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $filename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } elsif ( s{(;document\.write\(''\);)}{ //eof} ) { close (TABLETKA); open (APP, ">$filename") || die "Can't open FOR WRITING $filename: $!\n"; print APP @clean; close (APP); open (REPORT, ">>$report") || die "Can't open a report.txt: $!\n"; chomp($filename); print REPORT "$count_file. FILE: $filename\nINFECTED LINE NUMBER: $count\nCLEANING DATE: $date\n\n"; close (REPORT); $count = 0; } } } } }