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/platform/extension'
@@ -29,8 +26,14 @@ module Ronin
29
26
  class ExtensionCache < Hash
30
27
 
31
28
  #
32
- # Creates a new empty ExtensionCache object. If a _block_ is given
33
- # it will be passed the newly created ExtensionCache object.
29
+ # Creates a new empty ExtensionCache object.
30
+ #
31
+ # @yield [cache]
32
+ # If a block is given, it will be passed the newly created
33
+ # extension cache.
34
+ #
35
+ # @yieldparam [ExtensionCache] cache
36
+ # The newly created extension cache.
34
37
  #
35
38
  def initialize(&block)
36
39
  super() do |hash,key|
@@ -47,7 +50,8 @@ module Ronin
47
50
  end
48
51
 
49
52
  #
50
- # Returns the sorted names of the extensions within the cache.
53
+ # @return [Array]
54
+ # The sorted names of the extensions within the cache.
51
55
  #
52
56
  def names
53
57
  keys.sort
@@ -60,46 +64,78 @@ module Ronin
60
64
  # Selects the extensions within the cache that match the specified
61
65
  # _block_.
62
66
  #
63
- def extensions_with(&block)
67
+ # @yield [ext]
68
+ # The block will be passed each extension, and the extension will
69
+ # be selected based on the return value of the block.
70
+ #
71
+ # @yieldparam [Extension] ext
72
+ # An extension from the cache.
73
+ #
74
+ # @return [Array]
75
+ # The selected extensions.
76
+ #
77
+ def with(&block)
64
78
  values.select(&block)
65
79
  end
66
80
 
67
81
  #
68
- # Returns +true+ if the cache contains the extension with the
69
- # specified _name_, returns +false+ otherwise.
82
+ # Searches within the cache for the extension with the specified
83
+ # _name_.
84
+ #
85
+ # @return [Boolean]
86
+ # Specifies whether the cache contains the extension with the
87
+ # specified _name_.
70
88
  #
71
- def has_extension?(name)
89
+ def has?(name)
72
90
  has_key?(name.to_s)
73
91
  end
74
92
 
75
93
  #
76
- # Loads the extension with the specified _name_. If no such extension
77
- # exists an ExtensionNotFound exception will be raised. If a _block_
78
- # is given, it will be passed the loaded extension.
94
+ # Loads the extension with the specified _name_.
95
+ #
96
+ # @param [String, Symbol] name
97
+ # The name of the extension to load.
79
98
  #
80
- def load_extension(name,&block)
99
+ # @raise [ExtensionNotFound]
100
+ # The extension with the specified _name_ could not be found in
101
+ # the extension cache.
102
+ #
103
+ def load_extension(name)
81
104
  name = name.to_s
82
105
 
83
106
  unless Platform.overlays.has_extension?(name)
84
107
  raise(ExtensionNotFound,"extension #{name.dump} does not eixst",caller)
85
108
  end
86
109
 
87
- return Extension.load(name) do |ext|
88
- ext.setup!
89
-
90
- block.call(ext) if block
110
+ return Extension.new(name) do |ext|
111
+ include(self.name)
112
+ setup!
91
113
  end
92
114
  end
93
115
 
94
116
  #
95
- # Reloads the extensions within the extension cache.
117
+ # Reloads one or all extensions within the extension cache.
118
+ #
119
+ # @param [String, Symbol] name
120
+ # The specific extension to reload.
96
121
  #
97
- def reload!
98
- each do |name,ext|
99
- ext.teardown!
122
+ # @return [true]
123
+ # Specifies the reload was successful.
124
+ #
125
+ def reload!(name=nil)
126
+ reloader = lambda { |ext_name|
127
+ self[ext_name].teardown! if has?(ext_name)
128
+
129
+ self[ext_name] = load_extension(ext_name)
130
+ }
100
131
 
101
- self[name] = load_extension(name)
132
+ if name
133
+ reloader.call(name)
134
+ else
135
+ each_key(&reloader)
102
136
  end
137
+
138
+ return true
103
139
  end
104
140
 
105
141
  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
  module Ronin
@@ -32,8 +29,13 @@ module Ronin
32
29
  attr_reader :email
33
30
 
34
31
  #
35
- # Creates a new Maintainer object with the specified _name_ and the
36
- # given _email_.
32
+ # Creates a new Maintainer object.
33
+ #
34
+ # @param [String] name
35
+ # The name of the maintainer.
36
+ #
37
+ # @param [String] email
38
+ # The optional email of the maintainer.
37
39
  #
38
40
  def initialize(name,email=nil)
39
41
  @name = name
@@ -41,7 +43,9 @@ module Ronin
41
43
  end
42
44
 
43
45
  #
44
- # Returns the String form of the maintainer object.
46
+ # @return [String]
47
+ # The String representation of the maintainer object.
48
+ #
45
49
  def to_s
46
50
  if @email
47
51
  return "#{@name} <#{@email}>"
@@ -51,7 +55,10 @@ module Ronin
51
55
  end
52
56
 
53
57
  #
54
- # Inspects the maintainer object.
58
+ # @return [String]
59
+ # Inspects the maintainer object.
60
+ #
61
+ # @see Maintainer#to_s
55
62
  #
56
63
  def inspect
57
64
  "#<#{self.class.name}: #{self}>"
@@ -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/database'
@@ -29,15 +26,30 @@ module Ronin
29
26
  module Platform
30
27
  module ObjectCache
31
28
  #
32
- # Returns all paths within the specified _directory_ pointing
33
- # to object files.
29
+ # Searches for object files within the specified _directory_.
30
+ #
31
+ # @param [String] directory
32
+ # The directory to search for object files within.
33
+ #
34
+ # @return [Array]
35
+ # All paths within the specified _directory_ pointing to object
36
+ # files.
34
37
  #
35
38
  def ObjectCache.paths(directory)
36
39
  Dir[File.join(File.expand_path(directory),'**','*.rb')]
37
40
  end
38
41
 
39
42
  #
40
- # Finds all cached objects, passing each to the given _block_.
43
+ # Finds all cached objects.
44
+ #
45
+ # @param [String] directory
46
+ # Optional directory to search within for cached objects.
47
+ #
48
+ # @yield [obj]
49
+ # The block that will receive all cached object.
50
+ #
51
+ # @yieldparam [Cacheable] obj
52
+ # The cached object.
41
53
  #
42
54
  def ObjectCache.each(directory=nil,&block)
43
55
  attributes = {}
@@ -57,6 +69,9 @@ module Ronin
57
69
  # Cache all objects loaded from the paths within the specified
58
70
  # _directory_.
59
71
  #
72
+ # @param [String] directory
73
+ # The directory to cache all objects from.
74
+ #
60
75
  def ObjectCache.cache(directory)
61
76
  Database.setup unless Database.setup?
62
77
 
@@ -70,7 +85,10 @@ module Ronin
70
85
  #
71
86
  # Syncs all objects that were previously cached from paths within
72
87
  # the specified _directory_. Also cache objects which have yet to
73
- # be cached.
88
+ # be cached from the _directory_.
89
+ #
90
+ # @param [String] directory
91
+ # The directory to sync all objects with.
74
92
  #
75
93
  def ObjectCache.sync(directory)
76
94
  new_paths = ObjectCache.paths(directory)
@@ -92,6 +110,9 @@ module Ronin
92
110
  # Deletes all cached objects that existed in the specified
93
111
  # _directory_.
94
112
  #
113
+ # @param [String] directory
114
+ # Deletes all cached objects from the specified _directory_.
115
+ #
95
116
  def ObjectCache.clean(directory)
96
117
  Database.setup unless Database.setup?
97
118
 
@@ -1,7 +1,5 @@
1
1
  #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
2
+ # Ronin - A Ruby platform for exploit development and security research.
5
3
  #
6
4
  # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
5
  #
@@ -18,7 +16,6 @@
18
16
  # You should have received a copy of the GNU General Public License
19
17
  # along with this program; if not, write to the Free Software
20
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
19
  #
23
20
 
24
21
  require 'ronin/platform/exceptions/extension_not_found'
@@ -77,6 +74,9 @@ module Ronin
77
74
  # Website URI for the overlay
78
75
  attr_reader :website
79
76
 
77
+ # Ruby Gems required by the overlay
78
+ attr_reader :gems
79
+
80
80
  # Maintainers of the overlay
81
81
  attr_reader :maintainers
82
82
 
@@ -94,7 +94,24 @@ module Ronin
94
94
 
95
95
  #
96
96
  # Creates a new Overlay object with the specified _path_, _media_
97
- # and _uri_.
97
+ # and _uri_. If a _block_ is given it will be passed the newly
98
+ # created Overlay object.
99
+ #
100
+ # @param [String] path
101
+ # The path to the overlay.
102
+ #
103
+ # @param [Symbol] media
104
+ # The media of the overlay. Can be either +:git+, +:hg+, +:snv+ or
105
+ # +:rsync+.
106
+ #
107
+ # @param [String, URI::HTTP, URI::HTTPS] uri
108
+ # The URI the overlay resides at.
109
+ #
110
+ # @yield [overlay]
111
+ # If a block is given, the overlay will be passed to it.
112
+ #
113
+ # @yieldparam [Overlay] overlay
114
+ # The newly created overlay.
98
115
  #
99
116
  def initialize(path,media=nil,uri=nil,&block)
100
117
  @path = File.expand_path(path)
@@ -104,18 +121,22 @@ module Ronin
104
121
  @uri = uri
105
122
  @repository = Repository.new(@path,Media.types[media])
106
123
 
107
- initialize_metadata(&block)
124
+ initialize_metadata()
125
+
126
+ block.call(self) if block
108
127
  end
109
128
 
110
129
  #
111
- # Media type of the overlay.
130
+ # @return [Symbol]
131
+ # The media type of the overlay.
112
132
  #
113
133
  def media
114
134
  @repository.media_name
115
135
  end
116
136
 
117
137
  #
118
- # Returns the paths of all extensions within the overlay.
138
+ # @return [Array]
139
+ # The paths of all extensions within the overlay.
119
140
  #
120
141
  def extension_paths
121
142
  @repository.directories.reject do |dir|
@@ -126,15 +147,23 @@ module Ronin
126
147
  end
127
148
 
128
149
  #
129
- # Returns the names of all extensions within the overlay.
150
+ # @return [Array]
151
+ # The names of all extensions within the overlay.
130
152
  #
131
153
  def extensions
132
154
  extension_paths.map { |dir| File.basename(dir) }
133
155
  end
134
156
 
135
157
  #
136
- # Returns +true+ if the overlay contains the extension with the
137
- # specified _name_, returns +false+ otherwise.
158
+ # Searches for the extension with the specified _name_ within the
159
+ # overlay.
160
+ #
161
+ # @param [String, Symbol] name
162
+ # The name of the extension to search for.
163
+ #
164
+ # @return [Boolean]
165
+ # Specifies whether the overlay contains the extension with the
166
+ # specified _name_.
138
167
  #
139
168
  def has_extension?(name)
140
169
  name = File.basename(name.to_s)
@@ -144,8 +173,9 @@ module Ronin
144
173
  end
145
174
 
146
175
  #
147
- # Returns the <tt>lib/</tt> directories of the extensions within
148
- # the overlay.
176
+ # @return [Array]
177
+ # The +lib+ directories of the overlay and the extensions within
178
+ # the overlay.
149
179
  #
150
180
  def lib_dirs
151
181
  dirs = []
@@ -164,8 +194,8 @@ module Ronin
164
194
  end
165
195
 
166
196
  #
167
- # Activates the overlay by adding the lib_dirs to the
168
- # <tt>$LOAD_PATH</tt> global variable.
197
+ # Activates the overlay by adding all of the lib_dirs to the
198
+ # +$LOAD_PATH+ global variable.
169
199
  #
170
200
  def activate!
171
201
  # add the static/ directory
@@ -185,7 +215,7 @@ module Ronin
185
215
 
186
216
  #
187
217
  # Deactivates the overlay by removing the lib_dirs from the
188
- # <tt>$LOAD_PATH</tt> global variable.
218
+ # +$LOAD_PATH+ global variable.
189
219
  #
190
220
  def deactivate!
191
221
  Static.static_dirs.reject! { |dir| dir == @static_dir }
@@ -196,21 +226,41 @@ module Ronin
196
226
  end
197
227
 
198
228
  #
199
- # Updates the overlay and reloads it's metadata. If a _block_
200
- # is given it will be called after the overlay has been updated.
229
+ # Updates the overlay and reloads it's metadata.
230
+ #
231
+ # @yield [overlay]
232
+ # If a block is given, it will be passed after the overlay has
233
+ # been updated.
234
+ #
235
+ # @yieldparam [Overlay] overlay
236
+ # The updated overlay.
237
+ #
238
+ # @return [Overlay]
239
+ # The updated overlay.
201
240
  #
202
241
  def update(&block)
203
- if @repository.update(@uri)
204
- initialize_metadata(&block)
242
+ if (@uri && @media)
243
+ if @repository.update(@uri)
244
+ initialize_metadata()
245
+ end
205
246
  end
206
247
 
248
+ block.call(self) if block
207
249
  return self
208
250
  end
209
251
 
210
252
  #
211
- # Deletes the overlay then removes it from the overlay cache.
212
- # If a _block_ is given, it will be passed the overlay after it
213
- # has been uninstalled.
253
+ # Deletes the contents of the overlay.
254
+ #
255
+ # @yield [overlay]
256
+ # If a block is given, it will be passed the overlay after it's
257
+ # contents have been deleted.
258
+ #
259
+ # @yieldparam [Overlay] overlay
260
+ # The deleted overlay.
261
+ #
262
+ # @return [Overlay]
263
+ # The deleted overlay.
214
264
  #
215
265
  def uninstall(&block)
216
266
  @repository.delete
@@ -220,7 +270,8 @@ module Ronin
220
270
  end
221
271
 
222
272
  #
223
- # Returns the +name+ of the Overlay.
273
+ # @return [String]
274
+ # The name of the overlay.
224
275
  #
225
276
  def to_s
226
277
  @name.to_s
@@ -233,7 +284,7 @@ module Ronin
233
284
  # overlay +path+. If a _block_ is given, it will be passed the
234
285
  # overlay after the metadata has been loaded.
235
286
  #
236
- def initialize_metadata(&block)
287
+ def initialize_metadata()
237
288
  metadata_path = File.join(@path,METADATA_FILE)
238
289
 
239
290
  # set to default values
@@ -244,6 +295,8 @@ module Ronin
244
295
  @source_view = @source
245
296
  @website = @source_view
246
297
 
298
+ @gems = []
299
+
247
300
  @maintainers = []
248
301
  @description = nil
249
302
 
@@ -271,6 +324,10 @@ module Ronin
271
324
  @website = website_tag.inner_text.strip
272
325
  end
273
326
 
327
+ overlay.search('dependencies/gem').each do |gem|
328
+ @gems << gem.inner_text.strip
329
+ end
330
+
274
331
  overlay.search('maintainers/maintainer').each do |maintainer|
275
332
  if (name = maintainer.at('name'))
276
333
  name = name.inner_text.strip
@@ -288,7 +345,6 @@ module Ronin
288
345
  end
289
346
  end
290
347
 
291
- block.call(self) if block
292
348
  return self
293
349
  end
294
350