php網(wǎng)頁(yè)病毒清除類
本文實(shí)例講述了php網(wǎng)頁(yè)病毒清除類。分享給大家供大家參考。具體如下:
相信很多人的網(wǎng)頁(yè)經(jīng)常被無(wú)故的在php,asp,html,js 等文件后臺(tái)加上一些木馬地址,造成了很大的困擾!我以前有個(gè)站就是這樣,所以一恨之下寫了這段代碼,文章雖然有一點(diǎn)浪費(fèi)資源了,但是總比我們手動(dòng)清除要好吧,下面我為講講程序的清除病毒的原理吧.
首先們要讀取 $checkFile 文件這個(gè)文章是判斷一個(gè)文章 是否被感染了,如果是就會(huì)執(zhí)行$savafile變量里面的txt文件路徑的所有文件,進(jìn)行按你infecFile病毒列表清除一次.
Class clear_virus{
//public $content;
public $infectFile ='virus.txt';//病毒文件列表文件
public $savefile ="save.txt";//所在查看病毒的文件列表
public $timep ='time.txt';//些記錄清除病毒時(shí)間
public $checkFile ='e.php';//這里是設(shè)置
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.'不存在了,請(qǐng)?jiān)O(shè)置病毒感染文件'
);
echo $array[$number];
}
}
$virus =new clear_virus;
$virus->open_file();
?>
希望本文所述對(duì)大家的PHP程序設(shè)計(jì)有所幫助。
- linux服務(wù)器被植入ddgs、qW3xT.2挖礦病毒的處理實(shí)戰(zhàn)記錄
- 通過(guò)批處理關(guān)閉135 137 445等端口的實(shí)現(xiàn)代碼(勒索病毒)
- 對(duì)一個(gè)vbs腳本病毒的病毒原理分析
- VC實(shí)現(xiàn)的病毒專殺工具完整實(shí)例
- 利用DOS命令來(lái)對(duì)抗U盤病毒保護(hù)U盤數(shù)據(jù)
- 自制殺u盤病毒的批處理代碼
- c病毒程序原理分析(防范病毒 c語(yǔ)言小病毒示例)
- 解析:清除SQL被注入惡意病毒代碼的語(yǔ)句
- Autorun 病毒清除工具bat代碼
- VBS.Runauto腳本病毒分析篇
- 一段病毒常用的VBS代碼
- 記事本U盤病毒 Notepad.exe查殺方法
- 美女游戲病毒iwbkvd.exe查殺方法
- 批處理 Autorun 病毒清除工具
- Rootkit病毒的解決辦法
相關(guān)文章
PHP實(shí)現(xiàn)生成推廣海報(bào)的方法詳解
這篇文章主要介紹了PHP實(shí)現(xiàn)生成推廣海報(bào)的方法,結(jié)合具體實(shí)例形式詳細(xì)分析了php圖片生成的相關(guān)操作技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下2018-03-03golang與php實(shí)現(xiàn)計(jì)算兩個(gè)經(jīng)緯度之間距離的方法
這篇文章主要介紹了golang與php實(shí)現(xiàn)計(jì)算兩個(gè)經(jīng)緯度之間距離的方法,結(jié)合實(shí)例形式對(duì)比分析了Go語(yǔ)言與php進(jìn)行經(jīng)緯度計(jì)算的相關(guān)數(shù)學(xué)運(yùn)算技巧,需要的朋友可以參考下2016-07-07PHP laravel實(shí)現(xiàn)配置使用多數(shù)據(jù)庫(kù)
有的時(shí)候,我們?cè)陂_發(fā)的過(guò)程中需要連接多個(gè)數(shù)據(jù)庫(kù)。Laravel框架中早已為我們想到了這樣的需求。這篇文章主要為大家介紹了laravel配置使用多數(shù)據(jù)庫(kù)的方法,需要的可以參考一下2022-10-10Json_decode 解析json字符串為NULL的解決方法(必看)
下面小編就為大家?guī)?lái)一篇Json_decode 解析json字符串為NULL的解決方法(必看)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02PHP中全局變量global和$GLOBALS[]的區(qū)別分析
$GLOBALS['var']是外部的全局變量本身,global $var是外部$var的同名引用或者指針2012-08-08