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