Skip to content

Commit ad6eed0

Browse files
committed
.to_credential now assigns a parent
Metasploit::Credential::Core#to_credential will set the parent to the original core objext Metasploit::Framework::Credential#to_credential also sets the parent to itself.
1 parent 6a72572 commit ad6eed0

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

app/concerns/metasploit/credential/core/to_credential.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def to_credential
1313
private: private.try(:data),
1414
private_type: private.try(:type).try(:demodulize).try(:underscore).try(:to_sym),
1515
realm: realm.try(:value),
16-
realm_key: realm.try(:key)
16+
realm_key: realm.try(:key),
17+
parent: self
1718
)
1819
end
1920

lib/metasploit/framework/credential.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def ==(other)
8787
end
8888

8989
def to_credential
90-
self
90+
self.parent = self
91+
self
9192
end
9293

9394
private

lib/metasploit/framework/login_scanner/base.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def each_credential
8383
# This could be a Credential object, or a Credential Core, or an Attempt object
8484
# so make sure that whatever it is, we end up with a Credential.
8585
credential = raw_cred.to_credential
86-
credential.parent = raw_cred
8786

8887
if credential.realm.present? && self.class::REALM_KEY.present?
8988
credential.realm_key = self.class::REALM_KEY

spec/support/shared/examples/credential/core/to_credential.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
).to be_a Metasploit::Framework::Credential
1717
end
1818

19+
it "should set the parent to the credential object" do
20+
expect(
21+
crednetial_core.to_credential.parent
22+
).to eq(crednetial_core)
23+
end
1924
end
2025
end
2126
end

0 commit comments

Comments
 (0)