[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : Generic Payload Handler
# Published : 2011-02-28
# Author : metasploit
# Previous Title : Citrix Access Gateway Command Execution
# Next Title : Cesar FTP 0.99g MKD Command Buffer Overflow


##
# $Id: handler.rb 11845 2011-02-28 03:22:40Z hdm $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
	Rank = ManualRanking

	#
	# This module does basically nothing
	#

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'Generic Payload Handler',
			'Description'    => %q{
				This module is a stub that provides all of the
				features of the Metasploit payload system to exploits
				that have been launched outside of the framework.
			},
			'License'        => MSF_LICENSE,
			'Author'         =>  ['hdm'],
			'Version'        => '$Revision: 11845 $',
			'References'     =>  [ ],
			'Payload'        =>
				{
					'Space'       => 10000000,
					'BadChars'    => '',
					'DisableNops' => true,
				},
			'Platform'       => [ 'win', 'linux', 'solaris', 'unix', 'osx', 'bsd', 'php', 'java' ],
			'Arch'           => ARCH_ALL,
			'Targets'        => [ [ 'Wildcard Target', { } ] ],
			'DefaultTarget'  => 0
			))

		register_advanced_options(
			[
				OptBool.new("ExitOnSession", [ false, "Return from the exploit after a session has been created", true ]),
				OptInt.new("ListenerTimeout", [ false, "The maximum number of seconds to wait for new sessions", 0])
			], self.class)
	end

	def exploit
		if not datastore['ExitOnSession'] and not job_id
			raise RuntimeError, "Setting ExitOnSession to false requires running as a job (exploit -j)"
		end

		stime = Time.now.to_f
		print_status "Starting the payload handler..."
		while(true)
			break if session_created? and datastore['ExitOnSession']
			break if ( datastore['ListenerTimeout'].to_i > 0 and (stime + datastore['ListenerTimeout'].to_i < Time.now.to_f) )

			select(nil,nil,nil,1)
		end
	end


end