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
@@ -1,52 +0,0 @@
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/create_targets_table'
21
- require 'ronin/database/migrations/create_taggings_table'
22
- require 'ronin/database/migrations/migrations'
23
-
24
- module Ronin
25
- module Database
26
- module Migrations
27
- migration(
28
- :create_remote_files_table,
29
- :needs => [:create_targets_table, :create_taggings_table]
30
- ) do
31
- up do
32
- create_table :ronin_remote_files do
33
- column :id, Integer, :serial => true
34
- column :remote_path, String, :not_null => true
35
- column :target_id, Integer, :not_null => true
36
- column :created_at, Time, :not_null => true
37
- column :frozen_tag_list, Text
38
- end
39
-
40
- create_index :ronin_remote_files, :remote_path
41
- create_index :ronin_remote_files, :target_id, :remote_path,
42
- :name => :target_remote_path,
43
- :unique => true
44
- end
45
-
46
- down do
47
- drop_table :ronin_remote_files
48
- end
49
- end
50
- end
51
- end
52
- end
data/lib/ronin/proxy.rb DELETED
@@ -1,178 +0,0 @@
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/network/http/proxy'
21
- require 'ronin/network/http/http'
22
- require 'ronin/proxy_credential'
23
- require 'ronin/ip_address'
24
- require 'ronin/port'
25
- require 'ronin/model'
26
-
27
- require 'dm-timestamps'
28
-
29
- module Ronin
30
- class Proxy
31
-
32
- include Model
33
-
34
- # The primary-key of the proxy
35
- property :id, Serial
36
-
37
- # The type of proxy
38
- property :type, String, :set => %w[http socks]
39
-
40
- # Whether the proxy was anonymous
41
- property :anonymous, Boolean, :default => false
42
-
43
- # The latency for the proxy
44
- property :latency, Float
45
-
46
- # Specifies whether the proxy is dead or alive
47
- property :alive, Boolean, :default => true
48
-
49
- # The address of the proxy
50
- belongs_to :ip_address, :model => 'Ronin::IPAddress'
51
-
52
- # The port of the proxy
53
- belongs_to :port
54
-
55
- # Any credentials used for the proxy
56
- has 0..n, :credentials, :model => 'Ronin::ProxyCredential'
57
-
58
- # Specifies when the proxy was first created and last updated at
59
- timestamps :at
60
-
61
- #
62
- # Determines if the proxy is an HTTP proxy.
63
- #
64
- # @return [Boolean]
65
- # Specifies whether the proxy was an HTTP proxy.
66
- #
67
- def http?
68
- self.type == 'http'
69
- end
70
-
71
- #
72
- # Determines if the proxy is a SOCKS proxy.
73
- #
74
- # @return [Boolean]
75
- # Specifies whether the proxy was a SOCKS proxy.
76
- #
77
- def socks?
78
- self.type == 'socks'
79
- end
80
-
81
- #
82
- # Creates an HTTP Proxy.
83
- #
84
- # @return [Network::HTTP::Proxy]
85
- # The HTTP Proxy.
86
- #
87
- # @since 0.2.0
88
- #
89
- def http_proxy
90
- proxy = Network::HTTP::Proxy.new(
91
- :host => self.ip_address.address,
92
- :port => self.port.number,
93
- )
94
-
95
- unless self.credentials.empty?
96
- creds = self.credentials.first
97
-
98
- proxy.user = creds.user
99
- proxy.password = creds.password
100
- end
101
-
102
- return proxy
103
- end
104
-
105
- #
106
- # Uses the proxy.
107
- #
108
- # @return [Boolean]
109
- # Specifies if the proxy is being used.
110
- #
111
- # @since 0.2.0
112
- #
113
- def use!
114
- if http?
115
- Network::HTTP.proxy = http_proxy
116
- elsif socks?
117
- raise(NotImplementedError,"SOCKS proxies not supported yet")
118
- end
119
-
120
- return true
121
- end
122
-
123
- #
124
- # Tests the proxy.
125
- #
126
- # @return [Boolean]
127
- # Specifies whether the proxy is alive or dead.
128
- #
129
- # @since 0.2.0
130
- #
131
- def test
132
- if http?
133
- proxy = http_proxy
134
-
135
- if proxy.valid?
136
- self.alive = true
137
- self.anonymous = proxy.anonymous?
138
- self.latency = proxy.latency
139
- return true
140
- else
141
- self.alive = false
142
- return false
143
- end
144
- elsif socks?
145
- # simply return if it is a SOCKS proxy
146
- return true
147
- end
148
- end
149
-
150
- #
151
- # Converts the proxy to a String.
152
- #
153
- # @return [String]
154
- # The String representation of the proxy.
155
- #
156
- # @since 0.2.0
157
- #
158
- def to_s
159
- "#{self.ip_address}:#{self.port}"
160
- end
161
-
162
- #
163
- # Splats the proxy into multiple variables.
164
- #
165
- # @return [Array]
166
- # The IP address and port number of the proxy.
167
- #
168
- # @example
169
- # ip, port = proxy
170
- #
171
- # @since 1.0.0
172
- #
173
- def to_ary
174
- [self.ip_address.address, self.port.number]
175
- end
176
-
177
- end
178
- end
@@ -1,29 +0,0 @@
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/credential'
21
- require 'ronin/proxy'
22
-
23
- module Ronin
24
- class ProxyCredential < Credential
25
-
26
- belongs_to :proxy, :required => false
27
-
28
- end
29
- end
@@ -1,152 +0,0 @@
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/target'
21
- require 'ronin/model'
22
- require 'ronin/extensions/file'
23
-
24
- require 'dm-timestamps'
25
- require 'dm-tags'
26
- require 'fileutils'
27
-
28
- module Ronin
29
- class RemoteFile
30
-
31
- include Model
32
-
33
- # Primary key of the remote file
34
- property :id, Serial
35
-
36
- # Remote path of the file
37
- property :remote_path, String, :required => true,
38
- :index => true
39
-
40
- # The target the file was recovered from
41
- belongs_to :target
42
-
43
- # The address the file was recovered from
44
- has 1, :address, :through => :target
45
-
46
- # Tracks when the remote file was first recovered
47
- timestamps :created_at
48
-
49
- # Tags
50
- has_tags_on :tags
51
-
52
- # Validates the uniqueness of the remote_path and the target.
53
- validates_uniqueness_of :remote_path, :scope => [:target]
54
-
55
- #
56
- # Searches for all remote files with the basename.
57
- #
58
- # @param [String] basename
59
- # The basename of the file.
60
- #
61
- # @return [Array<RemoteFile>]
62
- # The matching remote files.
63
- #
64
- # @since 1.0.0
65
- #
66
- def self.named(basename)
67
- all(:remote_path => basename) |
68
- all(:remote_path.like => "%/#{basename}")
69
- end
70
-
71
- #
72
- # Searches for all remote files with the file name extension.
73
- #
74
- # @param [String, Symbol] ext
75
- # The file name extension.
76
- #
77
- # @return [Array<RemoteFile>]
78
- # The matching remote files.
79
- #
80
- # @since 1.0.0
81
- #
82
- def self.extension(ext)
83
- all(:remote_path => "%.#{ext}")
84
- end
85
-
86
- #
87
- # The local path for the remote file.
88
- #
89
- # @return [String, nil]
90
- # The local path within the `~/.ronin/campaigns` directory.
91
- #
92
- # @since 1.0.0
93
- #
94
- def local_path
95
- if self.target
96
- escaped_path = File.escape_path(self.remote_path)
97
- return File.join(self.target.directory,escaped_path)
98
- end
99
- end
100
-
101
- #
102
- # Determines whether the remote file has been downloaded yet.
103
- #
104
- # @return [Boolean]
105
- # Specifies whether the remote file was downloaded.
106
- #
107
- # @since 1.0.0
108
- #
109
- def downloaded?
110
- !(File.file?(local_path))
111
- end
112
-
113
- #
114
- # Opens the downloaded remote file for reading.
115
- #
116
- # @yield [file]
117
- # The opened file will be passed to the given block.
118
- #
119
- # @yieldparam [File] file
120
- # The opened file.
121
- #
122
- # @return [File, nil]
123
- # If no block is given, the opened file will be returned.
124
- #
125
- # @since 1.0.0
126
- #
127
- def open(&block)
128
- File.open(local_path,'rb',&block)
129
- end
130
-
131
- #
132
- # Opens a local file for saving the contents of the remote file.
133
- #
134
- # @yield [file]
135
- # The opened file will be passed to the given block.
136
- #
137
- # @yieldparam [File] file
138
- # The opened file.
139
- #
140
- # @return [File, nil]
141
- # If no block is given, the opened file will be returned.
142
- #
143
- def download!(&block)
144
- path = local_path
145
- directory = File.dirname(path)
146
-
147
- FileUtils.mkdir_p(directory) unless File.directory?(directory)
148
- return File.open(path,'wb',&block)
149
- end
150
-
151
- end
152
- end