ronin 1.1.0.rc3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/ChangeLog.md +10 -5
  2. data/Gemfile +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +4 -4
  5. data/bin/ronin +2 -2
  6. data/bin/ronin-campaigns +2 -2
  7. data/bin/ronin-console +2 -2
  8. data/bin/ronin-creds +2 -2
  9. data/bin/ronin-database +2 -2
  10. data/bin/ronin-emails +2 -2
  11. data/bin/ronin-exec +2 -2
  12. data/bin/ronin-help +2 -2
  13. data/bin/ronin-hosts +2 -2
  14. data/bin/ronin-ips +2 -2
  15. data/bin/ronin-repos +2 -2
  16. data/bin/ronin-urls +2 -2
  17. data/gemspec.yml +2 -4
  18. data/lib/ronin/database/database.rb +12 -13
  19. data/lib/ronin/database/migrations.rb +2 -29
  20. data/lib/ronin/database/migrations/1.0.0.rb +568 -0
  21. data/lib/ronin/database/migrations/1.1.0.rb +125 -0
  22. data/lib/ronin/spec/database.rb +1 -4
  23. data/lib/ronin/target.rb +0 -19
  24. data/lib/ronin/ui/cli/cli.rb +1 -1
  25. data/lib/ronin/ui/cli/commands/database.rb +15 -22
  26. data/lib/ronin/ui/output/output.rb +1 -1
  27. data/lib/ronin/url.rb +23 -24
  28. data/lib/ronin/url_query_param.rb +4 -6
  29. data/lib/ronin/url_query_param_name.rb +89 -0
  30. data/lib/ronin/user_name.rb +0 -2
  31. data/lib/ronin/version.rb +1 -1
  32. data/ronin.gemspec +129 -13
  33. data/spec/host_name_spec.rb +9 -10
  34. data/spec/ip_address.rb +3 -3
  35. data/spec/url_query_param_spec.rb +5 -3
  36. data/spec/url_spec.rb +14 -9
  37. metadata +9 -35
  38. data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +0 -48
  39. data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +0 -47
  40. data/lib/ronin/database/migrations/create_addresses_table.rb +0 -49
  41. data/lib/ronin/database/migrations/create_arches_table.rb +0 -43
  42. data/lib/ronin/database/migrations/create_authors_table.rb +0 -46
  43. data/lib/ronin/database/migrations/create_campaigns_table.rb +0 -43
  44. data/lib/ronin/database/migrations/create_countries_table.rb +0 -43
  45. data/lib/ronin/database/migrations/create_credentials_table.rb +0 -64
  46. data/lib/ronin/database/migrations/create_email_addresses_table.rb +0 -50
  47. data/lib/ronin/database/migrations/create_host_name_ip_addresses_table.rb +0 -50
  48. data/lib/ronin/database/migrations/create_ip_address_mac_addresses_table.rb +0 -50
  49. data/lib/ronin/database/migrations/create_licenses_table.rb +0 -43
  50. data/lib/ronin/database/migrations/create_open_ports_table.rb +0 -56
  51. data/lib/ronin/database/migrations/create_organizations_table.rb +0 -43
  52. data/lib/ronin/database/migrations/create_os_guesses_table.rb +0 -49
  53. data/lib/ronin/database/migrations/create_os_table.rb +0 -42
  54. data/lib/ronin/database/migrations/create_passwords_table.rb +0 -41
  55. data/lib/ronin/database/migrations/create_ports_table.rb +0 -47
  56. data/lib/ronin/database/migrations/create_proxies_table.rb +0 -54
  57. data/lib/ronin/database/migrations/create_repositories_table.rb +0 -60
  58. data/lib/ronin/database/migrations/create_script_paths_table.rb +0 -46
  59. data/lib/ronin/database/migrations/create_services_table.rb +0 -46
  60. data/lib/ronin/database/migrations/create_softwares_table.rb +0 -45
  61. data/lib/ronin/database/migrations/create_targets_table.rb +0 -49
  62. data/lib/ronin/database/migrations/create_url_query_params_table.rb +0 -41
  63. data/lib/ronin/database/migrations/create_url_schemes_table.rb +0 -39
  64. data/lib/ronin/database/migrations/create_urls_table.rb +0 -65
  65. data/lib/ronin/database/migrations/create_user_names_table.rb +0 -42
  66. data/lib/ronin/database/migrations/create_vendors_table.rb +0 -41
data/ChangeLog.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 1.1.0 / 2011-05-17
1
+ ### 1.1.0 / 2011-07-04
2
2
 
3
3
  * Require env ~> 0.2.
4
4
  * Require data_paths ~> 0.3.
@@ -9,6 +9,7 @@
9
9
  * Added {Ronin::Arch.arm}.
10
10
  * Added {Ronin::Arch.mips}.
11
11
  * Added {Ronin::Arch.x86}.
12
+ * Added {Ronin::URLQueryParamName}.
12
13
  * Added timestamps to {Ronin::Campaign}.
13
14
  * Added the `created_at` timestamp to {Ronin::Target}.
14
15
  * Added {Ronin::Network::Mixins::HTTP#http_status}.
@@ -45,27 +46,31 @@
45
46
  * Removed `Ronin::Engine#method_missing`.
46
47
  * Extend `DataPaths::Finders` into {Ronin::Config}.
47
48
  * Fixed a RubyGems deprecation in {Ronin::Installation}.
48
- * Enabled verbose DataMapper logging if the `DEBUG` environment variable is
49
- set.
49
+ * Enabled verbose DataMapper logging if `$DEBUG` or the `DEBUG`
50
+ environment variable are set.
51
+ * Switched from DataMapper URIs to Hashes.
50
52
  * Fixed a bug in {Ronin::Database::Migrations::Migration#initialize}, where
51
53
  `:needs` was being overridden.
54
+ * Group Database migration files by {Ronin::VERSION}.
52
55
  * Ensure that {Ronin::Database::Migrations} preserves the order of loaded
53
56
  migrations.
54
57
  * Set the length of {Ronin::Password.clear_text} to 256.
55
58
  * Set the length of {Ronin::License.url} to 256.
56
59
  * Merged `Ronin::Model::Cacheable` into {Ronin::Script}.
57
60
  * Repositories can now cache/load scripts from the `scripts/` directory.
58
- * Disable {Ronin::UI::Console.short_errors} if the `VERBOSE` environment
61
+ * Disable {Ronin::UI::Console.short_errors?} if the `VERBOSE` environment
59
62
  variable is set.
60
- * Disable {Ronin::UI::Console.color} if the `STDOUT` is a tty.
63
+ * Disable {Ronin::UI::Console.color?} if the `STDOUT` is a tty.
61
64
  * Set {Ronin::UI::Output.handler} to {Ronin::UI::Output::Terminal::Raw},
62
65
  when `STDOUT` is not a tty.
66
+ * Enable {Ronin::UI::Output.verbose?} if `$VERBOSE` or `$DEBUG` are set.
63
67
  * {Ronin::UI::CLI::ModelCommand#setup} now automatically calls
64
68
  {Ronin::Database.setup}, before executing the command.
65
69
  * Merged `query_method` into {Ronin::UI::CLI::ModelCommand#query}.
66
70
  * Allow {Ronin::UI::CLI::ModelCommand.query_option} to map to Model
67
71
  properties.
68
72
  * Use DataMapper query-paths to improve performance of query-helper methods.
73
+ * Removed `Ronin::Target#directory`.
69
74
 
70
75
  ### 1.0.0 / 2011-03-25
71
76
 
data/Gemfile CHANGED
@@ -25,7 +25,7 @@ gemspec
25
25
  # gem 'ronin-support', '~> 0.2', :git => "#{RONIN_URI}/ronin-support.git"
26
26
 
27
27
  group :development do
28
- gem 'rake', '~> 0.8.7'
28
+ gem 'rake', '~> 0.8'
29
29
 
30
30
  gem 'ore-tasks', '~> 0.4'
31
31
  gem 'rspec', '~> 2.4'
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  * [Issues](http://github.com/ronin-ruby/ronin/issues)
6
6
  * [Documentation](http://rubydoc.info/gems/ronin/frames)
7
7
  * [Mailing List](http://groups.google.com/group/ronin-ruby)
8
- * irc.freenode.net #ronin
8
+ * [irc.freenode.net #ronin](http://webchat.freenode.net/?channels=ronin&uio=Mj10cnVldd)
9
9
 
10
10
  ## Description
11
11
 
data/Rakefile CHANGED
@@ -3,16 +3,16 @@ require 'rubygems'
3
3
  begin
4
4
  require 'bundler'
5
5
  rescue LoadError => e
6
- STDERR.puts e.message
7
- STDERR.puts "Run `gem install bundler` to install Bundler."
6
+ warn e.message
7
+ warn "Run `gem install bundler` to install Bundler."
8
8
  exit e.status_code
9
9
  end
10
10
 
11
11
  begin
12
12
  Bundler.setup(:development)
13
13
  rescue Bundler::BundlerError => e
14
- STDERR.puts e.message
15
- STDERR.puts "Run `bundle install` to install missing gems"
14
+ warn e.message
15
+ warn "Run `bundle install` to install missing gems"
16
16
  exit e.status_code
17
17
  end
18
18
 
data/bin/ronin CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-campaigns CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-console CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-creds CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-database CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-emails CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-exec CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-help CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-hosts CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-ips CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-repos CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/bin/ronin-urls CHANGED
@@ -10,8 +10,8 @@ if File.directory?(File.join(root_dir,'.git'))
10
10
  begin
11
11
  Bundler.setup(:default)
12
12
  rescue Bundler::BundlerError => e
13
- STDERR.puts e.message
14
- STDERR.puts "Run `bundle install` to install missing gems"
13
+ warn e.message
14
+ warn "Run `bundle install` to install missing gems"
15
15
  exit e.status_code
16
16
  end
17
17
  end
data/gemspec.yml CHANGED
@@ -52,8 +52,7 @@ dependencies:
52
52
  uri-query_params: ~> 0.5, >= 0.5.2
53
53
  open_namespace: ~> 0.3
54
54
  parameters: ~> 0.2, >= 0.2.3
55
- # data_paths: ~> 0.3
56
- data_paths: ~> 0.3.0.rc1
55
+ data_paths: ~> 0.3
57
56
  object_loader: ~> 1.0
58
57
  env: ~> 0.2
59
58
  pullr: ~> 0.1, >= 0.1.2
@@ -64,8 +63,7 @@ dependencies:
64
63
  ripl-color_result: ~> 0.3
65
64
  thor: ~> 0.14.3
66
65
  # Ronin dependencies:
67
- # ronin-support: ~> 0.2
68
- ronin-support: ~> 0.2.0.rc2
66
+ ronin-support: ~> 0.2
69
67
 
70
68
  development_dependencies:
71
69
  bundler: ~> 1.0.10
@@ -22,7 +22,6 @@ require 'ronin/database/exceptions/unknown_repository'
22
22
  require 'ronin/database/migrations'
23
23
  require 'ronin/config'
24
24
 
25
- require 'addressable/uri'
26
25
  require 'yaml'
27
26
  require 'dm-core'
28
27
 
@@ -43,10 +42,10 @@ module Ronin
43
42
  DEFAULT_LOG_LEVEL = :info
44
43
 
45
44
  # Default database repository
46
- DEFAULT_REPOSITORY = Addressable::URI.new(
47
- :scheme => 'sqlite3',
48
- :path => File.join(Config::PATH,'database.sqlite3')
49
- )
45
+ DEFAULT_REPOSITORY = {
46
+ :adapter => 'sqlite3',
47
+ :database => File.join(Config::PATH,'database.sqlite3')
48
+ }
50
49
 
51
50
  @repositories = {}
52
51
  @log = nil
@@ -54,7 +53,7 @@ module Ronin
54
53
  #
55
54
  # Returns the Database repositories to use.
56
55
  #
57
- # @return [Hash{Symbol => Addressable::URI}]
56
+ # @return [Hash{Symbol => Hash}]
58
57
  # The database repository names and URIs.
59
58
  #
60
59
  # @raise [InvalidConfig]
@@ -69,14 +68,14 @@ module Ronin
69
68
  @repositories[:default] = DEFAULT_REPOSITORY
70
69
 
71
70
  if File.file?(CONFIG_FILE)
72
- conf = YAML.load_file(CONFIG_FILE)
71
+ config = YAML.load_file(CONFIG_FILE)
73
72
 
74
- unless conf.kind_of?(Hash)
73
+ unless config.kind_of?(Hash)
75
74
  raise(InvalidConfig,"#{CONFIG_FILE} must contain a YAML Hash of repositories")
76
75
  end
77
76
 
78
- conf.each do |name,uri|
79
- @repositories[name.to_sym] = Addressable::URI.parse(uri)
77
+ config.each do |name,uri|
78
+ @repositories[name.to_sym] = uri
80
79
  end
81
80
  end
82
81
  end
@@ -121,7 +120,7 @@ module Ronin
121
120
  hash = {}
122
121
 
123
122
  repositories.each do |name,value|
124
- hash[name.to_s] = value.to_s
123
+ hash[name.to_sym] = value
125
124
  end
126
125
 
127
126
  YAML.dump(hash,file)
@@ -205,8 +204,8 @@ module Ronin
205
204
  def Database.setup
206
205
  # setup the database log
207
206
  unless @log
208
- if ENV['DEBUG']
209
- setup_log(:stream => STDERR, :level => :debug)
207
+ if ($DEBUG || ENV['DEBUG'])
208
+ setup_log(:stream => $stderr, :level => :debug)
210
209
  else
211
210
  setup_log
212
211
  end
@@ -18,32 +18,5 @@
18
18
  #
19
19
 
20
20
  require 'ronin/database/migrations/migrations'
21
- require 'ronin/database/migrations/create_arches_table'
22
- require 'ronin/database/migrations/create_os_table'
23
- require 'ronin/database/migrations/create_vendors_table'
24
- require 'ronin/database/migrations/create_softwares_table'
25
- require 'ronin/database/migrations/create_licenses_table'
26
- require 'ronin/database/migrations/create_authors_table'
27
- require 'ronin/database/migrations/create_addresses_table'
28
- require 'ronin/database/migrations/create_ports_table'
29
- require 'ronin/database/migrations/create_ip_address_mac_addresses_table'
30
- require 'ronin/database/migrations/create_host_name_ip_addresses_table'
31
- require 'ronin/database/migrations/create_proxies_table'
32
- require 'ronin/database/migrations/create_services_table'
33
- require 'ronin/database/migrations/create_open_ports_table'
34
- require 'ronin/database/migrations/create_os_guesses_table'
35
- require 'ronin/database/migrations/create_url_schemes_table'
36
- require 'ronin/database/migrations/create_url_query_params_table'
37
- require 'ronin/database/migrations/create_urls_table'
38
- require 'ronin/database/migrations/create_user_names_table'
39
- require 'ronin/database/migrations/create_email_addresses_table'
40
- require 'ronin/database/migrations/create_passwords_table'
41
- require 'ronin/database/migrations/create_credentials_table'
42
- require 'ronin/database/migrations/create_countries_table'
43
- require 'ronin/database/migrations/create_organizations_table'
44
- require 'ronin/database/migrations/create_campaigns_table'
45
- require 'ronin/database/migrations/create_targets_table'
46
- require 'ronin/database/migrations/create_script_paths_table'
47
- require 'ronin/database/migrations/create_repositories_table'
48
- require 'ronin/database/migrations/add_updated_at_column_to_campaigns_table'
49
- require 'ronin/database/migrations/add_created_at_column_to_targets_table'
21
+ require 'ronin/database/migrations/1.0.0'
22
+ require 'ronin/database/migrations/1.1.0'
@@ -0,0 +1,568 @@
1
+ #
2
+ # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ #
4
+ # This file is part of Ronin.
5
+ #
6
+ # Ronin is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Ronin is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'ronin/database/migrations/migrations'
21
+
22
+ module Ronin
23
+ module Database
24
+ module Migrations
25
+ migration :create_addresses_table,
26
+ :needs => :create_organizations_table do
27
+ up do
28
+ create_table :ronin_addresses do
29
+ column :id, Integer, :serial => true
30
+ column :type, String, :not_null => true
31
+ column :version, Integer
32
+ column :address, String, :length => 256, :not_null => true
33
+ column :organization_id, Integer
34
+ column :created_at, Time, :not_null => true
35
+ end
36
+
37
+ create_index :ronin_addresses, :address, :unique => true
38
+ end
39
+
40
+ down do
41
+ drop_table :ronin_addresses
42
+ end
43
+ end
44
+
45
+ migration :create_arches_table do
46
+ up do
47
+ create_table :ronin_arches do
48
+ column :id, Integer, :serial => true
49
+ column :name, String, :not_null => true
50
+ column :endian, String, :not_null => true
51
+ column :address_length, Integer, :not_null => true
52
+ end
53
+
54
+ create_index :ronin_arches, :name, :unique => true
55
+ end
56
+
57
+ down do
58
+ drop_table :ronin_arches
59
+ end
60
+ end
61
+
62
+ migration :create_authors_table do
63
+ up do
64
+ create_table :ronin_authors do
65
+ column :id, Integer, :serial => true
66
+ column :name, String
67
+ column :organization, String
68
+ column :pgp_signature, String
69
+ column :email, String
70
+ column :site, String
71
+ column :biography, Text
72
+ end
73
+
74
+ create_index :ronin_authors, :name
75
+ end
76
+
77
+ down do
78
+ drop_table :ronin_authors
79
+ end
80
+ end
81
+
82
+ migration :create_campaigns_table do
83
+ up do
84
+ create_table :ronin_campaigns do
85
+ column :id, Integer, :serial => true
86
+ column :name, String, :not_null => true
87
+ column :description, Text, :not_null => true
88
+ column :created_at, Time
89
+ end
90
+
91
+ create_index :ronin_campaigns, :name, :unique => true
92
+ end
93
+
94
+ down do
95
+ drop_table :ronin_campaigns
96
+ end
97
+ end
98
+
99
+ migration :create_countries_table do
100
+ up do
101
+ create_table :ronin_countries do
102
+ column :id, Integer, :serial => true
103
+ column :name, String, :not_null => true
104
+ column :code, String, :length => 2, :not_null => true
105
+ end
106
+
107
+ create_index :ronin_countries, :name, :unique => true
108
+ create_index :ronin_countries, :code, :unique => true
109
+ end
110
+
111
+ down do
112
+ drop_table :ronin_countries
113
+ end
114
+ end
115
+
116
+ migration :create_credentials_table,
117
+ :needs => [
118
+ :create_user_names_table,
119
+ :create_passwords_table,
120
+ :create_open_ports_table,
121
+ :create_urls_table,
122
+ :create_proxies_table
123
+ ] do
124
+ up do
125
+ create_table :ronin_credentials do
126
+ column :id, Serial
127
+ column :user_name_id, Integer, :not_null => true
128
+ column :password_id, Integer, :not_null => true
129
+
130
+ column :open_port_id, Integer
131
+ column :email_address_id, Integer
132
+ column :url_id, Integer
133
+ end
134
+
135
+ create_index :ronin_credentials,
136
+ :user_name_id, :password_id,
137
+ :open_port_id, :email_address_id, :url_id,
138
+ :name => :unique_index_ronin_credentials,
139
+ :unique => true
140
+ end
141
+
142
+ down do
143
+ drop_table :ronin_credentials
144
+ end
145
+ end
146
+
147
+ migration :create_email_addresses_table,
148
+ :needs => [
149
+ :create_user_names_table,
150
+ :create_addresses_table
151
+ ] do
152
+ up do
153
+ create_table :ronin_email_addresses do
154
+ column :id, Serial
155
+ column :user_name_id, Integer, :not_null => true
156
+ column :host_name_id, Integer, :not_null => true
157
+ column :created_at, Time, :not_null => true
158
+ end
159
+
160
+ create_index :ronin_email_addresses, :user_name_id, :host_name_id,
161
+ :name => :unique_index_ronin_email_addresses,
162
+ :unique => true
163
+ end
164
+
165
+ down do
166
+ drop_table :ronin_email_addresses
167
+ end
168
+ end
169
+
170
+ migration :create_host_name_ip_addresses_table,
171
+ :needs => :create_addresses_table do
172
+ up do
173
+ create_table :ronin_host_name_ip_addresses do
174
+ column :id, Serial
175
+ column :host_name_id, Integer, :not_null => true
176
+ column :ip_address_id, Integer, :not_null => true
177
+ column :created_at, Time, :not_null => true
178
+ end
179
+
180
+ create_index :ronin_host_name_ip_addresses,
181
+ :host_name_id, :ip_address_id,
182
+ :name => :unique_index_ronin_host_name_ip_addresses,
183
+ :unique => true
184
+ end
185
+
186
+ down do
187
+ drop_table :ronin_host_name_ip_addresses
188
+ end
189
+ end
190
+
191
+ migration :create_ip_address_mac_addresses_table,
192
+ :needs => :create_addresses_table do
193
+ up do
194
+ create_table :ronin_ip_address_mac_addresses do
195
+ column :id, Serial
196
+ column :ip_address_id, Integer, :not_null => true
197
+ column :mac_address_id, Integer, :not_null => true
198
+ column :created_at, Time, :not_null => true
199
+ end
200
+
201
+ create_index :ronin_ip_address_mac_addresses,
202
+ :ip_address_id, :mac_address_id,
203
+ :name => :unique_index_ronin_ip_address_mac_addresses,
204
+ :unique => true
205
+ end
206
+
207
+ down do
208
+ drop_table :ronin_ip_address_mac_addresses
209
+ end
210
+ end
211
+
212
+ migration :create_licenses_table do
213
+ up do
214
+ create_table :ronin_licenses do
215
+ column :id, Integer, :serial => true
216
+ column :name, String, :not_null => true
217
+ column :description, Text, :not_null => true
218
+ column :url, String, :length => 256
219
+ end
220
+
221
+ create_index :ronin_licenses, :name, :unique => true
222
+ end
223
+
224
+ down do
225
+ drop_table :ronin_licenses
226
+ end
227
+ end
228
+
229
+ migration :create_open_ports_table,
230
+ :needs => [
231
+ :create_addresses_table,
232
+ :create_ports_table,
233
+ ] do
234
+ up do
235
+ create_table :ronin_open_ports do
236
+ column :id, Integer, :serial => true
237
+ column :ip_address_id, Integer, :not_null => true
238
+ column :port_id, Integer, :not_null => true
239
+ column :service_id, Integer
240
+ column :last_scanned_at, Time
241
+ column :created_at, Time, :not_null => true
242
+ end
243
+
244
+ create_index :ronin_open_ports,
245
+ :ip_address_id, :port_id, :service_id,
246
+ :name => :unique_index_ronin_open_ports,
247
+ :unique => true
248
+ end
249
+
250
+ down do
251
+ drop_table :ronin_open_ports
252
+ end
253
+ end
254
+
255
+ migration :create_organizations_table do
256
+ up do
257
+ create_table :ronin_organizations do
258
+ column :id, Integer, :serial => true
259
+ column :name, String, :not_null => true
260
+ column :description, Text, :not_null => true
261
+ column :created_at, Time, :not_null => true
262
+ end
263
+
264
+ create_index :ronin_organizations, :name, :unique => true
265
+ end
266
+
267
+ down do
268
+ drop_table :ronin_organizations
269
+ end
270
+ end
271
+
272
+ migration :create_os_guesses_table,
273
+ :needs => [
274
+ :create_addresses_table,
275
+ :create_os_table
276
+ ] do
277
+ up do
278
+ create_table :ronin_os_guesses do
279
+ column :id, Serial
280
+ column :ip_address_id, Integer, :not_null => true
281
+ column :os_id, Integer, :not_null => true
282
+ column :created_at, Time, :not_null => true
283
+ end
284
+
285
+ create_index :ronin_os_guesses, :ip_address_id, :os_id,
286
+ :name => :unique_index_ronin_os_guesses,
287
+ :unique => true
288
+ end
289
+
290
+ down do
291
+ drop_table :ronin_os_guesses
292
+ end
293
+ end
294
+
295
+ migration :create_os_table do
296
+ up do
297
+ create_table :ronin_os do
298
+ column :id, Integer, :serial => true
299
+ column :name, String, :not_null => true
300
+ column :version, String
301
+ end
302
+
303
+ create_index :ronin_os, :name
304
+ end
305
+
306
+ down do
307
+ drop_table :ronin_os
308
+ end
309
+ end
310
+
311
+ migration :create_passwords_table do
312
+ up do
313
+ create_table :ronin_passwords do
314
+ column :id, Integer, :serial => true
315
+ column :clear_text, String, :length => 256, :not_null => true
316
+ end
317
+
318
+ create_index :ronin_passwords, :clear_text, :unique => true
319
+ end
320
+
321
+ down do
322
+ drop_table :ronin_passwords
323
+ end
324
+ end
325
+
326
+ migration :create_ports_table, :needs => :create_organizations_table do
327
+ up do
328
+ create_table :ronin_ports do
329
+ column :id, Integer, :serial => true
330
+ column :protocol, String, :not_null => true
331
+ column :number, Integer, :not_null => true
332
+ column :organization_id, Integer
333
+ end
334
+
335
+ create_index :ronin_ports, :protocol, :number, :name => :protocol_number, :unique => true
336
+ end
337
+
338
+ down do
339
+ drop_table :ronin_ports
340
+ end
341
+ end
342
+
343
+ migration :create_proxies_table,
344
+ :needs => [
345
+ :create_addresses_table,
346
+ :create_ports_table
347
+ ] do
348
+ up do
349
+ create_table :ronin_proxies do
350
+ column :id, Integer, :serial => true
351
+ column :type, String, :not_null => true
352
+ column :anonymous, Boolean, :default => false
353
+ column :latency, Float
354
+ column :alive, Boolean, :default => true
355
+ column :ip_address_id, Integer, :not_null => true
356
+ column :port_id, Integer, :not_null => true
357
+ column :created_at, DateTime
358
+ column :updated_at, DateTime
359
+ end
360
+ end
361
+
362
+ down do
363
+ drop_table :ronin_proxies
364
+ end
365
+ end
366
+
367
+ migration :create_repositories_table, :needs => :create_licenses_table do
368
+ up do
369
+ create_table :ronin_repositories do
370
+ column :id, Integer, :serial => true
371
+ column :scm, String
372
+ column :path, FilePath, :not_null => true
373
+ column :uri, DataMapper::Property::URI
374
+ column :installed, Boolean, :default => false
375
+ column :name, String
376
+ column :domain, String, :not_null => true
377
+ column :title, Text
378
+ column :source, DataMapper::Property::URI
379
+ column :website, DataMapper::Property::URI
380
+ column :description, Text
381
+
382
+ column :license_id, Integer
383
+ end
384
+
385
+ create_table :ronin_author_repositories do
386
+ column :id, Integer, :serial => true
387
+ column :author_id, Integer
388
+ column :repository_id, Integer
389
+ end
390
+
391
+ create_index :ronin_repositories, :path, :unique => true
392
+ end
393
+
394
+ down do
395
+ drop_table :ronin_author_repositories
396
+ drop_table :ronin_repositories
397
+ end
398
+ end
399
+
400
+ migration :create_script_paths_table,
401
+ :needs => :create_repositories_table do
402
+ up do
403
+ create_table :ronin_script_paths do
404
+ column :id, Integer, :serial => true
405
+ column :path, FilePath, :not_null => true
406
+ column :timestamp, Time, :not_null => true
407
+ column :class_name, String, :not_null => true
408
+ column :repository_id, Integer, :not_null => true
409
+ end
410
+ end
411
+
412
+ down do
413
+ drop_table :ronin_script_paths
414
+ end
415
+ end
416
+
417
+ migration :create_services_table,
418
+ :needs => :create_organizations_table do
419
+ up do
420
+ create_table :ronin_services do
421
+ column :id, Integer, :serial => true
422
+ column :name, String, :not_null => true
423
+ column :organization_id, Integer
424
+ end
425
+
426
+ create_index :ronin_services, :name, :unique => true
427
+ end
428
+
429
+ down do
430
+ drop_table :ronin_services
431
+ end
432
+ end
433
+
434
+ migration :create_softwares_table,
435
+ :needs => :create_vendors_table do
436
+ up do
437
+ create_table :ronin_softwares do
438
+ column :id, Integer, :serial => true
439
+ column :name, String, :not_null => true
440
+ column :version, String, :not_null => true
441
+ column :vendor_id, Integer
442
+ end
443
+
444
+ create_index :ronin_softwares, :name
445
+ create_index :ronin_softwares, :version
446
+ end
447
+
448
+ down do
449
+ drop_table :ronin_arches
450
+ end
451
+ end
452
+
453
+ migration :create_targets_table,
454
+ :needs => [
455
+ :create_campaigns_table,
456
+ :create_addresses_table
457
+ ] do
458
+ up do
459
+ create_table :ronin_targets do
460
+ column :id, Integer, :serial => true
461
+ column :campaign_id, Integer, :not_null => true
462
+ column :address_id, Integer, :not_null => true
463
+ end
464
+
465
+ create_index :ronin_targets, :campaign_id, :address_id,
466
+ :name => :unique_index_ronin_campaigns,
467
+ :unique => true
468
+ end
469
+
470
+ down do
471
+ drop_table :ronin_targets
472
+ end
473
+ end
474
+
475
+ migration :create_url_query_params_table do
476
+ up do
477
+ create_table :ronin_url_query_params do
478
+ column :id, Integer, :serial => true
479
+ column :name, String, :length => 256, :not_null => true
480
+ column :value, Text
481
+ column :url_id, Integer, :not_null => true
482
+ end
483
+ end
484
+
485
+ down do
486
+ drop_table :ronin_url_query_params
487
+ end
488
+ end
489
+
490
+ migration :create_url_schemes_table do
491
+ up do
492
+ create_table :ronin_url_schemes do
493
+ column :id, Integer, :serial => true
494
+ column :name, String, :not_null => true
495
+ end
496
+ end
497
+
498
+ down do
499
+ drop_table :ronin_url_schemes
500
+ end
501
+ end
502
+
503
+ migration :create_urls_table,
504
+ :needs => [
505
+ :create_url_schemes_table,
506
+ :create_url_query_params_table,
507
+ :create_addresses_table,
508
+ :create_ports_table
509
+ ] do
510
+ up do
511
+ create_table :ronin_urls do
512
+ column :id, Integer, :serial => true
513
+ column :scheme_id, Integer, :not_null => true
514
+ column :host_name_id, Integer, :not_null => true
515
+ column :port_id, Integer
516
+ column :path, String
517
+ column :fragment, String
518
+ column :last_scanned_at, Time
519
+ column :created_at, Time, :not_null => true
520
+ end
521
+
522
+ create_index :ronin_urls, :scheme_id,
523
+ :host_name_id,
524
+ :port_id,
525
+ :path,
526
+ :fragment,
527
+ :name => :unique_index_ronin_urls,
528
+ :unique => true
529
+ end
530
+
531
+ down do
532
+ drop_table :ronin_urls
533
+ end
534
+ end
535
+
536
+ migration :create_user_names_table do
537
+ up do
538
+ create_table :ronin_user_names do
539
+ column :id, Integer, :serial => true
540
+ column :name, String, :not_null => true
541
+ column :created_at, Time, :not_null => true
542
+ end
543
+
544
+ create_index :ronin_user_names, :name, :unique => true
545
+ end
546
+
547
+ down do
548
+ drop_table :ronin_user_names
549
+ end
550
+ end
551
+
552
+ migration :create_vendors_table do
553
+ up do
554
+ create_table :ronin_vendors do
555
+ column :id, Integer, :serial => true
556
+ column :name, String, :not_null => true
557
+ end
558
+
559
+ create_index :ronin_vendors, :name, :unique => true
560
+ end
561
+
562
+ down do
563
+ drop_table :ronin_vendors
564
+ end
565
+ end
566
+ end
567
+ end
568
+ end