diff --git a/lib/msf/core/exploit/http/client.rb b/lib/msf/core/exploit/http/client.rb index 187059b64c..96a8b00190 100644 --- a/lib/msf/core/exploit/http/client.rb +++ b/lib/msf/core/exploit/http/client.rb @@ -508,6 +508,23 @@ module Exploit::Remote::HttpClient end end + # + # Returns a hash of request opts from a URL string + def request_opts_from_url(url) + tgt = URI.parse(url) + opts = { 'rhost' => tgt.host, 'rport' => tgt.port, 'uri' => tgt.request_uri } + opts['SSL'] = true if tgt.scheme == 'https' + if tgt.query and tgt.query.size > 13 + # Assming that this is going to be mostly used for GET requests as string -> req + opts['vars_get'] = {} + tgt.query.split('&').each do |pair| + k,v = pair.split('=',2) + opts['vars_get'][k] = v + end + end + return opts + end + # removes HTML tags from a provided string. # The string is html-unescaped before the tags are removed # Leading whitespaces and double linebreaks are removed too diff --git a/modules/auxiliary/gather/http_pdf_authors.rb b/modules/auxiliary/gather/http_pdf_authors.rb index 541032c208..19ece51d7d 100644 --- a/modules/auxiliary/gather/http_pdf_authors.rb +++ b/modules/auxiliary/gather/http_pdf_authors.rb @@ -88,25 +88,8 @@ class MetasploitModule < Msf::Auxiliary def download(url) print_status "Downloading '#{url}'" - begin - target = URI.parse url - raise 'Invalid URL' unless target.scheme =~ %r{https?} - raise 'Invalid URL' if target.host.to_s.eql? '' - rescue => e - print_error "Could not parse URL: #{e}" - return - end - options = { - 'rhost' => target.host, - 'rport' => target.port, - 'method' => 'GET', - 'uri' => target.request_uri - } - - options['SSL'] = true if target.scheme.eql? 'https' - - res = send_request_raw(options) + res = send_request_raw(request_options_from_url(url)) disconnect print_status "HTTP #{res.code} -- Downloaded PDF (#{res.body.length} bytes)"