Module: Msf::Payload::Generic

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

Overview

The generic payloads are used to define a generalized payload type that is both architecture and platform independent. Under the hood, generic payloads seek out the correct payload for the appropriate architecture and platform that is being targeted.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#explicit_archObject

Accessor that makes it possible to define an explicit architecture. This is used for things like payload regeneration.


173
174
175
# File 'lib/msf/core/payload/generic.rb', line 173

def explicit_arch
  @explicit_arch
end

#explicit_platformObject

Accessor that makes it possible to define an explicit platform. This is used for things like payload regeneration.


168
169
170
# File 'lib/msf/core/payload/generic.rb', line 168

def explicit_platform
  @explicit_platform
end

Instance Method Details

#compatible_encodersObject


86
87
88
# File 'lib/msf/core/payload/generic.rb', line 86

def compatible_encoders
  redirect_to_actual(:compatible_encoders)
end

#compatible_nopsObject


90
91
92
# File 'lib/msf/core/payload/generic.rb', line 90

def compatible_nops
  redirect_to_actual(:compatible_nops)
end

#generateObject

Generate is different from other methods – it will try to re-detect the actual payload in case settings have changed. Other methods will use the cached version if possible.


57
58
59
60
61
# File 'lib/msf/core/payload/generic.rb', line 57

def generate
  reset

  redirect_to_actual(:generate)
end

#generate_stageObject


126
127
128
# File 'lib/msf/core/payload/generic.rb', line 126

def generate_stage
  redirect_to_actual(:generate_stage)
end

#handle_connection(*args) ⇒ Object


94
95
96
# File 'lib/msf/core/payload/generic.rb', line 94

def handle_connection(*args)
  redirect_to_actual(:handle_connection, *args)
end

#handle_connection_stage(*args) ⇒ Object


130
131
132
# File 'lib/msf/core/payload/generic.rb', line 130

def handle_connection_stage(*args)
  redirect_to_actual(:handle_connection_stage, *args)
end

#handle_intermediate_stage(*args) ⇒ Object


134
135
136
# File 'lib/msf/core/payload/generic.rb', line 134

def handle_intermediate_stage(*args)
  redirect_to_actual(:handle_intermediate_stage, *args)
end

#initialize(info = {}) ⇒ Object

Registers options that are common to all generic payloads, such as platform and arch.


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/msf/core/payload/generic.rb', line 20

def initialize(info = {})
  super(merge_info(info,
    'Arch'     => ARCH_ALL - [ARCH_TTY],
    'Platform' => ''))

  register_advanced_options(
    [
      OptString.new('PLATFORM',
        [
          false,
          "The platform that is being targeted",
          nil
        ]),
      OptString.new('ARCH',
        [
          false,
          "The architecture that is being targeted",
          nil
        ])
    ], Msf::Payload::Generic)
end

#offsetsObject


74
75
76
# File 'lib/msf/core/payload/generic.rb', line 74

def offsets
  redirect_to_actual(:offsets)
end

#on_session(*args) ⇒ Object


98
99
100
# File 'lib/msf/core/payload/generic.rb', line 98

def on_session(*args)
  redirect_to_actual(:on_session, *args)
end

#payloadObject

Overrides – we have to redirect all potential payload methods to the actual payload so that they get handled appropriately, cuz we're like a proxy and stuff. We can't use method_undefined because all of these methods are actually defined.


70
71
72
# File 'lib/msf/core/payload/generic.rb', line 70

def payload
  redirect_to_actual(:payload)
end

#redirect_to_actual(name, *args) ⇒ Object

First, find the underlying payload and then pass all methods onto it.


159
160
161
162
# File 'lib/msf/core/payload/generic.rb', line 159

def redirect_to_actual(name, *args)
  find_actual_payload
  actual_payload.send(name, *args)
end

#replace_var(*args) ⇒ Object


82
83
84
# File 'lib/msf/core/payload/generic.rb', line 82

def replace_var(*args)
  redirect_to_actual(:replace_var, *args)
end

#resetObject

Reset's the generic payload's internal state so that it can find a new actual payload.


46
47
48
49
50
# File 'lib/msf/core/payload/generic.rb', line 46

def reset
  self.explicit_arch     = nil
  self.explicit_platform = nil
  self.actual_payload    = nil
end

#stage_offsetsObject


110
111
112
# File 'lib/msf/core/payload/generic.rb', line 110

def stage_offsets
  redirect_to_actual(:stage_offsets)
end

#stage_over_connection?Boolean

Returns:

  • (Boolean)

122
123
124
# File 'lib/msf/core/payload/generic.rb', line 122

def stage_over_connection?
  redirect_to_actual(:stage_over_connection?)
end

#stage_payloadObject

Stager overrides


106
107
108
# File 'lib/msf/core/payload/generic.rb', line 106

def stage_payload
  redirect_to_actual(:stage_payload)
end

#stage_prefixObject


138
139
140
# File 'lib/msf/core/payload/generic.rb', line 138

def stage_prefix
  redirect_to_actual(:stage_prefix)
end

#stage_prefix=(*args) ⇒ Object


142
143
144
# File 'lib/msf/core/payload/generic.rb', line 142

def stage_prefix=(*args)
  redirect_to_actual(:stage_prefix=, *args)
end

#stager_offsetsObject


118
119
120
# File 'lib/msf/core/payload/generic.rb', line 118

def stager_offsets
  redirect_to_actual(:stager_offsets)
end

#stager_payloadObject


114
115
116
# File 'lib/msf/core/payload/generic.rb', line 114

def stager_payload
  redirect_to_actual(:stager_payload)
end

#substitute_vars(*args) ⇒ Object


78
79
80
# File 'lib/msf/core/payload/generic.rb', line 78

def substitute_vars(*args)
  redirect_to_actual(:substitute_vars, *args)
end

#user_input=(h) ⇒ Object


146
147
148
149
# File 'lib/msf/core/payload/generic.rb', line 146

def user_input=(h)
  @user_input = h
  redirect_to_actual(:user_input, h) if actual_payload
end

#user_output=(h) ⇒ Object


151
152
153
154
# File 'lib/msf/core/payload/generic.rb', line 151

def user_output=(h)
  @user_output = h
  redirect_to_actual(:user_output, h) if actual_payload
end