Skip to content

Commit 00c7581

Browse files
committed
Fix constant names and 'exe-only'
That'll teach me to commit before the specs finish. Really [FixRM rapid7#8149]
1 parent 1b50419 commit 00c7581

File tree

2 files changed

+15
-13
lines changed
  • lib/msf/util
  • spec/support/shared/contexts/msf/util

2 files changed

+15
-13
lines changed

lib/msf/util/exe.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,11 @@ def self.to_win32pe(framework, code, opts={})
365365

366366
def self.to_winpe_only(framework, code, opts={}, arch="x86")
367367

368-
# Allow the user to specify their own EXE template
368+
if arch == ARCH_X86_64
369+
arch = ARCH_X64
370+
end
369371

372+
# Allow the user to specify their own EXE template
370373
set_template_default(opts, "template_"+arch+"_windows.exe")
371374

372375
pe = Rex::PeParsey::Pe.new_from_file(opts[:template], true)
@@ -1962,28 +1965,26 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
19621965
output = case arch
19631966
when ARCH_X86,nil then to_win32pe_dll(framework, code, exeopts)
19641967
when ARCH_X86_64 then to_win64pe_dll(framework, code, exeopts)
1965-
when ARCH_64 then to_win64pe_dll(framework, code, exeopts)
1968+
when ARCH_X64 then to_win64pe_dll(framework, code, exeopts)
19661969
end
19671970
when 'exe'
19681971
output = case arch
19691972
when ARCH_X86,nil then to_win32pe(framework, code, exeopts)
19701973
when ARCH_X86_64 then to_win64pe(framework, code, exeopts)
1971-
when ARCH_64 then to_win64pe(framework, code, exeopts)
1974+
when ARCH_X64 then to_win64pe(framework, code, exeopts)
19721975
end
19731976

19741977
when 'exe-small'
1975-
if(not arch or (arch.index(ARCH_X86)))
1976-
output = Msf::Util::EXE.to_win32pe_old(framework, code, exeopts)
1977-
end
1978+
output = case arch
1979+
when ARCH_X86,nil then to_win32pe_old(framework, code, exeopts)
1980+
end
19781981

19791982
when 'exe-only'
1980-
if(not arch or (arch.index(ARCH_X86)))
1981-
output = Msf::Util::EXE.to_winpe_only(framework, code, exeopts)
1982-
end
1983-
1984-
if(arch and (arch.index( ARCH_X86_64 ) or arch.index( ARCH_X64 )))
1985-
output = Msf::Util::EXE.to_winpe_only(framework, code, exeopts, "x64")
1986-
end
1983+
output = case arch
1984+
when ARCH_X86,nil then to_winpe_only(framework, code, exeopts, arch)
1985+
when ARCH_X86_64 then to_winpe_only(framework, code, exeopts, arch)
1986+
when ARCH_X64 then to_winpe_only(framework, code, exeopts, arch)
1987+
end
19871988

19881989
when 'elf'
19891990
if (not plat or (plat.index(Msf::Module::Platform::Linux)))

spec/support/shared/contexts/msf/util/exe.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#{ :format => "exe-small", :arch => "x64", :file_fp => /PE32\+/ },
1515
{ :format => "exe-only", :arch => "x86", :file_fp => /PE32 / },
1616
{ :format => "exe-only", :arch => "x64", :file_fp => /PE32\+ / },
17+
{ :format => "exe-only", :arch => "x86_64", :file_fp => /PE32\+ / },
1718
],
1819
"linux" => [
1920
{ :format => "elf", :arch => "x86", :file_fp => /ELF 32.*SYSV/ },

0 commit comments

Comments
 (0)