# # ronin-exploits - A Ruby library for ronin-rb that provides exploitation and # payload crafting functionality. # # Copyright (c) 2007-2022 Hal Brodigan (postmodern.mod3 at gmail.com) # # ronin-exploits is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ronin-exploits is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ronin-exploits. If not, see . # require 'uri' module Ronin module Exploits module Params # # Adds the required `base_url` param to the exploit. # # @api public # # @since 1.0.0 # module BaseURL # # Adds the required `base_url` param to the exploit including # {Params::BaseURL}. # # @param [Class] exploit # The exploit class including {Params::BaseURL}. # # @api private # def self.included(exploit) exploit.param :base_url, URI, required: true, desc: 'The base URL of the target' end # # The targeted host. # # @return [String] # def host params[:base_url].host end # # The targeted port. # # @return [Integer] # def port params[:base_url].port end # # Expands the URL or path into a fully qualitifed URL. # # @param [String] path # The URL or path to expand. # # @return [URI::HTTP, URI::HTTPS] # If a URL is given, it will be returned as a `URI::HTTP` or # `URI::HTTPS` object. If a path was given, it will be joined with # the `base_url` param and a `URI::HTTP` or `URI::HTTPS` object will # be returned. # def url_for(path) params[:base_url].merge(path) end end end end end