ronin 1.0.0 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/.yardopts +0 -1
  2. data/ChangeLog.md +67 -3
  3. data/Gemfile +20 -12
  4. data/README.md +3 -5
  5. data/gemspec.yml +5 -5
  6. data/lib/ronin/address.rb +8 -3
  7. data/lib/ronin/arch.rb +39 -14
  8. data/lib/ronin/author.rb +2 -0
  9. data/lib/ronin/auto_load.rb +67 -0
  10. data/lib/ronin/campaign.rb +15 -2
  11. data/lib/ronin/class_methods.rb +7 -1
  12. data/lib/ronin/config.rb +5 -0
  13. data/lib/ronin/credential.rb +14 -3
  14. data/lib/ronin/database/database.rb +38 -12
  15. data/lib/ronin/database/migrations.rb +3 -1
  16. data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
  17. data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
  18. data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
  19. data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
  20. data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
  21. data/lib/ronin/database/migrations/migration.rb +3 -6
  22. data/lib/ronin/database/migrations/migrations.rb +3 -3
  23. data/lib/ronin/email_address.rb +20 -3
  24. data/lib/ronin/environment.rb +0 -3
  25. data/lib/ronin/host_name.rb +20 -6
  26. data/lib/ronin/host_name_ip_address.rb +2 -3
  27. data/lib/ronin/installation.rb +92 -23
  28. data/lib/ronin/ip_address.rb +31 -8
  29. data/lib/ronin/ip_address_mac_address.rb +2 -3
  30. data/lib/ronin/license.rb +1 -1
  31. data/lib/ronin/mac_address.rb +6 -4
  32. data/lib/ronin/model/class_methods.rb +4 -0
  33. data/lib/ronin/model/has_authors/class_methods.rb +4 -0
  34. data/lib/ronin/model/has_authors/has_authors.rb +4 -0
  35. data/lib/ronin/model/has_description/class_methods.rb +2 -0
  36. data/lib/ronin/model/has_description/has_description.rb +2 -0
  37. data/lib/ronin/model/has_license/class_methods.rb +2 -0
  38. data/lib/ronin/model/has_license/has_license.rb +4 -0
  39. data/lib/ronin/model/has_name/class_methods.rb +2 -0
  40. data/lib/ronin/model/has_name/has_name.rb +4 -0
  41. data/lib/ronin/model/has_title/class_methods.rb +2 -0
  42. data/lib/ronin/model/has_title/has_title.rb +2 -0
  43. data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
  44. data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
  45. data/lib/ronin/model/has_version/class_methods.rb +4 -0
  46. data/lib/ronin/model/has_version/has_version.rb +2 -0
  47. data/lib/ronin/model/model.rb +2 -0
  48. data/lib/ronin/model/types.rb +1 -7
  49. data/lib/ronin/model/types/description.rb +2 -0
  50. data/lib/ronin/network/mixins/esmtp.rb +40 -25
  51. data/lib/ronin/network/mixins/http.rb +336 -73
  52. data/lib/ronin/network/mixins/imap.rb +38 -25
  53. data/lib/ronin/network/mixins/pop3.rb +34 -21
  54. data/lib/ronin/network/mixins/smtp.rb +40 -25
  55. data/lib/ronin/network/mixins/tcp.rb +66 -41
  56. data/lib/ronin/network/mixins/telnet.rb +43 -30
  57. data/lib/ronin/network/mixins/udp.rb +59 -40
  58. data/lib/ronin/open_port.rb +12 -5
  59. data/lib/ronin/organization.rb +1 -2
  60. data/lib/ronin/os.rb +10 -3
  61. data/lib/ronin/os_guess.rb +2 -3
  62. data/lib/ronin/password.rb +11 -3
  63. data/lib/ronin/port.rb +7 -2
  64. data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
  65. data/lib/ronin/repository.rb +110 -37
  66. data/lib/ronin/ronin.rb +4 -3
  67. data/lib/ronin/{engine.rb → script.rb} +2 -1
  68. data/lib/ronin/{engine → script}/buildable.rb +43 -29
  69. data/lib/ronin/script/class_methods.rb +84 -0
  70. data/lib/ronin/{engine → script}/deployable.rb +61 -40
  71. data/lib/ronin/{engine → script}/exceptions.rb +4 -3
  72. data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
  73. data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
  74. data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
  75. data/lib/ronin/script/exceptions/test_failed.rb +27 -0
  76. data/lib/ronin/script/instance_methods.rb +217 -0
  77. data/lib/ronin/script/path.rb +277 -0
  78. data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
  79. data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
  80. data/lib/ronin/service.rb +1 -2
  81. data/lib/ronin/service_credential.rb +1 -2
  82. data/lib/ronin/software.rb +3 -2
  83. data/lib/ronin/spec/database.rb +0 -4
  84. data/lib/ronin/target.rb +11 -3
  85. data/lib/ronin/tcp_port.rb +3 -2
  86. data/lib/ronin/udp_port.rb +2 -0
  87. data/lib/ronin/ui/cli/cli.rb +6 -0
  88. data/lib/ronin/ui/cli/command.rb +48 -12
  89. data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
  90. data/lib/ronin/ui/cli/commands/console.rb +2 -1
  91. data/lib/ronin/ui/cli/commands/creds.rb +3 -3
  92. data/lib/ronin/ui/cli/commands/database.rb +1 -17
  93. data/lib/ronin/ui/cli/commands/emails.rb +3 -3
  94. data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
  95. data/lib/ronin/ui/cli/commands/ips.rb +3 -7
  96. data/lib/ronin/ui/cli/commands/repos.rb +5 -17
  97. data/lib/ronin/ui/cli/commands/urls.rb +3 -3
  98. data/lib/ronin/ui/cli/model_command.rb +82 -97
  99. data/lib/ronin/ui/cli/resources_command.rb +89 -0
  100. data/lib/ronin/ui/cli/script_command.rb +115 -0
  101. data/lib/ronin/ui/console.rb +17 -3
  102. data/lib/ronin/ui/output/helpers.rb +18 -0
  103. data/lib/ronin/ui/output/output.rb +20 -1
  104. data/lib/ronin/ui/output/terminal/color.rb +10 -0
  105. data/lib/ronin/ui/output/terminal/raw.rb +10 -0
  106. data/lib/ronin/ui/shell.rb +2 -0
  107. data/lib/ronin/url.rb +47 -12
  108. data/lib/ronin/url_query_param.rb +4 -0
  109. data/lib/ronin/url_scheme.rb +3 -3
  110. data/lib/ronin/user_name.rb +2 -0
  111. data/lib/ronin/version.rb +1 -1
  112. data/lib/ronin/web_credential.rb +6 -3
  113. data/spec/arch_spec.rb +3 -3
  114. data/spec/classes/my_script.rb +21 -0
  115. data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
  116. data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
  117. data/spec/helpers/repos/local/lib/init.rb +1 -0
  118. data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
  119. data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
  120. data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
  121. data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
  122. data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
  123. data/spec/helpers/repos/remote/scripts/.keep +0 -0
  124. data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
  125. data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
  126. data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
  127. data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
  128. data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
  129. data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
  130. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
  131. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
  132. data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
  133. data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
  134. data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
  135. data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
  136. data/spec/model/spec_helper.rb +0 -2
  137. data/spec/repository_spec.rb +61 -81
  138. data/spec/ronin_spec.rb +2 -2
  139. data/spec/{engine → script}/buildable_spec.rb +9 -9
  140. data/spec/script/classes/buildable_class.rb +15 -0
  141. data/spec/script/classes/deployable_class.rb +13 -0
  142. data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
  143. data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
  144. data/spec/{engine → script}/deployable_spec.rb +10 -10
  145. data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
  146. data/spec/script/script_spec.rb +130 -0
  147. data/spec/script/testable_spec.rb +117 -0
  148. data/spec/spec_helper.rb +15 -13
  149. metadata +114 -139
  150. data/lib/ronin/cached_file.rb +0 -247
  151. data/lib/ronin/engine/class_methods.rb +0 -135
  152. data/lib/ronin/engine/instance_methods.rb +0 -97
  153. data/lib/ronin/model/cacheable.rb +0 -21
  154. data/lib/ronin/model/cacheable/cacheable.rb +0 -273
  155. data/lib/ronin/model/cacheable/class_methods.rb +0 -60
  156. data/lib/ronin/ui/cli/engine_command.rb +0 -106
  157. data/spec/engine/classes/buildable_class.rb +0 -15
  158. data/spec/engine/classes/deployable_class.rb +0 -13
  159. data/spec/engine/engine_spec.rb +0 -55
  160. data/spec/engine/verifiable_spec.rb +0 -117
  161. data/spec/helpers/repos/hello/lib/init.rb +0 -1
  162. data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
  163. data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
  164. data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
  165. data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
  166. data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
  167. data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
  168. data/spec/model/cacheable_spec.rb +0 -96
  169. data/spec/model/models/cacheable_model.rb +0 -13
@@ -18,13 +18,12 @@
18
18
  #
19
19
 
20
20
  require 'ronin/model'
21
+ require 'ronin/user_name'
22
+ require 'ronin/host_name'
21
23
 
22
24
  require 'dm-timestamps'
23
25
 
24
26
  module Ronin
25
- autoload :UserName, 'ronin/user_name'
26
- autoload :HostName, 'ronin/host_name'
27
-
28
27
  #
29
28
  # Represents email addresses that can be stored in the {Database}.
30
29
  #
@@ -65,6 +64,8 @@ module Ronin
65
64
  #
66
65
  # @since 1.0.0
67
66
  #
67
+ # @api public
68
+ #
68
69
  def self.with_hosts(names)
69
70
  all(:host_name => {:address => names})
70
71
  end
@@ -80,6 +81,8 @@ module Ronin
80
81
  #
81
82
  # @since 1.0.0
82
83
  #
84
+ # @api public
85
+ #
83
86
  def self.with_ips(ips)
84
87
  all(:ip_addresses => {:address => ips})
85
88
  end
@@ -95,6 +98,8 @@ module Ronin
95
98
  #
96
99
  # @since 1.0.0
97
100
  #
101
+ # @api public
102
+ #
98
103
  def self.with_users(names)
99
104
  all(:user_name => {:name => names})
100
105
  end
@@ -113,6 +118,8 @@ module Ronin
113
118
  #
114
119
  # @since 1.0.0
115
120
  #
121
+ # @api public
122
+ #
116
123
  def EmailAddress.parse(email)
117
124
  user, host = email.split('@',2)
118
125
 
@@ -142,6 +149,8 @@ module Ronin
142
149
  #
143
150
  # @since 1.0.0
144
151
  #
152
+ # @api public
153
+ #
145
154
  def user
146
155
  self.user_name.name if self.user_name
147
156
  end
@@ -154,6 +163,8 @@ module Ronin
154
163
  #
155
164
  # @since 1.0.0
156
165
  #
166
+ # @api public
167
+ #
157
168
  def host
158
169
  self.host_name.address if self.host_name
159
170
  end
@@ -166,6 +177,8 @@ module Ronin
166
177
  #
167
178
  # @since 1.0.0
168
179
  #
180
+ # @api public
181
+ #
169
182
  def to_s
170
183
  "#{self.user_name}@#{self.host_name}"
171
184
  end
@@ -178,6 +191,8 @@ module Ronin
178
191
  #
179
192
  # @since 1.0.0
180
193
  #
194
+ # @api public
195
+ #
181
196
  def inspect
182
197
  "#<#{self.class}: #{self}>"
183
198
  end
@@ -199,6 +214,8 @@ module Ronin
199
214
  #
200
215
  # @since 1.0.0
201
216
  #
217
+ # @api public
218
+ #
202
219
  def to_ary
203
220
  [self.user_name.name, self.host_name.address]
204
221
  end
@@ -26,9 +26,6 @@ require 'ronin/formatting/extensions'
26
26
  require 'ronin/network/extensions'
27
27
  require 'ronin/ui/output/helpers'
28
28
 
29
- require 'chars/extensions'
30
- require 'hexdump/extensions'
31
-
32
29
  #
33
30
  # Includes the Ronin namespace and output helper methods.
34
31
  #
@@ -18,15 +18,13 @@
18
18
  #
19
19
 
20
20
  require 'ronin/address'
21
- require 'ronin/model'
21
+ require 'ronin/host_name_ip_address'
22
+ require 'ronin/url'
23
+ require 'ronin/email_address'
22
24
 
23
25
  require 'resolv'
24
26
 
25
27
  module Ronin
26
- autoload :HostNameIPAddress, 'ronin/host_name_ip_address'
27
- autoload :URL, 'ronin/url'
28
- autoload :EmailAddress, 'ronin/email_address'
29
-
30
28
  #
31
29
  # Represents host names that can be stored in the {Database}.
32
30
  #
@@ -67,6 +65,8 @@ module Ronin
67
65
  #
68
66
  # @since 1.0.0
69
67
  #
68
+ # @api public
69
+ #
70
70
  def self.with_ips(ips)
71
71
  all(:ip_addresses => {:address => ips})
72
72
  end
@@ -82,6 +82,8 @@ module Ronin
82
82
  #
83
83
  # @since 1.0.0
84
84
  #
85
+ # @api public
86
+ #
85
87
  def self.with_ports(numbers)
86
88
  all(:ports => {:number => numbers})
87
89
  end
@@ -97,6 +99,8 @@ module Ronin
97
99
  #
98
100
  # @since 1.0.0
99
101
  #
102
+ # @api public
103
+ #
100
104
  def self.tld(name)
101
105
  all(:address.like => "%.#{name}")
102
106
  end
@@ -112,6 +116,8 @@ module Ronin
112
116
  #
113
117
  # @since 1.0.0
114
118
  #
119
+ # @api public
120
+ #
115
121
  def self.domain(name)
116
122
  all(:address.like => "#{name}.%") |
117
123
  all(:address.like => "%.#{name}.%")
@@ -128,6 +134,8 @@ module Ronin
128
134
  #
129
135
  # @since 1.0.0
130
136
  #
137
+ # @api public
138
+ #
131
139
  def self.lookup(addr)
132
140
  addr = addr.to_s
133
141
  ip = IPAddress.first_or_new(:address => addr)
@@ -157,6 +165,8 @@ module Ronin
157
165
  #
158
166
  # @since 1.0.0
159
167
  #
168
+ # @api public
169
+ #
160
170
  def lookup!
161
171
  ips = begin
162
172
  Resolv.getaddresses(self.address)
@@ -182,6 +192,8 @@ module Ronin
182
192
  #
183
193
  # @since 1.0.0
184
194
  #
195
+ # @api public
196
+ #
185
197
  def recent_ip_address
186
198
  self.host_name_ip_addresses.all(
187
199
  :order => [:created_at.desc]
@@ -196,9 +208,11 @@ module Ronin
196
208
  #
197
209
  # @since 1.0.0
198
210
  #
211
+ # @api public
212
+ #
199
213
  def last_scanned_at
200
214
  last_scanned_url = self.urls.first(
201
- :order_by => [:last_scanned_at.desc]
215
+ :order => [:last_scanned_at.desc]
202
216
  )
203
217
 
204
218
  return last_scanned_url.last_scanned_at if last_scanned_url
@@ -18,13 +18,12 @@
18
18
  #
19
19
 
20
20
  require 'ronin/model'
21
+ require 'ronin/host_name'
22
+ require 'ronin/ip_address'
21
23
 
22
24
  require 'dm-timestamps'
23
25
 
24
26
  module Ronin
25
- autoload :HostName, 'ronin/host_name'
26
- autoload :IPAddress, 'ronin/ip_address'
27
-
28
27
  #
29
28
  # Associates a {HostName} with an {IPAddress}.
30
29
  #
@@ -17,6 +17,8 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
+ require 'set'
21
+
20
22
  module Ronin
21
23
  #
22
24
  # The {Installation} module provides methods which help reflect on the
@@ -25,6 +27,7 @@ module Ronin
25
27
  module Installation
26
28
  # The loaded gemspecs of all installed ronin libraries
27
29
  @gems = {}
30
+ @paths = Set[]
28
31
 
29
32
  #
30
33
  # Finds the installed Ronin libraries via RubyGems.
@@ -34,11 +37,28 @@ module Ronin
34
37
  #
35
38
  # @since 1.0.0
36
39
  #
40
+ # @api semipublic
41
+ #
37
42
  def Installation.gems
38
- load_gemspecs! if @gems.empty?
43
+ load! if @gems.empty?
39
44
  return @gems
40
45
  end
41
46
 
47
+ #
48
+ # The paths of the installed Ronin libraries.
49
+ #
50
+ # @return [Set<String>]
51
+ # The paths of the Ronin libraries.
52
+ #
53
+ # @since 1.0.1
54
+ #
55
+ # @api semipublic
56
+ #
57
+ def Installation.paths
58
+ load! if @paths.empty?
59
+ return @paths
60
+ end
61
+
42
62
  #
43
63
  # The names of the additional Ronin libraries installed on the system.
44
64
  #
@@ -47,6 +67,8 @@ module Ronin
47
67
  #
48
68
  # @since 1.0.0
49
69
  #
70
+ # @api semipublic
71
+ #
50
72
  def Installation.libraries
51
73
  gems.keys
52
74
  end
@@ -69,15 +91,16 @@ module Ronin
69
91
  #
70
92
  # @since 1.0.0
71
93
  #
94
+ # @api semipublic
95
+ #
72
96
  def Installation.each_file(pattern)
73
97
  return enum_for(:each_file,pattern) unless block_given?
74
98
 
75
99
  # query the installed gems
76
- gems.each_value do |gem|
77
- gem_root = gem.full_gem_path
78
- slice_index = gem_root.length + 1
100
+ paths.each do |gem_path|
101
+ slice_index = gem_path.length + 1
79
102
 
80
- Dir.glob(File.join(gem_root,pattern)) do |path|
103
+ Dir.glob(File.join(gem_path,pattern)) do |path|
81
104
  yield path[slice_index..-1]
82
105
  end
83
106
  end
@@ -105,6 +128,8 @@ module Ronin
105
128
  #
106
129
  # @since 1.0.0
107
130
  #
131
+ # @api semipublic
132
+ #
108
133
  def Installation.each_file_in(directory,ext=nil)
109
134
  return enum_for(:each_file_in,directory,ext) unless block_given?
110
135
 
@@ -121,38 +146,82 @@ module Ronin
121
146
  protected
122
147
 
123
148
  #
124
- # Loads the gemspecs for any installed Ronin libraries.
149
+ # Finds the installed Ronin gems.
125
150
  #
126
151
  # @return [true]
127
152
  # All Ronin libraries were successfully found.
128
153
  #
129
- # @since 1.0.0
154
+ # @since 1.0.1
130
155
  #
131
- def Installation.load_gemspecs!
156
+ # @api private
157
+ #
158
+ def Installation.load_gems!
159
+ register_gem = lambda { |gem|
160
+ @gems[gem.name] = gem
161
+ @paths << gem.full_gem_path
162
+ }
163
+
132
164
  ronin_gem = Gem.loaded_specs['ronin']
133
165
 
134
- if ronin_gem
135
- @gems['ronin'] = ronin_gem
166
+ # add the main ronin gem
167
+ register_gem[ronin_gem]
136
168
 
137
- ronin_gem.dependent_gems.each do |gems|
138
- gem = gems.first
139
- @gems[gem.name] = gem
140
- end
141
- else
142
- # if we cannot find an installed ronin gem, search the $LOAD_PATH
143
- # for ronin gemspecs and load those
144
- $LOAD_PATH.each do |lib_dir|
145
- root_dir = File.expand_path(File.join(lib_dir,'..'))
146
- gemspec_path = Dir[File.join(root_dir,'ronin*.gemspec')].first
147
-
148
- if gemspec_path
149
- gem = Gem::SourceIndex.load_specification(gemspec_path)
169
+ # add any dependent gems
170
+ ronin_gem.dependent_gems.each do |gems|
171
+ register_gem[gems[0]]
172
+ end
173
+
174
+ return true
175
+ end
176
+
177
+ #
178
+ # Loads the gemspecs of Ronin libraries from the `$LOAD_PATH`.
179
+ #
180
+ # @return [true]
181
+ # All Ronin gemspecs were successfully found.
182
+ #
183
+ # @since 1.0.0
184
+ #
185
+ # @api private
186
+ #
187
+ def Installation.load_gemspecs!
188
+ $LOAD_PATH.each do |lib_dir|
189
+ root_dir = File.expand_path(File.join(lib_dir,'..'))
190
+ gemspec_path = Dir[File.join(root_dir,'ronin*.gemspec')][0]
191
+
192
+ if gemspec_path
193
+ # switch into the gem directory, before loading the gemspec
194
+ gem = Dir.chdir(root_dir) do
195
+ Gem::Specification.load(gemspec_path)
196
+ end
197
+
198
+ # do not add duplicate ronin gems
199
+ unless @gems.has_key?(gem.name)
150
200
  @gems[gem.name] = gem
201
+ @paths << root_dir
151
202
  end
152
203
  end
153
204
  end
154
205
 
155
206
  return true
156
207
  end
208
+
209
+ #
210
+ # Finds the installed Ronin libraries.
211
+ #
212
+ # @return [true]
213
+ # All Ronin libraries were successfully found.
214
+ #
215
+ # @since 1.0.1
216
+ #
217
+ # @api private
218
+ #
219
+ def Installation.load!
220
+ if Gem.loaded_specs.has_key?('ronin')
221
+ load_gems!
222
+ else
223
+ load_gemspecs!
224
+ end
225
+ end
157
226
  end
158
227
  end
@@ -17,19 +17,16 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model'
21
20
  require 'ronin/address'
21
+ require 'ronin/ip_address_mac_address'
22
+ require 'ronin/host_name_ip_address'
23
+ require 'ronin/os'
24
+ require 'ronin/open_port'
22
25
 
23
26
  require 'ipaddr'
24
27
  require 'resolv'
25
28
 
26
29
  module Ronin
27
- autoload :IPAddressMACAddress, 'ronin/ip_address_mac_address'
28
- autoload :HostNameIPAddress, 'ronin/host_name_ip_address'
29
- autoload :OSGuess, 'ronin/os_guess'
30
- autoload :OS, 'ronin/os'
31
- autoload :OpenPort, 'ronin/open_port'
32
-
33
30
  #
34
31
  # Represents IP addresses that can be stored in the {Database}.
35
32
  #
@@ -86,6 +83,8 @@ module Ronin
86
83
  #
87
84
  # @since 1.0.0
88
85
  #
86
+ # @api public
87
+ #
89
88
  def self.v4
90
89
  all(:version => 4)
91
90
  end
@@ -98,6 +97,8 @@ module Ronin
98
97
  #
99
98
  # @since 1.0.0
100
99
  #
100
+ # @api public
101
+ #
101
102
  def self.v6
102
103
  all(:version => 6)
103
104
  end
@@ -113,6 +114,8 @@ module Ronin
113
114
  #
114
115
  # @since 1.0.0
115
116
  #
117
+ # @api public
118
+ #
116
119
  def self.with_macs(macs)
117
120
  all(:mac_addresses => {:address => macs})
118
121
  end
@@ -128,6 +131,8 @@ module Ronin
128
131
  #
129
132
  # @since 1.0.0
130
133
  #
134
+ # @api public
135
+ #
131
136
  def self.with_hosts(names)
132
137
  all(:host_names => {:address => names})
133
138
  end
@@ -143,6 +148,8 @@ module Ronin
143
148
  #
144
149
  # @since 1.0.0
145
150
  #
151
+ # @api public
152
+ #
146
153
  def self.with_ports(numbers)
147
154
  all(:ports => {:number => numbers})
148
155
  end
@@ -158,6 +165,8 @@ module Ronin
158
165
  #
159
166
  # @since 1.0.0
160
167
  #
168
+ # @api public
169
+ #
161
170
  def self.lookup(name)
162
171
  host = HostName.first_or_new(:address => name)
163
172
  ips = begin
@@ -184,6 +193,8 @@ module Ronin
184
193
  #
185
194
  # @since 1.0.0
186
195
  #
196
+ # @api public
197
+ #
187
198
  def lookup!
188
199
  hosts = begin
189
200
  Resolv.getnames(self.address.to_s)
@@ -209,6 +220,8 @@ module Ronin
209
220
  #
210
221
  # @since 1.0.0
211
222
  #
223
+ # @api public
224
+ #
212
225
  def recent_mac_address
213
226
  self.ip_address_mac_addresses.all(
214
227
  :order => [:created_at.desc]
@@ -223,6 +236,8 @@ module Ronin
223
236
  #
224
237
  # @since 1.0.0
225
238
  #
239
+ # @api public
240
+ #
226
241
  def recent_host_name
227
242
  self.host_name_ip_addresses.all(
228
243
  :order => [:created_at.desc]
@@ -238,6 +253,8 @@ module Ronin
238
253
  #
239
254
  # @since 1.0.0
240
255
  #
256
+ # @api public
257
+ #
241
258
  def recent_os_guess
242
259
  self.os_guesses.all(:order => [:created_at.desc]).oses.first
243
260
  end
@@ -250,9 +267,11 @@ module Ronin
250
267
  #
251
268
  # @since 1.0.0
252
269
  #
270
+ # @api public
271
+ #
253
272
  def last_scanned_at
254
273
  last_scanned_port = self.open_ports.first(
255
- :order_by => [:last_scanned_at.desc]
274
+ :order => [:last_scanned_at.desc]
256
275
  )
257
276
 
258
277
  return last_scanned_port.last_scanned_at if last_scanned_port
@@ -266,6 +285,8 @@ module Ronin
266
285
  #
267
286
  # @since 1.0.0
268
287
  #
288
+ # @api public
289
+ #
269
290
  def to_ip
270
291
  self.address
271
292
  end
@@ -278,6 +299,8 @@ module Ronin
278
299
  #
279
300
  # @since 1.0.0
280
301
  #
302
+ # @api public
303
+ #
281
304
  def to_i
282
305
  self.address.to_i
283
306
  end