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
data/bin/ronin
CHANGED
data/bin/ronin-add
CHANGED
data/bin/ronin-console
CHANGED
data/bin/ronin-help
CHANGED
data/bin/ronin-install
CHANGED
data/bin/ronin-list
CHANGED
data/bin/ronin-remove
CHANGED
data/bin/ronin-uninstall
CHANGED
data/bin/ronin-update
CHANGED
data/lib/ronin.rb
CHANGED
@@ -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,8 +16,8 @@
|
|
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/environment'
|
22
|
+
require 'ronin/platform'
|
25
23
|
require 'ronin/version'
|
data/lib/ronin/arch.rb
CHANGED
@@ -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/extensions/meta'
|
@@ -54,34 +51,82 @@ module Ronin
|
|
54
51
|
validates_is_number :address_length
|
55
52
|
|
56
53
|
#
|
57
|
-
#
|
54
|
+
# Converts the architecture to a String.
|
55
|
+
#
|
56
|
+
# @return [String]
|
57
|
+
# The name of the architecture.
|
58
58
|
#
|
59
59
|
def to_s
|
60
|
-
|
60
|
+
self.name.to_s
|
61
61
|
end
|
62
62
|
|
63
63
|
#
|
64
64
|
# Defines a new builtin Arch with the specified _name_ and the given
|
65
65
|
# _options_.
|
66
66
|
#
|
67
|
-
|
67
|
+
# @param [Symbol, String] name
|
68
|
+
# The name of the architecture.
|
69
|
+
#
|
70
|
+
# @param [Hash] options
|
71
|
+
# Additional options.
|
72
|
+
#
|
73
|
+
# @option options [Symbol, String] :endian
|
74
|
+
# The endianness of the architecture.
|
75
|
+
#
|
76
|
+
# @option options [Integer] :address_length
|
77
|
+
# The address-length of the architecture.
|
78
|
+
#
|
79
|
+
# @example Defining a builtin Arch
|
80
|
+
# Arch.predefine :alpha, :endian => :big, :address_length => 8
|
81
|
+
#
|
82
|
+
# @example Retrieving a predefined Arch
|
83
|
+
# Arch.alpha
|
84
|
+
#
|
85
|
+
def self.predefine(name,options={})
|
68
86
|
super(name,options.merge(:name => name))
|
69
87
|
end
|
70
88
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
# The i386 Architecture
|
90
|
+
predefine :i386, :endian => :little, :address_length => 4
|
91
|
+
|
92
|
+
# The i486 Architecture
|
93
|
+
predefine :i486, :endian => :little, :address_length => 4
|
94
|
+
|
95
|
+
# The i686 Architecture
|
96
|
+
predefine :i686, :endian => :little, :address_length => 4
|
97
|
+
|
98
|
+
# The i986 Architecture
|
99
|
+
predefine :i986, :endian => :little, :address_length => 4
|
100
|
+
|
101
|
+
# The x86_64 Architecture
|
102
|
+
predefine :x86_64, :endian => :little, :address_length => 8
|
103
|
+
|
104
|
+
# The ia64 Architecture
|
105
|
+
predefine :ia64, :endian => :little, :address_length => 8
|
106
|
+
|
107
|
+
# The 32-bit PowerPC Architecture
|
108
|
+
predefine :ppc, :endian => :big, :address_length => 4
|
109
|
+
|
110
|
+
# The 64-bit PowerPC Architecture
|
111
|
+
predefine :ppc64, :endian => :big, :address_length => 8
|
112
|
+
|
113
|
+
# The 32-bit SPARC Architecture
|
114
|
+
predefine :sparc, :endian => :big, :address_length => 4
|
115
|
+
|
116
|
+
# The 64-bit SPARC Architecture
|
117
|
+
predefine :sparc64, :endian => :big, :address_length => 8
|
118
|
+
|
119
|
+
# The MIPS (little-endian) Architecture
|
120
|
+
predefine :mips_le, :endian => :little, :address_length => 4
|
121
|
+
|
122
|
+
# The MIPS (big-endian) Architecture
|
123
|
+
predefine :mips_be, :endian => :big, :address_length => 4
|
124
|
+
|
125
|
+
# The ARM (little-endian) Architecture
|
126
|
+
predefine :arm_le, :endian => :little, :address_length => 4
|
127
|
+
|
128
|
+
# The ARM (big-endian) Architecture
|
129
|
+
predefine :arm_be, :endian => :big, :address_length => 4
|
85
130
|
|
86
131
|
end
|
87
132
|
end
|
data/lib/ronin/author.rb
CHANGED
@@ -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/model'
|
@@ -32,7 +29,7 @@ module Ronin
|
|
32
29
|
include Model
|
33
30
|
|
34
31
|
# Anonymouse author name
|
35
|
-
ANONYMOUSE = '
|
32
|
+
ANONYMOUSE = 'Anonymous'
|
36
33
|
|
37
34
|
# Primary key of the author
|
38
35
|
property :id, Serial
|
@@ -59,13 +56,26 @@ module Ronin
|
|
59
56
|
# Creates a new Author object with the given _options_. If _block_ is
|
60
57
|
# given, it will be passed the newly created Author object.
|
61
58
|
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
59
|
+
# @param [Hash] options
|
60
|
+
# Additional options.
|
61
|
+
#
|
62
|
+
# @option options [String] :name (ANONYMOUSE)
|
63
|
+
# The name of the author.
|
64
|
+
#
|
65
|
+
# @option options [String] :organization
|
66
|
+
# The organization the author belongs to.
|
67
|
+
#
|
68
|
+
# @option options [String] :pgp_signature
|
69
|
+
# The PGP fingerprint of the author.
|
70
|
+
#
|
71
|
+
# @option options [String] :email
|
72
|
+
# The email to contact the author.
|
73
|
+
#
|
74
|
+
# @option options [String] :url
|
75
|
+
# The URL of the author.
|
76
|
+
#
|
77
|
+
# @option options [String] :biography
|
78
|
+
# The biography of the author.
|
69
79
|
#
|
70
80
|
def initialize(options={},&block)
|
71
81
|
super(options)
|
@@ -73,15 +83,14 @@ module Ronin
|
|
73
83
|
block.call(self) if block
|
74
84
|
end
|
75
85
|
|
76
|
-
def name
|
77
|
-
@name || ANONYMOUSE
|
78
|
-
end
|
79
|
-
|
80
86
|
#
|
81
|
-
#
|
87
|
+
# Converts the author to a String.
|
88
|
+
#
|
89
|
+
# @return [String]
|
90
|
+
# The name of the author.
|
82
91
|
#
|
83
92
|
def to_s
|
84
|
-
|
93
|
+
self.name.to_s
|
85
94
|
end
|
86
95
|
|
87
96
|
end
|
data/lib/ronin/cacheable.rb
CHANGED
@@ -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/model'
|
@@ -102,13 +99,32 @@ module Ronin
|
|
102
99
|
end
|
103
100
|
|
104
101
|
#
|
105
|
-
# Loads the first object with
|
102
|
+
# Loads the first object with matching attributes.
|
106
103
|
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
# @param [Hash] attributes
|
105
|
+
# Attributes to search for.
|
106
|
+
#
|
107
|
+
# @yield [objs]
|
108
|
+
# If a block is given, it will be passed all matching
|
109
|
+
# objects to be filtered down. The first object from the filtered
|
110
|
+
# objects will end up being selected.
|
111
|
+
#
|
112
|
+
# @yieldparam [Array<Cacheable>] objs
|
113
|
+
# All matching objects.
|
114
|
+
#
|
115
|
+
# @return [Cacheable]
|
116
|
+
# The loaded cached objects.
|
117
|
+
#
|
118
|
+
def self.load_first(attributes={},&block)
|
119
|
+
obj = if block
|
120
|
+
objs = self.all(attributes)
|
121
|
+
|
122
|
+
(block.call(objs) || objs).first
|
123
|
+
else
|
124
|
+
self.first(attributes)
|
125
|
+
end
|
111
126
|
|
127
|
+
obj.load_original! if obj
|
112
128
|
return obj
|
113
129
|
end
|
114
130
|
end
|
@@ -119,15 +135,27 @@ module Ronin
|
|
119
135
|
end
|
120
136
|
|
121
137
|
#
|
122
|
-
#
|
138
|
+
# @return [Array]
|
139
|
+
# List of cacheable models.
|
123
140
|
#
|
124
141
|
def Cacheable.models
|
125
142
|
@@ronin_cacheable_models ||= []
|
126
143
|
end
|
127
144
|
|
128
145
|
#
|
129
|
-
# Loads all cacheable objects from the specified _path_.
|
130
|
-
#
|
146
|
+
# Loads all cacheable objects from the specified _path_.
|
147
|
+
#
|
148
|
+
# @param [String] path
|
149
|
+
# The path to load the objects from.
|
150
|
+
#
|
151
|
+
# @yield [obj]
|
152
|
+
# If a block is given, it will be passed each loaded object.
|
153
|
+
#
|
154
|
+
# @yieldparam [Cacheable] obj
|
155
|
+
# An object loaded from the specified _path_.
|
156
|
+
#
|
157
|
+
# @return [Array]
|
158
|
+
# All objects loaded from the specified _path_.
|
131
159
|
#
|
132
160
|
def Cacheable.load_all_from(path,&block)
|
133
161
|
path = File.expand_path(path)
|
@@ -148,7 +176,10 @@ module Ronin
|
|
148
176
|
end
|
149
177
|
|
150
178
|
#
|
151
|
-
# Cache all objects defined in
|
179
|
+
# Cache all objects defined in a file.
|
180
|
+
#
|
181
|
+
# @param [String] path
|
182
|
+
# The path to cache all objects from.
|
152
183
|
#
|
153
184
|
def Cacheable.cache_all(path)
|
154
185
|
path = File.expand_path(path)
|
@@ -159,15 +190,17 @@ module Ronin
|
|
159
190
|
end
|
160
191
|
|
161
192
|
#
|
162
|
-
#
|
163
|
-
#
|
193
|
+
# @return [Boolean]
|
194
|
+
# Specifies whether the original code has been loaded into the
|
195
|
+
# object.
|
164
196
|
#
|
165
197
|
def original_loaded?
|
166
198
|
@original_loaded == true
|
167
199
|
end
|
168
200
|
|
169
201
|
#
|
170
|
-
#
|
202
|
+
# Loads the code from the cached file for the object, and instance evals
|
203
|
+
# it into the object.
|
171
204
|
#
|
172
205
|
def load_original!
|
173
206
|
if (self.cached_path && !(@original_loaded))
|
@@ -182,8 +215,10 @@ module Ronin
|
|
182
215
|
|
183
216
|
#
|
184
217
|
# Deletes any previously cached copies of the object and caches it into
|
185
|
-
# the database.
|
186
|
-
#
|
218
|
+
# the database.
|
219
|
+
#
|
220
|
+
# @return [Boolean]
|
221
|
+
# Specifies whether the object was successfully cached,
|
187
222
|
#
|
188
223
|
def cache!
|
189
224
|
if self.cached_path
|
@@ -201,9 +236,10 @@ module Ronin
|
|
201
236
|
# Deletes any previous cached copies of the object and caches it into
|
202
237
|
# the database, only if the file where the object was originally cached
|
203
238
|
# from was modified. The object will also be destroyed if the file
|
204
|
-
# where the object was originally cached from is missing.
|
205
|
-
#
|
206
|
-
#
|
239
|
+
# where the object was originally cached from is missing.
|
240
|
+
#
|
241
|
+
# @return [Boolean]
|
242
|
+
# Specifies whether the object was successfully synced.
|
207
243
|
#
|
208
244
|
def sync!
|
209
245
|
if (self.cached_path && self.cached_timestamp)
|
@@ -224,8 +260,8 @@ module Ronin
|
|
224
260
|
end
|
225
261
|
|
226
262
|
#
|
227
|
-
#
|
228
|
-
#
|
263
|
+
# @return [Boolean]
|
264
|
+
# Specifies whether the object has been prepared to be cached,
|
229
265
|
#
|
230
266
|
def prepared_for_cache?
|
231
267
|
@cache_prepared == true
|
@@ -246,6 +282,10 @@ module Ronin
|
|
246
282
|
#
|
247
283
|
# Will run the specified _block_ when the object is about to be cached.
|
248
284
|
#
|
285
|
+
# @yield []
|
286
|
+
# The block will be ran inside the object when the object is to be
|
287
|
+
# prepared for caching.
|
288
|
+
#
|
249
289
|
def cache(&block)
|
250
290
|
@cache_block = block
|
251
291
|
end
|
data/lib/ronin/code/emittable.rb
CHANGED
@@ -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
|
module Ronin
|