metasploit-credential 6.0.20 → 6.0.21

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: 8812bdc403724cf3a31080fa3de9e8c2ff95a1d8b792c29c047d1ba693c40286
4
+ data.tar.gz: 203337f164044196d492582a5d99b498d31a5afc0b17b6eb72fa5c55c48b3e52
5
5
  SHA512:
6
- metadata.gz: 11b80697bd98c100da4d8208db64d4a111afa01bfd33f9c68e821caf5232317aa44828073648ac1a03f806afc07759f36be594306a13a6552687bbbb13696754
7
- data.tar.gz: ce6337b1cdcdef9cab14d9f37b15fee1d7515cc503b57ad2d39febd02ad1177c54d997ee8bbd967a3a33a7382ff0df87030e357aaa499a98bbbbd3c02770027d
6
+ metadata.gz: a47718c56eef2fbfff45374bd73cb1f83026476c9a6aa77178aedfa05ee3cfe0c78d05e39cbc619d6f25bf33d845f07b39d4ce15f6e60c56268f26a48c9a8c3c
7
+ data.tar.gz: c7c22d92745f28b54226f47f11c91dcfdb2a893698228b3e96620cf324d514e2a38d26ddbba620148ecb6135511a55f252ca3ee06f124bd7ff5e1b2a3ad25671
@@ -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.21'
7
7
 
8
8
  # @return [String]
9
9
  #
@@ -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.21
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-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metasploit-concern