php網(wǎng)頁病毒清除類
本文實例講述了php網(wǎng)頁病毒清除類。分享給大家供大家參考。具體如下:
相信很多人的網(wǎng)頁經(jīng)常被無故的在php,asp,html,js 等文件后臺加上一些木馬地址,造成了很大的困擾!我以前有個站就是這樣,所以一恨之下寫了這段代碼,文章雖然有一點浪費資源了,但是總比我們手動清除要好吧,下面我為講講程序的清除病毒的原理吧.
首先們要讀取 $checkFile 文件這個文章是判斷一個文章 是否被感染了,如果是就會執(zhí)行$savafile變量里面的txt文件路徑的所有文件,進行按你infecFile病毒列表清除一次.
Class clear_virus{
//public $content;
public $infectFile ='virus.txt';//病毒文件列表文件
public $savefile ="save.txt";//所在查看病毒的文件列表
public $timep ='time.txt';//些記錄清除病毒時間
public $checkFile ='e.php';//這里是設置
public $run =0;
public $virus_type;
public $replace ;
public $filepath ;
public $tag =0;
function open_file(){
$this->read_virus();
$this->check_File();
if($this->run){
$this->update_time();
$this->read_file() ;
foreach($this->filepath as $tmppath){
if(file_exists($tmppath)){
$tmp_file =file_get_contents($tmppath);
print_r( $this->virus_type);
for( $i=0;$i<sizeof($this->virus_type);$i++ ){
if( strrpos($tmp_file,$this->virus_type[$i])!== false){
$tmp_file =str_replace($this->virus_type[$i],'',$tmp_file);
$this->tag =1;
}
}
if( $this->tag ){
$handle =fopen($tmppath,'w');
fwrite($handle,$tmp_file);
fclose($handle);
unset($tmp_file);
}
}else{
;
}
}
}
}
function check_File(){
if(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile) ;
echo $temp;
foreach( $this->virus_type as $v_tmp ){
if( strrpos($temp,$v_tmp)!== false ){
$this->run =1;
break;
}
}
echo $this->run;
unset($temp);
}else{
$this->show_error(5);
}
}
function update_time(){
if(file_exists($this->timep) ){
$tmp_time =date("Y-m-d H:i:s").chr(13).'|';
$tmp_fp =fopen($this->timep,'a+');
fwrite($tmp_fp,$tmp_time);
fclose($tmp_fp);
}
}
function read_File(){
if(file_exists($this->savefile) ){
$this->content =file($this->savefile);
if(is_array($this->content)){
$this->filepath =$this->content;
}else{
$this->show_error(3);
}
}else{
$this->show_error(4);
}
}
function read_virus(){
if(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile);
if(is_array($this->replace)){
$this->virus_type=$this->replace;
}else{
$this->show_error(1);
}
}else{
$this->show_error(2);
}
}
function show_error($number){
$array = array(
'1'=>'病毒文件未不能讀取!',
'2'=>'病毒文件列表不存在!',
'3'=>'文件列表不存了',
'4'=>'查殺的文件不存',
'5'=>$this->$checkFile.'不存在了,請設置病毒感染文件'
);
echo $array[$number];
}
}
$virus =new clear_virus;
$virus->open_file();
?>
希望本文所述對大家的PHP程序設計有所幫助。
- linux服務器被植入ddgs、qW3xT.2挖礦病毒的處理實戰(zhàn)記錄
- 通過批處理關閉135 137 445等端口的實現(xiàn)代碼(勒索病毒)
- 對一個vbs腳本病毒的病毒原理分析
- VC實現(xiàn)的病毒專殺工具完整實例
- 利用DOS命令來對抗U盤病毒保護U盤數(shù)據(jù)
- 自制殺u盤病毒的批處理代碼
- c病毒程序原理分析(防范病毒 c語言小病毒示例)
- 解析:清除SQL被注入惡意病毒代碼的語句
- Autorun 病毒清除工具bat代碼
- VBS.Runauto腳本病毒分析篇
- 一段病毒常用的VBS代碼
- 記事本U盤病毒 Notepad.exe查殺方法
- 美女游戲病毒iwbkvd.exe查殺方法
- 批處理 Autorun 病毒清除工具
- Rootkit病毒的解決辦法
相關文章
golang與php實現(xiàn)計算兩個經(jīng)緯度之間距離的方法
這篇文章主要介紹了golang與php實現(xiàn)計算兩個經(jīng)緯度之間距離的方法,結合實例形式對比分析了Go語言與php進行經(jīng)緯度計算的相關數(shù)學運算技巧,需要的朋友可以參考下2016-07-07PHP laravel實現(xiàn)配置使用多數(shù)據(jù)庫
有的時候,我們在開發(fā)的過程中需要連接多個數(shù)據(jù)庫。Laravel框架中早已為我們想到了這樣的需求。這篇文章主要為大家介紹了laravel配置使用多數(shù)據(jù)庫的方法,需要的可以參考一下2022-10-10Json_decode 解析json字符串為NULL的解決方法(必看)
下面小編就為大家?guī)硪黄狫son_decode 解析json字符串為NULL的解決方法(必看)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02PHP中全局變量global和$GLOBALS[]的區(qū)別分析
$GLOBALS['var']是外部的全局變量本身,global $var是外部$var的同名引用或者指針2012-08-08