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.
91 92 93 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 91 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.
57 58 59 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 57 def self.included(exploit) exploit.extend ClassMethods end |
Instance Method Details
#initialize(payload: nil, **kwargs) ⇒ Object
Initializes the exploit and sets the #payload.
99 100 101 102 103 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 99 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.
155 156 157 158 159 160 161 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 155 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.
197 198 199 200 201 202 203 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 197 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.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 173 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.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ronin/exploits/mixins/has_payload.rb', line 139 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 |