Path: blob/master/lib/msf/util/exe/linux.rb
57467 views
# -*- coding: binary -*-1module Msf::Util::EXE::Linux23include Msf::Util::EXE::Linux::Common4include Msf::Util::EXE::Linux::Aarch645include Msf::Util::EXE::Linux::Armle6include Msf::Util::EXE::Linux::Armbe7include Msf::Util::EXE::Linux::Loongarch648include Msf::Util::EXE::Linux::Mips649include Msf::Util::EXE::Linux::Mipsbe10include Msf::Util::EXE::Linux::Mipsle11include Msf::Util::EXE::Linux::Ppc12include Msf::Util::EXE::Linux::Ppc6413include Msf::Util::EXE::Linux::Ppce500v214include Msf::Util::EXE::Linux::Riscv32le15include Msf::Util::EXE::Linux::Riscv32le16include Msf::Util::EXE::Linux::X6417include Msf::Util::EXE::Linux::X8618include Msf::Util::EXE::Linux::Zarch1920def self.included(base)21base.extend(ClassMethods)22end2324module ClassMethods25def to_executable_linux(framework, arch, code, fmt = 'elf', opts = {})2627elf_formats = ['elf','elf-so']28elf_fmt = 'elf'29elf_fmt = fmt if elf_formats.include?(fmt)3031elf = to_executable_linux_x86(framework, code, elf_fmt, opts) if arch.index(ARCH_X86)32elf = to_executable_linux_x64(framework, code, elf_fmt,opts) if arch.index(ARCH_X64)33elf = to_executable_linux_armle(framework, code, elf_fmt,opts) if arch.index(ARCH_ARMLE)34elf = to_executable_linux_armbe(framework, code, elf_fmt,opts) if arch.index(ARCH_ARMBE)35elf = to_executable_linux_aarch64(framework, code, elf_fmt,opts) if arch.index(ARCH_AARCH64)36elf = to_executable_linux_mipsbe(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPSBE)37elf = to_executable_linux_mipsle(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPSLE)38elf = to_executable_linux_mips64(framework, code, elf_fmt,opts) if arch.index(ARCH_MIPS64)39elf = to_executable_linux_ppc(framework, code, elf_fmt,opts) if arch.index(ARCH_PPC)40elf = to_executable_linux_ppc64(framework, code, elf_fmt,opts) if arch.index(ARCH_PPC64LE)41elf = to_executable_linux_ppce500v2(framework, code, elf_fmt,opts) if arch.index(ARCH_PPCE500V2)42elf = to_executable_linux_riscv32le(framework, code,elf_fmt, opts) if arch.index(ARCH_RISCV32LE)43elf = to_executable_linux_riscv64le(framework, code, elf_fmt,opts) if arch.index(ARCH_RISCV64LE)44elf = to_executable_linux_zarch(framework, code, elf_fmt,opts) if arch.index(ARCH_ZARCH)45elf = to_executable_linux_loongarch64(framework, code, elf_fmt,opts) if arch.index(ARCH_LOONGARCH64)4647return elf if elf_formats.include?(fmt) # Returning only the elf48end4950def to_executable_linux_x64(framework, code, fmt = 'elf', opts = {})51return to_linux_x64_elf(framework, code, opts) if fmt == 'elf'52return to_linux_x64_elf_dll(framework, code, opts) if fmt == 'elf-so'53end5455def to_executable_linux_x86(framework, code, fmt = 'exe', opts = {})56return to_linux_x86_elf(framework, code, opts) if fmt == 'elf'57return to_linux_x86_elf_dll(framework, code, opts) if fmt == 'elf-so'58end5960def to_executable_linux_armle(framework, code, fmt = 'elf', opts = {})61return to_linux_armle_elf(framework, code, opts) if fmt == 'elf'62return to_linux_armle_elf_dll(framework, code, opts) if fmt == 'elf-so'63end6465def to_executable_linux_armbe(framework, code, fmt = 'elf', opts = {})66return to_linux_armbe_elf(framework, code, opts) if fmt == 'elf'67end6869def to_executable_linux_aarch64(framework, code, fmt = 'elf', opts = {})70return to_linux_aarch64_elf(framework, code, opts) if fmt == 'elf'71return to_linux_aarch64_elf_dll(framework, code, opts) if fmt == 'elf-so'72end7374def to_executable_linux_mipsbe(framework, code, fmt = 'elf', opts = {})75return to_linux_mipsbe_elf(framework, code, opts) if fmt == 'elf'76end7778def to_executable_linux_mipsle(framework, code, fmt = 'elf', opts = {})79return to_linux_mipsle_elf(framework, code, opts) if fmt == 'elf'80end8182def to_executable_linux_mips64(framework, code, fmt = 'elf', opts = {})83return to_linux_mips64_elf(framework, code, opts) if fmt == 'elf'84end8586def to_executable_linux_ppc(framework, code, fmt = 'elf', opts = {})87return to_linux_ppc_elf(framework, code, opts) if fmt == 'elf'88end8990def to_executable_linux_ppc64(framework, code, fmt = 'elf', opts = {})91return to_linux_ppc64_elf(framework, code, opts) if fmt == 'elf'92end9394def to_executable_linux_ppce500v2(framework, code, fmt = 'elf', opts = {})95return to_linux_ppce500v2_elf(framework, code, opts) if fmt == 'elf'96end9798def to_executable_linux_riscv32le(framework, code, fmt = 'elf', opts = {})99return to_linux_riscv32le_elf(framework, code, opts) if fmt == 'elf'100return to_linux_riscv32le_elf_dll(framework, code, opts) if fmt == 'elf-so'101end102103def to_executable_linux_riscv64le(framework, code, fmt = 'elf', opts = {})104return to_linux_riscv64le_elf(framework, code, opts) if fmt == 'elf'105return to_linux_riscv64le_elf_dll(framework, code, opts) if fmt == 'elf-so'106end107108def to_executable_linux_zarch(framework, code, fmt = 'elf', opts = {})109return to_linux_zarch_elf(framework, code, opts) if fmt == 'elf'110end111112def to_executable_linux_loongarch64(framework, code, fmt = 'elf', opts = {})113return to_linux_loongarch64_elf(framework, code, opts) if fmt == 'elf'114return to_linux_loongarch64_elf_dll(framework, code, opts) if fmt == 'elf-so'115end116end117118class << self119include ClassMethods120end121end122123124