Save payloads and urls in database when running a module
parent
a9af924317
commit
1ec1b3b493
|
@ -1,15 +1,35 @@
|
||||||
module Msf::DBManager::Payload
|
module Msf::DBManager::Payload
|
||||||
|
|
||||||
def create_payload(opts)
|
def create_payload(opts)
|
||||||
'MOCK: Payload created!'
|
Mdm::Payload.create(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_payload(opts)
|
def get_payload(opts)
|
||||||
'MOCK: Payload retrieved!'
|
if opts.kind_of? Mdm::Payload
|
||||||
|
return opts
|
||||||
|
else
|
||||||
|
uuid = opts[:uuid] || return
|
||||||
|
end
|
||||||
|
::ActiveRecord::Base.connection_pool.with_connection do
|
||||||
|
return Mdm::Payload.find_by(uuid: uuid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_or_create_payload(opts)
|
||||||
|
payload = get_payload(opts.clone)
|
||||||
|
return payload unless payload.nil?
|
||||||
|
|
||||||
|
create_payload(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_payload(opts)
|
def update_payload(opts)
|
||||||
'MOCK: Payload updated!'
|
::ActiveRecord::Base.connection_pool.with_connection do
|
||||||
|
wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework, false)
|
||||||
|
opts[:workspace] = wspace if wspace
|
||||||
|
|
||||||
|
id = opts.delete(:id)
|
||||||
|
Mdm::Payload.update(id, opts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_payload(opts)
|
def delete_payload(opts)
|
||||||
|
|
|
@ -88,11 +88,12 @@ module Msf::Payload::UUID::Options
|
||||||
return unless datastore['PayloadUUIDTracking']
|
return unless datastore['PayloadUUIDTracking']
|
||||||
|
|
||||||
uuid_info = info.merge({
|
uuid_info = info.merge({
|
||||||
|
uuid: uuid.puid_hex,
|
||||||
arch: uuid.arch,
|
arch: uuid.arch,
|
||||||
platform: uuid.platform,
|
platform: uuid.platform,
|
||||||
timestamp: uuid.timestamp,
|
timestamp: uuid.timestamp,
|
||||||
payload: self.fullname,
|
# payload: self.fullname,
|
||||||
datastore: self.datastore
|
# datastore: self.datastore
|
||||||
})
|
})
|
||||||
|
|
||||||
if datastore['PayloadUUIDSeed'].to_s.length > 0
|
if datastore['PayloadUUIDSeed'].to_s.length > 0
|
||||||
|
@ -103,17 +104,17 @@ module Msf::Payload::UUID::Options
|
||||||
uuid_info[:name] = datastore['PayloadUUIDName']
|
uuid_info[:name] = datastore['PayloadUUIDName']
|
||||||
end
|
end
|
||||||
|
|
||||||
framework.uuid_db[uuid.puid_hex] = uuid_info
|
framework.db.create_payload(uuid_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Store a UUID URL in the JSON database if tracking is enabled
|
# Store a UUID URL in the JSON database if tracking is enabled
|
||||||
def record_payload_uuid_url(uuid, url)
|
def record_payload_uuid_url(uuid, url)
|
||||||
return unless datastore['PayloadUUIDTracking']
|
return unless datastore['PayloadUUIDTracking']
|
||||||
uuid_info = framework.uuid_db[uuid.puid_hex]
|
payload = framework.db.get_payload({:uuid => uuid.puid_hex})
|
||||||
uuid_info['urls'] ||= []
|
urls = payload.urls.nil? ? [] : payload.urls
|
||||||
uuid_info['urls'] << url
|
urls << url
|
||||||
uuid_info['urls'].uniq!
|
urls.uniq!
|
||||||
framework.uuid_db[uuid.puid_hex] = uuid_info
|
framework.db.update_payload({id: payload.id, urls: urls})
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue