Files
metasploit-gs/lib/msf/core/exploit/exe.rb
T
Joshua Drake 276a83d7b4 allow specifing which code to use for the exe
git-svn-id: file:///home/svn/framework3/trunk@9895 4d416f70-5f16-0410-b530-b9f4589650da
2010-07-21 00:01:45 +00:00

63 lines
1.2 KiB
Ruby

##
# $Id$
##
###
#
# This module exposes a simple method to create an payload in an executable.
#
###
module Msf
module Exploit::EXE
def initialize(info = {})
super
register_advanced_options(
[
OptString.new( 'EXETEMPLATE', [ false, 'The executable template file name.' ]),
OptBool.new( 'EXEINJECT', [ false, 'Set to preserve the original EXE function' ])
], self.class)
end
def generate_exe(opts = {})
if (altexe = datastore['EXETEMPLATE'])
opts.merge!({ :template => altexe })
end
if (datastore['EXEINJECT'])
opts.merge!({ :inject => true })
end
# Prefer the target's platform/architecture information, but use
# the module's if no target specific information exists
lplat ||= target_platform
lplat ||= platform
larch ||= target_arch
larch ||= arch
# Ensure we have an array
if not larch.kind_of? Array
larch = [larch]
end
# Fall back to x86...
if (larch.length < 1)
larch = [ARCH_X86]
end
# Transform the PlatformList
if (lplat.kind_of? Msf::Module::PlatformList)
lplat = lplat.platforms
end
pl = opts[:code]
pl ||= payload.encoded
Msf::Util::EXE.to_executable(framework, larch, lplat, pl, opts)
end
end
end