ronin 1.4.1 → 1.5.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/.document +1 -0
  2. data/.gitignore +1 -0
  3. data/ChangeLog.md +38 -1
  4. data/Gemfile +10 -10
  5. data/README.md +1 -1
  6. data/Rakefile +13 -2
  7. data/bin/ronin-net-proxy +25 -0
  8. data/gemspec.yml +21 -2
  9. data/lib/bond/completions/ronin.rb +16 -5
  10. data/lib/ronin/arch.rb +5 -5
  11. data/lib/ronin/auto_load.rb +22 -1
  12. data/lib/ronin/campaign.rb +1 -1
  13. data/lib/ronin/database/database.rb +36 -25
  14. data/lib/ronin/installation.rb +2 -2
  15. data/lib/ronin/model/model.rb +5 -6
  16. data/lib/ronin/model/types/description.rb +0 -3
  17. data/lib/ronin/os.rb +2 -2
  18. data/lib/ronin/password.rb +1 -1
  19. data/lib/ronin/repository.rb +6 -6
  20. data/lib/ronin/script/path.rb +1 -2
  21. data/lib/ronin/spec/database.rb +16 -4
  22. data/lib/ronin/ui/cli/cli.rb +1 -1
  23. data/lib/ronin/ui/cli/command.rb +50 -7
  24. data/lib/ronin/ui/cli/commands/console.rb +15 -6
  25. data/lib/ronin/ui/cli/commands/creds.rb +1 -1
  26. data/lib/ronin/ui/cli/commands/database.rb +41 -29
  27. data/lib/ronin/ui/cli/commands/emails.rb +20 -15
  28. data/lib/ronin/ui/cli/commands/help.rb +18 -5
  29. data/lib/ronin/ui/cli/commands/hosts.rb +34 -27
  30. data/lib/ronin/ui/cli/commands/install.rb +21 -4
  31. data/lib/ronin/ui/cli/commands/ips.rb +34 -23
  32. data/lib/ronin/ui/cli/commands/net/proxy.rb +403 -0
  33. data/lib/ronin/ui/cli/commands/repos.rb +4 -4
  34. data/lib/ronin/ui/cli/commands/uninstall.rb +10 -0
  35. data/lib/ronin/ui/cli/commands/update.rb +11 -1
  36. data/lib/ronin/ui/cli/commands/urls.rb +39 -30
  37. data/lib/ronin/ui/cli/commands/wordlist.rb +11 -1
  38. data/lib/ronin/ui/console.rb +1 -0
  39. data/lib/ronin/ui/console/commands.rb +16 -98
  40. data/lib/ronin/ui/console/shell.rb +184 -0
  41. data/lib/ronin/url.rb +3 -3
  42. data/lib/ronin/url_scheme.rb +3 -3
  43. data/lib/ronin/version.rb +1 -1
  44. data/man/ronin-campaigns.1.md +78 -0
  45. data/man/ronin-console.1.md +72 -0
  46. data/man/ronin-creds.1.md +66 -0
  47. data/man/ronin-database.1.md +82 -0
  48. data/man/ronin-emails.1.md +72 -0
  49. data/man/ronin-exec.1.md +49 -0
  50. data/man/ronin-help.1.md +34 -0
  51. data/man/ronin-hosts.1.md +78 -0
  52. data/man/ronin-install.1.md +79 -0
  53. data/man/ronin-ips.1.md +81 -0
  54. data/man/ronin-net-proxy.1.md +86 -0
  55. data/man/ronin-repos.1.md +77 -0
  56. data/man/ronin-uninstall.1.md +67 -0
  57. data/man/ronin-update.1.md +67 -0
  58. data/man/ronin-urls.1.md +84 -0
  59. data/man/ronin-wordlist.1.md +53 -0
  60. data/man/ronin.1.md +26 -0
  61. data/ronin.gemspec +38 -109
  62. data/spec/installation_spec.rb +2 -1
  63. data/spec/spec_helper.rb +2 -0
  64. data/spec/ui/cli/classes/test_command.rb +7 -0
  65. data/spec/ui/cli/command_spec.rb +235 -7
  66. metadata +217 -96
@@ -77,8 +77,8 @@ module Ronin
77
77
  # Enumerates over all files within a given directory found in any
78
78
  # of the installed Ronin libraries.
79
79
  #
80
- # @param [String] directory
81
- # The directory path to search within.
80
+ # @param [String] pattern
81
+ # The glob pattern to search for.
82
82
  #
83
83
  # @yield [file]
84
84
  # The given block will be passed each file found within the directory.
@@ -18,7 +18,6 @@
18
18
  #
19
19
 
20
20
  require 'ronin/model/types'
21
- require 'ronin/support/inflector'
22
21
 
23
22
  require 'dm-core'
24
23
  require 'dm-types'
@@ -75,9 +74,9 @@ module Ronin
75
74
  # @api semipublic
76
75
  #
77
76
  def relationship_name
78
- name = Support::Inflector.underscore(self.name.split('::').last)
79
-
80
- return Support::Inflector.pluralize(name).to_sym
77
+ DataMapper::Inflector.pluralize(
78
+ DataMapper::Inflector.underscore(self.name.split('::').last)
79
+ ).to_sym
81
80
  end
82
81
 
83
82
  #
@@ -133,7 +132,7 @@ module Ronin
133
132
  if value.kind_of?(Array)
134
133
  value.map(&formatter).join(', ')
135
134
  elsif value.kind_of?(Symbol)
136
- Support::Inflector.humanize(value)
135
+ DataMapper::Inflector.humanize(value)
137
136
  else
138
137
  value.to_s
139
138
  end
@@ -148,7 +147,7 @@ module Ronin
148
147
  name = name.to_s
149
148
 
150
149
  unless name[-3..-1] == '_id'
151
- name = Support::Inflector.humanize(name)
150
+ name = DataMapper::Inflector.humanize(name)
152
151
  value = formatter.call(value)
153
152
 
154
153
  if block_given?
@@ -35,9 +35,6 @@ module Ronin
35
35
  # @param [Object] value
36
36
  # The text of the description.
37
37
  #
38
- # @param [DataMapper::Property] property
39
- # The description property.
40
- #
41
38
  # @return [String, nil]
42
39
  # The type-casted description.
43
40
  #
@@ -96,8 +96,8 @@ module Ronin
96
96
  # @param [Symbol, String] name
97
97
  # The method name to define for the predefined OS.
98
98
  #
99
- # @param [String] os_name
100
- # The name of the OS.
99
+ # @param [Hash{Symbol => Object}] attributes
100
+ # Additional attributes for the OS.
101
101
  #
102
102
  # @return [nil]
103
103
  #
@@ -63,7 +63,7 @@ module Ronin
63
63
  #
64
64
  # Hashes the password.
65
65
  #
66
- # @param [Symbol, String] digest
66
+ # @param [Symbol, String] algorithm
67
67
  # The digest algorithm to use.
68
68
  #
69
69
  # @param [Hash] options
@@ -126,10 +126,10 @@ module Ronin
126
126
  # @param [Hash] attributes
127
127
  # The attributes of the repository.
128
128
  #
129
- # @param [String] path
129
+ # @option attributes [String] :path
130
130
  # The path to the repository.
131
131
  #
132
- # @param [Symbol] scm
132
+ # @option attributes [Symbol] :scm
133
133
  # The SCM used by the repository. Can be either:
134
134
  #
135
135
  # * `:git`
@@ -137,7 +137,7 @@ module Ronin
137
137
  # * `:sub_version` / `:svn`
138
138
  # * `:rsync`
139
139
  #
140
- # @param [String, URI::HTTP, URI::HTTPS] uri
140
+ # @option attributes [String, URI] :uri
141
141
  # The URI the repository resides at.
142
142
  #
143
143
  # @yield [repo]
@@ -393,10 +393,10 @@ module Ronin
393
393
  end
394
394
 
395
395
  #
396
- # De-activates all installed or added repositories.
396
+ # Deactivates all installed or added repositories.
397
397
  #
398
398
  # @return [Array<Repository>]
399
- # The de-activated repositories.
399
+ # The deactivated repositories.
400
400
  #
401
401
  # @see #deactivate!
402
402
  #
@@ -520,7 +520,7 @@ module Ronin
520
520
  end
521
521
 
522
522
  #
523
- # De-activates the repository by removing the {#lib_dir} from the
523
+ # Deactivates the repository by removing the {#lib_dir} from the
524
524
  # `$LOAD_PATH` global variable.
525
525
  #
526
526
  # @api private
@@ -19,7 +19,6 @@
19
19
 
20
20
  require 'ronin/model'
21
21
  require 'ronin/script/script'
22
- require 'ronin/support/inflector'
23
22
 
24
23
  require 'object_loader'
25
24
 
@@ -66,7 +65,7 @@ module Ronin
66
65
  #
67
66
  def class_path
68
67
  if self.class_name
69
- Support::Inflector.underscore(self.class_name)
68
+ DataMapper::Inflector.underscore(self.class_name)
70
69
  end
71
70
  end
72
71
 
@@ -24,13 +24,25 @@ require 'tempfile'
24
24
 
25
25
  RSpec.configure do |spec|
26
26
  spec.before(:suite) do
27
- database_file = Tempfile.new('ronin_database').path
28
- database_uri = {:adapter => 'sqlite3', :database => database_file}
27
+ defaults = {
28
+ :user => 'ronin_test',
29
+ :password => 'ronin_test',
30
+ :database => 'ronin_test'
31
+ }
32
+ adapter = ENV.fetch('ADAPTER','sqlite3')
29
33
 
30
- Ronin::Database.repositories[:default] = database_uri
34
+ uri = case adapter
35
+ when 'sqlite3', 'sqlite'
36
+ {
37
+ :adapter => 'sqlite3',
38
+ :database => Tempfile.new('ronin_database').path
39
+ }
40
+ else
41
+ defaults.merge(:adapter => adapter)
42
+ end
31
43
 
32
44
  # setup the database
33
- Ronin::Database.setup
45
+ Ronin::Database.setup(uri)
34
46
 
35
47
  # auto-migrate any models defined in the specs
36
48
  DataMapper.finalize.auto_migrate!
@@ -51,7 +51,7 @@ module Ronin
51
51
  if @commands.empty?
52
52
  commands_dir = File.join('lib',Commands.namespace_root)
53
53
 
54
- Installation.each_file_in(commands_dir,:rb) do |path|
54
+ Installation.each_file_in(commands_dir,'rb') do |path|
55
55
  # remove the .rb file extension
56
56
  name = path.chomp('.rb')
57
57
 
@@ -185,9 +185,7 @@ module Ronin
185
185
  # @api public
186
186
  #
187
187
  def self.run(options={})
188
- command = new()
189
-
190
- return command.run(options)
188
+ new().run(options)
191
189
  end
192
190
 
193
191
  #
@@ -263,7 +261,10 @@ module Ronin
263
261
 
264
262
  setup
265
263
  execute
264
+
266
265
  return true
266
+ ensure
267
+ cleanup
267
268
  end
268
269
 
269
270
  #
@@ -293,6 +294,16 @@ module Ronin
293
294
  def execute
294
295
  end
295
296
 
297
+ #
298
+ # Default method to call after the command has finished.
299
+ #
300
+ # @since 1.5.0
301
+ #
302
+ # @api semipublic
303
+ #
304
+ def cleanup
305
+ end
306
+
296
307
  protected
297
308
 
298
309
  #
@@ -343,6 +354,31 @@ module Ronin
343
354
  end
344
355
  end
345
356
 
357
+ #
358
+ # Example usages for the command.
359
+ #
360
+ # @param [Array<String>] new_examples
361
+ # The new examples for the command.
362
+ #
363
+ # @return [Array]
364
+ # Example commands.
365
+ #
366
+ # @since 1.5.0
367
+ #
368
+ # @api semipublic
369
+ #
370
+ def self.examples(new_examples=nil)
371
+ if new_examples
372
+ @examples = new_examples
373
+ else
374
+ @examples ||= if superclass < Command
375
+ superclass.examples.dup
376
+ else
377
+ []
378
+ end
379
+ end
380
+ end
381
+
346
382
  #
347
383
  # The options for the parameters.
348
384
  #
@@ -366,7 +402,7 @@ module Ronin
366
402
  # @param [Hash] options
367
403
  # Additional options for the option.
368
404
  #
369
- # @option options [Hash{Class => Class}, Set<Class>, Array<Class>, Class, true] :type (String)
405
+ # @option options [Hash{Class => Class}, Set<Class>, Array<Class>, Class, true] :type
370
406
  # The type of the options.
371
407
  #
372
408
  # @option options [Object, Proc] :default
@@ -395,8 +431,6 @@ module Ronin
395
431
  # @api semipublic
396
432
  #
397
433
  def self.option(name,options={})
398
- options = {:type => String}.merge(options)
399
-
400
434
  self.options[name] = {
401
435
  :flag => options[:flag],
402
436
  :usage => options[:usage],
@@ -417,7 +451,7 @@ module Ronin
417
451
  :description => 'Silence all output'
418
452
 
419
453
  option :color, :type => true,
420
- :default => proc { !$stdout.tty? },
454
+ :default => proc { $stdout.tty? },
421
455
  :description => 'Enables color output'
422
456
 
423
457
  #
@@ -598,6 +632,15 @@ module Ronin
598
632
  end
599
633
  end
600
634
 
635
+ unless self.class.examples.empty?
636
+ opts.separator ''
637
+ opts.separator 'Examples:'
638
+
639
+ self.class.examples.each do |example|
640
+ opts.separator " #{example}"
641
+ end
642
+ end
643
+
601
644
  if self.class.summary
602
645
  opts.separator ''
603
646
  opts.separator self.class.summary
@@ -68,13 +68,12 @@ module Ronin
68
68
  :description => 'Print the Ronin version'
69
69
 
70
70
  #
71
- # Starts the Ronin Console.
71
+ # Sets up the Ronin Console.
72
72
  #
73
- def execute
74
- if version?
75
- puts "ronin #{Ronin::VERSION}"
76
- return
77
- end
73
+ # @since 1.5.0
74
+ #
75
+ def setup
76
+ super
78
77
 
79
78
  UI::Console.color = color?
80
79
  UI::Console.short_errors = !backtrace?
@@ -86,6 +85,16 @@ module Ronin
86
85
  if database?
87
86
  Database.repositories[:default] = @database
88
87
  end
88
+ end
89
+
90
+ #
91
+ # Starts the Ronin Console.
92
+ #
93
+ def execute
94
+ if version?
95
+ puts "ronin #{Ronin::VERSION}"
96
+ return
97
+ end
89
98
 
90
99
  UI::Console.start
91
100
  end
@@ -69,7 +69,7 @@ module Ronin
69
69
  option :list, :type => true,
70
70
  :default => true,
71
71
  :flag => '-l',
72
- :description => 'List all Credentials'
72
+ :description => 'List the Credentials'
73
73
 
74
74
  #
75
75
  # Queries the {Credential} model.
@@ -56,44 +56,56 @@ module Ronin
56
56
 
57
57
  summary 'Manages the Ronin Database'
58
58
 
59
- option :add, :type => Symbol,
60
- :flag => '-a',
61
- :usage => 'NAME'
62
-
63
- option :set, :type => Symbol,
64
- :flag => '-s',
65
- :usage => 'NAME'
66
-
67
- option :remove, :type => Symbol,
68
- :flag => '-r',
69
- :usage => 'NAME'
70
-
71
- option :clear, :type => Symbol,
72
- :flag => '-C',
73
- :usage => 'NAME'
59
+ option :add, :type => Symbol,
60
+ :flag => '-a',
61
+ :usage => 'NAME',
62
+ :description => 'Adds a Database Repository'
63
+
64
+ option :set, :type => Symbol,
65
+ :flag => '-s',
66
+ :usage => 'NAME',
67
+ :description => 'Sets the information for a Database Repository'
68
+
69
+ option :remove, :type => Symbol,
70
+ :flag => '-r',
71
+ :usage => 'NAME',
72
+ :description => 'Removes a Database Repository'
73
+
74
+ option :clear, :type => Symbol,
75
+ :flag => '-C',
76
+ :usage => 'NAME',
77
+ :description => 'WARNING: Clears a Database Repository'
74
78
 
75
79
  # repository options
76
- option :uri, :type => String,
77
- :usage => 'sqlite3:///path'
80
+ option :uri, :type => String,
81
+ :usage => 'sqlite3:///path',
82
+ :description => 'The URI for the Database Repository'
78
83
 
79
- option :adapter, :type => String,
80
- :usage => 'DB'
84
+ option :adapter, :type => String,
85
+ :usage => 'sqlite3|mysql|postgres',
86
+ :description => 'The Database Adapter'
81
87
 
82
- option :host, :type => String,
83
- :usage => 'HOST'
88
+ option :host, :type => String,
89
+ :usage => 'HOST',
90
+ :description => 'The host running the Database'
84
91
 
85
- option :port, :type => Integer,
86
- :usage => 'PORT'
92
+ option :port, :type => Integer,
93
+ :usage => 'PORT',
94
+ :description => 'The port the Database is listening on'
87
95
 
88
- option :user, :type => String
96
+ option :user, :type => String,
97
+ :description => 'User to authenticate with'
89
98
 
90
- option :password, :type => String
99
+ option :password, :type => String,
100
+ :description => 'Password to authenticate with'
91
101
 
92
- option :database, :type => String,
93
- :usage => 'NAME'
102
+ option :database, :type => String,
103
+ :usage => 'NAME',
104
+ :description => 'Database name'
94
105
 
95
- option :path, :type => String,
96
- :usage => 'PATH'
106
+ option :path, :type => String,
107
+ :usage => 'PATH',
108
+ :description => 'Path to the Database file.'
97
109
 
98
110
  #
99
111
  # Displays or modifies the Ronin Database configuration.
@@ -54,25 +54,30 @@ module Ronin
54
54
 
55
55
  summary 'Manages EmailAddresses'
56
56
 
57
- query_option :with_hosts, :type => Array,
58
- :flag => '-H',
59
- :usage => 'HOST [...]'
57
+ query_option :with_hosts, :type => Array,
58
+ :flag => '-H',
59
+ :usage => 'HOST [...]',
60
+ :description => 'Searches for the associated HOST(s)'
60
61
 
61
- query_option :with_ips, :type => Array,
62
- :flag => '-I',
63
- :usage => 'IP [...]'
62
+ query_option :with_ips, :type => Array,
63
+ :flag => '-I',
64
+ :usage => 'IP [...]',
65
+ :description => 'Searches for the associated IP(s)'
64
66
 
65
- query_option :with_users, :type => Array,
66
- :flag => '-u',
67
- :usage => 'NAME [...]'
67
+ query_option :with_users, :type => Array,
68
+ :flag => '-u',
69
+ :usage => 'NAME [...]',
70
+ :description => 'Searches for the associated UserName(s)'
68
71
 
69
- option :list, :type => true,
70
- :default => true,
71
- :flag => '-l'
72
+ option :list, :type => true,
73
+ :default => true,
74
+ :flag => '-l',
75
+ :description => 'Lists the EmailAddresses'
72
76
 
73
- option :import, :type => String,
74
- :flag => '-i',
75
- :usage => 'FILE'
77
+ option :import, :type => String,
78
+ :flag => '-i',
79
+ :usage => 'FILE',
80
+ :description => 'Imports EmailAddresses from the FILE'
76
81
 
77
82
  end
78
83
  end