Path: blob/master/lib/msf/util/exe/windows.rb
57467 views
# -*- coding: binary -*-1module Msf::Util::EXE::Windows2include Msf::Util::EXE::Common3include Msf::Util::EXE::Windows::Common4include Msf::Util::EXE::Windows::Aarch645include Msf::Util::EXE::Windows::X646include Msf::Util::EXE::Windows::X8678def self.included(base)9base.extend(ClassMethods)10end1112module ClassMethods1314def to_executable_windows(framework, arch, code, fmt = 'exe', opts = {})15exe_formats = ['exe', 'exe-service', 'dll', 'dll-dccw-gdiplus']1617exe_fmt ||= 'exe-small' if ['vba-exe', 'vbs', 'loop-vbs', 'asp', 'aspx-exe'].include?(fmt)18exe_fmt = 'exe'1920exe_fmt = fmt if exe_formats.include?(fmt)2122exe = nil23exe = to_executable_windows_x86(framework, code, exe_fmt, opts) if arch.index(ARCH_X86)24exe = to_executable_windows_x64(framework, code, exe_fmt, opts) if arch.index(ARCH_X64)25exe = to_executable_windows_aarch64(framework, code, exe_fmt, opts) if arch.index(ARCH_AARCH64)26return exe if exe_formats.include?(fmt) # Returning only the exe27end2829def to_executable_windows_aarch64(framework, code, fmt = 'exe', opts = {})30return to_winaarch64pe(framework, code, opts) if fmt == 'exe'31end3233def to_executable_windows_x64(framework, code, fmt = 'exe', opts = {})34return to_win64pe(framework, code, opts) if fmt == 'exe'35return to_win64pe(framework, code, opts) if fmt == 'exe-small'36return to_win64pe_service(framework, code, opts) if fmt == 'exe-service'37return to_win64pe_dll(framework, code, opts) if fmt == 'dll'38return to_win64pe_dccw_gdiplus_dll(framework, code, opts) if fmt == 'dll-dccw-gdiplus'39end4041def to_executable_windows_x86(framework, code, fmt = 'exe', opts = {})42return to_win32pe(framework, code, opts) if fmt == 'exe'43return to_win32pe_service(framework, code, opts) if fmt == 'exe-servsice'44return to_win32pe_dll(framework, code, opts) if fmt == 'dll'45return to_winpe_only(framework, code, opts, ARCH_X86) if fmt == 'exe-only'46return to_win32pe_old(framework, code, opts) if fmt == 'exe-small'47end48end4950class << self51include ClassMethods52end53end545556