ronin 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +95 -0
  3. data/Manifest.txt +55 -25
  4. data/README.txt +64 -52
  5. data/Rakefile +21 -14
  6. data/bin/ronin +1 -1
  7. data/bin/ronin-add +1 -1
  8. data/bin/ronin-console +1 -1
  9. data/bin/ronin-help +1 -1
  10. data/bin/ronin-install +1 -1
  11. data/bin/ronin-list +1 -1
  12. data/bin/ronin-remove +1 -1
  13. data/bin/ronin-uninstall +1 -1
  14. data/bin/ronin-update +1 -1
  15. data/lib/ronin.rb +2 -4
  16. data/lib/ronin/arch.rb +66 -21
  17. data/lib/ronin/author.rb +27 -18
  18. data/lib/ronin/cacheable.rb +63 -23
  19. data/lib/ronin/code/emittable.rb +1 -4
  20. data/lib/ronin/code/reference.rb +2 -5
  21. data/lib/ronin/code/symbol_table.rb +1 -4
  22. data/lib/ronin/code/token.rb +1 -4
  23. data/lib/ronin/config.rb +31 -10
  24. data/lib/ronin/database.rb +1 -4
  25. data/lib/ronin/database/database.rb +42 -23
  26. data/lib/ronin/database/exceptions.rb +1 -4
  27. data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
  28. data/lib/ronin/environment.rb +1 -5
  29. data/lib/ronin/extensions.rb +1 -5
  30. data/lib/ronin/extensions/array.rb +8 -6
  31. data/lib/ronin/extensions/file.rb +9 -4
  32. data/lib/ronin/extensions/ip_addr.rb +33 -13
  33. data/lib/ronin/extensions/kernel.rb +44 -9
  34. data/lib/ronin/extensions/meta.rb +1 -4
  35. data/lib/ronin/extensions/string.rb +8 -7
  36. data/lib/ronin/extensions/uri.rb +1 -4
  37. data/lib/ronin/extensions/uri/http.rb +1 -48
  38. data/lib/ronin/extensions/uri/query_params.rb +27 -8
  39. data/lib/ronin/formatting.rb +1 -4
  40. data/lib/ronin/formatting/binary.rb +1 -4
  41. data/lib/ronin/formatting/digest.rb +1 -4
  42. data/lib/ronin/formatting/extensions.rb +1 -4
  43. data/lib/ronin/formatting/extensions/binary.rb +1 -4
  44. data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
  45. data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
  46. data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
  47. data/lib/ronin/formatting/extensions/digest.rb +1 -4
  48. data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
  49. data/lib/ronin/formatting/extensions/http.rb +1 -4
  50. data/lib/ronin/formatting/extensions/http/string.rb +16 -9
  51. data/lib/ronin/formatting/extensions/text.rb +1 -4
  52. data/lib/ronin/formatting/extensions/text/array.rb +17 -7
  53. data/lib/ronin/formatting/extensions/text/string.rb +70 -27
  54. data/lib/ronin/formatting/http.rb +1 -4
  55. data/lib/ronin/formatting/text.rb +1 -4
  56. data/lib/ronin/license.rb +72 -65
  57. data/lib/ronin/model.rb +1 -4
  58. data/lib/ronin/model/has_description.rb +37 -8
  59. data/lib/ronin/model/has_license.rb +12 -8
  60. data/lib/ronin/model/has_name.rb +10 -7
  61. data/lib/ronin/model/has_version.rb +14 -4
  62. data/lib/ronin/model/model.rb +71 -14
  63. data/lib/ronin/network.rb +1 -4
  64. data/lib/ronin/network/esmtp.rb +1 -4
  65. data/lib/ronin/network/extensions.rb +1 -4
  66. data/lib/ronin/network/extensions/esmtp.rb +1 -4
  67. data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
  68. data/lib/ronin/network/extensions/http.rb +1 -4
  69. data/lib/ronin/network/extensions/http/net.rb +319 -531
  70. data/lib/ronin/network/extensions/imap.rb +1 -4
  71. data/lib/ronin/network/extensions/imap/net.rb +50 -23
  72. data/lib/ronin/network/extensions/pop3.rb +1 -4
  73. data/lib/ronin/network/extensions/pop3/net.rb +40 -17
  74. data/lib/ronin/network/extensions/smtp.rb +1 -4
  75. data/lib/ronin/network/extensions/smtp/net.rb +49 -21
  76. data/lib/ronin/network/extensions/tcp.rb +1 -4
  77. data/lib/ronin/network/extensions/tcp/net.rb +234 -31
  78. data/lib/ronin/network/extensions/telnet.rb +1 -4
  79. data/lib/ronin/network/extensions/telnet/net.rb +83 -51
  80. data/lib/ronin/network/extensions/udp.rb +1 -4
  81. data/lib/ronin/network/extensions/udp/net.rb +164 -27
  82. data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
  83. data/lib/ronin/network/helpers/esmtp.rb +129 -0
  84. data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
  85. data/lib/ronin/network/helpers/http.rb +444 -0
  86. data/lib/ronin/network/helpers/imap.rb +115 -0
  87. data/lib/ronin/network/helpers/pop3.rb +110 -0
  88. data/lib/ronin/network/helpers/smtp.rb +123 -0
  89. data/lib/ronin/network/helpers/tcp.rb +309 -0
  90. data/lib/ronin/network/helpers/telnet.rb +158 -0
  91. data/lib/ronin/network/helpers/udp.rb +197 -0
  92. data/lib/ronin/network/http.rb +3 -156
  93. data/lib/ronin/network/http/exceptions.rb +1 -4
  94. data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
  95. data/lib/ronin/network/http/http.rb +214 -0
  96. data/lib/ronin/network/http/proxy.rb +308 -0
  97. data/lib/ronin/network/imap.rb +7 -6
  98. data/lib/ronin/network/pop3.rb +7 -6
  99. data/lib/ronin/network/smtp.rb +1 -4
  100. data/lib/ronin/network/smtp/email.rb +34 -18
  101. data/lib/ronin/network/smtp/smtp.rb +19 -7
  102. data/lib/ronin/network/tcp.rb +1 -4
  103. data/lib/ronin/network/telnet.rb +25 -12
  104. data/lib/ronin/network/udp.rb +1 -4
  105. data/lib/ronin/os.rb +43 -21
  106. data/lib/ronin/path.rb +29 -9
  107. data/lib/ronin/platform.rb +1 -4
  108. data/lib/ronin/platform/exceptions.rb +1 -4
  109. data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
  110. data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
  111. data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
  112. data/lib/ronin/platform/extension.rb +195 -52
  113. data/lib/ronin/platform/extension_cache.rb +60 -24
  114. data/lib/ronin/platform/maintainer.rb +15 -8
  115. data/lib/ronin/platform/object_cache.rb +29 -8
  116. data/lib/ronin/platform/overlay.rb +82 -26
  117. data/lib/ronin/platform/overlay_cache.rb +179 -56
  118. data/lib/ronin/platform/platform.rb +154 -58
  119. data/lib/ronin/platform/ronin.rb +38 -11
  120. data/lib/ronin/product.rb +17 -17
  121. data/lib/ronin/rpc.rb +1 -4
  122. data/lib/ronin/rpc/call.rb +1 -4
  123. data/lib/ronin/rpc/client.rb +1 -4
  124. data/lib/ronin/rpc/console.rb +1 -4
  125. data/lib/ronin/rpc/exceptions.rb +1 -4
  126. data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
  127. data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
  128. data/lib/ronin/rpc/response.rb +1 -4
  129. data/lib/ronin/rpc/service.rb +1 -4
  130. data/lib/ronin/rpc/shell.rb +1 -4
  131. data/lib/ronin/scanners.rb +1 -4
  132. data/lib/ronin/scanners/exceptions.rb +1 -4
  133. data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
  134. data/lib/ronin/scanners/scanner.rb +82 -26
  135. data/lib/ronin/static.rb +1 -4
  136. data/lib/ronin/static/finders.rb +1 -4
  137. data/lib/ronin/static/static.rb +16 -7
  138. data/lib/ronin/templates.rb +2 -4
  139. data/lib/ronin/templates/erb.rb +24 -10
  140. data/lib/ronin/templates/template.rb +130 -0
  141. data/lib/ronin/ui.rb +2 -6
  142. data/lib/ronin/ui/command_line.rb +1 -4
  143. data/lib/ronin/ui/command_line/command.rb +137 -68
  144. data/lib/ronin/ui/command_line/command_line.rb +52 -29
  145. data/lib/ronin/ui/command_line/commands/add.rb +39 -67
  146. data/lib/ronin/ui/command_line/commands/console.rb +23 -27
  147. data/lib/ronin/ui/command_line/commands/help.rb +10 -29
  148. data/lib/ronin/ui/command_line/commands/install.rb +31 -56
  149. data/lib/ronin/ui/command_line/commands/list.rb +34 -52
  150. data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
  151. data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
  152. data/lib/ronin/ui/command_line/commands/update.rb +15 -35
  153. data/lib/ronin/ui/command_line/exceptions.rb +1 -4
  154. data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
  155. data/lib/ronin/ui/console.rb +54 -23
  156. data/lib/ronin/ui/hexdump.rb +1 -4
  157. data/lib/ronin/ui/hexdump/extensions.rb +1 -4
  158. data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
  159. data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
  160. data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
  161. data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
  162. data/lib/ronin/ui/output/handler.rb +121 -0
  163. data/lib/ronin/ui/output/helpers.rb +110 -0
  164. data/lib/ronin/ui/output/output.rb +144 -0
  165. data/lib/ronin/ui/shell.rb +38 -12
  166. data/lib/ronin/version.rb +2 -5
  167. data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
  168. data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
  169. data/lib/ronin/yard/handlers/ruby.rb +27 -0
  170. data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
  171. data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
  172. data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
  173. data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
  174. data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
  175. data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
  176. data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
  177. data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
  178. data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
  179. data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
  180. data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
  181. data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
  182. data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
  183. data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
  184. data/spec/author_spec.rb +3 -3
  185. data/spec/extensions/classes/some_class.rb +2 -0
  186. data/spec/extensions/kernel_spec.rb +17 -0
  187. data/spec/extensions/uri/http_spec.rb +0 -31
  188. data/spec/formatting/binary/integer_spec.rb +4 -0
  189. data/spec/formatting/text/string_spec.rb +96 -0
  190. data/spec/license_spec.rb +6 -6
  191. data/spec/model/classes/basic_model.rb +13 -0
  192. data/spec/model/classes/custom_model.rb +17 -0
  193. data/spec/model/classes/described_model.rb +10 -0
  194. data/spec/model/has_description_spec.rb +42 -0
  195. data/spec/model/has_license_spec.rb +18 -4
  196. data/spec/model/model_spec.rb +68 -0
  197. data/spec/network/helpers/classes/test_helper.rb +11 -0
  198. data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
  199. data/spec/network/helpers/helper_spec.rb +25 -0
  200. data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
  201. data/spec/network/http/proxy_spec.rb +116 -0
  202. data/spec/os_spec.rb +4 -4
  203. data/spec/platform/extension_cache_spec.rb +14 -0
  204. data/spec/platform/extension_spec.rb +11 -0
  205. data/spec/platform/platform_spec.rb +8 -0
  206. data/spec/product_spec.rb +9 -9
  207. data/spec/spec_helper.rb +1 -1
  208. data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
  209. data/spec/templates/classes/example_template.rb +21 -0
  210. data/spec/templates/erb_spec.rb +2 -2
  211. data/spec/templates/helpers/static.rb +5 -0
  212. data/spec/templates/helpers/static/templates/_relative.erb +1 -0
  213. data/spec/templates/helpers/static/templates/example.erb +1 -0
  214. data/spec/templates/template_spec.rb +41 -0
  215. data/spec/ui/command_line/classes/test_command.rb +23 -0
  216. data/spec/ui/command_line/command_spec.rb +31 -0
  217. data/spec/ui/output_spec.rb +29 -0
  218. data/static/ronin/platform/overlay.xsl +135 -114
  219. data/tasks/spec.rb +1 -0
  220. data/tasks/yard.rb +18 -0
  221. metadata +98 -59
  222. metadata.gz.sig +0 -0
  223. data/TODO.txt +0 -15
  224. data/lib/ronin/extensions/hash.rb +0 -62
  225. data/lib/ronin/sessions/esmtp.rb +0 -57
  226. data/lib/ronin/sessions/http.rb +0 -678
  227. data/lib/ronin/sessions/imap.rb +0 -54
  228. data/lib/ronin/sessions/pop3.rb +0 -52
  229. data/lib/ronin/sessions/smtp.rb +0 -57
  230. data/lib/ronin/sessions/tcp.rb +0 -100
  231. data/lib/ronin/sessions/telnet.rb +0 -55
  232. data/lib/ronin/sessions/udp.rb +0 -73
  233. data/lib/ronin/ui/command_line/options.rb +0 -136
  234. data/lib/ronin/ui/diagnostics.rb +0 -66
  235. data/lib/ronin/ui/verbose.rb +0 -58
  236. data/spec/extensions/hash_spec.rb +0 -38
  237. data/spec/sessions/classes/test_session.rb +0 -11
  238. data/spec/sessions/classes/uses_test_session.rb +0 -10
  239. data/spec/sessions/session_spec.rb +0 -25
  240. 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/ui/command_line/exceptions/unknown_command'
@@ -36,45 +33,63 @@ module Ronin
36
33
  DEFAULT_COMMAND = 'console'
37
34
 
38
35
  #
39
- # Returns the commands registered with the command-line utility.
36
+ # All command-line names of Commands available to the CommandLine.
37
+ #
38
+ # @return [Array]
39
+ # The command-line names of available Command classes.
40
40
  #
41
41
  def CommandLine.commands
42
42
  unless class_variable_defined?('@@ronin_commands')
43
43
  pattern = File.join('lib',COMMANDS_DIR,'*.rb')
44
- paths = Gem.find_resources(pattern)
45
-
46
- @@ronin_commands = []
47
-
48
- paths.each do |path|
49
- name = File.basename(path).gsub(/\.rb$/,'')
50
-
51
- @@ronin_commands << name unless @@ronin_commands.include?(name)
52
- end
44
+
45
+ @@ronin_commands = Gem.find_resources(pattern).map { |path|
46
+ File.basename(path).gsub(/\.rb$/,'')
47
+ }.uniq
53
48
  end
54
49
 
55
50
  return @@ronin_commands
56
51
  end
57
52
 
58
53
  #
59
- # Returns +true+ if a command exists with the specified _name_,
60
- # returns +false+ otherwise.
54
+ # Searches for the command with the matching name.
55
+ #
56
+ # @param [String, Symbol] name
57
+ # The name of the command to search for.
58
+ #
59
+ # @return [Boolean]
60
+ # Specifies whether a command exists with the matching name.
61
61
  #
62
62
  def CommandLine.has_command?(name)
63
63
  CommandLine.commands.include?(name.to_s)
64
64
  end
65
65
 
66
66
  #
67
- # Returns the Command registered with the command-line utility
68
- # with the specified _name_.
67
+ # Searches for a Command class with the matching command-line name.
68
+ #
69
+ # @param [String, Symbol] name
70
+ # The command-line name of the command to search for.
71
+ #
72
+ # @return [Ronin::UI::Command]
73
+ # The Command registered with the command-line utility with the
74
+ # matching command-line _name_.
69
75
  #
76
+ # @raise [UnknownCommand]
77
+ # No valid command could be found or loaded with the matching
78
+ # command-line _name_.
79
+ #
80
+ # @example
70
81
  # CommandLine.get_command('gen_overlay')
71
82
  # # => Ronin::UI::CommandLine::Commands::GenOverlay
72
83
  #
84
+ # @example
85
+ # CommandLine.get_command('gen-overlay')
86
+ # # => Ronin::UI::CommandLine::Commands::GenOverlay
87
+ #
73
88
  def CommandLine.get_command(name)
74
89
  name = name.to_s
75
90
 
76
- #eventually someone is going to use a space or - which is going mess things up
77
- #we will take care of this ahead of time here
91
+ # eventually someone is going to use a space or - which is going
92
+ # mess things up we will take care of this ahead of time here
78
93
  name.gsub!(/[\s-]/, '_')
79
94
 
80
95
  begin
@@ -93,29 +108,37 @@ module Ronin
93
108
 
94
109
  command = Commands.const_get(class_name)
95
110
 
96
- unless command.respond_to?(:run)
97
- raise(UnknownCommand,"command #{name.dump} must provide a 'run' method",caller)
111
+ unless command.respond_to?(:start)
112
+ raise(UnknownCommand,"command #{name.dump} must provide a 'start' method",caller)
98
113
  end
99
114
 
100
115
  return command
101
116
  end
102
117
 
103
118
  #
104
- # Runs the command-line utility with the given _argv_ Array. If the
105
- # first argument is a sub-command name, the command-line utility will
106
- # attempt to find and execute the Command with the same name.
119
+ # Runs the CommandLine utility. If the first argument is a Command
120
+ # name, the CommandLine utility will attempt to find and run
121
+ # the Command with the matching command-line name. If the first
122
+ # argument is an option, or there are no arguments, the
123
+ # +DEFAULT_COMMAND+ will be ran.
124
+ #
125
+ # @param [Array] argv
126
+ # Command-line arguments which are used to select the Command to
127
+ # run, and which will be passed to the Command.
128
+ #
129
+ # @return [true]
130
+ # The command was successfully ran.
107
131
  #
108
- def CommandLine.run(*argv)
109
- if (argv.empty? || argv.first[0..0]=='-')
132
+ def CommandLine.start(argv=ARGV)
133
+ if (argv.empty? || argv.first[0,1]=='-')
110
134
  name = DEFAULT_COMMAND
111
- argv = ARGV
112
135
  else
113
136
  name = argv.first
114
137
  argv = argv[1..-1]
115
138
  end
116
139
 
117
140
  begin
118
- CommandLine.get_command(name).run(*argv)
141
+ CommandLine.get_command(name).start(argv)
119
142
  rescue UnknownCommand => e
120
143
  STDERR.puts e
121
144
  exit -1
@@ -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'
@@ -30,73 +27,48 @@ module Ronin
30
27
  module Commands
31
28
  class Add < Command
32
29
 
33
- def defaults
34
- @cache = nil
35
- @media = nil
36
- @uri = nil
37
- end
38
-
39
- def define_options(opts)
40
- opts.usage = 'PATH [options]'
41
-
42
- opts.options do
43
- opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
44
- @cache = dir
45
- end
46
-
47
- opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
48
- @media = media.to_sym
49
- end
50
-
51
- opts.on('-L','--local','Similiar to: -m local') do
52
- @media = nil
53
- end
54
-
55
- opts.on('--rsync','Alias for -m rsync') do
56
- @media = :rsync
57
- end
58
-
59
- opts.on('--svn','Alias for -m svn') do
60
- @media = :svn
61
- end
62
-
63
- opts.on('--hg','Alias for -m hg') do
64
- @media = :hg
65
- end
66
-
67
- opts.on('--git','Alias for -m git') do
68
- @media = :git
69
- end
70
-
71
- opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
72
- @uri = uri
73
- end
30
+ desc "add PATH", "Add a local overlay to the Overlay cache"
31
+ method_option :cache, :type => :string, :aliases => '-C'
32
+ method_option :media, :type => :string, :aliases => '-m'
33
+ method_option :local, :type => :boolean, :aliases => '-L'
34
+ method_option :rsync, :type => :boolean
35
+ method_option :svn, :type => :boolean
36
+ method_option :hg, :type => :boolean
37
+ method_option :git, :type => :boolean
38
+ method_option :uri, :type => :string, :aliaes => '-U'
39
+
40
+ def default(path)
41
+ if options[:cache]
42
+ Platform.load_overlays(options[:cache])
74
43
  end
75
44
 
76
- opts.arguments(
77
- 'PATH' => 'Add the overlay located at the specified PATH'
78
- )
79
-
80
- opts.summary %{
81
- Add a local overlay located at the specified PATH to the
82
- Overlay cache
83
- }
84
- end
85
-
86
- def arguments(*args)
87
- unless args.length == 1
88
- fail('only one overlay path maybe specified')
45
+ overlay_options = {:path => path}
46
+
47
+ overlay_options[:media] = if options[:media]
48
+ options[:media].to_sym
49
+ elsif options.local?
50
+ nil
51
+ elsif options.rsync?
52
+ :rsync
53
+ elsif options.svn?
54
+ :svn
55
+ elsif options.hg?
56
+ :hg
57
+ elsif options.git?
58
+ :git
59
+ end
60
+
61
+ if options[:uri]
62
+ overlay_options[:uri] = options[:uri]
89
63
  end
90
64
 
91
- Platform.load_overlays(@cache) if @cache
92
-
93
- overlay_options = {:path => args.first}
94
-
95
- overlay_options[:media] = @media if @media
96
- overlay_options[:uri] = @uri if @uri
97
-
98
- Platform.add(overlay_options) do |overlay|
99
- puts "Overlay #{overlay.name.dump} added."
65
+ begin
66
+ Platform.add(overlay_options) do |overlay|
67
+ print_info "Overlay #{overlay.name.dump} added."
68
+ end
69
+ rescue Platform::OverlayNotFound, Platform::OverlayCached => e
70
+ print_error e.message
71
+ exit -1
100
72
  end
101
73
  end
102
74
 
@@ -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,13 +16,13 @@
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'
25
- require 'ronin/ui/verbose'
22
+ require 'ronin/ui/output'
26
23
  require 'ronin/ui/console'
27
24
  require 'ronin/database'
25
+ require 'ronin/version'
28
26
 
29
27
  module Ronin
30
28
  module UI
@@ -32,36 +30,34 @@ module Ronin
32
30
  module Commands
33
31
  class Console < Command
34
32
 
35
- def define_options(opts)
36
- opts.usage = '<command> [options]'
37
- opts.options do
38
- opts.on('-D','--database URI','The URI for the Database') do |uri|
39
- Database.config = uri.to_s
40
- end
33
+ map '-V' => :version
41
34
 
42
- opts.on('-r','--require LIB','Require the specified library or path') do |lib|
43
- UI::Console.auto_load << lib.to_s
44
- end
35
+ desc "console", "start the Ronin Console"
36
+ method_option :database, :type => :string, :aliases => '-D'
37
+ method_option :require, :type => :array, :aliases => '-r'
38
+ method_option :verbose, :type => :boolean, :aliases => '-v'
45
39
 
46
- opts.on('-v','--verbose','Enables verbose output') do
47
- UI::Verbose.enable!
40
+ def default
41
+ if options[:require]
42
+ options[:require].each do |path|
43
+ UI::Console.auto_load << path
48
44
  end
45
+ end
49
46
 
50
- opts.on('-V','--version','Print version information and exit') do
51
- success do
52
- puts "Ronin #{Ronin::VERSION}"
53
- end
54
- end
47
+ if options[:database]
48
+ Database.config = options[:database]
55
49
  end
56
50
 
57
- opts.summary %{
58
- Ronin is a Ruby development platform designed for information
59
- security and data exploration tasks.
60
- }
51
+ UI::Console.start
61
52
  end
62
53
 
63
- def arguments(*args)
64
- UI::Console.start
54
+ desc "version", "displays the version"
55
+
56
+ #
57
+ # Prints the version information and exists.
58
+ #
59
+ def version
60
+ puts "Ronin #{Ronin::VERSION}"
65
61
  end
66
62
 
67
63
  end
@@ -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'
@@ -30,37 +27,21 @@ module Ronin
30
27
  module Commands
31
28
  class Help < Command
32
29
 
33
- def define_options(opts)
34
- opts.usage = '[COMMAND]'
30
+ desc "help [COMMAND]", "Displays the list of available commands or prints information on a specific command"
35
31
 
36
- opts.arguments(
37
- 'COMMAND' => 'The command to view'
38
- )
39
-
40
- opts.summary %{
41
- View a list of supported commands or information on a
42
- specific command
43
- }
44
- end
45
-
46
- def arguments(*args)
47
- if args.length > 1
48
- fail('only one command maybe specified')
49
- end
50
-
51
- topic = args.first
52
-
53
- if topic
32
+ def default(command=nil)
33
+ if command
54
34
  begin
55
- CommandLine.get_command(topic).run('--help')
35
+ CommandLine.get_command(command).start(['--help'])
56
36
  rescue UnknownCommand
57
- fail("unknown sub-command #{topic.dump}")
37
+ print_error "unknown command #{command.dump}"
38
+ exit -1
58
39
  end
59
40
  else
60
- puts 'Available sub-commands:'
41
+ puts 'Available commands:'
61
42
 
62
- CommandLine.commands.sort.each do |name|
63
- puts " #{name}"
43
+ indent do
44
+ CommandLine.commands.sort.each { |name| puts name }
64
45
  end
65
46
  end
66
47
  end
@@ -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'
@@ -30,60 +27,38 @@ module Ronin
30
27
  module Commands
31
28
  class Install < Command
32
29
 
33
- def defaults
34
- @cache = nil
35
- @media = nil
36
- end
37
-
38
- def define_options(opts)
39
- opts.usage = 'URI [options]'
40
-
41
- opts.options do
42
- opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
43
- @cache = dir
44
- end
45
-
46
- opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
47
- @media = media.to_sym
48
- end
49
-
50
- opts.on('--rsync','Alias for -m rsync') do
51
- @media = :rsync
52
- end
53
-
54
- opts.on('--svn','Alias for -m svn') do
55
- @media = :svn
56
- end
57
-
58
- opts.on('--hg','Alias for -m hg') do
59
- @media = :hg
60
- end
61
-
62
- opts.on('--git','Alias for -m git') do
63
- @media = :git
64
- end
30
+ desc "install URI", "Installs the Overlay located at the specified URI"
31
+ method_option :cache, :type => :string, :aliases => '-C'
32
+ method_option :media, :type => :string, :aliases => '-m'
33
+ method_option :rsync, :type => :boolean
34
+ method_option :svn, :type => :boolean
35
+ method_option :hg, :type => :boolean
36
+ method_option :git, :type => :boolean
37
+
38
+ def default(uri)
39
+ if options[:cache]
40
+ Platform.load_overlays(options[:cache])
65
41
  end
66
42
 
67
- opts.arguments(
68
- 'URI' => 'The URI of the overlay to install'
69
- )
70
-
71
- opts.summary %{
72
- Installs the overlay located at the specified URI
73
- }
74
- end
75
-
76
- def arguments(*args)
77
- unless args.length == 1
78
- fail('only one overlay URI maybe specified')
79
- end
80
-
81
- uri = args.first
82
-
83
- Platform.load_overlays(@cache) if @cache
84
-
85
- Platform.install(:uri => uri, :media => @media) do |overlay|
86
- puts "Overlay #{overlay.name.dump} has been installed."
43
+ media = if options[:media]
44
+ options[:media].to_sym
45
+ elsif options.rsync?
46
+ :rsync
47
+ elsif options.svn?
48
+ :svn
49
+ elsif options.hg?
50
+ :hg
51
+ elsif options.git?
52
+ :git
53
+ end
54
+
55
+ begin
56
+ Platform.install(:uri => uri, :media => media) do |overlay|
57
+ print_info "Overlay #{overlay.name.dump} has been installed."
58
+ end
59
+ rescue Platform::OverlayCached => e
60
+ print_error e.message
61
+ exit -1
87
62
  end
88
63
  end
89
64