# #-- # Ronin Exploits - A Ruby library for Ronin that provides exploitation and # payload crafting functionality. # # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #++ # require 'ronin/extensions/meta' module Ronin module Exploits module Exploitable def self.included(base) base.metaclass_eval do # # Returns the Hash of the exploit names and the +Proc+ # objects used to generate various Exploit objects. # def exploit_generators @ronin_exploit_generators ||= {} end def each_exploit_generator(&block) self.class.ancestors.each do |super_class| if super_class.include?(Ronin::Exploits::Exploitable) super_class.exploit_generators.each(&block) end end end # # Registers a new exploit generator with the specified _name_ # and the specified _block_ which will return an Array of # exploits. # # has_exploits :lfi do |url| # ... # end # def has_exploits(name,&block) self.exploit_generators[name.to_sym] = block return self end end end def exploits viable_exploits = [] self.class.each_exploit_generator do |name,block| viable_exploits += block.call(self).select do |exp| exp.vulnerable? end end return viable_exploits end end end end