# frozen_string_literal: true
#
# ronin-exploits - A Ruby library for ronin-rb that provides exploitation and
# payload crafting functionality.
#
# Copyright (c) 2007-2024 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 .
#
module Ronin
module Exploits
module Metadata
#
# Adds a {URLPath::ClassMethods#url_path url_path} metadata attribute
# to an exploit class.
#
module URLPath
#
# Adds {ClassMethods} to the exploit class.
#
# @param [Class] exploit
# The exploit class including {URLQueryParam}.
#
# @api private
#
def self.included(exploit)
exploit.extend ClassMethods
end
#
# Class-methods.
#
module ClassMethods
#
# Get or sets the target URL path of the exploit.
#
# @param [String, nil] new_url_path
# The optional new URL path value to set.
#
# @return [String]
# The URL path value. Defaults to `"/"` if not set.
#
# @api public
#
def url_path(new_url_path=nil)
if new_url_path
@url_path = new_url_path
else
@url_path ||= if superclass.kind_of?(ClassMethods)
superclass.url_path
else
'/'
end
end
end
end
#
# The target URL path of the exploit.
#
# @return [String]
# The URL path to exploit. Defaults to `"/"` if not set in the class.
#
# @api public
#
# @see ClassMethods#url_path
#
def url_path
self.class.url_path
end
end
end
end
end