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/formatting/extensions/binary/integer'
@@ -30,12 +27,22 @@ require 'base64'
30
27
  class String
31
28
 
32
29
  #
33
- # Packs the integer using the specified _arch_ and the given
34
- # _address_length_. The _address_length_ will default to the address
35
- # length of the _arch_.
30
+ # Packs an Integer from a String, which was originally packed for
31
+ # a specific architecture and address-length.
36
32
  #
33
+ # @param [Ronin::Arch] arch
34
+ # The architecture that the Integer was originally packed with.
35
+ #
36
+ # @param [Integer] address_length
37
+ # The number of bytes to depack.
38
+ #
39
+ # @return [Integer]
40
+ # The depacked Integer.
41
+ #
42
+ # @example
37
43
  # 0x41.pack(Arch('i686')) # => "A\000\000\000"
38
44
  #
45
+ # @example
39
46
  # 0x41.pack(Arch('ppc'),2) # => "\000A"
40
47
  #
41
48
  def depack(arch,address_length=arch.address_length)
@@ -61,8 +68,10 @@ class String
61
68
  end
62
69
 
63
70
  #
64
- # Returns the hex escaped form of the string.
71
+ # @return [String]
72
+ # The hex escaped version of the String.
65
73
  #
74
+ # @example
66
75
  # "hello".hex_escape
67
76
  # # => "\\x68\\x65\\x6c\\x6c\\x6f"
68
77
  #
@@ -71,8 +80,10 @@ class String
71
80
  end
72
81
 
73
82
  #
74
- # Returns an unescaped version of the hex escaped string.
83
+ # @return [String]
84
+ # The unescaped version of the hex escaped String.
75
85
  #
86
+ # @example
76
87
  # "\\x68\\x65\\x6c\\x6c\\x6f".hex_unescape
77
88
  # # => "hello"
78
89
  #
@@ -126,7 +137,17 @@ class String
126
137
  end
127
138
 
128
139
  #
129
- # XOR encodes the string using the specified _key_.
140
+ # XOR encodes the String.
141
+ #
142
+ # @param [Integer] key
143
+ # The byte to XOR against each byte in the String.
144
+ #
145
+ # @return [String]
146
+ # The XOR encoded String.
147
+ #
148
+ # @example
149
+ # "hello".xor(0x41)
150
+ # # => ")$--."
130
151
  #
131
152
  def xor(key)
132
153
  encoded = ''
@@ -136,14 +157,20 @@ class String
136
157
  end
137
158
 
138
159
  #
139
- # Returns the base64 encoded form of the string.
160
+ # Base64 encodes a string.
161
+ #
162
+ # @return [String]
163
+ # The base64 encoded form of the string.
140
164
  #
141
165
  def base64_encode
142
166
  Base64.encode64(self)
143
167
  end
144
168
 
145
169
  #
146
- # Returns the base64 decoded form of the string.
170
+ # Base64 decodes a string.
171
+ #
172
+ # @return [String]
173
+ # The base64 decoded form of the string.
147
174
  #
148
175
  def base64_decode
149
176
  Base64.decode64(self)
@@ -151,31 +178,27 @@ class String
151
178
 
152
179
  #
153
180
  # Converts a multitude of hexdump formats back into the original
154
- # raw-data using the given _options_.
181
+ # raw-data.
182
+ #
183
+ # @param [Hash] options
184
+ # Additional options.
185
+ #
186
+ # @option options [Symbol] :format
187
+ # The expected format of the hexdump. Must be either +:od+ or
188
+ # +:hexdump+.
189
+ #
190
+ # @option options [Symbol] :encoding
191
+ # Denotes the encoding used for the bytes within the hexdump.
192
+ # Must be one of the following: +:binary+, +:octal+, +:octal_bytes+
193
+ # +:octal_shorts+, +:octal_ints+, :octal_quads+, +:decimal+,
194
+ # +:decimal_bytes+, +:decimal_shorts+, +:decimal_ints+,
195
+ # +:decimal_quads+, +:hex+ +:hex_bytes+, +:hex_shorts+, +:hex_ints+ or
196
+ # +:hex_quads+.
197
+ #
198
+ # @option options [Integer] :segment (16)
199
+ # The length in bytes of each segment in the hexdump.
155
200
  #
156
- # _options_ may contain the following keys:
157
- # <tt>:format</tt>:: The expected format of the hexdump. Must be either
158
- # <tt>:od</tt> or <tt>:hexdump</tt>.
159
- # <tt>:encoding</tt>:: Denotes the encoding used for the bytes within the
160
- # hexdump. Must be one of the following:
161
- # <tt>:binary</tt>:: Binary encoded bytes.
162
- # <tt>:octal</tt>:: Octal encoding.
163
- # <tt>:octal_bytes</tt>:: Octal encoded bytes.
164
- # <tt>:octal_shorts</tt>:: Octal encoded shorts.
165
- # <tt>:octal_ints</tt>:: Octal encoded integers.
166
- # <tt>:octal_quads</tt>:: Octal encoded quads.
167
- # <tt>:decimal</tt>:: Unsigned decimal encoding.
168
- # <tt>:decimal_bytes</tt>:: Unsigned decimal bytes.
169
- # <tt>:decimal_shorts</tt>:: Unsigned decimal shorts.
170
- # <tt>:decimal_ints</tt>:: Unsigned decimal ints.
171
- # <tt>:decimal_quads</tt>:: Unsigned decimal quads.
172
- # <tt>:hex</tt>:: Hexadecimal encoding.
173
- # <tt>:hex_bytes</tt>:: Hexadecimal bytes.
174
- # <tt>:hex_shorts</tt>:: Hexadecimal shorts.
175
- # <tt>:hex_ints</tt>:: Hexadecimal ints.
176
- # <tt>:hex_quads</tt>:: Hexadecimal quads.
177
- # <tt>:segment</tt>:: The length in bytes of each segment in the hexdump.
178
- # Defaults to 16, if not specified.
201
+ # @return [String] The raw-data from the hexdump.
179
202
  #
180
203
  def unhexdump(options={})
181
204
  case (format = options[:format])
@@ -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/formatting/extensions/digest/string'
@@ -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 'digest/md5'
@@ -28,35 +25,60 @@ require 'digest/sha2'
28
25
  class String
29
26
 
30
27
  #
31
- # Returns the MD5 checksum of the String.
28
+ # @return [String]
29
+ # The MD5 checksum of the String.
30
+ #
31
+ # @example
32
+ # "hello".md5
33
+ # # => "5d41402abc4b2a76b9719d911017c592"
32
34
  #
33
35
  def md5
34
36
  Digest::MD5.hexdigest(self)
35
37
  end
36
38
 
37
39
  #
38
- # Returns the SHA1 checksum of the String.
40
+ # @return [String]
41
+ # The SHA1 checksum of the String.
42
+ #
43
+ # @example
44
+ # "hello".sha1
45
+ # # => "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
39
46
  #
40
47
  def sha1
41
48
  Digest::SHA1.hexdigest(self)
42
49
  end
43
50
 
44
51
  #
45
- # Returns the SHA2 checksum of the String.
52
+ # @return [String]
53
+ # The SHA2 checksum of the String.
54
+ #
55
+ # @example
56
+ # "hello".sha2
57
+ # # => "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
46
58
  #
47
59
  def sha2
48
60
  Digest::SHA2.hexdigest(self)
49
61
  end
50
62
 
51
63
  #
52
- # Returns the SHA256 checksum of the String.
64
+ # @return [String]
65
+ # The SHA256 checksum of the String.
66
+ #
67
+ # @example
68
+ # "hello".sha256
69
+ # # => "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
53
70
  #
54
71
  def sha256
55
72
  Digest::SHA256.hexdigest(self)
56
73
  end
57
74
 
58
75
  #
59
- # Returns the SHA512 checksum of the String.
76
+ # @return [String]
77
+ # The SHA512 checksum of the String.
78
+ #
79
+ # @example
80
+ # "hello".sha512
81
+ # # => "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
60
82
  #
61
83
  def sha512
62
84
  Digest::SHA512.hexdigest(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/formatting/extensions/http/string'
@@ -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/formatting/extensions/text'
@@ -29,8 +26,10 @@ require 'cgi'
29
26
  class String
30
27
 
31
28
  #
32
- # Returns the URI encoded form of the string.
29
+ # @return [String]
30
+ # The URI encoded form of the String.
33
31
  #
32
+ # @example
34
33
  # "art is graffiti".uri_encode
35
34
  # # => "art%20is%20graffiti"
36
35
  #
@@ -39,8 +38,10 @@ class String
39
38
  end
40
39
 
41
40
  #
42
- # Returns the decoded URI form of the string.
41
+ # @return [String]
42
+ # The decoded URI form of the String.
43
43
  #
44
+ # @example
44
45
  # "genre%3f".uri_decode
45
46
  # # => "genre?"
46
47
  #
@@ -49,8 +50,10 @@ class String
49
50
  end
50
51
 
51
52
  #
52
- # Returns the URI escaped form of the string.
53
+ # @return [String]
54
+ # The URI escaped form of the String.
53
55
  #
56
+ # @example
54
57
  # "x > y".uri_escape
55
58
  # # => "x+%3E+y"
56
59
  #
@@ -59,8 +62,10 @@ class String
59
62
  end
60
63
 
61
64
  #
62
- # Returns the unescaped URI form of the string.
65
+ # @return [String]
66
+ # The unescaped URI form of the String.
63
67
  #
68
+ # @example
64
69
  # "sweet+%26+sour".uri_unescape
65
70
  # # => "sweet & sour"
66
71
  #
@@ -69,8 +74,10 @@ class String
69
74
  end
70
75
 
71
76
  #
72
- # Returns the HTTP hexidecimal encoded form of the string.
77
+ # @return [String]
78
+ # The HTTP hexidecimal encoded form of the String.
73
79
  #
80
+ # @example
74
81
  # "hello".format_http
75
82
  # # => "&#104;&#101;&#108;&#108;&#111;"
76
83
  #
@@ -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/formatting/extensions/text/string'
@@ -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,17 +16,22 @@
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
  class Array
25
22
 
26
23
  #
27
- # Returns the bytes contained in the array.
24
+ # Decodes the bytes contained within the Array. The Array may contain
25
+ # both Integer and String objects.
28
26
  #
27
+ # @return [Array]
28
+ # The bytes contained in the Array.
29
+ #
30
+ # @example
29
31
  # [0x41, 0x41, 0x20].bytes
30
32
  # # => [0x41, 0x41, 0x20]
31
33
  #
34
+ # @example
32
35
  # ['A', 'BB', 0x90].bytes
33
36
  # # => [0x41, 0x42, 0x42, 0x90]
34
37
  #
@@ -45,8 +48,13 @@ class Array
45
48
  end
46
49
 
47
50
  #
48
- # Returns the Array of characters generated from the array.
51
+ # Decodes the characters contained within the Array. The Array may contain
52
+ # either Integer or String objects.
53
+ #
54
+ # @return [Array]
55
+ # The characters generated from the array.
49
56
  #
57
+ # @example
50
58
  # [0x41, 0x41, 0x20].chars
51
59
  # # => ["A", "A", " "]
52
60
  #
@@ -55,8 +63,10 @@ class Array
55
63
  end
56
64
 
57
65
  #
58
- # Returns the String created from the characters within the array.
66
+ # @return [String]
67
+ # The String created from the characters within the Array.
59
68
  #
69
+ # @example
60
70
  # [0x41, 0x41, 0x20].char_string
61
71
  # # => "AA "
62
72
  #
@@ -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 'chars'
@@ -26,23 +23,38 @@ require 'chars'
26
23
  class String
27
24
 
28
25
  #
29
- # Creates a new String by passing each byte to the specified _block_
30
- # using the given _options_.
26
+ # Creates a new String by formatting each byte.
31
27
  #
32
- # _options_ may include the following keys:
33
- # <tt>:included</tt>:: The set of characters that will be formated,
34
- # defaults to <tt>Chars.all</tt>.
35
- # <tt>:excluded</tt>:: The characters not to format.
28
+ # @param [Hash] options
29
+ # Additional options.
30
+ #
31
+ # @option options [Array, Range] :included (0x00..0xff)
32
+ # The bytes to format.
33
+ #
34
+ # @option options [Array, Range] :excluded
35
+ # The bytes not to format.
36
+ #
37
+ # @yield [byte]
38
+ # The block which will return the formatted version of each byte
39
+ # within the String.
40
+ #
41
+ # @yieldparam [Integer] byte
42
+ # The byte to format.
43
+ #
44
+ # @return [String]
45
+ # The formatted version of the String.
36
46
  #
37
47
  def format_bytes(options={},&block)
38
- included = (options[:included] || Chars.all)
48
+ included = (options[:included] || (0x00..0xff))
39
49
  excluded = (options[:excluded] || [])
40
50
 
41
- targeted = included - excluded
42
51
  formatted = ''
43
52
 
44
53
  self.each_byte do |b|
45
- if targeted.include_byte?(b)
54
+ c = b.chr
55
+
56
+ if ((included.include?(b) || included.include?(c)) \
57
+ && !(excluded.include?(b) || excluded.include?(c)))
46
58
  formatted << block.call(b)
47
59
  else
48
60
  formatted << b
@@ -53,13 +65,26 @@ class String
53
65
  end
54
66
 
55
67
  #
56
- # Creates a new String by passing each character to the specified _block_
57
- # using the given _options_.
68
+ # Creates a new String by formatting each character.
69
+ #
70
+ # @param [Hash] options
71
+ # Additional options.
72
+ #
73
+ # @option options [Array, Range] :included (0x00..0xff)
74
+ # The bytes to format.
75
+ #
76
+ # @option options [Array, Range] :excluded
77
+ # The bytes not to format.
58
78
  #
59
- # _options_ may include the following keys:
60
- # <tt>:included</tt>:: The set of characters that will be formated,
61
- # defaults to <tt>Chars.all</tt>.
62
- # <tt>:excluded</tt>:: The characters not to format.
79
+ # @yield [char]
80
+ # The block which will return the formatted version of each character
81
+ # within the String.
82
+ #
83
+ # @yieldparam [String] char
84
+ # The character to format.
85
+ #
86
+ # @return [String]
87
+ # The formatted version of the String.
63
88
  #
64
89
  def format_chars(options={},&block)
65
90
  format_bytes(options) do |b|
@@ -68,13 +93,22 @@ class String
68
93
  end
69
94
 
70
95
  #
71
- # Creates a new String by randomizing the case of each character using
72
- # the given _options_.
96
+ # Creates a new String by randomizing the case of each character in the
97
+ # String.
98
+ #
99
+ # @param [Hash] options
100
+ # Additional options.
101
+ #
102
+ # @option options [Array, Range] :included (0x00..0xff)
103
+ # The bytes to format.
73
104
  #
74
- # _options_ may include the following keys:
75
- # <tt>:probability</tt>:: The probability that a character will have it's
76
- # case changed; defaults to 0.5.
105
+ # @option options [Array, Range] :excluded
106
+ # The bytes not to format.
77
107
  #
108
+ # @option options [Float] :probability (0.5)
109
+ # The probability that a character will have it's case changed.
110
+ #
111
+ # @example
78
112
  # "get out your checkbook".random_case
79
113
  # # => "gEt Out YOur CHEckbook"
80
114
  #
@@ -91,10 +125,19 @@ class String
91
125
  end
92
126
 
93
127
  #
94
- # Pads the string using the specified _padding_ out to the given
95
- # _max_length_. _max_length_ will default to the strings own length,
96
- # if not given.
128
+ # Creates a new String by padding the String with repeating text,
129
+ # out to a specified length.
130
+ #
131
+ # @param [String] padding
132
+ # The text to pad the new String with.
133
+ #
134
+ # @param [String] max_length
135
+ # The maximum length to pad the new String out to.
136
+ #
137
+ # @return [String]
138
+ # The padded version of the String.
97
139
  #
140
+ # @example
98
141
  # "hello".pad('A',50)
99
142
  # # => "helloAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
100
143
  #