ronin 1.3.0 → 1.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/ChangeLog.md +51 -1
  2. data/Gemfile +1 -1
  3. data/README.md +36 -41
  4. data/bin/ronin-install +25 -0
  5. data/bin/ronin-uninstall +25 -0
  6. data/bin/ronin-update +25 -0
  7. data/gemspec.yml +4 -4
  8. data/lib/bond/completions/ronin.rb +6 -5
  9. data/lib/ronin/address.rb +0 -2
  10. data/lib/ronin/auto_load.rb +4 -5
  11. data/lib/ronin/campaign.rb +1 -0
  12. data/lib/ronin/credential.rb +6 -5
  13. data/lib/ronin/database/database.rb +1 -0
  14. data/lib/ronin/email_address.rb +28 -3
  15. data/lib/ronin/environment.rb +3 -6
  16. data/lib/ronin/host_name.rb +1 -3
  17. data/lib/ronin/host_name_ip_address.rb +0 -2
  18. data/lib/ronin/ip_address.rb +1 -4
  19. data/lib/ronin/ip_address_mac_address.rb +0 -2
  20. data/lib/ronin/mac_address.rb +0 -2
  21. data/lib/ronin/model/has_unique_name.rb +17 -0
  22. data/lib/ronin/open_port.rb +0 -4
  23. data/lib/ronin/organization.rb +0 -1
  24. data/lib/ronin/os.rb +0 -2
  25. data/lib/ronin/os_guess.rb +0 -2
  26. data/lib/ronin/password.rb +17 -1
  27. data/lib/ronin/port.rb +34 -1
  28. data/lib/ronin/repository.rb +31 -25
  29. data/lib/ronin/script/buildable.rb +19 -4
  30. data/lib/ronin/script/deployable.rb +7 -8
  31. data/lib/ronin/script/exceptions.rb +1 -0
  32. data/lib/ronin/script/exceptions/build_failed.rb +27 -0
  33. data/lib/ronin/script/path.rb +28 -11
  34. data/lib/ronin/script/script.rb +17 -14
  35. data/lib/ronin/script/testable.rb +3 -3
  36. data/lib/ronin/service.rb +0 -1
  37. data/lib/ronin/service_credential.rb +0 -1
  38. data/lib/ronin/software.rb +0 -1
  39. data/lib/ronin/target.rb +0 -2
  40. data/lib/ronin/tcp_port.rb +0 -1
  41. data/lib/ronin/ui/cli/class_command.rb +130 -0
  42. data/lib/ronin/ui/cli/command.rb +344 -159
  43. data/lib/ronin/ui/cli/commands/campaigns.rb +39 -29
  44. data/lib/ronin/ui/cli/commands/console.rb +24 -15
  45. data/lib/ronin/ui/cli/commands/creds.rb +14 -12
  46. data/lib/ronin/ui/cli/commands/database.rb +63 -46
  47. data/lib/ronin/ui/cli/commands/emails.rb +15 -15
  48. data/lib/ronin/ui/cli/commands/help.rb +6 -5
  49. data/lib/ronin/ui/cli/commands/hosts.rb +24 -24
  50. data/lib/ronin/ui/cli/commands/install.rb +104 -0
  51. data/lib/ronin/ui/cli/commands/ips.rb +23 -23
  52. data/lib/ronin/ui/cli/commands/repos.rb +69 -182
  53. data/lib/ronin/ui/cli/commands/uninstall.rb +65 -0
  54. data/lib/ronin/ui/cli/commands/update.rb +100 -0
  55. data/lib/ronin/ui/cli/commands/urls.rb +24 -24
  56. data/lib/ronin/ui/cli/model_command.rb +8 -6
  57. data/lib/ronin/ui/cli/printing.rb +167 -0
  58. data/lib/ronin/ui/cli/resources_command.rb +21 -13
  59. data/lib/ronin/ui/cli/script_command.rb +126 -24
  60. data/lib/ronin/ui/console/commands.rb +4 -1
  61. data/lib/ronin/ui/console/console.rb +1 -1
  62. data/lib/ronin/ui/console/context.rb +1 -1
  63. data/lib/ronin/url.rb +24 -5
  64. data/lib/ronin/url_query_param.rb +0 -1
  65. data/lib/ronin/version.rb +1 -1
  66. data/lib/ronin/web_credential.rb +0 -5
  67. data/spec/email_address_spec.rb +17 -0
  68. data/spec/installation_spec.rb +24 -34
  69. data/spec/model/has_authors_spec.rb +1 -1
  70. data/spec/model/has_description_spec.rb +1 -1
  71. data/spec/model/has_license_spec.rb +1 -1
  72. data/spec/model/has_name_spec.rb +1 -1
  73. data/spec/model/has_title_spec.rb +1 -1
  74. data/spec/model/has_version_spec.rb +1 -1
  75. data/spec/model/model_spec.rb +1 -1
  76. data/spec/repository_spec.rb +9 -9
  77. data/spec/script/script_spec.rb +2 -4
  78. data/spec/spec_helper.rb +16 -0
  79. data/spec/ui/cli/classes/test_command.rb +7 -3
  80. data/spec/ui/cli/command_spec.rb +37 -5
  81. metadata +82 -73
  82. data/spec/model/spec_helper.rb +0 -20
@@ -31,29 +31,37 @@ module Ronin
31
31
 
32
32
  model Campaign
33
33
 
34
- query_option :named, :type => :string,
35
- :aliases => '-n'
36
-
37
- query_option :describing, :type => :string, :aliases => '-d'
38
-
39
- query_option :targeting, :type => :array,
40
- :aliases => '-T',
41
- :banner => 'ADDR [...]'
42
-
43
- query_option :targeting_orgs, :type => :array,
44
- :aliases => '-O',
45
- :banner => 'NAME [...]'
46
-
47
- class_option :list, :type => :boolean,
48
- :default => true,
49
- :aliases => '-l'
50
-
51
- class_option :add, :type => :string,
52
- :aliases => '-a',
53
- :banner => 'NAME'
54
-
55
- class_option :targets, :type => :array,
56
- :banner => 'ADDR [...]'
34
+ query_option :named, :type => String,
35
+ :flag => '-n',
36
+ :description => 'Name to search for'
37
+
38
+ query_option :describing, :type => String,
39
+ :flag => '-d',
40
+ :description => 'Description to search for'
41
+
42
+ query_option :targeting, :type => Array,
43
+ :flag => '-T',
44
+ :usage => 'ADDR [...]',
45
+ :description => 'Addresses to search for'
46
+
47
+ query_option :targeting_orgs, :type => Array,
48
+ :flag => '-O',
49
+ :usage => 'NAME [...]',
50
+ :description => 'Orgs to search for'
51
+
52
+ option :list, :type => true,
53
+ :default => true,
54
+ :flag => '-l',
55
+ :description => 'List all Campaigns'
56
+
57
+ option :add, :type => String,
58
+ :flag => '-a',
59
+ :usage => 'NAME',
60
+ :description => 'Create a new Campaign'
61
+
62
+ option :targets, :type => Array,
63
+ :usage => 'ADDR [...]',
64
+ :description => 'Addresses to target'
57
65
 
58
66
  #
59
67
  # Queries the {Campaign} model.
@@ -61,9 +69,9 @@ module Ronin
61
69
  # @since 1.0.0
62
70
  #
63
71
  def execute
64
- if options[:add]
65
- add options[:add]
66
- elsif options.list?
72
+ if add?
73
+ add(@add)
74
+ elsif list?
67
75
  super
68
76
  end
69
77
  end
@@ -81,8 +89,10 @@ module Ronin
81
89
  def add(name)
82
90
  campaign = Campaign.new(:name => name)
83
91
 
84
- # add targets to the campaign
85
- options[:targets].each { |target| campaign.target!(target) }
92
+ if targets?
93
+ # add targets to the campaign
94
+ @targets.each { |target| campaign.target!(target) }
95
+ end
86
96
 
87
97
  if campaign.save
88
98
  print_info "Added campaign #{campaign}"
@@ -100,7 +110,7 @@ module Ronin
100
110
  # @since 1.0.0
101
111
  #
102
112
  def print_resource(campaign)
103
- return super(campaign) unless options.verbose?
113
+ return super(campaign) unless verbose?
104
114
 
105
115
  print_title campaign.name
106
116
 
@@ -32,34 +32,43 @@ module Ronin
32
32
  #
33
33
  class Console < Command
34
34
 
35
- desc 'start the Ronin Console'
36
- class_option :database, :type => :string, :aliases => '-D'
37
- class_option :require, :type => :array,
38
- :default => [],
39
- :aliases => '-r',
40
- :banner => 'PATH'
41
- class_option :backtrace, :type => :boolean
42
- class_option :verbose, :type => :boolean, :aliases => '-v'
43
- class_option :version, :type => :boolean, :aliases => '-V'
35
+ summary 'Start the Ronin Console'
36
+
37
+ option :database, :type => URI,
38
+ :flag => '-D',
39
+ :description => 'The database to URI'
40
+
41
+ option :require, :type => Array,
42
+ :default => [],
43
+ :flag => '-r',
44
+ :usage => 'PATH',
45
+ :description => 'Ruby files to require'
46
+
47
+ option :backtrace, :type => true,
48
+ :description => 'Enable long backtraces'
49
+
50
+ option :version, :type => true,
51
+ :flag => '-V',
52
+ :description => 'Print the Ronin version'
44
53
 
45
54
  #
46
55
  # Starts the Ronin Console.
47
56
  #
48
57
  def execute
49
- if options.version?
58
+ if version?
50
59
  puts "ronin #{Ronin::VERSION}"
51
60
  return
52
61
  end
53
62
 
54
- UI::Console.color = !(options.color?)
55
- UI::Console.short_errors = !(options.backtrace?)
63
+ UI::Console.color = color?
64
+ UI::Console.short_errors = !backtrace?
56
65
 
57
- options[:require].each do |path|
66
+ @require.each do |path|
58
67
  UI::Console.auto_load << path
59
68
  end
60
69
 
61
- if options[:database]
62
- Database.repositories[:default] = options[:database]
70
+ if database?
71
+ Database.repositories[:default] = @database
63
72
  end
64
73
 
65
74
  UI::Console.start
@@ -18,6 +18,7 @@
18
18
  #
19
19
 
20
20
  require 'ronin/ui/cli/resources_command'
21
+
21
22
  require 'ronin/credential'
22
23
  require 'ronin/service_credential'
23
24
  require 'ronin/web_credential'
@@ -33,17 +34,20 @@ module Ronin
33
34
 
34
35
  model Credential
35
36
 
36
- query_option :for_user, :type => :string,
37
- :aliases => '-u',
38
- :banner => 'USER'
37
+ query_option :for_user, :type => String,
38
+ :flag => '-u',
39
+ :usage => 'USER',
40
+ :description => 'Username to search for'
39
41
 
40
- query_option :with_password, :type => :string,
41
- :aliases => '-p',
42
- :banner => 'PASS'
42
+ query_option :with_password, :type => String,
43
+ :flag => '-p',
44
+ :usage => 'PASS',
45
+ :description => 'Password to search for'
43
46
 
44
- class_option :list, :type => :boolean,
45
- :default => true,
46
- :aliases => '-l'
47
+ option :list, :type => true,
48
+ :default => true,
49
+ :flag => '-l',
50
+ :description => 'List all Credentials'
47
51
 
48
52
  #
49
53
  # Queries the {Credential} model.
@@ -51,9 +55,7 @@ module Ronin
51
55
  # @since 1.0.0
52
56
  #
53
57
  def execute
54
- if options.list?
55
- super
56
- end
58
+ super if list?
57
59
  end
58
60
 
59
61
  protected
@@ -31,43 +31,66 @@ module Ronin
31
31
  #
32
32
  class Database < Command
33
33
 
34
- desc "Manages the Ronin Database"
35
- class_option :add, :type => :string, :banner => 'NAME', :aliases => '-a'
36
- class_option :set, :type => :string, :banner => 'NAME', :aliases => '-s'
37
- class_option :remove, :type => :string, :banner => 'NAME', :aliases => '-r'
38
- class_option :clear, :type => :string, :banner => 'NAME', :aliases => '-C'
34
+ summary "Manages the Ronin Database"
35
+
36
+ option :add, :type => Symbol,
37
+ :flag => '-a',
38
+ :usage => 'NAME'
39
+
40
+ option :set, :type => Symbol,
41
+ :flag => '-s',
42
+ :usage => 'NAME'
43
+
44
+ option :remove, :type => Symbol,
45
+ :flag => '-r',
46
+ :usage => 'NAME'
47
+
48
+ option :clear, :type => Symbol,
49
+ :flag => '-C',
50
+ :usage => 'NAME'
39
51
 
40
52
  # repository options
41
- class_option :uri, :type => :string, :banner => 'sqlite3:///path'
42
- class_option :adapter, :type => :string, :banner => 'sqlite3'
43
- class_option :host, :type => :string, :banner => 'www.example.com'
44
- class_option :port, :type => :numeric, :banner => '9999'
45
- class_option :user, :type => :string
46
- class_option :password, :type => :string
47
- class_option :database, :type => :string, :banner => 'NAME'
48
- class_option :path, :type => :string, :banner => '/path/file.db'
53
+ option :uri, :type => String,
54
+ :usage => 'sqlite3:///path'
55
+
56
+ option :adapter, :type => String,
57
+ :usage => 'DB'
58
+
59
+ option :host, :type => String,
60
+ :usage => 'HOST'
61
+
62
+ option :port, :type => Integer,
63
+ :usage => 'PORT'
64
+
65
+ option :user, :type => String
66
+
67
+ option :password, :type => String
68
+
69
+ option :database, :type => String,
70
+ :usage => 'NAME'
71
+
72
+ option :path, :type => String,
73
+ :usage => 'PATH'
49
74
 
50
75
  #
51
76
  # Displays or modifies the Ronin Database configuration.
52
77
  #
53
78
  def execute
54
- if options[:clear]
55
- name = options[:clear].to_sym
56
-
57
- print_info "Clearing the Database repository #{name} ..."
79
+ if clear?
80
+ print_info "Clearing the Database repository #{@clear} ..."
58
81
 
59
- Ronin::Database.clear(name) do
60
- print_info "Database repository #{name} cleared."
82
+ Ronin::Database.clear(@clear) do
83
+ print_info "Database repository #{@clear} cleared."
61
84
  end
62
85
 
63
86
  return
64
87
  end
65
88
 
66
- if options[:add]
89
+ if add?
67
90
  add_repository
68
- elsif options[:set]
91
+ elsif set?
69
92
  set_repository
70
- elsif options[:delete]
93
+ elsif delete?
71
94
  delete_repository
72
95
  else
73
96
  Ronin::Database.repositories.each do |name,uri|
@@ -85,16 +108,16 @@ module Ronin
85
108
  # The repository URI.
86
109
  #
87
110
  def repository_uri
88
- if options[:uri]
89
- Addressable::URI.parse(options[:uri]).to_hash
111
+ if uri?
112
+ Addressable::URI.parse(@uri).to_hash
90
113
  else
91
114
  {
92
- :adapter => options[:adapter],
93
- :host => options[:host],
94
- :port => options[:port],
95
- :user => options[:user],
96
- :password => options[:password],
97
- :database => (options[:database] || options[:path])
115
+ :adapter => @adapter,
116
+ :host => @host,
117
+ :port => @port,
118
+ :user => @user,
119
+ :password => @password,
120
+ :database => (@database || @path)
98
121
  }
99
122
  end
100
123
  end
@@ -103,49 +126,43 @@ module Ronin
103
126
  # Adds a new Database repository.
104
127
  #
105
128
  def add_repository
106
- name = options[:add].to_sym
107
-
108
129
  Ronin::Database.save do
109
- Ronin::Database.repositories[name] = repository_uri
130
+ Ronin::Database.repositories[@add] = repository_uri
110
131
  end
111
132
 
112
- print_info "Database repository #{name} added."
133
+ print_info "Database repository #{@add} added."
113
134
  end
114
135
 
115
136
  #
116
137
  # Sets the URI for an existing Database repository.
117
138
  #
118
139
  def set_repository
119
- name = options[:set].to_sym
120
-
121
- unless Ronin::Database.repository?(name)
122
- print_error "Unknown Database repository #{name}"
140
+ unless Ronin::Database.repository?(@set)
141
+ print_error "Unknown Database repository #{@set}"
123
142
  return
124
143
  end
125
144
 
126
145
  Ronin::Database.save do
127
- Ronin::Database.repositories[name] = repository_uri
146
+ Ronin::Database.repositories[@set] = repository_uri
128
147
  end
129
148
 
130
- print_info "Database repository #{name} updated."
149
+ print_info "Database repository #{@set} updated."
131
150
  end
132
151
 
133
152
  #
134
153
  # Removes an existing Database repository.
135
154
  #
136
155
  def remove_repository
137
- name = options[:remove].to_sym
138
-
139
- unless Ronin::Database.repository?(name)
140
- print_error "Unknown Database repository #{name}"
156
+ unless Ronin::Database.repository?(@remove)
157
+ print_error "Unknown Database repository #{@remove}"
141
158
  return
142
159
  end
143
160
 
144
161
  Ronin::Database.save do
145
- Ronin::Database.repositories.delete(name)
162
+ Ronin::Database.repositories.delete(@remove)
146
163
  end
147
164
 
148
- print_info "Database repository #{name} removed."
165
+ print_info "Database repository #{@remove} removed."
149
166
  end
150
167
 
151
168
  end
@@ -31,25 +31,25 @@ module Ronin
31
31
 
32
32
  model EmailAddress
33
33
 
34
- query_option :with_hosts, :type => :array,
35
- :aliases => '-H',
36
- :banner => 'HOST [...]'
34
+ query_option :with_hosts, :type => Array,
35
+ :flag => '-H',
36
+ :usage => 'HOST [...]'
37
37
 
38
- query_option :with_ips, :type => :array,
39
- :aliases => '-I',
40
- :banner => 'IP [...]'
38
+ query_option :with_ips, :type => Array,
39
+ :flag => '-I',
40
+ :usage => 'IP [...]'
41
41
 
42
- query_option :with_users, :type => :array,
43
- :aliases => '-u',
44
- :banner => 'NAME [...]'
42
+ query_option :with_users, :type => Array,
43
+ :flag => '-u',
44
+ :usage => 'NAME [...]'
45
45
 
46
- class_option :list, :type => :boolean,
47
- :default => true,
48
- :aliases => '-l'
46
+ option :list, :type => true,
47
+ :default => true,
48
+ :flag => '-l'
49
49
 
50
- class_option :import, :type => :string,
51
- :aliases => '-i',
52
- :banner => 'FILE'
50
+ option :import, :type => String,
51
+ :flag => '-i',
52
+ :usage => 'FILE'
53
53
 
54
54
  end
55
55
  end
@@ -29,18 +29,19 @@ module Ronin
29
29
  #
30
30
  class Help < Command
31
31
 
32
- desc 'Displays the list of available commands or prints information on a specific command'
33
- argument :command, :type => :string, :required => false
32
+ summary 'Displays the list of available commands or prints information on a specific command'
33
+
34
+ argument :command, :type => Symbol
34
35
 
35
36
  #
36
37
  # Lists the available commands.
37
38
  #
38
39
  def execute
39
- if self.command
40
+ if command?
40
41
  begin
41
- CLI.command(self.command).start(['--help'])
42
+ CLI.command(@command).start(['--help'])
42
43
  rescue UnknownCommand
43
- print_error "unknown command #{command.dump}"
44
+ print_error "unknown command: #{@command}"
44
45
  end
45
46
  else
46
47
  print_array CLI.commands, :title => 'Available commands'
@@ -31,33 +31,33 @@ module Ronin
31
31
 
32
32
  model HostName
33
33
 
34
- query_option :with_ips, :type => :array,
35
- :aliases => '-I',
36
- :banner => 'IP [...]'
34
+ query_option :with_ips, :type => Array,
35
+ :flag => '-I',
36
+ :usage => 'IP [...]'
37
37
 
38
- query_option :with_ports, :type => :array,
39
- :aliases => '-p',
40
- :banner => 'PORT [...]'
38
+ query_option :with_ports, :type => Array[Integer],
39
+ :flag => '-p',
40
+ :usage => 'PORT [...]'
41
41
 
42
- query_option :domain, :type => :string,
43
- :aliases => '-D',
44
- :banner => 'DOMAIN'
42
+ query_option :domain, :type => String,
43
+ :flag => '-D',
44
+ :usage => 'DOMAIN'
45
45
 
46
- query_option :tld, :type => :string,
47
- :aliases => '-T',
48
- :banner => 'TLD'
46
+ query_option :tld, :type => String,
47
+ :flag => '-T',
48
+ :usage => 'TLD'
49
49
 
50
- class_option :list, :type => :boolean,
51
- :default => true,
52
- :aliases => '-l'
50
+ option :list, :type => true,
51
+ :default => true,
52
+ :flag => '-l'
53
53
 
54
- class_option :lookup, :type => :string,
55
- :aliases => '-L',
56
- :banner => 'IP'
54
+ option :lookup, :type => String,
55
+ :flag => '-L',
56
+ :usage => 'IP'
57
57
 
58
- class_option :import, :type => :string,
59
- :aliases => '-i',
60
- :banner => 'FILE'
58
+ option :import, :type => String,
59
+ :flag => '-i',
60
+ :usage => 'FILE'
61
61
 
62
62
  #
63
63
  # Queries the {HostName} model.
@@ -65,8 +65,8 @@ module Ronin
65
65
  # @since 1.0.0
66
66
  #
67
67
  def execute
68
- if options[:lookup]
69
- lookup options[:lookup]
68
+ if lookup?
69
+ lookup(@lookup)
70
70
  else
71
71
  super
72
72
  end
@@ -101,7 +101,7 @@ module Ronin
101
101
  # @since 1.0.0
102
102
  #
103
103
  def print_resource(host)
104
- return super(host) unless options.verbose?
104
+ return super(host) unless verbose?
105
105
 
106
106
  print_title host.address
107
107