lib/metasploit/credential/migrator.rb in metasploit-credential-0.8.8 vs lib/metasploit/credential/migrator.rb in metasploit-credential-0.8.9
- old
+ new
@@ -93,12 +93,16 @@
# Returns the text of the SSH key as read from the file
# @param path [String] Path to an SSH key file on disk
# @return [String]
def key_data_from_file(path)
- File.open(path) do |file|
- file.read
+ # Sometimes we will set the :pass attribute to a file path containing the key
+ if File.exists?(path)
+ File.read(path)
+ # In other cases we store the entire SSH key directly in the :pass attribute
+ elsif Metasploit::Credential::SSHKey.new(data: path).private?
+ path
end
end
# Returns private data given an `Mdm::Cred`
# @param cred [Mdm::Cred]
@@ -110,6 +114,6 @@
else
cred.pass
end
end
-end
\ No newline at end of file
+end