Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/util/exe/windows.rb
36037 views
1
module Msf::Util::EXE::Windows
2
include Msf::Util::EXE::Common
3
include Msf::Util::EXE::Windows::Common
4
include Msf::Util::EXE::Windows::Aarch64
5
include Msf::Util::EXE::Windows::X64
6
include Msf::Util::EXE::Windows::X86
7
8
def self.included(base)
9
base.extend(ClassMethods)
10
end
11
12
module ClassMethods
13
14
def to_executable_windows(framework, arch, code, fmt = 'exe', opts = {})
15
exe_formats = ['exe', 'exe-service', 'dll', 'dll-dccw-gdiplus']
16
17
exe_fmt ||= 'exe-small' if ['vba-exe', 'vbs', 'loop-vbs', 'asp', 'aspx-exe'].include?(fmt)
18
exe_fmt = 'exe'
19
20
exe_fmt = fmt if exe_formats.include?(fmt)
21
22
exe = nil
23
exe = to_executable_windows_x86(framework, code, exe_fmt, opts) if arch.index(ARCH_X86)
24
exe = to_executable_windows_x64(framework, code, exe_fmt, opts) if arch.index(ARCH_X64)
25
exe = to_executable_windows_aarch64(framework, code, exe_fmt, opts) if arch.index(ARCH_AARCH64)
26
return exe if exe_formats.include?(fmt) # Returning only the exe
27
end
28
29
def to_executable_windows_aarch64(framework, code, fmt = 'exe', opts = {})
30
return to_winaarch64pe(framework, code, opts) if fmt == 'exe'
31
end
32
33
def to_executable_windows_x64(framework, code, fmt = 'exe', opts = {})
34
return to_win64pe(framework, code, opts) if fmt == 'exe'
35
return to_win64pe(framework, code, opts) if fmt == 'exe-small'
36
return to_win64pe_service(framework, code, opts) if fmt == 'exe-service'
37
return to_win64pe_dll(framework, code, opts) if fmt == 'dll'
38
return to_win64pe_dccw_gdiplus_dll(framework, code, opts) if fmt == 'dll-dccw-gdiplus'
39
end
40
41
def to_executable_windows_x86(framework, code, fmt = 'exe', opts = {})
42
return to_win32pe(framework, code, opts) if fmt == 'exe'
43
return to_win32pe_service(framework, code, opts) if fmt == 'exe-servsice'
44
return to_win32pe_dll(framework, code, opts) if fmt == 'dll'
45
return to_winpe_only(framework, code, opts, ARCH_X86) if fmt == 'exe-only'
46
return to_win32pe_old(framework, code, opts) if fmt == 'exe-small'
47
end
48
end
49
50
class << self
51
include ClassMethods
52
end
53
end
54
55