Replace uuid methods for payload count and url validation

master
Erin Bleiweiss 2018-09-13 12:28:04 -05:00
parent 89b68df9d8
commit 8f4e17c277
No known key found for this signature in database
GPG Key ID: F69B2138BD594660
2 changed files with 8 additions and 8 deletions

View File

@ -15,11 +15,10 @@ module Msf::DBManager::Payload
end
end
def find_or_create_payload(opts)
payload = get_payload(opts.clone)
return payload unless payload.nil?
create_payload(opts)
def payload_count
::ActiveRecord::Base.connection_pool.with_connection do
Mdm::Payload.count
end
end
def update_payload(opts)

View File

@ -239,7 +239,7 @@ module ReverseHttp
lookup_proxy_settings
if datastore['IgnoreUnknownPayloads']
print_status("Handler is ignoring unknown payloads, there are #{framework.uuid_db.keys.length} UUIDs whitelisted")
print_status("Handler is ignoring unknown payloads, there are #{framework.db.payload_count} UUIDs whitelisted")
end
end
@ -323,14 +323,15 @@ protected
request_summary = "#{conn_id} with UA '#{req.headers['User-Agent']}'"
# Validate known UUIDs for all requests if IgnoreUnknownPayloads is set
if datastore['IgnoreUnknownPayloads'] && ! framework.uuid_db[uuid.puid_hex]
if datastore['IgnoreUnknownPayloads'] && ! framework.db.get_payload({uuid: uuid.puid_hex})
print_status("Ignoring unknown UUID: #{request_summary}")
info[:mode] = :unknown_uuid
end
# Validate known URLs for all session init requests if IgnoreUnknownPayloads is set
if datastore['IgnoreUnknownPayloads'] && info[:mode].to_s =~ /^init_/
allowed_urls = framework.uuid_db[uuid.puid_hex]['urls'] || []
payload = framework.db.get_payload({uuid: uuid.puid_hex})
allowed_urls = payload ? payload.urls : []
unless allowed_urls.include?(req.relative_resource)
print_status("Ignoring unknown UUID URL: #{request_summary}")
info[:mode] = :unknown_uuid_url