mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-24 01:25:37 +01:00
Fixed ChannelError constructor calls
There is a missing argument to the ChannelError constructor - ch (channel). Because of this, many explicitly passed error messages are simply rejected. There is a minor typo correction as well, 'writiers' -> 'writers'.
This commit is contained in:
parent
89ad889977
commit
6b8a956c54
@ -37,7 +37,17 @@ class Connect(Socket):
|
|||||||
) as progress:
|
) as progress:
|
||||||
progress.add_task("connecting", total=1, start=False)
|
progress.add_task("connecting", total=1, start=False)
|
||||||
# Connect to the remote host
|
# Connect to the remote host
|
||||||
|
|
||||||
|
# If we get an invalid host from the user, that cannot be resolved
|
||||||
|
# then we capture the GAI (getaddrinfo) exception and raise it as ChannelError
|
||||||
|
# so that it is handled properly by the parent methods
|
||||||
|
|
||||||
|
try:
|
||||||
client = socket.create_connection((host, port))
|
client = socket.create_connection((host, port))
|
||||||
|
except socket.gaierror:
|
||||||
|
raise ChannelError(self, "invalid host provided")
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
raise ChannelError(self, "connection refused, check your port")
|
||||||
|
|
||||||
progress.log(
|
progress.log(
|
||||||
f"connection to "
|
f"connection to "
|
||||||
|
@ -34,7 +34,7 @@ class Ssh(Channel):
|
|||||||
port = 22
|
port = 22
|
||||||
|
|
||||||
if not user or user is None:
|
if not user or user is None:
|
||||||
raise ChannelError("you must specify a user")
|
raise ChannelError(self, "you must specify a user")
|
||||||
|
|
||||||
if password is None and identity is None:
|
if password is None and identity is None:
|
||||||
password = prompt("Password: ", is_password=True)
|
password = prompt("Password: ", is_password=True)
|
||||||
@ -43,7 +43,7 @@ class Ssh(Channel):
|
|||||||
# Connect to the remote host's ssh server
|
# Connect to the remote host's ssh server
|
||||||
sock = socket.create_connection((host, port))
|
sock = socket.create_connection((host, port))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise ChannelError(str(exc))
|
raise ChannelError(self, str(exc))
|
||||||
|
|
||||||
# Create a paramiko SSH transport layer around the socket
|
# Create a paramiko SSH transport layer around the socket
|
||||||
t = paramiko.Transport(sock)
|
t = paramiko.Transport(sock)
|
||||||
@ -51,7 +51,7 @@ class Ssh(Channel):
|
|||||||
t.start_client()
|
t.start_client()
|
||||||
except paramiko.SSHException:
|
except paramiko.SSHException:
|
||||||
sock.close()
|
sock.close()
|
||||||
raise ChannelError("ssh negotiation failed")
|
raise ChannelError(self, "ssh negotiation failed")
|
||||||
|
|
||||||
if identity is not None:
|
if identity is not None:
|
||||||
try:
|
try:
|
||||||
@ -67,23 +67,23 @@ class Ssh(Channel):
|
|||||||
try:
|
try:
|
||||||
key = paramiko.RSAKey.from_private_key_file(identity, password)
|
key = paramiko.RSAKey.from_private_key_file(identity, password)
|
||||||
except paramiko.ssh_exception.SSHException:
|
except paramiko.ssh_exception.SSHException:
|
||||||
raise ChannelError("invalid private key or passphrase")
|
raise ChannelError(self, "invalid private key or passphrase")
|
||||||
|
|
||||||
# Attempt authentication
|
# Attempt authentication
|
||||||
try:
|
try:
|
||||||
t.auth_publickey(user, key)
|
t.auth_publickey(user, key)
|
||||||
except paramiko.ssh_exception.AuthenticationException as exc:
|
except paramiko.ssh_exception.AuthenticationException as exc:
|
||||||
raise ChannelError(str(exc))
|
raise ChannelError(self, str(exc))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
t.auth_password(user, password)
|
t.auth_password(user, password)
|
||||||
except paramiko.ssh_exception.AuthenticationException as exc:
|
except paramiko.ssh_exception.AuthenticationException as exc:
|
||||||
raise ChannelError(str(exc))
|
raise ChannelError(self, str(exc))
|
||||||
|
|
||||||
if not t.is_authenticated():
|
if not t.is_authenticated():
|
||||||
t.close()
|
t.close()
|
||||||
sock.close()
|
sock.close()
|
||||||
raise ChannelError("authentication failed")
|
raise ChannelError(self, "authentication failed")
|
||||||
|
|
||||||
# Open an interactive session
|
# Open an interactive session
|
||||||
chan = t.open_session()
|
chan = t.open_session()
|
||||||
|
@ -653,7 +653,11 @@ class Manager:
|
|||||||
specified platform.
|
specified platform.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
session = Session(self, platform, channel, **kwargs)
|
session = Session(self, platform, channel, **kwargs)
|
||||||
|
except ChannelError as exc:
|
||||||
|
self.log(f"[red]error:[/red] {exc}")
|
||||||
|
return None
|
||||||
|
|
||||||
# Increment the ``session_id`` variable upon adding a new session
|
# Increment the ``session_id`` variable upon adding a new session
|
||||||
# Session constructor will automatically grab the current
|
# Session constructor will automatically grab the current
|
||||||
|
@ -1249,7 +1249,7 @@ class Linux(Platform):
|
|||||||
except MissingBinary:
|
except MissingBinary:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise PlatformError("no available gtfobins writiers")
|
raise PlatformError("no available gtfobins writers")
|
||||||
|
|
||||||
popen = self.Popen(
|
popen = self.Popen(
|
||||||
payload,
|
payload,
|
||||||
@ -1278,7 +1278,7 @@ class Linux(Platform):
|
|||||||
except MissingBinary:
|
except MissingBinary:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise PlatformError("no available gtfobins writiers")
|
raise PlatformError("no available gtfobins writers")
|
||||||
|
|
||||||
popen = self.Popen(
|
popen = self.Popen(
|
||||||
payload,
|
payload,
|
||||||
|
Loading…
Reference in New Issue
Block a user