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