Merge pull request #243 from kernelsmith/venom
added macho support to msfvenom and fixed overly aggressive regexunstable
commit
e35ce32c1f
24
msfvenom
24
msfvenom
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
#
|
#
|
||||||
# $Id: msfvenom 14815 2012-02-27 02:12:04Z rapid7 $
|
# $Id: msfvenom 14909 2012-03-10 06:50:03Z rapid7 $
|
||||||
# $Revision: 14815 $
|
# $Revision: 14909 $
|
||||||
#
|
#
|
||||||
msfbase = __FILE__
|
msfbase = __FILE__
|
||||||
while File.symlink?(msfbase)
|
while File.symlink?(msfbase)
|
||||||
|
@ -107,6 +107,7 @@ def parse_args
|
||||||
|
|
||||||
begin
|
begin
|
||||||
opt.parse!
|
opt.parse!
|
||||||
|
|
||||||
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
||||||
puts "Invalid option, try -h for usage"
|
puts "Invalid option, try -h for usage"
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -297,11 +298,11 @@ else
|
||||||
opts[:arch] ||= "x86"
|
opts[:arch] ||= "x86"
|
||||||
opts[:platform] ||= Msf::Module::PlatformList.transform("Windows")
|
opts[:platform] ||= Msf::Module::PlatformList.transform("Windows")
|
||||||
end
|
end
|
||||||
|
|
||||||
opts[:format] ||= 'ruby'
|
opts[:format] ||= 'ruby'
|
||||||
opts[:encoder] ||= nil
|
opts[:encoder] ||= nil
|
||||||
opts[:encode] ||= !(opts[:badchars].nil? or opts[:badchars].empty?)
|
opts[:encode] ||= !(opts[:badchars].nil? or opts[:badchars].empty?)
|
||||||
|
|
||||||
|
|
||||||
if opts[:encoder].nil?
|
if opts[:encoder].nil?
|
||||||
fmt = 'raw'
|
fmt = 'raw'
|
||||||
else
|
else
|
||||||
|
@ -392,12 +393,13 @@ if opts[:nopsled]
|
||||||
end
|
end
|
||||||
|
|
||||||
$stdout.binmode
|
$stdout.binmode
|
||||||
|
|
||||||
if opts[:format] !~/ruby|rb|perl|pl|bash|sh|c|js|dll|elf/i
|
if opts[:format] !~/ruby|rb|perl|pl|bash|sh|c|js|dll|elf/i
|
||||||
exe = Msf::Util::EXE.to_executable_fmt($framework, opts[:arch], opts[:platform], payload_raw, opts[:format], exeopts)
|
exe = Msf::Util::EXE.to_executable_fmt($framework, opts[:arch], opts[:platform], payload_raw, opts[:format], exeopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
case opts[:format]
|
case opts[:format]
|
||||||
when /ruby|rb|perl|pl|bash|sh|c|js_le|raw/i
|
when /ruby|rb|perl|pl|bash|sh|^c$|js_le|raw/i
|
||||||
$stdout.write Msf::Simple::Buffer.transform(payload_raw, opts[:format])
|
$stdout.write Msf::Simple::Buffer.transform(payload_raw, opts[:format])
|
||||||
when /asp$/
|
when /asp$/
|
||||||
asp = Msf::Util::EXE.to_win32pe_asp($framework, payload_raw, exeopts)
|
asp = Msf::Util::EXE.to_win32pe_asp($framework, payload_raw, exeopts)
|
||||||
|
@ -433,6 +435,20 @@ when /elf/i
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
$stdout.write elf
|
$stdout.write elf
|
||||||
|
when /macho/i
|
||||||
|
if opts[:arch] =~ /x64/
|
||||||
|
bin = Msf::Util::EXE.to_osx_x64_macho($framework, payload_raw, exeopts)
|
||||||
|
elsif opts[:arch] =~ /x86/
|
||||||
|
bin = Msf::Util::EXE.to_osx_x86_macho($framework, payload_raw, exeopts)
|
||||||
|
elsif opts[:arch] =~ /arm/
|
||||||
|
bin = Msf::Util::EXE.to_osx_arm_macho($framework, payload_raw, exeopts)
|
||||||
|
elsif opts[:arch] =~ /ppc/
|
||||||
|
bin = Msf::Util::EXE.to_osx_ppc_macho($framework, payload_raw, exeopts)
|
||||||
|
else
|
||||||
|
print_error("This format does not support that architecture")
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
$stdout.write bin
|
||||||
when /dll/i
|
when /dll/i
|
||||||
if opts[:arch] == "x86"
|
if opts[:arch] == "x86"
|
||||||
dll = Msf::Util::EXE.to_win32pe_dll($framework, payload_raw)
|
dll = Msf::Util::EXE.to_win32pe_dll($framework, payload_raw)
|
||||||
|
|
Loading…
Reference in New Issue