@@ -659,12 +659,12 @@ def cmd_creds_help
659
659
print_line
660
660
print_line "Usage - Adding credentials:"
661
661
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
668
668
669
669
print_line
670
670
print_line "General options"
@@ -693,19 +693,28 @@ def cmd_creds_help
693
693
print_line
694
694
end
695
695
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 )
697
697
cred_data = {
698
698
username : username ,
699
699
private_data : password ,
700
700
private_type : private_type ,
701
701
workspace_id : framework . db . workspace ,
702
702
origin_type : :import ,
703
- filename : "MSFCONSOLE "
703
+ filename : "msfconsole "
704
704
}
705
705
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
706
715
cred_data . merge! (
707
716
realm_value : realm ,
708
- realm_key : Metasploit :: Model :: Realm :: Key :: ACTIVE_DIRECTORY_DOMAIN
717
+ realm_key : realm_key
709
718
)
710
719
end
711
720
0 commit comments