ronin 1.0.0.pre4 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.gemtest +0 -0
  2. data/ChangeLog.md +1 -0
  3. data/Gemfile +3 -1
  4. data/README.md +17 -19
  5. data/Rakefile +1 -0
  6. data/gemspec.yml +2 -1
  7. data/lib/ronin.rb +3 -0
  8. data/lib/ronin/address.rb +7 -3
  9. data/lib/ronin/arch.rb +2 -2
  10. data/lib/ronin/bootstrap.rb +3 -0
  11. data/lib/ronin/cached_file.rb +1 -1
  12. data/lib/ronin/campaign.rb +3 -32
  13. data/lib/ronin/class_methods.rb +17 -0
  14. data/lib/ronin/config.rb +25 -24
  15. data/lib/ronin/credential.rb +3 -0
  16. data/lib/ronin/database/migrations.rb +0 -1
  17. data/lib/ronin/database/migrations/create_credentials_table.rb +1 -2
  18. data/lib/ronin/database/migrations/graph.rb +6 -3
  19. data/lib/ronin/database/migrations/migration.rb +3 -0
  20. data/lib/ronin/database/migrations/migrations.rb +2 -2
  21. data/lib/ronin/email_address.rb +3 -0
  22. data/lib/ronin/engine/buildable.rb +3 -0
  23. data/lib/ronin/engine/class_methods.rb +3 -0
  24. data/lib/ronin/engine/deployable.rb +3 -0
  25. data/lib/ronin/engine/engine.rb +14 -0
  26. data/lib/ronin/engine/instance_methods.rb +3 -0
  27. data/lib/ronin/engine/verifiable.rb +3 -0
  28. data/lib/ronin/environment.rb +6 -0
  29. data/lib/ronin/host_name.rb +3 -0
  30. data/lib/ronin/host_name_ip_address.rb +3 -0
  31. data/lib/ronin/ip_address.rb +3 -0
  32. data/lib/ronin/ip_address_mac_address.rb +3 -0
  33. data/lib/ronin/license.rb +1 -1
  34. data/lib/ronin/mac_address.rb +3 -0
  35. data/lib/ronin/model/cacheable/cacheable.rb +1 -1
  36. data/lib/ronin/model/class_methods.rb +3 -0
  37. data/lib/ronin/model/has_authors/class_methods.rb +4 -0
  38. data/lib/ronin/model/has_authors/has_authors.rb +9 -5
  39. data/lib/ronin/model/has_description/class_methods.rb +4 -0
  40. data/lib/ronin/model/has_description/has_description.rb +6 -0
  41. data/lib/ronin/model/has_license/class_methods.rb +4 -0
  42. data/lib/ronin/model/has_license/has_license.rb +9 -5
  43. data/lib/ronin/model/has_name/class_methods.rb +4 -0
  44. data/lib/ronin/model/has_name/has_name.rb +6 -0
  45. data/lib/ronin/model/has_title/class_methods.rb +4 -0
  46. data/lib/ronin/model/has_title/has_title.rb +6 -0
  47. data/lib/ronin/model/has_unique_name.rb +7 -0
  48. data/lib/ronin/model/has_version/class_methods.rb +4 -0
  49. data/lib/ronin/model/has_version/has_version.rb +6 -0
  50. data/lib/ronin/model/model.rb +7 -0
  51. data/lib/ronin/model/types/description.rb +7 -2
  52. data/lib/ronin/open_port.rb +3 -0
  53. data/lib/ronin/organization.rb +3 -0
  54. data/lib/ronin/os.rb +2 -2
  55. data/lib/ronin/os_guess.rb +3 -0
  56. data/lib/ronin/password.rb +4 -1
  57. data/lib/ronin/port.rb +6 -1
  58. data/lib/ronin/ronin.rb +8 -0
  59. data/lib/ronin/service.rb +3 -0
  60. data/lib/ronin/service_credential.rb +3 -0
  61. data/lib/ronin/target.rb +3 -4
  62. data/lib/ronin/tcp_port.rb +4 -1
  63. data/lib/ronin/udp_port.rb +4 -1
  64. data/lib/ronin/ui/cli/cli.rb +1 -1
  65. data/lib/ronin/ui/cli/command.rb +6 -0
  66. data/lib/ronin/ui/cli/commands/repos.rb +33 -0
  67. data/lib/ronin/ui/cli/engine_command.rb +3 -0
  68. data/lib/ronin/ui/cli/model_command.rb +3 -0
  69. data/lib/ronin/ui/console.rb +5 -1
  70. data/lib/ronin/ui/hexdump/hexdump.rb +3 -0
  71. data/lib/ronin/ui/output/helpers.rb +59 -26
  72. data/lib/ronin/ui/output/output.rb +3 -0
  73. data/lib/ronin/ui/output/terminal/color.rb +32 -20
  74. data/lib/ronin/ui/output/terminal/raw.rb +23 -20
  75. data/lib/ronin/ui/shell.rb +3 -0
  76. data/lib/ronin/url.rb +8 -5
  77. data/lib/ronin/url_query_param.rb +3 -0
  78. data/lib/ronin/url_scheme.rb +3 -0
  79. data/lib/ronin/user_name.rb +4 -1
  80. data/lib/ronin/vendor.rb +1 -1
  81. data/lib/ronin/version.rb +1 -1
  82. data/lib/ronin/web_credential.rb +4 -1
  83. data/ronin.gemspec +7 -2
  84. data/spec/campaign_spec.rb +0 -25
  85. data/spec/url_spec.rb +5 -2
  86. metadata +48 -36
  87. data/lib/ronin/database/migrations/create_remote_files_table.rb +0 -52
  88. data/lib/ronin/proxy.rb +0 -178
  89. data/lib/ronin/proxy_credential.rb +0 -29
  90. data/lib/ronin/remote_file.rb +0 -152
@@ -22,10 +22,15 @@ require 'dm-core'
22
22
  module Ronin
23
23
  module Model
24
24
  module Types
25
+ #
26
+ # The Description property type is similar to the `Text` type,
27
+ # but automatically strips all leading and tailing white-space
28
+ # from every line.
29
+ #
25
30
  class Description < DataMapper::Property::Text
26
31
 
27
32
  #
28
- # Typecasts the description.
33
+ # Type-casts the description.
29
34
  #
30
35
  # @param [Object] value
31
36
  # The text of the description.
@@ -34,7 +39,7 @@ module Ronin
34
39
  # The description property.
35
40
  #
36
41
  # @return [String, nil]
37
- # The typecasted description.
42
+ # The type-casted description.
38
43
  #
39
44
  # @since 1.0.0
40
45
  #
@@ -27,6 +27,9 @@ require 'dm-timestamps'
27
27
  require 'dm-tags'
28
28
 
29
29
  module Ronin
30
+ #
31
+ # Represents a open port at a specified IP address.
32
+ #
30
33
  class OpenPort
31
34
 
32
35
  include Model
@@ -26,6 +26,9 @@ require 'dm-timestamps'
26
26
  require 'dm-tags'
27
27
 
28
28
  module Ronin
29
+ #
30
+ # Represents an Organization which owns {Address}es.
31
+ #
29
32
  class Organization
30
33
 
31
34
  include Model
data/lib/ronin/os.rb CHANGED
@@ -25,7 +25,7 @@ require 'ronin/extensions/meta'
25
25
 
26
26
  module Ronin
27
27
  #
28
- # Represents an Operating System and predefines other common ones
28
+ # Represents an Operating System and pre-defines other common ones
29
29
  # ({linux}, {freebsd}, {openbsd}, {netbsd}, {osx}, {solaris}, {windows}
30
30
  # and {unix}).
31
31
  #
@@ -109,7 +109,7 @@ module Ronin
109
109
  # Defines a new predefined OS.
110
110
  #
111
111
  # @param [Symbol, String] name
112
- # The method name to define for the builtin OS.
112
+ # The method name to define for the predefined OS.
113
113
  #
114
114
  # @param [String] os_name
115
115
  # The name of the OS.
@@ -24,6 +24,9 @@ require 'ronin/model'
24
24
  require 'dm-timestamps'
25
25
 
26
26
  module Ronin
27
+ #
28
+ # Represents a guess about what {OS} an {IPAddress} might be running.
29
+ #
27
30
  class OSGuess
28
31
 
29
32
  include Model
@@ -23,6 +23,9 @@ require 'ronin/model'
23
23
  require 'digest'
24
24
 
25
25
  module Ronin
26
+ #
27
+ # Represents a password that can be stored in the {Database}.
28
+ #
26
29
  class Password
27
30
 
28
31
  include Model
@@ -59,7 +62,7 @@ module Ronin
59
62
  # The hex-digest of the hashed password.
60
63
  #
61
64
  # @raise [ArgumentError]
62
- # Unknown Digest alogrithm.
65
+ # Unknown Digest algorithm.
63
66
  #
64
67
  # @example
65
68
  # pass = Password.new(:clear_text => 'secret')
data/lib/ronin/port.rb CHANGED
@@ -21,6 +21,9 @@ require 'ronin/open_port'
21
21
  require 'ronin/model'
22
22
 
23
23
  module Ronin
24
+ #
25
+ # Represents a TCP or UDP port.
26
+ #
24
27
  class Port
25
28
 
26
29
  include Model
@@ -28,13 +31,15 @@ module Ronin
28
31
  # Primary key of the port
29
32
  property :id, Serial
30
33
 
31
- # The protocol of the port (tcp/udp)
34
+ # The protocol of the port (either `'tcp'` / `'udp'`)
32
35
  property :protocol, String, :set => ['tcp', 'udp'],
33
36
  :required => true,
34
37
  :unique_index => :protocol_port
35
38
 
36
39
  # The port number
37
40
  property :number, Integer, :required => true,
41
+ :min => 1,
42
+ :max => 65535,
38
43
  :unique_index => :protocol_port
39
44
 
40
45
  # The open ports
data/lib/ronin/ronin.rb CHANGED
@@ -24,6 +24,14 @@ require 'open_namespace'
24
24
  module Ronin
25
25
  include OpenNamespace
26
26
 
27
+ #
28
+ # Includes {ClassMethods} when {Ronin} is included.
29
+ #
30
+ # @param [Class, Module] base
31
+ # The class or module that {Ronin} is being included into.
32
+ #
33
+ # @since 1.0.0
34
+ #
27
35
  def self.included(base)
28
36
  base.send :extend, ClassMethods
29
37
  end
data/lib/ronin/service.rb CHANGED
@@ -22,6 +22,9 @@ require 'ronin/model'
22
22
  require 'ronin/model/has_unique_name'
23
23
 
24
24
  module Ronin
25
+ #
26
+ # Represents a TCP/UDP Service that runs on various common ports.
27
+ #
25
28
  class Service
26
29
 
27
30
  include Model
@@ -21,6 +21,9 @@ require 'ronin/credential'
21
21
  require 'ronin/open_port'
22
22
 
23
23
  module Ronin
24
+ #
25
+ # Represents Credentials used to access a TCP/UDP {Service}.
26
+ #
24
27
  class ServiceCredential < Credential
25
28
 
26
29
  belongs_to :open_port, :required => false
data/lib/ronin/target.rb CHANGED
@@ -19,12 +19,14 @@
19
19
 
20
20
  require 'ronin/campaign'
21
21
  require 'ronin/address'
22
- require 'ronin/remote_file'
23
22
  require 'ronin/model'
24
23
 
25
24
  require 'fileutils'
26
25
 
27
26
  module Ronin
27
+ #
28
+ # Represents an {Address} targeted by a {Campaign}.
29
+ #
28
30
  class Target
29
31
 
30
32
  include Model
@@ -41,9 +43,6 @@ module Ronin
41
43
  # The organization that is being targeted
42
44
  has 1, :organization, :through => :address
43
45
 
44
- # The remote files recovered from the target
45
- has 0..n, :remote_files
46
-
47
46
  # Validates the uniqueness of the address and the campaign.
48
47
  validates_uniqueness_of :address, :scope => [:campaign]
49
48
 
@@ -21,6 +21,9 @@ require 'ronin/port'
21
21
  require 'ronin/url'
22
22
 
23
23
  module Ronin
24
+ #
25
+ # Represents a TCP {Port}.
26
+ #
24
27
  class TCPPort < Port
25
28
 
26
29
  # The URLs that use the port
@@ -30,7 +33,7 @@ module Ronin
30
33
  # Creates a new {TCPPort} resource.
31
34
  #
32
35
  # @param [Hash] attributes
33
- # The attribute names and values to initialize the tcp port with.
36
+ # The attribute names and values to initialize the TCP port with.
34
37
  #
35
38
  def initialize(attributes={})
36
39
  super(attributes.merge(:protocol => 'tcp'))
@@ -20,13 +20,16 @@
20
20
  require 'ronin/port'
21
21
 
22
22
  module Ronin
23
+ #
24
+ # Represents a UDP {Port}.
25
+ #
23
26
  class UDPPort < Port
24
27
 
25
28
  #
26
29
  # Creates a new {UDPPort} resource.
27
30
  #
28
31
  # @param [Hash] attributes
29
- # The attribute names and values to initialize the udp port with.
32
+ # The attribute names and values to initialize the UDP port with.
30
33
  #
31
34
  def initialize(attributes={})
32
35
  super(attributes.merge(:protocol => 'udp'))
@@ -24,7 +24,7 @@ require 'ronin/installation'
24
24
  module Ronin
25
25
  module UI
26
26
  #
27
- # The {CLI} provides an extendable Command Line Interface (CLI)
27
+ # The {CLI} provides an extensible Command Line Interface (CLI)
28
28
  # for Ronin. The {CLI} can load any sub-command using the
29
29
  # {command} method, from the `ronin/ui/cli/commands`
30
30
  # directory.
@@ -117,6 +117,12 @@ module Ronin
117
117
  class_option :color, :type => :boolean, :default => true
118
118
  class_option :no_color, :type => :boolean, :default => false
119
119
 
120
+ #
121
+ # Sets the namespace of a new {Command} class.
122
+ #
123
+ # @param [Class] super_class
124
+ # The new {Command} class.
125
+ #
120
126
  def self.inherited(super_class)
121
127
  super_class.namespace(super_class.command_name)
122
128
  end
@@ -53,6 +53,9 @@ module Ronin
53
53
 
54
54
  argument :name, :type => :string, :required => false
55
55
 
56
+ #
57
+ # Executes the command.
58
+ #
56
59
  def execute
57
60
  Database.setup
58
61
 
@@ -71,6 +74,12 @@ module Ronin
71
74
 
72
75
  protected
73
76
 
77
+ #
78
+ # The selected SCM.
79
+ #
80
+ # @return [Symbol]
81
+ # The name of the selected SCM.
82
+ #
74
83
  def scm
75
84
  @scm ||= if options[:scm]
76
85
  options[:scm].to_sym
@@ -106,6 +115,9 @@ module Ronin
106
115
  end
107
116
  end
108
117
 
118
+ #
119
+ # Lists installed or added Repositories.
120
+ #
109
121
  def list
110
122
  unless name
111
123
  print_array Repository.all
@@ -177,6 +189,12 @@ module Ronin
177
189
  end
178
190
  end
179
191
 
192
+ #
193
+ # Adds a Repository.
194
+ #
195
+ # @param [String] path
196
+ # The path of the local repository.
197
+ #
180
198
  def add(path)
181
199
  repo = begin
182
200
  Repository.add!(:path => path, :scm => @scm)
@@ -188,6 +206,12 @@ module Ronin
188
206
  print_info "Repository #{repo} added."
189
207
  end
190
208
 
209
+ #
210
+ # Installs a Repository.
211
+ #
212
+ # @param [String, URI] uri
213
+ # The URI of the remote repository.
214
+ #
191
215
  def install(uri)
192
216
  repo = begin
193
217
  Repository.install!(:uri => uri, :scm => scm)
@@ -200,6 +224,9 @@ module Ronin
200
224
  print_info "Repository #{repo} has been installed."
201
225
  end
202
226
 
227
+ #
228
+ # Updates installed Repositories.
229
+ #
203
230
  def update
204
231
  repos = if name
205
232
  begin
@@ -222,6 +249,12 @@ module Ronin
222
249
  end
223
250
  end
224
251
 
252
+ #
253
+ # Uninstalls a Repository.
254
+ #
255
+ # @param [String] name
256
+ # The name of the repository.
257
+ #
225
258
  def uninstall(name)
226
259
  repo = Repository.uninstall!(name)
227
260
 
@@ -23,6 +23,9 @@ require 'ronin/engine'
23
23
  module Ronin
24
24
  module UI
25
25
  module CLI
26
+ #
27
+ # A base-command for querying and loading {Engine}s.
28
+ #
26
29
  class EngineCommand < ModelCommand
27
30
 
28
31
  class_option :file, :type => :string, :aliases => '-f'
@@ -25,6 +25,9 @@ require 'set'
25
25
  module Ronin
26
26
  module UI
27
27
  module CLI
28
+ #
29
+ # A base-command for querying and exporting {Model}s.
30
+ #
28
31
  class ModelCommand < Command
29
32
 
30
33
  class_option :csv, :type => :boolean
@@ -29,6 +29,10 @@ require 'ripl/auto_indent'
29
29
 
30
30
  module Ronin
31
31
  module UI
32
+ #
33
+ # An interactive Ruby {Console} using
34
+ # [Ripl](https://github.com/cldwalker/ripl).
35
+ #
32
36
  class Console
33
37
 
34
38
  # The history file for the Console session
@@ -67,7 +71,7 @@ module Ronin
67
71
  end
68
72
 
69
73
  #
70
- # Determines whenter one-line errors will be printed, instead of full
74
+ # Determines whether one-line errors will be printed, instead of full
71
75
  # backtraces.
72
76
  #
73
77
  # @return [Boolean]
@@ -19,6 +19,9 @@
19
19
 
20
20
  module Ronin
21
21
  module UI
22
+ #
23
+ # Methods for hexdumping data.
24
+ #
22
25
  module Hexdump
23
26
  #
24
27
  # Hexdumps an object.
@@ -22,6 +22,9 @@ require 'ronin/ui/output/output'
22
22
  module Ronin
23
23
  module UI
24
24
  module Output
25
+ #
26
+ # Helper methods for printing output.
27
+ #
25
28
  module Helpers
26
29
  #
27
30
  # Writes data unless output has been silenced.
@@ -30,7 +33,7 @@ module Ronin
30
33
  # The data to write.
31
34
  #
32
35
  # @return [Integer, nil]
33
- # The number of bytes writen.
36
+ # The number of bytes written.
34
37
  #
35
38
  # @since 1.0.0
36
39
  #
@@ -101,22 +104,25 @@ module Ronin
101
104
  end
102
105
 
103
106
  #
104
- # Prints one or more messages as `info` output.
107
+ # Prints an `info` message.
105
108
  #
106
- # @param [Array] messages
107
- # The messages to print.
109
+ # @param [Array] message
110
+ # The message to print.
108
111
  #
109
112
  # @return [Boolean]
110
113
  # Specifies whether the messages were successfully printed.
111
114
  #
112
115
  # @example
113
- # print_info 'Connecting ...'
116
+ # print_info "Connecting ..."
117
+ #
118
+ # @example Print a formatted message.
119
+ # print_info "Connected to %s", host
114
120
  #
115
121
  # @since 0.3.0
116
122
  #
117
- def print_info(*messages)
123
+ def print_info(*message)
118
124
  unless Output.silent?
119
- Output.handler.print_info(*messages)
125
+ Output.handler.print_info(format_message(message))
120
126
  return true
121
127
  end
122
128
 
@@ -124,22 +130,22 @@ module Ronin
124
130
  end
125
131
 
126
132
  #
127
- # Prints one or more messages as `debug` output.
133
+ # Prints a `debug` message.
128
134
  #
129
- # @param [Array] messages
130
- # The messages to print.
135
+ # @param [Array, String] message
136
+ # The message to print.
131
137
  #
132
138
  # @return [Boolean]
133
139
  # Specifies whether the messages were successfully printed.
134
140
  #
135
- # @example
136
- # print_debug "var1: #{var1.inspect}"
141
+ # @example Print a formatted message.
142
+ # print_debug "vars: %p %p", vars[0], vars[1]
137
143
  #
138
144
  # @since 0.3.0
139
145
  #
140
- def print_debug(*messages)
146
+ def print_debug(*message)
141
147
  if (Output.verbose? && !(Output.silent?))
142
- Output.handler.print_debug(*messages)
148
+ Output.handler.print_debug(format_message(message))
143
149
  return true
144
150
  end
145
151
 
@@ -147,22 +153,25 @@ module Ronin
147
153
  end
148
154
 
149
155
  #
150
- # Prints one or more messages as `warning` output.
156
+ # Prints a `warning` message.
151
157
  #
152
- # @param [Array] messages
153
- # The messages to print.
158
+ # @param [Array, String] message
159
+ # The message to print.
154
160
  #
155
161
  # @return [Boolean]
156
162
  # Specifies whether the messages were successfully printed.
157
163
  #
158
164
  # @example
159
- # print_warning 'Detecting a restricted character in the buffer'
165
+ # print_warning "Detecting a restricted character in the buffer"
166
+ #
167
+ # @example Print a formatted message.
168
+ # print_warning "Malformed input detected: %p", user_input
160
169
  #
161
170
  # @since 0.3.0
162
171
  #
163
- def print_warning(*messages)
172
+ def print_warning(*message)
164
173
  if (Output.verbose? && !(Output.silent?))
165
- Output.handler.print_warning(*messages)
174
+ Output.handler.print_warning(format_message(message))
166
175
  return true
167
176
  end
168
177
 
@@ -170,27 +179,51 @@ module Ronin
170
179
  end
171
180
 
172
181
  #
173
- # Prints one or more messages as `error` output.
182
+ # Prints an `error` message.
174
183
  #
175
- # @param [Array] messages
176
- # The messages to print.
184
+ # @param [Array, String] message
185
+ # The message to print.
177
186
  #
178
187
  # @return [Boolean]
179
188
  # Specifies whether the messages were successfully printed.
180
189
  #
181
190
  # @example
182
- # print_error 'Could not connect!'
191
+ # print_error "Could not connect!"
192
+ #
193
+ # @example Print a formatted message.
194
+ # print_error "%p: %s", error.class, error.message
183
195
  #
184
196
  # @since 0.3.0
185
197
  #
186
- def print_error(*messages)
198
+ def print_error(*message)
187
199
  unless Output.silent?
188
- Output.handler.print_error(*messages)
200
+ Output.handler.print_error(format_message(message))
189
201
  return true
190
202
  end
191
203
 
192
204
  return false
193
205
  end
206
+
207
+ protected
208
+
209
+ #
210
+ # Formats a message to be printed.
211
+ #
212
+ # @param [Array] message
213
+ # The message and additional Objects to format.
214
+ #
215
+ # @return [String]
216
+ # The formatted message.
217
+ #
218
+ # @since 1.0.0
219
+ #
220
+ def format_message(message)
221
+ if message.length == 1
222
+ message[0]
223
+ else
224
+ message[0] % message[1..-1]
225
+ end
226
+ end
194
227
  end
195
228
  end
196
229
  end