Module: Ronin::Exploits::Mixins::HasPayload
- Included in:
- CommandInjection, RFI, SQLI, WebVuln
- Defined in:
- lib/ronin/exploits/mixins/has_payload.rb
Overview
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#payload ⇒ Ronin::Payloads::Payload, ...
The payload the exploit can use.
Class Method Summary collapse
-
.included(exploit) ⇒ Object
private
Adds ClassMethods to the exploit.
Instance Method Summary collapse
-
#initialize(payload: nil, **kwargs) ⇒ Object
Initializes the exploit and sets the #payload.
-
#perform_build ⇒ Object
Calls the payload's
perform_build
method first before the exploit is built. -
#perform_cleanup ⇒ Object
Calls the payload's
perform_cleanup
method first after the exploit is cleaned up. -
#perform_launch ⇒ Object
Overrides the payload's
perform_prelaunch
method, then calls the exploit's perform_launch method, and finally calls the payload'sperform_postlaunch
method. -
#perform_validate ⇒ Object
Validates #payload and the exploit.
Instance Attribute Details
#payload ⇒ Ronin::Payloads::Payload, ...
The payload the exploit can use.
90 91 92 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 90 def payload @payload end |
Class Method Details
.included(exploit) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds ClassMethods to the exploit.
56 57 58 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 56 def self.included(exploit) exploit.extend ClassMethods end |
Instance Method Details
#initialize(payload: nil, **kwargs) ⇒ Object
Initializes the exploit and sets the #payload.
98 99 100 101 102 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 98 def initialize(payload: nil, **kwargs) super(**kwargs) self.payload = payload end |
#perform_build ⇒ Object
Calls the payload's perform_build
method first before the exploit
is built.
151 152 153 154 155 156 157 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 151 def perform_build if @payload.kind_of?(Ronin::Payloads::Payload) @payload.perform_build end super end |
#perform_cleanup ⇒ Object
Calls the payload's perform_cleanup
method first after the exploit
is cleaned up.
193 194 195 196 197 198 199 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 193 def perform_cleanup super if @payload.kind_of?(Ronin::Payloads::Payload) @payload.perform_cleanup end end |
#perform_launch ⇒ Object
If any exception is raised by the exploit's launch
method, then
the payload's perform_cleanup
method is called and the exception
is re-raised.
Overrides the payload's perform_prelaunch
method, then calls the
exploit's perform_launch method, and finally
calls the payload's perform_postlaunch
method.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 169 def perform_launch if @payload.kind_of?(Ronin::Payloads::Payload) @payload.perform_prelaunch end begin super() if @payload.kind_of?(Ronin::Payloads::Payload) @payload.perform_postlaunch end rescue => error if @payload.kind_of?(Ronin::Payloads::Payload) @payload.perform_cleanup end raise(error) end end |
#perform_validate ⇒ Object
Validates #payload and the exploit.
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 135 def perform_validate unless @payload raise(MissingPayload,"exploit requires a payload") end if @payload.kind_of?(Ronin::Core::Params::Mixin) @payload.validate_params end super end |