diff --git a/lib/metasploit/framework/data_service/remote/http/core.rb b/lib/metasploit/framework/data_service/remote/http/core.rb index 3e21256999..39bb38b1e3 100644 --- a/lib/metasploit/framework/data_service/remote/http/core.rb +++ b/lib/metasploit/framework/data_service/remote/http/core.rb @@ -108,7 +108,8 @@ class RemoteHTTPDataService # def make_request(request_type, path, data_hash = nil, query = nil) begin - query_str = (!query.nil? && !query.empty?) ? URI.encode_www_form(append_workspace(query)) : nil + # simplify query by removing nil values + query_str = (!query.nil? && !query.empty?) ? append_workspace(query).compact.to_query : nil uri = URI::HTTP::build({path: path, query: query_str}) puts "#{Time.now} - HTTP #{request_type} request to #{uri.request_uri} with #{data_hash ? data_hash : "nil"}" diff --git a/lib/msf/core/db_manager/host.rb b/lib/msf/core/db_manager/host.rb index cb710c19a7..880e7d7c3e 100644 --- a/lib/msf/core/db_manager/host.rb +++ b/lib/msf/core/db_manager/host.rb @@ -152,9 +152,9 @@ module Msf::DBManager::Host conditions = {} conditions[:state] = [Msf::HostState::Alive, Msf::HostState::Unknown] if opts[:non_dead] - conditions[:address] = opts[:addresses] if opts[:addresses] + conditions[:address] = opts[:addresses] if opts[:addresses] && !opts[:addresses].empty? - if opts[:search_term] + if opts[:search_term] && !opts[:search_term].empty? column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Host, opts[:search_term]) tag_conditions = Arel::Nodes::Regexp.new(Mdm::Tag.arel_table[:name], Arel::Nodes.build_quoted("(?mi)#{opts[:search_term]}")) search_conditions = column_search_conditions.or(tag_conditions)