แก้ Malware jstools.js ฉบับรันบนเว็บ

Written on 2:24 PM by ปั้มเงิน Cookie Run

แก้ Malware jstools.js ฉบับรันบนเว็บ
ไม่มีอะไรมาก แค่ Copy ไปวางในไฟล์ PHP แล้วก็รัน


set_time_limit(600);
echo "-";
define('DS', DIRECTORY_SEPARATOR);
define('BASE_PATH', realpath(dirname(__FILE__)));
flush();
$source = BASE_PATH;
$sourceMain = $source ;
function smartFind($source){
global $sourceMain ;
$dirHandle=opendir($source);
while($file=readdir($dirHandle))
{
flush();
if($file!="." && $file!="..")
{
if(!is_dir($source.DS.$file)){
if( $file == 'index.php' || $file == 'index.html' || $file == 'index.htm' || $file == 'main.php' || $file == 'main.html' || $file == 'main.htm' )
{
$files = $source.DS.$file;
$str = array('@@si');
chmod($files,0777);
$fp = fopen($files, 'r');
$text = @fread($fp, filesize($files));
$text = preg_replace($str, '', $text, -1 , $count);
fclose($fp);
$fp = fopen($files, 'w+');
fwrite($fp, $text);
fclose($fp);
chmod($files,0444);

if($count){
echo $files."
";
++$inum;
$fh = fopen($sourceMain.DS.'log.txt', 'a');
$log = $files." Edit:{$count}\r\n";
fwrite($fh, $log);
fclose($fh);
}
}
} else {
echo $source.DS.$file."
";
smartFind($source.DS.$file);
}
}
}
closedir($dirHandle);
}
smartFind($source);

Malware jstools.js

Written on 11:56 AM by ปั้มเงิน Cookie Run

วันนี้ก็ต้องมานั่งแก้ Malware jstools.js ขยันติดจริง เจ้า Malware jstools.js โดยลักษณะของ Code Malware ตัวนี้คือ
<script src="http://xn--wytrwa-g1a.tarnobrzeg.pl/jstools.js" type="text/javascript">
</script>
<script src="http://xn--niewraliwo-zhb12hem.swidnica.pl/jstools.js" type="text/javascript">
</script>


แล้วก็อื่นอีกหลายตัว แต่ลงท้ายด้วย/jstools.js

OK~ เรามาเริ่มวิธีจัดการมันเลยดีกว่า
ขั้นแรก เราต้องค้าหาไฟล์ที่ติดก่อน ในที่นี้คือไฟล์ indexและ main
find /home -name 'index.php' -or -name 'index.html' -or -name 'index.htm' -or -name 'main.php' -or -name 'main.html' -or -name 'main.htm' -or -name 'default.php' -or -name 'default.html' -or -name 'default.htm' >errors.txt
เนื่องจากผมต้องมานั่งแก้ทั้ง Server วิธีที่ดีที่สุดคือหาไฟล์เหล่านี้มาเก็บไว้ก่อนแล้วค่อย รันคำสั่งแก้ทีเดี่ยว เพราะถ้าไม่ทำแบบนี้มันจะหนัก Server.

ขั้นต่อมา คือเขียนคำสั่งวนลูป อ่านไฟล์ errors.txt หรือ ไฟล์ที่เก็บรายชื่อไฟล์ที่น่าจะติด Malware jstools.js ครับ ในที่นี่ผมเขียนคำสั่ง PHP แก้เอาง่ายดี เหอะๆ.

<?php
$inum = 0;
$files = "/home/errors.txt";
if(file_exists($files))
{
$filelist = file($files);
foreach($filelist as $file)
{
$text = $count = false;
if( trim($file) !== '' ) $file = trim($file);
$str = array('@@si');
chmod($file,0777);
$fp = fopen($file, 'r');
$text = @fread($fp, filesize($file));
$text = preg_replace($str, '', $text, -1 , $count);
fclose($fp);
$fp = fopen($file, 'w+');
fwrite($fp, $text);
fclose($fp);
chmod($file,0444);

if($count){
++$inum;
$fh = fopen('/home/log.txt', 'a');
$log = $file." Edit:{$count}\r\n";
fwrite($fh, $log);
fclose($fh);
echo $inum;
echo $file."\n";
}
}

}
?>


แค่นี้ละจบกันทีกับ Malware jstools.js

X Close