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
data/.document CHANGED
@@ -2,3 +2,4 @@ lib/**/*.rb
2
2
  -
3
3
  ChangeLog.md
4
4
  COPYING.txt
5
+ man/*.md
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  doc
2
2
  pkg
3
+ man/*.[1-9]
3
4
  vendor/cache
4
5
  Gemfile.lock
5
6
  .bundle
@@ -1,9 +1,46 @@
1
+ ### 1.5.0 / 2012-05-28
2
+
3
+ * Require ronin-support ~> 0.5.
4
+ * Added {Ronin::UI::CLI::Command#setup}.
5
+ * Added {Ronin::UI::CLI::Command#cleanup}.
6
+ * Added {Ronin::UI::CLI::Command.examples}.
7
+ * Added the {Ronin::UI::CLI::Commands::Net::Proxy net:proxy} ronin command.
8
+ * Added man-pages for each `ronin` command.
9
+ * Added more specs for the {Ronin::UI::CLI::Command} DSL methods.
10
+ * Added {Ronin::AutoLoad::ClassMethods#require_const}, to also
11
+ finalize auto-loaded DataMapper models.
12
+ * Renamed `Ronin::Database.setup_log` to {Ronin::Database.log}.
13
+ * Allow {Ronin::Database.setup} to accept a URI for the `default` repository.
14
+ * Allow `ronin/spec/database` to test against other Databases,
15
+ specified by the `ADAPTER` environment variable.
16
+ * If `ADAPTER` is set to `mysql` or `postgres`, then `ronin/spec/database`
17
+ will connect to the `ronin_test` database with username/password
18
+ `ronin_test`.
19
+ * By default `ronin/spec/database` will test against a temporary sqlite3
20
+ database.
21
+ * Allow console `!command`s to embed Ruby expressions:
22
+
23
+ >> !ncat #{ip} #{port}
24
+
25
+ * Moved console `!command` logic into {Ronin::UI::Console::Shell}.
26
+ * `!command`s now only execute shell commands.
27
+ * Moved console `.command` logic into {Ronin::UI::Console::Commands}.
28
+ * `.command`s are now reserved only for special console commands
29
+ (ex: `.edit`).
30
+ * Improved recognition of console `!command`s and `.command`s.
31
+ * Do not allow executing console commands while in multi-line mode!
32
+ * Fixed bug in {Ronin::UI::CLI::Command} that was disabling colour output.
33
+ * Improved `--help` output of `ronin` commands by adding `examples` and more
34
+ `:description`s to options.
35
+ * Changed `ronin help COMMAND` to display the man-page for the given command.
36
+ * No longer honor the `DEBUG` environment variable. Use `ruby -w` or `ruby -d`
37
+ instead.
38
+
1
39
  ### 1.4.1 / 2012-04-01
2
40
 
3
41
  * Removed dependencey on env.
4
42
  * Removed `#to_ary` methods from Ronin Models that were causing
5
43
  `SystemStackError: stack level too deep` exceptions. Fixes issue #4.
6
- * Ensure that {Ronin::AutoLoad} will finalize models loaded via `require_const`.
7
44
  * {Ronin::UI::CLI::Command#start} now rescues Interupts.
8
45
 
9
46
  ### 1.4.0 / 2012-02-12
data/Gemfile CHANGED
@@ -7,9 +7,7 @@ RONIN_URI = 'http://github.com/ronin-ruby'
7
7
 
8
8
  gemspec
9
9
 
10
- platforms :jruby do
11
- gem 'jruby-openssl', '~> 0.7'
12
- end
10
+ gem 'jruby-openssl', '~> 0.7', :platforms => :jruby
13
11
 
14
12
  # DataMapper dependencies
15
13
  # gem 'data_objects', DO_VERSION, :git => "#{DM_URI}/do.git"
@@ -26,17 +24,19 @@ end
26
24
  # gem 'dm-timestamps', DM_VERSION, :git => "#{DM_URI}/dm-timestamps.git"
27
25
 
28
26
  # Library dependencies
29
- # gem 'ronin-support', '~> 0.4.0.rc1', :git => "#{RONIN_URI}/ronin-support.git"
27
+ # gem 'ronin-support', '~> 0.5.0.rc1', :git => "#{RONIN_URI}/ronin-support.git",
28
+ # :branch => '0.5.0'
30
29
 
31
30
  group :development do
32
- gem 'rake', '~> 0.8'
31
+ gem 'rake', '~> 0.8'
32
+ gem 'rubygems-tasks', '~> 0.1'
33
+ gem 'rspec', '~> 2.4'
33
34
 
34
- gem 'ore-tasks', '~> 0.4'
35
- gem 'rspec', '~> 2.4'
35
+ gem 'redcarpet', '~> 2.1'
36
+ gem 'md2man', '~> 1.2', :git => 'http://github.com/postmodern/md2man.git', :branch => 'rake_task'
36
37
 
37
- gem 'kramdown', '~> 0.12'
38
- gem 'ruby-graphviz', '~> 0.9'
39
- gem 'dm-visualizer', '~> 0.2'
38
+ gem 'ruby-graphviz', '~> 0.9.10'
39
+ gem 'dm-visualizer', '~> 0.2.0'
40
40
  end
41
41
 
42
42
  #
data/README.md CHANGED
@@ -185,7 +185,7 @@ Remove a Database:
185
185
  * [ripl-color_result](https://github.com/janlelis/ripl-color_result#readme)
186
186
  ~> 0.3
187
187
  * [ronin-support](https://github.com/ronin-ruby/ronin-support#readme)
188
- ~> 0.4
188
+ ~> 0.5
189
189
 
190
190
  ## Install
191
191
 
data/Rakefile CHANGED
@@ -18,8 +18,16 @@ end
18
18
 
19
19
  require 'rake'
20
20
 
21
- require 'ore/tasks'
22
- Ore::Tasks.new
21
+ require 'rubygems/tasks'
22
+ Gem::Tasks.new(:sign => {:checksum => true, :pgp => true}) do |tasks|
23
+ tasks.scm.tag.format = 'v%s'
24
+ tasks.console.command = 'ripl'
25
+ tasks.console.options = %w[
26
+ -rripl/multi_line
27
+ -rripl/auto_indent
28
+ -rripl/color_result
29
+ ]
30
+ end
23
31
 
24
32
  require 'rspec/core/rake_task'
25
33
  RSpec::Core::RakeTask.new
@@ -71,3 +79,6 @@ YARD::Rake::YardocTask.new
71
79
 
72
80
  desc "Generates all documentation"
73
81
  task :docs => [:yard, 'dm:doc:graphviz']
82
+
83
+ require 'md2man/task'
84
+ Md2Man::Task.new
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ root_dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
6
+ if File.directory?(File.join(root_dir,'.git'))
7
+ Dir.chdir(root_dir) do |path|
8
+ require 'bundler'
9
+
10
+ begin
11
+ Bundler.setup(:default)
12
+ rescue Bundler::BundlerError => e
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
+ exit e.status_code
16
+ end
17
+ end
18
+ end
19
+
20
+ lib_dir = File.join(root_dir,'lib')
21
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
22
+
23
+ require 'ronin/ui/cli/commands/net/proxy'
24
+
25
+ Ronin::UI::CLI::Commands::Net::Proxy.start
@@ -33,6 +33,25 @@ post_install_message: |
33
33
 
34
34
  *************************************************************************
35
35
 
36
+ generated_files:
37
+ - man/ronin.1
38
+ - man/ronin-campaigns.1
39
+ - man/ronin-console.1
40
+ - man/ronin-creds.1
41
+ - man/ronin-database.1
42
+ - man/ronin-emails.1
43
+ - man/ronin-exec.1
44
+ - man/ronin-help.1
45
+ - man/ronin-hosts.1
46
+ - man/ronin-install.1
47
+ - man/ronin-ips.1
48
+ - man/ronin-net-proxy.1
49
+ - man/ronin-repos.1
50
+ - man/ronin-uninstall.1
51
+ - man/ronin-update.1
52
+ - man/ronin-urls.1
53
+ - man/ronin-wordlist.1
54
+
36
55
  required_ruby_version: ">= 1.8.7"
37
56
 
38
57
  dependencies:
@@ -62,10 +81,10 @@ dependencies:
62
81
  ripl-short_errors: ~> 0.1
63
82
  ripl-color_result: ~> 0.3
64
83
  # Ronin dependencies:
65
- ronin-support: ~> 0.4
84
+ ronin-support: ~> 0.5.0.rc1
66
85
 
67
86
  development_dependencies:
68
87
  bundler: ~> 1.0
69
- yard: ~> 0.7
88
+ yard: ~> 0.8
70
89
  yard-dm: ~> 0.1
71
90
  yard-dm-is-predefined: ~> 0.2
@@ -19,11 +19,22 @@
19
19
 
20
20
  require 'ronin/config'
21
21
  require 'ronin/ui/console/commands'
22
+ require 'ronin/ui/console/shell'
22
23
 
23
24
  require 'set'
24
25
 
25
- complete(:on => /^[\!\.][a-zA-Z]\w*/) do |cmd|
26
- prefix = cmd[0,1]
26
+ complete(:on => Ronin::UI::Console::Commands::PATTERN) do |cmd|
27
+ name = cmd[1..-1]
28
+ commands = Set[]
29
+
30
+ Ronin::UI::Console::Commands.singleton_methods.each do |method|
31
+ commands << ".#{method}" if method.start_with?(name)
32
+ end
33
+
34
+ commands
35
+ end
36
+
37
+ complete(:on => Ronin::UI::Console::Shell::PATTERN) do |cmd|
27
38
  name = cmd[1..-1]
28
39
  glob = "#{name}*"
29
40
  paths = Set[]
@@ -32,14 +43,14 @@ complete(:on => /^[\!\.][a-zA-Z]\w*/) do |cmd|
32
43
  Ronin::Config::BIN_DIRS.each do |dir|
33
44
  Dir.glob(File.join(dir,glob)) do |path|
34
45
  if (File.file?(path) && File.executable?(path))
35
- paths << "#{prefix}#{File.basename(path)}"
46
+ paths << "!#{File.basename(path)}"
36
47
  end
37
48
  end
38
49
  end
39
50
 
40
51
  # add the black-listed keywords last
41
- Ronin::UI::Console::Commands::BLACKLIST.each do |keyword|
42
- paths << "#{prefix}#{keyword}" if keyword.start_with?(name)
52
+ Ronin::UI::Console::Shell::BLACKLIST.each do |keyword|
53
+ paths << "!#{keyword}" if keyword.start_with?(name)
43
54
  end
44
55
 
45
56
  paths
@@ -24,7 +24,7 @@ require 'dm-is-predefined'
24
24
 
25
25
  module Ronin
26
26
  #
27
- # Represents a Computer Architecture and pre-defines many other common
27
+ # Represents a Computer Architecture and predefines many other common
28
28
  # architectures ({x86}, {x86_64}, {ia64}, {ppc}, {ppc64}, {sparc},
29
29
  # {sparc64}, {mips} and {arm}).
30
30
  #
@@ -114,19 +114,19 @@ module Ronin
114
114
  # The 64-bit SPARC Architecture
115
115
  predefine :sparc64, :endian => :big, :address_length => 8
116
116
 
117
- # The MIPS (little-endian) Architecture
117
+ # The MIPS (little endian) Architecture
118
118
  predefine :mips_le, :endian => :little, :address_length => 4
119
119
 
120
- # The MIPS (big-endian) Architecture
120
+ # The MIPS (big endian) Architecture
121
121
  predefine :mips_be, :endian => :big, :address_length => 4
122
122
 
123
123
  # Alias to {mips_be}.
124
124
  predefine :mips, :name => 'mips_be', :endian => :big, :address_length => 4
125
125
 
126
- # The ARM (little-endian) Architecture
126
+ # The ARM (little endian) Architecture
127
127
  predefine :arm_le, :endian => :little, :address_length => 4
128
128
 
129
- # The ARM (big-endian) Architecture
129
+ # The ARM (big endian) Architecture
130
130
  predefine :arm_be, :endian => :big, :address_length => 4
131
131
 
132
132
  # Alias to {arm_be}.
@@ -34,7 +34,28 @@ module Ronin
34
34
  end
35
35
 
36
36
  module ClassMethods
37
- protected
37
+ #
38
+ # Requires the file that should contain the constant.
39
+ #
40
+ # @param [String, Symbol] name
41
+ # The name of the constant.
42
+ #
43
+ # @return [Class, Module, nil]
44
+ # The loaded constant.
45
+ #
46
+ # @since 1.5.0
47
+ #
48
+ # @api public
49
+ #
50
+ def require_const(name)
51
+ const = super(name)
52
+
53
+ if (const && const < DataMapper::Resource)
54
+ const.finalize
55
+ end
56
+
57
+ return const
58
+ end
38
59
 
39
60
  #
40
61
  # Transparently auto-loads Classes and Modules from their respective
@@ -97,7 +97,7 @@ module Ronin
97
97
  #
98
98
  # @api public
99
99
  #
100
- def targets?(addr)
100
+ def targets?(address)
101
101
  self.addresses.include?(address)
102
102
  end
103
103
 
@@ -64,7 +64,7 @@ module Ronin
64
64
  #
65
65
  # @api private
66
66
  #
67
- def Database.repositories
67
+ def self.repositories
68
68
  if @repositories.empty?
69
69
  @repositories[:default] = DEFAULT_REPOSITORY
70
70
 
@@ -97,7 +97,7 @@ module Ronin
97
97
  #
98
98
  # @api semipublic
99
99
  #
100
- def Database.repository?(name)
100
+ def self.repository?(name)
101
101
  repositories.has_key?(name.to_sym)
102
102
  end
103
103
 
@@ -114,7 +114,7 @@ module Ronin
114
114
  #
115
115
  # @api private
116
116
  #
117
- def Database.save
117
+ def self.save
118
118
  yield if block_given?
119
119
 
120
120
  File.open(CONFIG_FILE,'w') do |file|
@@ -131,7 +131,7 @@ module Ronin
131
131
  end
132
132
 
133
133
  #
134
- # Setup the Database log.
134
+ # Returns or sets up the Database log.
135
135
  #
136
136
  # @param [Hash] options
137
137
  # Additional options.
@@ -151,18 +151,21 @@ module Ronin
151
151
  # * `:info`
152
152
  # * `:debug`
153
153
  #
154
- # @return [true]
155
- # Specifies that the log has been setup.
154
+ # @return [DataMapper::Logger]
155
+ # The Database Logger.
156
156
  #
157
- # @api private
157
+ # @api semipublic
158
158
  #
159
- def Database.setup_log(options={})
160
- path = options.fetch(:path,DEFAULT_LOG_PATH)
161
- stream = options.fetch(:stream,File.new(path,'w+'))
162
- level = options.fetch(:level,DEFAULT_LOG_LEVEL)
159
+ def self.log(options={})
160
+ unless (@log && options.empty?)
161
+ path = options.fetch(:path,DEFAULT_LOG_PATH)
162
+ stream = options.fetch(:stream,File.new(path,'w+'))
163
+ level = options.fetch(:level,DEFAULT_LOG_LEVEL)
163
164
 
164
- @log = DataMapper::Logger.new(stream,level)
165
- return true
165
+ @log = DataMapper::Logger.new(stream,level)
166
+ end
167
+
168
+ return @log
166
169
  end
167
170
 
168
171
  #
@@ -176,7 +179,7 @@ module Ronin
176
179
  #
177
180
  # @api semipublic
178
181
  #
179
- def Database.setup?(name=:default)
182
+ def self.setup?(name=:default)
180
183
  repository = DataMapper.repository(name)
181
184
 
182
185
  return repository.class.adapters.has_key?(repository.name)
@@ -192,7 +195,7 @@ module Ronin
192
195
  #
193
196
  # @api semipublic
194
197
  #
195
- def Database.upgrade!
198
+ def self.upgrade!
196
199
  if setup?
197
200
  Migrations.migrate_up!
198
201
  else
@@ -203,23 +206,31 @@ module Ronin
203
206
  #
204
207
  # Sets up the Database.
205
208
  #
209
+ # @param [String, Hash] uri
210
+ # The optional default repository to setup instead of {repositories}.
211
+ #
206
212
  # @see Database.upgrade!
207
213
  #
208
214
  # @api semipublic
209
215
  #
210
- def Database.setup
216
+ def self.setup(uri=nil)
211
217
  # setup the database log
212
218
  unless @log
213
- if ($DEBUG || ENV['DEBUG'])
214
- setup_log(:stream => $stderr, :level => :debug)
219
+ if $DEBUG
220
+ log(:stream => $stderr, :level => :debug)
215
221
  else
216
- setup_log
222
+ log
217
223
  end
218
224
  end
219
225
 
220
- # setup the database repositories
221
- repositories.each do |name,uri|
222
- DataMapper.setup(name,uri)
226
+ if uri
227
+ # only setup the default database repositories
228
+ DataMapper.setup(:default,uri)
229
+ else
230
+ # setup the database repositories
231
+ repositories.each do |name,uri|
232
+ DataMapper.setup(name,uri)
233
+ end
223
234
  end
224
235
 
225
236
  # finalize the Models
@@ -245,7 +256,7 @@ module Ronin
245
256
  #
246
257
  # @api public
247
258
  #
248
- def Database.repository(name,&block)
259
+ def self.repository(name,&block)
249
260
  name = name.to_sym
250
261
 
251
262
  unless repository?(name)
@@ -274,7 +285,7 @@ module Ronin
274
285
  #
275
286
  # @api private
276
287
  #
277
- def Database.clear(name)
288
+ def self.clear(name)
278
289
  name = name.to_sym
279
290
 
280
291
  unless repository?(name)
@@ -302,7 +313,7 @@ module Ronin
302
313
  #
303
314
  # @api public
304
315
  #
305
- def Database.map
316
+ def self.map
306
317
  results = []
307
318
 
308
319
  repositories.each_key do |name|