Skip to content

Commit b9fdca0

Browse files
author
Brent Cook
committed
rework logical fix for rapid7#8884 to function with bootstrap code
1 parent c365db1 commit b9fdca0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/msf/base/sessions/meterpreter.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def shell_init
120120

121121
end
122122

123-
def bootstrap(datastore={})
123+
def bootstrap(datastore = {}, handler = nil)
124124
session = self
125125

126126
init_session = Proc.new do
@@ -182,9 +182,12 @@ def bootstrap(datastore={})
182182
end
183183

184184
# Process the auto-run scripts for this session
185-
if self.respond_to?('process_autoruns')
185+
if self.respond_to?(:process_autoruns)
186186
self.process_autoruns(datastore)
187187
end
188+
189+
# Tell the handler that we have a session
190+
handler.on_session(self) if handler
188191
end
189192

190193
# Defer the session initialization to the Session Manager scheduler

lib/msf/core/handler.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,11 @@ def register_session(session)
244244
framework.sessions.register(session)
245245

246246
# Call the handler's on_session() method
247-
on_session(session)
248-
session.bootstrap(datastore)
247+
if session.respond_to?(:bootstrap)
248+
session.bootstrap(datastore, self)
249+
else
250+
on_session(session)
251+
end
249252

250253
# If there is an exploit associated with this payload, then let's notify
251254
# anyone who is interested that this exploit succeeded

0 commit comments

Comments
 (0)