ホームページ  >  記事  >  バックエンド開発  >  Web ウイルスを削除する方法_PHP チュートリアル

Web ウイルスを削除する方法_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:09:35899ブラウズ

あなたの Web ページでは、理由もなく php、asp、html、js などのファイルのバックグラウンドにトロイの木馬のアドレスが追加されることがよくありますか?少しリソースの無駄ですが、手動で削除するよりは良いでしょう。次に、プログラムによるウイルス削除の原理について説明します。

まず、$checkFile ファイルを読み取る必要があります。この記事は、記事が感染しているかどうかを判断するためのもので、感染している場合は、$savafile 変数の txt ファイル パス内のすべてのファイルが実行され、infecFile ウイルス リストに従って消去されます。

クラスクリア_ウイルス{
//パブリック $content;
public $infectFile ='virus.txt';//ウイルスファイルリストファイル
public $savefile ="save.txt";//ウイルスを表示するファイルのリスト
public $timep ='time.txt';//ウイルス除去時間のいくつかの記録
public $checkFile ='e.php';//以下が設定です
パブリック $run =0;
パブリック $virus_type;
パブリック $replace ;
パブリック $ファイルパス ;
パブリック $タグ =0;
関数 open_file(){
$this->read_virus(); $this->check_File();
if($this->run){
$this->update_time(); $this->read_file() ; foreach($this->ファイルパスを$tmppathとして){
If(file_exists($tmppath)){
$tmp_file =file_get_contents($tmppath); print_r( $this->virus_type); for( $i=0;$ivirus_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)
                                                                            
}その他{
;
                                                                         }
}
}

関数 check_File(){
If(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile) ;
エコー $temp;
foreach( $this->virus_type as $v_tmp ){
If( strrpos($temp,$v_tmp)!== false ){
$this->run =1;
休憩;
}
}
echo $this->run;
unset($temp);
}その他{
$this->show_error(5);
}
}

関数 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);
}

}


関数 read_File(){
If(file_exists($this->savefile) ){
$this->content =file($this->savefile)
If(is_array($this->content)){
$this->ファイルパス =$this->コンテンツ; $this->ファイルパス }その他{
$this->show_error(3);
}
}その他{
$this->show_error(4);
}
}


関数 read_virus(){
If(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile)
If(is_array($this->replace)){
$this->virus_type=$ }その他{
$this->show_error(1);
}
}その他{
$this->show_error(2);
}
}


関数 show_error($number){
$array = 配列(
'1'=>'ウイルス ファイルを読み取れません!',
'2'=>'ウイルス ファイル リストは存在しません!',
'3'=>'ファイルリストは保存されなくなりました',
'4'=>'スキャンされたファイルは保存されません',
'5'=>$this->$checkFile.'存在しません。ウイルス感染ファイルを設定してください'
);
エコー $array[$number];
}

}
$virus =新しいclear_virus;
$virus->open_file();
?>
最後に、このサイトのオリジナルのソースが www.111cn.cn/phper/php.html であることを明記してください

http://www.bkjia.com/PHPjc/629746.htmlwww.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/629746.html技術記事あなたの Web ページでは、理由もなく php、asp、html、js などのファイルのバックグラウンドにトロイの木馬のアドレスが追加されることがよくありますか? ..
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。