From e9e8519be6cf520fab689fb6fbe755f3eb490226 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Wed, 14 Apr 2010 17:23:35 +0000 Subject: [PATCH] Macho support for msfencode git-svn-id: file:///home/svn/framework3/trunk@9071 4d416f70-5f16-0410-b530-b9f4589650da --- msfencode | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/msfencode b/msfencode index 190072cf7a..bcdcf1151a 100755 --- a/msfencode +++ b/msfencode @@ -20,7 +20,7 @@ $args = Rex::Parser::Arguments.new( "-m" => [ true, "Specifies an additional module search path" ], "-a" => [ true, "The architecture to encode as" ], "-p" => [ true, "The platform to encode for" ], - "-t" => [ true, "The format to display the encoded buffer with (c, elf, exe, java, js_le, js_be, perl, raw, ruby, vba, vbs, loop-vbs, asp, war)" ], + "-t" => [ true, "The format to display the encoded buffer with (c, elf, exe, java, js_le, js_be, perl, raw, ruby, vba, vbs, loop-vbs, asp, war, macho)" ], "-b" => [ true, "The list of characters to avoid: '\\x00\\xff'" ], "-s" => [ true, "The maximum size of the encoded data" ], "-e" => [ true, "The encoder to use" ], @@ -126,7 +126,7 @@ $args.parse(ARGV) { |opt, idx, val| when "-s" space = val.to_i when "-t" - if (val =~ /^(perl|ruby|rb|raw|c|js_le|js_be|java|exe|exe-small|elf|vba|vbs|loop-vbs|asp|war)$/) + if (val =~ /^(perl|ruby|rb|raw|c|js_le|js_be|java|exe|exe-small|elf|vba|vbs|loop-vbs|asp|war|macho)$/) fmt = val else $stderr.puts(OutError + "Invalid format: #{val}") @@ -254,6 +254,15 @@ case cmd fd.write(elf) end end + when 'macho' + macho = Msf::Util::EXE.to_osx_x86_macho($framework, raw) + if(not output) + $stdout.write(macho) + else + File.open(output, "wb") do |fd| + fd.write(macho) + end + end when 'vba' exe = Msf::Util::EXE.to_win32pe($framework, raw, {:insert => inject, :template => altexe}) vba = Msf::Util::EXE.to_exe_vba(exe)