From 00c758109915636ecb6e33be5c39d8b440595d88 Mon Sep 17 00:00:00 2001 From: James Lee Date: Sat, 6 Jul 2013 12:39:15 -0500 Subject: [PATCH] Fix constant names and 'exe-only' That'll teach me to commit before the specs finish. Really [FixRM #8149] --- lib/msf/util/exe.rb | 27 ++++++++++---------- spec/support/shared/contexts/msf/util/exe.rb | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/msf/util/exe.rb b/lib/msf/util/exe.rb index a69dcd82ac..4b74e5d1de 100755 --- a/lib/msf/util/exe.rb +++ b/lib/msf/util/exe.rb @@ -365,8 +365,11 @@ require 'digest/sha1' def self.to_winpe_only(framework, code, opts={}, arch="x86") - # Allow the user to specify their own EXE template + if arch == ARCH_X86_64 + arch = ARCH_X64 + end + # Allow the user to specify their own EXE template set_template_default(opts, "template_"+arch+"_windows.exe") pe = Rex::PeParsey::Pe.new_from_file(opts[:template], true) @@ -1962,28 +1965,26 @@ End Sub output = case arch when ARCH_X86,nil then to_win32pe_dll(framework, code, exeopts) when ARCH_X86_64 then to_win64pe_dll(framework, code, exeopts) - when ARCH_64 then to_win64pe_dll(framework, code, exeopts) + when ARCH_X64 then to_win64pe_dll(framework, code, exeopts) end when 'exe' output = case arch when ARCH_X86,nil then to_win32pe(framework, code, exeopts) when ARCH_X86_64 then to_win64pe(framework, code, exeopts) - when ARCH_64 then to_win64pe(framework, code, exeopts) + when ARCH_X64 then to_win64pe(framework, code, exeopts) end when 'exe-small' - if(not arch or (arch.index(ARCH_X86))) - output = Msf::Util::EXE.to_win32pe_old(framework, code, exeopts) - end + output = case arch + when ARCH_X86,nil then to_win32pe_old(framework, code, exeopts) + end when 'exe-only' - if(not arch or (arch.index(ARCH_X86))) - output = Msf::Util::EXE.to_winpe_only(framework, code, exeopts) - end - - if(arch and (arch.index( ARCH_X86_64 ) or arch.index( ARCH_X64 ))) - output = Msf::Util::EXE.to_winpe_only(framework, code, exeopts, "x64") - end + output = case arch + when ARCH_X86,nil then to_winpe_only(framework, code, exeopts, arch) + when ARCH_X86_64 then to_winpe_only(framework, code, exeopts, arch) + when ARCH_X64 then to_winpe_only(framework, code, exeopts, arch) + end when 'elf' if (not plat or (plat.index(Msf::Module::Platform::Linux))) diff --git a/spec/support/shared/contexts/msf/util/exe.rb b/spec/support/shared/contexts/msf/util/exe.rb index 5f44a97d12..06f8cfd883 100644 --- a/spec/support/shared/contexts/msf/util/exe.rb +++ b/spec/support/shared/contexts/msf/util/exe.rb @@ -14,6 +14,7 @@ shared_context 'Msf::Util::Exe' do #{ :format => "exe-small", :arch => "x64", :file_fp => /PE32\+/ }, { :format => "exe-only", :arch => "x86", :file_fp => /PE32 / }, { :format => "exe-only", :arch => "x64", :file_fp => /PE32\+ / }, + { :format => "exe-only", :arch => "x86_64", :file_fp => /PE32\+ / }, ], "linux" => [ { :format => "elf", :arch => "x86", :file_fp => /ELF 32.*SYSV/ },