metasploit-credential 6.0.20 → 6.0.22

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: 29eb2adae3e354efa557b14938b7e85b7eeb44ea3bd98fdb69bbc7b8bc6efdf3
4
- data.tar.gz: 425f101cb90ce6620e61bbed4e786f7e750e1d823ede8e2c0ab55362f836f162
3
+ metadata.gz: b54980fe704b7045ccd25fcef674e10d8c7774ad9a8662e15d229821a4d5ce0a
4
+ data.tar.gz: d7fc83e6ff13464f8a3bab067136e4196b2ee3da8b0a49cd27989aa2a4924202
5
5
  SHA512:
6
- metadata.gz: 11b80697bd98c100da4d8208db64d4a111afa01bfd33f9c68e821caf5232317aa44828073648ac1a03f806afc07759f36be594306a13a6552687bbbb13696754
7
- data.tar.gz: ce6337b1cdcdef9cab14d9f37b15fee1d7515cc503b57ad2d39febd02ad1177c54d997ee8bbd967a3a33a7382ff0df87030e357aaa499a98bbbbd3c02770027d
6
+ metadata.gz: f2dcea6416ced734289968238e4da7d3184f2b8b672a3ee7106bfca3b0c9440fbb2ef605c34b28389d36e6a1adfea91ddff5e032a88b646c1e4ff659632109f8
7
+ data.tar.gz: 67a8e8061eab4ba68e1f47e4bd393c94d78fb53289e307dd75b0e9f2845d14099a5b1ba3f7a29f3714c3054cfb490551b2cc1f192b7a61c8698dc6e841299d4b
@@ -73,7 +73,7 @@ class Metasploit::Credential::KrbEncKey < Metasploit::Credential::PasswordHash
73
73
  # Callbacks
74
74
  #
75
75
 
76
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
76
+ if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1)
77
77
  serialize :data, coder: Metasploit::Credential::CaseInsensitiveSerializer
78
78
  else
79
79
  serialize :data, Metasploit::Credential::CaseInsensitiveSerializer
@@ -43,7 +43,7 @@ class Metasploit::Credential::NTLMHash < Metasploit::Credential::ReplayableHash
43
43
 
44
44
  # Hash results are always downcased when stored in the database
45
45
  # This serializer allows for ORM to search in a case-insensitive
46
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
46
+ if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1)
47
47
  serialize :data, coder: Metasploit::Credential::CaseInsensitiveSerializer
48
48
  else
49
49
  serialize :data, Metasploit::Credential::CaseInsensitiveSerializer
@@ -13,7 +13,7 @@ class Metasploit::Credential::PostgresMD5 < Metasploit::Credential::ReplayableHa
13
13
  # Callbacks
14
14
  #
15
15
 
16
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
16
+ if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1)
17
17
  serialize :data, coder: Metasploit::Credential::CaseInsensitiveSerializer
18
18
  else
19
19
  serialize :data, Metasploit::Credential::CaseInsensitiveSerializer
@@ -413,6 +413,8 @@ module Metasploit::Credential::Creation
413
413
  # If there is not a matching `Mdm::Host` it will create it. If there is not a matching
414
414
  # `Mdm::Service` it will create that too.
415
415
  #
416
+ # @option opts [Mdm::Service] :service The service to use instead of creating one
417
+ # @option opts [Fixnum] :service_id The ID of the `Mdm::Service` to link this Origin to
416
418
  # @option opts [String] :address The address of the `Mdm::Host` to link this Origin to
417
419
  # @option opts [Fixnum] :port The port number of the `Mdm::Service` to link this Origin to
418
420
  # @option opts [String] :service_name The service name to use for the `Mdm::Service`
@@ -423,8 +425,13 @@ module Metasploit::Credential::Creation
423
425
  # @return [Metasploit::Credential::Origin::Service] The created {Metasploit::Credential::Origin::Service} object
424
426
  def create_credential_origin_service(opts={})
425
427
  return nil unless active_db?
428
+
426
429
  module_fullname = opts.fetch(:module_fullname)
427
- service_object = create_credential_service(opts)
430
+ if (service_id = opts[:service_id] || opts[:service].try(:id))
431
+ service_object = Mdm::Service.where(id: service_id).first
432
+ else
433
+ service_object = create_credential_service(opts)
434
+ end
428
435
  return nil if service_object.nil?
429
436
 
430
437
  retry_transaction do
@@ -3,7 +3,7 @@
3
3
  module Metasploit
4
4
  module Credential
5
5
  # VERSION is managed by GemRelease
6
- VERSION = '6.0.20'
6
+ VERSION = '6.0.22'
7
7
 
8
8
  # @return [String]
9
9
  #
@@ -55,8 +55,6 @@ module Dummy
55
55
  # like if you have constraints or database-specific column types
56
56
  config.active_record.schema_format = :sql
57
57
 
58
- config.autoloader = :zeitwerk
59
-
60
58
  if ActiveRecord.respond_to?(:legacy_connection_handling)
61
59
  ActiveRecord.legacy_connection_handling = false
62
60
  end
@@ -1,7 +1,11 @@
1
+ \restrict mBrhviFaGapJnTy1Ng5G4Nmfldi6cVCqDsnBZBhvNpaMCYyEUttPQyvzrS3RhNF
2
+
3
+ -- Dumped from database version 14.22 (Homebrew)
4
+ -- Dumped by pg_dump version 14.22 (Homebrew)
5
+
1
6
  SET statement_timeout = 0;
2
7
  SET lock_timeout = 0;
3
8
  SET idle_in_transaction_session_timeout = 0;
4
- SET transaction_timeout = 0;
5
9
  SET client_encoding = 'UTF8';
6
10
  SET standard_conforming_strings = on;
7
11
  SELECT pg_catalog.set_config('search_path', '', false);
@@ -4004,6 +4008,8 @@ CREATE UNIQUE INDEX unique_realmless_metasploit_credential_cores ON public.metas
4004
4008
  -- PostgreSQL database dump complete
4005
4009
  --
4006
4010
 
4011
+ \unrestrict mBrhviFaGapJnTy1Ng5G4Nmfldi6cVCqDsnBZBhvNpaMCYyEUttPQyvzrS3RhNF
4012
+
4007
4013
  SET search_path TO "$user", public;
4008
4014
 
4009
4015
  INSERT INTO "schema_migrations" (version) VALUES
@@ -0,0 +1 @@
1
+ 6a51993ec952777b354be51d945c684ff857fc3d3998977cce58c852e7e84603f6999bdbe3471130e137c437a38e775c2eef37156a46f59bd7a46eb38b642b9a
@@ -652,6 +652,49 @@ RSpec.describe Metasploit::Credential::Creation do
652
652
  expect{ test_object.create_credential_origin_service(opts)}.to raise_error KeyError
653
653
  end
654
654
  end
655
+
656
+ context 'when :service is provided' do
657
+ it 'uses the given service object and does not create a new Mdm::Service' do
658
+ host = FactoryBot.create(:mdm_host, workspace: workspace)
659
+ existing_service = FactoryBot.create(:mdm_service, host: host)
660
+ opts = {
661
+ service: existing_service,
662
+ module_fullname: 'auxiliary/scanner/smb/smb_login',
663
+ origin_type: :service
664
+ }
665
+ expect { test_object.create_credential_origin_service(opts) }.to_not change { Mdm::Service.count }
666
+ origin = test_object.create_credential_origin_service(opts)
667
+ expect(origin.service_id).to eq(existing_service.id)
668
+ end
669
+ end
670
+
671
+ context 'when :service_id is provided' do
672
+ context 'and the ID corresponds to an existing Mdm::Service' do
673
+ it 'uses that service and does not create a new Mdm::Service' do
674
+ host = FactoryBot.create(:mdm_host, workspace: workspace)
675
+ existing_service = FactoryBot.create(:mdm_service, host: host)
676
+ opts = {
677
+ service_id: existing_service.id,
678
+ module_fullname: 'auxiliary/scanner/smb/smb_login',
679
+ origin_type: :service
680
+ }
681
+ expect { test_object.create_credential_origin_service(opts) }.to_not change { Mdm::Service.count }
682
+ origin = test_object.create_credential_origin_service(opts)
683
+ expect(origin.service_id).to eq(existing_service.id)
684
+ end
685
+ end
686
+
687
+ context 'and the ID does not correspond to an existing Mdm::Service' do
688
+ it 'returns nil' do
689
+ opts = {
690
+ service_id: 0,
691
+ module_fullname: 'auxiliary/scanner/smb/smb_login',
692
+ origin_type: :service
693
+ }
694
+ expect(test_object.create_credential_origin_service(opts)).to be_nil
695
+ end
696
+ end
697
+ end
655
698
  end
656
699
 
657
700
  context '#create_credential_origin_session' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit-credential
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.20
4
+ version: 6.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-09 00:00:00.000000000 Z
11
+ date: 2026-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metasploit-concern
@@ -325,6 +325,7 @@ files:
325
325
  - spec/dummy/public/500.html
326
326
  - spec/dummy/public/favicon.ico
327
327
  - spec/dummy/script/rails
328
+ - spec/dummy/tmp/local_secret.txt
328
329
  - spec/factories/metasploit/credential/blank_usernames.rb
329
330
  - spec/factories/metasploit/credential/cores.rb
330
331
  - spec/factories/metasploit/credential/importer/cores.rb
@@ -457,6 +458,7 @@ test_files:
457
458
  - spec/dummy/public/500.html
458
459
  - spec/dummy/public/favicon.ico
459
460
  - spec/dummy/script/rails
461
+ - spec/dummy/tmp/local_secret.txt
460
462
  - spec/factories/metasploit/credential/blank_usernames.rb
461
463
  - spec/factories/metasploit/credential/cores.rb
462
464
  - spec/factories/metasploit/credential/importer/cores.rb