Skip to content

Commit

Permalink
PR Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
manishkumarr1017 committed Jun 23, 2023
1 parent 375a91e commit 2e5718d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions lib/msf/ui/console/command_dispatcher/creds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,6 @@ def filtered_query(query, opts, origin_ranges, host_ranges)
# we will not show the cracked password in a seperate row instead we will show in seperate column
if core.origin.kind_of?(Metasploit::Credential::Origin::CrackedPassword) && query.find_by(id: core.origin.metasploit_credential_core_id).present?
next
elsif core.origin.kind_of?(Metasploit::Credential::Origin::CrackedPassword)
core = framework.db.creds.find_by(id: core.origin.metasploit_credential_core_id)
end

# Exclude non-blank username creds if that's what we're after
Expand All @@ -582,7 +580,17 @@ def filtered_query(query, opts, origin_ranges, host_ranges)
next
end

cracked_password_core = core.public.cores.where(origin_type: "Metasploit::Credential::Origin::CrackedPassword").joins("LEFT JOIN metasploit_credential_origin_cracked_passwords ON metasploit_credential_origin_cracked_passwords.id = metasploit_credential_cores.origin_id").find_by("metasploit_credential_origin_cracked_passwords.metasploit_credential_core_id = (?)", core.id)
# this is a direct rails interaction that cannot cross the json db service layer, access of origin objects may be problematic
cracked_password_core = nil

if !core.origin.kind_of?(Metasploit::Credential::Origin::CrackedPassword) && core.public.cores.count > 1
core.public.cores.each do |potential_cracked_core|
next unless potential_cracked_core.origin.kind_of?(Metasploit::Credential::Origin::CrackedPassword)
if potential_cracked_core.origin.originating_core == core
cracked_password_core = potential_cracked_core
end
end
end

if core.logins.empty?
service = service_from_origin(core)
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/msf/ui/console/command_dispatcher/creds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@
"Credentials",
"===========",
"",
"host origin service public private realm private_type JtR Format cracked_password",
"---- ------ ------- ------ ------- ----- ------------ ---------- ----------------",
" thisuser thispass Password ",
" this_username some_hash Nonreplayable hash this_cracked_password"
"host origin service public private realm private_type JtR Format cracked_password",
"---- ------ ------- ------ ------- ----- ------------ ---------- ----------------",
" thisuser thispass Password ",
" this_username this_cracked_password Password "
])
end
end
Expand Down

0 comments on commit 2e5718d

Please sign in to comment.