Module: Msf::Payload::Adapter

Defined in:
lib/msf/core/payload/adapter.rb

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)

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

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

#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.


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/msf/core/payload/adapter.rb', line 31

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


20
21
22
# File 'lib/msf/core/payload/adapter.rb', line 20

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

#merge_info_platform(info, opt) ⇒ Object


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

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

#payload_typeObject


16
17
18
# File 'lib/msf/core/payload/adapter.rb', line 16

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