Use update_session rather than Mdm save method
The changes ensure that updates to an Mdm::Session are reflected on a remote data service.GSoC/Meterpreter_Web_Console
parent
b6cdf7aa9d
commit
c2af36f405
|
@ -516,8 +516,8 @@ class Meterpreter < Rex::Post::Meterpreter::Client
|
|||
})
|
||||
|
||||
if self.db_record
|
||||
self.db_record.desc = safe_info
|
||||
self.db_record.save!
|
||||
$stderr.puts("Msf::Sessions::Meterpreter.load_session_info(): self.sid=#{self.sid}, self.db_record.id=#{self.db_record.id}; calling framework.db.update_session(self)...") # TODO: remove
|
||||
framework.db.update_session(self)
|
||||
end
|
||||
|
||||
# XXX: This is obsolete given the Mdm::Host.normalize_os() support for host.os.session_fingerprint
|
||||
|
|
|
@ -283,12 +283,14 @@ module Session
|
|||
# Also must tolerate being called multiple times.
|
||||
#
|
||||
def cleanup
|
||||
$stderr.puts("#{DateTime.now} Msf::Session.cleanup(): db_record=#{db_record}, db_record.class=#{db_record.class}, framework.db.active=#{framework.db.active}") # TODO: remove
|
||||
$stderr.puts("#{DateTime.now} Msf::Session.cleanup(): db_record.id=#{db_record.id}, Time.now.utc=#{Time.now.utc}, before update: #{db_record.attributes}") unless db_record.nil? # TODO: remove
|
||||
if db_record and framework.db.active
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
db_record.closed_at = Time.now.utc
|
||||
# ignore exceptions
|
||||
db_record.save
|
||||
tmp_db_record = framework.db.update_session(id: db_record.id, closed_at: Time.now.utc, close_reason: db_record.close_reason)
|
||||
$stderr.puts("#{DateTime.now} Msf::Session.cleanup(): tmp_db_record.id=#{tmp_db_record.id}, self.sid=#{self.sid}, after save: #{tmp_db_record.attributes}") unless tmp_db_record.nil? # TODO: remove
|
||||
db_record = nil
|
||||
$stderr.puts("#{DateTime.now} Msf::Session.cleanup(): returning after db_record.save call... db_record.class=#{db_record.class}") # TODO: remove
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,8 +119,9 @@ class SessionManager < Hash
|
|||
# as recently seen. This notifies other framework instances that this
|
||||
# session is being maintained.
|
||||
if s.db_record
|
||||
s.db_record.last_seen = Time.now.utc
|
||||
s.db_record.save
|
||||
$stderr.puts("#{DateTime.now} SessionManager.initialize() [monitor_thread]: before update: Time.now.utc=#{Time.now.utc}, s.sid=#{s.sid}, s.db_record.id=#{s.db_record.id}, #{s.db_record.attributes}") # TODO: remove
|
||||
s.db_record = framework.db.update_session(id: s.db_record.id, last_seen: Time.now.utc)
|
||||
$stderr.puts("#{DateTime.now} SessionManager.initialize() [monitor_thread]: after update: s.sid=#{s.sid}, s.db_record.id=#{s.db_record.id}, #{s.db_record.attributes}") # TODO: remove
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue