Skip to content

Commit 117c2b9

Browse files
committed
feat: Allow explicit SSL configuration in start_service method
The start_service method now allows users to specify their SSL preferences directly through the opts parameter. If the ssl option is not provided in opts, it will default to the value in datastore['SSL']. This change enhances the flexibility and usability of the start_service method, preventing unintended behavior when users need to control the SSL setting explicitly. Closes rapid7#19329
1 parent b5d89f3 commit 117c2b9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/msf/core/exploit/remote/http_server.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,17 @@ def check_dependencies
116116
# completely on the datastore. (See dlink_upnp_exec_noauth)
117117
def start_service(opts = {})
118118

119+
# Keep compatibility with modules that don't pass the ssl option to the start server but rely on the datastore instead.
120+
opts['ssl'] = opts['ssl'].nil? ? datastore['SSL'] : opts['ssl']
121+
119122
check_dependencies
120123

121124
# Start a new HTTP server service.
122125
self.service = Rex::ServiceManager.start(
123126
Rex::Proto::Http::Server,
124127
(opts['ServerPort'] || bindport).to_i,
125-
opts['ServerHost'] || bindhost,
126-
datastore['SSL'], # XXX: Should be in opts, need to test this
128+
opts['ServerHost'] || bindhost,
129+
opts['ssl'],
127130
{
128131
'Msf' => framework,
129132
'MsfExploit' => self,
@@ -149,7 +152,9 @@ def start_service(opts = {})
149152
'Path' => opts['Path'] || resource_uri
150153
}.update(opts['Uri'] || {})
151154

152-
proto = (datastore["SSL"] ? "https" : "http")
155+
proto = (opts['ssl'] ? "https" : "http")
156+
157+
puts proto
153158

154159
# SSLCompression may or may not actually be available. For example, on
155160
# Ubuntu, it's disabled by default, unless the correct environment

modules/auxiliary/gather/magento_xxe_cve_2024_34102.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,16 @@ def run
154154
fail_with(Failure::BadConfig, 'SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful')
155155
end
156156

157-
if datastore['SSL']
158-
ssl_restore = true
159-
datastore['SSL'] = false
160-
end
161157
start_service({
162158
'Uri' => {
163159
'Proc' => proc do |cli, req|
164160
on_request_uri(cli, req)
165161
end,
166162
'Path' => '/'
167-
}
163+
},
164+
'ssl' => false
168165
})
169-
datastore['SSL'] = true if ssl_restore
166+
170167
xxe_request
171168
rescue Timeout::Error => e
172169
fail_with(Failure::TimeoutExpired, e.message)

0 commit comments

Comments
 (0)