1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 10:54:14 +01:00

Added ability to detect a pty

This stops pwncat from attempting to spawn a pty when one is already
running on the shell.
This commit is contained in:
Caleb Stewart 2020-09-13 14:30:38 -04:00
parent 57809be2ee
commit e6c86e614a

View File

@ -377,6 +377,11 @@ class Victim:
self.run(f"export PS1='{self.remote_prefix} {self.remote_prompt}'")
# This should be valid in any POSIX compliant shell
progress.update(task_id, status="checking for pty")
result = self.run("[ -t 1 ] && echo terminal")
if b"terminal" not in result:
progress.update(task_id, status="spawning pty", advance=1)
# At this point, the system is functioning, but we don't have a raw terminal/
@ -404,6 +409,8 @@ class Victim:
# Open the PTY
if not isinstance(self.client, paramiko.Channel) and method is not None:
self.run(method_cmd, wait=False)
else:
progress.update(task_id, status="pty already running", advance=1)
progress.update(task_id, status="synchronizing prompt", advance=1)