Land #2952, -1 for last session ID

bug/bundler_fix
William Vu 2014-02-11 16:22:36 -06:00
commit 18816f3d5e
No known key found for this signature in database
GPG Key ID: E761DCB4C1629024
3 changed files with 13 additions and 3 deletions

View File

@ -99,7 +99,7 @@ protected
# Grab the session object since we need to fire an event for not # Grab the session object since we need to fire an event for not
# only the normal module_run event that all module types have to # only the normal module_run event that all module types have to
# report, but a specific event for sessions as well. # report, but a specific event for sessions as well.
s = mod.framework.sessions[mod.datastore["SESSION"]] s = mod.framework.sessions.get(mod.datastore["SESSION"].to_i)
mod.framework.events.on_session_module_run(s, mod) mod.framework.events.on_session_module_run(s, mod)
mod.run mod.run
rescue ::Timeout::Error => e rescue ::Timeout::Error => e

View File

@ -74,7 +74,7 @@ module Msf::PostMixin
return @session if @session and not session_changed? return @session if @session and not session_changed?
if datastore["SESSION"] if datastore["SESSION"]
@session = framework.sessions[datastore["SESSION"].to_i] @session = framework.sessions.get(datastore["SESSION"].to_i)
else else
@session = nil @session = nil
end end

View File

@ -279,7 +279,17 @@ class SessionManager < Hash
# Returns the session associated with the supplied sid, if any. # Returns the session associated with the supplied sid, if any.
# #
def get(sid) def get(sid)
return self[sid.to_i] session = nil
sid = sid.to_i
if sid > 0
session = self[sid]
elsif sid == -1
sid = self.keys.sort[-1]
session = self[sid]
end
session
end end
# #