ronin-exploits 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/COPYING.txt +339 -0
  2. data/History.txt +18 -0
  3. data/Manifest.txt +42 -0
  4. data/README.txt +69 -0
  5. data/Rakefile +15 -0
  6. data/TODO.txt +25 -0
  7. data/lib/ronin/exploits.rb +39 -0
  8. data/lib/ronin/exploits/binary_exploit.rb +133 -0
  9. data/lib/ronin/exploits/buffer_overflow.rb +76 -0
  10. data/lib/ronin/exploits/buffer_overflow_target.rb +46 -0
  11. data/lib/ronin/exploits/exceptions.rb +25 -0
  12. data/lib/ronin/exploits/exceptions/exploit_not_built.rb +29 -0
  13. data/lib/ronin/exploits/exceptions/restricted_char.rb +29 -0
  14. data/lib/ronin/exploits/exploit.rb +263 -0
  15. data/lib/ronin/exploits/exploit_author.rb +34 -0
  16. data/lib/ronin/exploits/exploit_target.rb +48 -0
  17. data/lib/ronin/exploits/exploitable.rb +77 -0
  18. data/lib/ronin/exploits/format_string.rb +84 -0
  19. data/lib/ronin/exploits/format_string_target.rb +43 -0
  20. data/lib/ronin/exploits/impact.rb +46 -0
  21. data/lib/ronin/exploits/requirement.rb +46 -0
  22. data/lib/ronin/exploits/version.rb +29 -0
  23. data/lib/ronin/exploits/web_exploit.rb +77 -0
  24. data/lib/ronin/models.rb +38 -0
  25. data/lib/ronin/payloads.rb +33 -0
  26. data/lib/ronin/payloads/ability.rb +46 -0
  27. data/lib/ronin/payloads/binary_payload.rb +40 -0
  28. data/lib/ronin/payloads/payload.rb +203 -0
  29. data/lib/ronin/payloads/payload_author.rb +34 -0
  30. data/lib/ronin/payloads/shellcode.rb +34 -0
  31. data/lib/ronin/payloads/web_payload.rb +34 -0
  32. data/lib/ronin/translators/xor.rb +96 -0
  33. data/lib/ronin/vuln/behavior.rb +92 -0
  34. data/spec/exploits/exploit_spec.rb +80 -0
  35. data/spec/exploits/exploitable_spec.rb +21 -0
  36. data/spec/exploits/web_exploit_spec.rb +29 -0
  37. data/spec/exploits_spec.rb +9 -0
  38. data/spec/payloads/payload_spec.rb +60 -0
  39. data/spec/spec_helper.rb +11 -0
  40. data/spec/translators/xor_spec.rb +26 -0
  41. data/spec/vuln/behavior_spec.rb +15 -0
  42. data/tasks/spec.rb +9 -0
  43. metadata +119 -0
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './tasks/spec.rb'
6
+ require './lib/ronin/exploits/version.rb'
7
+
8
+ Hoe.new('ronin-exploits', Ronin::Exploits::VERSION) do |p|
9
+ p.rubyforge_name = 'ronin'
10
+ p.developer('Postmodern', 'postmodern.mod3@gmail.com')
11
+ p.remote_rdoc_dir = 'docs/ronin-exploits'
12
+ p.extra_deps = [['ronin', '>=0.1.3']]
13
+ end
14
+
15
+ # vim: syntax=Ruby
data/TODO.txt ADDED
@@ -0,0 +1,25 @@
1
+ == TODO:
2
+
3
+ === Ronin Exploits 0.1.0:
4
+
5
+ * Complete exploit/payload taxonomy code.
6
+ * Add dm-scope methods for finding exploits based on their taxonomy
7
+ relations.
8
+
9
+ === Ronin Exploits 0.1.1:
10
+
11
+ * Add more dm-scope methods for finding exploits and payloads based:
12
+ * Target attributes:
13
+ * Arch (name).
14
+ * Platform (os, version).
15
+ * Authors
16
+ * Spec exploit/payload relations and dm-scope methods.
17
+ * Add methods for chaining exploits.
18
+
19
+ === Ronin Exploits 0.1.2:
20
+
21
+ * Design a basic Vulnerability Scanner class:
22
+ * Scan networks of hosts.
23
+ * Scan web-sites.
24
+ * Custom tests.
25
+
@@ -0,0 +1,39 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/requirement'
25
+ require 'ronin/exploits/impact'
26
+ require 'ronin/exploits/exploit_author'
27
+ require 'ronin/exploits/exploit_target'
28
+ require 'ronin/exploits/exploit'
29
+ require 'ronin/exploits/binary_exploit'
30
+ require 'ronin/exploits/buffer_overflow_target'
31
+ require 'ronin/exploits/buffer_overflow'
32
+ require 'ronin/exploits/format_string_target'
33
+ require 'ronin/exploits/format_string'
34
+
35
+ require 'reverse_require'
36
+
37
+ module Ronin
38
+ require_for 'ronin', 'ronin/exploits'
39
+ end
@@ -0,0 +1,133 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/exceptions/exploit_not_built'
25
+ require 'ronin/exploits/exceptions/restricted_char'
26
+ require 'ronin/exploits/exploit_target'
27
+ require 'ronin/exploits/exploit'
28
+ require 'ronin/chars/char_set'
29
+ require 'ronin/formatting/binary'
30
+
31
+ module Ronin
32
+ module Exploits
33
+ class BinaryExploit < Exploit
34
+
35
+ objectify :ronin_binary_exploit
36
+
37
+ # Targets of the exploit
38
+ has n, :targets, :class_name => 'ExploitTarget'
39
+
40
+ # Target index to use
41
+ parameter :target_index,
42
+ :value => 0,
43
+ :description => 'default target index'
44
+
45
+ # Custom target to use
46
+ parameter :custom_target, :description => 'custom target'
47
+
48
+ # String to pad extra space with
49
+ parameter :pad, :value => 'A', :description => 'padding string'
50
+
51
+ # Restricted characters that may not occurr in the built exploit
52
+ attr_accessor :restricted
53
+
54
+ # The built exploit
55
+ attr_accessor :exploit
56
+
57
+ #
58
+ # Creates a new BinaryExploit object with the given _attributes_.
59
+ #
60
+ def initialize(attributes={})
61
+ super(attributes)
62
+
63
+ @restricted = Chars::CharSet.new(attributes[:restricted] || [])
64
+ end
65
+
66
+ #
67
+ # Adds an ExploitTarget with the given _attributes_. If a _block_ is
68
+ # given, it will be passed the ExploitTarget.
69
+ #
70
+ def target(attributes={},&block)
71
+ @targets << ExploitTarget.first_or_create(attributes,&block)
72
+ end
73
+
74
+ #
75
+ # Returns the selected target.
76
+ #
77
+ def selected_target
78
+ (@custom_target || @targets[@target_index])
79
+ end
80
+
81
+ #
82
+ # Creates a padded buffer of the specified _length_ using the
83
+ # specified _padding_ data.
84
+ #
85
+ def pad_buffer(padding,length)
86
+ padding = padding.to_s
87
+
88
+ buffer = (padding * (length / padding.length))
89
+ pad_remaining = (length % padding.length)
90
+
91
+ unless pad_remaining==0
92
+ buffer += padding[0,pad_remaining]
93
+ end
94
+
95
+ return buffer
96
+ end
97
+
98
+ #
99
+ # Adds the given _chars_ to the restricted list of characters.
100
+ #
101
+ # restrict 0x00, "\n"
102
+ # # => #<Ronin::Chars::CharSet: {"\0", "\n"}>
103
+ #
104
+ def restrict(*chars)
105
+ @restricted += pattern
106
+ end
107
+
108
+ def build
109
+ @exploit = ''
110
+ return super
111
+ end
112
+
113
+ #
114
+ # Verifies that the exploit is built and does not contain any
115
+ # restricted characters.
116
+ #
117
+ def verify
118
+ unless @exploit
119
+ raise(ExploitNotBuilt,"cannot verify an unbuilt exploit",caller)
120
+ end
121
+
122
+ @restricted.each do |char|
123
+ if @exploit.include?(char)
124
+ raise(RestrictedChar,"Restricted character '#{char}' was found in the built exploit",caller)
125
+ end
126
+ end
127
+
128
+ return super
129
+ end
130
+
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,76 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/buffer_overflow_target'
25
+ require 'ronin/exploits/binary_exploit'
26
+
27
+ module Ronin
28
+ module Exploits
29
+ class BufferOverflow < BinaryExploit
30
+
31
+ objectify :ronin_buffer_overflow
32
+
33
+ # Targets of the buffer overflow
34
+ has n, :targets, :class_name => 'BufferOverflowTarget'
35
+
36
+ #
37
+ # Adds a new BufferOverflowTarget with the given _attributes_. If a
38
+ # _block_ is given, it will be passed the BufferOverflowTarget object.
39
+ #
40
+ def target(options={},&block)
41
+ @targets << BufferOverflowTarget.new(options,&block)
42
+ end
43
+
44
+ #
45
+ # Builds the exploit buffer with the given _options_.
46
+ #
47
+ def build_buffer(options={})
48
+ target = (options[:target] || selected_target)
49
+ payload = (options[:payload] || @payload).to_s
50
+
51
+ unless payload.length<=target.buffer_length
52
+ raise(PayloadSize,"the specified payload is too large for the target's buffer length",caller)
53
+ end
54
+
55
+ buffer = pad_buffer(@pad,(target.buffer_length-payload.length))+payload
56
+
57
+ ip_packed = target.ip.pack(target.arch)
58
+ unless target.bp==0
59
+ buffer += (target.bp.pack(target.arch)+ip_packed)*target.return_length
60
+ else
61
+ buffer += ip_packed*(target.return_length*2)
62
+ end
63
+
64
+ return buffer
65
+ end
66
+
67
+ #
68
+ # Default builder method which simply calls build_buffer.
69
+ #
70
+ def builder
71
+ @package = build_buffer
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/exploit_target'
25
+
26
+ module Ronin
27
+ module Exploits
28
+ class BufferOverflowTarget < ExploitTarget
29
+
30
+ # Buffer length
31
+ property :buffer_length, Integer, :default => 0
32
+
33
+ # Return length
34
+ property :return_length, Integer, :default => 1
35
+
36
+ # Instruction Pointer
37
+ property :ip, Integer, :default => 0x0
38
+
39
+ # Stack base pointer
40
+ property :bp, Integer
41
+
42
+ belongs_to :buffer_overflow
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/exceptions/exploit_not_built'
25
+ require 'ronin/exploits/exceptions/restricted_char'
@@ -0,0 +1,29 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ module Ronin
25
+ module Exploits
26
+ class ExploitNotBuilt < RuntimeError
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ module Ronin
25
+ module Exploits
26
+ class RestrictedChar < RuntimeError
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,263 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/exploits/requirement'
25
+ require 'ronin/exploits/impact'
26
+ require 'ronin/exploits/exploit_author'
27
+ require 'ronin/vulnerability/behavior'
28
+ require 'ronin/objectify'
29
+ require 'ronin/has_license'
30
+
31
+ module Ronin
32
+ module Exploits
33
+ class Exploit
34
+
35
+ include Objectify
36
+ include HasLicense
37
+
38
+ objectify :ronin_exploit
39
+
40
+ # Primary key of the exploit
41
+ property :id, Serial
42
+
43
+ # Name of the exploit
44
+ property :name, String, :index => true
45
+
46
+ # Version of the exploit
47
+ property :version, String, :default => '0.1', :index => true
48
+
49
+ # Description of the exploit
50
+ property :description, Text
51
+
52
+ # Author(s) of the exploit
53
+ has n, :authors, :class_name => 'ExploitAuthor'
54
+
55
+ # The requirements of the exploit
56
+ has n, :requirements
57
+
58
+ # Impact of the exploit
59
+ has n, :impact, :class_name => 'Impact'
60
+
61
+ # Validations
62
+ validates_present :name
63
+ validates_is_unique :version, :scope => [:name]
64
+
65
+ # Exploit payload
66
+ attr_accessor :payload
67
+
68
+ #
69
+ # Creates a new Exploit object with the given _attributes_.
70
+ #
71
+ def initialize(attributes={},&block)
72
+ super(attributes)
73
+
74
+ @built = false
75
+
76
+ instance_eval(&block) if block
77
+ end
78
+
79
+ #
80
+ # Finds all exploits with names like the specified _name_.
81
+ #
82
+ def self.named(name)
83
+ self.all(:name.like => "%#{name}%")
84
+ end
85
+
86
+ #
87
+ # Finds all exploits with descriptions like the specified
88
+ # _description_.
89
+ #
90
+ def self.describing(description)
91
+ self.all(:description.like => "%#{description}%")
92
+ end
93
+
94
+ #
95
+ # Finds the exploit with the most recent vesion.
96
+ #
97
+ def self.latest
98
+ self.first(:order => [:version.desc])
99
+ end
100
+
101
+ #
102
+ # Adds an ExploitAuthor with the given _attributes_ to the exploit.
103
+ # If a _block_ is given, it will be passed the ExploitAuthro object.
104
+ #
105
+ def author(attributes={},&block)
106
+ self.authors << ExploitAuthor.first_or_create(attributes,&block)
107
+ end
108
+
109
+ #
110
+ # Adds a new Requirement for the Ability with the specified
111
+ # _behavior_.
112
+ #
113
+ def requires(behavior)
114
+ self.requirements << Requirement.new(
115
+ :behavior => behavior,
116
+ :exploit => self
117
+ )
118
+
119
+ return self
120
+ end
121
+
122
+ #
123
+ # Adds a new Impact granting the specified _behavior_.
124
+ #
125
+ def allows(behavior)
126
+ self.impact << Impact.new(
127
+ :behavior => behavior,
128
+ :exploit => self
129
+ )
130
+
131
+ return self
132
+ end
133
+
134
+ #
135
+ # Switches to the _new_payload_ then calls the specified _block_.
136
+ # After the _block_ has been called the payload will be reverted to
137
+ # it's previous value.
138
+ #
139
+ def switch_payload(new_payload,&block)
140
+ old_payload = @payload
141
+ @payload = new_payload
142
+
143
+ block.call(self)
144
+
145
+ @payload = old_payload
146
+ return self
147
+ end
148
+
149
+ #
150
+ # Default vulnerability test method. Returning +true+ symbolizes
151
+ # that the target of the exploit is vulnerable. Returning +nil+
152
+ # symbolizes that the exploit cannot determine if the target is
153
+ # vulnerable or not. Returning +false+ symbolizes that the target
154
+ # of the exploit is definitely not vulnerable. Returns +nil+ by
155
+ # default.
156
+ #
157
+ def vulnerable?
158
+ nil
159
+ end
160
+
161
+ #
162
+ # Default builder method.
163
+ #
164
+ def builder
165
+ end
166
+
167
+ #
168
+ # Returns +true+ if the exploit is built, returns +false+ otherwise.
169
+ #
170
+ def built?
171
+ @built == true
172
+ end
173
+
174
+ #
175
+ # Builds the exploit with the given _options_ and checks for
176
+ # restricted characters or patterns. If any restricted characters or
177
+ # patterns are found in the built exploit, a RestrictedText exception
178
+ # will be raised.
179
+ #
180
+ def build(options={})
181
+ self.params = options
182
+
183
+ @payload = (options[:payload] || @payload)
184
+
185
+ if (@payload && @payload.include?(Parameters))
186
+ @payload.params = options
187
+ end
188
+
189
+ @built = false
190
+
191
+ result = builder
192
+
193
+ @built = true
194
+ return result
195
+ end
196
+
197
+ #
198
+ # Default exploit verifier method.
199
+ #
200
+ def verifier
201
+ end
202
+
203
+ #
204
+ # Verifies the exploit is properly configured, built and ready to be
205
+ # deployed. An exception should be raised if the exploit is not ready
206
+ # to be deployed, returns +true+ otherwise.
207
+ #
208
+ def verify
209
+ unless built?
210
+ raise(ExploitNotBuilt,"cannot deploy an unbuilt exploit",caller)
211
+ end
212
+
213
+ verifier
214
+ return true
215
+ end
216
+
217
+ #
218
+ # Default exploit deployer method, passes the exploit object to the
219
+ # given _block_ by default.
220
+ #
221
+ def deployer(&block)
222
+ block.call(self) if block
223
+ end
224
+
225
+ #
226
+ # Deploys the exploit. If a _block_ is given and the payload used is
227
+ # a kind of Payload, then the payloads deploy method will be passed
228
+ # the given _block_. If the payload used is not a kind of Payload and
229
+ # a _block_ is given, the _block_ will be passed to the exploits
230
+ # deployer method. If the exploit has not been previously built, an
231
+ # ExploitNotBuilt exception will be raised.
232
+ #
233
+ def deploy(&block)
234
+ verify
235
+
236
+ if (@payload && @payload.kind_of?(Payloads::Payload))
237
+ deployer()
238
+
239
+ return @payload.deploy(&block)
240
+ else
241
+ return deployer(&block)
242
+ end
243
+ end
244
+
245
+ #
246
+ # Builds, deploys and then cleans the exploit with the given _options_.
247
+ #
248
+ def exploit(options={},&block)
249
+ build(options)
250
+
251
+ return deploy(&block)
252
+ end
253
+
254
+ #
255
+ # Returns the built exploit.
256
+ #
257
+ def to_s
258
+ "#{self.name} #{self.version}"
259
+ end
260
+
261
+ end
262
+ end
263
+ end