Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/util/exe/linux.rb
36037 views
1
module Msf::Util::EXE::Linux
2
3
include Msf::Util::EXE::Linux::Common
4
include Msf::Util::EXE::Linux::Aarch64
5
include Msf::Util::EXE::Linux::Armle
6
include Msf::Util::EXE::Linux::Armbe
7
include Msf::Util::EXE::Linux::Loongarch64
8
include Msf::Util::EXE::Linux::Mips64
9
include Msf::Util::EXE::Linux::Mipsbe
10
include Msf::Util::EXE::Linux::Mipsle
11
include Msf::Util::EXE::Linux::Ppc
12
include Msf::Util::EXE::Linux::Ppc64
13
include Msf::Util::EXE::Linux::Ppce500v2
14
include Msf::Util::EXE::Linux::Riscv32le
15
include Msf::Util::EXE::Linux::Riscv32le
16
include Msf::Util::EXE::Linux::X64
17
include Msf::Util::EXE::Linux::X86
18
include Msf::Util::EXE::Linux::Zarch
19
20
def self.included(base)
21
base.extend(ClassMethods)
22
end
23
24
module ClassMethods
25
def to_executable_linux(framework, arch, code, fmt = 'elf', opts = {})
26
27
elf_formats = ['elf','elf-so']
28
elf_fmt = 'elf'
29
elf_fmt = fmt if elf_formats.include?(fmt)
30
31
elf = to_executable_linux_x86(framework, code, elf_fmt, opts) if arch.index(ARCH_X86)
32
elf = to_executable_linux_x64(framework, code, elf_fmt,opts) if arch.index(ARCH_X64)
33
elf = to_executable_linux_armle(framework, code, elf_fmt,opts) if arch.index(ARCH_ARMLE)
34
elf = to_executable_linux_armbe(framework, code, elf_fmt,opts) if arch.index(ARCH_ARMBE)
35
elf = to_executable_linux_aarch64(framework, code, elf_fmt,opts) if arch.index(ARCH_AARCH64)
36
elf = to_executable_linux_mipsbe(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPSBE)
37
elf = to_executable_linux_mipsle(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPSLE)
38
elf = to_executable_linux_mips64(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPS64)
39
elf = to_executable_linux_ppc(framework, code, elf_fmt,opts) if arch.index(ARCH_PPC)
40
elf = to_executable_linux_ppc64(framework, code, elf_fmt,opts) if arch.index(ARCH_PPC64LE)
41
elf = to_executable_linux_ppce500v2(framework, code, elf_fmt,opts) if arch.index(ARCH_PPCE500V2)
42
elf = to_executable_linux_riscv32le(framework, code,elf_fmt, opts) if arch.index(ARCH_RISCV32LE)
43
elf = to_executable_linux_riscv64le(framework, code, elf_fmt,opts) if arch.index(ARCH_RISCV64LE)
44
elf = to_executable_linux_zarch(framework, code, elf_fmt,opts) if arch.index(ARCH_ZARCH)
45
elf = to_executable_linux_loongarch64(framework, code, elf_fmt,opts) if arch.index(ARCH_LOONGARCH64)
46
47
return elf if elf_formats.include?(fmt) # Returning only the elf
48
end
49
50
def to_executable_linux_x64(framework, code, fmt = 'elf', opts = {})
51
return to_linux_x64_elf(framework, code, opts) if fmt == 'elf'
52
return to_linux_x64_elf_dll(framework, code, opts) if fmt == 'elf-so'
53
end
54
55
def to_executable_linux_x86(framework, code, fmt = 'exe', opts = {})
56
return to_linux_x86_elf(framework, code, opts) if fmt == 'elf'
57
return to_linux_x86_elf_dll(framework, code, opts) if fmt == 'elf-so'
58
end
59
60
def to_executable_linux_armle(framework, code, fmt = 'elf', opts = {})
61
return to_linux_armle_elf(framework, code, opts) if fmt == 'elf'
62
return to_linux_armle_elf_dll(framework, code, opts) if fmt == 'elf-so'
63
end
64
65
def to_executable_linux_armbe(framework, code, fmt = 'elf', opts = {})
66
return to_linux_armbe_elf(framework, code, opts) if fmt == 'elf'
67
end
68
69
def to_executable_linux_aarch64(framework, code, fmt = 'elf', opts = {})
70
return to_linux_aarch64_elf(framework, code, opts) if fmt == 'elf'
71
return to_linux_aarch64_elf_dll(framework, code, opts) if fmt == 'elf-so'
72
end
73
74
def to_executable_linux_mipsbe(framework, code, fmt = 'elf', opts = {})
75
return to_linux_mipsbe_elf(framework, code, opts) if fmt == 'elf'
76
end
77
78
def to_executable_linux_mipsle(framework, code, fmt = 'elf', opts = {})
79
return to_linux_mipsle_elf(framework, code, opts) if fmt == 'elf'
80
end
81
82
def to_executable_linux_mips64(framework, code, fmt = 'elf', opts = {})
83
return to_linux_mips64_elf(framework, code, opts) if fmt == 'elf'
84
end
85
86
def to_executable_linux_ppc(framework, code, fmt = 'elf', opts = {})
87
return to_linux_ppc_elf(framework, code, opts) if fmt == 'elf'
88
end
89
90
def to_executable_linux_ppc64(framework, code, fmt = 'elf', opts = {})
91
return to_linux_ppc64_elf(framework, code, opts) if fmt == 'elf'
92
end
93
94
def to_executable_linux_ppce500v2(framework, code, fmt = 'elf', opts = {})
95
return to_linux_ppce500v2_elf(framework, code, opts) if fmt == 'elf'
96
end
97
98
def to_executable_linux_riscv32le(framework, code, fmt = 'elf', opts = {})
99
return to_linux_riscv32le_elf(framework, code, opts) if fmt == 'elf'
100
return to_linux_riscv32le_elf_dll(framework, code, opts) if fmt == 'elf-so'
101
end
102
103
def to_executable_linux_riscv64le(framework, code, fmt = 'elf', opts = {})
104
return to_linux_riscv64le_elf(framework, code, opts) if fmt == 'elf'
105
return to_linux_riscv64le_elf_dll(framework, code, opts) if fmt == 'elf-so'
106
end
107
108
def to_executable_linux_zarch(framework, code, fmt = 'elf', opts = {})
109
return to_linux_zarch_elf(framework, code, opts) if fmt == 'elf'
110
end
111
112
def to_executable_linux_loongarch64(framework, code, fmt = 'elf', opts = {})
113
return to_linux_loongarch64_elf(framework, code, opts) if fmt == 'elf'
114
return to_linux_loongarch64_elf_dll(framework, code, opts) if fmt == 'elf-so'
115
end
116
end
117
118
class << self
119
include ClassMethods
120
end
121
end
122
123