From db37afa5ce074af8dc837b6259421533ab2bf653 Mon Sep 17 00:00:00 2001 From: John Hammond Date: Sat, 23 May 2020 23:26:21 -0400 Subject: [PATCH] Corrected issues determining if SSH is used to connect --- pwncat/commands/connect.py | 6 ++---- pwncat/remote/victim.py | 11 +++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pwncat/commands/connect.py b/pwncat/commands/connect.py index 9a17aaa..56afa97 100644 --- a/pwncat/commands/connect.py +++ b/pwncat/commands/connect.py @@ -186,15 +186,13 @@ class Command(CommandDefinition): if args.identity: try: # Load the private key for the user - key = paramiko.RSAKey.from_private_key_file( - pwncat.victim.config["privkey"] - ) + key = paramiko.RSAKey.from_private_key_file(args.identity) except: password = prompt( "RSA Private Key Passphrase: ", is_password=True ) key = paramiko.RSAKey.from_private_key_file( - pwncat.victim.config["privkey"], password + args.identity, password ) # Attempt authentication diff --git a/pwncat/remote/victim.py b/pwncat/remote/victim.py index 222b197..9ef96b7 100644 --- a/pwncat/remote/victim.py +++ b/pwncat/remote/victim.py @@ -8,6 +8,7 @@ import sys import time from typing import Dict, Optional, IO, Any, List, Tuple, Iterator, Union +import paramiko import requests from colorama import Fore from sqlalchemy.engine import Engine, create_engine @@ -324,10 +325,12 @@ class Victim: raise RuntimeError("no available methods to spawn a pty!") # Open the PTY - util.info( - f"opening pseudoterminal via {Fore.GREEN}{method}{Fore.RESET}", overlay=True - ) - self.run(method_cmd, wait=False) + if not isinstance(self.client, paramiko.Channel): + util.info( + f"opening pseudoterminal via {Fore.GREEN}{method}{Fore.RESET}", + overlay=True, + ) + self.run(method_cmd, wait=False) # This stuff won't carry through to the PTY, so we need to reset it again. util.info("setting terminal prompt", overlay=True)