Module: Msf::Util::EXE::Windows::X64::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

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

to_win64pe

Parameters:

  • framework (Msf::Framework)

    The framework of you want to use

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

Returns:

  • (String)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/msf/util/exe/windows/x64.rb', line 18

def to_win64pe(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_x64_windows.exe')

  # Try to inject code into executable by adding a section without affecting executable behavior
  if opts[:inject]
    injector = Msf::Exe::SegmentInjector.new({
       :payload  => code,
       :template => opts[:template],
       :arch     => :x64,
       :secname  => opts[:secname]
    })
    return injector.generate_pe
  end

  # Append a new section instead
  appender = Msf::Exe::SegmentAppender.new({
    :payload  => code,
    :template => opts[:template],
    :arch     => :x64,
    :secname	=> opts[:secname]
  })
  return appender.generate_pe
end

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

to_win64pe_dccw_gdiplus_dll

Parameters:

  • framework (Msf::Framework)

    The framework of you want to use

  • code (String)
  • opts (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

Returns:

  • (String)


123
124
125
126
# File 'lib/msf/util/exe/windows/x64.rb', line 123

def to_win64pe_dccw_gdiplus_dll(framework, code, opts = {})
  set_template_default_winpe_dll(opts, ARCH_X64, code.size, flavor: 'dccw_gdiplus')
  to_win64pe_dll(framework, code, opts)
end

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

to_win64pe_dll

Parameters:

  • framework (Msf::Framework)

    The framework of you want to use

  • code (String)
  • opts (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

Returns:

  • (String)


101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/msf/util/exe/windows/x64.rb', line 101

def to_win64pe_dll(framework, code, opts = {})
  flavor = opts.fetch(:mixed_mode, false) ? 'mixed_mode' : nil
  set_template_default_winpe_dll(opts, ARCH_X64, code.size, flavor: flavor)

  opts[:exe_type] = :dll

  if opts[:inject]
    raise RuntimeError, 'Template injection unsupported for x64 DLLs'
  else
    exe_sub_method(code,opts)
  end
end

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

to_win64pe_service

Parameters:

  • framework (Msf::Framework)

    The framework of you want to use

  • code (String)
  • opts (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

Returns:

  • (String)


85
86
87
88
89
90
# File 'lib/msf/util/exe/windows/x64.rb', line 85

def to_win64pe_service(framework, code, opts = {})
  # Allow the user to specify their own service EXE template
  set_template_default(opts, "template_x64_windows_svc.exe")
  opts[:exe_type] = :service_exe
  exe_sub_method(code,opts)
end