New hash syntax

bug/bundler_fix
James Lee 2015-03-26 10:05:08 -05:00
parent a3ae0daf5a
commit a9e4961563
No known key found for this signature in database
GPG Key ID: 2D6094C7CEA0A321
1 changed files with 25 additions and 24 deletions

View File

@ -77,6 +77,7 @@ module Msf::DBManager::Session
# @raise ArgumentError if :host and :session is +nil+ # @raise ArgumentError if :host and :session is +nil+
def report_session(opts) def report_session(opts)
return if not active return if not active
::ActiveRecord::Base.connection_pool.with_connection { ::ActiveRecord::Base.connection_pool.with_connection {
if opts[:session] if opts[:session]
raise ArgumentError.new("Invalid :session, expected Msf::Session") unless opts[:session].kind_of? Msf::Session raise ArgumentError.new("Invalid :session, expected Msf::Session") unless opts[:session].kind_of? Msf::Session
@ -88,35 +89,35 @@ module Msf::DBManager::Session
h_opts[:workspace] = wspace h_opts[:workspace] = wspace
host = find_or_create_host(h_opts) host = find_or_create_host(h_opts)
sess_data = { sess_data = {
:host_id => host.id, host_id: host.id,
:stype => session.type, stype: session.type,
:desc => session.info, desc: session.info,
:platform => session.platform, platform: session.platform,
:via_payload => session.via_payload, via_payload: session.via_payload,
:via_exploit => session.via_exploit, via_exploit: session.via_exploit,
:routes => [], routes: [],
:datastore => session.exploit_datastore.to_h, datastore: session.exploit_datastore.to_h,
:port => session.session_port, port: session.session_port,
:opened_at => Time.now.utc, opened_at: Time.now.utc,
:last_seen => Time.now.utc, last_seen: Time.now.utc,
:local_id => session.sid local_id: session.sid
} }
elsif opts[:host] elsif opts[:host]
raise ArgumentError.new("Invalid :host, expected Host object") unless opts[:host].kind_of? ::Mdm::Host raise ArgumentError.new("Invalid :host, expected Host object") unless opts[:host].kind_of? ::Mdm::Host
host = opts[:host] host = opts[:host]
sess_data = { sess_data = {
:host_id => host.id, host_id: host.id,
:stype => opts[:stype], stype: opts[:stype],
:desc => opts[:desc], desc: opts[:desc],
:platform => opts[:platform], platform: opts[:platform],
:via_payload => opts[:via_payload], via_payload: opts[:via_payload],
:via_exploit => opts[:via_exploit], via_exploit: opts[:via_exploit],
:routes => opts[:routes] || [], routes: opts[:routes] || [],
:datastore => opts[:datastore], datastore: opts[:datastore],
:opened_at => opts[:opened_at], opened_at: opts[:opened_at],
:closed_at => opts[:closed_at], closed_at: opts[:closed_at],
:last_seen => opts[:last_seen] || opts[:closed_at], last_seen: opts[:last_seen] || opts[:closed_at],
:close_reason => opts[:close_reason], close_reason: opts[:close_reason],
} }
else else
raise ArgumentError.new("Missing option :session or :host") raise ArgumentError.new("Missing option :session or :host")