# # 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 'ronin/exploits/web_vuln' require 'ronin/vulns/ssti' module Ronin module Exploits # # Represents a [Server Side Template Injection (SSTI)][SSTI] exploit. # # [SSTI]: https://owasp.org/www-project-web-security-testing-guide/v41/4-Web_Application_Security_Testing/07-Input_Validation_Testing/18-Testing_for_Server_Side_Template_Injection # # ## Example # # require 'ronin/exploits/ssti' # # module Ronin # module Exploits # class MyExploit < SSTI # # register 'my_exploit' # # base_path '/path/to/page.php' # query_param 'name' # escape_expr ->(expr) { "${{#{expr}}}" } # # end # end # end # # @api public # # @since 1.0.0 # class SSTI < WebVuln references [ 'https://owasp.org/www-project-web-security-testing-guide/v41/4-Web_Application_Security_Testing/07-Input_Validation_Testing/18-Testing_for_Server_Side_Template_Injection' ] # # Gets or sets the exploit's SSTI escape logic. # # @param [Proc, nil] new_escape_expr # The optional new escape proc. # # @return [Proc, nil] # The escape expression proc. # # @example # escape_expr ->(expr) { "${{#{expr}}}" } # def self.escape_expr(new_escape_expr=nil) if new_escape_expr @escape_expr = new_escape_expr else @escape_expr || if superclass < SSTI superclass.escape_expr end end end # # Returns the type or kind of exploit. # # @return [Symbol] # # @note # This is used internally to map an exploit class to a printable type. # # @api private # def self.exploit_type :ssti end # # The Server Side Template Injection (SSTI) vulnerability to exploit. # # @return [Ronin::Vulns::SSTI] # def vuln @vuln ||= Vulns::SSTI.new(url, escape: self.class.escape_expr, **web_vuln_kwargs) end end end end