Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/util/exe/bsd.rb
36037 views
1
module Msf::Util::EXE::Bsd
2
include Msf::Util::EXE::Common
3
include Msf::Util::EXE::Bsd::X86
4
include Msf::Util::EXE::Bsd::X64
5
6
def self.included(base)
7
base.extend(ClassMethods)
8
end
9
10
module ClassMethods
11
def to_executable_bsd(framework, arch, code, fmt = 'elf', opts = {})
12
exe_formats = ['elf', 'elf-so']
13
exe_fmt = 'elf'
14
exe_fmt = fmt if exe_formats.include?(fmt)
15
16
exe = nil
17
exe = to_executable_bsd_x86(framework, code, exe_fmt, opts) if arch.index(ARCH_X86)
18
exe = to_executable_bsd_x64(framework, code, exe_fmt, opts) if arch.index(ARCH_X64)
19
#exe = to_executable_bsd_armle(framework, code, exe_fmt, opts) if arch =~ /armle|armv7l/i Not yet implemented
20
#exe = to_executable_bsd_aarch64(framework, code, exe_fmt, opts) if arch =~ /aarch64|arm64/i Not yet implemented
21
22
return exe if exe_formats.include?(fmt) # Returning only the exe
23
nil
24
end
25
26
def to_executable_bsd_x86(framework, code, fmt = 'elf', opts = {})
27
return to_bsd_x86_elf(framework, code, opts) if fmt == 'elf'
28
# return to_bsd_x86_elf_dll(framework, code, opts) if fmt == 'elf-so' Not yet implemented
29
end
30
31
def to_executable_bsd_x64(framework, code, fmt = 'elf', opts = {})
32
return to_bsd_x64_elf(framework, code, opts) if fmt == 'elf'
33
#return to_bsd_x64_elf_dll(framework, code, opts) if fmt == 'elf-so' Not yet implemented
34
end
35
end
36
37
class << self
38
include ClassMethods
39
end
40
end
41
42