metasploit_data_models 0.24.4 → 0.24.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/.travis.yml +3 -6
- data/CONTRIBUTING.md +52 -10
- data/Gemfile +8 -1
- data/Rakefile +0 -23
- data/app/models/mdm/api_key.rb +1 -41
- data/app/models/mdm/client.rb +1 -41
- data/app/models/mdm/cred.rb +19 -107
- data/app/models/mdm/event.rb +1 -48
- data/app/models/mdm/exploit_attempt.rb +16 -65
- data/app/models/mdm/exploited_host.rb +1 -28
- data/app/models/mdm/host_detail.rb +1 -45
- data/app/models/mdm/host_tag.rb +8 -6
- data/app/models/mdm/listener.rb +1 -53
- data/app/models/mdm/macro.rb +0 -42
- data/app/models/mdm/mod_ref.rb +0 -21
- data/app/models/mdm/module/action.rb +0 -15
- data/app/models/mdm/module/arch.rb +0 -10
- data/app/models/mdm/module/author.rb +0 -16
- data/app/models/mdm/module/mixin.rb +0 -13
- data/app/models/mdm/module/platform.rb +0 -11
- data/app/models/mdm/module/target.rb +0 -18
- data/app/models/mdm/nexpose_console.rb +4 -82
- data/app/models/mdm/profile.rb +0 -36
- data/app/models/mdm/route.rb +5 -17
- data/app/models/mdm/session_event.rb +1 -33
- data/app/models/mdm/tag.rb +10 -49
- data/app/models/mdm/task.rb +45 -94
- data/app/models/mdm/task_cred.rb +0 -29
- data/app/models/mdm/task_host.rb +0 -25
- data/app/models/mdm/task_service.rb +0 -25
- data/app/models/mdm/task_session.rb +0 -25
- data/app/models/mdm/user.rb +6 -188
- data/app/models/mdm/vuln_attempt.rb +12 -37
- data/app/models/mdm/vuln_detail.rb +5 -139
- data/app/models/mdm/vuln_ref.rb +1 -4
- data/app/models/mdm/web_form.rb +1 -35
- data/app/models/mdm/web_page.rb +1 -70
- data/app/models/mdm/web_site.rb +1 -51
- data/app/models/mdm/wmap_request.rb +0 -85
- data/app/models/mdm/wmap_target.rb +0 -40
- data/app/models/mdm/workspace.rb +14 -152
- data/app/models/metasploit_data_models/automatic_exploitation.rb +16 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +24 -19
- data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +5 -33
- data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +4 -22
- data/app/models/metasploit_data_models/automatic_exploitation/run.rb +3 -13
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/module_run.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/ip_format_validator.rb +0 -4
- data/app/validators/parameters_validator.rb +0 -12
- data/app/validators/password_is_strong_validator.rb +1 -10
- data/lib/mdm/host/operating_system_normalization.rb +10 -7
- data/lib/metasploit_data_models.rb +0 -4
- data/lib/metasploit_data_models/engine.rb +0 -2
- data/lib/metasploit_data_models/serialized_prefs.rb +0 -6
- data/lib/metasploit_data_models/version.rb +10 -24
- data/lib/tasks/yard.rake +33 -0
- data/metasploit_data_models.gemspec +2 -9
- data/spec/app/models/mdm/api_key_spec.rb +3 -1
- data/spec/app/models/mdm/client_spec.rb +11 -9
- data/spec/app/models/mdm/cred_spec.rb +54 -42
- data/spec/app/models/mdm/event_spec.rb +23 -21
- data/spec/app/models/mdm/exploit_attempt_spec.rb +21 -19
- data/spec/app/models/mdm/exploited_host_spec.rb +13 -11
- data/spec/app/models/mdm/host_detail_spec.rb +17 -15
- data/spec/app/models/mdm/host_spec.rb +260 -261
- data/spec/app/models/mdm/host_tag_spec.rb +8 -6
- data/spec/app/models/mdm/listener_spec.rb +32 -30
- data/spec/app/models/mdm/loot_spec.rb +23 -21
- data/spec/app/models/mdm/macro_spec.rb +3 -1
- data/spec/app/models/mdm/mod_ref_spec.rb +3 -1
- data/spec/app/models/mdm/module/action_spec.rb +12 -10
- data/spec/app/models/mdm/module/arch_spec.rb +12 -10
- data/spec/app/models/mdm/module/author_spec.rb +17 -22
- data/spec/app/models/mdm/module/detail_spec.rb +75 -184
- data/spec/app/models/mdm/module/mixin_spec.rb +12 -10
- data/spec/app/models/mdm/module/platform_spec.rb +12 -10
- data/spec/app/models/mdm/module/ref_spec.rb +12 -10
- data/spec/app/models/mdm/module/target_spec.rb +15 -13
- data/spec/app/models/mdm/nexpose_console_spec.rb +37 -35
- data/spec/app/models/mdm/note_spec.rb +25 -23
- data/spec/app/models/mdm/profile_spec.rb +3 -1
- data/spec/app/models/mdm/ref_spec.rb +12 -10
- data/spec/app/models/mdm/route_spec.rb +8 -6
- data/spec/app/models/mdm/service_spec.rb +40 -38
- data/spec/app/models/mdm/session_event_spec.rb +12 -10
- data/spec/app/models/mdm/session_spec.rb +15 -13
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +11 -9
- data/spec/app/models/mdm/task_host_spec.rb +11 -9
- data/spec/app/models/mdm/task_service_spec.rb +11 -9
- data/spec/app/models/mdm/task_session_spec.rb +9 -7
- data/spec/app/models/mdm/task_spec.rb +29 -27
- data/spec/app/models/mdm/user_spec.rb +19 -17
- data/spec/app/models/mdm/vuln_attempt_spec.rb +16 -14
- data/spec/app/models/mdm/vuln_detail_spec.rb +28 -26
- data/spec/app/models/mdm/vuln_ref_spec.rb +10 -8
- data/spec/app/models/mdm/vuln_spec.rb +26 -24
- data/spec/app/models/mdm/web_form_spec.rb +13 -11
- data/spec/app/models/mdm/web_page_spec.rb +21 -19
- data/spec/app/models/mdm/web_site_spec.rb +23 -21
- data/spec/app/models/mdm/web_vuln_spec.rb +65 -63
- data/spec/app/models/mdm/wmap_request_spec.rb +3 -1
- data/spec/app/models/mdm/wmap_target_spec.rb +3 -1
- data/spec/app/models/mdm/workspace_spec.rb +100 -97
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +5 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +15 -13
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +12 -10
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +15 -22
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +20 -18
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +4 -2
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +19 -17
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +23 -61
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +10 -8
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +46 -54
- data/spec/dummy/db/structure.sql +3403 -0
- data/spec/factories/mdm/module/details.rb +1 -1
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +12 -18
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/match/child_spec.rb +4 -2
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/version_spec.rb +141 -3
- data/spec/spec_helper.rb +12 -86
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +6 -7
- metadata +9 -67
- data/CHANGELOG.md +0 -6
- data/RELEASING.md +0 -88
- data/UPGRADING.md +0 -1
- data/lib/metasploit_data_models/automatic_exploitation.rb +0 -25
- data/spec/lib/metasploit_data_models_spec.rb +0 -4
data/lib/tasks/yard.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# @note All options not specific to any given rake task should go in the .yardopts file so they are available to both
|
2
|
+
# the below rake tasks and when invoking `yard` from the command line
|
3
|
+
|
4
|
+
if defined? YARD
|
5
|
+
namespace :yard do
|
6
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
7
|
+
# --no-stats here as 'stats' task called after will print fuller stats
|
8
|
+
t.options = ['--no-stats']
|
9
|
+
|
10
|
+
t.after = Proc.new {
|
11
|
+
Rake::Task['yard:stats'].execute
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
# need environment so that yard templates can load ActiveRecord::Base subclasses for Entity-Relationship Diagrams
|
16
|
+
task :doc => :eager_load
|
17
|
+
|
18
|
+
desc "Shows stats for YARD Documentation including listing undocumented modules, classes, constants, and methods"
|
19
|
+
task :stats => :environment do
|
20
|
+
stats = YARD::CLI::Stats.new
|
21
|
+
stats.run('--compact', '--list-undoc')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @todo Figure out how to just clone description from yard:doc
|
26
|
+
desc "Generate YARD documentation"
|
27
|
+
# allow calling namespace to as a task that goes to default task for namespace
|
28
|
+
task :yard => ['yard:doc']
|
29
|
+
end
|
30
|
+
|
31
|
+
task eager_load: :environment do
|
32
|
+
Rails.application.eager_load!
|
33
|
+
end
|
@@ -29,13 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.required_ruby_version = '>= 2.1'
|
30
30
|
|
31
31
|
# ---- Dependencies ----
|
32
|
-
s.add_development_dependency 'metasploit-version', '~> 0.1.3'
|
33
|
-
# documentation
|
34
|
-
s.add_development_dependency 'metasploit-yard', '~> 1.0'
|
35
|
-
s.add_development_dependency 'yard-activerecord', '~> 0.0.14'
|
36
|
-
# embed ERDs on index, namespace Module and Class<ActiveRecord::Base> pages
|
37
|
-
s.add_development_dependency 'yard-metasploit-erd', '~> 0.1.0'
|
38
|
-
|
39
32
|
s.add_development_dependency 'rake'
|
40
33
|
|
41
34
|
# documentation
|
@@ -51,8 +44,8 @@ Gem::Specification.new do |s|
|
|
51
44
|
# os fingerprinting
|
52
45
|
s.add_runtime_dependency 'recog', '~> 1.0'
|
53
46
|
|
54
|
-
s.add_runtime_dependency 'metasploit-concern', '0.
|
55
|
-
s.add_runtime_dependency 'metasploit-model', '~> 0.
|
47
|
+
s.add_runtime_dependency 'metasploit-concern', '0.4.0'
|
48
|
+
s.add_runtime_dependency 'metasploit-model', '~> 0.29.0'
|
56
49
|
s.add_runtime_dependency 'railties', '< 4.0.0'
|
57
50
|
|
58
51
|
# arel-helpers: Useful tools to help construct database queries with ActiveRecord and Arel.
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::Client do
|
2
4
|
|
3
5
|
it_should_behave_like 'Metasploit::Concern.run'
|
4
6
|
|
5
7
|
context 'associations' do
|
6
|
-
it {
|
8
|
+
it { should belong_to(:host).class_name('Mdm::Host') }
|
7
9
|
end
|
8
10
|
|
9
11
|
context '#destroy' do
|
@@ -21,21 +23,21 @@ RSpec.describe Mdm::Client, type: :model do
|
|
21
23
|
context 'factory' do
|
22
24
|
it 'should be valid' do
|
23
25
|
client = FactoryGirl.build(:mdm_client)
|
24
|
-
|
26
|
+
client.should be_valid
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
context 'database' do
|
29
31
|
context 'columns' do
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
32
|
+
it { should have_db_column(:host_id).of_type(:integer)}
|
33
|
+
it { should have_db_column(:ua_string).of_type(:string).with_options(:null => false) }
|
34
|
+
it { should have_db_column(:ua_name).of_type(:string) }
|
35
|
+
it { should have_db_column(:ua_ver).of_type(:string) }
|
34
36
|
end
|
35
37
|
|
36
38
|
context 'timestamps' do
|
37
|
-
it {
|
38
|
-
it {
|
39
|
+
it { should have_db_column(:created_at).of_type(:datetime) }
|
40
|
+
it { should have_db_column(:updated_at).of_type(:datetime) }
|
39
41
|
end
|
40
42
|
|
41
43
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::Cred do
|
2
4
|
it_should_behave_like 'Metasploit::Concern.run'
|
3
5
|
|
4
6
|
context "Associations" do
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
7
|
+
it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
|
8
|
+
it { should have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
|
9
|
+
it { should belong_to(:service).class_name('Mdm::Service') }
|
8
10
|
end
|
9
11
|
|
10
12
|
context 'database' do
|
11
13
|
context 'timestamps' do
|
12
|
-
it {
|
13
|
-
it {
|
14
|
+
it { should have_db_column(:created_at).of_type(:datetime) }
|
15
|
+
it { should have_db_column(:updated_at).of_type(:datetime) }
|
14
16
|
end
|
15
17
|
|
16
18
|
context 'columns' do
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
19
|
+
it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
|
20
|
+
it { should have_db_column(:user).of_type(:string) }
|
21
|
+
it { should have_db_column(:pass).of_type(:string) }
|
22
|
+
it { should have_db_column(:active).of_type(:boolean).with_options(:default => true) }
|
23
|
+
it { should have_db_column(:proof).of_type(:string) }
|
24
|
+
it { should have_db_column(:ptype).of_type(:string) }
|
25
|
+
it { should have_db_column(:source_id).of_type(:integer) }
|
26
|
+
it { should have_db_column(:source_type).of_type(:string) }
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -66,23 +68,25 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
66
68
|
|
67
69
|
context 'constants' do
|
68
70
|
it 'should define the key_id regex' do
|
69
|
-
|
71
|
+
described_class::KEY_ID_REGEX.should == /([0-9a-fA-F:]{47})/
|
70
72
|
end
|
71
73
|
|
72
74
|
it 'should define ptypes to humanize' do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
}
|
81
|
-
)
|
75
|
+
described_class::PTYPES.should == {
|
76
|
+
'read/write password' => 'password_rw',
|
77
|
+
'read-only password' => 'password_ro',
|
78
|
+
'SMB hash' => 'smb_hash',
|
79
|
+
'SSH private key' => 'ssh_key',
|
80
|
+
'SSH public key' => 'ssh_pubkey'
|
81
|
+
}
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'methods' do
|
86
|
+
#
|
87
|
+
# lets
|
88
|
+
#
|
89
|
+
|
86
90
|
let(:host) {
|
87
91
|
FactoryGirl.create(
|
88
92
|
:mdm_host,
|
@@ -130,47 +134,55 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
130
134
|
FactoryGirl.create(:mdm_workspace)
|
131
135
|
}
|
132
136
|
|
137
|
+
#
|
138
|
+
# Callbacks
|
139
|
+
#
|
140
|
+
|
141
|
+
before(:all) do
|
142
|
+
Mdm::Workspace.any_instance.stub(:valid_ip_or_range? => true)
|
143
|
+
end
|
144
|
+
|
133
145
|
context '#ptype_human' do
|
134
146
|
it "should return 'read/write password' for 'password_rw'" do
|
135
147
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
|
136
|
-
|
148
|
+
cred.ptype_human.should == 'read/write password'
|
137
149
|
end
|
138
150
|
|
139
151
|
it "should return 'read-only password' for 'password_ro'" do
|
140
152
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_ro')
|
141
|
-
|
153
|
+
cred.ptype_human.should == 'read-only password'
|
142
154
|
end
|
143
155
|
|
144
156
|
it "should return 'SMB Hash' for 'smb_hash'" do
|
145
157
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'smb_hash')
|
146
|
-
|
158
|
+
cred.ptype_human.should == 'SMB hash'
|
147
159
|
end
|
148
160
|
|
149
161
|
it "should return 'SSH private key' for 'ssh_key'" do
|
150
162
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_key')
|
151
|
-
|
163
|
+
cred.ptype_human.should == 'SSH private key'
|
152
164
|
end
|
153
165
|
|
154
166
|
it "should return 'SSH public key' for 'ssh_pubkey'" do
|
155
167
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_pubkey')
|
156
|
-
|
168
|
+
cred.ptype_human.should == 'SSH public key'
|
157
169
|
end
|
158
170
|
end
|
159
171
|
|
160
172
|
context '#ssh_key_id' do
|
161
173
|
it 'should return nil if not an ssh_key' do
|
162
174
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
|
163
|
-
|
175
|
+
cred.ssh_key_id.should == nil
|
164
176
|
end
|
165
177
|
|
166
178
|
it 'should return nil if proof does not contain the key id' do
|
167
179
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "no key here")
|
168
|
-
|
180
|
+
cred.ssh_key_id.should == nil
|
169
181
|
end
|
170
182
|
|
171
183
|
it 'should return the key id for an ssh_key' do
|
172
184
|
cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
|
173
|
-
|
185
|
+
cred.ssh_key_id.should == '57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a'
|
174
186
|
end
|
175
187
|
|
176
188
|
end
|
@@ -222,14 +234,14 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
222
234
|
it 'should behave the same for public keys as private keys' do
|
223
235
|
pubkey2 = FactoryGirl.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
|
224
236
|
pubkey3 = FactoryGirl.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=66:d4:22:6e:88:d6:74:A1:44:3e:d6:d5:AA:89:73:8b")
|
225
|
-
|
226
|
-
|
237
|
+
pubkey2.ssh_key_matches?(ssh_pubkey).should == true
|
238
|
+
pubkey2.ssh_key_matches?(pubkey3).should == false
|
227
239
|
end
|
228
240
|
|
229
241
|
it 'should always return false for non ssh key creds' do
|
230
242
|
cred2 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
|
231
243
|
cred3 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
|
232
|
-
|
244
|
+
cred2.ssh_key_matches?(cred3).should == false
|
233
245
|
end
|
234
246
|
end
|
235
247
|
|
@@ -259,11 +271,11 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
259
271
|
end
|
260
272
|
|
261
273
|
it 'should return all ssh private keys with a matching id' do
|
262
|
-
|
274
|
+
other_ssh_key.ssh_keys.should include(ssh_key)
|
263
275
|
end
|
264
276
|
|
265
277
|
it 'should return all ssh public keys with a matching id' do
|
266
|
-
|
278
|
+
other_ssh_key.ssh_keys.should include(ssh_pubkey)
|
267
279
|
end
|
268
280
|
end
|
269
281
|
|
@@ -293,11 +305,11 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
293
305
|
end
|
294
306
|
|
295
307
|
it 'should return ssh private keys with matching ids' do
|
296
|
-
|
308
|
+
other_ssh_key.ssh_private_keys.should include(ssh_key)
|
297
309
|
end
|
298
310
|
|
299
311
|
it 'should not return ssh public keys with matching ids' do
|
300
|
-
|
312
|
+
other_ssh_key.ssh_private_keys.should_not include(ssh_pubkey)
|
301
313
|
end
|
302
314
|
end
|
303
315
|
|
@@ -327,11 +339,11 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
327
339
|
end
|
328
340
|
|
329
341
|
it 'should not return ssh private keys with matching ids' do
|
330
|
-
|
342
|
+
other_ssh_key.ssh_public_keys.should_not include(ssh_key)
|
331
343
|
end
|
332
344
|
|
333
345
|
it 'should return ssh public keys with matching ids' do
|
334
|
-
|
346
|
+
other_ssh_key.ssh_public_keys.should include(ssh_pubkey)
|
335
347
|
end
|
336
348
|
end
|
337
349
|
end
|
@@ -339,7 +351,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
339
351
|
context 'factory' do
|
340
352
|
it 'should be valid' do
|
341
353
|
cred = FactoryGirl.build(:mdm_cred)
|
342
|
-
|
354
|
+
cred.should be_valid
|
343
355
|
end
|
344
356
|
end
|
345
357
|
|
@@ -1,25 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::Event do
|
2
4
|
it_should_behave_like 'Metasploit::Concern.run'
|
3
5
|
|
4
6
|
context 'associations' do
|
5
|
-
it {
|
6
|
-
it {
|
7
|
+
it { should belong_to(:host).class_name('Mdm::Host') }
|
8
|
+
it { should belong_to(:workspace).class_name('Mdm::Workspace') }
|
7
9
|
end
|
8
10
|
|
9
11
|
context 'database' do
|
10
12
|
context 'timestamps' do
|
11
|
-
it {
|
12
|
-
it {
|
13
|
+
it { should have_db_column(:created_at).of_type(:datetime) }
|
14
|
+
it { should have_db_column(:updated_at).of_type(:datetime) }
|
13
15
|
end
|
14
16
|
|
15
17
|
context 'columns' do
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
18
|
+
it { should have_db_column(:workspace_id).of_type(:integer) }
|
19
|
+
it { should have_db_column(:host_id).of_type(:integer) }
|
20
|
+
it { should have_db_column(:name).of_type(:string) }
|
21
|
+
it { should have_db_column(:critical).of_type(:boolean) }
|
22
|
+
it { should have_db_column(:seen).of_type(:boolean) }
|
23
|
+
it { should have_db_column(:username).of_type(:string) }
|
24
|
+
it { should have_db_column(:info).of_type(:text) }
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -42,16 +44,16 @@ RSpec.describe Mdm::Event, type: :model do
|
|
42
44
|
flagged_event = FactoryGirl.create(:mdm_event, :name => 'flagme', :critical => true, :seen => false)
|
43
45
|
non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro', :critical => false, :seen => false)
|
44
46
|
flagged_set = Mdm::Event.flagged
|
45
|
-
|
46
|
-
|
47
|
+
flagged_set.should include(flagged_event)
|
48
|
+
flagged_set.should_not include(non_critical_event)
|
47
49
|
end
|
48
50
|
|
49
51
|
it 'should exclude seen events' do
|
50
52
|
flagged_event = FactoryGirl.create(:mdm_event, :name => 'flagme', :critical => true, :seen => false)
|
51
53
|
non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro', :critical => false, :seen => true)
|
52
54
|
flagged_set = Mdm::Event.flagged
|
53
|
-
|
54
|
-
|
55
|
+
flagged_set.should include(flagged_event)
|
56
|
+
flagged_set.should_not include(non_critical_event)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -60,8 +62,8 @@ RSpec.describe Mdm::Event, type: :model do
|
|
60
62
|
flagged_event = FactoryGirl.create(:mdm_event, :name => 'module_run')
|
61
63
|
non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro')
|
62
64
|
flagged_set = Mdm::Event.module_run
|
63
|
-
|
64
|
-
|
65
|
+
flagged_set.should include(flagged_event)
|
66
|
+
flagged_set.should_not include(non_critical_event)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
end
|
@@ -69,15 +71,15 @@ RSpec.describe Mdm::Event, type: :model do
|
|
69
71
|
context 'validations' do
|
70
72
|
it 'should require name' do
|
71
73
|
unnamed_event = FactoryGirl.build(:mdm_event, :name => nil)
|
72
|
-
|
73
|
-
|
74
|
+
unnamed_event.should_not be_valid
|
75
|
+
unnamed_event.errors[:name].should include("can't be blank")
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
79
|
context 'factory' do
|
78
80
|
it 'should be valid' do
|
79
81
|
event = FactoryGirl.build(:mdm_event)
|
80
|
-
|
82
|
+
event.should be_valid
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -1,29 +1,31 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ExploitAttempt do
|
2
4
|
it_should_behave_like 'Metasploit::Concern.run'
|
3
5
|
|
4
6
|
context 'associations' do
|
5
|
-
it {
|
7
|
+
it { should belong_to(:host).class_name('Mdm::Host') }
|
6
8
|
end
|
7
9
|
|
8
10
|
context 'database' do
|
9
11
|
|
10
12
|
context 'timestamps'do
|
11
|
-
it {
|
13
|
+
it { should have_db_column(:attempted_at).of_type(:datetime) }
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'columns' do
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
17
|
+
it { should have_db_column(:host_id).of_type(:integer) }
|
18
|
+
it { should have_db_column(:service_id).of_type(:integer) }
|
19
|
+
it { should have_db_column(:vuln_id).of_type(:integer) }
|
20
|
+
it { should have_db_column(:exploited).of_type(:boolean) }
|
21
|
+
it { should have_db_column(:fail_reason).of_type(:string) }
|
22
|
+
it { should have_db_column(:username).of_type(:string) }
|
23
|
+
it { should have_db_column(:module).of_type(:text) }
|
24
|
+
it { should have_db_column(:session_id).of_type(:integer) }
|
25
|
+
it { should have_db_column(:loot_id).of_type(:integer) }
|
26
|
+
it { should have_db_column(:port).of_type(:integer) }
|
27
|
+
it { should have_db_column(:proto).of_type(:string) }
|
28
|
+
it { should have_db_column(:fail_detail).of_type(:text) }
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -43,17 +45,17 @@ RSpec.describe Mdm::ExploitAttempt, type: :model do
|
|
43
45
|
context 'validations' do
|
44
46
|
it 'should only be valid with a host_id' do
|
45
47
|
orphaned_attempt = FactoryGirl.build(:mdm_exploit_attempt, :host => nil)
|
46
|
-
|
47
|
-
|
48
|
+
orphaned_attempt.should_not be_valid
|
49
|
+
orphaned_attempt.errors[:host_id].should include("can't be blank")
|
48
50
|
propper_attempt = FactoryGirl.build(:mdm_exploit_attempt)
|
49
|
-
|
51
|
+
propper_attempt.should be_valid
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
55
|
context 'factory' do
|
54
56
|
it 'should be valid' do
|
55
57
|
exploit_attempt = FactoryGirl.build(:mdm_exploit_attempt)
|
56
|
-
|
58
|
+
exploit_attempt.should be_valid
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|