# #-- # Ronin Exploits - A Ruby library for Ronin that provides exploitation and # payload crafting functionality. # # Copyright (c) 2007-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/payloads' require 'ronin/ui/command_line/command' require 'ronin/ui/verbose' require 'ronin/database' require 'parameters/parser' module Ronin module UI module CommandLine module Commands class Payload < Command include Parameters::Parser def defaults @path = nil @query = {} @params = {} end def define_options(opts) opts.usage = '[options] [NAME]' opts.options do opts.on('-D','--database URI','The URI for the database') do |uri| Database.config = uri.to_s end opts.on('-p','--param NAME=VALUE','Add a parameter NAME and VALUE') do |name_and_value| @params.merge!(Parser.parse_param(name_and_value)) end opts.on('-f','--file PATH','Load the payload from the specified FILE') do |path| @path = path end opts.on('-v','--verbose','Enables verbose output') do UI::Verbose.enable! end opts.on('-V','--version VERSION','Use the payload with the specified VERSION') do |version| @query[:version] = version.to_s end end opts.arguments( 'NAME' => 'The NAME of the payload to load' ) opts.summary %{ Build the specified payload } end def arguments(*args) Database.setup! # Load the payload if @path payload = Payloads::Payload.load_from(@path) elsif args.length >= 1 @query[:name] = args.first unless (payload = Payloads::Payload.first(@query)) fail("could not find the specified payload") end else fail("must either specify a payload NAME or a PATH") end # Build the payload payload.build!(@params) # Dump the built payload puts payload.payload.dump end end end end end end