1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-24 01:25:37 +01:00

Added checks for open file-like object for ssh

This commit is contained in:
Caleb Stewart 2021-09-19 01:32:29 -04:00
parent e9e72e3e49
commit 5bbefd8403

View File

@ -65,7 +65,12 @@ class Ssh(Channel):
except paramiko.ssh_exception.SSHException:
password = prompt("RSA Private Key Passphrase: ", is_password=True)
try:
key = paramiko.RSAKey.from_private_key_file(identity, password)
if isinstance(identity, str):
key = paramiko.RSAKey.from_private_key_file(identity, password)
else:
# Seek back to the beginning of the file (the above load read the whole file)
identity.seek(0)
key = paramiko.RSAKey.from_private_key(identity, password)
except paramiko.ssh_exception.SSHException:
raise ChannelError(self, "invalid private key or passphrase")