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.
- data/ChangeLog.md +10 -5
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +4 -4
- data/bin/ronin +2 -2
- data/bin/ronin-campaigns +2 -2
- data/bin/ronin-console +2 -2
- data/bin/ronin-creds +2 -2
- data/bin/ronin-database +2 -2
- data/bin/ronin-emails +2 -2
- data/bin/ronin-exec +2 -2
- data/bin/ronin-help +2 -2
- data/bin/ronin-hosts +2 -2
- data/bin/ronin-ips +2 -2
- data/bin/ronin-repos +2 -2
- data/bin/ronin-urls +2 -2
- data/gemspec.yml +2 -4
- data/lib/ronin/database/database.rb +12 -13
- data/lib/ronin/database/migrations.rb +2 -29
- data/lib/ronin/database/migrations/1.0.0.rb +568 -0
- data/lib/ronin/database/migrations/1.1.0.rb +125 -0
- data/lib/ronin/spec/database.rb +1 -4
- data/lib/ronin/target.rb +0 -19
- data/lib/ronin/ui/cli/cli.rb +1 -1
- data/lib/ronin/ui/cli/commands/database.rb +15 -22
- data/lib/ronin/ui/output/output.rb +1 -1
- data/lib/ronin/url.rb +23 -24
- data/lib/ronin/url_query_param.rb +4 -6
- data/lib/ronin/url_query_param_name.rb +89 -0
- data/lib/ronin/user_name.rb +0 -2
- data/lib/ronin/version.rb +1 -1
- data/ronin.gemspec +129 -13
- data/spec/host_name_spec.rb +9 -10
- data/spec/ip_address.rb +3 -3
- data/spec/url_query_param_spec.rb +5 -3
- data/spec/url_spec.rb +14 -9
- metadata +9 -35
- data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +0 -48
- data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +0 -47
- data/lib/ronin/database/migrations/create_addresses_table.rb +0 -49
- data/lib/ronin/database/migrations/create_arches_table.rb +0 -43
- data/lib/ronin/database/migrations/create_authors_table.rb +0 -46
- data/lib/ronin/database/migrations/create_campaigns_table.rb +0 -43
- data/lib/ronin/database/migrations/create_countries_table.rb +0 -43
- data/lib/ronin/database/migrations/create_credentials_table.rb +0 -64
- data/lib/ronin/database/migrations/create_email_addresses_table.rb +0 -50
- data/lib/ronin/database/migrations/create_host_name_ip_addresses_table.rb +0 -50
- data/lib/ronin/database/migrations/create_ip_address_mac_addresses_table.rb +0 -50
- data/lib/ronin/database/migrations/create_licenses_table.rb +0 -43
- data/lib/ronin/database/migrations/create_open_ports_table.rb +0 -56
- data/lib/ronin/database/migrations/create_organizations_table.rb +0 -43
- data/lib/ronin/database/migrations/create_os_guesses_table.rb +0 -49
- data/lib/ronin/database/migrations/create_os_table.rb +0 -42
- data/lib/ronin/database/migrations/create_passwords_table.rb +0 -41
- data/lib/ronin/database/migrations/create_ports_table.rb +0 -47
- data/lib/ronin/database/migrations/create_proxies_table.rb +0 -54
- data/lib/ronin/database/migrations/create_repositories_table.rb +0 -60
- data/lib/ronin/database/migrations/create_script_paths_table.rb +0 -46
- data/lib/ronin/database/migrations/create_services_table.rb +0 -46
- data/lib/ronin/database/migrations/create_softwares_table.rb +0 -45
- data/lib/ronin/database/migrations/create_targets_table.rb +0 -49
- data/lib/ronin/database/migrations/create_url_query_params_table.rb +0 -41
- data/lib/ronin/database/migrations/create_url_schemes_table.rb +0 -39
- data/lib/ronin/database/migrations/create_urls_table.rb +0 -65
- data/lib/ronin/database/migrations/create_user_names_table.rb +0 -42
- data/lib/ronin/database/migrations/create_vendors_table.rb +0 -41
@@ -0,0 +1,125 @@
|
|
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/1.0.0'
|
21
|
+
require 'ronin/campaign'
|
22
|
+
require 'ronin/target'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module Database
|
26
|
+
module Migrations
|
27
|
+
migration :add_updated_at_column_to_campaigns_table,
|
28
|
+
:needs => :create_campaigns_table do
|
29
|
+
up do
|
30
|
+
modify_table :ronin_campaigns do
|
31
|
+
add_column :updated_at, Time
|
32
|
+
end
|
33
|
+
|
34
|
+
# set the updated_at column to created_at
|
35
|
+
Campaign.each do |campaign|
|
36
|
+
campaign.update(:updated_at => campaign.created_at)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
migration :add_created_at_column_to_targets_table,
|
42
|
+
:needs => :create_targets_table do
|
43
|
+
up do
|
44
|
+
modify_table :ronin_targets do
|
45
|
+
add_column :created_at, Time
|
46
|
+
end
|
47
|
+
|
48
|
+
# set the updated_at column to the created_at of the Campaign
|
49
|
+
Target.each do |target|
|
50
|
+
target.update(:created_at => target.campaign.created_at)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
migration :create_url_query_param_names_table,
|
56
|
+
:needs => :create_url_query_params_table do
|
57
|
+
up do
|
58
|
+
create_table :ronin_url_query_param_names do
|
59
|
+
column :id, Integer, :serial => true
|
60
|
+
column :name, String, :length => 256, :not_null => true
|
61
|
+
end
|
62
|
+
|
63
|
+
create_index :ronin_url_query_param_names, :name, :unique => true
|
64
|
+
|
65
|
+
# select any previous URLQueryParam entries before recreating the table
|
66
|
+
query_params = adapter.select('SELECT id,name,value,url_id FROM ronin_url_query_params')
|
67
|
+
|
68
|
+
# recreate the `ronin_url_query_params` table
|
69
|
+
drop_table :ronin_url_query_params
|
70
|
+
create_table :ronin_url_query_params do
|
71
|
+
column :id, Integer, :serial => true
|
72
|
+
column :name_id, Integer, :not_null => true
|
73
|
+
column :value, Text
|
74
|
+
column :url_id, Integer, :not_null => true
|
75
|
+
end
|
76
|
+
|
77
|
+
name_ids = {}
|
78
|
+
|
79
|
+
query_params.each do |row|
|
80
|
+
unless name_ids.has_key?(row.name)
|
81
|
+
result = adapter.execute(
|
82
|
+
'INSERT INTO ronin_url_query_param_names (name) VALUES (?)',
|
83
|
+
row.name
|
84
|
+
)
|
85
|
+
|
86
|
+
name_ids[row.name] = result.insert_id
|
87
|
+
end
|
88
|
+
|
89
|
+
adapter.execute(
|
90
|
+
'INSERT INTO ronin_url_query_params (id,name_id,value,url_id) VALUES (?,?,?,?)',
|
91
|
+
row.id, name_ids[row.name], row.value, row.url_id
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
down do
|
97
|
+
id_names = {}
|
98
|
+
|
99
|
+
adapter.select('SELECT id,name FROM ronin_url_query_param_names').each do |row|
|
100
|
+
id_names[row.id] = row.name
|
101
|
+
end
|
102
|
+
|
103
|
+
query_params = adapter.select('SELECT id,name_id,value,url_id FROM ronin_url_query_params')
|
104
|
+
|
105
|
+
drop_table :ronin_url_query_params
|
106
|
+
create_table :ronin_url_query_params do
|
107
|
+
column :id, Integer, :serial => true
|
108
|
+
column :name, String, :length => 256, :not_null => true
|
109
|
+
column :value, Text
|
110
|
+
column :url_id, Integer, :not_null => true
|
111
|
+
end
|
112
|
+
|
113
|
+
query_params.each do |row|
|
114
|
+
adapter.execute(
|
115
|
+
'INSERT INTO ronin_url_query_params (id,name,value,url_id) VALUES (?,?,?,?)',
|
116
|
+
row.id, id_names[row.name_id], row.value, row.url_id
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
drop_table :ronin_url_query_param_names
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/ronin/spec/database.rb
CHANGED
@@ -25,10 +25,7 @@ require 'tempfile'
|
|
25
25
|
RSpec.configure do |spec|
|
26
26
|
spec.before(:suite) do
|
27
27
|
database_file = Tempfile.new('ronin_database').path
|
28
|
-
database_uri =
|
29
|
-
:scheme => 'sqlite3',
|
30
|
-
:path => database_file
|
31
|
-
)
|
28
|
+
database_uri = {:adapter => 'sqlite3', :database => database_file}
|
32
29
|
|
33
30
|
Ronin::Database.repositories[:default] = database_uri
|
34
31
|
|
data/lib/ronin/target.rb
CHANGED
@@ -51,25 +51,6 @@ module Ronin
|
|
51
51
|
# Validates the uniqueness of the address and the campaign.
|
52
52
|
validates_uniqueness_of :address, :scope => [:campaign]
|
53
53
|
|
54
|
-
#
|
55
|
-
# The directory to store files related to the target.
|
56
|
-
#
|
57
|
-
# @return [String]
|
58
|
-
# The path to the directory.
|
59
|
-
#
|
60
|
-
# @since 1.0.0
|
61
|
-
#
|
62
|
-
# @api semipublic
|
63
|
-
#
|
64
|
-
def directory
|
65
|
-
if self.campaign
|
66
|
-
path = File.join(self.campaign.directory,self.address.address)
|
67
|
-
|
68
|
-
FileUtils.mkdir(path) unless File.directory?(path)
|
69
|
-
return path
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
54
|
#
|
74
55
|
# Converts the target to a String.
|
75
56
|
#
|
data/lib/ronin/ui/cli/cli.rb
CHANGED
@@ -20,6 +20,8 @@
|
|
20
20
|
require 'ronin/ui/cli/command'
|
21
21
|
require 'ronin/database'
|
22
22
|
|
23
|
+
require 'addressable/uri'
|
24
|
+
|
23
25
|
module Ronin
|
24
26
|
module UI
|
25
27
|
module CLI
|
@@ -68,10 +70,8 @@ module Ronin
|
|
68
70
|
elsif options[:delete]
|
69
71
|
delete_repository
|
70
72
|
else
|
71
|
-
|
72
|
-
|
73
|
-
puts "#{name}: #{uri}"
|
74
|
-
end
|
73
|
+
Ronin::Database.repositories.each do |name,uri|
|
74
|
+
print_hash uri, :title => name
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -85,25 +85,18 @@ module Ronin
|
|
85
85
|
# The repository URI.
|
86
86
|
#
|
87
87
|
def repository_uri
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
if options[:database]
|
101
|
-
uri.path = options[:database]
|
102
|
-
elsif options[:path]
|
103
|
-
uri.path = options[:path]
|
88
|
+
if options[:uri]
|
89
|
+
Addressable::URI.parse(options[:uri]).to_hash
|
90
|
+
else
|
91
|
+
{
|
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])
|
98
|
+
}
|
104
99
|
end
|
105
|
-
|
106
|
-
return uri
|
107
100
|
end
|
108
101
|
|
109
102
|
#
|
data/lib/ronin/url.rb
CHANGED
@@ -186,7 +186,7 @@ module Ronin
|
|
186
186
|
# @api public
|
187
187
|
#
|
188
188
|
def self.query_param(name)
|
189
|
-
all('query_params.name' => name)
|
189
|
+
all('query_params.name.name' => name)
|
190
190
|
end
|
191
191
|
|
192
192
|
#
|
@@ -223,31 +223,27 @@ module Ronin
|
|
223
223
|
return super(url) if url.kind_of?(Integer)
|
224
224
|
|
225
225
|
# optionally parse the URL
|
226
|
-
unless url.kind_of?(::URI)
|
227
|
-
url = ::URI.parse(url.to_s)
|
228
|
-
end
|
229
|
-
|
230
|
-
port = if url.port
|
231
|
-
{:number => url.port}
|
232
|
-
end
|
233
|
-
|
234
|
-
path = normalized_path(url)
|
235
|
-
fragment = url.fragment
|
226
|
+
url = ::URI.parse(url.to_s) unless url.kind_of?(::URI)
|
236
227
|
|
237
228
|
# create the initial query
|
238
229
|
query = all(
|
239
|
-
|
240
|
-
|
241
|
-
:
|
242
|
-
:
|
243
|
-
:fragment => fragment
|
230
|
+
'scheme.name' => url.scheme,
|
231
|
+
'host_name.address' => url.host,
|
232
|
+
:path => normalized_path(url),
|
233
|
+
:fragment => url.fragment
|
244
234
|
)
|
245
235
|
|
236
|
+
if url.port
|
237
|
+
# query the port
|
238
|
+
query = query.all('port.number' => url.port)
|
239
|
+
end
|
240
|
+
|
246
241
|
if url.query
|
247
242
|
# add the query params to the query
|
248
243
|
URI::QueryParams.parse(url.query).each do |name,value|
|
249
244
|
query = query.all(
|
250
|
-
|
245
|
+
'query_params.name.name' => name,
|
246
|
+
'query_params.value' => value
|
251
247
|
)
|
252
248
|
end
|
253
249
|
end
|
@@ -270,10 +266,10 @@ module Ronin
|
|
270
266
|
#
|
271
267
|
def self.from(uri)
|
272
268
|
# find or create the URL scheme, host_name and port
|
273
|
-
scheme =
|
274
|
-
host_name =
|
269
|
+
scheme = URLScheme.first_or_new(:name => uri.scheme)
|
270
|
+
host_name = HostName.first_or_new(:address => uri.host)
|
275
271
|
port = if uri.port
|
276
|
-
|
272
|
+
TCPPort.first_or_new(:number => uri.port)
|
277
273
|
end
|
278
274
|
|
279
275
|
path = normalized_path(uri)
|
@@ -284,10 +280,10 @@ module Ronin
|
|
284
280
|
if uri.respond_to?(:query_params)
|
285
281
|
# find or create the URL query params
|
286
282
|
uri.query_params.each do |name,value|
|
287
|
-
query_params <<
|
288
|
-
:name => name,
|
283
|
+
query_params << {
|
284
|
+
:name => URLQueryParamName.first_or_new(:name => name),
|
289
285
|
:value => value
|
290
|
-
|
286
|
+
}
|
291
287
|
end
|
292
288
|
end
|
293
289
|
|
@@ -386,7 +382,10 @@ module Ronin
|
|
386
382
|
self.query_params.clear
|
387
383
|
|
388
384
|
URI::QueryParams.parse(query).each do |name,value|
|
389
|
-
self.query_params.new(
|
385
|
+
self.query_params.new(
|
386
|
+
:name => URLQueryParamName.first_or_new(:name => name),
|
387
|
+
:value => value
|
388
|
+
)
|
390
389
|
end
|
391
390
|
|
392
391
|
return query
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ronin/
|
20
|
+
require 'ronin/url_query_param_name'
|
21
21
|
require 'ronin/model'
|
22
22
|
|
23
23
|
require 'uri/query_params'
|
@@ -29,14 +29,12 @@ module Ronin
|
|
29
29
|
class URLQueryParam
|
30
30
|
|
31
31
|
include Model
|
32
|
-
include Model::HasName
|
33
32
|
|
34
33
|
# The primary-key of the URL query param
|
35
34
|
property :id, Serial
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
:index => true
|
36
|
+
# The name of the URL query param
|
37
|
+
belongs_to :name, :model => 'URLQueryParamName'
|
40
38
|
|
41
39
|
# The value of the URL query param
|
42
40
|
property :value, Text
|
@@ -55,7 +53,7 @@ module Ronin
|
|
55
53
|
# @api public
|
56
54
|
#
|
57
55
|
def to_s
|
58
|
-
URI::QueryParams.dump(self.name => self.value)
|
56
|
+
URI::QueryParams.dump(self.name.to_s => self.value)
|
59
57
|
end
|
60
58
|
|
61
59
|
#
|
@@ -0,0 +1,89 @@
|
|
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/model/has_unique_name'
|
21
|
+
require 'ronin/model'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
#
|
25
|
+
# Represents the name of a {URLQueryParam}.
|
26
|
+
#
|
27
|
+
class URLQueryParamName
|
28
|
+
|
29
|
+
include Model
|
30
|
+
include Model::HasUniqueName
|
31
|
+
|
32
|
+
# The primary-key of the URL query param
|
33
|
+
property :id, Serial
|
34
|
+
|
35
|
+
# The name of the URL query param
|
36
|
+
property :name, String, :length => 256,
|
37
|
+
:required => true,
|
38
|
+
:unique => true
|
39
|
+
|
40
|
+
# The URL query params
|
41
|
+
has 0..n, :query_params, :model => 'URLQueryParam',
|
42
|
+
:child_key => [:name_id]
|
43
|
+
|
44
|
+
#
|
45
|
+
# Specifies when the URL query param name was first seen.
|
46
|
+
#
|
47
|
+
# @return [Time]
|
48
|
+
# The timestamp that the query param name was first seen.
|
49
|
+
#
|
50
|
+
# @since 1.1.0
|
51
|
+
#
|
52
|
+
# @api public
|
53
|
+
#
|
54
|
+
def created_at
|
55
|
+
if (url = self.query_params.urls.first(:fields => [:created_at]))
|
56
|
+
url.created_at
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Converts the URL query param name to a String.
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
# The name of the URL query param
|
65
|
+
#
|
66
|
+
# @since 1.1.0
|
67
|
+
#
|
68
|
+
# @api public
|
69
|
+
#
|
70
|
+
def to_s
|
71
|
+
self.name.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Inspects the URL query param name.
|
76
|
+
#
|
77
|
+
# @return [String]
|
78
|
+
# The inspected URL query param name.
|
79
|
+
#
|
80
|
+
# @since 1.1.0
|
81
|
+
#
|
82
|
+
# @api public
|
83
|
+
#
|
84
|
+
def inspect
|
85
|
+
"#<#{self.class}: #{self}>"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|