ronin 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +53 -0
- data/Manifest.txt +26 -18
- data/README.txt +12 -19
- data/Rakefile +9 -9
- data/TODO.txt +5 -5
- data/lib/ronin/cacheable.rb +246 -0
- data/lib/ronin/database/database.rb +21 -3
- data/lib/ronin/database/exceptions/invalid_config.rb +1 -1
- data/lib/ronin/environment.rb +5 -2
- data/lib/ronin/extensions.rb +2 -0
- data/lib/ronin/{models.rb → extensions/array.rb} +19 -6
- data/lib/ronin/extensions/ip_addr.rb +127 -0
- data/lib/ronin/{objectify/exceptions/object_context_not_found.rb → extensions/kernel.rb} +14 -3
- data/lib/ronin/extensions/uri/query_params.rb +4 -2
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +14 -12
- data/lib/ronin/formatting/extensions/text/string.rb +37 -19
- data/lib/ronin/has_license.rb +4 -2
- data/lib/ronin/model.rb +0 -1
- data/lib/ronin/network/extensions/http/net.rb +30 -3
- data/lib/ronin/network/extensions/telnet/net.rb +0 -18
- data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -1
- data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -1
- data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -1
- data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -1
- data/lib/ronin/platform/extension.rb +18 -3
- data/lib/ronin/platform/extension_cache.rb +7 -1
- data/lib/ronin/platform/object_cache.rb +13 -12
- data/lib/ronin/platform/overlay.rb +14 -6
- data/lib/ronin/platform/overlay_cache.rb +11 -5
- data/lib/ronin/product.rb +20 -3
- data/lib/ronin/ronin.rb +0 -15
- data/lib/ronin/rpc/exceptions/response_missing.rb +1 -1
- data/lib/ronin/sessions/esmtp.rb +1 -10
- data/lib/ronin/{objectify.rb → sessions/exceptions.rb} +3 -3
- data/lib/ronin/{objectify/exceptions/unknown_object_context.rb → sessions/exceptions/variable_missing.rb} +4 -4
- data/lib/ronin/sessions/http.rb +3 -10
- data/lib/ronin/sessions/imap.rb +1 -10
- data/lib/ronin/sessions/pop3.rb +1 -9
- data/lib/ronin/sessions/session.rb +11 -21
- data/lib/ronin/sessions/smtp.rb +1 -10
- data/lib/ronin/sessions/tcp.rb +10 -13
- data/lib/ronin/sessions/telnet.rb +2 -17
- data/lib/ronin/sessions/udp.rb +6 -11
- data/lib/ronin/static/finders.rb +24 -0
- data/lib/ronin/ui/command_line/command_line.rb +41 -21
- data/lib/ronin/ui/command_line/commands/help.rb +7 -3
- data/lib/ronin/ui/command_line/commands/ls.rb +1 -1
- data/lib/ronin/ui/command_line/commands/rm.rb +1 -1
- data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -1
- data/lib/ronin/ui/diagnostics.rb +12 -5
- data/lib/ronin/ui/hexdump/extensions/file.rb +3 -1
- data/lib/ronin/ui/hexdump/hexdump.rb +1 -1
- data/lib/ronin/ui/verbose.rb +14 -0
- data/lib/ronin/version.rb +1 -1
- data/spec/cacheable_spec.rb +150 -0
- data/spec/classes/cacheable_model.rb +15 -0
- data/spec/classes/licensed_model.rb +12 -0
- data/spec/code/classes/thing.rb +13 -0
- data/spec/code/reference_spec.rb +1 -14
- data/spec/extensions/array_spec.rb +34 -0
- data/spec/extensions/ip_addr_spec.rb +44 -0
- data/spec/extensions/kernel_spec.rb +19 -0
- data/spec/extensions/uri/query_params_spec.rb +8 -0
- data/spec/formatting/binary/string_spec.rb +1 -1
- data/spec/formatting/digest/string_spec.rb +84 -0
- data/spec/formatting/http/string_spec.rb +84 -0
- data/spec/formatting/text/string_spec.rb +51 -0
- data/spec/has_license_spec.rb +29 -0
- data/spec/helpers/cacheable.rb +7 -0
- data/spec/helpers/contexts/ronin_cacheable_model.rb +13 -0
- data/spec/helpers/database.rb +5 -0
- data/spec/platform/helpers/overlays/hello/lib/init.rb +1 -0
- data/spec/platform/helpers/overlays/hello/lib/stuff/another_test.rb +6 -0
- data/spec/platform/helpers/overlays/hello/lib/stuff/test.rb +4 -0
- data/spec/platform/overlay_cache_spec.rb +1 -1
- data/spec/platform/overlay_spec.rb +28 -0
- data/spec/product_spec.rb +7 -0
- data/spec/sessions/classes/test_session.rb +11 -0
- data/spec/sessions/classes/uses_test_session.rb +10 -0
- data/spec/sessions/session_spec.rb +13 -44
- data/spec/spec_helper.rb +0 -5
- data/spec/static/{helpers → classes}/static_class.rb +0 -0
- data/spec/static/helpers/static.rb +0 -1
- data/spec/static/static_spec.rb +1 -0
- metadata +44 -35
- data/lib/ronin/objectify/exceptions.rb +0 -25
- data/lib/ronin/objectify/objectify.rb +0 -240
- data/lib/ronin/target.rb +0 -44
- data/lib/ronin/ui/command_line/param_parser.rb +0 -93
- data/spec/formatting/digest_spec.rb +0 -54
- data/spec/formatting/http_spec.rb +0 -53
- data/spec/formatting/text_spec.rb +0 -40
- data/spec/helpers.rb +0 -0
- data/spec/objectify/objectify_spec.rb +0 -31
- data/spec/target_spec.rb +0 -16
- data/spec/ui/command_line/helpers/example_command.rb +0 -21
- data/spec/ui/command_line/param_parser_spec.rb +0 -49
data/lib/ronin/has_license.rb
CHANGED
@@ -31,7 +31,9 @@ module Ronin
|
|
31
31
|
include Ronin::Model
|
32
32
|
|
33
33
|
# The license
|
34
|
-
belongs_to :license,
|
34
|
+
belongs_to :license,
|
35
|
+
:child_key => [:license_id],
|
36
|
+
:class_name => 'Ronin::License'
|
35
37
|
|
36
38
|
#
|
37
39
|
# Returns all models having the predefined license with the
|
@@ -41,7 +43,7 @@ module Ronin
|
|
41
43
|
# # => [#<Ronin::LicensedModel: ...>, ...]
|
42
44
|
#
|
43
45
|
def self.licensed_under(name)
|
44
|
-
self.all(:
|
46
|
+
self.all(:license_id => Ronin::License[name].id)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/ronin/model.rb
CHANGED
@@ -165,6 +165,33 @@ module Net
|
|
165
165
|
Net.http_head(options).code == 200
|
166
166
|
end
|
167
167
|
|
168
|
+
#
|
169
|
+
# Returns the HTTP Server header for the given _options_.
|
170
|
+
#
|
171
|
+
# Net.http_server(:url => 'http://www.darkc0de.com/)
|
172
|
+
# # => "Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c
|
173
|
+
# mod_fastcgi/2.4.6 Phusion_Passenger/2.1.2 DAV/2 SVN/1.4.2"
|
174
|
+
#
|
175
|
+
def Net.http_server(options={})
|
176
|
+
Net.http_head(options)['server']
|
177
|
+
end
|
178
|
+
|
179
|
+
#
|
180
|
+
# Returns the HTTP X-Powered-By header for the given _options_.
|
181
|
+
#
|
182
|
+
# Net.http_powered_by(:url => 'http://www.stalkdaily.com/')
|
183
|
+
# # => "PHP/5.2.9"
|
184
|
+
#
|
185
|
+
def Net.http_powered_by(options={})
|
186
|
+
resp = Net.http_head(options)
|
187
|
+
|
188
|
+
if resp.code != 200
|
189
|
+
resp = Net.http_get(options)
|
190
|
+
end
|
191
|
+
|
192
|
+
return resp['x-powered-by']
|
193
|
+
end
|
194
|
+
|
168
195
|
#
|
169
196
|
# Performes an HTTP Lock request with the given _options_. If a _block_
|
170
197
|
# is given, it will be passed the response from the HTTP server.
|
@@ -268,13 +295,13 @@ module Net
|
|
268
295
|
end
|
269
296
|
|
270
297
|
#
|
271
|
-
# Performes an HTTP
|
298
|
+
# Performes an HTTP Proppatch request with the given _options_. If a
|
272
299
|
# _block_ is given, it will be passed the response from the HTTP server.
|
273
300
|
# Returns the response from the HTTP server.
|
274
301
|
#
|
275
|
-
def Net.
|
302
|
+
def Net.http_prop_patch(options={},&block)
|
276
303
|
Net.http_session(options) do |http|
|
277
|
-
resp = http.request(Ronin::Network::HTTP.request(:
|
304
|
+
resp = http.request(Ronin::Network::HTTP.request(:proppatch,options),options[:body])
|
278
305
|
|
279
306
|
block.call(resp) if block
|
280
307
|
return resp
|
@@ -24,7 +24,6 @@
|
|
24
24
|
require 'ronin/network/telnet'
|
25
25
|
|
26
26
|
require 'net/telnet'
|
27
|
-
require 'net/telnets'
|
28
27
|
|
29
28
|
module Net
|
30
29
|
#
|
@@ -67,13 +66,6 @@ module Net
|
|
67
66
|
# <tt>Ronin::Network::Telnet.proxy</tt>, if not given.
|
68
67
|
# <tt>:user</tt>:: The user to login with.
|
69
68
|
# <tt>:password</tt>:: The password to login with.
|
70
|
-
# <tt>:ssl</tt>:: A Hash of SSL information to use for a SSLed
|
71
|
-
# Telnet session. This hash must contain the following
|
72
|
-
# keys.
|
73
|
-
# <tt>:certfile</tt>:: The SSL Certfile to use.
|
74
|
-
# <tt>:keyfile</tt>:: The SSL Key file to use.
|
75
|
-
# <tt>:cafile</tt>:: The SSL CAFile to use.
|
76
|
-
# <tt>:capath</tt>:: The SSL CAPath to use.
|
77
69
|
#
|
78
70
|
# Telnet.connect('towel.blinkenlights.nl') # => Telnet
|
79
71
|
#
|
@@ -97,16 +89,6 @@ module Net
|
|
97
89
|
user = options[:user]
|
98
90
|
passwd = options[:passwd]
|
99
91
|
|
100
|
-
if options[:ssl]
|
101
|
-
sess_opts['CertFile'] = options[:ssl][:certfile]
|
102
|
-
sess_opts['KeyFile'] = options[:ssl][:keyfile]
|
103
|
-
sess_opts['CAFile'] = options[:ssl][:cafile]
|
104
|
-
sess_opts['CAPath'] = options[:ssl][:capath]
|
105
|
-
sess_opts['VerifyMode'] = (options[:ssl][:verify] || SSL::VERIFY_PEER)
|
106
|
-
sess_opts['VerifyCallback'] = options[:ssl][:verify_callback]
|
107
|
-
sess_opts['VerifyDepth'] = options[:ssl][:verify_depth]
|
108
|
-
end
|
109
|
-
|
110
92
|
sess = Net::Telnet.new(sess_opts)
|
111
93
|
sess.login(user,passwd) if user
|
112
94
|
|
@@ -140,21 +140,36 @@ module Ronin
|
|
140
140
|
# instance_eval the extension block
|
141
141
|
context_block = Extension.load_context_block(extension_file)
|
142
142
|
|
143
|
-
|
143
|
+
if context_block
|
144
|
+
begin
|
145
|
+
instance_eval(&context_block)
|
146
|
+
rescue SyntaxError, RuntimeError, StandardError => e
|
147
|
+
STDERR.puts "#{e.class}: #{e}"
|
148
|
+
e.backtrace.each { |trace| STDERR.puts "\t#{trace}" }
|
149
|
+
end
|
150
|
+
end
|
144
151
|
end
|
145
152
|
|
146
153
|
block.call(self) if block
|
147
154
|
return self
|
148
155
|
end
|
149
156
|
|
157
|
+
#
|
158
|
+
# Returns the list of methods exposed by the extension.
|
159
|
+
#
|
160
|
+
def exposed_methods
|
161
|
+
methods(false).map { |name| name.to_sym }
|
162
|
+
end
|
163
|
+
|
150
164
|
#
|
151
165
|
# Returns +true+ if the extension context has a public instance method
|
152
166
|
# of the matching _name_, returns +false+ otherwise.
|
153
167
|
#
|
154
|
-
# ext.has_method?(:console)
|
168
|
+
# ext.has_method?(:console)
|
169
|
+
# # => true
|
155
170
|
#
|
156
171
|
def has_method?(name)
|
157
|
-
|
172
|
+
exposed_methods.include?(name.to_sym)
|
158
173
|
end
|
159
174
|
|
160
175
|
#
|
@@ -46,7 +46,13 @@ module Ronin
|
|
46
46
|
block.call(self) if block
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
#
|
50
|
+
# Returns the sorted names of the extensions within the cache.
|
51
|
+
#
|
52
|
+
def names
|
53
|
+
keys.sort
|
54
|
+
end
|
55
|
+
|
50
56
|
alias extensions values
|
51
57
|
alias each_extension each_value
|
52
58
|
|
@@ -21,7 +21,7 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
24
|
+
require 'ronin/cacheable'
|
25
25
|
|
26
26
|
module Ronin
|
27
27
|
module Platform
|
@@ -31,7 +31,7 @@ module Ronin
|
|
31
31
|
# to object files.
|
32
32
|
#
|
33
33
|
def ObjectCache.paths(directory)
|
34
|
-
Dir[File.join(directory,'**','*.rb')]
|
34
|
+
Dir[File.join(File.expand_path(directory),'**','*.rb')]
|
35
35
|
end
|
36
36
|
|
37
37
|
#
|
@@ -41,10 +41,10 @@ module Ronin
|
|
41
41
|
attributes = {}
|
42
42
|
|
43
43
|
if directory
|
44
|
-
attributes.merge!(:
|
44
|
+
attributes.merge!(:cached_path.like => File.join(directory,'%'))
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
Cacheable.models.each do |base|
|
48
48
|
base.all(attributes).each(&block)
|
49
49
|
end
|
50
50
|
|
@@ -57,35 +57,36 @@ module Ronin
|
|
57
57
|
#
|
58
58
|
def ObjectCache.cache(directory)
|
59
59
|
ObjectCache.paths(directory).each do |path|
|
60
|
-
|
60
|
+
Cacheable.cache(path)
|
61
61
|
end
|
62
62
|
|
63
63
|
return true
|
64
64
|
end
|
65
65
|
|
66
66
|
#
|
67
|
-
#
|
67
|
+
# Syncs all objects that were previously cached from paths within
|
68
68
|
# the specified _directory_. Also cache objects which have yet to
|
69
69
|
# be cached.
|
70
70
|
#
|
71
|
-
def ObjectCache.
|
71
|
+
def ObjectCache.sync(directory)
|
72
72
|
new_paths = ObjectCache.paths(directory)
|
73
73
|
|
74
74
|
ObjectCache.each(directory) do |obj|
|
75
|
-
new_paths.delete(obj.
|
75
|
+
new_paths.delete(obj.cached_path)
|
76
76
|
|
77
|
-
obj.
|
77
|
+
obj.sync!
|
78
78
|
end
|
79
79
|
|
80
80
|
# cache the remaining new paths
|
81
|
-
new_paths.each { |path|
|
81
|
+
new_paths.each { |path| Cacheable.cache(path) }
|
82
82
|
return true
|
83
83
|
end
|
84
84
|
|
85
85
|
#
|
86
|
-
# Deletes all cached objects that existed in the specified
|
86
|
+
# Deletes all cached objects that existed in the specified
|
87
|
+
# _directory_.
|
87
88
|
#
|
88
|
-
def ObjectCache.
|
89
|
+
def ObjectCache.clean(directory)
|
89
90
|
ObjectCache.each(directory) { |obj| obj.destroy }
|
90
91
|
return true
|
91
92
|
end
|
@@ -41,6 +41,9 @@ module Ronin
|
|
41
41
|
# Overlay lib/ directory
|
42
42
|
LIB_DIR = 'lib'
|
43
43
|
|
44
|
+
# The init.rb file to load from the LIB_DIR
|
45
|
+
INIT_FILE = 'init.rb'
|
46
|
+
|
44
47
|
# Overlay static/ directory
|
45
48
|
STATIC_DIR = 'static'
|
46
49
|
|
@@ -162,24 +165,29 @@ module Ronin
|
|
162
165
|
|
163
166
|
#
|
164
167
|
# Activates the overlay by adding the lib_dirs to the
|
165
|
-
# <tt>$LOAD_PATH</tt
|
168
|
+
# <tt>$LOAD_PATH</tt> global variable.
|
166
169
|
#
|
167
170
|
def activate!
|
171
|
+
# add the static/ directory
|
172
|
+
Static.directory(@static_dir) if File.directory?(@static_dir)
|
173
|
+
|
168
174
|
# add the lib/ directories
|
169
175
|
lib_dirs.each do |path|
|
170
176
|
$LOAD_PATH << path unless $LOAD_PATH.include?(path)
|
171
177
|
end
|
172
178
|
|
173
|
-
#
|
174
|
-
|
179
|
+
# load the lib/init.rb file
|
180
|
+
init_path = File.join(@path,LIB_DIR,INIT_FILE)
|
181
|
+
load init_path if File.file?(init_path)
|
182
|
+
|
175
183
|
return true
|
176
184
|
end
|
177
185
|
|
178
186
|
#
|
179
|
-
# Deactivates the overlay by removing the lib_dirs
|
180
|
-
# <tt>$LOAD_PATH</tt
|
187
|
+
# Deactivates the overlay by removing the lib_dirs from the
|
188
|
+
# <tt>$LOAD_PATH</tt> global variable.
|
181
189
|
#
|
182
|
-
def
|
190
|
+
def deactivate!
|
183
191
|
Static.static_dirs.reject! { |dir| dir == @static_dir }
|
184
192
|
|
185
193
|
paths = lib_dirs
|
@@ -53,7 +53,7 @@ module Ronin
|
|
53
53
|
@dirty = false
|
54
54
|
|
55
55
|
if File.file?(@path)
|
56
|
-
descriptions = YAML.
|
56
|
+
descriptions = YAML.load_file(@path)
|
57
57
|
|
58
58
|
if descriptions.kind_of?(Array)
|
59
59
|
descriptions.each do |overlay|
|
@@ -83,7 +83,13 @@ module Ronin
|
|
83
83
|
@dirty == true
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
#
|
87
|
+
# Returns the sorted names of the overlays within the cache.
|
88
|
+
#
|
89
|
+
def names
|
90
|
+
keys.sort
|
91
|
+
end
|
92
|
+
|
87
93
|
alias overlays values
|
88
94
|
alias each_overlay each_value
|
89
95
|
|
@@ -151,7 +157,7 @@ module Ronin
|
|
151
157
|
end
|
152
158
|
end
|
153
159
|
|
154
|
-
return ext_names
|
160
|
+
return ext_names.sort
|
155
161
|
end
|
156
162
|
|
157
163
|
#
|
@@ -219,7 +225,7 @@ module Ronin
|
|
219
225
|
#
|
220
226
|
def update(&block)
|
221
227
|
overlays.each do |overlay|
|
222
|
-
overlay.
|
228
|
+
overlay.deactivate!
|
223
229
|
overlay.update(&block)
|
224
230
|
overlay.active!
|
225
231
|
end
|
@@ -243,7 +249,7 @@ module Ronin
|
|
243
249
|
name = name.to_s
|
244
250
|
|
245
251
|
overlay = get(name)
|
246
|
-
overlay.
|
252
|
+
overlay.deactivate!
|
247
253
|
|
248
254
|
delete_if { |key,value| key == name }
|
249
255
|
dirty!
|
data/lib/ronin/product.rb
CHANGED
@@ -45,14 +45,31 @@ module Ronin
|
|
45
45
|
# Validates
|
46
46
|
validates_present :name, :version
|
47
47
|
|
48
|
+
#
|
49
|
+
# Creates a new Product object with the given _attributes_.
|
50
|
+
#
|
51
|
+
# _attributes_ must contain the following keys:
|
52
|
+
# <tt>:name</tt>:: The name of the product.
|
53
|
+
# <tt>:vendor</tt>:: The vendor of the product. Will default to the
|
54
|
+
# product name, if not given.
|
55
|
+
#
|
56
|
+
# _attributes_ may contain the following keys:
|
57
|
+
# <tt>:version</tt>:: The version of the product.
|
58
|
+
#
|
59
|
+
def initialize(attributes={})
|
60
|
+
attributes[:vendor] ||= attributes[:name]
|
61
|
+
|
62
|
+
super(attributes)
|
63
|
+
end
|
64
|
+
|
48
65
|
#
|
49
66
|
# Returns the String form of the product.
|
50
67
|
#
|
51
68
|
def to_s
|
52
|
-
unless
|
53
|
-
return "#{
|
69
|
+
unless self.vendor == self.name
|
70
|
+
return "#{self.vendor} #{self.name} #{self.version}"
|
54
71
|
else
|
55
|
-
return "#{
|
72
|
+
return "#{self.name} #{self.version}"
|
56
73
|
end
|
57
74
|
end
|
58
75
|
|
data/lib/ronin/ronin.rb
CHANGED
@@ -21,24 +21,9 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/objectify'
|
25
24
|
require 'ronin/ui/console'
|
26
25
|
|
27
26
|
module Ronin
|
28
|
-
#
|
29
|
-
# See Objectify.load_objects.
|
30
|
-
#
|
31
|
-
def Ronin.load_objects(path)
|
32
|
-
Objectify.load_objects(path)
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# See Objectify.load_object.
|
37
|
-
#
|
38
|
-
def Ronin.load_object(type,path)
|
39
|
-
Objectify.load_object(type,path)
|
40
|
-
end
|
41
|
-
|
42
27
|
#
|
43
28
|
# Starts Ronin's console with the given _script_. If a _block_ is given
|
44
29
|
# it will be ran within the console.
|