注入输入连接到标准输入(交互控制台)
问题描述:
过程中我们有一个工具,它执行PHP交互shell这样的:注入输入连接到标准输入(交互控制台)
$descriptorSpec = array(
0 => STDIN,
1 => STDOUT,
2 => STDERR
);
$prependFile = __DIR__ . '/../../../../../res/dev/console_auto_prepend.php';
$exec = 'php -a -d auto_prepend_file=' . escapeshellarg($prependFile);
$pipes = array();
proc_open($exec, $descriptorSpec, $pipes);
与auto_prepend_file
诀窍不幸导致在PHP 5.3自动加载的问题。我们发现,everyting效果很好,当我们包括交互shell文件里面:
$ php -a Interactive shell php > include "myproject/res/dev/console_auto_prepend.php"; Autoloader initialized.
我们想要做的是以下几点:
- 通过proc_open
- 执行PHP交互shell发送包括线到交互式外壳
- 交出控制研究于用户输入
有没有办法做到这一点?
答
未测试的想法:
- 创建一个新的输入管
- 打开PHP处理(
php -a
)与该输入管,输出和错误可以被连接到系统管 - 注入包括命令(写入输入管道)
- 从STDIN读取并写入我们新的输入管道(连接到
php -a
)的循环中
答
该项目最终使用自定义PHP外壳(psysh
)