ronin 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/lib/ronin/static.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/static/static'
|
data/lib/ronin/static/finders.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/static/static'
|
data/lib/ronin/static/static.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 'set'
|
|
@@ -26,20 +23,32 @@ require 'set'
|
|
|
26
23
|
module Ronin
|
|
27
24
|
module Static
|
|
28
25
|
#
|
|
29
|
-
#
|
|
26
|
+
# @return [Set]
|
|
27
|
+
# The directories which contain static content.
|
|
30
28
|
#
|
|
31
29
|
def Static.static_dirs
|
|
32
30
|
@@ronin_static_dirs ||= Set[]
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
#
|
|
36
|
-
# Adds the
|
|
34
|
+
# Adds the path to the Set of static directories.
|
|
35
|
+
#
|
|
36
|
+
# @param [String] path
|
|
37
|
+
# The path to add to +static_dirs+.
|
|
38
|
+
#
|
|
39
|
+
# @return [String]
|
|
40
|
+
# The fully qualified form of the specified _path_.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# Static.directory(File.join(File.dirname(__FILE__),'..','..','..','static'))
|
|
44
|
+
#
|
|
45
|
+
# @raise [RuntimeError] The specified _path_ is not a directory.
|
|
37
46
|
#
|
|
38
47
|
def Static.directory(path)
|
|
39
48
|
path = File.expand_path(path)
|
|
40
49
|
|
|
41
50
|
unless File.directory?(path)
|
|
42
|
-
raise("#{path.dump} must be a directory")
|
|
51
|
+
raise(RuntimeError,"#{path.dump} must be a directory")
|
|
43
52
|
end
|
|
44
53
|
|
|
45
54
|
Static.static_dirs << path
|
data/lib/ronin/templates.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,7 @@
|
|
|
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
|
|
|
21
|
+
require 'ronin/templates/template'
|
|
24
22
|
require 'ronin/templates/erb'
|
data/lib/ronin/templates/erb.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,18 +16,26 @@
|
|
|
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
|
|
|
21
|
+
require 'ronin/templates/template'
|
|
22
|
+
|
|
24
23
|
require 'erb'
|
|
25
24
|
|
|
26
25
|
module Ronin
|
|
27
26
|
module Templates
|
|
28
27
|
module Erb
|
|
28
|
+
include Template
|
|
29
|
+
#
|
|
30
|
+
# Renders the inline ERB template in the scope of the object.
|
|
31
|
+
#
|
|
32
|
+
# @param [String] template
|
|
33
|
+
# Source of the ERB template.
|
|
29
34
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
# Result of the rendered template.
|
|
32
37
|
#
|
|
38
|
+
# @example
|
|
33
39
|
# @user = 'lolcats'
|
|
34
40
|
#
|
|
35
41
|
# erb %{
|
|
@@ -43,13 +49,21 @@ module Ronin
|
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
#
|
|
46
|
-
# Renders
|
|
47
|
-
#
|
|
52
|
+
# Renders an ERB template file in the scope of the object.
|
|
53
|
+
#
|
|
54
|
+
# @param [String] template_path
|
|
55
|
+
# The relative path of the ERB template.
|
|
56
|
+
#
|
|
57
|
+
# @return [String]
|
|
58
|
+
# Result of the rendered template.
|
|
48
59
|
#
|
|
60
|
+
# @example
|
|
49
61
|
# erb_file 'path/to/template.erb'
|
|
50
62
|
#
|
|
51
|
-
def erb_file(
|
|
52
|
-
|
|
63
|
+
def erb_file(template_path)
|
|
64
|
+
enter_template(template_path) do |path|
|
|
65
|
+
erb(File.read(path))
|
|
66
|
+
end
|
|
53
67
|
end
|
|
54
68
|
end
|
|
55
69
|
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with this program; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/static/finders'
|
|
22
|
+
|
|
23
|
+
module Ronin
|
|
24
|
+
module Templates
|
|
25
|
+
module Template
|
|
26
|
+
include Static::Finders
|
|
27
|
+
|
|
28
|
+
protected
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# A stack of directories to search for other templates within.
|
|
32
|
+
#
|
|
33
|
+
# @return [Array]
|
|
34
|
+
# The stack of directory paths.
|
|
35
|
+
#
|
|
36
|
+
# @since 0.3.0
|
|
37
|
+
#
|
|
38
|
+
def template_dirs
|
|
39
|
+
@template_dirs ||= []
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# The first path in +template_dirs+, that will be used to search for
|
|
44
|
+
# other templates in.
|
|
45
|
+
#
|
|
46
|
+
# @return [String, nil]
|
|
47
|
+
# Returns the first path in template_dirs, or +nil+ if
|
|
48
|
+
# template_dirs is empty.
|
|
49
|
+
#
|
|
50
|
+
# @since 0.3.0
|
|
51
|
+
#
|
|
52
|
+
def template_dir
|
|
53
|
+
template_dirs.first
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Finds the template within the +template_dir+ or uses
|
|
58
|
+
# Static::Finders#find_static_file to search through all
|
|
59
|
+
# +static+ directories for the template.
|
|
60
|
+
#
|
|
61
|
+
# @param [String] sub_path
|
|
62
|
+
# The relative path of the template to find.
|
|
63
|
+
#
|
|
64
|
+
# @return [String, nil]
|
|
65
|
+
# Returns the absolute path to the template, or +nil+ if the
|
|
66
|
+
# template could not be found.
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# find_template 'sub/path/template.erb'
|
|
70
|
+
#
|
|
71
|
+
# @since 0.3.0
|
|
72
|
+
#
|
|
73
|
+
def find_template(sub_path)
|
|
74
|
+
sub_path = sub_path.to_s
|
|
75
|
+
|
|
76
|
+
if template_dir
|
|
77
|
+
path = File.expand_path(File.join(template_dir,sub_path))
|
|
78
|
+
|
|
79
|
+
return path if File.file?(path)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
return find_static_file(sub_path)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Finds the template, pushing the directory that the template resides
|
|
87
|
+
# within to +template_dirs+, calls the given _block_ and then pops
|
|
88
|
+
# the directory off of +template_dirs+.
|
|
89
|
+
#
|
|
90
|
+
# @param [String] sub_path
|
|
91
|
+
# The relative path of the template to find.
|
|
92
|
+
#
|
|
93
|
+
# @yield [path]
|
|
94
|
+
# The block to be called after the directory of the template has
|
|
95
|
+
# been pushed onto +template_dirs+. After the block has returned,
|
|
96
|
+
# the directory will be popped off of +template_dirs+.
|
|
97
|
+
#
|
|
98
|
+
# @yieldparam [String] path
|
|
99
|
+
# The absolute path of the template.
|
|
100
|
+
#
|
|
101
|
+
# @return [Object]
|
|
102
|
+
# Result of the given block.
|
|
103
|
+
#
|
|
104
|
+
# @raise [RuntimeError]
|
|
105
|
+
# The template was not found.
|
|
106
|
+
#
|
|
107
|
+
# @example
|
|
108
|
+
# enter_template('sub/path/template.erb') do |path|
|
|
109
|
+
# # do stuff with the full path
|
|
110
|
+
# end
|
|
111
|
+
#
|
|
112
|
+
# @since 0.3.0
|
|
113
|
+
#
|
|
114
|
+
def enter_template(sub_path,&block)
|
|
115
|
+
sub_path = sub_path.to_s
|
|
116
|
+
|
|
117
|
+
unless (path = find_template(sub_path))
|
|
118
|
+
raise(RuntimeError,"could not find template #{sub_path.dump}",caller)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
template_dirs.unshift(File.dirname(path))
|
|
122
|
+
|
|
123
|
+
result = block.call(path)
|
|
124
|
+
|
|
125
|
+
template_dirs.shift
|
|
126
|
+
return result
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
data/lib/ronin/ui.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,11 +16,9 @@
|
|
|
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
|
-
require 'ronin/ui/
|
|
25
|
-
require 'ronin/ui/diagnostics'
|
|
21
|
+
require 'ronin/ui/output'
|
|
26
22
|
require 'ronin/ui/hexdump'
|
|
27
23
|
require 'ronin/ui/console'
|
|
28
24
|
require 'ronin/ui/shell'
|
|
@@ -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/ui/command_line/command'
|
|
@@ -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,127 +16,198 @@
|
|
|
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
|
-
require 'ronin/ui/
|
|
21
|
+
require 'ronin/ui/output'
|
|
22
|
+
|
|
23
|
+
require 'thor'
|
|
24
|
+
require 'extlib'
|
|
25
25
|
|
|
26
26
|
module Ronin
|
|
27
27
|
module UI
|
|
28
28
|
module CommandLine
|
|
29
|
-
class Command
|
|
29
|
+
class Command < Thor
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
include Thor::Actions
|
|
32
|
+
include Output::Helpers
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
default_task :default
|
|
35
|
+
map '-h' => :help
|
|
36
36
|
|
|
37
37
|
#
|
|
38
38
|
# Creates a new Command object.
|
|
39
39
|
#
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
# @param [Array] arguments
|
|
41
|
+
# Command-line arguments.
|
|
42
|
+
#
|
|
43
|
+
# @param [Hash] options
|
|
44
|
+
# Additional command-line options.
|
|
45
|
+
#
|
|
46
|
+
# @param [Hash] config
|
|
47
|
+
# Additional configuration.
|
|
48
|
+
#
|
|
49
|
+
def initialize(arguments=[],options={},config={})
|
|
50
|
+
@indent = 0
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
super(arguments,options,config)
|
|
53
|
+
end
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
def self.start(arguments=ARGV,config={})
|
|
56
|
+
unless map[arguments.first.to_s]
|
|
57
|
+
arguments = [default_task] + arguments
|
|
49
58
|
end
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
super(arguments,config)
|
|
52
61
|
end
|
|
53
62
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
name.gsub!(/^ronin-/,'')
|
|
63
|
+
no_tasks do
|
|
64
|
+
def invoke(task,arguments)
|
|
65
|
+
UI::Output.verbose = options.verbose?
|
|
66
|
+
UI::Output.quiet = options.quiet?
|
|
67
|
+
UI::Output.silent = options.silent?
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
if options.nocolor?
|
|
70
|
+
UI::Output::Handler.color = false
|
|
71
|
+
end
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
cmd.arguments(*(cmd.options.parse(args)))
|
|
65
|
-
rescue OptionParser::MissingArgument,
|
|
66
|
-
OptionParser::InvalidOption => e
|
|
67
|
-
STDERR.puts e
|
|
68
|
-
exit -1
|
|
73
|
+
super(task,arguments)
|
|
69
74
|
end
|
|
70
|
-
|
|
71
|
-
return true
|
|
72
75
|
end
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
desc "command [ARGS...]", "default task to run"
|
|
78
|
+
method_option :verbose, :type => :boolean, :default => false, :aliases => '-v'
|
|
79
|
+
method_option :quiet, :type => :boolean, :default => true, :aliases => '-q'
|
|
80
|
+
method_option :silent, :type => :boolean, :default => true, :aliases => '-Q'
|
|
81
|
+
method_option :color, :type => :boolean, :default => true
|
|
82
|
+
method_option :nocolor, :type => :boolean, :default => false
|
|
80
83
|
|
|
81
84
|
#
|
|
82
|
-
#
|
|
85
|
+
# Default method to call after the options have been parsed.
|
|
83
86
|
#
|
|
84
|
-
def
|
|
85
|
-
@options.help
|
|
86
|
-
return self
|
|
87
|
+
def default(*arguments)
|
|
87
88
|
end
|
|
88
89
|
|
|
90
|
+
desc "help", "displays the help for the command"
|
|
91
|
+
|
|
89
92
|
#
|
|
90
|
-
#
|
|
93
|
+
# Prints the help information for the command and exists.
|
|
91
94
|
#
|
|
92
|
-
def
|
|
93
|
-
|
|
95
|
+
def help
|
|
96
|
+
self.class.help(
|
|
97
|
+
shell,
|
|
98
|
+
self.class.default_task,
|
|
99
|
+
:short => false,
|
|
100
|
+
:ident => 2,
|
|
101
|
+
:namespace => false
|
|
102
|
+
)
|
|
94
103
|
end
|
|
95
104
|
|
|
96
105
|
protected
|
|
97
106
|
|
|
98
107
|
#
|
|
99
|
-
#
|
|
108
|
+
# Returns the name of the command.
|
|
100
109
|
#
|
|
101
|
-
def
|
|
102
|
-
|
|
103
|
-
return false
|
|
110
|
+
def name
|
|
111
|
+
self.class.name.split('::').last.snake_case
|
|
104
112
|
end
|
|
105
113
|
|
|
106
114
|
#
|
|
107
|
-
#
|
|
115
|
+
# Increases the indentation out output temporarily.
|
|
108
116
|
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
# @param [Integer] n
|
|
118
|
+
# The number of spaces to increase the indentation by.
|
|
119
|
+
#
|
|
120
|
+
# @yield []
|
|
121
|
+
# The block will be called after the indentation has been
|
|
122
|
+
# increased. After the block has returned, the indentation will
|
|
123
|
+
# be returned to normal.
|
|
124
|
+
#
|
|
125
|
+
# @return [nil]
|
|
126
|
+
#
|
|
127
|
+
def indent(n=2,&block)
|
|
128
|
+
@indent += n
|
|
129
|
+
|
|
130
|
+
block.call()
|
|
131
|
+
|
|
132
|
+
@indent -= n
|
|
133
|
+
return nil
|
|
112
134
|
end
|
|
113
135
|
|
|
114
136
|
#
|
|
115
|
-
#
|
|
116
|
-
# command-line utility. If a _block_ is given, it will be called before
|
|
117
|
-
# any error _message_ are printed.
|
|
137
|
+
# Print the given messages with indentation.
|
|
118
138
|
#
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
# @param [Array] messages
|
|
140
|
+
# The messages to print, one per-line.
|
|
141
|
+
#
|
|
142
|
+
def puts(*messages)
|
|
143
|
+
super(*(messages.map { |mesg| (' ' * @indent) + mesg.to_s }))
|
|
124
144
|
end
|
|
125
145
|
|
|
126
146
|
#
|
|
127
|
-
#
|
|
147
|
+
# Prints a given title.
|
|
128
148
|
#
|
|
129
|
-
|
|
149
|
+
# @param [String] title
|
|
150
|
+
# The title to print.
|
|
151
|
+
#
|
|
152
|
+
def print_title(title)
|
|
153
|
+
puts "[ #{title} ]"
|
|
130
154
|
end
|
|
131
155
|
|
|
132
156
|
#
|
|
133
|
-
#
|
|
157
|
+
# Prints a given Array.
|
|
158
|
+
#
|
|
159
|
+
# @param [Array] array
|
|
160
|
+
# The Array to print.
|
|
134
161
|
#
|
|
135
|
-
|
|
162
|
+
# @param [Hash] options
|
|
163
|
+
# Additional options.
|
|
164
|
+
#
|
|
165
|
+
# @option options [String] :title
|
|
166
|
+
# The optional title to print before the contents of the Array.
|
|
167
|
+
#
|
|
168
|
+
# @return [nil]
|
|
169
|
+
#
|
|
170
|
+
def print_array(array,options={})
|
|
171
|
+
print_title(options[:title]) if options[:title]
|
|
172
|
+
|
|
173
|
+
indent do
|
|
174
|
+
array.each { |value| puts value }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
puts "\n" if options[:title]
|
|
178
|
+
return nil
|
|
136
179
|
end
|
|
137
180
|
|
|
138
181
|
#
|
|
139
|
-
#
|
|
182
|
+
# Prints a given Hash.
|
|
183
|
+
#
|
|
184
|
+
# @param [Hash] hash
|
|
185
|
+
# The Hash to print.
|
|
186
|
+
#
|
|
187
|
+
# @param [Hash] options
|
|
188
|
+
# Additional options.
|
|
189
|
+
#
|
|
190
|
+
# @option options [String] :title
|
|
191
|
+
# The optional title to print before the contents of the Hash.
|
|
192
|
+
#
|
|
193
|
+
# @return [nil]
|
|
140
194
|
#
|
|
141
|
-
def
|
|
195
|
+
def print_hash(hash,options={})
|
|
196
|
+
align = hash.keys.map { |name|
|
|
197
|
+
name.to_s.length
|
|
198
|
+
}.max
|
|
199
|
+
|
|
200
|
+
print_title(options[:title]) if options[:title]
|
|
201
|
+
|
|
202
|
+
indent do
|
|
203
|
+
hash.each do |name,value|
|
|
204
|
+
name = "#{name}:".ljust(align)
|
|
205
|
+
puts "#{name}\t#{value}"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
puts "\n" if options[:title]
|
|
210
|
+
return nil
|
|
142
211
|
end
|
|
143
212
|
|
|
144
213
|
end
|