ronin 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +95 -0
- data/Manifest.txt +55 -25
- data/README.txt +64 -52
- data/Rakefile +21 -14
- data/bin/ronin +1 -1
- data/bin/ronin-add +1 -1
- data/bin/ronin-console +1 -1
- data/bin/ronin-help +1 -1
- data/bin/ronin-install +1 -1
- data/bin/ronin-list +1 -1
- data/bin/ronin-remove +1 -1
- data/bin/ronin-uninstall +1 -1
- data/bin/ronin-update +1 -1
- data/lib/ronin.rb +2 -4
- data/lib/ronin/arch.rb +66 -21
- data/lib/ronin/author.rb +27 -18
- data/lib/ronin/cacheable.rb +63 -23
- data/lib/ronin/code/emittable.rb +1 -4
- data/lib/ronin/code/reference.rb +2 -5
- data/lib/ronin/code/symbol_table.rb +1 -4
- data/lib/ronin/code/token.rb +1 -4
- data/lib/ronin/config.rb +31 -10
- data/lib/ronin/database.rb +1 -4
- data/lib/ronin/database/database.rb +42 -23
- data/lib/ronin/database/exceptions.rb +1 -4
- data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
- data/lib/ronin/environment.rb +1 -5
- data/lib/ronin/extensions.rb +1 -5
- data/lib/ronin/extensions/array.rb +8 -6
- data/lib/ronin/extensions/file.rb +9 -4
- data/lib/ronin/extensions/ip_addr.rb +33 -13
- data/lib/ronin/extensions/kernel.rb +44 -9
- data/lib/ronin/extensions/meta.rb +1 -4
- data/lib/ronin/extensions/string.rb +8 -7
- data/lib/ronin/extensions/uri.rb +1 -4
- data/lib/ronin/extensions/uri/http.rb +1 -48
- data/lib/ronin/extensions/uri/query_params.rb +27 -8
- data/lib/ronin/formatting.rb +1 -4
- data/lib/ronin/formatting/binary.rb +1 -4
- data/lib/ronin/formatting/digest.rb +1 -4
- data/lib/ronin/formatting/extensions.rb +1 -4
- data/lib/ronin/formatting/extensions/binary.rb +1 -4
- data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
- data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
- data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
- data/lib/ronin/formatting/extensions/digest.rb +1 -4
- data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
- data/lib/ronin/formatting/extensions/http.rb +1 -4
- data/lib/ronin/formatting/extensions/http/string.rb +16 -9
- data/lib/ronin/formatting/extensions/text.rb +1 -4
- data/lib/ronin/formatting/extensions/text/array.rb +17 -7
- data/lib/ronin/formatting/extensions/text/string.rb +70 -27
- data/lib/ronin/formatting/http.rb +1 -4
- data/lib/ronin/formatting/text.rb +1 -4
- data/lib/ronin/license.rb +72 -65
- data/lib/ronin/model.rb +1 -4
- data/lib/ronin/model/has_description.rb +37 -8
- data/lib/ronin/model/has_license.rb +12 -8
- data/lib/ronin/model/has_name.rb +10 -7
- data/lib/ronin/model/has_version.rb +14 -4
- data/lib/ronin/model/model.rb +71 -14
- data/lib/ronin/network.rb +1 -4
- data/lib/ronin/network/esmtp.rb +1 -4
- data/lib/ronin/network/extensions.rb +1 -4
- data/lib/ronin/network/extensions/esmtp.rb +1 -4
- data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
- data/lib/ronin/network/extensions/http.rb +1 -4
- data/lib/ronin/network/extensions/http/net.rb +319 -531
- data/lib/ronin/network/extensions/imap.rb +1 -4
- data/lib/ronin/network/extensions/imap/net.rb +50 -23
- data/lib/ronin/network/extensions/pop3.rb +1 -4
- data/lib/ronin/network/extensions/pop3/net.rb +40 -17
- data/lib/ronin/network/extensions/smtp.rb +1 -4
- data/lib/ronin/network/extensions/smtp/net.rb +49 -21
- data/lib/ronin/network/extensions/tcp.rb +1 -4
- data/lib/ronin/network/extensions/tcp/net.rb +234 -31
- data/lib/ronin/network/extensions/telnet.rb +1 -4
- data/lib/ronin/network/extensions/telnet/net.rb +83 -51
- data/lib/ronin/network/extensions/udp.rb +1 -4
- data/lib/ronin/network/extensions/udp/net.rb +164 -27
- data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
- data/lib/ronin/network/helpers/esmtp.rb +129 -0
- data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
- data/lib/ronin/network/helpers/http.rb +444 -0
- data/lib/ronin/network/helpers/imap.rb +115 -0
- data/lib/ronin/network/helpers/pop3.rb +110 -0
- data/lib/ronin/network/helpers/smtp.rb +123 -0
- data/lib/ronin/network/helpers/tcp.rb +309 -0
- data/lib/ronin/network/helpers/telnet.rb +158 -0
- data/lib/ronin/network/helpers/udp.rb +197 -0
- data/lib/ronin/network/http.rb +3 -156
- data/lib/ronin/network/http/exceptions.rb +1 -4
- data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
- data/lib/ronin/network/http/http.rb +214 -0
- data/lib/ronin/network/http/proxy.rb +308 -0
- data/lib/ronin/network/imap.rb +7 -6
- data/lib/ronin/network/pop3.rb +7 -6
- data/lib/ronin/network/smtp.rb +1 -4
- data/lib/ronin/network/smtp/email.rb +34 -18
- data/lib/ronin/network/smtp/smtp.rb +19 -7
- data/lib/ronin/network/tcp.rb +1 -4
- data/lib/ronin/network/telnet.rb +25 -12
- data/lib/ronin/network/udp.rb +1 -4
- data/lib/ronin/os.rb +43 -21
- data/lib/ronin/path.rb +29 -9
- data/lib/ronin/platform.rb +1 -4
- data/lib/ronin/platform/exceptions.rb +1 -4
- data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
- data/lib/ronin/platform/extension.rb +195 -52
- data/lib/ronin/platform/extension_cache.rb +60 -24
- data/lib/ronin/platform/maintainer.rb +15 -8
- data/lib/ronin/platform/object_cache.rb +29 -8
- data/lib/ronin/platform/overlay.rb +82 -26
- data/lib/ronin/platform/overlay_cache.rb +179 -56
- data/lib/ronin/platform/platform.rb +154 -58
- data/lib/ronin/platform/ronin.rb +38 -11
- data/lib/ronin/product.rb +17 -17
- data/lib/ronin/rpc.rb +1 -4
- data/lib/ronin/rpc/call.rb +1 -4
- data/lib/ronin/rpc/client.rb +1 -4
- data/lib/ronin/rpc/console.rb +1 -4
- data/lib/ronin/rpc/exceptions.rb +1 -4
- data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
- data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
- data/lib/ronin/rpc/response.rb +1 -4
- data/lib/ronin/rpc/service.rb +1 -4
- data/lib/ronin/rpc/shell.rb +1 -4
- data/lib/ronin/scanners.rb +1 -4
- data/lib/ronin/scanners/exceptions.rb +1 -4
- data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
- data/lib/ronin/scanners/scanner.rb +82 -26
- data/lib/ronin/static.rb +1 -4
- data/lib/ronin/static/finders.rb +1 -4
- data/lib/ronin/static/static.rb +16 -7
- data/lib/ronin/templates.rb +2 -4
- data/lib/ronin/templates/erb.rb +24 -10
- data/lib/ronin/templates/template.rb +130 -0
- data/lib/ronin/ui.rb +2 -6
- data/lib/ronin/ui/command_line.rb +1 -4
- data/lib/ronin/ui/command_line/command.rb +137 -68
- data/lib/ronin/ui/command_line/command_line.rb +52 -29
- data/lib/ronin/ui/command_line/commands/add.rb +39 -67
- data/lib/ronin/ui/command_line/commands/console.rb +23 -27
- data/lib/ronin/ui/command_line/commands/help.rb +10 -29
- data/lib/ronin/ui/command_line/commands/install.rb +31 -56
- data/lib/ronin/ui/command_line/commands/list.rb +34 -52
- data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
- data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
- data/lib/ronin/ui/command_line/commands/update.rb +15 -35
- data/lib/ronin/ui/command_line/exceptions.rb +1 -4
- data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
- data/lib/ronin/ui/console.rb +54 -23
- data/lib/ronin/ui/hexdump.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
- data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
- data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
- data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
- data/lib/ronin/ui/output/handler.rb +121 -0
- data/lib/ronin/ui/output/helpers.rb +110 -0
- data/lib/ronin/ui/output/output.rb +144 -0
- data/lib/ronin/ui/shell.rb +38 -12
- data/lib/ronin/version.rb +2 -5
- data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
- data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
- data/lib/ronin/yard/handlers/ruby.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
- data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
- data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
- data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
- data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
- data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
- data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
- data/spec/author_spec.rb +3 -3
- data/spec/extensions/classes/some_class.rb +2 -0
- data/spec/extensions/kernel_spec.rb +17 -0
- data/spec/extensions/uri/http_spec.rb +0 -31
- data/spec/formatting/binary/integer_spec.rb +4 -0
- data/spec/formatting/text/string_spec.rb +96 -0
- data/spec/license_spec.rb +6 -6
- data/spec/model/classes/basic_model.rb +13 -0
- data/spec/model/classes/custom_model.rb +17 -0
- data/spec/model/classes/described_model.rb +10 -0
- data/spec/model/has_description_spec.rb +42 -0
- data/spec/model/has_license_spec.rb +18 -4
- data/spec/model/model_spec.rb +68 -0
- data/spec/network/helpers/classes/test_helper.rb +11 -0
- data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
- data/spec/network/helpers/helper_spec.rb +25 -0
- data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
- data/spec/network/http/proxy_spec.rb +116 -0
- data/spec/os_spec.rb +4 -4
- data/spec/platform/extension_cache_spec.rb +14 -0
- data/spec/platform/extension_spec.rb +11 -0
- data/spec/platform/platform_spec.rb +8 -0
- data/spec/product_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -1
- data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
- data/spec/templates/classes/example_template.rb +21 -0
- data/spec/templates/erb_spec.rb +2 -2
- data/spec/templates/helpers/static.rb +5 -0
- data/spec/templates/helpers/static/templates/_relative.erb +1 -0
- data/spec/templates/helpers/static/templates/example.erb +1 -0
- data/spec/templates/template_spec.rb +41 -0
- data/spec/ui/command_line/classes/test_command.rb +23 -0
- data/spec/ui/command_line/command_spec.rb +31 -0
- data/spec/ui/output_spec.rb +29 -0
- data/static/ronin/platform/overlay.xsl +135 -114
- data/tasks/spec.rb +1 -0
- data/tasks/yard.rb +18 -0
- metadata +98 -59
- metadata.gz.sig +0 -0
- data/TODO.txt +0 -15
- data/lib/ronin/extensions/hash.rb +0 -62
- data/lib/ronin/sessions/esmtp.rb +0 -57
- data/lib/ronin/sessions/http.rb +0 -678
- data/lib/ronin/sessions/imap.rb +0 -54
- data/lib/ronin/sessions/pop3.rb +0 -52
- data/lib/ronin/sessions/smtp.rb +0 -57
- data/lib/ronin/sessions/tcp.rb +0 -100
- data/lib/ronin/sessions/telnet.rb +0 -55
- data/lib/ronin/sessions/udp.rb +0 -73
- data/lib/ronin/ui/command_line/options.rb +0 -136
- data/lib/ronin/ui/diagnostics.rb +0 -66
- data/lib/ronin/ui/verbose.rb +0 -58
- data/spec/extensions/hash_spec.rb +0 -38
- data/spec/sessions/classes/test_session.rb +0 -11
- data/spec/sessions/classes/uses_test_session.rb +0 -10
- data/spec/sessions/session_spec.rb +0 -25
- data/spec/ui/verbose_spec.rb +0 -17
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
5
3
|
#
|
6
4
|
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
5
|
#
|
@@ -18,7 +16,6 @@
|
|
18
16
|
# You should have received a copy of the GNU General Public License
|
19
17
|
# along with this program; if not, write to the Free Software
|
20
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
19
|
#
|
23
20
|
|
24
21
|
require 'ronin/platform/exceptions/overlay_cached'
|
@@ -42,9 +39,17 @@ module Ronin
|
|
42
39
|
attr_reader :path
|
43
40
|
|
44
41
|
#
|
45
|
-
# Create a new OverlayCache object
|
46
|
-
#
|
47
|
-
#
|
42
|
+
# Create a new OverlayCache object.
|
43
|
+
#
|
44
|
+
# @param [String] path
|
45
|
+
# The path of the overlay cache file.
|
46
|
+
#
|
47
|
+
# @yield [cache]
|
48
|
+
# If a block is given, it will be passed the newly created overlay
|
49
|
+
# cache.
|
50
|
+
#
|
51
|
+
# @yieldparam [OverlayCache] cache
|
52
|
+
# The newly created overly cache.
|
48
53
|
#
|
49
54
|
def initialize(path=CACHE_FILE,&block)
|
50
55
|
super()
|
@@ -52,23 +57,7 @@ module Ronin
|
|
52
57
|
@path = path
|
53
58
|
@dirty = false
|
54
59
|
|
55
|
-
|
56
|
-
descriptions = YAML.load_file(@path)
|
57
|
-
|
58
|
-
if descriptions.kind_of?(Array)
|
59
|
-
descriptions.each do |overlay|
|
60
|
-
if overlay.kind_of?(Hash)
|
61
|
-
overlay = Overlay.new(
|
62
|
-
overlay[:path],
|
63
|
-
overlay[:media],
|
64
|
-
overlay[:uri]
|
65
|
-
)
|
66
|
-
|
67
|
-
self[overlay.name] = overlay
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
60
|
+
load!()
|
72
61
|
|
73
62
|
at_exit(&method(:save))
|
74
63
|
|
@@ -76,15 +65,50 @@ module Ronin
|
|
76
65
|
end
|
77
66
|
|
78
67
|
#
|
79
|
-
#
|
80
|
-
#
|
68
|
+
# Loads the overlays from the cache-file at the +path+.
|
69
|
+
#
|
70
|
+
def load!
|
71
|
+
return false unless File.file?(@path)
|
72
|
+
|
73
|
+
descriptions = YAML.load_file(@path)
|
74
|
+
|
75
|
+
return false unless descriptions.kind_of?(Array)
|
76
|
+
|
77
|
+
descriptions.each do |overlay|
|
78
|
+
if overlay.kind_of?(Hash)
|
79
|
+
overlay = Overlay.new(
|
80
|
+
overlay[:path],
|
81
|
+
overlay[:media],
|
82
|
+
overlay[:uri]
|
83
|
+
)
|
84
|
+
|
85
|
+
self[overlay.name] = overlay
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
return true
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Clears the overlay cache, and reloads it's contents from the same
|
94
|
+
# cache-file.
|
95
|
+
#
|
96
|
+
def reload!
|
97
|
+
clear
|
98
|
+
load!
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# @return [Boolean]
|
103
|
+
# Specifies whether the overlay cache has been modified.
|
81
104
|
#
|
82
105
|
def dirty?
|
83
106
|
@dirty == true
|
84
107
|
end
|
85
108
|
|
86
109
|
#
|
87
|
-
#
|
110
|
+
# @return [Array]
|
111
|
+
# The sorted names of the overlays within the cache.
|
88
112
|
#
|
89
113
|
def names
|
90
114
|
keys.sort
|
@@ -94,8 +118,19 @@ module Ronin
|
|
94
118
|
alias each_overlay each_value
|
95
119
|
|
96
120
|
#
|
97
|
-
#
|
121
|
+
# Selects overlays from the overlay cache.
|
98
122
|
#
|
123
|
+
# @yield [overlay]
|
124
|
+
# The block that will be passed each overlay. Overlays will be
|
125
|
+
# selected based on the return value of the block.
|
126
|
+
#
|
127
|
+
# @yieldparam [Overlay] overlay
|
128
|
+
# An overlay from the cache.
|
129
|
+
#
|
130
|
+
# @return [Array]
|
131
|
+
# The selected overlay.
|
132
|
+
#
|
133
|
+
# @example
|
99
134
|
# cache.with do |overlay|
|
100
135
|
# overlay.author == 'the dude'
|
101
136
|
# end
|
@@ -105,15 +140,31 @@ module Ronin
|
|
105
140
|
end
|
106
141
|
|
107
142
|
#
|
108
|
-
#
|
109
|
-
#
|
143
|
+
# Searches for the overlay with the specified _name_.
|
144
|
+
#
|
145
|
+
# @param [String] name
|
146
|
+
# The name of the overlay to search for.
|
147
|
+
#
|
148
|
+
# @return [Boolean]
|
149
|
+
# Specifies whether the cache contains the Overlay with the
|
150
|
+
# matching _name_.
|
110
151
|
#
|
111
152
|
def has?(name)
|
112
153
|
has_key?(name.to_s)
|
113
154
|
end
|
114
155
|
|
115
156
|
#
|
116
|
-
#
|
157
|
+
# Searches for the overlay with the specified _name_.
|
158
|
+
#
|
159
|
+
# @param [String] name
|
160
|
+
# The name of the overlay to search for.
|
161
|
+
#
|
162
|
+
# @return [Overlay]
|
163
|
+
# The overlay with the matching _name_.
|
164
|
+
#
|
165
|
+
# @raise [OverlayNotFound]
|
166
|
+
# No overlay with the matching _name_ could be found in the
|
167
|
+
# overlay cache.
|
117
168
|
#
|
118
169
|
def get(name)
|
119
170
|
name = name.to_s
|
@@ -126,16 +177,22 @@ module Ronin
|
|
126
177
|
end
|
127
178
|
|
128
179
|
#
|
129
|
-
#
|
180
|
+
# @return [Array]
|
181
|
+
# The paths of the overlays contained in the cache.
|
130
182
|
#
|
131
183
|
def paths
|
132
184
|
overlays.map { |overlay| overlay.path }
|
133
185
|
end
|
134
186
|
|
135
187
|
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
188
|
+
# Searches for an extension within all overlays in the overlay cache.
|
189
|
+
#
|
190
|
+
# @param [String] name
|
191
|
+
# The name of the extension to search for.
|
192
|
+
#
|
193
|
+
# @return [Boolean]
|
194
|
+
# Specifies whether the extension with the specified _name_ exists
|
195
|
+
# within any of the overlays in the overlay cache.
|
139
196
|
#
|
140
197
|
def has_extension?(name)
|
141
198
|
each_overlay do |overlay|
|
@@ -146,7 +203,8 @@ module Ronin
|
|
146
203
|
end
|
147
204
|
|
148
205
|
#
|
149
|
-
#
|
206
|
+
# @return [Array]
|
207
|
+
# The names of all extensions within the overlay cache.
|
150
208
|
#
|
151
209
|
def extensions
|
152
210
|
ext_names = []
|
@@ -161,7 +219,14 @@ module Ronin
|
|
161
219
|
end
|
162
220
|
|
163
221
|
#
|
164
|
-
#
|
222
|
+
# Selects the paths of extensions that have the specified _name_, in
|
223
|
+
# all overlays in the overlay cache.
|
224
|
+
#
|
225
|
+
# @param [String] name
|
226
|
+
# The name of the extension to gather paths for.
|
227
|
+
#
|
228
|
+
# @return [Array]
|
229
|
+
# The paths of all extensions with the matching _name_.
|
165
230
|
#
|
166
231
|
def extension_paths(name)
|
167
232
|
ext_paths = []
|
@@ -176,8 +241,16 @@ module Ronin
|
|
176
241
|
end
|
177
242
|
|
178
243
|
#
|
179
|
-
# Adds
|
180
|
-
#
|
244
|
+
# Adds an overlay with the specified _name_ to the overlay cache.
|
245
|
+
#
|
246
|
+
# @param [String] name
|
247
|
+
# The name of the overlay.
|
248
|
+
#
|
249
|
+
# @param [Overlay] overlay
|
250
|
+
# The new overlay.
|
251
|
+
#
|
252
|
+
# @return [Overlay]
|
253
|
+
# The new overlay.
|
181
254
|
#
|
182
255
|
def []=(name,overlay)
|
183
256
|
super(name.to_s,overlay)
|
@@ -187,38 +260,62 @@ module Ronin
|
|
187
260
|
end
|
188
261
|
|
189
262
|
#
|
190
|
-
# Adds
|
191
|
-
#
|
192
|
-
#
|
263
|
+
# Adds an overlay to the cache.
|
264
|
+
#
|
265
|
+
# @param [Overlay] overlay
|
266
|
+
# The overlay to add.
|
267
|
+
#
|
268
|
+
# @yield [overlay]
|
269
|
+
# If a block is given, it will be passed the overlay after it has
|
270
|
+
# been added to the cache.
|
271
|
+
#
|
272
|
+
# @yieldparam [Overlay] overlay
|
273
|
+
# The newly added overlay.
|
193
274
|
#
|
275
|
+
# @return [Overlay]
|
276
|
+
# The newly added overlay.
|
277
|
+
#
|
278
|
+
# @example
|
194
279
|
# cache.add(overlay)
|
195
280
|
# # => #<Ronin::Platform::Overlay: ...>
|
196
281
|
#
|
282
|
+
# @example
|
197
283
|
# cache.add(overlay) do |cache|
|
198
284
|
# puts "Overlay #{overlay} added"
|
199
285
|
# end
|
200
286
|
#
|
287
|
+
# @raise [OverlayCache]
|
288
|
+
# The specified _overlay_ has already been cached.
|
289
|
+
#
|
201
290
|
def add(overlay,&block)
|
202
291
|
name = overlay.name.to_s
|
203
292
|
|
204
293
|
if has?(name)
|
205
|
-
raise(OverlayCached,"overlay #{name.dump} already present in the cache #{self.to_s.dump}",caller)
|
294
|
+
raise(OverlayCached,"overlay #{name.dump} is already present in the cache #{self.to_s.dump}",caller)
|
206
295
|
end
|
207
296
|
|
208
297
|
self[overlay.name.to_s] = overlay
|
209
298
|
dirty!
|
210
299
|
|
211
|
-
block.call(
|
212
|
-
return
|
300
|
+
block.call(overlay) if block
|
301
|
+
return overlay
|
213
302
|
end
|
214
303
|
|
215
304
|
#
|
216
|
-
# Updates all the
|
217
|
-
#
|
305
|
+
# Updates all overlays in the cache.
|
306
|
+
#
|
307
|
+
# @yield [overlay]
|
308
|
+
# If a block is given, it will be passed each overlay after it has
|
309
|
+
# been updated.
|
218
310
|
#
|
311
|
+
# @yieldparam [Overlay] overlay
|
312
|
+
# Each updated overlay in the cache.
|
313
|
+
#
|
314
|
+
# @example
|
219
315
|
# update
|
220
316
|
# # => #<Ronin::Platform::OverlayCache: ...>
|
221
317
|
#
|
318
|
+
# @example
|
222
319
|
# update do |overlay|
|
223
320
|
# puts "#{overaly} is updated"
|
224
321
|
# end
|
@@ -234,13 +331,26 @@ module Ronin
|
|
234
331
|
end
|
235
332
|
|
236
333
|
#
|
237
|
-
# Removes
|
238
|
-
#
|
239
|
-
#
|
334
|
+
# Removes an overlay from the overlay cache, but leaves the contents
|
335
|
+
# of the overlay intact.
|
336
|
+
#
|
337
|
+
# @param [String] name
|
338
|
+
# The name of the overlay to remove.
|
339
|
+
#
|
340
|
+
# @yield [overlay]
|
341
|
+
# If a block is given, it will be passed the removed overlay.
|
240
342
|
#
|
343
|
+
# @yieldparam [Overlay] overlay
|
344
|
+
# The removed overlay.
|
345
|
+
#
|
346
|
+
# @return [Overlay]
|
347
|
+
# The removed overlay.
|
348
|
+
#
|
349
|
+
# @example
|
241
350
|
# cache.remove('hello_word')
|
242
351
|
# # => #<Ronin::Platform::Overlay: ...>
|
243
352
|
#
|
353
|
+
# @example
|
244
354
|
# cache.remove('hello_word') do |overlay|
|
245
355
|
# puts "Overlay #{overlay} removed"
|
246
356
|
# end
|
@@ -255,17 +365,27 @@ module Ronin
|
|
255
365
|
dirty!
|
256
366
|
|
257
367
|
block.call(overlay) if block
|
258
|
-
return
|
368
|
+
return overlay
|
259
369
|
end
|
260
370
|
|
261
371
|
#
|
262
|
-
# Uninstalls
|
263
|
-
# is given, it will be passed the uninstalled overlay. The cache
|
264
|
-
# will be returned, after the overlay is removed.
|
372
|
+
# Uninstalls an overlay and its contents from the overlay cache.
|
265
373
|
#
|
374
|
+
# @param [String] name
|
375
|
+
# The name of the overlay to uninstall.
|
376
|
+
#
|
377
|
+
# @yield [overlay]
|
378
|
+
# If a block is given, it will be passed the overlay, after it has
|
379
|
+
# been uninstalled.
|
380
|
+
#
|
381
|
+
# @yieldparam [Overlay] overlay
|
382
|
+
# The uninstalled overlay.
|
383
|
+
#
|
384
|
+
# @example
|
266
385
|
# cache.uninstall('hello_word')
|
267
386
|
# # => #<Ronin::Platform::Overlay: ...>
|
268
387
|
#
|
388
|
+
# @example
|
269
389
|
# cache.uninstall('hello_word') do |overlay|
|
270
390
|
# puts "Overlay #{overlay} uninstalled"
|
271
391
|
# end
|
@@ -274,10 +394,12 @@ module Ronin
|
|
274
394
|
remove(name) do |overlay|
|
275
395
|
overlay.uninstall(&block)
|
276
396
|
end
|
397
|
+
|
398
|
+
return nil
|
277
399
|
end
|
278
400
|
|
279
401
|
#
|
280
|
-
# Saves the overlay cache.
|
402
|
+
# Saves the overlay cache to the path.
|
281
403
|
#
|
282
404
|
def save
|
283
405
|
return false unless dirty?
|
@@ -304,7 +426,8 @@ module Ronin
|
|
304
426
|
end
|
305
427
|
|
306
428
|
#
|
307
|
-
#
|
429
|
+
# @return [String]
|
430
|
+
# The path of the cache.
|
308
431
|
#
|
309
432
|
def to_s
|
310
433
|
@path.to_s
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
|
3
|
-
# Ronin - A Ruby platform designed for information security and data
|
4
|
-
# exploration tasks.
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
5
3
|
#
|
6
4
|
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
5
|
#
|
@@ -18,7 +16,6 @@
|
|
18
16
|
# You should have received a copy of the GNU General Public License
|
19
17
|
# along with this program; if not, write to the Free Software
|
20
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
-
#++
|
22
19
|
#
|
23
20
|
|
24
21
|
require 'ronin/platform/exceptions/overlay_not_found'
|
@@ -31,34 +28,66 @@ require 'uri'
|
|
31
28
|
module Ronin
|
32
29
|
module Platform
|
33
30
|
#
|
34
|
-
# Load the overlay cache
|
35
|
-
# given it will be passed the current overlay cache.
|
31
|
+
# Load the overlay cache.
|
36
32
|
#
|
33
|
+
# @param [String] path
|
34
|
+
# The optional path to the overlay cache file.
|
35
|
+
#
|
36
|
+
# @return [OverlayCache]
|
37
|
+
# The newly loaded overlay cache.
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Overlay.load_overlays
|
41
|
+
# # => #<Ronin::Platform::OverlayCache: ...>
|
42
|
+
#
|
43
|
+
# @example
|
37
44
|
# Overlay.load_overlays('/custom/overlays/cache.yaml')
|
38
45
|
# # => #<Ronin::Platform::OverlayCache: ...>
|
39
46
|
#
|
40
|
-
def Platform.load_overlays(path)
|
47
|
+
def Platform.load_overlays(path=OverlayCache::CACHE_FILE)
|
41
48
|
@@ronin_overlay_cache = OverlayCache.new(path)
|
42
49
|
end
|
43
50
|
|
44
51
|
#
|
45
|
-
#
|
46
|
-
# cache
|
52
|
+
# @return [OverlayCache]
|
53
|
+
# The current overlay cache. If no overlay cache is present, the
|
54
|
+
# default overlay will be loaded.
|
47
55
|
#
|
48
56
|
def Platform.overlays
|
49
57
|
@@ronin_overlay_cache ||= OverlayCache.new
|
50
58
|
end
|
51
59
|
|
52
60
|
#
|
53
|
-
# Adds a new
|
54
|
-
#
|
61
|
+
# Adds a new overlay to the overlay cache.
|
62
|
+
#
|
63
|
+
# @param [Hash] options
|
64
|
+
# Additional options.
|
65
|
+
#
|
66
|
+
# @option options [String] :path
|
67
|
+
# A pre-existing path to the overlay.
|
68
|
+
#
|
69
|
+
# @option options [Symbol] :media
|
70
|
+
# The media type of the overlay, may be either +:git+, +:hg+,
|
71
|
+
# +:svn+ or +:rsync+.
|
72
|
+
#
|
73
|
+
# @option options [String, URI::HTTP, URI::HTTPS] uri
|
74
|
+
# The URI of the overlay.
|
75
|
+
#
|
76
|
+
# @yield [overlay]
|
77
|
+
# If a block is given, it will be passed the overlay after it has
|
78
|
+
# been added to the cache.
|
79
|
+
#
|
80
|
+
# @yieldparam [Overlay] overlay
|
81
|
+
# The newly added overlay.
|
82
|
+
#
|
83
|
+
# @return [Overlay]
|
84
|
+
# The newly added overlay.
|
55
85
|
#
|
56
|
-
#
|
57
|
-
#
|
86
|
+
# @raise [ArgumentError]
|
87
|
+
# The +:path+ option was not specified.
|
58
88
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
# <tt>:uri</tt>:: The URI of the overlay.
|
89
|
+
# @raise [OverlayNotFound]
|
90
|
+
# The +:path+ option did not represent a valid directory.
|
62
91
|
#
|
63
92
|
def Platform.add(options={},&block)
|
64
93
|
path = options[:path]
|
@@ -78,24 +107,40 @@ module Ronin
|
|
78
107
|
|
79
108
|
overlay = Overlay.new(path,media,uri)
|
80
109
|
|
81
|
-
Platform.overlays.add(overlay) do
|
110
|
+
Platform.overlays.add(overlay) do |overlay|
|
82
111
|
ObjectCache.cache(overlay.objects_dir)
|
83
112
|
end
|
84
113
|
|
114
|
+
block.call(overlay) if block
|
85
115
|
return overlay
|
86
116
|
end
|
87
117
|
|
88
118
|
#
|
89
|
-
# Installs an
|
90
|
-
#
|
91
|
-
# passed the newly created overlay after it has been added to
|
92
|
-
# the overlay cache.
|
119
|
+
# Installs an overlay into the OverlayCache::CACHE_DIR and adds it
|
120
|
+
# to the overlay cache.
|
93
121
|
#
|
94
|
-
#
|
95
|
-
#
|
122
|
+
# @param [Hash] options
|
123
|
+
# Additional options.
|
96
124
|
#
|
97
|
-
#
|
98
|
-
#
|
125
|
+
# @option options [String, URI::HTTP, URI::HTTPS] :uri
|
126
|
+
# The URI to the overlay.
|
127
|
+
#
|
128
|
+
# @option options [Symbol] :media
|
129
|
+
# The media type of the overlay, may be either +:git+, +:hg+,
|
130
|
+
# +:svn+ or +:rsync+.
|
131
|
+
#
|
132
|
+
# @yield [overlay]
|
133
|
+
# If a block is given, it will be passed the overlay, after it has
|
134
|
+
# been installed.
|
135
|
+
#
|
136
|
+
# @yieldparam [Overlay] overlay
|
137
|
+
# The newly installed overlay.
|
138
|
+
#
|
139
|
+
# @return [Overlay]
|
140
|
+
# The newly installed overlay.
|
141
|
+
#
|
142
|
+
# @raise [ArgumentError]
|
143
|
+
# The +:uri+ option must be specified.
|
99
144
|
#
|
100
145
|
def Platform.install(options={},&block)
|
101
146
|
unless options[:uri]
|
@@ -111,14 +156,18 @@ module Ronin
|
|
111
156
|
return Platform.add(
|
112
157
|
:path => repo.path,
|
113
158
|
:media => repo.media_name,
|
114
|
-
:uri => uri
|
159
|
+
:uri => uri,
|
160
|
+
&block
|
115
161
|
)
|
116
162
|
end
|
117
163
|
end
|
118
164
|
|
119
165
|
#
|
120
|
-
# Updates all previously installed overlays
|
121
|
-
#
|
166
|
+
# Updates all previously installed overlays within the overlay cache.
|
167
|
+
#
|
168
|
+
# @yield []
|
169
|
+
# If a block is given, it will be called after all overlays have been
|
170
|
+
# updated within the cache.
|
122
171
|
#
|
123
172
|
def Platform.update(&block)
|
124
173
|
Platform.overlays.update do |overlay|
|
@@ -130,10 +179,22 @@ module Ronin
|
|
130
179
|
end
|
131
180
|
|
132
181
|
#
|
133
|
-
# Removes
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
182
|
+
# Removes an overlay from the overlay cache, but leaves the contents
|
183
|
+
# of the overlay intact.
|
184
|
+
#
|
185
|
+
# @param [String] name
|
186
|
+
# The name of the overlay to remove.
|
187
|
+
#
|
188
|
+
# @yield [overlay]
|
189
|
+
# If a block is given, it will be passed the overlay after it has
|
190
|
+
# been removed.
|
191
|
+
#
|
192
|
+
# @yieldparam [Overlay] overlay
|
193
|
+
# The removed overlay.
|
194
|
+
#
|
195
|
+
# @raise [OverlayNotFound]
|
196
|
+
# The overlay with the specified _name_ could not be found in the
|
197
|
+
# overlay cache.
|
137
198
|
#
|
138
199
|
def Platform.remove(name,&block)
|
139
200
|
Platform.overlays.remove(name,&block)
|
@@ -141,10 +202,19 @@ module Ronin
|
|
141
202
|
end
|
142
203
|
|
143
204
|
#
|
144
|
-
# Uninstalls
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
205
|
+
# Uninstalls an overlay from the overlay cache, and deletes the
|
206
|
+
# contents of the overlay.
|
207
|
+
#
|
208
|
+
# @param [String] name
|
209
|
+
# The name of the overlay to uninstall.
|
210
|
+
#
|
211
|
+
# @yield []
|
212
|
+
# If a block is given, it will be called after the overlay has been
|
213
|
+
# uninstalled.
|
214
|
+
#
|
215
|
+
# @raise [OverlayNotFound]
|
216
|
+
# The overlay with the specified _name_ could not be found in the
|
217
|
+
# overlay cache.
|
148
218
|
#
|
149
219
|
def Platform.uninstall(name,&block)
|
150
220
|
Platform.overlays.uninstall(name) do |overlay|
|
@@ -156,36 +226,36 @@ module Ronin
|
|
156
226
|
end
|
157
227
|
|
158
228
|
#
|
159
|
-
#
|
229
|
+
# @return [Array]
|
230
|
+
# The names of all extensions within the overlays in the overlay
|
231
|
+
# cache.
|
160
232
|
#
|
161
233
|
def Platform.extension_names
|
162
|
-
|
163
|
-
|
164
|
-
Platform.overlays.each_overlay do |overlay|
|
165
|
-
overlay.extensions.each do |name|
|
166
|
-
names << name unless names.include?(name)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
return names
|
234
|
+
Platform.overlays.extensions
|
171
235
|
end
|
172
236
|
|
173
237
|
#
|
174
|
-
#
|
175
|
-
#
|
238
|
+
# Searches for the extension with the specified _name_, in all
|
239
|
+
# overlays within the overlay cache.
|
240
|
+
#
|
241
|
+
# @param [String] name
|
242
|
+
# The name of the extension to search for.
|
243
|
+
#
|
244
|
+
# @return [Boolean]
|
245
|
+
# Specifies whether the overlay cache contains the extension with
|
246
|
+
# the matching _name_.
|
176
247
|
#
|
177
248
|
def Platform.has_extension?(name)
|
178
|
-
Platform.overlays.
|
179
|
-
return true if overlay.has_extension?(name)
|
180
|
-
end
|
181
|
-
|
182
|
-
return false
|
249
|
+
Platform.overlays.has_extension?(name)
|
183
250
|
end
|
184
251
|
|
185
252
|
#
|
186
|
-
#
|
187
|
-
#
|
253
|
+
# The extension cache.
|
254
|
+
#
|
255
|
+
# @return [ExtensionCache]
|
256
|
+
# The extension cache of all currently loaded extensions.
|
188
257
|
#
|
258
|
+
# @example
|
189
259
|
# Platform.extensions['shellcode']
|
190
260
|
# # => #<Ronin::Platform::Extension: ...>
|
191
261
|
#
|
@@ -194,9 +264,25 @@ module Ronin
|
|
194
264
|
end
|
195
265
|
|
196
266
|
#
|
197
|
-
# Loads
|
198
|
-
#
|
199
|
-
#
|
267
|
+
# Loads an extension into the extension cache, if it has yet to be
|
268
|
+
# loaded.
|
269
|
+
#
|
270
|
+
# @param [String] name
|
271
|
+
# The name of the desired extension.
|
272
|
+
#
|
273
|
+
# @yield [ext]
|
274
|
+
# If a block is given, it will be passed the extension with the
|
275
|
+
# matching _name_.
|
276
|
+
#
|
277
|
+
# @yieldparam [Extension] ext
|
278
|
+
# The desired extension.
|
279
|
+
#
|
280
|
+
# @return [Extension]
|
281
|
+
# The desired extension.
|
282
|
+
#
|
283
|
+
# @raise [ExtensionNotFound]
|
284
|
+
# The extension with the specified _name_ could not be found in any
|
285
|
+
# of the overlays or in the extension cache.
|
200
286
|
#
|
201
287
|
def Platform.extension(name,&block)
|
202
288
|
ext = Platform.extensions[name]
|
@@ -204,5 +290,15 @@ module Ronin
|
|
204
290
|
block.call(ext) if block
|
205
291
|
return ext
|
206
292
|
end
|
293
|
+
|
294
|
+
#
|
295
|
+
# Reloads the overlay cache and the extension cache.
|
296
|
+
#
|
297
|
+
# @return [Boolean]
|
298
|
+
# Specifies whether the reload was successful or not.
|
299
|
+
#
|
300
|
+
def Platform.reload!
|
301
|
+
Platform.overlays.reload! && Platform.extensions.reload!
|
302
|
+
end
|
207
303
|
end
|
208
304
|
end
|