#######################################################################
# PHP Program Name : FizScript   
# Program Version 3.2.2 (Recommended)
# PHP Search and Replace in file ( replace a line in a file )
# Create date : 21/04/2009 # By Chareanrut Junnithi ( nick : "mean" ) 
# Last Modify : 4/11/2009
# Present : http://fizscript.ishare.in.th 
# Sponsor : http://www.ireallyhost.com
#
#
# เรียนท่านผู้ใช้ ก่อนดำเนินการใช้งาน โปรดดำเนินการตั้งค่า โดยทำการเปิดแก้ไขไฟล์  ด้วยโปรแกรม text edit เช่น editplus
# ทำการตั้งค่าต่างๆ เช่น อีเมล์ของคุณ เพื่อใช้ในการตอบกลับ ให้คำแนะนำ เกี่ยวกับการส่ง Report
#
# โปรดศึกษา ข้อมูล แนะนำต่อไปนี้ !
# โปรดให้ความเคารพต่อผู้พัฒนาโปรแกรม มิควรตัดเครดิสผู้พัฒนา แต่สามารถเขียนเพิ่มเติมได้
# ผู้พัฒนาหวังเพียงว่า โปรแกรมนี้ จะเป็นประโยชน์ต่อส่วนรวม และท่านทั้งหลาย 
# หากมีการพัฒนาเพิ่มเติม กรุณาเขียน comment เพิ่มเติมนี้ และแจ้งได้ที่อีเมล์หรือเว็บของผู้พัฒนา
#
# โปรแกรมนี้ เป็นฟรีโปรแกรม โดยอ้างอิงนโยบายข้อบังคับ ตาม The GNU General Public License v.2
# และ แสดงที่มา-อนุญาตแบบเดียวกัน 3.0 ประเทศไทย ( CC 3.0 )
# สามารถทำการเผยแพร่ ปรับปรุง อันเป็นไปตามข้อกำหนดข้างต้น
# ท่านสามารถรายงานข้อผิดพลาด แก่ทางผู้พัฒนา และติดตามการปรับปรุงแก้ไข ผ่านทางเว็บไซต์ได้
#
#
######################################################
# เพื่อการแก้ไขปัญหา อย่างมีประสิทธิภาพ สามารถติดตามข้อมูลคำแนะนำ หรือเสนอข้อเสนอแนะ ได้ที่
# @ http://fizscript.ishare.in.th
######################################################
#
# คุณสมบัติ การทำงาน
# @ ระบบสามารถช่วยค้นหา และ แก้ไขปัญหาไวรัสไอเฟรม ไวรัสเว็บไซต์ ได้อย่างมีประสิทธิภาพ
# @ ระบบสามารถทำการสำรองไฟล์ ก่อนทำการแก้ไขได้
# @ ทำการค้นหา และแก้ไข โดยใช้เงื่อนไขได้อย่างมีประสิทธิภาพ
# @ ระบบสามารถทำการค้นหา คำ หรือ แทร็ก ในไฟล์ ที่กำหนดได้ ทั้งในโฟเดอร์ และโฟรเดอร์ ย่อย
# @ ผู้ใช้โปรด ศึกษารูปแบบ code  ให้แน่ใจว่าท่านต้องการแทนที่ หรือ ลบ บรรทัดนั้นออกจากไฟล์ต้นฉบับนั้น
# @ โปรแกรม จะทำการค้นหา string/word/tag และทำการแทน ที่ เฉพาะบรรทัด ที่พบ ในไฟล์ที่เลือกเท่านั้น
# @ โปรแกรม ถูกพัฒนา ขึ้นเพื่อแก้ไขปัญหา เกี่ยวกับ การถูกลักลอบฝั่งแทร็ก ลงบนไฟล์ของเว็บไซต์ เช่น iframe หรือ javascript หรือ tag script ต่างๆ
# @ หากท่านไม่แน่ใจ สามาถ ส่ง ข้อมูล โดยคลิก Send to analysis เพื่อนำมาวิเคราห์ให้การแนะนำได้
# @ หากสคิบที่ถูกฝั่งนั้น code มากกว่า 1 บรรทัด ท่านต้องลบด้วยมือ โดยมากจะเริ่มต้นด้วย <script>...</script> หรือ <iframe> </iframe>
# @ ท่านต้องดูให้แน่ใจว่า บรรทัดนั้นเป็นจุดเริ่มต้น และสิ้นสุดของ Code คำสั่ง
# 
# @ วิธีใช้ นำไฟล์ นี้ไปใส่ไว้ในโฟเดอร์ ที่ต้องทำการ Scan และ ตั้งค่า และ เรียกใช้งานได้ทันที
#
# ๑ ท่านสามารถมีส่วนช่วยพัฒนา แก้ไขปรับปรุง หรือ ให้การแนะนำ สคิบนี้เพิ่มเติม เพื่อประโยชน์ ต่อทุกคนได้ และเรา จะใส่ชื่อของท่านให้ประจัก
# ๑  ปล . ท่านใดมีความชำนาญภาษา รบกวนช่วยแปล  และส่งเมล์ให้ทีครับ จะขอบพระคุณงามๆ เลยครับ
#
# เพื่อความปลอดภัย ควรดาว์โหลด โปรแกรม จาก เว็บไซต์ ผู้พัฒนา
# และควรทำการ สำรองข้อมูลเว็บของท่าน อย่างน้อย 1 ฉบับเสมอ
# ขอบคุณทุกท่าน
#  mean
#
# Hi This php program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#  ...
#######################################################################
"; // Repalce to ... (when use $config['HowReplace'] = 2 or 4) // find word example : "unescape" or "eval" or "eval\(unescape" or "\.*?gzencode.*?set_error_handler.*?\?>#i', // (PHP/ScriptEngine/RSS) gumblar.cn '#<\?(php)?.*?eval.*?base64_decode.*?\?>#i', // (PHP/Backdoor/POST/Eval) gumblar.cn '#[^<]*#i', // (PHP/IFrame/Hidden) litecarexcellent.cn [Final] (Update 22/10/09 by mean) '##i', // 4/11/09 by mean '##i', // 4/11/09 by mean '#]*>.*?#i', // 4/11/09 by mean '#\(function\([a-z0-9]*\)\{.*?(eval|replace|unescape).*?(eval|replace|unescape).*?(eval|replace|unescape).*?\}\)\(.*?\);#i', // (JS/ScriptEngine/RSS) gumblar.cn [Final] '#]*>[^<]+function[^<]+fromcharcode[^<]+(eval|unescape)[^<]+(eval|unescape)[^<]+#is', // (JS/Encoded/Multiline) Credit: devil_joe '#<\?(php)?.*?base64_encode.*?base64_decode.*?eval.*?\?>#i', // (PHP/ENCODED) Credit: g-ji '#]*>.*?(eval|replace|unescape).*?(eval|replace|unescape).*?(eval|replace|unescape).*?#i', // (JS/Encoded/Singleline) Credit: mapandy ); if($config['auth_user']=='' || $config['auth_pass']=='') { echo'
เพื่อความปลอดภัย กรุณาดำเนินการตั้งค่า ผู้ใช้ $config[\'auth_user\'] และ $config[\'auth_pass\']'; if($config['ftp_createbackup'] == false) echo '
ระบบสำรองไฟล์ยังไม่ถูกเปิดใช้งาน ท่านสามารถเปิดใช้งานได้จาก $config[\'ftp_createbackup\']'; exit; } //=============================== Authenticate if (isset($_GET['step'])!="" && $config['auth_Access'] && (( !isset( $_SERVER["PHP_AUTH_USER"] )) || (!isset($_SERVER["PHP_AUTH_PW"] )) || ( $_SERVER["PHP_AUTH_USER"] != $config['auth_user'] ) || ( $_SERVER["PHP_AUTH_PW"] != $config['auth_pass'] ) )) { header( 'WWW-Authenticate: Basic realm="Secure Admin"' ); header( 'HTTP/1.0 401 Unauthorized' ); echo 'Authorized Users Only.'; exit; } ################################### # Start ! PHP Coding Program ################################### if(isset($_GET['step'])==""){// Start Step 1 ?>

Find in directory :


HTML_JAVASCRIPT; function list_dir($dir_handle,$path){ global $config; $filetype = explode(',', str_replace(" ","",($config['SearchInFileType']))); echo "
    "; while (false !== ($file = readdir($dir_handle))) { $dir =trim($path).'/'.$file; if(is_dir($dir) && $file != '.' && $file !='..' ) { $handle = @opendir($dir) or die("undable to open file $file"); if($config['print_result']==1) echo "
  • $file
  • "; list_dir($handle, $dir); }elseif($file != '.' && $file !='..' && $file != $config['scriptname']) { if(in_array(substr($file , -3), $filetype) || in_array(substr($file , -4), $filetype)){ $fileLines = file($dir); foreach($fileLines as $line =>$v) { preg_match_all('~'.$config['SearchString'].'~', $v, $matches); if($matches[0]) { //$dir = str_replace($config['path'],'',$dir); $dia = str_replace ( "%5C", "-x-", urlencode($dir)); $erd = rand(0,1000); $line+=1; $outs = ''; $outs .= "
    Warning! Line : ".$line ." : ($dir)"; $outs .= ""; $outs .= '"; //$outs .= ""; } if($config['print_result']==1){ echo "
  • $file
  • "; }else if( $matches[0] ) { echo "
  • $file
  • "; echo $outs; } } } } } echo "
"; closedir($dir_handle); } $path = urldecode($config['path']); echo "Directory Listing of $path
Find : ".htmlspecialchars($config['SearchString'])."
"; echo "Replace to :".htmlspecialchars($config['ReplaceTo'])."
File Type :".$config['SearchInFileType']."
"; echo "Script change : http to hxxp
"; $dir_handle = @opendir($path) or die("Unable to open $path"); list_dir($dir_handle,$path); $endtime = microtime(); $endarray = explode(" ", $endtime); $endtime = $endarray[1] + $endarray[0]; $totaltime = $endtime - $starttime; $totaltime = round($totaltime,5); echo "
This page loaded in $totaltime seconds.
"; } // End Step 2 elseif($_GET['step']=="3"){ // Start Step 3 header('Content-Type: text/html'); header('Pragma: no-cache'); $outputWhenReplace=''; function replace_line_by_number($line, $file){ global $config; global $outputWhenReplace; $contents = array(); $new_contents = ""; $number_of_lines = 0; if(file_exists($file)) { if($contents = file($file)){ $number_of_lines = count($contents); if($line <= $number_of_lines) { $contents = array_map("trim", $contents); if($config['HowReplace']=='1'){// Remove Line unset($contents[($line-1)]); }elseif($config['HowReplace']=='2'){ // Replace Line $contents[($line-1)] = $config['ReplaceTo']; }elseif($config['HowReplace']=='3'){// Find and Replace String $contents[($line-1)] = str_replace($config['SearchString'], $config['ReplaceTo'] , $contents[($line-1)]); }elseif($config['HowReplace']=='4'){ // Auto Find and remove from Regular foreach($config['virus_core'] as $code) { preg_match_all($code, $contents[($line-1)], $match); if(count($match[0]) > 0) $outputWhenReplace = $contents[($line-1)] = preg_replace($code, $config['ReplaceTo'], $contents[($line-1)]); } } $new_contents = implode("\n", $contents); if(is_writable($file)){ if($handle = fopen($file, 'w')) if(fwrite($handle, $new_contents) !== false) return true; } else if($config['ftp_mode']) { if(($conn_id = @ftp_connect($config['ftp_host'])) && @ftp_login($conn_id, $config['ftp_user'], $config['ftp_pass'])) { echo ""; if($config['ftp_passiveMode']) ftp_pasv($conn_id,TRUE); $buffer = explode("/",$file); for($i=0 ; $i<= count($buffer) ; $i++){ unset($buffer[$i]); $bfile = implode("/", $buffer); $oldpermiss = substr(sprintf('%o', fileperms($file)), -4); if(@ftp_chmod($conn_id, 0777,$bfile )){ echo "
Chmod file to : 0777 [$bfile]"; break; }else{ continue; } } if($config['ftp_permission']=='') $config['ftp_permission'] = $oldpermiss; if($config['ftp_createbackup']){ if(ftp_put($conn_id, $bfile.".backup", $file, FTP_ASCII)) echo"
Create Backup file : {$file}.backup"; } if($handle = fopen($file, 'w')) if(fwrite($handle, $new_contents)) echo "
Process : remove or replace line : ".($line)." [$bfile]"; if(@ftp_chmod($conn_id, octdec($config['ftp_permission']),$bfile )) echo "
Chmod file to : ".$config['ftp_permission']." [$bfile]"; //$fp = fopen( $file.'.temp','w'); if(fwrite($fp,stripslashes($new_contents))) echo"
Create temp file {$file}.temp"; fclose($fp); //if(ftp_delete($conn_id, $bfile)) echo "
Delete : ".$bfile; //if(ftp_rename($conn_id, $file.'.temp', $bfile, FTP_ASCII)) echo "
Rename : .temp to normal file"; //if(ftp_chmod($conn_id, $config['ftp_permission'], $bfile)) echo "
Chmod file to : ".$config['ftp_permission']; ftp_close($conn_id); echo "
"; return true; }else{ echo "
Error ! FTP ! 530 Login incorrect. [invalid : Host Name or Username or Password]
"; return false; } }else{ echo "Error ! $file could not be opened for writing / Please turn on ftp option"; return false; } } else{ echo "Error !$file only has $number_of_lines lines, so line $line could not be removed "; return false; } } else { echo "Error ! $file is not readable"; return false; } }else { echo "Error ! $file does not exist"; return false; } } $pathAfile = str_replace ( array("-x-",'%5C'), "/",$_GET['filepath']); if($rer = replace_line_by_number($_GET['line'],$pathAfile)){ echo ''; echo"".htmlspecialchars($outputWhenReplace).""; echo "Success"; } } // End Step 3 elseif($_GET['step']=="4"){ // Report Function Start step 4 header('Content-Type: text/html'); header('Pragma: no-cache'); $url = "http://fizscript.ishare.in.th/recreport.php"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$url); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5))); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS,"fromMail=$fromMail&fromWeb=$fromWeb&line=$line&value=$value&filepath=$filepath"); curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type: application/x-www-form-urlencoded")); $result= curl_exec ($curl); curl_close ($curl); }// End Step 4 if(isset($_GET['step']) <= '2' ){ echo '
FizScript V. 3.2.2 Last Modify : 4/11/2009
© 2009 http://fizscript.ishare.in.th
'; } ?>