Module: Ronin::Payloads::HasPayload

Included in:
Exploits::Exploit, Ronin::Payloads::Helpers::Chained, Payload
Defined in:
lib/ronin/payloads/has_payload.rb

Overview

The HasPayload module allows another class to be coupled with a Payload. The module provides methods for loading payloads from the database or from a file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &block) ⇒ Object (protected)

Relays missing method calls to the payload, if the payload inherits from Payload.

Since:

  • 0.3.0


135
136
137
138
139
140
141
# File 'lib/ronin/payloads/has_payload.rb', line 135

def method_missing(name,*arguments,&block)
  if (@payload.kind_of?(Payload) && @payload.respond_to?(name))
    return @payload.send(name,*arguments,&block)
  end

  super(name,*arguments,&block)
end

Instance Attribute Details

#payloadObject

The payload being used


34
35
36
# File 'lib/ronin/payloads/has_payload.rb', line 34

def payload
  @payload
end

Instance Method Details

#default_payloadPayload

The default payload to use, if no other payload has been selected.

Since:

  • 1.0.0


58
59
# File 'lib/ronin/payloads/has_payload.rb', line 58

def default_payload
end

#initialize(attributes = {}) ⇒ Object

Initializes the default payload.

Since:

  • 1.0.0


44
45
46
47
48
# File 'lib/ronin/payloads/has_payload.rb', line 44

def initialize(attributes={})
  super(attributes)

  self.payload = default_payload
end

#payload_classClass

Specifies that the Payload class will be used when searching for compatible payloads.

Since:

  • 0.3.0


70
71
72
# File 'lib/ronin/payloads/has_payload.rb', line 70

def payload_class
  Ronin::Payloads::Payload
end

#respond_to?(name, include_private = false) ⇒ Boolean

Determines if the object responds to a method defined in the payload.

Since:

  • 1.0.0


120
121
122
123
124
125
# File 'lib/ronin/payloads/has_payload.rb', line 120

def respond_to?(name,include_private=false)
  super(name,include_private) || (
    @payload.kind_of?(Payload) &&
    @payload.respond_to?(name,include_private)
  )
end

#use_payload!(query = {}) ⇒ Payload?

Selects and uses a new payload.

Since:

  • 0.3.0


85
86
87
# File 'lib/ronin/payloads/has_payload.rb', line 85

def use_payload!(query={})
  self.payload = payload_class.load_first(query)
end

#use_payload_from!(path) ⇒ Payload?

Loads and uses a new payload from a given path.

Since:

  • 0.3.0


100
101
102
# File 'lib/ronin/payloads/has_payload.rb', line 100

def use_payload_from!(path)
  self.payload = payload_class.load_from(path)
end