Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/util/exe/windows/aarch64.rb
36043 views
1
module Msf::Util::EXE::Windows::Aarch64
2
include Msf::Util::EXE::Common
3
include Msf::Util::EXE::Windows::Common
4
5
def self.included(base)
6
base.extend(ClassMethods)
7
end
8
9
module ClassMethods
10
# Construct a Windows AArch64 PE executable with the given shellcode.
11
# to_winaarch64pe
12
#
13
# @param framework [Msf::Framework] The Metasploit framework instance.
14
# @param code [String] The shellcode to embed in the executable.
15
# @param opts [Hash] Additional options.
16
# @return [String] The constructed PE executable as a binary string.
17
18
def to_winaarch64pe(framework, code, opts = {})
19
# Use the standard template if not specified by the user.
20
# This helper finds the full path and stores it in opts[:template].
21
set_template_default(opts, 'template_aarch64_windows.exe')
22
23
# Read the template directly from the path now stored in the options.
24
pe = File.read(opts[:template], mode: 'rb')
25
26
# Find the tag and inject the payload
27
bo = find_payload_tag(pe, 'Invalid Windows AArch64 template: missing "PAYLOAD:" tag')
28
pe[bo, code.length] = code.dup
29
pe
30
end
31
end
32
33
class << self
34
include ClassMethods
35
end
36
end
37
38