1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-24 01:25:37 +01:00

fix sudo timeout, fix set-password login, other exceptions

This commit is contained in:
trevorbryant 2020-10-05 15:25:38 -04:00
parent c2c83ca058
commit b5ce7f52a4

View File

@ -1783,7 +1783,8 @@ class Victim:
): ):
if send_password and password is None: if send_password and password is None:
self.client.send(util.CTRL_C) self.client.send(util.CTRL_C*2)
self.flush_output()
raise PermissionError(f"{self.current_user.name}: no known password") raise PermissionError(f"{self.current_user.name}: no known password")
self.flush_output() self.flush_output()
@ -1791,23 +1792,28 @@ class Victim:
if send_password: if send_password:
self.client.send(password.encode("utf-8") + b"\n") self.client.send(password.encode("utf-8") + b"\n")
old_timeout = pwncat.victim.client.gettimeout() old_timeout = pwncat.victim.client.gettimeout()
pwncat.victim.client.settimeout(5) pwncat.victim.client.settimeout(5)
output = pwncat.victim.peek_output(some=True) output = pwncat.victim.peek_output(some=True)
pwncat.victim.client.settimeout(old_timeout) pwncat.victim.client.settimeout(old_timeout)
if (
b"[sudo]" in output
or b"password for " in output
or b"sorry," in output
or b"Sorry," in output
or b"sudo: " in output
):
pwncat.victim.client.send(util.CTRL_C)
pwncat.victim.recvuntil(b"\n")
raise PermissionError(
f"{self.current_user.name}: incorrect password/permissions"
)
else:
self.client.send(util.CTRL_C*2)
self.flush_output()
raise PermissionError(f"{self.current_user.name}: no known password")
if (
b"[sudo]" in output
or b"password for " in output
or b"sorry," in output
or b"Sorry," in output
or b"sudo: " in output
):
pwncat.victim.client.send(util.CTRL_C)
pwncat.victim.recvuntil(b"\n")
raise PermissionError(
f"{self.current_user.name}: incorrect password/permissions"
)
if stream: if stream:
return pipe return pipe