ronin 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/FAQ.txt +103 -0
  2. data/History.txt +10 -1
  3. data/Manifest.txt +26 -0
  4. data/Rakefile +2 -0
  5. data/TODO.txt +9 -2
  6. data/lib/ronin/arch.rb +9 -2
  7. data/lib/ronin/author.rb +9 -10
  8. data/lib/ronin/chars/chars.rb +1 -1
  9. data/lib/ronin/console.rb +5 -5
  10. data/lib/ronin/context.rb +1 -1
  11. data/lib/ronin/database.rb +8 -3
  12. data/lib/ronin/extensions/string.rb +1 -1
  13. data/lib/ronin/extensions/uri/http.rb +1 -1
  14. data/lib/ronin/license.rb +4 -0
  15. data/lib/ronin/model.rb +8 -0
  16. data/lib/ronin/models.rb +1 -8
  17. data/lib/ronin/network/extensions/telnet/net.rb +11 -6
  18. data/lib/ronin/network/extensions/udp/net.rb +0 -12
  19. data/lib/ronin/objects.rb +1 -3
  20. data/lib/ronin/parameters/parameters.rb +26 -15
  21. data/lib/ronin/platform.rb +4 -1
  22. data/lib/ronin/product.rb +3 -0
  23. data/lib/ronin/runner/program/program.rb +4 -2
  24. data/lib/ronin/sessions/esmtp.rb +2 -10
  25. data/lib/ronin/sessions/imap.rb +1 -9
  26. data/lib/ronin/sessions/pop3.rb +1 -9
  27. data/lib/ronin/sessions/session.rb +20 -19
  28. data/lib/ronin/sessions/smtp.rb +1 -9
  29. data/lib/ronin/sessions/tcp.rb +1 -21
  30. data/lib/ronin/sessions/telnet.rb +1 -9
  31. data/lib/ronin/sessions/udp.rb +1 -21
  32. data/lib/ronin/sessions/web.rb +1 -9
  33. data/lib/ronin/target.rb +3 -0
  34. data/lib/ronin/version.rb +1 -1
  35. data/spec/arch_spec.rb +61 -0
  36. data/spec/author_spec.rb +10 -0
  37. data/spec/chars/chars_spec.rb +82 -0
  38. data/spec/context/context_spec.rb +84 -0
  39. data/spec/context/helpers/book_context.rb +15 -0
  40. data/spec/context/helpers/book_review_context.rb +21 -0
  41. data/spec/context/helpers/contexts/neuromancer_review.rb +15 -0
  42. data/spec/context/helpers/contexts/snow_crash.rb +8 -0
  43. data/spec/extensions/hash_spec.rb +38 -0
  44. data/spec/extensions/string_spec.rb +13 -0
  45. data/spec/extensions/uri/http_spec.rb +40 -0
  46. data/spec/extensions/uri/query_params_spec.rb +38 -0
  47. data/spec/formatting/binary_spec.rb +65 -0
  48. data/spec/formatting/digest_spec.rb +54 -0
  49. data/spec/formatting/html_spec.rb +37 -0
  50. data/spec/formatting/http_spec.rb +44 -0
  51. data/spec/formatting/text_spec.rb +21 -0
  52. data/spec/license_spec.rb +20 -0
  53. data/spec/parameters/parameters_spec.rb +109 -0
  54. data/spec/path_spec.rb +34 -0
  55. data/spec/platform_spec.rb +24 -0
  56. data/spec/product_spec.rb +16 -0
  57. data/spec/ronin_spec.rb +11 -0
  58. data/spec/sessions/session_spec.rb +56 -0
  59. data/spec/spec_helper.rb +2 -0
  60. data/spec/target_spec.rb +16 -0
  61. metadata +39 -2
@@ -42,18 +42,6 @@ module Net
42
42
  return sock
43
43
  end
44
44
 
45
- #
46
- # Creates a new UDPSocket object with the specified _rhost_
47
- # _rport_, and the given _lhost_ and _lport_. The specified _block_
48
- # will be passed the first line received from the UDPSocket object.
49
- # The newly created UDPSocket object will be returned.
50
- #
51
- def Net.udp_connect_and_recv(rhost,rport,lhost=nil,lport=nil,&block)
52
- Net.udp_connect(rhost,rport,lhost,lport) do |sock|
53
- block.call(sock.read) if block
54
- end
55
- end
56
-
57
45
  #
58
46
  # Creates a new UDPSocket object with the specified _rhost_
59
47
  # _rport_, and the given _lhost_ and _lport_. The specified _data_ will
data/lib/ronin/objects.rb CHANGED
@@ -24,6 +24,4 @@
24
24
  require 'ronin/extensions/kernel'
25
25
  require 'ronin/object_context'
26
26
 
27
- module Ronin
28
- ronin_require 'ronin/objects'
29
- end
27
+ ronin_require 'ronin/objects'
@@ -43,13 +43,13 @@ module Ronin
43
43
  #
44
44
  # parameter 'var'
45
45
  #
46
- # parameter 'var', :value => 3, :description => 'my variable'
46
+ # parameter 'var', :default => 3, :description => 'my variable'
47
47
  #
48
48
  def parameter(name,options={})
49
49
  name = name.to_sym
50
50
 
51
51
  # add the parameter to the class params list
52
- params[name] = ClassParam.new(name,options[:description],options[:value])
52
+ params[name] = ClassParam.new(name,options[:description],options[:default])
53
53
 
54
54
  # define the reader class method for the parameter
55
55
  meta_def(name) do
@@ -73,10 +73,10 @@ module Ronin
73
73
  def get_param(name)
74
74
  name = name.to_sym
75
75
 
76
- ancestors.each do |superclass|
77
- if superclass.include?(Parameters)
78
- if superclass.params.has_key?(name)
79
- return superclass.params[name]
76
+ ancestors.each do |ancestor|
77
+ if ancestor.include?(Parameters)
78
+ if ancestor.params.has_key?(name)
79
+ return ancestor.params[name]
80
80
  end
81
81
  end
82
82
  end
@@ -91,9 +91,9 @@ module Ronin
91
91
  def has_param?(name)
92
92
  name = name.to_sym
93
93
 
94
- ancestors.each do |superclass|
95
- if superclass.include?(Parameters)
96
- return true if superclass.params.has_key?(name)
94
+ ancestors.each do |ancestor|
95
+ if ancestor.include?(Parameters)
96
+ return true if ancestor.params.has_key?(name)
97
97
  end
98
98
  end
99
99
 
@@ -105,9 +105,9 @@ module Ronin
105
105
  # specified _block_.
106
106
  #
107
107
  def each_param(&block)
108
- ancestors.each do |superclass|
109
- if superclass.include?(Parameters)
110
- superclass.params.each_value(&block)
108
+ ancestors.each do |ancestor|
109
+ if ancestor.include?(Parameters)
110
+ ancestor.params.each_value(&block)
111
111
  end
112
112
  end
113
113
 
@@ -159,13 +159,13 @@ module Ronin
159
159
  #
160
160
  # obj.parameter('var')
161
161
  #
162
- # obj.parameter('var',:value => 3, :description => 'my variable')
162
+ # obj.parameter('var',:default => 3, :description => 'my variable')
163
163
  #
164
164
  def parameter(name,options={})
165
165
  name = name.to_sym
166
166
 
167
167
  # set the instance variable
168
- instance_variable_set("@#{name}",options[:value])
168
+ instance_variable_set("@#{name}",options[:default])
169
169
 
170
170
  # add the new parameter
171
171
  params[name] = InstanceParam.new(self,name,options[:description])
@@ -247,8 +247,19 @@ module Ronin
247
247
  get_param(name).value
248
248
  end
249
249
 
250
- protected
250
+ #
251
+ # Sets the values of the parameters listed in the specified _values_.
252
+ #
253
+ # obj.set_params(:rhost => 'www.example.com', :rport => 80)
254
+ # # => {:rhost=>"www.example.com", :rport=>80}
255
+ #
256
+ def set_params(values={})
257
+ values.each do |name,value|
258
+ get_param(name).value = value
259
+ end
260
+ end
251
261
 
262
+ protected
252
263
 
253
264
  #
254
265
  # Initializes the specified class _param_.
@@ -37,6 +37,9 @@ module Ronin
37
37
  # Version of the Operating System
38
38
  property :version, String
39
39
 
40
+ # Validates
41
+ validates_present :os, :version
42
+
40
43
  #
41
44
  # Returns the String form of the Platform.
42
45
  #
@@ -72,7 +75,7 @@ module Ronin
72
75
  method_name = name.to_method_name
73
76
 
74
77
  meta_def(method_name) do
75
- Platform.find_or_new(:os => name)
78
+ Platform.new(:os => name)
76
79
  end
77
80
 
78
81
  meta_def("#{method_name}_version") do |version|
data/lib/ronin/product.rb CHANGED
@@ -41,6 +41,9 @@ module Ronin
41
41
  # Venders
42
42
  property :vendor, String
43
43
 
44
+ # Validates
45
+ validates_present :name, :version
46
+
44
47
  #
45
48
  # Returns the String form of the product.
46
49
  #
@@ -113,9 +113,11 @@ module Ronin
113
113
  else
114
114
  puts 'Available commands:'
115
115
 
116
- Program.commands.each do |cmd|
116
+ Program.commands.sort_by { |cmd|
117
+ cmd.command_names.first
118
+ }.each { |cmd|
117
119
  puts " #{cmd.command_names.join(', ')}"
118
- end
120
+ }
119
121
  end
120
122
  end
121
123
 
@@ -26,10 +26,10 @@ require 'ronin/network/esmtp'
26
26
 
27
27
  module Ronin
28
28
  module Sessions
29
- module SMTP
29
+ module ESMTP
30
30
  include Session
31
31
 
32
- ESMTP_SESSION = proc do
32
+ setup_session do
33
33
  parameter :esmtp_host, :description => 'ESMTP host'
34
34
  parameter :esmtp_port, :description => 'ESMTP port'
35
35
 
@@ -38,14 +38,6 @@ module Ronin
38
38
  parameter :esmtp_password, :description => 'ESMTP password'
39
39
  end
40
40
 
41
- def self.included(base)
42
- Session.setup_class(base,&ESMTP_SESSION)
43
- end
44
-
45
- def self.extended(obj)
46
- Session.setup_object(obj,&ESMTP_SESSION)
47
- end
48
-
49
41
  protected
50
42
 
51
43
  def esmtp_message(options={},&block)
@@ -29,7 +29,7 @@ module Ronin
29
29
  module IMAP
30
30
  include Session
31
31
 
32
- IMAP_SESSION = proc do
32
+ setup_session do
33
33
  parameter :imap_host, :description => 'IMAP host'
34
34
  parameter :imap_port, :description => 'IMAP port'
35
35
 
@@ -38,14 +38,6 @@ module Ronin
38
38
  parameter :imap_password, :description => 'IMAP password'
39
39
  end
40
40
 
41
- def self.included(base)
42
- Session.setup_class(base,&IMAP_SESSION)
43
- end
44
-
45
- def self.extended(obj)
46
- Session.setup_object(obj,&IMAP_SESSION)
47
- end
48
-
49
41
  protected
50
42
 
51
43
  def imap_connect(options={},&block)
@@ -29,7 +29,7 @@ module Ronin
29
29
  module POP3
30
30
  include Session
31
31
 
32
- POP3_SESSION = proc do
32
+ setup_session do
33
33
  parameter :pop3_host, :description => 'POP3 host'
34
34
  parameter :pop3_port, :description => 'POP3 port'
35
35
 
@@ -37,14 +37,6 @@ module Ronin
37
37
  parameter :pop3_password, :description => 'POP3 password'
38
38
  end
39
39
 
40
- def self.included(base)
41
- Session.setup_class(base,&POP3_SESSION)
42
- end
43
-
44
- def self.extended(obj)
45
- Session.setup_object(obj,&POP3_SESSION)
46
- end
47
-
48
40
  protected
49
41
 
50
42
  def pop3_connect(options={},&block)
@@ -21,31 +21,32 @@
21
21
  #++
22
22
  #
23
23
 
24
+ require 'ronin/extensions/meta'
24
25
  require 'ronin/parameters'
25
26
 
26
27
  module Ronin
27
28
  module Sessions
28
29
  module Session
29
- #
30
- # Includes Parameters and runs the _block_ in the specified
31
- # _base_class_.
32
- #
33
- def Session.setup_class(base_class,&block)
34
- base_class.module_eval { include Parameters }
35
- base_class.module_eval(&block)
30
+ def self.included(base)
31
+ base.module_eval do
32
+ def self.setup_session(&block)
33
+ #
34
+ # Includes Parameters and runs the _block_.
35
+ #
36
+ metaclass_def(:included) do |base_class|
37
+ base_class.class_eval { include Parameters }
38
+ base_class.class_eval(&block)
39
+ end
36
40
 
37
- return base_class
38
- end
39
-
40
- #
41
- # Extends Parameters and runs the specified _block_ in the specified
42
- # _obj_.
43
- #
44
- def Session.setup_object(obj,&block)
45
- obj.extend(Parameters)
46
- obj.instance_eval(&block)
47
-
48
- return obj
41
+ #
42
+ # Extends Parameters and runs the specified _block_.
43
+ #
44
+ metaclass_def(:extended) do |base_obj|
45
+ base_obj.extend Parameters
46
+ base_obj.instance_eval(&block)
47
+ end
48
+ end
49
+ end
49
50
  end
50
51
  end
51
52
  end
@@ -29,7 +29,7 @@ module Ronin
29
29
  module SMTP
30
30
  include Session
31
31
 
32
- SMTP_SESSION = proc do
32
+ setup_session do
33
33
  parameter :smtp_host, :description => 'SMTP host'
34
34
  parameter :smtp_port, :description => 'SMTP port'
35
35
 
@@ -38,14 +38,6 @@ module Ronin
38
38
  parameter :smtp_password, :description => 'SMTP password'
39
39
  end
40
40
 
41
- def self.included(base)
42
- Session.setup_class(base,&SMTP_SESSION)
43
- end
44
-
45
- def self.extended(obj)
46
- Session.setup_object(obj,&SMTP_SESSION)
47
- end
48
-
49
41
  protected
50
42
 
51
43
  def smtp_message(options={},&block)
@@ -29,7 +29,7 @@ module Ronin
29
29
  module TCP
30
30
  include Session
31
31
 
32
- TCP_SESSION = proc do
32
+ setup_session do
33
33
  parameter :lhost, :description => 'TCP local host'
34
34
  parameter :lport, :description => 'TCP local port'
35
35
 
@@ -37,14 +37,6 @@ module Ronin
37
37
  parameter :rport, :description => 'TCP remote port'
38
38
  end
39
39
 
40
- def self.included(base)
41
- Session.setup_class(base,&TCP_SESSION)
42
- end
43
-
44
- def self.extended(obj)
45
- Session.setup_object(obj,&TCP_SESSION)
46
- end
47
-
48
40
  protected
49
41
 
50
42
  def tcp_connect(&block)
@@ -59,18 +51,6 @@ module Ronin
59
51
  return ::Net.tcp_connect(@rhost,@rport,@lhost,@lport,&block)
60
52
  end
61
53
 
62
- def tcp_connect_and_recv(&block)
63
- unless @rhost
64
- raise(ParamNotFound,"Missing parameter '#{describe_param(:rhost)}'",caller)
65
- end
66
-
67
- unless @rport
68
- raise(ParamNotFound,"Missing parameter '#{describe_param(:rport)}'",caller)
69
- end
70
-
71
- return ::Net.tcp_connect_and_recv(@rhost,@rport,@lhost,@lport,&block)
72
- end
73
-
74
54
  def tcp_connect_and_send(data,&block)
75
55
  unless @rhost
76
56
  raise(ParamNotFound,"Missing parameter '#{describe_param(:rhost)}'",caller)
@@ -29,7 +29,7 @@ module Ronin
29
29
  module TELNET
30
30
  include Session
31
31
 
32
- TELNET_SESSION = proc do
32
+ setup_session do
33
33
  parameter :telnet_host, :description => 'Telnet host'
34
34
  parameter :telnet_port, :value => Network::Telnet.default_port, :description => 'Telnet port'
35
35
 
@@ -40,14 +40,6 @@ module Ronin
40
40
  parameter :telnet_ssl, :description => 'Telnet SSL options'
41
41
  end
42
42
 
43
- def self.included(base)
44
- Session.setup_class(base,&TELNET_SESSION)
45
- end
46
-
47
- def self.extended(obj)
48
- Session.setup_object(obj,&TELNET_SESSION)
49
- end
50
-
51
43
  protected
52
44
 
53
45
  def telnet_connect(options={},&block)
@@ -29,7 +29,7 @@ module Ronin
29
29
  module UDP
30
30
  include Parameters
31
31
 
32
- UDP_SESSION = proc do
32
+ setup_session do
33
33
  parameter :lhost, :description => 'local host'
34
34
  parameter :lport, :description => 'local port'
35
35
 
@@ -37,14 +37,6 @@ module Ronin
37
37
  parameter :rport, :description => 'remote port'
38
38
  end
39
39
 
40
- def self.included(base)
41
- Session.setup_class(base,&UDP_SESSION)
42
- end
43
-
44
- def self.extended(obj)
45
- Session.setup_object(obj,&UDP_SESSION)
46
- end
47
-
48
40
  protected
49
41
 
50
42
  def udp_connect(&block)
@@ -59,18 +51,6 @@ module Ronin
59
51
  return ::Net.udp_connect(@rhost,@rport,@lhost,@lport,&block)
60
52
  end
61
53
 
62
- def udp_connect_and_recv(&block)
63
- unless @rhost
64
- raise(ParamNotFound,"Missing '#{describe_param(:rhost)}' parameter",caller)
65
- end
66
-
67
- unless @rport
68
- raise(ParamNotFound,"Missing '#{describe_param(:rport)}' parameter",caller)
69
- end
70
-
71
- return ::Net.udp_connect_and_recv(@rhost,@rport,@lhost,@lport,&block)
72
- end
73
-
74
54
  def udp_connect_and_send(data,&block)
75
55
  unless @rhost
76
56
  raise(ParamNotFound,"Missing '#{describe_param(:rhost)}' parameter",caller)
@@ -29,19 +29,11 @@ module Ronin
29
29
  module Web
30
30
  include Session
31
31
 
32
- WEB_SESSION = proc do
32
+ setup_session do
33
33
  parameter :web_proxy, :value => Ronin::Web.proxy, :description => 'Web Proxy'
34
34
  parameter :web_user_agent, :value => Ronin::Web.user_agent, :description => 'Web User-Agent'
35
35
  end
36
36
 
37
- def self.included(base)
38
- Session.setup_class(base,&WEB_SESSION)
39
- end
40
-
41
- def self.extended(obj)
42
- Session.setup_object(obj,&WEB_SESSION)
43
- end
44
-
45
37
  protected
46
38
 
47
39
  def web_agent(options={},&block)