Class: Msf::Exe::SegmentHijacker

Inherits:
SegmentAppender show all
Defined in:
lib/msf/core/exe/segment_hijacker.rb

Overview

Appends a payload section and redirects the PE entrypoint to it.

Constant Summary

Constants inherited from SegmentAppender

Msf::Exe::SegmentAppender::DEFAULT_SECTION_CHARACTERISTICS, Msf::Exe::SegmentAppender::MAX_PE_SECTION_NAME_LENGTH, Msf::Exe::SegmentAppender::MAX_SECTION_NAME_WITHOUT_DOT_LENGTH

Instance Attribute Summary

Attributes inherited from SegmentAppender

#arch, #payload, #section_characteristics, #section_name, #template

Instance Method Summary collapse

Methods inherited from SegmentAppender

#append_section, #build_section_name, #copy_pe, #initialize, #processor, #random_section_name

Constructor Details

This class inherits a constructor from Msf::Exe::SegmentAppender

Instance Method Details

#generate_peObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/msf/core/exe/segment_hijacker.rb', line 8

def generate_pe
  pe_orig = Metasm::PE.decode_file(template)
  pe = copy_pe(pe_orig)

  append_section(pe)

  pe.optheader.entrypoint = 'new_entrypoint'
  pe.cpu = pe_orig.cpu

  pe.encode_string
end