From 5bbefd84032802505ae56f53bb189a1bf2eb488b Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sun, 19 Sep 2021 01:32:29 -0400 Subject: [PATCH 1/2] Added checks for open file-like object for ssh --- pwncat/channel/ssh.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pwncat/channel/ssh.py b/pwncat/channel/ssh.py index 8da056f..358659a 100644 --- a/pwncat/channel/ssh.py +++ b/pwncat/channel/ssh.py @@ -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") From 0e8ed033b4fa5c2f8d18162e9e93ccd1243341f7 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sun, 19 Sep 2021 01:36:09 -0400 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e83c51f..5004cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and simply didn't have the time to go back and retroactively create one. - Fixed verbose logging handler to be __unique__ for every `channel` - Fixed docstrings in `Command` modules - Changed docker base image to `python3.9-alpine` to fix python version issues. +- Added logic for calling correct paramiko method when reloading an encrypted SSH privat ekey ([#185](https://github.com/calebstewart/issues/185)). ### Added - Added alternatives to `bash` to be used during _shell upgrade_ for a _better shell_ - Added a warning message when a `KeyboardInterrupt` is caught