Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/util/exe/osx.rb
57467 views
1
# -*- coding: binary -*-
2
module Msf::Util::EXE::OSX
3
include Msf::Util::EXE::Common
4
include Msf::Util::EXE::OSX::Common
5
include Msf::Util::EXE::OSX::X86
6
include Msf::Util::EXE::OSX::X64
7
include Msf::Util::EXE::OSX::Armle
8
include Msf::Util::EXE::OSX::Aarch64
9
10
def self.included(base)
11
base.extend(ClassMethods)
12
end
13
14
module ClassMethods
15
def to_executable_osx(framework, arch, code, fmt = 'macho', opts = {})
16
exe_formats = ['macho', 'app']
17
exe_fmt = 'macho'
18
exe_fmt = fmt if exe_formats.include?(fmt)
19
20
exe = nil
21
exe = to_executable_osx_x86(framework, code, exe_fmt, opts) if arch.index(ARCH_X86)
22
exe = to_executable_osx_x64(framework, code, exe_fmt, opts) if arch.index(ARCH_X64)
23
exe = to_executable_osx_armle(framework, code, exe_fmt, opts) if arch.index(ARCH_ARMLE)
24
exe = to_executable_osx_aarch64(framework, code, exe_fmt, opts) if arch.index(ARCH_AARCH64)
25
exe = to_executable_osx_app(framework, code, exe_fmt, opts) if fmt == 'app'
26
exe = to_executable_osx_ppc(framework, code, exe_fmt, opts) if arch.index(ARCH_PPC)
27
28
return exe if exe_formats.include?(fmt) # Returning only the exe
29
end
30
31
def to_executable_osx_x86(framework, code, fmt = 'macho', opts = {})
32
return to_osx_x86_macho(framework, code, opts) if fmt == 'macho'
33
end
34
35
def to_executable_osx_x64(framework, code, fmt = 'macho', opts = {})
36
return to_osx_x64_macho(framework, code, opts) if fmt == 'macho'
37
end
38
39
def to_executable_osx_armle(framework, code, fmt = 'macho', opts = {})
40
return to_osx_armle_macho(framework, code, opts) if fmt == 'macho'
41
end
42
43
def to_executable_osx_aarch64(framework, code, fmt = 'macho', opts = {})
44
return to_osx_aarch64_macho(framework, code, opts) if fmt == 'macho'
45
end
46
47
def to_executable_osx_app(framework, code, fmt = 'app', opts = {})
48
return to_osx_app(code, opts) if fmt == 'app'
49
end
50
51
def to_executable_osx_ppc(framework, code, fmt = 'macho', opts = {})
52
return to_osx_ppc_macho(framework, code, opts) if fmt == 'macho'
53
end
54
end
55
class << self
56
include ClassMethods
57
end
58
end
59
60