Module: Msf::Payload::Adapter

Included in:
Fetch::HTTP, Fetch::Https, Fetch::SMB, Fetch::TFTP
Defined in:
lib/msf/core/payload/adapter.rb

Defined Under Namespace

Modules: Fetch

Constant Summary collapse

CachedSize =

since an adapter wraps a single or stager payload, the cached size would be different for each, this means the cached size can’t be a single value and must be set to dynamic

:dynamic

Instance Method Summary collapse

Instance Method Details

#compatible?(mod) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
# File 'lib/msf/core/payload/adapter.rb', line 15

def compatible?(mod)
  if mod.type == Msf::MODULE_PAYLOAD
    return false if Set.new([module_info['AdaptedArch']]) != mod.arch.to_set

    return false if (Msf::Module::PlatformList.new(module_info['AdaptedPlatform']) & mod.platform).empty?
  end

  super
end

#initialize(info = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/msf/core/payload/adapter.rb', line 6

def initialize(info={})
  super

  if self.is_a?(Msf::Payload::Stager)
    self.stage_arch = Rex::Transformer.transform(module_info['AdaptedArch'], Array, [ String ], 'AdaptedArch')
    self.stage_platform = Msf::Module::PlatformList.transform(module_info['AdaptedPlatform'])
  end
end

#merge_info_adapted(key, info, opt) ⇒ Object

Due to how payloads are made by combining all the modules, this is necessary to ensure that the adapted information isn’t placed into the final object. The current implementation requires that AdaptedArch/AdaptedPlatform are single entries and not arrays of entries like the normal Arch/Platform info keys are.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/msf/core/payload/adapter.rb', line 40

def merge_info_adapted(key, info, opt)
  if info[key] && !info[key].kind_of?(Array)
    info[key] = [ info[key] ]
  elsif !info[key]
    info[key] = []
  end

  if opt.kind_of?(Array)
    opt.each do |opt_val|
      next if info["Adapted#{key}"] == opt_val
      next if info[key].include?(opt_val)

      info[key] << opt_val
    end
  elsif opt != info["Adapted#{key}"] && !info[key].include?(opt)
    info[key] << opt
  end
end

#merge_info_arch(info, opt) ⇒ Object



29
30
31
# File 'lib/msf/core/payload/adapter.rb', line 29

def merge_info_arch(info, opt)
  merge_info_adapted('Arch', info, opt)
end

#merge_info_platform(info, opt) ⇒ Object



33
34
35
# File 'lib/msf/core/payload/adapter.rb', line 33

def merge_info_platform(info, opt)
  merge_info_adapted('Platform', info, opt)
end

#payload_typeObject



25
26
27
# File 'lib/msf/core/payload/adapter.rb', line 25

def payload_type
  return Msf::Payload::Type::Adapter
end