Skip to content

Commit 49d0fc3

Browse files
committed
Add support for different realm_key
1 parent c65db18 commit 49d0fc3

File tree

1 file changed

+18
-9
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+18
-9
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,12 @@ def cmd_creds_help
659659
print_line
660660
print_line "Usage - Adding credentials:"
661661
print_line " creds add-ntlm <user> <ntlm hash> [domain]"
662-
print_line " creds add-password <user> <password> [realm]"
663-
print_line " creds add-ssh-key <user> </path/to/id_rsa>"
664-
#print_line "Where [realm type] can be one of:"
665-
#Metasploit::Model::Realm::Key::SHORT_NAMES.each do |short, description|
666-
# print_line " #{short} - #{description}"
667-
#end
662+
print_line " creds add-password <user> <password> [realm] [realm-type]"
663+
print_line " creds add-ssh-key <user> </path/to/id_rsa> [realm-type]"
664+
print_line "Where [realm type] can be one of:"
665+
Metasploit::Model::Realm::Key::SHORT_NAMES.each do |short, description|
666+
print_line " #{short} - #{description}"
667+
end
668668

669669
print_line
670670
print_line "General options"
@@ -693,19 +693,28 @@ def cmd_creds_help
693693
print_line
694694
end
695695

696-
def creds_add(private_type, username, password=nil, realm=nil)
696+
def creds_add(private_type, username, password=nil, realm=nil, realm_type=nil)
697697
cred_data = {
698698
username: username,
699699
private_data: password,
700700
private_type: private_type,
701701
workspace_id: framework.db.workspace,
702702
origin_type: :import,
703-
filename: "MSFCONSOLE"
703+
filename: "msfconsole"
704704
}
705705
if realm
706+
if realm_type
707+
realm_key = Metasploit::Model::Realm::Key::SHORT_NAMES[realm_type]
708+
if realm_key.nil?
709+
valid = Metasploit::Model::Realm::Key::SHORT_NAMES.keys.map{|n|"'#{n}'"}.join(", ")
710+
print_error("Invalid realm type: #{realm_type}. Valid values: #{valid}")
711+
return
712+
end
713+
end
714+
realm_key ||= Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN
706715
cred_data.merge!(
707716
realm_value: realm,
708-
realm_key: Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN
717+
realm_key: realm_key
709718
)
710719
end
711720

0 commit comments

Comments
 (0)