metasploit_data_models 4.0.1 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b39228ee81c302b3a79adb5b6b7fd283609315ba4e6ba3ce54fc118975d6169
4
- data.tar.gz: 43d50e8c9c3dd6adcb4944539f45c7cae200b2d6341b4ab37ebbe1aff19583f6
3
+ metadata.gz: 7555384d31f970a18a9bbb5690a7222a786cdb966756007c3a1cfdc5075d4d36
4
+ data.tar.gz: deb67f833fd87103497c280059aee0636a247086e80d2b242709b78635943d76
5
5
  SHA512:
6
- metadata.gz: 91e81439cde4eecd56be639a8349554ec16b950f3affd58a13024ec39a55756c49f8e36683f2fea36409cb8bf27eedd44f45b67d9788c2b7dde3455292c53435
7
- data.tar.gz: 9b6e4a077c247d81d1fa24d63e4beb212a91b711ee762e52241b673b77045b08cf0b5e77249df08e73f33ca405e9e3838809ffde2734c53f6bac6a33d0f55887
6
+ metadata.gz: 1b35cf1660e18548a48ce3692a7536077544359a4cfb9d154c89b0a211f7ae2727ffa06501399eebfb1963531ce6a2f849ad1493918a893c0af454cce6b7598c
7
+ data.tar.gz: f43f98fce153d3774967efe636f7e53fd743f550ab37ee3856bb8f36e269c188ccd44823ae724e4f31c412833cba92809a9adc122106b1f94612ba0c0c318bc9
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,75 @@
1
+ name: Verify
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-16.04
14
+ timeout-minutes: 40
15
+
16
+ services:
17
+ postgres:
18
+ image: postgres:9.6
19
+ ports: ["5432:5432"]
20
+ env:
21
+ POSTGRES_USER: postgres
22
+ POSTGRES_PASSWORD: postgres
23
+ options: >-
24
+ --health-cmd pg_isready
25
+ --health-interval 10s
26
+ --health-timeout 5s
27
+ --health-retries 5
28
+
29
+ strategy:
30
+ fail-fast: true
31
+ matrix:
32
+ ruby:
33
+ - 2.7
34
+
35
+ env:
36
+ RAILS_ENV: test
37
+
38
+ name: Ruby ${{ matrix.ruby }}
39
+ steps:
40
+ - name: Install system dependencies
41
+ run: sudo apt-get install libpcap-dev graphviz
42
+
43
+ - name: Checkout code
44
+ uses: actions/checkout@v2
45
+
46
+ - uses: actions/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+
50
+ - name: Setup bundler
51
+ run: |
52
+ gem install bundler
53
+
54
+ - uses: actions/cache@v2
55
+ with:
56
+ path: vendor/bundle
57
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
58
+ restore-keys: |
59
+ ${{ runner.os }}-gems-
60
+
61
+ - name: Bundle install
62
+ run: |
63
+ bundle config path vendor/bundle
64
+ bundle install --jobs 4 --retry 3
65
+
66
+ - name: Test
67
+ run: |
68
+ cp spec/dummy/config/database.yml.github_actions spec/dummy/config/database.yml
69
+ bundle exec rake --version
70
+ bundle exec rake db:create db:migrate
71
+
72
+ # Disabling this check because it is proving unreliable
73
+ # git diff --exit-code spec/dummy/db/structure.sql
74
+ bundle exec rake spec
75
+ bundle exec rake yard
@@ -1,6 +1,5 @@
1
1
  # A connection to Nexpose from Metasploit.
2
2
  class Mdm::NexposeConsole < ApplicationRecord
3
-
4
3
  #
5
4
  # Associations
6
5
  #
@@ -80,7 +79,7 @@ class Mdm::NexposeConsole < ApplicationRecord
80
79
  # Callbacks
81
80
  #
82
81
 
83
- before_save :strip_protocol
82
+ before_validation :strip_protocol
84
83
 
85
84
  #
86
85
  # Serializations
@@ -96,10 +95,14 @@ class Mdm::NexposeConsole < ApplicationRecord
96
95
  # Validations
97
96
  #
98
97
 
99
- validates :address, :presence => true
98
+ validates :address, :presence => true, :address_format => true
99
+
100
100
  validates :name, :presence => true
101
+
101
102
  validates :password, :presence => true
103
+
102
104
  validates :port, :numericality => { :only_integer => true }, :inclusion => {:in => 1..65535}
105
+
103
106
  validates :username, :presence => true
104
107
 
105
108
  #
@@ -110,7 +113,7 @@ class Mdm::NexposeConsole < ApplicationRecord
110
113
  #
111
114
  # @return [void]
112
115
  def strip_protocol
113
- self.address.gsub!(/^http(s)*:\/\//i,'')
116
+ self.address.gsub!(/^http(s)*:\/\//i,'') unless self.address.nil?
114
117
  end
115
118
 
116
119
  Metasploit::Concern.run(self)
@@ -113,7 +113,7 @@ class Mdm::Note < ApplicationRecord
113
113
  #
114
114
  # @return [void]
115
115
  def normalize
116
- if data_changed? and ntype =~ /fingerprint/ && host.workspace.present? && !host.workspace.import_fingerprint
116
+ if saved_change_to_data? and ntype =~ /fingerprint/ && host.workspace.present? && !host.workspace.import_fingerprint
117
117
  host.normalize_os
118
118
  end
119
119
  end
@@ -21,11 +21,6 @@ class Mdm::Workspace < ApplicationRecord
21
21
  class_name: 'MetasploitDataModels::AutomaticExploitation:MatchSet',
22
22
  inverse_of: :workspace
23
23
 
24
- # @deprecated Use `Mdm::Workspace#core_credentials` defined by `Metasploit::Credential::Engine` to get
25
- # `Metasploit::Credential::Core`s gathered from this workspace's {#hosts} and {#services}.
26
- #
27
- # Creds gathered from this workspace's {#hosts} and {#services}.
28
- has_many :creds, :through => :services, :class_name => 'Mdm::Cred'
29
24
 
30
25
  # Events that occurred in this workspace.
31
26
  has_many :events, dependent: :delete_all, :class_name => 'Mdm::Event'
@@ -80,6 +75,12 @@ class Mdm::Workspace < ApplicationRecord
80
75
 
81
76
  # Sessions opened on {#hosts} in this workspace.
82
77
  has_many :sessions, :through => :hosts, :class_name => 'Mdm::Session'
78
+
79
+ # @deprecated Use `Mdm::Workspace#core_credentials` defined by `Metasploit::Credential::Engine` to get
80
+ # `Metasploit::Credential::Core`s gathered from this workspace's {#hosts} and {#services}.
81
+ #
82
+ # Creds gathered from this workspace's {#hosts} and {#services}.
83
+ has_many :creds, :through => :services, :class_name => 'Mdm::Cred'
83
84
 
84
85
  #
85
86
  # Attributes
@@ -91,7 +91,7 @@ class MetasploitDataModels::Search::Visitor::Where
91
91
  visit 'MetasploitDataModels::Search::Operation::Port::Range' do |range_operation|
92
92
  attribute = attribute_visitor.visit range_operation.operator
93
93
 
94
- attribute.in(range_operation.value)
94
+ attribute.between(range_operation.value)
95
95
  end
96
96
 
97
97
  #
@@ -8,7 +8,6 @@ class CreateAsyncCallbacks < ActiveRecord::Migration[4.2]
8
8
  t.string :target_port
9
9
 
10
10
  t.timestamps null: false
11
- t.uuid null: false
12
11
  end
13
12
  end
14
13
  end
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '4.0.1'
3
+ VERSION = '4.1.3'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -5,27 +5,19 @@ require 'metasploit_data_models/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'metasploit_data_models'
7
7
  s.version = MetasploitDataModels::VERSION
8
- s.authors = [
9
- 'Samuel Huckins',
10
- 'Luke Imhoff',
11
- "David 'thelightcosine' Maloney",
12
- "Trevor 'burlyscudd' Rosen"
13
- ]
14
- s.email = [
15
- 'shuckins@rapid7.com',
16
- 'luke_imhoff@rapid7.com',
17
- 'dmaloney@rapid7.com',
18
- 'trevor_rosen@rapid7.com'
19
- ]
8
+ s.authors = ['Metasploit Hackers']
9
+ s.email = ['msfdev@metasploit.com']
20
10
  s.homepage = ""
21
11
  s.summary = %q{Database code for MSF and Metasploit Pro}
22
12
  s.description = %q{Implements minimal ActiveRecord models and database helper code used in both the Metasploit Framework (MSF) and Metasploit commercial editions.}
23
13
 
24
- s.files = `git ls-files`.split("\n")
14
+ s.files = `git ls-files`.split("\n").reject { |file|
15
+ file =~ /^bin/
16
+ }
25
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
18
  s.require_paths = %w{app/models app/validators lib}
27
19
 
28
- s.required_ruby_version = '>= 2.1'
20
+ s.required_ruby_version = '>= 2.4'
29
21
 
30
22
  # ---- Dependencies ----
31
23
  # documentation
@@ -36,9 +28,7 @@ Gem::Specification.new do |s|
36
28
 
37
29
  s.add_development_dependency 'rake'
38
30
 
39
- # documentation
40
- # @note 0.8.7.4 has a bug where attribute writers show up as undocumented
41
- s.add_development_dependency 'yard', '< 0.8.7.4'
31
+ s.add_development_dependency 'yard'
42
32
  # debugging
43
33
  s.add_development_dependency 'pry'
44
34
 
@@ -46,8 +36,9 @@ Gem::Specification.new do |s|
46
36
  s.add_runtime_dependency 'activerecord', '~>5.2.2'
47
37
  s.add_runtime_dependency 'activesupport', '~>5.2.2'
48
38
  s.add_runtime_dependency 'metasploit-concern'
49
- s.add_runtime_dependency 'metasploit-model'
39
+ s.add_runtime_dependency 'metasploit-model', '>=3.1'
50
40
  s.add_runtime_dependency 'railties', '~>5.2.2'
41
+ s.add_runtime_dependency 'webrick'
51
42
 
52
43
  # os fingerprinting
53
44
  s.add_runtime_dependency 'recog', '~> 2.0'
@@ -471,33 +471,33 @@ RSpec.describe Mdm::Host, type: :model do
471
471
 
472
472
  context 'os normalization' do
473
473
  context '#get_arch_from_string' do
474
- context "should return 'x64'" do
474
+ context "should return 'x86_64'" do
475
475
  it "when the string contains 'x64'" do
476
- expect(host.send(:get_arch_from_string, 'blahx64blah')).to eq('x64')
476
+ expect(host.send(:get_arch_from_string, 'blahx64blah')).to eq('x86_64')
477
477
  end
478
478
 
479
479
  it "when the string contains 'X64'" do
480
- expect(host.send(:get_arch_from_string, 'blahX64blah')).to eq('x64')
480
+ expect(host.send(:get_arch_from_string, 'blahX64blah')).to eq('x86_64')
481
481
  end
482
482
 
483
483
  it "when the string contains 'x86_64'" do
484
- expect(host.send(:get_arch_from_string, 'blahx86_64blah')).to eq('x64')
484
+ expect(host.send(:get_arch_from_string, 'blahx86_64blah')).to eq('x86_64')
485
485
  end
486
486
 
487
487
  it "when the string contains 'X86_64'" do
488
- expect(host.send(:get_arch_from_string, 'blahX86_64blah')).to eq('x64')
488
+ expect(host.send(:get_arch_from_string, 'blahX86_64blah')).to eq('x86_64')
489
489
  end
490
490
 
491
491
  it "when the string contains 'amd64'" do
492
- expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
492
+ expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x86_64')
493
493
  end
494
494
 
495
495
  it "when the string contains 'AMD64'" do
496
- expect(host.send(:get_arch_from_string, 'blahAMD64blah')).to eq('x64')
496
+ expect(host.send(:get_arch_from_string, 'blahAMD64blah')).to eq('x86_64')
497
497
  end
498
498
 
499
499
  it "when the string contains 'aMd64'" do
500
- expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
500
+ expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x86_64')
501
501
  end
502
502
  end
503
503
 
@@ -531,21 +531,21 @@ RSpec.describe Mdm::Host, type: :model do
531
531
  end
532
532
  end
533
533
 
534
- context "should return 'ppc'" do
534
+ context "should return 'PowerPC'" do
535
535
  it "when the string contains 'PowerPC'" do
536
- expect(host.send(:get_arch_from_string, 'blahPowerPCblah')).to eq('ppc')
536
+ expect(host.send(:get_arch_from_string, 'blahPowerPCblah')).to eq('PowerPC')
537
537
  end
538
538
 
539
539
  it "when the string contains 'PPC'" do
540
- expect(host.send(:get_arch_from_string, 'blahPPCblah')).to eq('ppc')
540
+ expect(host.send(:get_arch_from_string, 'blahPPCblah')).to eq('PowerPC')
541
541
  end
542
542
 
543
543
  it "when the string contains 'POWER'" do
544
- expect(host.send(:get_arch_from_string, 'blahPOWERblah')).to eq('ppc')
544
+ expect(host.send(:get_arch_from_string, 'blahPOWERblah')).to eq('PowerPC')
545
545
  end
546
546
 
547
547
  it "when the string contains 'ppc'" do
548
- expect(host.send(:get_arch_from_string, 'blahppcblah')).to eq('ppc')
548
+ expect(host.send(:get_arch_from_string, 'blahppcblah')).to eq('PowerPC')
549
549
  end
550
550
  end
551
551
 
@@ -560,22 +560,22 @@ RSpec.describe Mdm::Host, type: :model do
560
560
  end
561
561
  end
562
562
 
563
- it "should return 'sparc' if the string contains SPARC, regardless of case" do
564
- expect(host.send(:get_arch_from_string, 'blahSPARCblah')).to eq('sparc')
565
- expect(host.send(:get_arch_from_string, 'blahSPaRCblah')).to eq('sparc')
566
- expect(host.send(:get_arch_from_string, 'blahsparcblah')).to eq('sparc')
563
+ it "should return 'Sparc' if the string contains SPARC, regardless of case" do
564
+ expect(host.send(:get_arch_from_string, 'blahSPARCblah')).to eq('Sparc')
565
+ expect(host.send(:get_arch_from_string, 'blahSPaRCblah')).to eq('Sparc')
566
+ expect(host.send(:get_arch_from_string, 'blahsparcblah')).to eq('Sparc')
567
567
  end
568
568
 
569
- it "should return 'arm' if the string contains 'ARM', regardless of case" do
570
- expect(host.send(:get_arch_from_string, 'blahARMblah')).to eq('arm')
571
- expect(host.send(:get_arch_from_string, 'blahArMblah')).to eq('arm')
572
- expect(host.send(:get_arch_from_string, 'blaharmblah')).to eq('arm')
569
+ it "should return 'ARM' if the string contains 'ARM', regardless of case" do
570
+ expect(host.send(:get_arch_from_string, 'blahARMblah')).to eq('ARM')
571
+ expect(host.send(:get_arch_from_string, 'blahArMblah')).to eq('ARM')
572
+ expect(host.send(:get_arch_from_string, 'blaharmblah')).to eq('ARM')
573
573
  end
574
574
 
575
- it "should return 'mips' if the string contains 'MIPS', regardless of case" do
576
- expect(host.send(:get_arch_from_string, 'blahMIPSblah')).to eq('mips')
577
- expect(host.send(:get_arch_from_string, 'blahMiPslah')).to eq('mips')
578
- expect(host.send(:get_arch_from_string, 'blahmipsblah')).to eq('mips')
575
+ it "should return 'MIPS' if the string contains 'MIPS', regardless of case" do
576
+ expect(host.send(:get_arch_from_string, 'blahMIPSblah')).to eq('MIPS')
577
+ expect(host.send(:get_arch_from_string, 'blahMiPslah')).to eq('MIPS')
578
+ expect(host.send(:get_arch_from_string, 'blahmipsblah')).to eq('MIPS')
579
579
  end
580
580
  end
581
581
 
@@ -588,7 +588,7 @@ RSpec.describe Mdm::Host, type: :model do
588
588
  context 'arch' do
589
589
  it 'should return a value for arch if there is one' do
590
590
  result = host.send(:parse_windows_os_str, 'Windows x64')
591
- expect(result['os.arch']).to eq('x64')
591
+ expect(result['os.arch']).to eq('x86_64')
592
592
  end
593
593
 
594
594
  it "should not have an arch key if we don't know the arch" do
@@ -1093,7 +1093,7 @@ RSpec.describe Mdm::Host, type: :model do
1093
1093
  fingerprint = FactoryBot.build(:mdm_retina_fingerprint, :host => host)
1094
1094
  result = host.send(:normalize_scanner_fp, fingerprint).first
1095
1095
  expect(result['os.product']).to eq( 'Windows Server 2003')
1096
- expect(result['os.arch']).to eq('x64')
1096
+ expect(result['os.arch']).to eq('x86_64')
1097
1097
  expect(result['os.version']).to eq('SP2')
1098
1098
  expect(result['os.certainty'].to_f).to eq(0.8)
1099
1099
  end
@@ -32,7 +32,7 @@ RSpec.describe Mdm::NexposeConsole, type: :model do
32
32
 
33
33
  context '#destroy' do
34
34
  it 'should successfully destroy the object' do
35
- nexpose_console = FactoryBot.create(:mdm_nexpose_console)
35
+ nexpose_console = FactoryBot.create(:mdm_nexpose_console, :address => 'localhost')
36
36
  expect {
37
37
  nexpose_console.destroy
38
38
  }.to_not raise_error
@@ -50,6 +50,20 @@ RSpec.describe Mdm::NexposeConsole, type: :model do
50
50
  expect(addressless_nexpose_console.errors[:address]).to include("can't be blank")
51
51
  end
52
52
 
53
+ it 'should be valid for a valid hostname' do
54
+ host_nexpose_console = FactoryBot.build(:mdm_nexpose_console, :address => 'testvalue.test.com')
55
+ expect(host_nexpose_console).to be_valid
56
+ end
57
+
58
+ it 'should be invalid for a malformed hostname' do
59
+ host_nexpose_consoles = ['testvalue.test.com:', 'testvalue-.test.com', '[testvalue.test.com]']
60
+ host_nexpose_consoles.each do | entry |
61
+ host_nexpose_console = FactoryBot.build(:mdm_nexpose_console, :address => entry)
62
+ expect(host_nexpose_console).not_to be_valid
63
+ expect(host_nexpose_console.errors[:address]).to include("must be a valid (IP or hostname) address")
64
+ end
65
+ end
66
+
53
67
  it 'should be valid for IPv4 format' do
54
68
  ipv4_nexpose_console = FactoryBot.build(:mdm_nexpose_console, :address => '192.168.1.120')
55
69
  expect(ipv4_nexpose_console).to be_valid
@@ -233,7 +233,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
233
233
  end
234
234
 
235
235
  context '#to_s' do
236
- subject(:to_s) {
236
+ subject(:call_to_s) {
237
237
  single.to_s
238
238
  }
239
239
 
@@ -256,7 +256,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
256
256
  it 'delegates to #value' do
257
257
  expect(value).to receive(:to_s)
258
258
 
259
- to_s
259
+ call_to_s
260
260
  end
261
261
  end
262
262
 
@@ -321,4 +321,4 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
321
321
  end
322
322
  end
323
323
  end
324
- end
324
+ end
@@ -129,7 +129,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Where, type: :model do
129
129
  attribute = double('Visited Operator')
130
130
  allow(visitor.attribute_visitor).to receive(:visit).with(operator).and_return(attribute)
131
131
 
132
- expect(attribute).to receive(:in).with(range)
132
+ expect(attribute).to receive(:between).with(range)
133
133
 
134
134
  visit
135
135
  end
@@ -1,18 +1,17 @@
1
- # @note This file is only for use in travis-ci. If you need to make a `spec/dummy/config/database.yml` for running
1
+ # @note This file is only for use in Github Actions. If you need to make a `spec/dummy/config/database.yml` for running
2
2
  # rake, rake spec, or rspec locally, please customize `spec/dummy/config/database.yml.example`.
3
3
  #
4
4
  # @example Customizing config/database.yml.example
5
5
  # cp spec/dummy/config/database.yml.example spec/dummy/config/database.yml
6
6
  # # update password fields for each environment's user
7
7
 
8
- # Using the postgres user locally without a host and port is the supported configuration from Travis-CI
9
- #
10
- # @see http://about.travis-ci.org/docs/user/database-setup/#PostgreSQL
11
8
  development: &pgsql
12
9
  adapter: postgresql
13
10
  database: metasploit_data_models_development
11
+ host: localhost
14
12
  username: postgres
15
- pool: 5
13
+ password: postgres
14
+ pool: 25
16
15
  timeout: 5
17
16
 
18
17
  # Warning: The database defined as "test" will be erased and re-generated from your development database when you run