easyphp
<?php
//题目环境:php:7.4.8-apache
$pid = pcntl_fork(); //创建一个子进程
//子进程和父进程都会执行以下代码
if ($pid == -1) { //错误处理,创建失败返回-1
die('could not fork');
}else if ($pid){
//父进程会获得子进程号,所以这里是父进程执行逻辑
$r=pcntl_wait($status); //等待子进程中断,防止子进程成为僵尸进程
if(!pcntl_wifexited($status)){ //挂起当前进行进程直到一个子进程退出或者收到一个信号要求中断当前进程或调用一个信号处理进程。
phpinfo();
}
}else if ($pid == 0){ //子进程pid为0,这里是子进程逻辑
highlight_file(__FILE__);
if(isset($_GET['a'])&&is_string($_GET['a'])&&!preg_match("/[:\\\\]|exec|pcntl/i",$_GET['a'])){
call_user_func_array($_GET['a'],[$_GET['b'],false,true]);
call_user_func_array(call(pcntl_wait()))
}
posix_kill(posix_getpid(), SIGUSR1);
}能够调用命令行的php函数:
其中三个参数的函数:
都受到了限制。
方法1 子程序不正常退出调用phpinfo();
stream_socket_client ( string
$remote_socket[, int&$errno[, string&$errstr[, float$timeout= ini_get("default_socket_timeout") [, int$flags= STREAM_CLIENT_CONNECT [, resource$context]]]]] ) : resource
$remote_socket 要连接的套接字地址。
$errno 如果连接失败,将被设置为系统级错误号。
$errstr 如果连接失败,将被设置为系统级错误消息。
$timeout 直到connect()系统调用应超时的秒数。
方法2 子程序被挂起调用phpinfo();
老套娃了。
Last updated