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
@@ -1,37 +1,42 @@
|
|
1
|
-
# Matches {#matchable} {Mdm::Service} or {Mdm::Vuln} to a {#module_detail Metasploit Module} that can exploit it.
|
2
1
|
class MetasploitDataModels::AutomaticExploitation::Match < ActiveRecord::Base
|
2
|
+
attr_accessible :match_set_id, :module_fullname
|
3
|
+
|
4
|
+
|
3
5
|
#
|
4
6
|
# Associations
|
5
7
|
#
|
6
8
|
|
7
|
-
#
|
9
|
+
# @!attribute matchable
|
10
|
+
# A (polymorphic) "matchable" entity like a {Mdm::Vuln} or {Mdm::Service}
|
8
11
|
#
|
9
|
-
#
|
12
|
+
# @return [Mdm::Vuln, Mdm::Service]
|
10
13
|
belongs_to :matchable, polymorphic: true
|
14
|
+
attr_accessible :matchable
|
11
15
|
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# The {MatchSet} this match is part of
|
18
|
-
belongs_to :match_set,
|
19
|
-
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
|
20
|
-
inverse_of: :matches
|
21
|
-
|
22
|
-
# The Metasploit Module that this match connects to
|
16
|
+
# @!attribute module_detail
|
17
|
+
# The MSF module that this match connects to
|
18
|
+
#
|
19
|
+
# @return [Mdm::Module::Detail]
|
23
20
|
belongs_to :module_detail,
|
24
21
|
class_name: 'Mdm::Module::Detail',
|
25
22
|
foreign_key: :module_fullname,
|
26
23
|
primary_key: :fullname
|
27
24
|
|
25
|
+
# @!attribute match_set
|
26
|
+
# The {MatchSet} this match is part of
|
28
27
|
#
|
29
|
-
#
|
30
|
-
|
28
|
+
# @return [MetasploitDataModels::AutomaticExploitation::MatchResult]
|
29
|
+
has_many :match_results,
|
30
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchResult',
|
31
|
+
inverse_of: :match
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# @!attribute match_set
|
34
|
+
# The {MatchSet} this match is part of
|
35
|
+
#
|
36
|
+
# @return [MetasploitDataModels::AutomaticExploitation::MatchSet]
|
37
|
+
belongs_to :match_set,
|
38
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
|
39
|
+
inverse_of: :matches
|
35
40
|
|
36
41
|
Metasploit::Concern.run(self)
|
37
42
|
end
|
@@ -1,52 +1,28 @@
|
|
1
|
-
# The result of {#run running} a {#match}.
|
2
1
|
class MetasploitDataModels::AutomaticExploitation::MatchResult < ActiveRecord::Base
|
3
|
-
|
4
|
-
# CONSTANTS
|
5
|
-
#
|
2
|
+
attr_accessible :match_id, :run_id, :state
|
6
3
|
|
7
4
|
# Running associated exploit did NOT create a session
|
8
5
|
FAILED = "failed"
|
9
6
|
# Running associated exploit created a session
|
10
7
|
SUCCEEDED = "succeeded"
|
11
8
|
|
12
|
-
# Valid values for {#state}
|
13
9
|
VALID_STATES = [FAILED, SUCCEEDED]
|
14
10
|
|
15
11
|
#
|
16
|
-
#
|
12
|
+
# ASSOCIATIONS
|
17
13
|
#
|
18
14
|
|
19
|
-
# A {MetasploitDataModels::AutomaticExploitation::Match#module_detail Metasploit Module} matched to
|
20
|
-
# {MetasploitDataModels::AutomaticExploitation::Match#matchable Mdm::Host or Mdm::Service}.
|
21
15
|
belongs_to :match,
|
22
16
|
class_name: 'MetasploitDataModels::AutomaticExploitation::Match',
|
23
17
|
inverse_of: :match_results,
|
24
18
|
dependent: :destroy
|
25
19
|
|
26
|
-
# A mass automatic exploitation run.
|
27
20
|
belongs_to :run,
|
28
21
|
inverse_of: :match_results,
|
29
22
|
class_name: 'MetasploitDataModels::AutomaticExploitation::Run'
|
30
23
|
|
31
24
|
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
# @!attribute state
|
36
|
-
# Whether the {#run} of {#match} succeeded.
|
37
|
-
#
|
38
|
-
# @return ['failed', 'succeeded']
|
39
|
-
|
40
|
-
#
|
41
|
-
# Mass Assignment Security
|
42
|
-
#
|
43
|
-
|
44
|
-
attr_accessible :match_id
|
45
|
-
attr_accessible :run_id
|
46
|
-
attr_accessible :state
|
47
|
-
|
48
|
-
#
|
49
|
-
# Validations
|
25
|
+
# VALIDATIONS
|
50
26
|
#
|
51
27
|
|
52
28
|
# must be present and one of allowable values
|
@@ -55,14 +31,10 @@ class MetasploitDataModels::AutomaticExploitation::MatchResult < ActiveRecord::B
|
|
55
31
|
inclusion: VALID_STATES
|
56
32
|
|
57
33
|
#
|
58
|
-
#
|
34
|
+
# SCOPES
|
59
35
|
#
|
60
|
-
|
61
|
-
# Runs of {#match} that failed
|
62
|
-
scope :failed, lambda { where(state:"failed") }
|
63
|
-
|
64
|
-
# Runs of {#match} that succeeded
|
65
36
|
scope :succeeded, lambda { where(state:"succeeded") }
|
37
|
+
scope :failed, lambda { where(state:"failed") }
|
66
38
|
|
67
39
|
# Runs of {#match} by workspace ID
|
68
40
|
scope :by_workspace, lambda { |workspace_id|
|
@@ -1,41 +1,23 @@
|
|
1
|
-
# A set of {#matches automatic exploitation matches}.
|
2
1
|
class MetasploitDataModels::AutomaticExploitation::MatchSet < ActiveRecord::Base
|
3
|
-
|
4
|
-
# Associations
|
5
|
-
#
|
2
|
+
attr_accessible :user_id, :workspace_id, :minimum_rank
|
6
3
|
|
7
|
-
# Runs of this set of {#matches}.
|
8
4
|
has_many :runs,
|
9
5
|
class_name: "MetasploitDataModels::AutomaticExploitation::Run",
|
10
6
|
inverse_of: :match_set
|
11
7
|
|
12
|
-
# Matches in this set.
|
13
8
|
has_many :matches,
|
14
9
|
class_name: "MetasploitDataModels::AutomaticExploitation::Match",
|
15
10
|
inverse_of: :match_set,
|
16
11
|
dependent: :destroy
|
17
12
|
|
18
|
-
# User that created this match set.
|
19
|
-
belongs_to :user,
|
20
|
-
inverse_of: :automatic_exploitation_match_sets,
|
21
|
-
class_name: "Mdm::User"
|
22
|
-
|
23
|
-
# Workspace in which this match set exists.
|
24
13
|
belongs_to :workspace,
|
25
14
|
inverse_of: :automatic_exploitation_match_sets,
|
26
15
|
class_name: "Mdm::Workspace"
|
27
16
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
attr_accessible :minimum_rank
|
33
|
-
attr_accessible :user_id
|
34
|
-
attr_accessible :workspace_id
|
17
|
+
belongs_to :user,
|
18
|
+
inverse_of: :automatic_exploitation_match_sets,
|
19
|
+
class_name: "Mdm::User"
|
35
20
|
|
36
|
-
#
|
37
|
-
# Validations
|
38
|
-
#
|
39
21
|
|
40
22
|
validates :user,
|
41
23
|
presence: true
|
@@ -1,37 +1,27 @@
|
|
1
|
-
# Runs a {#match_set set of matches} to produce {#match_results results}.
|
2
1
|
class MetasploitDataModels::AutomaticExploitation::Run < ActiveRecord::Base
|
2
|
+
attr_accessible :user_id, :workspace_id, :match_set_id
|
3
|
+
|
3
4
|
#
|
4
|
-
#
|
5
|
+
# ASSOCIATIONS
|
5
6
|
#
|
6
|
-
|
7
|
-
# Results of each match in {#match_set}.
|
8
7
|
has_many :match_results,
|
9
8
|
class_name:'MetasploitDataModels::AutomaticExploitation::MatchResult',
|
10
9
|
inverse_of: :run,
|
11
10
|
dependent: :destroy
|
12
11
|
|
13
|
-
# Set of matches to run
|
14
12
|
belongs_to :match_set,
|
15
13
|
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
|
16
14
|
inverse_of: :runs
|
17
15
|
|
18
|
-
# User that initiated this run.
|
19
16
|
belongs_to :user,
|
20
17
|
class_name: "Mdm::User",
|
21
18
|
inverse_of: :automatic_exploitation_runs
|
22
19
|
|
23
|
-
# Workspace in which this run was performed.
|
24
20
|
belongs_to :workspace,
|
25
21
|
class_name: "Mdm::Workspace",
|
26
22
|
inverse_of: :automatic_exploitation_runs
|
27
23
|
|
28
|
-
#
|
29
|
-
# Mass Assignment Security
|
30
|
-
#
|
31
24
|
|
32
|
-
attr_accessible :match_set_id
|
33
|
-
attr_accessible :user_id
|
34
|
-
attr_accessible :workspace_id
|
35
25
|
|
36
26
|
Metasploit::Concern.run(self)
|
37
27
|
end
|
@@ -34,7 +34,7 @@ class MetasploitDataModels::ModuleRun < ActiveRecord::Base
|
|
34
34
|
# @return [String]
|
35
35
|
|
36
36
|
# @!attribute [rw] fail_reason
|
37
|
-
# One of the values of the constants in
|
37
|
+
# One of the values of the constants in {Msf::Module::Failure}
|
38
38
|
# @return [String]
|
39
39
|
|
40
40
|
# @!attribute [rw] module_name
|
@@ -32,7 +32,7 @@ class MetasploitDataModels::Search::Visitor::Where
|
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
|
-
visit
|
35
|
+
visit *EQUALITY_OPERATION_CLASS_NAMES do |operation|
|
36
36
|
attribute = attribute_visitor.visit operation.operator
|
37
37
|
|
38
38
|
attribute.eq(operation.value)
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require "ipaddr"
|
2
2
|
|
3
|
-
# Validates that attribute is a valid IPv4 or IPv6 address.
|
4
3
|
class IpFormatValidator < ActiveModel::EachValidator
|
5
|
-
# Validates that `attribute`'s `value` on `object` is a valid IPv4 or IPv6 address.
|
6
|
-
#
|
7
|
-
# @return [void]
|
8
4
|
def validate_each(object, attribute, value)
|
9
5
|
error_message_block = lambda{ object.errors[attribute] << " must be a valid IPv4 or IPv6 address" }
|
10
6
|
begin
|
@@ -1,21 +1,9 @@
|
|
1
1
|
# Validates that attribute's value is Array<Array(String, String)> which is the only valid type signature for serialized
|
2
2
|
# parameters.
|
3
3
|
class ParametersValidator < ActiveModel::EachValidator
|
4
|
-
#
|
5
|
-
# CONSTANTS
|
6
|
-
#
|
7
|
-
|
8
4
|
# Sentence explaining the valid type signature for parameters.
|
9
5
|
TYPE_SIGNATURE_SENTENCE = 'Valid parameters are an Array<Array(String, String)>.'
|
10
6
|
|
11
|
-
#
|
12
|
-
# Instance Methods
|
13
|
-
#
|
14
|
-
|
15
|
-
# Validates that `attribute`'s `value` on `record` is `Array<Array(String, String)>` which is the only valid type
|
16
|
-
# signature for serialized parameters.
|
17
|
-
#
|
18
|
-
# @return [void]
|
19
7
|
def validate_each(record, attribute, value)
|
20
8
|
if value.is_a? Array
|
21
9
|
value.each_with_index do |element, index|
|
@@ -1,21 +1,12 @@
|
|
1
|
-
# Validates that
|
2
1
|
class PasswordIsStrongValidator < ActiveModel::EachValidator
|
3
|
-
#
|
4
|
-
# CONSTANTS
|
5
|
-
#
|
6
|
-
|
7
|
-
# Known passwords that should NOT be allowed and should be considered weak.
|
8
2
|
COMMON_PASSWORDS = %w{
|
9
3
|
password pass root admin metasploit
|
10
4
|
msf 123456 qwerty abc123 letmein monkey link182 demo
|
11
5
|
changeme test1234 rapid7
|
12
6
|
}
|
13
7
|
|
14
|
-
# Special characters that are considered to strength passwords and are required once in a strong password.
|
15
8
|
SPECIAL_CHARS = %q{!@"#$%&'()*+,-./:;<=>?[\\]^_`{|}~ }
|
16
9
|
|
17
|
-
# Validates that the `attribute`'s `value` on `record` contains letters, numbers, and at least one special character
|
18
|
-
# without containing the `record.username`, any {COMMON_PASSWORDS} or repetition.
|
19
10
|
def validate_each(record, attribute, value)
|
20
11
|
return if value.blank?
|
21
12
|
|
@@ -43,7 +34,7 @@ class PasswordIsStrongValidator < ActiveModel::EachValidator
|
|
43
34
|
end
|
44
35
|
|
45
36
|
def contains_username?(username, password)
|
46
|
-
|
37
|
+
password =~ /#{username}/i
|
47
38
|
end
|
48
39
|
|
49
40
|
def is_common_password?(password)
|
@@ -185,6 +185,15 @@ module Mdm::Host::OperatingSystemNormalization
|
|
185
185
|
# Merge and normalize the best match to the host object
|
186
186
|
apply_match_to_host(match) if match
|
187
187
|
|
188
|
+
# Handle cases where the flavor contains the base name (legacy parsing, etc)
|
189
|
+
# TODO: Remove this once we are sure it is no longer needed
|
190
|
+
if host.os_name && host.os_flavor && host.os_flavor.index(host.os_name)
|
191
|
+
dlog("Host #{host.address} has os_flavor that contains os_name")
|
192
|
+
dlog("os_flavor: #{host.os_flavor}")
|
193
|
+
dlog("os_name: #{host.os_name}")
|
194
|
+
host.os_flavor = host.os_flavor.gsub(host.os_name, '').strip
|
195
|
+
end
|
196
|
+
|
188
197
|
# Set some sane defaults if needed
|
189
198
|
host.os_name ||= 'Unknown'
|
190
199
|
host.purpose ||= 'device'
|
@@ -192,10 +201,6 @@ module Mdm::Host::OperatingSystemNormalization
|
|
192
201
|
host.save if host.changed?
|
193
202
|
end
|
194
203
|
|
195
|
-
# Recog matches for the `s` service.
|
196
|
-
#
|
197
|
-
# @param s [Mdm::Service]
|
198
|
-
# @return [Array<Hash>] Keys will be host, service, and os attributes
|
199
204
|
def recog_matches_for_service(s)
|
200
205
|
#
|
201
206
|
# We assume that the service.info field contains certain types of probe
|
@@ -237,9 +242,6 @@ module Mdm::Host::OperatingSystemNormalization
|
|
237
242
|
matches
|
238
243
|
end
|
239
244
|
|
240
|
-
# Recog matches for the fingerprint in `note`.
|
241
|
-
#
|
242
|
-
# @return [Array<Hash>] Keys will be host, service, and os attributes
|
243
245
|
def recog_matches_for_note(note)
|
244
246
|
# Skip notes that are missing the correct structure or have been blacklisted
|
245
247
|
return [] if not validate_fingerprint_data(note)
|
@@ -300,6 +302,7 @@ module Mdm::Host::OperatingSystemNormalization
|
|
300
302
|
# name collision seems silly.
|
301
303
|
return false
|
302
304
|
else
|
305
|
+
dlog("Could not validate fingerprint data: #{fp.inspect}")
|
303
306
|
return false
|
304
307
|
end
|
305
308
|
end
|
@@ -25,7 +25,6 @@ require 'metasploit_data_models/version'
|
|
25
25
|
|
26
26
|
autoload :Mdm, 'mdm'
|
27
27
|
|
28
|
-
# Core database models for metasploit-framework.
|
29
28
|
module MetasploitDataModels
|
30
29
|
extend ActiveSupport::Autoload
|
31
30
|
|
@@ -38,9 +37,6 @@ module MetasploitDataModels
|
|
38
37
|
autoload :Search
|
39
38
|
autoload :SerializedPrefs
|
40
39
|
|
41
|
-
# The root directory of `metasploit_data_models` gem in both development and gem installs.
|
42
|
-
#
|
43
|
-
# @return [Pathname]
|
44
40
|
def self.root
|
45
41
|
unless instance_variable_defined? :@root
|
46
42
|
lib_pathname = Pathname.new(__FILE__).dirname
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'rails'
|
2
2
|
|
3
|
-
# `Rails::Engine` that exposes MetasploitDataModel's `ActiveRecord::Base` subclasses and automatically loads its
|
4
|
-
# `FactoryGirl` factories, sequences, and traits.
|
5
3
|
class MetasploitDataModels::Engine < Rails::Engine
|
6
4
|
# @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
|
7
5
|
config.generators do |g|
|
@@ -1,10 +1,4 @@
|
|
1
|
-
# Allows attributes to be extracted and written to key of serialized `Hash` `prefs`.
|
2
1
|
module MetasploitDataModels::SerializedPrefs
|
3
|
-
# Setup each arg in `args` as the name of an attribute embedded in the `prefs` `Hash`. Defines `#<arg>` and
|
4
|
-
# `#<arg>=(value)` methods like standard `attr_accessor`.
|
5
|
-
#
|
6
|
-
# @param args [Array<Symbol>] The names of the attributes to store in the `prefs` `Hash`.
|
7
|
-
# @return [void]
|
8
2
|
def serialized_prefs_attr_accessor(*args)
|
9
3
|
args.each do |method_name|
|
10
4
|
|
@@ -1,29 +1,18 @@
|
|
1
1
|
module MetasploitDataModels
|
2
2
|
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
3
3
|
module Version
|
4
|
-
#
|
5
|
-
# CONSTANTS
|
6
|
-
#
|
7
|
-
|
8
4
|
# The major version number.
|
9
5
|
MAJOR = 0
|
10
6
|
# The minor version number, scoped to the {MAJOR} version number.
|
11
7
|
MINOR = 24
|
12
|
-
# The patch
|
13
|
-
PATCH =
|
14
|
-
|
15
|
-
#
|
16
|
-
# Module Methods
|
17
|
-
#
|
8
|
+
# The patch number, scoped to the {MAJOR} and {MINOR} version numbers.
|
9
|
+
PATCH = 5
|
18
10
|
|
19
|
-
# The full version string, including the {
|
20
|
-
# {MetasploitDataModels::Version::MINOR}, {MetasploitDataModels::Version::PATCH}, and optionally, the
|
21
|
-
# `MetasploitDataModels::Version::PRERELEASE` in the
|
11
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
|
22
12
|
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
23
13
|
#
|
24
|
-
# @return [String] '{
|
25
|
-
#
|
26
|
-
# on any branch other than master.
|
14
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-PRERELEASE' on any branch
|
15
|
+
# other than master.
|
27
16
|
def self.full
|
28
17
|
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
29
18
|
|
@@ -34,22 +23,19 @@ module MetasploitDataModels
|
|
34
23
|
version
|
35
24
|
end
|
36
25
|
|
37
|
-
# The full gem version string, including the {
|
38
|
-
# {MetasploitDataModels::Version::MINOR}, {MetasploitDataModels::Version::PATCH}, and optionally, the
|
39
|
-
# `MetasploitDataModels::Version::PRERELEASE` in the
|
26
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
40
27
|
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
41
28
|
#
|
42
|
-
# @return [String] '{
|
43
|
-
#
|
44
|
-
# on any branch other than master.
|
29
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
30
|
+
# other than master.
|
45
31
|
def self.gem
|
46
32
|
full.gsub('-', '.pre.')
|
47
33
|
end
|
48
34
|
end
|
49
35
|
|
50
|
-
#
|
36
|
+
# @see Version.gem
|
51
37
|
GEM_VERSION = Version.gem
|
52
38
|
|
53
|
-
#
|
39
|
+
# @see Version.full
|
54
40
|
VERSION = Version.full
|
55
41
|
end
|