mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-27 19:04:15 +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:
parent
57809be2ee
commit
e6c86e614a
@ -377,6 +377,11 @@ class Victim:
|
|||||||
|
|
||||||
self.run(f"export PS1='{self.remote_prefix} {self.remote_prompt}'")
|
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)
|
progress.update(task_id, status="spawning pty", advance=1)
|
||||||
|
|
||||||
# At this point, the system is functioning, but we don't have a raw terminal/
|
# At this point, the system is functioning, but we don't have a raw terminal/
|
||||||
@ -404,6 +409,8 @@ class Victim:
|
|||||||
# Open the PTY
|
# Open the PTY
|
||||||
if not isinstance(self.client, paramiko.Channel) and method is not None:
|
if not isinstance(self.client, paramiko.Channel) and method is not None:
|
||||||
self.run(method_cmd, wait=False)
|
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)
|
progress.update(task_id, status="synchronizing prompt", advance=1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user