Module: Msf::Util::EXE::Windows::Aarch64::ClassMethods

Included in:
Msf::Util::EXE::Windows::Aarch64
Defined in:
lib/msf/util/exe/windows/aarch64.rb

Instance Method Summary collapse

Instance Method Details

#to_winaarch64pe(framework, code, opts = {}) ⇒ String

Construct a Windows AArch64 PE executable with the given shellcode. to_winaarch64pe

Parameters:

  • framework (Msf::Framework)

    The Metasploit framework instance.

  • code (String)

    The shellcode to embed in the executable.

  • opts (Hash) (defaults to: {})

    Additional options.

Returns:

  • (String)

    The constructed PE executable as a binary string.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/msf/util/exe/windows/aarch64.rb', line 18

def to_winaarch64pe(framework, code, opts = {})
  # Use the standard template if not specified by the user.
  # This helper finds the full path and stores it in opts[:template].
  set_template_default(opts, 'template_aarch64_windows.exe')

  # Read the template directly from the path now stored in the options.
  pe = File.read(opts[:template], mode: 'rb')

  # Find the tag and inject the payload
  bo = find_payload_tag(pe, 'Invalid Windows AArch64 template: missing "PAYLOAD:" tag')
  pe[bo, code.length] = code.dup
  pe
end