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